Skip to content

Commit

Permalink
some small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Gysi committed Jun 11, 2020
1 parent 64b5af2 commit 3f5c581
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=<install_root> -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=<path_to_nvcc> -DCMAKE_LINKER=<path_to_lld> -DLLVM_PARALLEL_LINK_JOBS=2
cmake -G Ninja ../llvm -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_TARGETS_TO_BUILD="host;NVPTX;AMDGPU" -DCMAKE_INSTALL_PREFIX=<install_root> -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=<path_to_nvcc> -DCMAKE_LINKER=<path_to_lld> -DLLVM_PARALLEL_LINK_JOBS=2
```

Do not forget to apply possible patches to llvm before compiling (patches located in stencil-dialect/patches).
4 changes: 2 additions & 2 deletions lib/Conversion/LoopsToCUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if(OEC_CUDA_BACKEND_ENABLED)
if(CUDA_BACKEND_ENABLED)
set(NVPTX_LIB
NVPTXCodeGen
NVPTXDesc
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/Conversion/LoopsToCUDA/ConvertKernelFuncToCubin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Conversion/LoopsToCUDA/ConvertKernelFuncToHsaco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions oec-opt/oec-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ int main(int argc, char **argv) {
registerDialect<stencil::StencilDialect>();

// 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

Expand Down

0 comments on commit 3f5c581

Please sign in to comment.