[polly] r313623 - [GPUJIT] Improved temporary file handling.

Philipp Schaad via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 03:41:30 PDT 2017


Author: phschaad
Date: Tue Sep 19 03:41:29 2017
New Revision: 313623

URL: http://llvm.org/viewvc/llvm-project?rev=313623&view=rev
Log:
[GPUJIT] Improved temporary file handling.

Summary: Imporved the way the GPUJIT handles temporary files for Intel's Beignet.

Reviewers: bollu, grosser

Reviewed By: grosser

Subscribers: philip.pfaffe, pollydev

Differential Revision: https://reviews.llvm.org/D37691

Modified:
    polly/trunk/tools/GPURuntime/GPUJIT.c

Modified: polly/trunk/tools/GPURuntime/GPUJIT.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/tools/GPURuntime/GPUJIT.c?rev=313623&r1=313622&r2=313623&view=diff
==============================================================================
--- polly/trunk/tools/GPURuntime/GPUJIT.c (original)
+++ polly/trunk/tools/GPURuntime/GPUJIT.c Tue Sep 19 03:41:29 2017
@@ -507,21 +507,20 @@ static PollyGPUFunction *getKernelCL(con
   cl_int Ret;
 
   if (HandleOpenCLBeignet) {
-    // TODO: This is a workaround, since clCreateProgramWithLLVMIntel only
+    // This is a workaround, since clCreateProgramWithLLVMIntel only
     // accepts a filename to a valid llvm-ir file as an argument, instead
     // of accepting the BinaryBuffer directly.
-    FILE *fp = fopen("kernel.ll", "wb");
-    if (fp != NULL) {
-      fputs(BinaryBuffer, fp);
-      fclose(fp);
-    }
+    char FileName[] = "/tmp/polly_kernelXXXXXX";
+    int File = mkstemp(FileName);
+    write(File, BinaryBuffer, strlen(BinaryBuffer));
 
     ((OpenCLKernel *)Function->Kernel)->Program =
         clCreateProgramWithLLVMIntelFcnPtr(
             ((OpenCLContext *)GlobalContext->Context)->Context, 1,
-            &GlobalDeviceID, "kernel.ll", &Ret);
+            &GlobalDeviceID, FileName, &Ret);
     checkOpenCLError(Ret, "Failed to create program from llvm.\n");
-    unlink("kernel.ll");
+    close(File);
+    unlink(FileName);
   } else {
     size_t BinarySize = strlen(BinaryBuffer);
     ((OpenCLKernel *)Function->Kernel)->Program =




More information about the llvm-commits mailing list