//Header file A.h
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
class A
{
__host__ __device__ void move();
}
//cu file A.cu
#include "A.h"
{
__host__ __device__ void A::move()
{
...
}
}
从另一个A.cu
文件调用.cu
文件中定义的方法时,我收到以下错误:
External calls are not supported (found non-inlined call to ...),
我正在使用sm_10
编译选项。
答案 0 :(得分:2)
您需要单独编译。单独编译需要具有至少2.0
和至少CUDA 5.0的计算能力的卡。
引用CUDA 5.0发布重点:
现在可以使用NVCC单独编译和链接所有
__device__
个函数。 这允许创建__device__
函数的闭源静态库 这些库能够调用用户定义的__device__
回调函数。 链接器支持在此版本中被视为BETA功能。
CUDA COMPILER DRIVER NVCC Reference Guide的第7章描述了单独的编译。
对于那些感兴趣的人,NVIDIA论坛上的单独编译有一个非常好的主题,见
How to create a static lib for device functions using cuda 5.0?