Ask Your Question
0

OpenCV OpenCL- Where is creation of context?

asked 2015-07-15 12:30:33 -0600

Neamah gravatar image

I'm using OpenCV OpenCL and I've been tracing the code that gets executed when OpenCL is on. I see the creation of a kernel, filling the kernel args and running the kernel, but I see no setup in terms of creating a context and program. Where does this happen, if at all?

For example, in /modules/imgproc/src/color.cpp, I see that cv::cvtColor calls ocl_cvtColor. Inside ocl_cvtColor, I see how the kernel is set up and run, but there isn't any mention of a context. I thought a context is necessary for OpenCL programs to run on the GPU.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-07-16 05:34:18 -0600

LBerger gravatar image

updated 2015-07-16 07:40:35 -0600

May be it could help you

there is some link in stackoverfloaw here and a link in previous link with some code in C++

edit flag offensive delete link more

Comments

1

@JohannesZ thanks for link I don't insert in my post because it's also good answer

LBerger gravatar imageLBerger ( 2015-07-16 07:42:36 -0600 )edit

Hi, thanks for the answer!

I've read through most of those links and they're pretty helpful in understanding how I can use Context, Kernel and Program classes to execute my own kernels.

What I'm more curious about is how OpenCV runs its own kernels. The best example I can give is cvtColor. Color conversions are one area that OpenCV has enabled OpenCL for. Reading through the code, I see how the cv::cvtColor function decides whether to use the CPU implementation or the GPU implementation.

Once it decides to use GPU implementation, it calls the function ocl_cvtColor. My question: inside this function, there is no mention of a context being created. Where does OpenCV do this setup? Do they do it at all? Is OpenCV creating and running a kernel without a context??

Neamah gravatar imageNeamah ( 2015-07-16 14:01:45 -0600 )edit

may be in function HaveOpencl line 1455 in my own configuration

LBerger gravatar imageLBerger ( 2015-07-16 14:36:22 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-07-15 12:30:33 -0600

Seen: 534 times

Last updated: Jul 16 '15