7 Replies Latest reply on Nov 15, 2010 8:30 AM by zeland

    restrict

    zeland

      When will I get some profit of using restrict for __gloabal variable?

      (__global restrict float *)

        • restrict
          bubu

          Good question!

          • restrict
            gat3way

            What profit do you expect to see?

              • restrict
                zeland

                I do not know, may be "better memory access".

                OpenCL Compile Error: clBuildProgram failed (CL_BUILD_PROGRAM_FAILURE).

                Line 259: error: "restrict" is
                not allowed
                __kernel void Calc_ALL(__global restrict uint * in1,

                  • restrict
                    himanshu.gautam

                    gat3way,

                    restrict keyword is used to tell the compiler that the pointer does not alias with any other pointer argument.This helps compiler in doing more optimized compilation.

                    http://en.wikipedia.org/wiki/Restrict

                    zeland,

                    try __kernel void kernel(__global uint * restrict in1,...)

                     

                      • restrict
                        zeland

                        Thanks. I've read Wiki.  i want to what exactly do restrict in Amd implementation of OpenCL. And when it is better to use it or  not.  When will i feel difference?

                          • restrict
                            himanshu.gautam

                            zeland,

                            You can use restrict keyword for any pointer when you are sure the buffer will be accessed by only that pointer.And no pointer aliasing can happen.

                            IT can make the reordering of instructions more flexible which can improve performance.

                              • restrict
                                zeland

                                 

                                Originally posted by: himanshu.gautam zeland,

                                 

                                You can use restrict keyword for any pointer when you are sure the buffer will be accessed by only that pointer.And no pointer aliasing can happen. IT can make the reordering of instructions more flexible which can improve performance.

                                 

                                Thanks. So every time when  pointer variable will be accessed by the only pointer, and this is rather typically,  i should use restrict keyword for may be better performance.