简体   繁体   English

为什么nvcc无法使用boost :: spirit编译CUDA文件?

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

I'm trying to integrate CUDA to an existing aplication wich uses boost::spirit. 我正在尝试将CUDA集成到使用boost :: spirit的现有应用程序中。

Isolating the problem, I've found out that the following code does not copile with nvcc: 解决问题后,我发现以下代码与nvcc不兼容:

main.cu : 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 . 使用nvcc -o cudaTest main.cu编译时,出现了很多错误,可以在这里看到。

But if I change the filename to main.cpp , and compile again using nvcc , it works. 但是,如果我将文件名更改为main.cpp ,然后使用nvcc再次编译,则可以正常工作。 What is happening here and how can I fix it? 这是怎么回事,我该如何解决?

nvcc sometimes has trouble compiling complex template code such as is found in Boost, even if the code is only used in __host__ functions. nvcc有时在编译复杂的模板代码(例如在Boost中找到)时会遇到麻烦,即使该代码仅在__host__函数中使用也是__host__

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. 当文件扩展名是.cppnvcc自身不执行任何解析,而是将代码转发给主机编译器,这就是为什么您根据文件扩展名观察到不同的行为的原因。

If possible, try to quarantine code which depends on Boost into .cpp files which needn't be parsed by nvcc . 如果可能的话,尽量取决于升压到检疫代码.cpp这不需要由解析文件nvcc

I'd also make sure to try the nvcc which ships with the recent CUDA 4.1 . 我还要确保尝试使用最新CUDA 4.1附带的nvcc nvcc 's template support improves with each release. 每个版本对nvcc的模板支持都进行了改进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM