This repository was archived by the owner on May 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathscalehls.patch
186 lines (177 loc) · 5.58 KB
/
scalehls.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
Index: build-scalehls.sh
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/build-scalehls.sh b/build-scalehls.sh
--- a/build-scalehls.sh (revision d6ffcd0c5b2fa67c624a500365a3cc95942d91c0)
+++ b/build-scalehls.sh (date 1665765846483)
@@ -85,20 +85,7 @@
# Run building.
if [ "${CMAKE_GENERATOR}" == "Ninja" ]; then
ninja
- ninja check-mlir-clang
else
make -j "$(nproc)"
- make -j "$(nproc)" check-mlir-clang
fi
-echo ""
-echo ">>> ScaleHLS check..."
-echo ""
-
-cd "${SCALEHLS_DIR}/build"
-
-if [ "${CMAKE_GENERATOR}" == "Ninja" ]; then
- ninja check-scalehls
-else
- make -j "$(nproc)" check-scalehls
-fi
Index: lib/Translation/EmitHLSCpp.cpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/Translation/EmitHLSCpp.cpp b/lib/Translation/EmitHLSCpp.cpp
--- a/lib/Translation/EmitHLSCpp.cpp (revision d6ffcd0c5b2fa67c624a500365a3cc95942d91c0)
+++ b/lib/Translation/EmitHLSCpp.cpp (date 1666213189110)
@@ -1488,6 +1488,13 @@
}
os << "};";
emitInfoAndNewLine(op);
+
+ if (op.getResult().getType().isa<ShapedType>()) {
+ indent();
+ indent() << "#pragma HLS array_partition variable=";
+ emitValue(op.getResult());
+ os << " complete dim=0\n";
+ }
} else
emitError(op, "has unsupported constant type.");
}
@@ -1629,49 +1636,55 @@
auto layoutMap = type.getLayout().getAffineMap();
// Emit array_partition pragma(s).
- SmallVector<int64_t, 8> factors;
- getPartitionFactors(type, &factors);
+// SmallVector<int64_t, 8> factors;
+// getPartitionFactors(type, &factors);
+//
+// for (int64_t dim = 0; dim < type.getRank(); ++dim) {
+// if (factors[dim] != 1) {
+// emitPragmaFlag = true;
+//
+// indent() << "#pragma HLS array_partition";
+// os << " variable=";
+// emitValue(memref);
+//
+// // Emit partition type.
+// if (layoutMap.getResult(dim).getKind() == AffineExprKind::FloorDiv)
+// os << " block";
+// else
+// os << " cyclic";
+//
+// os << " factor=" << factors[dim];
+// os << " dim=" << dim + 1 << "\n";
+// }
+// }
- for (int64_t dim = 0; dim < type.getRank(); ++dim) {
- if (factors[dim] != 1) {
- emitPragmaFlag = true;
-
- indent() << "#pragma HLS array_partition";
- os << " variable=";
- emitValue(memref);
+ emitPragmaFlag = true;
+ indent() << "#pragma HLS array_partition variable=";
+ emitValue(memref);
+ os << " complete dim=0\n";
- // Emit partition type.
- if (layoutMap.getResult(dim).getKind() == AffineExprKind::FloorDiv)
- os << " block";
- else
- os << " cyclic";
-
- os << " factor=" << factors[dim];
- os << " dim=" << dim + 1 << "\n";
- }
- }
// Emit resource pragma when the array is not DRAM kind and is not fully
// partitioned.
auto kind = MemoryKind(type.getMemorySpaceAsInt());
- if (kind != MemoryKind::DRAM && !isFullyPartitioned(type)) {
- emitPragmaFlag = true;
-
- indent() << "#pragma HLS resource";
- os << " variable=";
- emitValue(memref);
-
- os << " core=";
- if (kind == MemoryKind::BRAM_1P)
- os << "ram_1p_bram";
- else if (kind == MemoryKind::BRAM_S2P)
- os << "ram_s2p_bram";
- else if (kind == MemoryKind::BRAM_T2P)
- os << "ram_t2p_bram";
- else
- os << "ram_s2p_bram";
- os << "\n";
- }
+// if (kind != MemoryKind::DRAM && !isFullyPartitioned(type)) {
+// emitPragmaFlag = true;
+//
+// indent() << "#pragma HLS resource";
+// os << " variable=";
+// emitValue(memref);
+//
+// os << " core=";
+// if (kind == MemoryKind::BRAM_1P)
+// os << "ram_1p_bram";
+// else if (kind == MemoryKind::BRAM_S2P)
+// os << "ram_s2p_bram";
+// else if (kind == MemoryKind::BRAM_T2P)
+// os << "ram_t2p_bram";
+// else
+// os << "ram_s2p_bram";
+// os << "\n";
+// }
// Emit an empty line.
if (emitPragmaFlag)
@@ -1732,6 +1745,10 @@
if (port.getType().isa<MemRefType>())
emitArrayDirectives(port);
}
+
+ for (auto &port : portList)
+ if (port.getType().isa<MemRefType>())
+ emitArrayDirectives(port);
auto funcDirect = getFuncDirective(func);
if (!funcDirect)
Index: lib/Transforms/Passes.cpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/Transforms/Passes.cpp b/lib/Transforms/Passes.cpp
--- a/lib/Transforms/Passes.cpp (revision d6ffcd0c5b2fa67c624a500365a3cc95942d91c0)
+++ b/lib/Transforms/Passes.cpp (date 1665765882767)
@@ -13,6 +13,7 @@
#include "mlir/Dialect/MemRef/Transforms/Passes.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Transforms/Passes.h"
+#include "mlir/Dialect/Func/IR/FuncOps.h"
using namespace mlir;
using namespace scalehls;
@@ -111,11 +112,12 @@
if (dataflowGran)
pm.addPass(
scalehls::createFuncDataflowPass(opts.hlsTopFunc, dataflowGran));
+
pm.addPass(mlir::createCanonicalizerPass());
- pm.addPass(tosa::createTosaToLinalgNamed());
+ pm.addNestedPass<FuncOp>(tosa::createTosaToLinalgNamed());
pm.addPass(mlir::createCanonicalizerPass());
pm.addPass(scalehls::createTosaToLinalgCleanupPass());
- pm.addPass(tosa::createTosaToLinalg());
+ pm.addNestedPass<FuncOp>(tosa::createTosaToLinalg());
pm.addPass(tosa::createTosaToStandard());
// Create runtime main function.