I've got a class with nested classes mixing both C++, CUDA and Thrust. I want to split member definitions across a number of files.
// In cls.h:
#include <thrust/device_vector.h>
class cls {
class foo { // define in foo.cu (include "cls.h")
kernelWrapper();
}
class bar { // define in bar.cu (include "cls.h")
thrust::device_vector A;
thrustStuff();
}
thrust::device_vector B;
pureCPP(); // define in cls.cpp (include "cls.h")
moreThrust(); // define in cls.cu (include "cls.h")
}
In each definition file I simply #include "cls.h"
. However, I am currently getting an assortment of compiler errors no matter what I try, like pureCPP was referenced but not defined
.
I've read Thrust can only be used with
.cu
files. Because my parent classcls
declares Thrust-type variables likeB
(and hence#include
sthrust/device_vector.h
), does that force all files that#include
cls.h
to be made into.cu
files?Where do I use
extern "C"
in this case? I supposecls.cpp
would require all functions in.cu
files to be wrapped inextern "C"
, but what about.cu
to.cu
calls, likemoreThrust()
callingbar::thrustStuff()
I've also been made aware members of classes don't work with
extern "C"
, so do I have to write anextern "C"
wrapper function for each member function?
I'm utterly confused as to how to make this all work - what cocktail of #include
s and extern "C"
s do I need for each file?