Make OpenCL dummyKernel to require a input parameter
authorJukka Maatta <jukka.s.maatta@gmail.com>
Wed, 27 Feb 2019 15:03:52 +0000 (17:03 +0200)
committerPaul Bauer <paul.bauer.q@gmail.com>
Fri, 1 Mar 2019 15:35:50 +0000 (16:35 +0100)
This is a tentative fix for OpenCL error with mdrun on MacOS.
MacOS seems to require that kernel functions have at least one parameter.
Otherwise clBuildProgram fails with error -11.

Here dummyKernel takes an empty pointer in the definition.
We then pass an empty pointer to dummyKernel with clSetKernelArg.

Fixes #2865

Change-Id: Ib7c08eeeb2ec6d8a43bfe703cf1b273819a45a29

src/gromacs/gpu_utils/gpu_utils_ocl.cpp

index d5dc3a9d90271d642cd6b3d00da2ff0041f52d88..a2173ad75035561655d3c160f7856e0ca7c85d50 100644 (file)
@@ -169,7 +169,8 @@ static bool isDeviceSane(const gmx_device_info_t *devInfo,
         return false;
     }
 
-    const char *lines[] = { "__kernel void dummyKernel(){}" };
+    // Some compilers such as Apple's require kernel functions to have at least one argument
+    const char *lines[] = { "__kernel void dummyKernel(__global void* input){}" };
     ClProgram   program(clCreateProgramWithSource(context, 1, lines, nullptr, &status));
     if (status != CL_SUCCESS)
     {
@@ -190,6 +191,8 @@ static bool isDeviceSane(const gmx_device_info_t *devInfo,
         return false;
     }
 
+    clSetKernelArg(kernel, 0, sizeof(void*), nullptr);
+
     const size_t localWorkSize = 1, globalWorkSize = 1;
     if ((status =
              clEnqueueNDRangeKernel(commandQueue, kernel, 1, nullptr,