CUDA不支持外部呼叫 [英] CUDA External calls not supported
问题描述
我正在开发一个在Fermi卡上运行的CUDA 4.0应用程序。根据规范,Fermi具有Compute Capability 2.0,因此应该支持非内联函数调用。
我在一个不同的obj文件中编译每个类的nvcc 4.0。然后,我将它们全部与g ++ - 4.4链接。
请考虑以下代码:
cuh]
#include< cuda_runtime.h>
struct A
{
__device__ __host__ void functionA();
};
[File B.cuh]
#include< cuda_runtime.h>
struct B
{
__device__ __host__ void functionB();
};
[File A.cu]
#includeA.cuh
#includeB.cuh
void A :: functionA()
{
B b;
b.functionB();
}
尝试使用 nvcc -o Ao -c A.cu -arch = sm_20
输出错误:不支持外部调用(发现非内联调用_ZN1B9functionBEv)
。<
正如 NVidia论坛上的此主题所述,似乎即使费米支持非内联函数,nvcc仍然需要在编译期间有所有的功能,即在同一个源文件:没有链接器(是的,这是一个遗憾...)。
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.
I compile every class I have with nvcc 4.0 in a distinct obj file. Then, I link them all with g++-4.4.
Consider the following code :
[File A.cuh]
#include <cuda_runtime.h>
struct A
{
__device__ __host__ void functionA();
};
[File B.cuh]
#include <cuda_runtime.h>
struct B
{
__device__ __host__ void functionB();
};
[File A.cu]
#include "A.cuh"
#include "B.cuh"
void A::functionA()
{
B b;
b.functionB();
}
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 ?
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屋!