26 cl_context context = 0;
27 cl_command_queue commandQueue = 0;
28 cl_program program = 0;
29 cl_device_id device = 0;
31 const int numMemoryObjects = 1;
32 cl_mem memoryObjects[numMemoryObjects] = {0};
41 cleanUpOpenCL(context, commandQueue, program, kernel, memoryObjects, numMemoryObjects);
42 cerr <<
"Failed to create an OpenCL context. " << __FILE__ <<
":"<< __LINE__ << endl;
50 cleanUpOpenCL(context, commandQueue, program, kernel, memoryObjects, numMemoryObjects);
51 cerr <<
"Failed to create the OpenCL command queue. " << __FILE__ <<
":"<< __LINE__ << endl;
57 if (!
createProgram(context, device,
"assets/template.cl", &program))
59 cleanUpOpenCL(context, commandQueue, program, kernel, memoryObjects, numMemoryObjects);
60 cerr <<
"Failed to create OpenCL program." << __FILE__ <<
":"<< __LINE__ << endl;
66 kernel = clCreateKernel(program,
"template", &errorNumber);
69 cleanUpOpenCL(context, commandQueue, program, kernel, memoryObjects, numMemoryObjects);
70 cerr <<
"Failed to create OpenCL kernel. " << __FILE__ <<
":"<< __LINE__ << endl;
87 const int workDimensions = 1;
88 size_t globalWorkSize[workDimensions] = {1};
95 if (!
checkSuccess(clEnqueueNDRangeKernel(commandQueue, kernel, workDimensions, NULL, globalWorkSize, NULL, 0, NULL, &event)))
97 cleanUpOpenCL(context, commandQueue, program, kernel, memoryObjects, numMemoryObjects);
98 cerr <<
"Failed enqueuing the kernel. " << __FILE__ <<
":"<< __LINE__ << endl;
106 cleanUpOpenCL(context, commandQueue, program, kernel, memoryObjects, numMemoryObjects);
107 cerr <<
"Failed waiting for kernel execution to finish. " << __FILE__ <<
":"<< __LINE__ << endl;
120 cleanUpOpenCL(context, commandQueue, program, kernel, memoryObjects, numMemoryObjects);
121 cerr <<
"Failed releasing the event object. " << __FILE__ <<
":"<< __LINE__ << endl;
131 cleanUpOpenCL(context, commandQueue, program, kernel, memoryObjects, numMemoryObjects);