__restrict__
这个使用两个int 数组的内核编译得很好:
__global__ void kerFoo( int* __restrict__ arr0, int* __restrict__ arr1, int num )
{
for ( /* Iterate over array */ )
arr1[i] = arr0[i]; // Copy one to other
}
但是,组成指针数组的相同的两个 int 数组无法编译:
__global__ void kerFoo( int* __restrict__ arr[2], int num )
{
for ( /* Iterate over array */ )
arr[1][i] = arr[0][i]; // Copy one to other
}
编译器给出的错误是:
error: invalid use of `restrict'
我有某些结构组成一个指向数组的指针数组。(例如,传递给内核的结构具有int* arr[16]
.)我如何将它们传递给内核并能够应用于__restrict__
它们?