Skip to content

CUDA program to LLVM #439

@RSCERE

Description

@RSCERE

Hi, I was trying to convert the official CUDA Sample vectorAdd program to mlir and llvm using Polygeist. The Polygeist was built using these commands:

LLVM-PROJECT BUILD
cmake -G Ninja ../llvm \ -DLLVM_ENABLE_PROJECTS="clang;mlir;lld" \ -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi" \ -DLLVM_TARGETS_TO_BUILD="X86;NVPTX" \ -DMLIR_ENABLE_CUDA_RUNNER=ON \ -DMLIR_ENABLE_EXECUTION_ENGINE=ON \ -DLLVM_ENABLE_RTTI=ON \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \ -DCMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES=/usr/local/cuda/include \ -DCLANG_LINKER_WRAPPER_ENABLED=OFF

ninja

POLYGEIST BUILD
cmake -G Ninja .. \ -DMLIR_DIR=$PWD/../llvm-project/build/lib/cmake/mlir \ -DCLANG_DIR=$PWD/../llvm-project/build/lib/cmake/clang \ -DPOLYGEIST_ENABLE_CUDA=1 \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_ENABLE_RTTI=ON \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES=/usr/local/cuda/include

ninja

The program converts to mlir without any errors using:
./cgeist --immediate -cuda-path=/usr/local/cuda -I/usr/local/cuda/include -I/usr/lib/gcc/x86_64-linux-gnu/11/include --resource-dir=/local/Polygeist/llvm-project/build/lib/clang/18 -I/local/cuda-samples/Common --cuda-gpu-arch=sm_86 vectorAdd.cu
The ouput is MLIR_trace.txt

But when I directly try to convert the using:
./cgeist -cuda-path=/usr/local/cuda -I/usr/local/cuda/include -I/usr/lib/gcc/x86_64-linux-gnu/11/include --resource-dir=/local/Polygeist/llvm-project/build/lib/clang/18 -I/local/cuda-samples/Common --cuda-gpu-arch=sm_86 vectorAdd.cu
The ouput is LLVM_trace.txt

Are there any steps that I am missing? What can be the issue? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions