CUDA中的"restrict" is not allowed 错误
const __restrict__ uint32_t *addr;
语句报的这个错。这就要说到__restrict__的用法。
__restrict__用法
__restrict__用于标识一个指针,提示编译器:这个指针对应的内存是被唯一指定指针访问的。
因此不能用于指针以外的类型,有以下几种正确和错误的用法
__restrict__ SomeType b[];// 错误
SomeType __restrict__ b[];// 错误
__restrict__ SomeType *b;// 错误
SomeType* __restrict__ b;// 正确
/
__device__ __forceinline__
uint32_t ld_gbl_ca(const __restrict__ uint32_t *addr);// 这样写不行,会报错
__device__ __forceinline__
uint32_t ld_gbl_ca(const uint32_t __restrict__ *addr);// 这样可以