user2167272
user2167272

Reputation: 41

What is the equivalent of clFinish in opencl c++ API wrapper?

I am new to opencl, but I am not new to GPU programming. I need to make sure that my cpu and gpu devices are synchronized with each other. It seems that I should use clFinish(cl::commandqueue queue), but I am using opencl c++ not opencl c.

So, is cl::finish() the equivalent of clFinish() or is there something else like cl::commandqueue::finish() (which visual studio dose not recognize)?

Can you pleaes provide your answers with example? I am new to opencl.

Upvotes: 4

Views: 196

Answers (1)

Sıddık Açıl
Sıddık Açıl

Reputation: 967

cl::command_queue::finish is the one you are looking for.

cl_int finish() const
{
    return detail::errHandler(::clFinish(object_), __FINISH_ERR);
}

cl::finish gets the default queue and performs finish on that queue.

inline cl_int finish(void)
{
    cl_int error;
    CommandQueue queue = CommandQueue::getDefault(&error);

    if (error != CL_SUCCESS) {
        return error;
    } 


    return queue.finish();
}

Upvotes: 1

Related Questions