Search code examples
c++pointerscompiler-errorscudarestrict-qualifier

Why am I getting the error message: "restrict" not allowed?


I'm writing a CUDA kernel and want to __restrict__ some of my parameters. I'm getting the error message:

"restrict" is not allowed

Is it not allowed for some variable types? For some combinations of parameters? Because of some compiler flags? Because I've been naughty?

Simplified kernel signature:

template <typename T> foo(
    const T a[],
    __restrict__ SomeType b[],
    const T c
) {
    /* etc. */
}

Solution

  • You can only use __restrict__ on a pointer type. That is also the only context in which __restrict__ makes sense.