[HLSCppDialect] refine parameter operations definition; create seperate attributes tablegen

This commit is contained in:
Hanchen Ye 2020-09-20 02:05:58 -05:00
parent f472053e58
commit e1b878e845
10 changed files with 199 additions and 60 deletions

View File

@ -0,0 +1,60 @@
//===-------------------------------------------------------*- tablegen -*-===//
//
//===----------------------------------------------------------------------===//
#ifndef SCALEHLS_DIALECT_HLSCPP_ATTRIBUTES_TD
#define SCALEHLS_DIALECT_HLSCPP_ATTRIBUTES_TD
//===----------------------------------------------------------------------===//
// Customized Attributes
//===----------------------------------------------------------------------===//
def PositiveUI32Attr : Confined<UI32Attr, [IntPositive]> {}
def PositiveUI32ArrayAttr : TypedArrayAttrBase<PositiveUI32Attr, ""> {}
def UI32ArrayAttr : TypedArrayAttrBase<UI32Attr, ""> {}
//===----------------------------------------------------------------------===//
// Pragma bind_storage Constraints
//===----------------------------------------------------------------------===//
def LegalStorageType : AttrConstraint<Or<[
CPred<"$_self.cast<StringAttr>().getValue() == \"fifo\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"ram_1p\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"ram_1wnr\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"ram_2p\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"ram_s2p\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"ram_t2p\"">
]>>;
def LegalStorageImpl : AttrConstraint<Or<[
CPred<"$_self.cast<StringAttr>().getValue() == \"bram\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"lutram\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"uram\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"srl\"">
]>>;
//===----------------------------------------------------------------------===//
// Pragma array_partition Constraints
//===----------------------------------------------------------------------===//
def LegalPartitionType : AttrConstraint<Or<[
CPred<"$_self.cast<StringAttr>().getValue() == \"cyclic\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"block\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"complete\"">
]>>;
//===----------------------------------------------------------------------===//
// Pragma bind_op Constraints
//===----------------------------------------------------------------------===//
def LegalOpImpl : AttrConstraint<Or<[
CPred<"$_self.cast<StringAttr>().getValue() == \"dsp\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"fabric\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"meddsp\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"fulldsp\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"maxdsp\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"primitivedsp\"">
]>>;
#endif // SCALEHLS_DIALECT_HLSCPP_ATTRIBUTES_TD

View File

@ -23,8 +23,11 @@ def HLSCppDialect : Dialect {
class HLSCppOp<string mnemonic, list<OpTrait> traits = []> :
Op<HLSCppDialect, mnemonic, traits>;
include "PragmaOps.td"
include "ParameterOps.td"
include "Interfaces.td"
include "Attributes.td"
include "ParamOps.td"
include "StructureOps.td"
include "PragmaOps.td"
#endif // SCALEHLS_DIALECT_HLSCPP_HLSCPP_TD

View File

@ -14,7 +14,7 @@ def PragmaOpInterface : OpInterface<"PragmaOpInterface"> {
}];
}
def ParameterOpInterface : OpInterface<"ParameterOpInterface"> {
def ParamOpInterface : OpInterface<"ParamOpInterface"> {
let description = [{
This interface indicates the operation represents a group of parameters of
its parent region.

View File

@ -0,0 +1,122 @@
//===-------------------------------------------------------*- tablegen -*-===//
//
//===----------------------------------------------------------------------===//
#ifndef SCALEHLS_DIALECT_HLSCPP_PARAMOPS_TD
#define SCALEHLS_DIALECT_HLSCPP_PARAMOPS_TD
//===----------------------------------------------------------------------===//
// FuncParamOp
//===----------------------------------------------------------------------===//
def FuncParamOp : HLSCppOp<"func_param", [
ParamOpInterface,
HasParent<"FuncOp">
]> {
let summary = "Hold function parameters";
let description = [{
This hlscpp.func_param operation holds parameters for function region.
}];
let arguments = (ins
// Pragma configuration parameters
BoolAttr : $enable_pipeline,
PositiveUI32Attr : $initial_interval,
// Resource utilization parameters
UI32Attr : $lut,
UI32Attr : $dsp,
UI32Attr : $bram
);
}
//===----------------------------------------------------------------------===//
// LoopParamOp
//===----------------------------------------------------------------------===//
def LoopParamOp : HLSCppOp<"loop_param", [
ParamOpInterface,
HasParent<"AffineForOp">
]> {
let summary = "Hold loop parameters";
let description = [{
This hlscpp.loop_param operation holds parameters for loop region.
}];
let arguments = (ins
// Pragma configuration parameters
BoolAttr : $enable_pipeline,
PositiveUI32Attr : $initial_interval,
PositiveUI32Attr : $unroll_factor,
// Performance parameters
UI32Attr : $bound,
UI32Attr : $nonperfect_latency,
UI32Attr : $iteration_latency,
UI32Attr : $loop_latency,
// Resource utilization parameters
UI32Attr : $lut,
UI32Attr : $dsp,
UI32Attr : $bram
);
}
//===----------------------------------------------------------------------===//
// IfParamOp
//===----------------------------------------------------------------------===//
def IfParamOp : HLSCppOp<"if_param", [
ParamOpInterface,
HasParent<"AffineIfOp">
]> {
let summary = "Hold if region parameters";
let description = [{
This hlscpp.if_param operation holds parameters for if regions, including
then region and else region (if applicable).
}];
let arguments = (ins
// Performance parameters
UI32Attr : $latency,
// Resource utilization parameters
UI32Attr : $lut,
UI32Attr : $dsp,
UI32Attr : $bram
);
}
//===----------------------------------------------------------------------===//
// ArrayParamOp
//===----------------------------------------------------------------------===//
def ArrayParamOp : HLSCppOp<"array_param", [
ParamOpInterface
]> {
let summary = "Hold array parameters";
let description = [{
This hlscpp.array_param operation holds parameters for arrays.
}];
let arguments = (ins
// Pragma configuration parameters
Confined<StrAttr, [LegalStorageType]> : $storage_type,
Confined<StrAttr, [LegalPartitionType]> : $partition_type,
PositiveUI32ArrayAttr : $partition_factor,
// Performance parameters
UI32Attr : $reads,
UI32Attr : $writes,
PositiveUI32Attr : $read_ports,
PositiveUI32Attr : $write_ports,
UI32Attr : $dependency_latency,
UI32Attr : $dependency_distance,
// Resource utilization parameters
UI32Attr : $lut,
UI32Attr : $bram
);
}
#endif // SCALEHLS_DIALECT_HLSCPP_PARAMOPS_TD

View File

@ -1,39 +0,0 @@
//===-------------------------------------------------------*- tablegen -*-===//
//
//===----------------------------------------------------------------------===//
#ifndef SCALEHLS_DIALECT_HLSCPP_PARAMETEROPS_TD
#define SCALEHLS_DIALECT_HLSCPP_PARAMETEROPS_TD
include "Interfaces.td"
def FuncParameterOp : HLSCppOp<"func_parameter", [
ParameterOpInterface,
HasParent<"FuncOp">
]> {
let summary = "Hold function parameters";
let description = [{
This hlscpp.func_parameter operation holds parameters for function region.
}];
}
def LoopParameterOp : HLSCppOp<"loop_parameter", [
ParameterOpInterface,
HasParent<"AffineForOp">
]> {
let summary = "Hold loop parameters";
let description = [{
This hlscpp.loop_parameter operation holds parameters for loop region.
}];
}
def ArrayParameterOp : HLSCppOp<"array_parameter", [
ParameterOpInterface
]> {
let summary = "Hold array parameters";
let description = [{
This hlscpp.array_parameter operation holds parameters for arrays.
}];
}
#endif // SCALEHLS_DIALECT_HLSCPP_PARAMETEROPS_TD

View File

@ -18,7 +18,7 @@ namespace hlscpp {
std::unique_ptr<mlir::Pass> createStaticAnalysisPass();
std::unique_ptr<mlir::Pass> createQoREstimationPass();
std::unique_ptr<mlir::Pass> createParallelOptPass();
std::unique_ptr<mlir::Pass> createPragmaDSEPass();
std::unique_ptr<mlir::Pass> createPragmaInsertionPass();
void registerHLSCppPasses();

View File

@ -30,19 +30,20 @@ def QoREstimation : Pass<"hlscpp-qor-estimation", "ModuleOp"> {
let constructor = "mlir::scalehls::hlscpp::createQoREstimationPass()";
}
def ParallelOpt : Pass<"hlscpp-parallel-opt", "ModuleOp"> {
let summary = "Optimize parallel strategy of each optimizable region";
def PragmaDSE : Pass<"hlscpp-pragma-dse", "ModuleOp"> {
let summary = "Optimize pragma configuration of each optimizable region";
let description = [{
This hlscpp-parallel-opt pass will automatically tune HLS parallel strategy
This hlscpp-pragma-dse pass will automatically tune HLS pragma optimization
of each optimizable region for performance and area opt. By calling methods
provided by hlscpp-qor-estimation, this pass is able to rapidly obtain the
QoR estimation of the current design point, and feed it back to the design
space exploration engine for an efficient convergence.
}];
let constructor = "mlir::scalehls::hlscpp::createParallelOptPass()";
let constructor = "mlir::scalehls::hlscpp::createPragmaDSEPass()";
}
/// Deprecated. Will be removed in the future.
def PragmaInsertion : Pass<"hlscpp-pragma-insertion", "ModuleOp"> {
let summary = "Insert HLS pragmas according to optimization results";
let description = [{

View File

@ -2,11 +2,11 @@
//
//===----------------------------------------------------------------------===//
/// Deprecated. Will be removed in the future.
#ifndef SCALEHLS_DIALECT_HLSCPP_PRAGMAOPS_TD
#define SCALEHLS_DIALECT_HLSCPP_PRAGMAOPS_TD
include "Interfaces.td"
def ApplyPragmasOp : HLSCppOp<"apply_pragmas", [
PragmaOpInterface,
SingleBlockImplicitTerminator<"EndOp">
@ -109,12 +109,6 @@ def PragmaUnrollOp : HLSCppOp<"pragma_unroll", [
}];
}
def LegalPartitionType : AttrConstraint<Or<[
CPred<"$_self.cast<StringAttr>().getValue() == \"cyclic\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"block\"">,
CPred<"$_self.cast<StringAttr>().getValue() == \"complete\"">
]>>;
def PragmaArrayPartitionOp : HLSCppOp<"pragma_array_partition", [
PragmaOpInterface
]> {

View File

@ -5,8 +5,6 @@
#ifndef SCALEHLS_DIALECT_HLSCPP_STRUCTUREOPS_TD
#define SCALEHLS_DIALECT_HLSCPP_STRUCTUREOPS_TD
include "Interfaces.td"
def AssignOp : HLSCppOp<"assign", [SameOperandsAndResultType]> {
let summary = "Assign input value to the output";
let description = [{

View File

@ -10,11 +10,11 @@ using namespace scalehls;
using namespace hlscpp;
namespace {
struct ParallelOpt : public ParallelOptBase<ParallelOpt> {
struct PragmaDSE : public PragmaDSEBase<PragmaDSE> {
void runOnOperation() {}
};
} // namespace
std::unique_ptr<mlir::Pass> hlscpp::createParallelOptPass() {
return std::make_unique<ParallelOpt>();
std::unique_ptr<mlir::Pass> hlscpp::createPragmaDSEPass() {
return std::make_unique<PragmaDSE>();
}