As far as I have understood, restrict can allow for optimizations from the compiler by telling it that a pointer will not be aliased. It’s quite straightforward in a simple example like this one:
__global__ void kernel(double *__restrict__ dst, const double * __restrict__ src)
{
// i = ...
dst[i] = src[i];
}
But if I have a more complicated example, where pointers are part of a struct which is initialized, and then passed to a device function. Where exactly do I need to add the keyword to get the effect?
In particular,
- Do I need it only on the pointer being accessed, or also on others?
- Do I need it only in the context of the accessed, or also in parent function calls?