Hello, i’m currently working with my first project in openCL c++ wrapper with Nvidia SDK. The program runs and kernel does simple math,such as multiplies two arrays and squares the result.Each array has 10 thousand numbers. I had some trouble with recording time, but some people on the internet helped to find the correct syntax and methods. But even after proofing enabled and events made, I get 0 time. My kernel code :
std::string kernel_code =
" void kernel simple_add(global const float* A, global const float* B, global float* C){ "
" int id =get_global_id(0); "
" C[id]=sqrt(A[id]*B[id]); "
" }
And the code, which launches kernel and proofing :
cl::CommandQueue queue(context, default_device, CL_QUEUE_PROFILING_ENABLE);
queue.enqueueWriteBuffer(buffer_A, CL_TRUE, 0, sizeof(float) * 10000, A);
queue.enqueueWriteBuffer(buffer_B, CL_TRUE, 0, sizeof(float) * 10000, B);
cl::Kernel kernel_add = cl::Kernel(program, "simple_add");
kernel_add.setArg(0, buffer_A);
cl::Event event;
queue.enqueueNDRangeKernel(kernel_add, cl::NullRange, cl::NDRange(10000), cl::NullRange, NULL,&event);
queue.finish();
float C[10000];
queue.enqueueReadBuffer(buffer_C, CL_TRUE, 0, sizeof(float) * 10000, C);
cl_ulong time_start, time_end;
time_start = event.getProfilingInfo<CL_PROFILING_COMMAND_START>();
time_end = event.getProfilingInfo<CL_PROFILING_COMMAND_END>();
double time = time_end - time_start;
std::cout << "START: " << time_start << "
";
std::cout << "END: " << time_end << "
";
std::cout << "TIME: " << time << "
";
Any ideas why is it giving 0 ?