cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

stefan_w
Journeyman III

__constant memory

With v2.1 __constant memory still seems to be nothing else but __global memory. Will __constant memory be cached with future releases or should one use texture access instead of __constant memory access?

0 Likes
5 Replies

stefan_w,
This is something that didn't make it into the 2.1 release by default but will make it into the next release. There is something we added in 2.1 that helps the compiler determine if we can use hardware constant memory or if we have to back it into global memory. Please see section 4.5 of the OpenCL programming guide on Constant memory optimizations. It is a pointer attribute that gives a hint to the compiler on the max size of the constant pointer.
0 Likes

MicahVillmow,

I have added the __attribute__((max_constant_size (16384))) hint to my __constant buffer as stated in section 4.5 of the programming guide, but this did not result in any perfomance improvement.

Is this attribute already supported in v2.1 or will I have to wait for the next release?

0 Likes

stefan,
This is supported in 2.1. However, the performance gain mainly comes if the indexes are known at compile time. If the indexes are not known at compile time then the hardware constant cache cannot be utilized and the performance should be the exact same as without the attribute.
0 Likes

Hi Micah,

What do you mean when you say "if the indexes are known at compile time"? what is index here and can you help me know it with an example?

 

Thx,

Roto

0 Likes

rotor,
the index into a pointer must be known at compile time for the compiler to generate code that uses the hardware cache. If the index into the pointer is dynamic, then the compiler generates vfetch instructions, which go out to main memory and provide no benefits currently over global memory pointers.
0 Likes