About restrict keyword in C functions

Hi, All:

In most OpenACC training slides, e.g. saxpy function in

http://on-demand.gputechconf.com/gtc/2012/presentations/S0517A-Monday-Programming-GPUs-OpenACC.pdf

slide 14:

void saxpy(int n, float a, float * x, float *restrict y);

It seems only one restrict keyword in front of y is needed for the compiler to recognize parallelism and independence between x and y, I am just wondering why the restrict keyword is not also added in front of x? Why does the compiler figure out x is not aliased with y?

Thanks a lot,

Feng

Hi Feng,

“x” is read-only so doesn’t need “restrict”.

  • Mat