cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

afo
Adept I

Constant buffer for a kernel

How to implement a constant (cached) memory buffer?

Hi,

I have a kernel that uses a constant value buffer as an input (each workitem reads the values from the constant buffer and writes a result based in its own work item value to an output buffer).

I would like that those constants were cached, so the entire workgroup uses those cached values and not a global memory read in each workitem. This is done automatically in the GPU or I should do something to get that? Thanks in advance for your help.

best regards,

Alfonso

0 Likes
2 Replies
himanshu_gautam
Grandmaster

Constant buffer for a kernel

Hi afo,

IIRC There are basically three ways for getting reads & writes faster than global memory access:

1. use cached buffers

2. use Images

3. use constant cache.

Refer to the samples constant memory bandwidth & Buffer Bandwidth for details. Also refer to the chapter4 OpenCL Programming Guide(Memory Transfer Optimizations).

0 Likes
MicahVillmow
Staff
Staff

Constant buffer for a kernel

afo,
If you use constant address space, the data is cached. Images and restricted read-only global buffers are also cached.
0 Likes