不支持 CUDA 外部调用 [英] CUDA External calls not supported

查看:27
本文介绍了不支持 CUDA 外部调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am developing a CUDA 4.0 application running on a Fermi card. According to the specs, Fermi has Compute Capability 2.0 and therefore should support non-inlined function calls.

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

I compile every class I have with nvcc 4.0 in a distinct obj file. Then, I link them all with g++-4.4.

考虑以下代码:

[文件 A.cuh]

#include <cuda_runtime.h>

struct A
{
    __device__ __host__ void functionA();
};

[文件 B.cuh]

#include <cuda_runtime.h>

struct B
{
    __device__ __host__ void functionB();
};

[文件 A.cu]

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

void A::functionA()
{
    B b;
    b.functionB();
}

尝试使用 nvcc -o Ao -c A.cu -arch=sm_20 编译 A.cu 输出 错误:不支持外部调用(发现对 _ZN1B9functionBEv 的非内联调用).

Attempting to compile A.cu with nvcc -o A.o -c A.cu -arch=sm_20 outputs Error: External calls are not supported (found non-inlined call to _ZN1B9functionBEv).

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

I must be doing something wrong, but what ?

推荐答案

NVidia 论坛上的此线程中所述,看来即使 Fermi 支持非内联函数,nvcc 仍然需要在编译期间拥有所有可用的函数,即在同一个源文件中:没有链接器(是的,这很可惜......).

As explained on this thread on the NVidia forums, it appears that even though Fermi supports non-inlined functions, nvcc still needs to have all the functions available during compilation, i.e. in the same source file: there is no linker (yep, that's a pity...).

这篇关于不支持 CUDA 外部调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆