remove global dialect registration; update file structure

This commit is contained in:
Hanchen Ye 2020-09-23 14:10:34 -05:00
parent 9b7c1c1c69
commit b605503236
22 changed files with 96 additions and 81 deletions

View File

@ -0,0 +1,2 @@
[config]
frequency=200MHz

View File

@ -1,2 +0,0 @@
[config]
frequency=200MHz

View File

@ -1,2 +1,3 @@
add_subdirectory(Conversion)
add_subdirectory(Dialect)
add_subdirectory(Transforms)

View File

@ -4,7 +4,3 @@ set(LLVM_TARGET_DEFINITIONS Interfaces.td)
mlir_tablegen(HLSCppInterfaces.h.inc -gen-op-interface-decls)
mlir_tablegen(HLSCppInterfaces.cpp.inc -gen-op-interface-defs)
add_public_tablegen_target(MLIRHLSCppInterfacesIncGen)
set(LLVM_TARGET_DEFINITIONS Passes.td)
mlir_tablegen(HLSCppPasses.h.inc -gen-pass-decls)
add_public_tablegen_target(MLIRHLSCppPassesIncGen)

View File

@ -1,43 +0,0 @@
//===-------------------------------------------------------*- tablegen -*-===//
//
//===----------------------------------------------------------------------===//
#ifndef SCALEHLS_DIALECT_HLSCPP_PASSES_TD
#define SCALEHLS_DIALECT_HLSCPP_PASSES_TD
include "mlir/Pass/PassBase.td"
def QoREstimation : Pass<"hlscpp-qor-estimation", "ModuleOp"> {
let summary = "Estimate the performance and resource utilization";
let description = [{
This hlscpp-qor-estimation pass will analyze the input CDFG and pragma
operations (if applied) for estimating performance and resource utilization
of the HLS results.
}];
let constructor = "mlir::scalehls::hlscpp::createQoREstimationPass()";
let options = [
Option<"toolConfig", "tool-config", "std::string",
/*default=*/"\"../config/tool-config.ini\"",
"Config file path: global configurations for the ScaleHLS tools">,
Option<"opLatency", "op-latency", "std::string",
/*default=*/"\"../config/op-latency.ini\"",
"Config file path: profiling data for operation latency">
];
}
def PragmaDSE : Pass<"hlscpp-pragma-dse", "ModuleOp"> {
let summary = "Optimize pragma configuration of each optimizable region";
let description = [{
This hlscpp-pragma-dse pass will automatically tune HLS pragma insertion and
configuration for performance and area optimization. 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::createPragmaDSEPass()";
}
#endif // SCALEHLS_DIALECT_HLSCPP_PASSES_TD

View File

@ -0,0 +1,3 @@
set(LLVM_TARGET_DEFINITIONS Passes.td)
mlir_tablegen(Passes.h.inc -gen-pass-decls)
add_public_tablegen_target(MLIRScaleHLSTransformsIncGen)

View File

@ -2,8 +2,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef SCALEHLS_DIALECT_HLSCPP_PASSES_H
#define SCALEHLS_DIALECT_HLSCPP_PASSES_H
#ifndef SCALEHLS_TRANSFORMS_PASSES_H
#define SCALEHLS_TRANSFORMS_PASSES_H
#include "mlir/Pass/Pass.h"
#include <memory>
@ -14,18 +14,16 @@ class Pass;
namespace mlir {
namespace scalehls {
namespace hlscpp {
std::unique_ptr<mlir::Pass> createQoREstimationPass();
std::unique_ptr<mlir::Pass> createPragmaDSEPass();
void registerHLSCppPasses();
void registerTransformsPasses();
#define GEN_PASS_CLASSES
#include "Dialect/HLSCpp/HLSCppPasses.h.inc"
#include "Transforms/Passes.h.inc"
} // namespace hlscpp
} // namespace scalehls
} // namespace mlir
#endif // SCALEHLS_DIALECT_HLSCPP_PASSES_H
#endif // SCALEHLS_TRANSFORMS_PASSES_H

View File

@ -0,0 +1,43 @@
//===-------------------------------------------------------*- tablegen -*-===//
//
//===----------------------------------------------------------------------===//
#ifndef SCALEHLS_TRANSFORMS_PASSES_TD
#define SCALEHLS_TRANSFORMS_PASSES_TD
include "mlir/Pass/PassBase.td"
def QoREstimation : Pass<"qor-estimation", "ModuleOp"> {
let summary = "Estimate the performance and resource utilization";
let description = [{
This qor-estimation pass will analyze the input CDFG and pragma operations
(if applied) for estimating performance and resource utilization of the HLS
results.
}];
let constructor = "mlir::scalehls::createQoREstimationPass()";
let options = [
Option<"targetSpec", "target-spec", "std::string",
/*default=*/"\"../config/target-spec.ini\"",
"File path: target backend specifications and configurations">,
Option<"opLatency", "op-latency", "std::string",
/*default=*/"\"../config/op-latency.ini\"",
"File path: profiling data for operation latency">
];
}
def PragmaDSE : Pass<"pragma-dse", "ModuleOp"> {
let summary = "Optimize pragma configuration of each optimizable region";
let description = [{
This pragma-dse pass will automatically tune HLS pragma insertion and
configuration for performance and area optimization. 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::createPragmaDSEPass()";
}
#endif // SCALEHLS_TRANSFORMS_PASSES_TD

View File

@ -1,3 +1,4 @@
add_subdirectory(Conversion)
add_subdirectory(Dialect)
add_subdirectory(EmitHLSCpp)
add_subdirectory(Transforms)

View File

@ -6,5 +6,4 @@ add_mlir_dialect_library(MLIRHLSCpp
DEPENDS
MLIRHLSCppIncGen
MLIRHLSCppInterfacesIncGen
MLIRHLSCppPassesIncGen
)

View File

@ -0,0 +1,9 @@
//===------------------------------------------------------------*- C++ -*-===//
//
//===----------------------------------------------------------------------===//
#include "Dialect/HLSCpp/HLSCpp.h"
using namespace mlir;
using namespace scalehls;
using namespace hlscpp;

View File

@ -1,6 +1,6 @@
file(GLOB globbed *.cpp)
add_mlir_library(MLIREmitHLSCpp
add_mlir_library(MLIRScaleHLSEmitHLSCpp
${globbed}
LINK_LIBS PUBLIC

View File

@ -0,0 +1,11 @@
file(GLOB globbed *.cpp)
add_mlir_library(MLIRScaleHLSTransforms
${globbed}
DEPENDS
MLIRScaleHLSTransformsIncGen
LINK_LIBS PUBLIC
MLIRHLSCpp
)

View File

@ -2,15 +2,14 @@
//
//===----------------------------------------------------------------------===//
#include "Dialect/HLSCpp/Passes.h"
#include "Transforms/Passes.h"
using namespace mlir;
using namespace scalehls;
using namespace hlscpp;
namespace {
#define GEN_PASS_REGISTRATION
#include "Dialect/HLSCpp/HLSCppPasses.h.inc"
#include "Transforms/Passes.h.inc"
} // namespace
void hlscpp::registerHLSCppPasses() { registerPasses(); }
void scalehls::registerTransformsPasses() { registerPasses(); }

View File

@ -3,11 +3,11 @@
//===----------------------------------------------------------------------===//
#include "Dialect/HLSCpp/HLSCpp.h"
#include "Dialect/HLSCpp/Passes.h"
#include "Transforms/INIReader.h"
#include "Transforms/Passes.h"
using namespace mlir;
using namespace scalehls;
using namespace hlscpp;
namespace {
struct PragmaDSE : public PragmaDSEBase<PragmaDSE> {
@ -15,6 +15,6 @@ struct PragmaDSE : public PragmaDSEBase<PragmaDSE> {
};
} // namespace
std::unique_ptr<mlir::Pass> hlscpp::createPragmaDSEPass() {
std::unique_ptr<mlir::Pass> scalehls::createPragmaDSEPass() {
return std::make_unique<PragmaDSE>();
}

View File

@ -3,12 +3,11 @@
//===----------------------------------------------------------------------===//
#include "Dialect/HLSCpp/HLSCpp.h"
#include "Dialect/HLSCpp/Passes.h"
#include "INIReader.h"
#include "Transforms/INIReader.h"
#include "Transforms/Passes.h"
using namespace mlir;
using namespace scalehls;
using namespace hlscpp;
/*
namespace {
@ -115,6 +114,6 @@ struct QoREstimation : public QoREstimationBase<QoREstimation> {
};
} // namespace
std::unique_ptr<mlir::Pass> hlscpp::createQoREstimationPass() {
std::unique_ptr<mlir::Pass> scalehls::createQoREstimationPass() {
return std::make_unique<QoREstimation>();
}

View File

@ -1,4 +1,4 @@
// RUN: scalehls-opt -hlscpp-pragma-dse %s | FileCheck %s
// RUN: scalehls-opt -pragma-dse %s | FileCheck %s
// CHECK-LABEL: func @test_pragma()
func @test_pragma() {

View File

@ -8,6 +8,7 @@ set(LIBS
MLIRHLSCpp
MLIRConvertToHLSCpp
MLIRScaleHLSTransforms
)
add_llvm_executable(scalehls-opt scalehls-opt.cpp)

View File

@ -4,7 +4,7 @@
#include "Conversion/ConvertToHLSCpp.h"
#include "Dialect/HLSCpp/HLSCpp.h"
#include "Dialect/HLSCpp/Passes.h"
#include "Transforms/Passes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/InitAllDialects.h"
@ -62,7 +62,7 @@ int main(int argc, char **argv) {
registry.insert<mlir::StandardOpsDialect>();
registry.insert<mlir::AffineDialect>();
mlir::scalehls::hlscpp::registerHLSCppPasses();
mlir::scalehls::registerTransformsPasses();
mlir::scalehls::hlscpp::registerConvertToHLSCppPass();
@ -79,8 +79,8 @@ int main(int argc, char **argv) {
mlir::MLIRContext context;
if (showDialects) {
llvm::outs() << "Registered Dialects:\n";
for (mlir::Dialect *dialect : context.getLoadedDialects()) {
llvm::outs() << dialect->getNamespace() << "\n";
for (const auto &nameAndRegistrationIt : registry) {
llvm::outs() << nameAndRegistrationIt.first << "\n";
}
return 0;
}

View File

@ -14,7 +14,7 @@ set(LIBS
MLIRTranslation
MLIRSupport
MLIREmitHLSCpp
MLIRScaleHLSEmitHLSCpp
)
add_llvm_executable(scalehls-translate scalehls-translate.cpp)

View File

@ -39,15 +39,9 @@ static llvm::cl::opt<bool> verifyDiagnostics(
llvm::cl::init(false));
int main(int argc, char **argv) {
mlir::enableGlobalDialectRegistry(true);
mlir::registerAllDialects();
mlir::registerAllTranslations();
mlir::registerDialect<mlir::scalehls::hlscpp::HLSCppDialect>();
mlir::registerDialect<mlir::StandardOpsDialect>();
mlir::registerDialect<mlir::AffineDialect>();
mlir::scalehls::registerHLSCppEmitterTranslation();
llvm::InitLLVM y(argc, argv);
@ -77,6 +71,10 @@ int main(int argc, char **argv) {
auto processBuffer = [&](std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
llvm::raw_ostream &os) {
mlir::MLIRContext context;
context.loadDialect<mlir::scalehls::hlscpp::HLSCppDialect,
mlir::StandardOpsDialect, mlir::AffineDialect>();
context.allowUnregisteredDialects();
context.printOpOnDiagnostic(!verifyDiagnostics);
llvm::SourceMgr sourceMgr;