[PATCH] D33198: Header file to help forcibly link GPURuntime

Singapuram Sanjay Srivallabh via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 23 00:40:56 PDT 2017


singam-sanjay added inline comments.


================
Comment at: include/polly/Support/LinkGPURuntime.h:18
+
+extern "C"
+{
----------------
grosser wrote:
> singam-sanjay wrote:
> > Although the Julia (the external tool) compiled without this construct, would it be better to enclose the #include line inside this extern "C" since it specifies that the code within should be treated as C code ?
> > 
> > e.g. Lines like the following, in GPUJIT.c, which are allowed in the default C dialect used by GCC, would fail when compiled as C++ ( although it didn't this time. Why was that the case ? )
> > 
> > 
> >   - PollyGPUFunction *Function = malloc(sizeof(PollyGPUFunction)); ([[ https://github.com/llvm-mirror/polly/blob/99a2e0c6bb2713e700c33cec48a9e8dd0461f9f6/tools/GPURuntime/GPUJIT.c#L467 | 1 ]] , [[ https://github.com/llvm-mirror/polly/blob/99a2e0c6bb2713e700c33cec48a9e8dd0461f9f6/tools/GPURuntime/GPUJIT.c#L1192 | 2 ]])
> >   - [[ https://github.com/llvm-mirror/polly/blob/99a2e0c6bb2713e700c33cec48a9e8dd0461f9f6/tools/GPURuntime/GPUJIT.c#L606 | PollyGPUDevicePtr *DevData = malloc(sizeof(PollyGPUDevicePtr)); ]]
> > 
> > 
> Why are you including the full .c file? You should probably introduce a GPUJIT.h header file and only include this one. Like this there is also no need to make CUDA or OpenCL includes available when linking.
I did it this way having Julia in mind. If I had to #include just the GPUJIT.h, I'd have to link libGPURuntime.so to libjulia.so, which would require the rpath to libGPURuntime.so's  location. But, the reviewers weren't happy with explicitly adding the rpath. So, I included GPUJIT.c and called every function to ensure an equivalent of linking to GPURuntime happend when I included LinkGPURuntime.h.

I'm now working to see if I could do away with GPUJIT.c and make libGPURuntime.so available by copying it to locations specified in RPATH of libjulia.so.


Repository:
  rL LLVM

https://reviews.llvm.org/D33198





More information about the llvm-commits mailing list