【发布时间】:2014-01-19 23:54:34
【问题描述】:
目标是调用另一个文件中可用的设备函数,当我编译 global 内核时,它显示以下错误 *External calls are not supported (found non-inlined call to _Z6GoldenSectionCUDA )*.
有问题的代码(不是完整的代码,而是出现问题的地方), 猫范数.h
# ifndef NORM_H_
# define NORM_H_
# include<stdio.h>
__device__ double invcdf(double prob, double mean, double stddev);
#endif
cat norm.cu
# include <norm.h>
__device__ double invcdf(double prob, double mean, double stddev) {
return (mean + stddev*normcdfinv(prob));
}
猫测试.cu
# include <norm.h>
# include <curand.h>
# include <curand_kernel.h>
__global__ void phase2Kernel(double* out_profit, struct strategyHolder* strategy) {
curandState seedValue;
curand_init(threadIdx.x, 0, 0, &seedValue);
double randomD = invcdf(curand_uniform_double( &seedValue ), 300, 80);
}
nvcc -c norm.cu -o norm.o -I"."
nvcc -c test.cu -o test.o -I"."
【问题讨论】:
-
请发布一个示例来重现问题(请参阅here 以获得指导),您的代码对我有用。
-
在实际代码中(与您在此处显示的相反),您是显式调用构造函数还是依赖于类的默认构造函数?
-
能否指定您使用的 nvcc 参数?
-
贴出真实代码。我正在使用Makefile进行编译,我使用的命令是nvcc -c file.cu -o file.o
-
@Bala 我不明白为什么将上述代码的一部分放在单独的
.h文件中,然后将其包含在.cu文件中会导致编译错误。您能否使用重现错误的确切文件分区编辑您的问题?