Why does nvcc fails to compile a CUDA file with boost::spirit?

自作多情 提交于 2019-11-26 12:33:58

问题


I\'m trying to integrate CUDA to an existing aplication wich uses boost::spirit.

Isolating the problem, I\'ve found out that the following code does not copile with nvcc:

main.cu:

#include <boost/spirit/include/qi.hpp>
int main(){
    exit(0);
}

Compiling with nvcc -o cudaTest main.cu I get a lot of errors that can be seen here.

But if I change the filename to main.cpp, and compile again using nvcc, it works. What is happening here and how can I fix it?


回答1:


nvcc sometimes has trouble compiling complex template code such as is found in Boost, even if the code is only used in __host__ functions.

When a file's extension is .cpp, nvcc performs no parsing itself and instead forwards the code to the host compiler, which is why you observe different behavior depending on the file extension.

If possible, try to quarantine code which depends on Boost into .cpp files which needn't be parsed by nvcc.

I'd also make sure to try the nvcc which ships with the recent CUDA 4.1. nvcc's template support improves with each release.



来源:https://stackoverflow.com/questions/8138673/why-does-nvcc-fails-to-compile-a-cuda-file-with-boostspirit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!