#include #include #include #include #include #include #include #include #include int main() { cl_int error; cl_platform_id platform; cl_device_id device; cl_uint platforms, devices; error=clGetPlatformIDs(1, &platform, &platforms); error=clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, &devices); cl_context_properties properties[]={ CL_CONTEXT_PLATFORM, (cl_context_properties)platform, 0}; cl_context context=clCreateContext(properties, 1, &device, NULL, NULL, &error); assert(error == 0); cl_command_queue cq = clCreateCommandQueue(context, device, 0, &error); assert(error == 0); char *crash_cl = malloc(1000000); FILE *kernel_file = fopen("crash.cl", "r"); assert(kernel_file != 0); int read = fread(crash_cl, sizeof(char), 1000000, kernel_file); crash_cl[read] = 0; /* puts(crash_cl); */ /* Submit the source code of the transpose kernel to OpenCL */ cl_program prog=clCreateProgramWithSource(context, 1, (const char**)&crash_cl, NULL, &error); assert(kernel_file != 0); /* And compile it (after this we could extract the compiled version) */ assert(clBuildProgram(prog, 1, &device, "", NULL, NULL) == CL_SUCCESS); return 0; }