1

我正在编写一个 CUDA 内核并想要__restrict__我的一些参数。我收到错误消息:

"restrict" is not allowed

某些变量类型不允许吗?对于一些参数组合?因为一些编译器标志?因为我调皮?

简化的内核签名:

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

2 回答 2

7

您只能__restrict__在指针类型上使用。这也是唯一__restrict__有意义的上下文。

于 2013-12-04T16:59:08.553 回答
1

如果您__restrict__在指向函数的指针参数上使用,但顺序错误,也会发生这种情况,例如:

__device__ int bar(float * __restrict__ x);
于 2021-03-07T17:12:50.227 回答