Polygeist icon indicating copy to clipboard operation
Polygeist copied to clipboard

Is it possible to take MLIR generated by CUDA-to-CPU flow to the cpu-openmp executable?

Open ericxu233 opened this issue 1 year ago • 1 comments

I want to modify the MLIR generated by --cuda-lower --cpuify and then take it back to the compiler and generate the opemp executable. Is there a way to do that?

I tried the cgeist command like this:

/home/xuhanya1/CUDAtoX/Polygeist/build/bin/cgeist -fopenmp -O2 --function=* -c -O2 -I/home/xuhanya1/CUDAtoX/Polygeist/build/projects/openmp/runtime/src/ -resource-dir=/home/xuhanya1/CUDAtoX/Polygeist/build/lib/clang/18/ -I/home/xuhanya1/CUDAtoX/Polygeist/build/projects/openmp/runtime/src/ -I/usr/local/cuda/include/ --cuda-gpu-arch=sm_75 --cuda-path=/usr/local/cuda/ --polygeist-alternatives-mode=static -std=c++17 -I/home/xuhanya1/CUDAtoX/rodinia/common// -include my_timing.h -include my_verification.h -D_MY_COMPILER_NAME_=\"c7094f0e7bca.polygeist.mincut.inner-serialize=1.raise-scf-to-affine.scal-rep=0\" -DMY_VERIFICATION_DISABLE pathfinder.sme.no-opt.conf1.mlir -o pathfinder.o -I../util -v

However, it seems that it does nothing and the -v output looks like this:

clang version 18.0.0 (https://github.com/llvm/llvm-project.git 26eb4285b56edd8c897642078d91f16ff0fd3472)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/xuhanya1/CUDAtoX/Polygeist/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda/, version 12.1

ericxu233 avatar May 05 '24 15:05 ericxu233

Sorry for the delay.

Currently there is no way to do that with cgeist, as it expects a c/c++ file. It should be easy to add, however, you can currently use polygeist-opt with --lower-affine, --convert-polygeist-to-llvm and then mlir-translate to convert that to llvm IR, which can then be compiled to an object file using clang.

ivanradanov avatar Jun 03 '24 02:06 ivanradanov