Skip to content

Commit 68829b7

Browse files
authored
Merge pull request coredac#232 from ShangkunLi/task-graph
Initialize the taskflow dialect for multi-CGRA/spatial accelerator scenarios
2 parents 6657186 + c5de038 commit 68829b7

26 files changed

Lines changed: 1045 additions & 18 deletions

File tree

.github/workflows/main.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
python-version: ["3.12.8"]
26+
python-version: ["3.11.13"]
2727

2828
steps:
2929
- uses: actions/checkout@v3
@@ -132,6 +132,23 @@ jobs:
132132
# sh script.sh
133133
# ./simulate
134134
135+
# Sets up Python environment for torch-mlir
136+
- name: Set up Python ${{ matrix.python-version }}
137+
uses: actions/setup-python@v4
138+
with:
139+
python-version: ${{ matrix.python-version }}
140+
# Installs NumPy 1.x first (compatable with torch-mlir)
141+
- name: Install NumPy 1.x
142+
run: pip install "numpy<2.0"
143+
- name: Install PyTorch
144+
run: |
145+
wget https://github.com/llvm/torch-mlir/releases/download/snapshot-20231229.1067/torch-2.2.0.dev20231204+cpu-cp311-cp311-linux_x86_64.whl
146+
pip install torch-2.2.0.dev20231204+cpu-cp311-cp311-linux_x86_64.whl
147+
- name: Install torch-mlir
148+
run: |
149+
wget https://github.com/llvm/torch-mlir/releases/download/snapshot-20231229.1067/torch_mlir-20231229.1067-cp311-cp311-linux_x86_64.whl
150+
pip install torch_mlir-20231229.1067-cp311-cp311-linux_x86_64.whl
151+
135152
# shows ccache stats to verify it's working.
136153
- name: ccache stats
137154
run: ccache -s

include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
add_subdirectory(NeuraDialect)
2+
add_subdirectory(TaskflowDialect)
23
add_subdirectory(Conversion)

include/Conversion/ConversionPasses.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ namespace mlir {
1313
#define GEN_PASS_DECL
1414
#include "Conversion/ConversionPasses.h.inc"
1515

16-
// Conversion passes.
16+
// Neura Conversion Passes.
1717
std::unique_ptr<mlir::Pass> createLowerArithToNeuraPass();
1818
std::unique_ptr<mlir::Pass> createLowerLlvmToNeuraPass();
1919
std::unique_ptr<mlir::Pass> createLowerMemRefToNeuraPass();
2020
std::unique_ptr<mlir::Pass> createLowerBuiltinToNeuraPass();
2121
std::unique_ptr<mlir::Pass> createLowerAffineToNeuraPass();
2222

23+
// TaskFlow Conversion Passes.
24+
std::unique_ptr<mlir::Pass> createConvertLinalgToTaskflowPass();
2325
#define GEN_PASS_REGISTRATION
2426
#include "Conversion/ConversionPasses.h.inc"
2527

include/Conversion/ConversionPasses.td

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
include "mlir/Pass/PassBase.td"
77

88
//=========================================================//
9-
// Conversion passes
9+
// Neura Conversion Passes.
1010
//=========================================================//
1111
def LowerArithToNeura : Pass<"lower-arith-to-neura", "FuncOp">{
1212
let summary = "Lower arith to Neura dialect";
@@ -44,4 +44,21 @@ def LowerAffineToNeura : Pass<"lower-affine-to-neura", "func::FuncOp">{
4444
let dependentDialects = ["mlir::neura::NeuraDialect", "mlir::affine::AffineDialect"];
4545
}
4646

47+
//=========================================================//
48+
// TaskFlow Conversion Passes.
49+
//=========================================================//
50+
def ConvertLinalgToTaskflow : Pass<"convert-linalg-to-taskflow", "ModuleOp">{
51+
let summary = "Convert Linalg operations to Taskflow dialect";
52+
let description = [{
53+
Extracts compute-intensive linalg operations and wraps them into a Taskflow graph for spatial architecture execution.
54+
}];
55+
let constructor = "mlir::createConvertLinalgToTaskflowPass()";
56+
let dependentDialects = [
57+
"mlir::taskflow::TaskflowDialect",
58+
"mlir::linalg::LinalgDialect",
59+
"mlir::func::FuncDialect",
60+
"mlir::arith::ArithDialect"
61+
];
62+
}
63+
4764
#endif // CONVERSION_PASSES_TD

include/NeuraDialect/Neura.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ include "NeuraOps.td"
66
include "NeuraPasses.td"
77
include "NeuraTypes.td"
88

9-
#endif // GRAPH_TD
9+
#endif // NEURA_TD
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_mlir_dialect(Taskflow taskflow)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef TASKFLOW_TD
2+
#define TASKFLOW_TD
3+
4+
include "TaskflowDialect.td"
5+
include "TaskflowOps.td"
6+
7+
#endif // TASKFLOW_TD
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef TASKFLOW_DIALECT_H
2+
#define TASKFLOW_DIALECT_H
3+
4+
#include "mlir/IR/Dialect.h"
5+
#include "mlir/IR/OpDefinition.h"
6+
7+
namespace mlir {
8+
namespace taskflow {
9+
class TaskflowDialect;
10+
} // End namespace taskflow.
11+
} // End namespace mlir.
12+
13+
#include "TaskflowDialect/TaskflowDialect.h.inc"
14+
#endif // TASKFLOW_DIALECT_H
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// TaskflowDialect.td - TableGen description of the dialect.
2+
#ifndef TASKFLOW_DIALECT_TD
3+
#define TASKFLOW_DIALECT_TD
4+
5+
include "mlir/IR/OpBase.td"
6+
include "mlir/IR/DialectBase.td"
7+
include "mlir/IR/AttrTypeBase.td"
8+
9+
// Defines the Taskflow dialect.
10+
def TaskflowDialect : Dialect {
11+
let name = "taskflow";
12+
let cppNamespace = "::mlir::taskflow";
13+
14+
let summary = "A computation abstraction dialect for both scale-out and scale-up spatial architectures.";
15+
let description = [{
16+
This dialect provides abstractions for expressing task-based computations
17+
suitable for execution on various spatial architectures.
18+
}];
19+
20+
let useDefaultTypePrinterParser = 1;
21+
let useDefaultAttributePrinterParser = 1;
22+
}
23+
24+
#endif // TASKFLOW_DIALECT_TD
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// TaskFlowOps.h - TaskFlow dialect operations.
2+
#ifndef TASKFLOW_OPS_H
3+
#define TASKFLOW_OPS_H
4+
5+
#include "TaskflowDialect/TaskflowTypes.h"
6+
#include "mlir/IR/Builders.h"
7+
#include "mlir/IR/BuiltinOps.h"
8+
#include "mlir/IR/DialectImplementation.h"
9+
#include "mlir/IR/OpDefinition.h"
10+
#include "mlir/Interfaces/ControlFlowInterfaces.h"
11+
#include "mlir/Interfaces/SideEffectInterfaces.h"
12+
13+
// First includes the interface declarations.
14+
#define GET_OP_INTERFACE_CLASSES
15+
#include "TaskflowDialect/Taskflow.h.inc"
16+
#undef GET_OP_INTERFACE_CLASSES
17+
18+
// Then includes the op declarations.
19+
#define GET_OP_DECLARATIONS
20+
#include "TaskflowDialect/Taskflow.h.inc"
21+
#undef GET_OP_DECLARATIONS
22+
23+
// Finally includes the op definitions.
24+
#define GET_OP_CLASSES
25+
#include "TaskflowDialect/Taskflow.h.inc"
26+
#undef GET_OP_CLASSES
27+
28+
#endif // TASKFLOW_OPS_H

0 commit comments

Comments
 (0)