Executing OpenMP 4.0 code on Nvidia's GPU

Hi Arpith,

That is exactly what it is :).

My bad, I thought I copied over the libraries to where LIBRARY_PATH pointing but apparently it was copied to a wrong destination.

Thanks a lot.

Hi,

I see now that the linking happens at the binary level. I was wondering whether it is possible to link to the OpenMP runtime library at the LLVM IR level (to enable LTO optimizations for the code after library calls has been replaced).

I have done this before by linking to the bitcode of a file that contains the compiled CUDA implementation of the OpenMP runtime library. But it was a bit hacky, and offloading was not supported yet. Is it there a cleaner/standard way to do this ?

Thanks.

Hi Ahmed,

I am experimenting with LTO, but as you said, it’s still very hacky.

Here’s what I did. First compile the CUDA GPU OMP runtime with Clang (rather than nvcc) to bitcode. When I looked at Clang-CUDA a couple of weeks ago I could only get device side bitcode by using the temporary files generated after passing -save-temps to Clang. The OMP-GPU version of LLVM that you are using is not up to date with trunk, so I had to do a bit of massaging on the generated IR.

I then had to manually link the various device side bitcodes, call opt, llc, ptxas, and finally link it with the host object file.

We don’t have support for this in the driver as yet but once we move to trunk I will look into streamlining this.

Thanks,
Arpith

graycol.gifAhmed ElTantawy —01/20/2016 08:44:38 AM—Hi, I see now that the linking happens at the binary level. I was wondering

Thanks Arpith.

I was doing it in almost the same way but with nvcc (or apc-llc), and of course I had to make the produced LLVM-IR matches my version of LLVM.

But, I would imagine it will less messy if I can compile CUDA GPU OMP runtime with Clang directly. I found that there is a patch that was committed recently to enable compiling CUDA with clang (http://llvm.org/docs/CompileCudaWithLLVM.html).

Do you know if there is any restriction about the CUDA version for the compilation of CUDA with clang to work ?

Thanks a lot

graycol.gif

Hi Ahmed,

I was able to compile the CUDA GPU OMP runtime with Clang directly. I did have to remove some printf statements and asserts to get it to go through Clang-CUDA. Depending on your configuration, you may need some or all of these flags: --cuda-gpu-arch=sm_35 -nocudalib -DOMPTARGET_NVPTX_TEST=0 -DOMPTARGET_NVPTX_DEBUG=0 -DOMPTARGET_NVPTX_WARNING=0

Cheers,
Arpith

graycol.gifAhmed ElTantawy —01/21/2016 04:49:17 AM—Thanks Arpith. I was doing it in almost the same way but with nvcc (or apc-llc