Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

c++ - 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.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...