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.
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?
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.
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?
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.