2019-03-30 05:10:12 +00:00
|
|
|
# MLIR project.
|
2020-04-12 06:29:07 +00:00
|
|
|
set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
|
|
|
|
set(MLIR_MAIN_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include )
|
2019-03-30 05:10:12 +00:00
|
|
|
|
2020-04-12 06:29:07 +00:00
|
|
|
set(MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
|
2019-03-30 05:10:12 +00:00
|
|
|
|
2020-01-22 00:44:17 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
2019-03-30 05:10:12 +00:00
|
|
|
|
2020-01-22 00:44:17 +00:00
|
|
|
include(AddMLIR)
|
|
|
|
|
2020-11-04 00:06:28 +00:00
|
|
|
# Forbid implicit function declaration: this may lead to subtle bugs and we
|
|
|
|
# don't have a reason to support this.
|
2020-11-05 02:33:51 +00:00
|
|
|
check_c_compiler_flag("-Werror=implicit-function-declaration" C_SUPPORTS_WERROR_IMPLICIT_FUNCTION_DECLARATION)
|
|
|
|
append_if(C_SUPPORTS_WERROR_IMPLICIT_FUNCTION_DECLARATION "-Werror=implicit-function-declaration" CMAKE_C_FLAGS)
|
2020-11-04 00:06:28 +00:00
|
|
|
|
Add missing mlir-headers target and add tablegen'd deps to it.
Summary:
Prior to this, "ninja install-mlir-headers" failed with an error indicating
the missing target. Verified that from a clean build, the installed
headers include generated files.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72045
2020-01-01 00:32:41 +00:00
|
|
|
# Installing the headers and docs needs to depend on generating any public
|
|
|
|
# tablegen'd targets.
|
2020-04-24 23:42:07 +00:00
|
|
|
# mlir-generic-headers are dialect-independent.
|
|
|
|
add_custom_target(mlir-generic-headers)
|
|
|
|
set_target_properties(mlir-generic-headers PROPERTIES FOLDER "Misc")
|
|
|
|
# mlir-headers may be dialect-dependent.
|
Add missing mlir-headers target and add tablegen'd deps to it.
Summary:
Prior to this, "ninja install-mlir-headers" failed with an error indicating
the missing target. Verified that from a clean build, the installed
headers include generated files.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72045
2020-01-01 00:32:41 +00:00
|
|
|
add_custom_target(mlir-headers)
|
|
|
|
set_target_properties(mlir-headers PROPERTIES FOLDER "Misc")
|
2020-04-24 23:42:07 +00:00
|
|
|
add_dependencies(mlir-headers mlir-generic-headers)
|
2019-12-02 17:17:51 +00:00
|
|
|
add_custom_target(mlir-doc)
|
|
|
|
|
2019-06-26 12:16:11 +00:00
|
|
|
# Build the CUDA conversions and run according tests if the NVPTX backend
|
|
|
|
# is available
|
|
|
|
if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
|
|
|
|
set(MLIR_CUDA_CONVERSIONS_ENABLED 1)
|
|
|
|
else()
|
|
|
|
set(MLIR_CUDA_CONVERSIONS_ENABLED 0)
|
|
|
|
endif()
|
2020-02-14 09:12:41 +00:00
|
|
|
# TODO: we should use a config.h file like LLVM does
|
|
|
|
add_definitions(-DMLIR_CUDA_CONVERSIONS_ENABLED=${MLIR_CUDA_CONVERSIONS_ENABLED})
|
2019-06-26 12:16:11 +00:00
|
|
|
|
2020-05-22 21:25:00 +00:00
|
|
|
# Build the ROCm conversions and run according tests if the AMDGPU backend
|
|
|
|
# is available
|
|
|
|
if ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)
|
|
|
|
set(MLIR_ROCM_CONVERSIONS_ENABLED 1)
|
|
|
|
else()
|
|
|
|
set(MLIR_ROCM_CONVERSIONS_ENABLED 0)
|
|
|
|
endif()
|
|
|
|
add_definitions(-DMLIR_ROCM_CONVERSIONS_ENABLED=${MLIR_ROCM_CONVERSIONS_ENABLED})
|
|
|
|
|
2019-07-04 14:49:52 +00:00
|
|
|
set(MLIR_CUDA_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir CUDA runner")
|
[mlir][gpu] Introduce mlir-rocm-runner.
Summary:
`mlir-rocm-runner` is introduced in this commit to execute GPU modules on ROCm
platform. A small wrapper to encapsulate ROCm's HIP runtime API is also inside
the commit.
Due to behavior of ROCm, raw pointers inside memrefs passed to `gpu.launch`
must be modified on the host side to properly capture the pointer values
addressable on the GPU.
LLVM MC is used to assemble AMD GCN ISA coming out from
`ConvertGPUKernelToBlobPass` to binary form, and LLD is used to produce a shared
ELF object which could be loaded by ROCm HIP runtime.
gfx900 is the default target be used right now, although it could be altered via
an option in `mlir-rocm-runner`. Future revisions may consider using ROCm Agent
Enumerator to detect the right target on the system.
Notice AMDGPU Code Object V2 is used in this revision. Future enhancements may
upgrade to AMDGPU Code Object V3.
Bitcode libraries in ROCm-Device-Libs, which implements math routines exposed in
`rocdl` dialect are not yet linked, and is left as a TODO in the logic.
Reviewers: herhut
Subscribers: mgorny, tpr, dexonsmith, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, llvm-commits
Tags: #mlir, #llvm
Differential Revision: https://reviews.llvm.org/D80676
2020-05-20 21:07:49 +00:00
|
|
|
set(MLIR_ROCM_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir ROCm runner")
|
[MLIR][mlir-spirv-cpu-runner] A SPIR-V cpu runner prototype
This patch introduces a SPIR-V runner. The aim is to run a gpu
kernel on a CPU via GPU -> SPIRV -> LLVM conversions. This is a first
prototype, so more features will be added in due time.
- Overview
The runner follows similar flow as the other runners in-tree. However,
having converted the kernel to SPIR-V, we encode the bind attributes of
global variables that represent kernel arguments. Then SPIR-V module is
converted to LLVM. On the host side, we emulate passing the data to device
by creating in main module globals with the same symbolic name as in kernel
module. These global variables are later linked with ones from the nested
module. We copy data from kernel arguments to globals, call the kernel
function from nested module and then copy the data back.
- Current state
At the moment, the runner is capable of running 2 modules, nested one in
another. The kernel module must contain exactly one kernel function. Also,
the runner supports rank 1 integer memref types as arguments (to be scaled).
- Enhancement of JitRunner and ExecutionEngine
To translate nested modules to LLVM IR, JitRunner and ExecutionEngine were
altered to take an optional (default to `nullptr`) function reference that
is a custom LLVM IR module builder. This allows to customize LLVM IR module
creation from MLIR modules.
Reviewed By: ftynse, mravishankar
Differential Revision: https://reviews.llvm.org/D86108
2020-10-23 14:46:18 +00:00
|
|
|
set(MLIR_SPIRV_CPU_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir SPIR-V cpu runner")
|
2020-02-19 14:11:22 +00:00
|
|
|
set(MLIR_VULKAN_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir Vulkan runner")
|
2019-07-04 14:49:52 +00:00
|
|
|
|
2020-10-04 22:17:34 +00:00
|
|
|
option(MLIR_INCLUDE_TESTS
|
|
|
|
"Generate build targets for the MLIR unit tests."
|
|
|
|
${LLVM_INCLUDE_TESTS})
|
|
|
|
|
|
|
|
option(MLIR_INCLUDE_INTEGRATION_TESTS
|
|
|
|
"Generate build targets for the MLIR integration tests.")
|
|
|
|
|
Initial boiler-plate for python bindings.
Summary:
* Native '_mlir' extension module.
* Python mlir/__init__.py trampoline module.
* Lit test that checks a message.
* Uses some cmake configurations that have worked for me in the past but likely needs further elaboration.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D83279
2020-07-07 06:05:46 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Python Bindings Configuration
|
|
|
|
# Requires:
|
|
|
|
# The pybind11 library can be found (set with -DPYBIND_DIR=...)
|
|
|
|
# The python executable is correct (set with -DPYTHON_EXECUTABLE=...)
|
|
|
|
#
|
|
|
|
# Version locking
|
|
|
|
# ---------------
|
|
|
|
# By default, python extensions are version locked to specific Python libraries.
|
|
|
|
# This linking mode is somewhat more consistent across platforms and surfaces
|
|
|
|
# undefined symbols at link time (vs runtime). It is suitable for development
|
|
|
|
# workflows but can be disabled for more flexible deployment by
|
|
|
|
# setting -DMLIR_PYTHON_BINDINGS_VERSION_LOCKED=OFF
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
set(MLIR_BINDINGS_PYTHON_ENABLED 0 CACHE BOOL
|
|
|
|
"Enables building of Python bindings.")
|
|
|
|
set(MLIR_PYTHON_BINDINGS_VERSION_LOCKED 1 CACHE BOOL
|
|
|
|
"Links to specific python libraries, resolving all symbols.")
|
|
|
|
|
|
|
|
if(MLIR_BINDINGS_PYTHON_ENABLED)
|
2020-11-21 01:57:46 +00:00
|
|
|
include(MLIRDetectPythonEnv)
|
2020-11-10 17:14:37 +00:00
|
|
|
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
|
|
|
|
message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
|
|
|
|
message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
|
2020-11-21 01:57:46 +00:00
|
|
|
mlir_detect_pybind11_install()
|
|
|
|
find_package(pybind11 2.6 CONFIG REQUIRED)
|
2020-11-07 17:05:51 +00:00
|
|
|
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIR}")
|
Initial boiler-plate for python bindings.
Summary:
* Native '_mlir' extension module.
* Python mlir/__init__.py trampoline module.
* Lit test that checks a message.
* Uses some cmake configurations that have worked for me in the past but likely needs further elaboration.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D83279
2020-07-07 06:05:46 +00:00
|
|
|
message(STATUS "Python prefix = '${PYTHON_MODULE_PREFIX}', "
|
|
|
|
"suffix = '${PYTHON_MODULE_SUFFIX}', "
|
|
|
|
"extension = '${PYTHON_MODULE_EXTENSION}")
|
|
|
|
endif()
|
|
|
|
|
2019-03-30 05:10:12 +00:00
|
|
|
include_directories( "include")
|
|
|
|
include_directories( ${MLIR_INCLUDE_DIR})
|
|
|
|
|
2020-03-14 18:41:12 +00:00
|
|
|
# Adding tools/mlir-tblgen here as calling add_tablegen sets some variables like
|
|
|
|
# MLIR_TABLEGEN_EXE in PARENT_SCOPE which gets lost if that folder is included
|
|
|
|
# from another directory like tools
|
2020-10-04 22:17:34 +00:00
|
|
|
add_subdirectory(tools/mlir-tblgen)
|
2020-03-14 18:41:12 +00:00
|
|
|
|
2019-03-30 05:10:12 +00:00
|
|
|
add_subdirectory(include/mlir)
|
|
|
|
add_subdirectory(lib)
|
2020-08-05 12:36:16 +00:00
|
|
|
# C API needs all dialects for registration, but should be built before tests.
|
|
|
|
add_subdirectory(lib/CAPI)
|
2020-05-18 16:44:26 +00:00
|
|
|
if (MLIR_INCLUDE_TESTS)
|
2020-10-04 22:17:34 +00:00
|
|
|
add_definitions(-DMLIR_INCLUDE_TESTS)
|
2020-05-18 16:44:26 +00:00
|
|
|
add_subdirectory(unittests)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
[mlir] [integration-test] [VectorOps] Start an integration test directory for MLIR
Summary:
This CL introduces an integration test directory for MLIR in general, with
vector dialect integration tests in particular as a first working suite. To
run all the integration tests (and currently just the vector suite):
$ cmake --build . --target check-mlir-integration
[0/1] Running the MLIR integration tests
Testing Time: 0.24s
Passed: 22
The general call is to contribute to this integration test directory with more
tests and other suites, running end-to-end examples that may be too heavy for
the regular test directory, but should be tested occasionally to verify the
health of MLIR.
Background discussion at:
https://llvm.discourse.group/t/vectorops-rfc-add-suite-of-integration-tests-for-vector-dialect-operations/1213/
Reviewers: nicolasvasilache, reidtatge, andydavis1, rriddle, ftynse, mehdi_amini, jpienaar, stephenneuendorffer
Reviewed By: nicolasvasilache, stephenneuendorffer
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D81626
2020-06-15 17:39:10 +00:00
|
|
|
if (MLIR_INCLUDE_INTEGRATION_TESTS)
|
2020-10-04 22:17:34 +00:00
|
|
|
add_definitions(-DMLIR_INCLUDE_INTEGRATION_TESTS)
|
[mlir] [integration-test] [VectorOps] Start an integration test directory for MLIR
Summary:
This CL introduces an integration test directory for MLIR in general, with
vector dialect integration tests in particular as a first working suite. To
run all the integration tests (and currently just the vector suite):
$ cmake --build . --target check-mlir-integration
[0/1] Running the MLIR integration tests
Testing Time: 0.24s
Passed: 22
The general call is to contribute to this integration test directory with more
tests and other suites, running end-to-end examples that may be too heavy for
the regular test directory, but should be tested occasionally to verify the
health of MLIR.
Background discussion at:
https://llvm.discourse.group/t/vectorops-rfc-add-suite-of-integration-tests-for-vector-dialect-operations/1213/
Reviewers: nicolasvasilache, reidtatge, andydavis1, rriddle, ftynse, mehdi_amini, jpienaar, stephenneuendorffer
Reviewed By: nicolasvasilache, stephenneuendorffer
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D81626
2020-06-15 17:39:10 +00:00
|
|
|
add_subdirectory(integration_test)
|
|
|
|
endif()
|
2020-02-09 03:27:54 +00:00
|
|
|
# Tools needs to come late to ensure that MLIR_ALL_LIBS is populated.
|
|
|
|
# Generally things after this point may depend on MLIR_ALL_LIBS or libMLIR.so.
|
2020-10-04 22:17:34 +00:00
|
|
|
add_subdirectory(tools)
|
2019-04-02 17:02:07 +00:00
|
|
|
|
2020-10-04 22:17:34 +00:00
|
|
|
if( LLVM_INCLUDE_EXAMPLES )
|
2019-04-02 17:02:07 +00:00
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
2019-11-20 05:04:45 +00:00
|
|
|
|
2020-10-04 22:17:34 +00:00
|
|
|
option(MLIR_INCLUDE_DOCS "Generate build targets for the MLIR docs."
|
|
|
|
${LLVM_INCLUDE_DOCS})
|
2020-01-25 17:17:31 +00:00
|
|
|
if (MLIR_INCLUDE_DOCS)
|
|
|
|
add_subdirectory(docs)
|
|
|
|
endif()
|
|
|
|
|
2020-10-04 22:17:34 +00:00
|
|
|
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
2019-11-20 05:04:45 +00:00
|
|
|
install(DIRECTORY include/mlir include/mlir-c
|
|
|
|
DESTINATION include
|
|
|
|
COMPONENT mlir-headers
|
|
|
|
FILES_MATCHING
|
2020-01-06 09:01:59 +00:00
|
|
|
PATTERN "*.def"
|
2019-11-20 05:04:45 +00:00
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN "*.inc"
|
2019-12-29 17:04:09 +00:00
|
|
|
PATTERN "*.td"
|
2019-11-20 05:04:45 +00:00
|
|
|
PATTERN "LICENSE.TXT"
|
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY ${MLIR_INCLUDE_DIR}/mlir ${MLIR_INCLUDE_DIR}/mlir-c
|
|
|
|
DESTINATION include
|
|
|
|
COMPONENT mlir-headers
|
|
|
|
FILES_MATCHING
|
2020-01-22 00:44:17 +00:00
|
|
|
PATTERN "*.def"
|
2019-11-20 05:04:45 +00:00
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN "*.gen"
|
|
|
|
PATTERN "*.inc"
|
2020-01-22 00:44:17 +00:00
|
|
|
PATTERN "*.td"
|
2019-11-20 05:04:45 +00:00
|
|
|
PATTERN "CMakeFiles" EXCLUDE
|
|
|
|
PATTERN "config.h" EXCLUDE
|
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT LLVM_ENABLE_IDE)
|
|
|
|
add_llvm_install_targets(install-mlir-headers
|
|
|
|
DEPENDS mlir-headers
|
|
|
|
COMPONENT mlir-headers)
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-01-22 00:44:17 +00:00
|
|
|
|
|
|
|
add_subdirectory(cmake/modules)
|