开发者

CUDA and STL vector

开发者 https://www.devze.com 2023-01-12 05:55 出处:网络
Having just learned that many cpp features (including the stl vector class) do not work in cu files. Even when using them in the host code.

Having just learned that many cpp features (including the stl vector class) do not work in cu files. Even when using them in the host code.

Since I have to use a C++ class which uses STL I cannot compile my CU file which invokes the kernel. (I don't use any STL features in the CU file, but I think t开发者_如何学运维he include is the problem.)

I tried to build this by using cmake with

cuda_add_executable(
Blah
Blah.cu
BlahKernel.cu
HostCodeWithVector.cpp
)

which obviously doesn't work. The question now arises if it's possible to build HostCodeWithVector.cpp with gcc instead of nvcc and the link it somehow..?


since __host__ is just what runs on your CPU you can compile this part using any compiler (MSVC, gcc) and then link with nvcc result. So you should just leave only GPU interop in CU files, everything else put into CPP.

0

精彩评论

暂无评论...
验证码 换一张
取 消