不支持CUDA外部呼叫

use*_*016 9 cuda

我正在开发一个在Fermi卡上运行的CUDA 4.0应用程序.根据规范,Fermi具有Compute Capability 2.0,因此应该支持非内联函数调用.

我在一个不同的obj文件中用nvcc 4.0编译我的每个类.然后,我用g ++ - 4.4将它们全部链接起来.

请考虑以下代码:

[文件A.cuh]

#include <cuda_runtime.h>

struct A
{
    __device__ __host__ void functionA();
};
Run Code Online (Sandbox Code Playgroud)

[文件B.cuh]

#include <cuda_runtime.h>

struct B
{
    __device__ __host__ void functionB();
};
Run Code Online (Sandbox Code Playgroud)

[File A.cu]

#include "A.cuh"
#include "B.cuh"

void A::functionA()
{
    B b;
    b.functionB();
}
Run Code Online (Sandbox Code Playgroud)

试图编译A.cu与nvcc -o A.o -c A.cu -arch=sm_20输出Error: External calls are not supported (found non-inlined call to _ZN1B9functionBEv).

一定做错了什么,但是什么?

Luc*_*lle 10

正如NVidia论坛上的这个帖子所解释的那样,即使Fermi支持非内联函数,nvcc仍然需要在编译期间拥有所有可用的函数,即在同一个源文件中:没有链接器(是的,这是一个可怜...).

  • 一年后:从CUDA 5.0开始,nvcc现在可以链接设备对象(`-dc`标志). (13认同)