0
votes

that might be a noob question but I want to use opencl to take advantage of the dozens of the gpu cores. A couple of days before, when I satrted searching about programing with opencl, I got confused with workgroups, work items, kernels and the logic of opencl. Before I proceed dealing with this staff, here is my quetion:

Can I just assign a thread with code to run in a single gpu compute core (or specified core) just like when you program a multi-core cpu?

1
"that might be a noob question", speculation is unnecessary. Ask your question, provide what you think the answer is and what lead you to that conclusion. Also, with a blanket statement like yours, provide some commentary about how you googled this already, what you found (if anything), and why it doesn't answer your question. SO is really about issues with code, providing code as an example of whats wrong.8protons
The searches I made, all talked about workgroups, work items, kernels. The basic examples were with these (workgroups, work items, kernels) in mind, and I couldn't find a straightforward way to do what I describe in my question.selfmade.exe

1 Answers

5
votes

No, that's not how it works. In OpenCL you write a kernel that executes a single work item of work. It might be as simple as a memory copy, or could read pixels from source images, mix them together, and write a pixel to an output image. This kernel gets executed across the whole work group (e.g., the whole output image). The runtime makes that happens. It's not like multithreaded CPU code where each thread does different stuff. It's more like having a warehouse full of 1000 interns. Each has a unique employee number, and the stuff in the warehouse has numbers, so you can say things like "look in boxes (your number) and (your number plus 1000) and put the pieces you find inside together and put the new part in box (your number plus 2000)". You say that once in the megaphone, and 1000 parts get built in parallel.