Hello,
I want to use CUDA-8.0 and OpenCL on SuSE Linux Enterprise 12.1. Unfortunately NVIDIA supports only OpenCL 1.2, so that I've installed the latest version of the Intel OpenCL SDK as well. I get a warning about a deprecated function if I use "clCreateCommandQueue ()" and my program breaks with a segmentation fault if I call "clCreateCommandQueueWithProperties ()" for my NVIDIA Quadro K2200 graphics card (it doesn't matter if I use Sun C, icc, or gcc). I assume the reason for the segmentation fault is that the graphics device supports only OpenCL 1.2 and "clCreateCommandQueueWithProperties ()" doesn't honour this fact. Now I have a more or less complicated code to create a command queue and to get my program working with different platforms (OpenCL 1.2 and OpenCL 2.x, Linux and Windows) and compilers. Why do I have to determine the OpenCL version of the device at run-time, if the OpenCL SDK reports CL_VERSION_2_0? In my opinion the library should automatically use the correct function and parameters if the device supports only OpenCL 1.2. I'm new to OpenCL so I may have misunderstood something or perhaps my program is even faulty. How can I create a command queue for OpenCL 1.2 and 2.x in a portable way, so that I don't get warnings about deprecated functions and I get a program that works if I compile it on different platforms with different compilers? I don't know how "clCreateCommandQueueWithProperties ()" will be translated for the device. Is it possible that the function doesn't work as expected if the device supports only OpenCL 1.2?
#if !defined(CL_VERSION_2_0) || defined(__NVCC__)
if (outOfOrderQueue == 1)
{
printf (" Using out-of-order clCreateCommandQueue (...)\n\n");
command_queue = clCreateCommandQueue (context, device_id,
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &errcode_ret);
}
else
{
printf (" Using in-order clCreateCommandQueue (...)\n\n");
command_queue = clCreateCommandQueue (context, device_id, 0, &errcode_ret);
}
#else
/* "deviceOpenCL_MajorVersion - '0'" converts char to int */
if ((deviceOpenCL_MajorVersion - '0') == 2)
{
cl_queue_properties queueProps[] =
{ CL_QUEUE_PROPERTIES,
(const cl_queue_properties) (CL_QUEUE_ON_DEVICE &&
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE),
0
};
printf (" Using out-of-order clCreateCommandQueueWithProperties (...)\n\n");
command_queue = clCreateCommandQueueWithProperties (context,
device_id, queueProps, &errcode_ret);
}
else
{
/* CL_VERSION_2_0 reported, but device supports only OpenCL 1.2 */
if (outOfOrderQueue == 1)
{
printf (" Using out-of-order clCreateCommandQueue (...)\n\n");
command_queue = clCreateCommandQueue (context, device_id,
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &errcode_ret);
}
else
{
printf (" Using in-order clCreateCommandQueue (...)\n\n");
command_queue = clCreateCommandQueue (context, device_id, 0, &errcode_ret);
}
}
#endif
CheckRetValueOfOpenCLFunction (errcode_ret);
I would be grateful for any comments entlighten my understanding of the problem and why I have to choose between clCreateCommandQueueWithProperties and clCreateCommandQueue myself when CL_VERSION_2_0 is reported. Thank you very much for any help in advance.
Siegmar