5 Replies Latest reply on May 11, 2010 3:03 PM by MicahVillmow

    __constant memory

    stefan_w

      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?

        • __constant memory
          MicahVillmow
          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.
            • __constant memory
              stefan_w

              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?

            • __constant memory
              MicahVillmow
              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.
              • __constant memory
                MicahVillmow
                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.