Support to import scalehls in python; Move analysis utils to support folder; Move qor estimator to transform folder

This commit is contained in:
Hanchen Ye 2021-09-30 02:18:31 -05:00
parent 149ed35967
commit ab9d20a6eb
43 changed files with 174 additions and 210 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.13.4)
if(POLICY CMP0068)
cmake_policy(SET CMP0068 NEW)
@ -13,22 +13,29 @@ if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
if (SCALEHLS_ENABLE_BINDINGS_PYTHON)
message(FATAL_ERROR "ScaleHLS Python bindings require a unified build.")
endif()
project(scalehls LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
set(LLVM_SOURCE_DIR ${CMAKE_SOURCE_DIR}/Polygeist/llvm-project/llvm)
message(STATUS "Searching for MLIRConfig.cmake in: ${MLIR_DIR}")
find_package(MLIR REQUIRED CONFIG)
# set(Clang_DIR ${CLANG_DIR})
# message(STATUS "Searching for ClangConfig.cmake in: ${Clang_DIR}")
# find_package(Clang REQUIRED CONFIG)
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
# message(STATUS "Using ClangConfig.cmake in: ${CLANG_DIR}")
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(TableGen)
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)
else ()
set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir)
@ -36,33 +43,57 @@ else ()
set(MLIR_CMAKE_DIR ${MLIR_MAIN_SRC_DIR}/cmake/modules)
set(MLIR_TABLEGEN_EXE $<TARGET_FILE:mlir-tblgen>)
set(MLIR_TABLEGEN_OUTPUT_DIR ${LLVM_BINARY_DIR}/tools/mlir/include)
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(SCALEHLS_TABLEGEN_OUTPUT_DIR ${LLVM_BINARY_DIR}/tools/scalehls/include)
include_directories(${MLIR_TABLEGEN_OUTPUT_DIR})
include_directories(${SCALEHLS_TABLEGEN_OUTPUT_DIR})
include_directories(SYSTEM ${MLIR_INCLUDE_DIR})
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
endif()
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
# list(APPEND CMAKE_MODULE_PATH "${CLANG_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
include(TableGen)
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)
set(LIT_ARGS_DEFAULT "-sv")
if (MSVC_IDE OR XCODE)
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
endif()
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
set(SCALEHLS_TOOLS_DIR ${CMAKE_BINARY_DIR})
set(SCALEHLS_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root
set(SCALEHLS_MAIN_INCLUDE_DIR ${SCALEHLS_MAIN_SRC_DIR}/include)
set(SCALEHLS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(SCALEHLS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(SCALEHLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include )
set(SCALEHLS_TOOLS_DIR ${CMAKE_BINARY_DIR}/bin)
set(SCALEHLS_UTILS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/utils)
set(SCALEHLS_PYTHON_PACKAGES_DIR ${SCALEHLS_BINARY_DIR}/python_packages)
list(APPEND CMAKE_MODULE_PATH "${MLIR_MAIN_SRC_DIR}/cmake/modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include_directories(${LLVM_INCLUDE_DIRS})
# include_directories(${CLANG_INCLUDE_DIRS})
include_directories(${MLIR_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}/include)
include_directories(${SCALEHLS_MAIN_INCLUDE_DIR})
include_directories(${SCALEHLS_INCLUDE_DIR})
link_directories(${LLVM_BUILD_LIBRARY_DIR})
add_definitions(${LLVM_DEFINITIONS})
set(LLVM_LIT_ARGS "-sv" CACHE STRING "lit default options")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
option(SCALEHLS_ENABLE_BINDINGS_PYTHON "Enables ScaleHLS Python bindings." OFF)
if(SCALEHLS_ENABLE_BINDINGS_PYTHON)
message(STATUS "ScaleHLS Python bindings are enabled.")
include(MLIRDetectPythonEnv)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
message(STATUS "Found Python include dirs: ${Python3_INCLUDE_DIRS}")
message(STATUS "Found Python libraries: ${Python3_LIBRARIES}")
message(STATUS "Found Python executable: ${Python3_EXECUTABLE}")
mlir_detect_pybind11_install()
find_package(pybind11 2.6 CONFIG REQUIRED)
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIR}")
message(STATUS "Python prefix = '${PYTHON_MODULE_PREFIX}', "
"suffix = '${PYTHON_MODULE_SUFFIX}', "
"extension = '${PYTHON_MODULE_EXTENSION}'")
else()
message(STATUS "ScaleHLS Python bindings are disabled.")
endif()
add_subdirectory(include/scalehls)
add_subdirectory(lib)

View File

@ -12,9 +12,11 @@ $ git clone --recursive git@github.com:hanchenye/scalehls.git
$ cd scalehls
```
### 1. Install MLIR, Clang, Polygeist, and ScaleHLS
### 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 \
-DLLVM_ENABLE_PROJECTS="mlir;clang" \
-DLLVM_EXTERNAL_PROJECTS="scalehls;polygeist" \
@ -22,7 +24,9 @@ $ cmake -G Ninja ../Polygeist/llvm-project/llvm \
-DLLVM_EXTERNAL_POLYGEIST_SOURCE_DIR=../Polygeist \
-DLLVM_TARGETS_TO_BUILD="host" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=DEBUG
-DCMAKE_BUILD_TYPE=DEBUG \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DSCALEHLS_ENABLE_BINDINGS_PYTHON=ON
$ ninja
$ ninja check-scalehls
$ export PATH=scalehls/build/bin:$PATH

View File

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

View File

@ -1,30 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Copyright 2020-2021 The ScaleHLS Authors.
//
//===----------------------------------------------------------------------===//
#ifndef SCALEHLS_ANALYSIS_PASSES_H
#define SCALEHLS_ANALYSIS_PASSES_H
#include "mlir/Pass/Pass.h"
#include <memory>
namespace mlir {
class Pass;
} // namespace mlir
namespace mlir {
namespace scalehls {
std::unique_ptr<Pass> createQoREstimationPass();
void registerAnalysisPasses();
#define GEN_PASS_CLASSES
#include "scalehls/Analysis/Passes.h.inc"
} // namespace scalehls
} // namespace mlir
#endif // SCALEHLS_ANALYSIS_PASSES_H

View File

@ -1,33 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Copyright 2020-2021 The ScaleHLS Authors.
//
//===----------------------------------------------------------------------===//
#ifndef SCALEHLS_ANALYSIS_PASSES_TD
#define SCALEHLS_ANALYSIS_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 IR and estimate the latency
and resource utilization of HLS C++ synthesis. This pass will take all
dependency and resource constraints and pragma settings into consideration,
and conduct the estimation through an ALAP scheduling.
}];
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<"depAnalysis", "dep-analysis", "bool", /*default=*/"true",
"Whether a comprehensive dependency analysis is conducted">
];
}
#endif // SCALEHLS_ANALYSIS_PASSES_TD

View File

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

View File

@ -8,7 +8,6 @@
#define SCALEHLS_INITALLPASSES_H
#include "mlir/InitAllPasses.h"
#include "scalehls/Analysis/Passes.h"
#include "scalehls/Conversion/Passes.h"
#include "scalehls/Dialect/HLSKernel/Passes.h"
#include "scalehls/Transforms/Passes.h"
@ -18,7 +17,6 @@ namespace scalehls {
// Add all the ScaleHLS passes.
inline void registerAllPasses() {
scalehls::registerAnalysisPasses();
scalehls::registerConversionPasses();
scalehls::registerTransformsPasses();
scalehls::registerHLSKernelTransformsPasses();

View File

@ -7,7 +7,7 @@
#ifndef SCALEHLS_TRANSFORMS_MULTIPLELEVELDSE_H
#define SCALEHLS_TRANSFORMS_MULTIPLELEVELDSE_H
#include "scalehls/Analysis/QoREstimation.h"
#include "scalehls/Transforms/QoREstimation.h"
#include "scalehls/Transforms/Utils.h"
namespace mlir {

View File

@ -17,6 +17,9 @@ class Pass;
namespace mlir {
namespace scalehls {
/// QoR estimation pass.
std::unique_ptr<Pass> createQoREstimationPass();
/// Design space exploration pass.
std::unique_ptr<Pass> createMultipleLevelDSEPass();

View File

@ -9,6 +9,31 @@
include "mlir/Pass/PassBase.td"
//===----------------------------------------------------------------------===//
// QoR Estimation Pass
//===----------------------------------------------------------------------===//
def QoREstimation : Pass<"qor-estimation", "ModuleOp"> {
let summary = "Estimate the performance and resource utilization";
let description = [{
This qor-estimation pass will analyze the input IR and estimate the latency
and resource utilization of HLS C++ synthesis. This pass will take all
dependency and resource constraints and pragma settings into consideration,
and conduct the estimation through an ALAP scheduling.
}];
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<"depAnalysis", "dep-analysis", "bool", /*default=*/"true",
"Whether a comprehensive dependency analysis is conducted">
];
}
//===----------------------------------------------------------------------===//
// Design Space Exploration Pass
//===----------------------------------------------------------------------===//

View File

@ -10,8 +10,8 @@
#include "external/INIReader.h"
#include "mlir/Analysis/AffineAnalysis.h"
#include "mlir/IR/BuiltinOps.h"
#include "scalehls/Analysis/Utils.h"
#include "scalehls/Dialect/HLSCpp/Visitor.h"
#include "scalehls/Support/Utils.h"
#include "scalehls/Transforms/Utils.h"
namespace mlir {

View File

@ -7,7 +7,7 @@
#ifndef SCALEHLS_TRANSFORMS_UTILS_H
#define SCALEHLS_TRANSFORMS_UTILS_H
#include "scalehls/Analysis/Utils.h"
#include "scalehls/Support/Utils.h"
namespace mlir {
namespace scalehls {

View File

@ -1,8 +0,0 @@
file(GLOB globbed *.cpp)
add_mlir_library(MLIRScaleHLSAnalysis
${globbed}
DEPENDS
MLIRScaleHLSAnalysisIncGen
)

View File

@ -1,17 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Copyright 2020-2021 The ScaleHLS Authors.
//
//===----------------------------------------------------------------------===//
#include "scalehls/Analysis/Passes.h"
using namespace mlir;
using namespace scalehls;
namespace {
#define GEN_PASS_REGISTRATION
#include "scalehls/Analysis/Passes.h.inc"
} // namespace
void scalehls::registerAnalysisPasses() { registerPasses(); }

View File

@ -1,3 +1,3 @@
if(SCALEHLS_BINDINGS_PYTHON_ENABLED)
if(SCALEHLS_ENABLE_BINDINGS_PYTHON)
add_subdirectory(Python)
endif()

View File

@ -18,7 +18,7 @@ declare_mlir_python_extension(ScaleHLSBindingsPythonExtension.Core
SOURCES
ScaleHLSModule.cpp
EMBED_CAPI_LINK_LIBS
CIRCTCAPIEmitHLSCpp
MLIRScaleHLSCAPIEmitHLSCpp
PRIVATE_LINK_LIBS
${_depends}
)
@ -31,77 +31,23 @@ declare_mlir_python_sources(ScaleHLSBindingsPythonSources
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
SOURCES
scalehls/__init__.py
scalehls/esi.py
scalehls/support.py
scalehls/dialects/_ods_common.py)
################################################################################
# Declare dialect-specific bindings.
################################################################################
# Ensure the build directory for generated Python files exists. Ninja is able to
# generate this, but make does not and the build fails.
file(MAKE_DIRECTORY ${CIRCT_BINARY_DIR}/lib/Bindings/Python/scalehls/dialects)
declare_mlir_python_sources(CIRCTBindingsPythonSources.Dialects
ADD_TO_PARENT CIRCTBindingsPythonSources)
declare_mlir_dialect_python_bindings(
ADD_TO_PARENT CIRCTBindingsPythonSources.Dialects
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
TD_FILE scalehls/dialects/CombOps.td
SOURCES
scalehls/dialects/comb.py
scalehls/dialects/_comb_ops_ext.py
DIALECT_NAME comb)
declare_mlir_dialect_python_bindings(
ADD_TO_PARENT CIRCTBindingsPythonSources.Dialects
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
TD_FILE scalehls/dialects/ESIOps.td
SOURCES scalehls/dialects/esi.py
DIALECT_NAME esi)
declare_mlir_dialect_python_bindings(
ADD_TO_PARENT CIRCTBindingsPythonSources.Dialects
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
TD_FILE scalehls/dialects/HWOps.td
SOURCES
scalehls/dialects/hw.py
scalehls/dialects/_hw_ops_ext.py
DIALECT_NAME hw)
declare_mlir_dialect_python_bindings(
ADD_TO_PARENT CIRCTBindingsPythonSources.Dialects
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
TD_FILE scalehls/dialects/SeqOps.td
SOURCES
scalehls/dialects/seq.py
scalehls/dialects/_seq_ops_ext.py
DIALECT_NAME seq)
declare_mlir_dialect_python_bindings(
ADD_TO_PARENT CIRCTBindingsPythonSources.Dialects
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
TD_FILE scalehls/dialects/SVOps.td
SOURCES scalehls/dialects/sv.py
DIALECT_NAME sv)
)
################################################################################
# Build composite binaries
################################################################################
# Bundle our own, self-contained CAPI library with all of our deps.
add_mlir_python_common_capi_library(CIRCTBindingsPythonCAPI
INSTALL_COMPONENT CIRCTBindingsPythonModules
add_mlir_python_common_capi_library(ScaleHLSBindingsPythonCAPI
INSTALL_COMPONENT ScaleHLSBindingsPythonModules
INSTALL_DESTINATION python_packages/scalehls_core/mlir/_mlir_libs
# NOTE: When the MLIR API is relocated under scalehls, this would change to
# .../scalehls/_mlir_libs
OUTPUT_DIRECTORY "${CIRCT_PYTHON_PACKAGES_DIR}/scalehls_core/mlir/_mlir_libs"
OUTPUT_DIRECTORY "${SCALEHLS_PYTHON_PACKAGES_DIR}/scalehls_core/mlir/_mlir_libs"
RELATIVE_INSTALL_ROOT "../../../.."
DECLARED_SOURCES
MLIRPythonSources.Core
CIRCTBindingsPythonSources
ScaleHLSBindingsPythonSources
ScaleHLSBindingsPythonExtension
)
@ -109,8 +55,8 @@ add_mlir_python_common_capi_library(CIRCTBindingsPythonCAPI
# The MLIR API is position independent, so we explicitly output it to the mlir/
# folder as a temporary measure. It will eventually migrate under the scalehls/
# folder and be accessible under the unified "import scalehls..." namespace.
add_mlir_python_modules(CIRCTMLIRPythonModules
ROOT_PREFIX "${CIRCT_PYTHON_PACKAGES_DIR}/scalehls_core/mlir"
add_mlir_python_modules(ScaleHLSMLIRPythonModules
ROOT_PREFIX "${SCALEHLS_PYTHON_PACKAGES_DIR}/scalehls_core/mlir"
INSTALL_PREFIX "python_packages/scalehls_core/mlir"
DECLARED_SOURCES
MLIRPythonSources.Core
@ -118,15 +64,15 @@ add_mlir_python_modules(CIRCTMLIRPythonModules
# the namespace is unified, this moves to the below.
ScaleHLSBindingsPythonExtension
COMMON_CAPI_LINK_LIBS
CIRCTBindingsPythonCAPI
ScaleHLSBindingsPythonCAPI
)
# Bundle the CIRCT python sources into our package.
add_mlir_python_modules(CIRCTPythonModules
ROOT_PREFIX "${CIRCT_PYTHON_PACKAGES_DIR}/scalehls_core"
# Bundle the ScaleHLS python sources into our package.
add_mlir_python_modules(ScaleHLSPythonModules
ROOT_PREFIX "${SCALEHLS_PYTHON_PACKAGES_DIR}/scalehls_core"
INSTALL_PREFIX "python_packages/scalehls_core"
DECLARED_SOURCES
CIRCTBindingsPythonSources
ScaleHLSBindingsPythonSources
COMMON_CAPI_LINK_LIBS
CIRCTBindingsPythonCAPI
ScaleHLSBindingsPythonCAPI
)

View File

@ -0,0 +1,7 @@
# ===----------------------------------------------------------------------=== #
#
# Copyright 2020-2021 The ScaleHLS Authors.
#
# ===----------------------------------------------------------------------=== #
from mlir._mlir_libs._scalehls import *

View File

@ -1,4 +1,4 @@
add_circt_library(MLIRScaleHLSCAPIEmitHLSCpp
add_mlir_library(MLIRScaleHLSCAPIEmitHLSCpp
EmitHLSCpp.cpp
ADDITIONAL_HEADER_DIRS

View File

@ -1,5 +1,7 @@
add_subdirectory(Analysis)
add_subdirectory(Bindings)
add_subdirectory(CAPI)
add_subdirectory(Conversion)
add_subdirectory(Dialect)
add_subdirectory(Support)
add_subdirectory(Transforms)
add_subdirectory(Translation)

View File

@ -0,0 +1,5 @@
file(GLOB globbed *.cpp)
add_mlir_library(MLIRScaleHLSSupport
${globbed}
)

View File

@ -4,7 +4,7 @@
//
//===----------------------------------------------------------------------===//
#include "scalehls/Analysis/Utils.h"
#include "scalehls/Support/Utils.h"
#include "mlir/Analysis/AffineAnalysis.h"
#include "mlir/Analysis/LoopAnalysis.h"
#include "mlir/Analysis/Utils.h"

View File

@ -5,4 +5,7 @@ add_mlir_library(MLIRScaleHLSTransforms
DEPENDS
MLIRScaleHLSTransformsIncGen
LINK_LIBS PUBLIC
MLIRScaleHLSSupport
)

View File

@ -4,10 +4,10 @@
//
//===----------------------------------------------------------------------===//
#include "scalehls/Analysis/QoREstimation.h"
#include "scalehls/Transforms/QoREstimation.h"
#include "mlir/Analysis/Utils.h"
#include "mlir/Dialect/Affine/IR/AffineValueMap.h"
#include "scalehls/Analysis/Passes.h"
#include "scalehls/Transforms/Passes.h"
#include "llvm/ADT/SmallPtrSet.h"
using namespace std;

View File

@ -8,7 +8,7 @@
#include "mlir/Analysis/Utils.h"
#include "mlir/IR/Dominance.h"
#include "mlir/IR/IntegerSet.h"
#include "scalehls/Analysis/Utils.h"
#include "scalehls/Support/Utils.h"
#include "scalehls/Transforms/Passes.h"
#include <algorithm>

View File

@ -4,7 +4,7 @@
//
//===----------------------------------------------------------------------===//
#include "scalehls/Analysis/Utils.h"
#include "scalehls/Support/Utils.h"
#include "scalehls/Transforms/Passes.h"
using namespace mlir;

View File

@ -6,4 +6,5 @@ add_mlir_library(MLIRScaleHLSEmitHLSCpp
LINK_LIBS PUBLIC
MLIRHLSCpp
MLIRHLSKernel
MLIRScaleHLSSupport
)

View File

@ -9,9 +9,9 @@
#include "mlir/IR/AffineExprVisitor.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/Translation.h"
#include "scalehls/Analysis/Utils.h"
#include "scalehls/Dialect/HLSCpp/Visitor.h"
#include "scalehls/InitAllDialects.h"
#include "scalehls/Support/Utils.h"
#include "llvm/Support/raw_ostream.h"
using namespace mlir;

4
test/Bindings/import.py Normal file
View File

@ -0,0 +1,4 @@
# REQUIRES: bindings_python
# RUN: %PYTHON %s
import scalehls

View File

@ -1,3 +1,7 @@
llvm_canonicalize_cmake_booleans(
SCALEHLS_ENABLE_BINDINGS_PYTHON
)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
@ -7,12 +11,16 @@ configure_lit_site_cfg(
set(SCALEHLS_TEST_DEPENDS
FileCheck count not
# scalehls-clang
scalehls-opt
scalehls-translate
benchmark-gen
)
if(SCALEHLS_ENABLE_BINDINGS_PYTHON)
list(APPEND SCALEHLS_TEST_DEPENDS ScaleHLSMLIRPythonModules)
list(APPEND SCALEHLS_TEST_DEPENDS ScaleHLSPythonModules)
endif()
add_lit_testsuite(check-scalehls "Running the scalehls regression tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${SCALEHLS_TEST_DEPENDS}

View File

@ -21,7 +21,7 @@ config.name = 'SCALEHLS'
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.mlir', '.ini', '.c']
config.suffixes = ['.mlir', '.ini', '.c', '.py']
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
@ -40,7 +40,11 @@ llvm_config.use_default_substitutions()
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
config.excludes = [
'CMakeLists.txt',
'README.txt',
'lit.cfg.py'
]
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
@ -51,13 +55,27 @@ config.test_exec_root = os.path.join(config.scalehls_obj_root, 'test')
# Tweak the PATH to include the tools dir.
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
# Tweak the PYTHONPATH to include the binary dir.
if config.enable_bindings_python:
llvm_config.with_environment(
'PYTHONPATH',
[os.path.join(config.scalehls_python_packages_dir, 'scalehls_core')],
append_path=True)
tool_dirs = [config.scalehls_tools_dir,
config.mlir_tools_dir, config.llvm_tools_dir]
tools = [
'scalehls-clang',
'scalehls-opt',
'scalehls-translate',
'benchmark-gen'
]
# The following tools are optional
tools.extend([
ToolSubst('%PYTHON', config.python_executable, unresolved='ignore')
])
llvm_config.add_tool_substitutions(tools, tool_dirs)
if config.enable_bindings_python:
config.available_features.add('bindings_python')

View File

@ -12,7 +12,7 @@ config.llvm_shlib_dir = "@SHLIBDIR@"
config.llvm_shlib_ext = "@SHLIBEXT@"
config.llvm_exe_ext = "@EXEEXT@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.python_executable = "@Python3_EXECUTABLE@"
config.gold_executable = "@GOLD_EXECUTABLE@"
config.ld64_executable = "@LD64_EXECUTABLE@"
config.enable_shared = @ENABLE_SHARED@
@ -34,6 +34,8 @@ config.mlir_tools_dir = "@MLIR_TOOLS_DIR@"
config.scalehls_src_root = "@SCALEHLS_SOURCE_DIR@"
config.scalehls_obj_root = "@SCALEHLS_BINARY_DIR@"
config.scalehls_tools_dir = "@SCALEHLS_TOOLS_DIR@"
config.scalehls_python_packages_dir = "@SCALEHLS_PYTHON_PACKAGES_DIR@"
config.enable_bindings_python = @SCALEHLS_ENABLE_BINDINGS_PYTHON@
# Support substitution of the tools_dir with user parameters. This is
# used when we can't determine the tool dir at configuration time.

View File

@ -17,7 +17,6 @@ target_link_libraries(scalehls-opt
MLIRHLSKernel
MLIRScaleHLSConversion
MLIRScaleHLSTransforms
MLIRScaleHLSAnalysis
# Threads::Threads
)

View File

@ -17,5 +17,5 @@ target_link_libraries(scalehls-translate
${translation_libs}
MLIRScaleHLSEmitHLSCpp
MLIRScaleHLSAnalysis
MLIRScaleHLSSupport
)