在包含curand_kernel.h之前包含thrust/sort.h会导致编译错误。

3
这段代码可以成功编译:
#include <curand_kernel.h>
#include <thrust/sort.h>

int main(void) {
    return 0;
}

虽然这会导致编译错误:

#include <thrust/sort.h>
#include <curand_kernel.h>

int main(void) {
    return 0;
}

CUDA 6 给我带来了三个错误:
... curand_mtgp32_kernel.h(315): error: calling a __device__ function("__syncthreads") from a __host__ __device__ function("curand_mtgp32_single") is not allowed

... include/curand_mtgp32_kernel.h(373): error: calling a __device__ function("__syncthreads") from a __host__ __device__ function("curand_mtgp32_single_specific") is not allowed

... curand_kernel.h(392): warning: missing return statement at end of non-void function "__curand_uint32_as_float"

在CUDA 5中,我只能得到以下结果:
... curand_kernel.h(405): warning: missing return statement at end of non-void function "__curand_uint32_as_float"

其中“...”是我的CUDA安装目录。它似乎所有这些区域都被包装在宏中,测试__CUDA_ARCH__是否已定义或其值是什么。我sort.h中遇到这个问题,而不是我包含的其他各种thrust头文件(host/device vectors、scan、scatter+gather和一些高级迭代器)。

鉴于这种行为,我不能轻松和明智地使当前项目中的所有头文件自给自足。有没有人能解释一下为什么这里的顺序很重要,或者这是这些头文件中的一个“错误”还是“特性”?

1个回答

4

这是一个已知问题(实际上有两个不同的问题)。在CUDA 6发布之前发现了这个问题,因此无法在CUDA 6中修复。

这个问题应该会在将来的版本中得到解决。

同时,您可以通过反转包含这些头文件的顺序来解决它,或者尝试更新到当前的Thrust主分支


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接