Skip to content

Latest commit

 

History

History
65 lines (55 loc) · 2.37 KB

README.md

File metadata and controls

65 lines (55 loc) · 2.37 KB

[EXPERIMENTAL] TPP GPU support

Experimental support for GPU code generation within TPP-MLIR.

Note: the GPU support is disabled by default. It is an opt-in feature which can be enabled with CMake flag -DTPP_GPU=cuda.

LLVM with GPU support

Build LLVM with GPU support:

cd llvm-project/build

cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
   -DLLVM_INSTALL_UTILS=ON \
   -DLLVM_TARGETS_TO_BUILD="host;NVPTX;AMDGPU" \
   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DCMAKE_C_COMPILER=clang \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DCMAKE_CUDA_COMPILER=nvcc \
   -DMLIR_ENABLE_CUDA_RUNNER=ON \
   -DMLIR_ENABLE_CUDA_CONVERSIONS=ON \
   -DMLIR_ENABLE_SPIRV_CPU_RUNNER=ON \
   -DLLVM_USE_LINKER=lld

TPP MLIR with GPU support

This setup assumes that the LLVM with GPU support is set as $CUSTOM_LLVM_ROOT.

The GPU support is disabled by default and can be enabled with the CMake flag -DTPP_GPU=cuda.

cd tpp-mlir/build

cmake -G Ninja .. \
   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
   -DMLIR_DIR=$CUSTOM_LLVM_ROOT/lib/cmake/mlir \
   -DLLVM_EXTERNAL_LIT=$CUSTOM_LLVM_ROOT/bin/llvm-lit \
   -DCMAKE_C_COMPILER=clang \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DTPP_GPU="cuda"

CUDA setup

Troubleshooting

  • CUDA driver vs runtime version mismatch:
    • check if CUDA driver and cuda-toolkit versions are the same:
      nvidia-smi
      dpkg -l | grep cuda-toolkit
    • thread with more details - link
  • MLIR CUDA_ERROR_ILLEGAL_ADDRESS bug - link

Notes

  • Monitor GPU usage
    watch -n 0.1 nvidia-smi