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

Singapuram Sanjay Srivallabh via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 15 08:03:40 PDT 2017


singam-sanjay added a comment.

I've uploaded only a proof-of-concept version. @grosser @Meinersbur Need your suggestions with code style, location of the file, etc. Questions inlined.



================
Comment at: CMakeLists.txt:209
   ${CMAKE_CURRENT_SOURCE_DIR}/lib/External
+  ${CMAKE_CURRENT_SOURCE_DIR}/tools
   ${CMAKE_CURRENT_BINARY_DIR}/include
----------------
This line makes available the files under tools/GPURuntime.

This is for a case when a program within the LLVM tree (opt, bugpoint) would require ForceGPURuntimeLinking.h. It isn't useful when the file is to be accessed by an external entitiy, e.g. Julia, since the line(s) that'll include <polly_src>/tools will have to be added to the compile commands of the tool.


================
Comment at: include/polly/Support/LinkGPURuntime.h:1
+//===- ??FOLDER??/LinkGPURuntime.h -- Headerfile to help force-link GPURuntime --------------------===//
+//////
----------------
Which folder would you recommend placing this file ? It's currently in include/polly/Support.


================
Comment at: include/polly/Support/LinkGPURuntime.h:18
+
+extern "C"
+{
----------------
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)); ]]




================
Comment at: include/polly/Support/LinkGPURuntime.h:34
+    polly_initContextCUDA();
+    polly_getKernel(nullptr, nullptr);
+    polly_freeKernel((PollyGPUFunction*)nullptr);
----------------
Should I typecast the nullptr (like in the line below) or leave it as is ?


Repository:
  rL LLVM

https://reviews.llvm.org/D33198





More information about the llvm-commits mailing list