From 3f5c581a77ee813fc283936e88906497fbce2755 Mon Sep 17 00:00:00 2001 From: Tobias Gysi Date: Thu, 11 Jun 2020 10:31:06 +0200 Subject: [PATCH] some small updates --- CMakeLists.txt | 16 ++++++++-------- README.md | 6 +++++- lib/Conversion/LoopsToCUDA/CMakeLists.txt | 4 ++-- .../LoopsToCUDA/ConvertKernelFuncToCubin.cpp | 2 +- .../LoopsToCUDA/ConvertKernelFuncToHsaco.cpp | 2 +- oec-opt/oec-opt.cpp | 4 ++-- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fe1d7a..244b831 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,16 +32,16 @@ include_directories(${PROJECT_BINARY_DIR}/include) link_directories(${LLVM_BUILD_LIBRARY_DIR}) add_definitions(${LLVM_DEFINITIONS}) -set(OEC_CUDA_BACKEND_ENABLED 1 CACHE BOOL "Enable building the oec CUDA backend") -set(OEC_ROCM_BACKEND_ENABLED 0 CACHE BOOL "Enable building the oec ROCM backend") -if(OEC_CUDA_BACKEND_ENABLED) - add_definitions(-DOEC_CUDA_BACKEND_ENABLED) +set(CUDA_BACKEND_ENABLED 1 CACHE BOOL "Enable building the oec CUDA backend") +set(ROCM_BACKEND_ENABLED 0 CACHE BOOL "Enable building the oec ROCM backend") +if(CUDA_BACKEND_ENABLED) + add_definitions(-DCUDA_BACKEND_ENABLED) endif() -if(OEC_ROCM_BACKEND_ENABLED) - add_definitions(-DOEC_ROCM_BACKEND_ENABLED) +if(ROCM_BACKEND_ENABLED) + add_definitions(-DROCM_BACKEND_ENABLED) endif() -if (OEC_CUDA_BACKEND_ENABLED) +if (CUDA_BACKEND_ENABLED) if (NOT ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)) message(SEND_ERROR "Building the oec CUDA backend requires NVPTX") endif() @@ -54,7 +54,7 @@ if (OEC_CUDA_BACKEND_ENABLED) endif() find_library(CUDA_RUNTIME_LIBRARY cuda) endif() -if (OEC_ROCM_BACKEND_ENABLED) +if (ROCM_BACKEND_ENABLED) if (NOT ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)) message(SEND_ERROR "Building the oec ROCM backend requires AMDGPU") endif() diff --git a/README.md b/README.md index 8da90d4..973f49d 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ mkdir build && cd build cmake -G Ninja .. -DMLIR_DIR=$PREFIX/lib/cmake/mlir -DLLVM_EXTERNAL_LIT=$BUILD_DIR/bin/llvm-lit cmake --build . --target check-oec-opt ``` +The ROCM_BACKEND_ENABLED flag enables the support for AMDGPU tragets. It requires an llvm build with lld and we need to set the path to lld using the following flag: +```sh +-DLLD_DIR=$PREFIX/lib/cmake/lld +``` To build the documentation from the TableGen description of the dialect operations, run ```sh cmake --build . --target mlir-doc @@ -22,7 +26,7 @@ cmake --build . --target mlir-doc Cmake configuration for llvm ``` -cmake -G Ninja ../llvm -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_TARGETS_TO_BUILD="host;NVPTX" -DCMAKE_INSTALL_PREFIX= -DLLVM_ENABLE_PROJECTS='mlir' -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_ENABLE_OCAMLDOC=OFF -DLLVM_ENABLE_BINDINGS=OFF -DLLVM_INSTALL_UTILS=ON -DMLIR_CUDA_RUNNER_ENABLED=ON -DCMAKE_CUDA_COMPILER= -DCMAKE_LINKER= -DLLVM_PARALLEL_LINK_JOBS=2 +cmake -G Ninja ../llvm -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_TARGETS_TO_BUILD="host;NVPTX;AMDGPU" -DCMAKE_INSTALL_PREFIX= -DLLVM_ENABLE_PROJECTS='mlir;lld' -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_ENABLE_OCAMLDOC=OFF -DLLVM_ENABLE_BINDINGS=OFF -DLLVM_INSTALL_UTILS=ON -DMLIR_CUDA_RUNNER_ENABLED=ON -DCMAKE_CUDA_COMPILER= -DCMAKE_LINKER= -DLLVM_PARALLEL_LINK_JOBS=2 ``` Do not forget to apply possible patches to llvm before compiling (patches located in stencil-dialect/patches). diff --git a/lib/Conversion/LoopsToCUDA/CMakeLists.txt b/lib/Conversion/LoopsToCUDA/CMakeLists.txt index 0af1c00..083db14 100644 --- a/lib/Conversion/LoopsToCUDA/CMakeLists.txt +++ b/lib/Conversion/LoopsToCUDA/CMakeLists.txt @@ -1,4 +1,4 @@ -if(OEC_CUDA_BACKEND_ENABLED) +if(CUDA_BACKEND_ENABLED) set(NVPTX_LIB NVPTXCodeGen NVPTXDesc @@ -9,7 +9,7 @@ if(OEC_CUDA_BACKEND_ENABLED) MLIRTargetNVVMIR ) endif() -if(OEC_ROCM_BACKEND_ENABLED) +if(ROCM_BACKEND_ENABLED) set(AMDGPU_LIBS AMDGPUAsmParser AMDGPUCodeGen diff --git a/lib/Conversion/LoopsToCUDA/ConvertKernelFuncToCubin.cpp b/lib/Conversion/LoopsToCUDA/ConvertKernelFuncToCubin.cpp index dceccc3..8db2ce4 100644 --- a/lib/Conversion/LoopsToCUDA/ConvertKernelFuncToCubin.cpp +++ b/lib/Conversion/LoopsToCUDA/ConvertKernelFuncToCubin.cpp @@ -13,7 +13,7 @@ #include "mlir/Transforms/Passes.h" #include "llvm/Support/TargetSelect.h" -#ifdef OEC_CUDA_BACKEND_ENABLED +#ifdef CUDA_BACKEND_ENABLED #include "cuda.h" using namespace mlir; diff --git a/lib/Conversion/LoopsToCUDA/ConvertKernelFuncToHsaco.cpp b/lib/Conversion/LoopsToCUDA/ConvertKernelFuncToHsaco.cpp index 29e3efa..0d5d849 100644 --- a/lib/Conversion/LoopsToCUDA/ConvertKernelFuncToHsaco.cpp +++ b/lib/Conversion/LoopsToCUDA/ConvertKernelFuncToHsaco.cpp @@ -18,7 +18,7 @@ #include "llvm/Support/TargetSelect.h" #include "llvm/Target/TargetMachine.h" -#ifdef OEC_ROCM_BACKEND_ENABLED +#ifdef ROCM_BACKEND_ENABLED // MC headers. #include "llvm/MC/MCAsmBackend.h" diff --git a/oec-opt/oec-opt.cpp b/oec-opt/oec-opt.cpp index 9b84d83..4a32e95 100644 --- a/oec-opt/oec-opt.cpp +++ b/oec-opt/oec-opt.cpp @@ -88,10 +88,10 @@ int main(int argc, char **argv) { registerDialect(); // Register the stencil pipelines -#ifdef OEC_CUDA_BACKEND_ENABLED +#ifdef CUDA_BACKEND_ENABLED registerGPUToCUBINPipeline(); #endif -#ifdef OEC_ROCM_BACKEND_ENABLED +#ifdef ROCM_BACKEND_ENABLED registerGPUToHSACOPipeline(); #endif