Sorry, here is a piece of code hanging on clBuildProgram call…
#include <stdio.h>
#include <string.h>
#include <CL/cl.h>
int main(void) {
char *source_str = "__kernel void emptyKernel() {}";
size_t source_size = strlen(source_str);
// Get platform and device information
cl_platform_id platform_id = NULL;
cl_device_id device_id = NULL;
clGetPlatformIDs(1, &platform_id, NULL);
clGetDeviceIDs( platform_id, CL_DEVICE_TYPE_DEFAULT, 1, &device_id, NULL);
// print device name
size_t valueSize;
clGetDeviceInfo(device_id, CL_DEVICE_NAME, 0, NULL, &valueSize);
char* value = (char*) malloc(valueSize);
clGetDeviceInfo(device_id, CL_DEVICE_NAME, valueSize, value, NULL);
printf("Device: %s
", value);
free(value);
// Create an OpenCL context
cl_context context = clCreateContext( NULL, 1, &device_id, NULL, NULL, NULL);
// Create a program from the kernel source
cl_int ciErr;
cl_program program = clCreateProgramWithSource(context, 1,(const char **)&source_str, (const size_t *)&source_size, &ciErr);
if (ciErr != CL_SUCCESS)
{
printf("clCreateProgramWithSource failed");
return 1;
}
// Build the program
printf("BEFORE
");
clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
printf("AFTER
");// Randomly appears
// Clean up
clReleaseProgram(program);
clReleaseContext(context);
return 0;
}