编译对于计算能力2.x的在CUDA C为VS2010 [英] Compiling for Compute Capability 2.x in CUDA C for VS2010
问题描述
我是跟随这名:<一href=\"http://stackoverflow.com/questions/6937693/dynamically-allocating-memory-inside-device-global-cuda-kernel\">Dynamically里面__device分配内存/ global__ CUDA内核
但它仍然不能编译。
error : calling a host function("_malloc_dbg") from a __device__/__global__
function("kernel") is not allowed
error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA
\v4.1\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\"
--use-local-env --cl-version 2010 -ccbin "c:\Program Files (x86)\Microsoft Visual
Studio 10.0\VC\bin\x86_amd64" -I"..\..\..\Source\Include" -G0 --keep-dir
"x64\Debug" -maxrregcount=0 --machine 64 --compile -g -Xcompiler "/EHsc /nologo
/Od /Zi /MDd " -o "x64\Debug\move.cu.obj" "C:\Source\scene\move.cu"" exited with
code 2. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA
4.1.targets 361 10
至于建议,我加了#如果__CUDA_ARCH__&GT; = 200
键,返回false
还有什么可以是问题?我跑在GTX480。
What else can be the issues? I'm running on a GTX480.
编辑:我有这样的警告,以及:指令#warning C4005:'_malloca':宏的重新定义
I have this warning as well: #warning C4005: '_malloca' : macro redefinition
推荐答案
我明白你的解决您的主要问题,但还有剩下的问题:
I understand you solved your main problem but there is the remaining question:
我添加#如果__CUDA_ARCH__方式&gt; = 200
键,返回false
I added
#if __CUDA_ARCH__ >= 200
and it returns false.
在CUDA code编译至少的两次的。在一个编译通过生成CPU code,在另一个传球,设备code。 __ __ CUDA_ARCH
定义的只有的用于设备code一代。
这有可能使更多的编译通行证和生产GPU code几架构。在code为CPU就不会改变,但会GPU
The CUDA code is compiled at least twice. In one compilation pass the CPU code is generated, in another pass, the device code. __CUDA_ARCH__
is defined only for the device code generation.
It is possible to make even more compilation passes and produce GPU code for several architectures. The code for CPU would not change, but the GPU will.
我怀疑你正在测试的#如果__CUDA_ARCH__方式&gt; = 200
生产CPU code时
I suspect that you are testing the #if __CUDA_ARCH__ >= 200
when producing CPU code.
这篇关于编译对于计算能力2.x的在CUDA C为VS2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!