@@ -19,7 +19,10 @@ int main(void) {
1919 const char * source =
2020 /* kernel pointer arguments must be __global, __constant, or __local. */
2121 /* https://www.khronos.org/registry/cl/sdk/2.1/docs/man/xhtml/restrictions.html */
22- "__kernel void main(__global int *out) {\n"
22+ /**/
23+ /* Kernel functions cannot be called main... NVIDIA's compiler may allow that
24+ * but others don't, so don't do it. */
25+ "__kernel void kmain(__global int *out) {\n"
2326 " out[0]++;\n"
2427 "}\n" ;
2528 cl_command_queue command_queue ;
@@ -37,7 +40,7 @@ int main(void) {
3740 context = clCreateContext (NULL , 1 , & device , NULL , NULL , NULL );
3841 program = clCreateProgramWithSource (context , 1 , & source , NULL , NULL );
3942 clBuildProgram (program , 1 , & device , "" , NULL , NULL );
40- kernel = clCreateKernel (program , "main " , NULL );
43+ kernel = clCreateKernel (program , "kmain " , NULL );
4144 buffer = clCreateBuffer (context , CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR , sizeof (cl_int ), & input , NULL );
4245 clSetKernelArg (kernel , 0 , sizeof (buffer ), & buffer );
4346 command_queue = clCreateCommandQueue (context , device , 0 , NULL );
0 commit comments