目标是在另一个文件中调用一个设备函数,当我编译全局内核时,它显示以下错误*不支持外部调用(找到非内联调用_Z6GoldenSectionCUDA)*.
有问题的代码(不是完整的代码,但问题出现的地方),cat norm.h
# ifndef NORM_H_
# define NORM_H_
# include<stdio.h>
__device__ double invcdf(double prob, double mean, double stddev);
#endif
Run Code Online (Sandbox Code Playgroud)
猫norm.cu
# include <norm.h>
__device__ double invcdf(double prob, double mean, double stddev) {
return (mean + stddev*normcdfinv(prob));
}
Run Code Online (Sandbox Code Playgroud)
猫test.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);
}
Run Code Online (Sandbox Code Playgroud)
nvcc -c norm.cu -o norm.o …