Update README; Enable output QoR estimation in DSE; Register LLVM dialect

This commit is contained in:
Hanchen Ye 2021-09-30 04:44:47 -05:00
parent 9cf839db30
commit 2d42d2d6b9
3 changed files with 20 additions and 31 deletions

View File

@ -6,17 +6,12 @@ Please check out our [arXiv paper](https://arxiv.org/abs/2107.11673) for more de
## Quick Start ## Quick Start
### 0. Download ScaleHLS ### 1. Download and Install ScaleHLS
To build ScaleHLS, run:
```sh ```sh
$ git clone --recursive git@github.com:hanchenye/scalehls.git $ git clone --recursive git@github.com:hanchenye/scalehls.git
$ cd scalehls $ mkdir scalehls/build
``` $ cd scalehls/build
### 1. Install ScaleHLS
This step assumes this repository is cloned to `scalehls`. To build ScaleHLS, run:
```sh
$ mkdir build
$ cd build
$ cmake -G Ninja ../Polygeist/llvm-project/llvm \ $ cmake -G Ninja ../Polygeist/llvm-project/llvm \
-DLLVM_ENABLE_PROJECTS="mlir;clang" \ -DLLVM_ENABLE_PROJECTS="mlir;clang" \
-DLLVM_EXTERNAL_PROJECTS="scalehls;polygeist" \ -DLLVM_EXTERNAL_PROJECTS="scalehls;polygeist" \
@ -26,10 +21,13 @@ $ cmake -G Ninja ../Polygeist/llvm-project/llvm \
-DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=DEBUG \ -DCMAKE_BUILD_TYPE=DEBUG \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DSCALEHLS_ENABLE_BINDINGS_PYTHON=ON -DSCALEHLS_ENABLE_BINDINGS_PYTHON=ON \
-DCMAKE_LINKER=lld \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++
$ ninja $ ninja
$ ninja check-scalehls $ ninja check-scalehls
$ export PATH=scalehls/build/bin:$PATH $ export PATH=$PWD/bin:$PATH
``` ```
### 2. Try ScaleHLS ### 2. Try ScaleHLS
@ -38,16 +36,10 @@ After the installation and test successfully completed, you should be able to pl
$ cd scalehls $ cd scalehls
$ # HLS C programs parsing and automatic kernel-level design space exploration. $ # HLS C programs parsing and automatic kernel-level design space exploration.
$ scalehls-opt samples/polybench/gemm/gemm_32.mlir \ $ mlir-clang samples/polybench/gemm/gemm_32.c -function=gemm_32 -memref-fullrank -S | \
-multiple-level-dse="top-func=gemm_32 output-path=./ target-spec=config/target-spec.ini" \ scalehls-opt -multiple-level-dse="top-func=gemm_32 output-path=./ target-spec=config/target-spec.ini" \
-debug-only=scalehls > /dev/null -debug-only=scalehls > /dev/null
$ scalehls-translate -emit-hlscpp gemm_pareto_0.mlir > gemm_pareto_0.cpp $ scalehls-translate -emit-hlscpp gemm_32_pareto_0.mlir > gemm_32_pareto_0.cpp
```
Note: We are currently refactoring the HLS C parsing feature, hence it is temporarily unavailable at present.
ScaleHLS transform passes and QoR estimator:
```sh
$ cd scalehls
$ # Loop and directive-level optimizations, QoR estimation, and C++ code generation. $ # Loop and directive-level optimizations, QoR estimation, and C++ code generation.
$ scalehls-opt samples/polybench/syrk/syrk_32.mlir \ $ scalehls-opt samples/polybench/syrk/syrk_32.mlir \
@ -57,11 +49,6 @@ $ scalehls-opt samples/polybench/syrk/syrk_32.mlir \
-affine-store-forward -simplify-memref-access -array-partition -cse -canonicalize \ -affine-store-forward -simplify-memref-access -array-partition -cse -canonicalize \
-qor-estimation="target-spec=config/target-spec.ini" \ -qor-estimation="target-spec=config/target-spec.ini" \
| scalehls-translate -emit-hlscpp | scalehls-translate -emit-hlscpp
$ # Benchmark generation, dataflow-level optimization, HLSKernel lowering and bufferization.
$ benchmark-gen -type "cnn" -config "config/cnn-config.ini" -number 1 \
| scalehls-opt -legalize-dataflow="insert-copy=true min-gran=2" -split-function \
-hlskernel-bufferize -hlskernel-to-affine -func-bufferize -canonicalize
``` ```
## Integration with ONNX-MLIR ## Integration with ONNX-MLIR

View File

@ -8,6 +8,7 @@
#define SCALEHLS_INITALLDIALECTS_H #define SCALEHLS_INITALLDIALECTS_H
#include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h"
#include "mlir/Dialect/Math/IR/Math.h" #include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/MemRef/IR/MemRef.h"
@ -30,7 +31,8 @@ inline void registerAllDialects(mlir::DialectRegistry &registry) {
mlir::memref::MemRefDialect, mlir::memref::MemRefDialect,
mlir::math::MathDialect, mlir::math::MathDialect,
mlir::scf::SCFDialect, mlir::scf::SCFDialect,
mlir::linalg::LinalgDialect mlir::linalg::LinalgDialect,
mlir::LLVM::LLVMDialect
>(); >();
// clang-format on // clang-format on
} }

View File

@ -536,7 +536,7 @@ bool FuncDesignSpace::exportParetoDesigns(unsigned outputNum,
auto tmpFunc = func.clone(); auto tmpFunc = func.clone();
if (!applyOptStrategy(tmpFunc, tileLists, targetIIs)) if (!applyOptStrategy(tmpFunc, tileLists, targetIIs))
return false; return false;
// estimator.estimateFunc(tmpFunc); estimator.estimateFunc(tmpFunc);
// Parse a new output file. // Parse a new output file.
auto outputFilePath = outputRootPath.str() + func.getName().str() + auto outputFilePath = outputRootPath.str() + func.getName().str() +
@ -566,12 +566,12 @@ bool FuncDesignSpace::exportParetoDesigns(unsigned outputNum,
bool ScaleHLSOptimizer::emitQoRDebugInfo(FuncOp func, std::string message) { bool ScaleHLSOptimizer::emitQoRDebugInfo(FuncOp func, std::string message) {
estimator.estimateFunc(func); estimator.estimateFunc(func);
auto latency = getTiming(func).getLatency(); // auto latency = getTiming(func).getLatency();
auto dspNum = getResource(func).getDsp(); auto dspNum = getResource(func).getDsp();
LLVM_DEBUG(llvm::dbgs() << message + "\n"; // LLVM_DEBUG(llvm::dbgs() << message + "\n";
llvm::dbgs() << "The clock cycle is " << Twine(latency) // llvm::dbgs() << "The clock cycle is " << Twine(latency)
<< ", DSP usage is " << Twine(dspNum) << ".\n\n";); // << ", DSP usage is " << Twine(dspNum) << ".\n\n";);
return dspNum <= maxDspNum; return dspNum <= maxDspNum;
} }