This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OpenCL hangs



The following OpenCL program hangs on the evmk2h platform.  The problem occurs when reading event profiling information from within an callback function.  Disabling CL_QUEUE_PROFILING_ENABLE avoids stalling the application (but disallows profiling, obviously).  The same program works fine on a Xeon Phi.  Could you please fix this?  BTW, I am very glad that OpenCL and OpenMP are (finally!) supported.

Thanks,  John Romein

#define __CL_ENABLE_EXCEPTIONS
#include <CL/cl.hpp>
#include <iostream>
#include <string>
#include <vector>


const char *kernelSource = "kernel void foo() { printf(\"kernel running\\n\"); }";


void eventCompleteCallBack(cl_event ev, cl_int status, void *arg)
{
  cl_ulong start, end;

  std::cout << "before clGetEventProfilingInfo" << std::endl;
  clGetEventProfilingInfo(ev, CL_PROFILING_COMMAND_START, sizeof start, &start, 0);
  std::cout << "after clGetEventProfilingInfo" << std::endl;
  clGetEventProfilingInfo(ev, CL_PROFILING_COMMAND_END, sizeof end, &end, 0);
  std::cout << "time = " << (end - start) / 1e9 << std::endl;
}


int main(int argc, char *argv[])
{
  try
  {
    cl::Context             context(CL_DEVICE_TYPE_ACCELERATOR);
    std::vector<cl::Device> devices(context.getInfo<CL_CONTEXT_DEVICES>());
    cl::Program::Sources    source(1, std::make_pair(kernelSource, strlen(kernelSource)));
    cl::Program             program(context, source);
    program.build(devices);

    cl::CommandQueue        queue(context, devices[0], CL_QUEUE_PROFILING_ENABLE);
    cl::Kernel              kernel(program, "foo");
    cl::Event               event;

    queue.enqueueTask(kernel, 0, &event);
    event.setCallback(CL_COMPLETE, eventCompleteCallBack);
    queue.finish(); // not strictly necessary
  } catch (cl::Error &err) {
    std::cerr <<"cl::Error(): " << err.what() << '(' << err.err() << ')' << std::endl;
  }

  return 0;
}

  • Moved this thread to High Performace Computing forum.

    Thanks.

  • Hi John,

        Thanks for reporting this bug.  I just fixed it and the fix should be available in our next OpenCL release.  If you are curious, enclosed are the running results from your application on my K2H EVM (ARM 1.0GHz, DSP 1.228GHz).

    - Yuan

    root@keystone-evm:~/yuan_examples/forum# ./profilehang
    [core 0] kernel running
    before clGetEventProfilingInfo
    after clGetEventProfilingInfo
    time = 0.000229
    root@keystone-evm:~/yuan_examples/forum# ./profilehang
    [core 0] kernel running
    before clGetEventProfilingInfo
    after clGetEventProfilingInfo
    time = 0.000233
    root@keystone-evm:~/yuan_examples/forum# ./profilehang
    [core 0] kernel running
    before clGetEventProfilingInfo
    after clGetEventProfilingInfo
    time = 0.000232

  • Thanks, looking forward to the next release.

    John