| 384 | } |
| 385 | |
| 386 | bool createCommandQueue(cl_context context, cl_command_queue* commandQueue, cl_device_id* device) |
| 387 | { |
| 388 | cl_int errorNumber = 0; |
| 389 | cl_device_id* devices = NULL; |
| 390 | size_t deviceBufferSize = -1; |
| 391 | |
| 392 | /* Retrieve the size of the buffer needed to contain information about the devices in this OpenCL context. */ |
| 393 | if (!checkSuccess(clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &deviceBufferSize))) |
| 394 | { |
| 395 | cerr << "Failed to get OpenCL context information. " << __FILE__ << ":"<< __LINE__ << endl; |
| 396 | return false; |
| 397 | } |
| 398 | |
| 399 | if(deviceBufferSize == 0) |
| 400 | { |
| 401 | cerr << "No OpenCL devices found. " << __FILE__ << ":"<< __LINE__ << endl; |
| 402 | return false; |
| 403 | } |
| 404 | |
| 405 | /* Retrieve the list of devices available in this context. */ |
| 406 | devices = new cl_device_id[deviceBufferSize / sizeof(cl_device_id)]; |
| 407 | if (!checkSuccess(clGetContextInfo(context, CL_CONTEXT_DEVICES, deviceBufferSize, devices, NULL))) |
| 408 | { |
| 409 | cerr << "Failed to get the OpenCL context information. " << __FILE__ << ":"<< __LINE__ << endl; |
| 410 | delete [] devices; |
| 411 | return false; |
| 412 | } |
| 413 | |
| 414 | /* Use the first available device in this context. */ |
| 415 | *device = devices[0]; |
| 416 | delete [] devices; |
| 417 | |
| 418 | //const cl_command_queue_properties queue_properties = NULL; |
| 419 | /* Set up the command queue with the selected device. */ |
| 420 | //*commandQueue = clCreateCommandQueue(context, *device, &queue_properties, &errorNumber); |
| 421 | *commandQueue = clCreateCommandQueue(context, *device, CL_QUEUE_PROFILING_ENABLE, &errorNumber); |
| 422 | if (!checkSuccess(errorNumber)) |
| 423 | { |
| 424 | cerr << "Failed to create the OpenCL command queue. " << __FILE__ << ":"<< __LINE__ << endl; |
| 425 | return false; |
| 426 | } |
| 427 | |
| 428 | return true; |
| 429 | } |
| 430 | |
| 431 | bool createProgram(cl_context context, cl_device_id device, string filename, cl_program* program) |
| 432 | { |