2
votes

I am the very beginner in OpenCL programming. My problem occurs when I try to debug OpenCL kernels in Visual Studio 2017. Debugger don't stop on breakpoints in kernel code but works fine in the Main function. I have installed Intel System Studio 2019.

I build context in this way:

cl_int platform_id = 0;
cl_int device_id = 0;
cl_context_properties contextProps[3] = {
    CL_CONTEXT_PLATFORM,
    (cl_context_properties)(platformList[platform_id])(),
    0
};

cl::Context context(CL_DEVICE_TYPE_GPU, contextProps, NULL, NULL, &errorState);

I try to build program with debugging options:

cl::Program program(context, source);
errorState = program.build(devices, "-g -s C:/OpenCL_Intel/OpenCL_Intel/multiply.cl");

After this I set parameters for kernel function and run the kernel:

cl::Kernel kernel(program, "multiply", &errorState);
kernel.setArg(0, inA);
kernel.setArg(1, inB);
kernel.setArg(2, outCL);
kernel.setArg(3, arraySize);

cl::Event event;
errorState = queue.enqueueNDRangeKernel(kernel, cl::NullRange,
    cl::NDRange(arraySize), cl::NDRange(1), NULL, &event);
checkErr(errorState, "ComamndQueue::enqueueNDRangeKernel()");

event.wait();
errorState = queue.enqueueReadBuffer(outCL, CL_TRUE, 0, sizeof(int) * arraySize, out);
checkErr(errorState, "ComamndQueue::enqueueReadBuffer()");

My debugging options in my OpenCL project I have also set some options in Code Builder:

  • API Debugger -> Enable OpenCL Tools API Debugger -> True
  • GPU Kernel Debugger -> Enable Debugging -> True

Thank you in advance

1

1 Answers

0
votes

Due to Windows limitations, debugging OpenCL kernels on GPU requires a specific host/target configuration of the system. You can find a step by step tutorial on the Intel website - https://software.intel.com/en-us/openclsdk-devguide-debugging-opencl-kernels-on-gpu.

Please also make sure you have the latest version of the OpenCL Runtime (video driver), as well as, the latest version of the OpenCL SDK.