How do I use local memory in OpenCL?

后端 未结 3 1234
刺人心
刺人心 2020-12-05 03:52

I\'ve been playing with OpenCL recently, and I\'m able to write simple kernels that use only global memory. Now I\'d like to start using local memory, but I can\'t seem to f

3条回答
  •  心在旅途
    2020-12-05 04:38

    In OpenCL local memory is meant to share data across all work items in a workgroup. And it usually requires to do a barrier call before the local memory data can be used (for example, one work item wants to read a local memory data that is written by the other work items). Barrier is costly in hardware. Keep in mind, local memory should be used for repeated data read/write. Bank conflict should be avoided as much as possible.

    If you are not careful with local memory, you may end up with worse performance some time than using global memory.

提交回复
热议问题