Use of STL in device code?

I have some problems porting an application to the GPU.

See the following very short code snippet:

#include <vector>

template <class T> class C {


 Â static T *get() {return NULL;}


__device__ void a() {

 Â std::vector<float> CC;

 float bb = CC.front();        Â // ERROR 5

 Â float *b = C<float>::get();   Â // WARNING 6


Compiler (MSVC2005 with SP1, CUDA 2.0) gives the following error(s):

I can fix the second “error” by adding device classifier to the function get(). But the first I cannot. Is this because STL is not supported in device code? Is it because we should put device before every STL function in which case it should work? :ermm:

Can anyone shed some light on this?

You cannot use STL in device code

Well, I figured that much since whatever I tried, I had compile errors all over. Is this documented somewhere?

Another thing, about the warning. I need to add device in front of any function that I would like to run on the GPU. This I also need to add for member-functions of a struct/class which I find a little bit strange. The variable is declared on the device (when not a static function as in my example), so shouldn’t nvcc be able to figure out to create device code for this? Furstrating :angry:

all functions called by kernel must have device prefix,
btw, they are not really called, they all are INLINED.
so the classes and such are not the best thing to use with CUDA
rather stick to C style (functions and structures)
for the details look to the programming guide.