[Transforms] Rename from setParallel/Point/TopFunc to setParallel/Point/TopFuncAttr
This commit is contained in:
parent
bc4dc1cf84
commit
36f748175e
|
@ -28,12 +28,12 @@ LoopInfoAttr getLoopInfo(Operation *op);
|
||||||
|
|
||||||
/// Parse loop directives.
|
/// Parse loop directives.
|
||||||
LoopDirectiveAttr getLoopDirective(Operation *op);
|
LoopDirectiveAttr getLoopDirective(Operation *op);
|
||||||
bool isParallel(AffineForOp loop);
|
bool hasParallelAttr(AffineForOp loop);
|
||||||
bool isPoint(AffineForOp loop);
|
bool hasPointAttr(AffineForOp loop);
|
||||||
|
|
||||||
/// Parse function directives.
|
/// Parse function directives.
|
||||||
FuncDirectiveAttr getFuncDirective(Operation *op);
|
FuncDirectiveAttr getFuncDirective(Operation *op);
|
||||||
bool isTopFunc(FuncOp func);
|
bool hasTopFuncAttr(FuncOp func);
|
||||||
|
|
||||||
/// Parse array attributes.
|
/// Parse array attributes.
|
||||||
SmallVector<int64_t, 8> getIntArrayAttrValue(Operation *op, StringRef name);
|
SmallVector<int64_t, 8> getIntArrayAttrValue(Operation *op, StringRef name);
|
||||||
|
|
|
@ -37,14 +37,14 @@ void setLoopInfo(Operation *op, int64_t flattenTripCount, int64_t iterLatency,
|
||||||
void setLoopDirective(Operation *op, LoopDirectiveAttr loopDirective);
|
void setLoopDirective(Operation *op, LoopDirectiveAttr loopDirective);
|
||||||
void setLoopDirective(Operation *op, bool pipeline, int64_t targetII,
|
void setLoopDirective(Operation *op, bool pipeline, int64_t targetII,
|
||||||
bool dataflow, bool flatten);
|
bool dataflow, bool flatten);
|
||||||
void setParallel(AffineForOp loop);
|
void setParallelAttr(AffineForOp loop);
|
||||||
void setPoint(AffineForOp loop);
|
void setPointAttr(AffineForOp loop);
|
||||||
|
|
||||||
/// Set function directives.
|
/// Set function directives.
|
||||||
void setFuncDirective(Operation *op, FuncDirectiveAttr FuncDirective);
|
void setFuncDirective(Operation *op, FuncDirectiveAttr FuncDirective);
|
||||||
void setFuncDirective(Operation *op, bool pipeline, int64_t targetInterval,
|
void setFuncDirective(Operation *op, bool pipeline, int64_t targetInterval,
|
||||||
bool dataflow);
|
bool dataflow);
|
||||||
void setTopFunc(FuncOp func);
|
void setTopFuncAttr(FuncOp func);
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Loop transform utils
|
// Loop transform utils
|
||||||
|
|
|
@ -38,11 +38,11 @@ LoopDirectiveAttr scalehls::getLoopDirective(Operation *op) {
|
||||||
return op->getAttrOfType<LoopDirectiveAttr>("loop_directive");
|
return op->getAttrOfType<LoopDirectiveAttr>("loop_directive");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool scalehls::isParallel(AffineForOp loop) {
|
bool scalehls::hasParallelAttr(AffineForOp loop) {
|
||||||
return loop->hasAttrOfType<UnitAttr>("parallel");
|
return loop->hasAttrOfType<UnitAttr>("parallel");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool scalehls::isPoint(AffineForOp loop) {
|
bool scalehls::hasPointAttr(AffineForOp loop) {
|
||||||
return loop->hasAttrOfType<UnitAttr>("point");
|
return loop->hasAttrOfType<UnitAttr>("point");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ FuncDirectiveAttr scalehls::getFuncDirective(Operation *op) {
|
||||||
return op->getAttrOfType<FuncDirectiveAttr>("func_directive");
|
return op->getAttrOfType<FuncDirectiveAttr>("func_directive");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool scalehls::isTopFunc(FuncOp func) {
|
bool scalehls::hasTopFuncAttr(FuncOp func) {
|
||||||
return func->hasAttrOfType<UnitAttr>("top_func");
|
return func->hasAttrOfType<UnitAttr>("top_func");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ bool scalehls::checkDependence(Operation *A, Operation *B) {
|
||||||
// Traverse each loop level to find dependencies.
|
// Traverse each loop level to find dependencies.
|
||||||
for (unsigned depth = numCommonLoops; depth > 0; depth--) {
|
for (unsigned depth = numCommonLoops; depth > 0; depth--) {
|
||||||
// Skip all parallel loop level.
|
// Skip all parallel loop level.
|
||||||
if (isParallel(commonLoops[depth - 1]))
|
if (hasParallelAttr(commonLoops[depth - 1]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FlatAffineValueConstraints depConstrs;
|
FlatAffineValueConstraints depConstrs;
|
||||||
|
|
|
@ -433,7 +433,7 @@ struct ArrayPartition : public ArrayPartitionBase<ArrayPartition> {
|
||||||
if (func.getName() == "main") {
|
if (func.getName() == "main") {
|
||||||
topFunc = func;
|
topFunc = func;
|
||||||
break;
|
break;
|
||||||
} else if (isTopFunc(func))
|
} else if (hasTopFuncAttr(func))
|
||||||
topFunc = func;
|
topFunc = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,12 +65,12 @@ bool scalehls::applyLegalizeToHLSCpp(FuncOp func, bool isTopFunc,
|
||||||
|
|
||||||
// Set top function attribute.
|
// Set top function attribute.
|
||||||
if (isTopFunc)
|
if (isTopFunc)
|
||||||
setTopFunc(func);
|
setTopFuncAttr(func);
|
||||||
|
|
||||||
// Set parallel attribute to each loop that is applicable.
|
// Set parallel attribute to each loop that is applicable.
|
||||||
func.walk([&](AffineForOp loop) {
|
func.walk([&](AffineForOp loop) {
|
||||||
if (isLoopParallel(loop))
|
if (isLoopParallel(loop))
|
||||||
setParallel(loop);
|
setParallelAttr(loop);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (axiInterf) {
|
if (axiInterf) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ bool scalehls::applyLoopTiling(AffineLoopBand &band, TileList tileList) {
|
||||||
auto originalBandSize = band.size();
|
auto originalBandSize = band.size();
|
||||||
SmallVector<bool, 6> parallelFlags;
|
SmallVector<bool, 6> parallelFlags;
|
||||||
for (auto loop : band)
|
for (auto loop : band)
|
||||||
parallelFlags.push_back(isParallel(loop));
|
parallelFlags.push_back(hasParallelAttr(loop));
|
||||||
|
|
||||||
// Apply loop tiling.
|
// Apply loop tiling.
|
||||||
AffineLoopBand tiledBand;
|
AffineLoopBand tiledBand;
|
||||||
|
@ -38,7 +38,7 @@ bool scalehls::applyLoopTiling(AffineLoopBand &band, TileList tileList) {
|
||||||
band.resize(originalBandSize);
|
band.resize(originalBandSize);
|
||||||
for (auto zip : llvm::zip(band, parallelFlags))
|
for (auto zip : llvm::zip(band, parallelFlags))
|
||||||
if (std::get<1>(zip))
|
if (std::get<1>(zip))
|
||||||
setParallel(std::get<0>(zip));
|
setParallelAttr(std::get<0>(zip));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ struct AffineLoopTileAndAnnotate
|
||||||
|
|
||||||
// Annotate point loops.
|
// Annotate point loops.
|
||||||
for (auto loop : llvm::drop_begin(tiledNest, band.size()))
|
for (auto loop : llvm::drop_begin(tiledNest, band.size()))
|
||||||
setPoint(loop);
|
setPointAttr(loop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -892,7 +892,7 @@ struct MultipleLevelDSE : public MultipleLevelDSEBase<MultipleLevelDSE> {
|
||||||
// Optimize the top function.
|
// Optimize the top function.
|
||||||
// TODO: Support to contain sub-functions.
|
// TODO: Support to contain sub-functions.
|
||||||
for (auto func : module.getOps<FuncOp>()) {
|
for (auto func : module.getOps<FuncOp>()) {
|
||||||
if (isTopFunc(func))
|
if (hasTopFuncAttr(func))
|
||||||
optimizer.applyMultipleLevelDSE(func, directiveOnly, outputPath,
|
optimizer.applyMultipleLevelDSE(func, directiveOnly, outputPath,
|
||||||
csvPath);
|
csvPath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,7 @@ int64_t ScaleHLSEstimator::getDepMinII(int64_t II, AffineForOp forOp,
|
||||||
for (unsigned i = 1, e = band.size(); i <= e; ++i) {
|
for (unsigned i = 1, e = band.size(); i <= e; ++i) {
|
||||||
auto loop = band[i - 1];
|
auto loop = band[i - 1];
|
||||||
auto loopDirect = getLoopDirective(loop);
|
auto loopDirect = getLoopDirective(loop);
|
||||||
if (!isParallel(forOp) && loopDirect)
|
if (!hasParallelAttr(forOp) && loopDirect)
|
||||||
if (loopDirect.getFlatten() || loopDirect.getPipeline())
|
if (loopDirect.getFlatten() || loopDirect.getPipeline())
|
||||||
loopDepths.push_back(i);
|
loopDepths.push_back(i);
|
||||||
}
|
}
|
||||||
|
@ -702,7 +702,8 @@ TimingAttr ScaleHLSEstimator::estimateBlock(Block &block, int64_t begin) {
|
||||||
|
|
||||||
for (unsigned depth = 1; depth <= loopDepth + 1; ++depth) {
|
for (unsigned depth = 1; depth <= loopDepth + 1; ++depth) {
|
||||||
// Skip all parallel loop level.
|
// Skip all parallel loop level.
|
||||||
if (depth != loopDepth + 1 && isParallel(commonLoops[depth - 1]))
|
if (depth != loopDepth + 1 &&
|
||||||
|
hasParallelAttr(commonLoops[depth - 1]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FlatAffineValueConstraints dependConstrs;
|
FlatAffineValueConstraints dependConstrs;
|
||||||
|
@ -978,7 +979,7 @@ struct QoREstimation : public scalehls::QoREstimationBase<QoREstimation> {
|
||||||
// called by the top function, it will be estimated in the procedure of
|
// called by the top function, it will be estimated in the procedure of
|
||||||
// estimating the top function.
|
// estimating the top function.
|
||||||
for (auto func : module.getOps<FuncOp>())
|
for (auto func : module.getOps<FuncOp>())
|
||||||
if (isTopFunc(func))
|
if (hasTopFuncAttr(func))
|
||||||
ScaleHLSEstimator(latencyMap, dspUsageMap, true).estimateFunc(func);
|
ScaleHLSEstimator(latencyMap, dspUsageMap, true).estimateFunc(func);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,11 +67,11 @@ void scalehls::setLoopDirective(Operation *op, bool pipeline, int64_t targetII,
|
||||||
setLoopDirective(op, loopDirective);
|
setLoopDirective(op, loopDirective);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scalehls::setParallel(AffineForOp loop) {
|
void scalehls::setParallelAttr(AffineForOp loop) {
|
||||||
loop->setAttr("parallel", UnitAttr::get(loop.getContext()));
|
loop->setAttr("parallel", UnitAttr::get(loop.getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void scalehls::setPoint(AffineForOp loop) {
|
void scalehls::setPointAttr(AffineForOp loop) {
|
||||||
loop->setAttr("point", UnitAttr::get(loop.getContext()));
|
loop->setAttr("point", UnitAttr::get(loop.getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ void scalehls::setFuncDirective(Operation *op, bool pipeline,
|
||||||
setFuncDirective(op, funcDirective);
|
setFuncDirective(op, funcDirective);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scalehls::setTopFunc(FuncOp func) {
|
void scalehls::setTopFuncAttr(FuncOp func) {
|
||||||
func->setAttr("top_func", UnitAttr::get(func.getContext()));
|
func->setAttr("top_func", UnitAttr::get(func.getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1659,7 +1659,7 @@ void ModuleEmitter::emitArrayDirectives(Value memref) {
|
||||||
void ModuleEmitter::emitFunctionDirectives(FuncOp func,
|
void ModuleEmitter::emitFunctionDirectives(FuncOp func,
|
||||||
ArrayRef<Value> portList) {
|
ArrayRef<Value> portList) {
|
||||||
// Only top function should emit interface pragmas.
|
// Only top function should emit interface pragmas.
|
||||||
if (isTopFunc(func)) {
|
if (hasTopFuncAttr(func)) {
|
||||||
indent();
|
indent();
|
||||||
os << "#pragma HLS interface s_axilite port=return bundle=ctrl\n";
|
os << "#pragma HLS interface s_axilite port=return bundle=ctrl\n";
|
||||||
|
|
||||||
|
@ -1729,7 +1729,7 @@ void ModuleEmitter::emitFunction(FuncOp func) {
|
||||||
if (func.getBlocks().size() != 1)
|
if (func.getBlocks().size() != 1)
|
||||||
emitError(func, "has zero or more than one basic blocks.");
|
emitError(func, "has zero or more than one basic blocks.");
|
||||||
|
|
||||||
if (isTopFunc(func))
|
if (hasTopFuncAttr(func))
|
||||||
os << "/// This is top function.\n";
|
os << "/// This is top function.\n";
|
||||||
|
|
||||||
if (auto timing = getTiming(func)) {
|
if (auto timing = getTiming(func)) {
|
||||||
|
|
Loading…
Reference in New Issue