thrust in a multi threaded dll

Hello,

I am trying to use thrust in my code but come to the conclusion that I cannot use it inside, because of compilation errors indicating that I have to compile my code with nvcc instead of visual studio compiler.

That is what I did, by setting the custom build rule for this file on CUDA runtime API. Everything works fine, no problem linking the whole project and when I debug the code, it steps inside the “separated” library where the thrust function is and just throws a bad allocation. Here is the small code I am trying to run. Any idea ? or should I use CUDPP ? Cheers

#include "StatTests.cuh"

void myfuncthrust()

  {// put three 1s in a device_vector

  thrust::device_vector<int> vec(5,0);

  vec[1] = 1;

  vec[3] = 1;

  vec[4] = 1;

// count the 1s

  int result = thrust::count(vec.begin(), vec.end(), 1);

 }

Hello,

I am trying to use thrust in my code but come to the conclusion that I cannot use it inside, because of compilation errors indicating that I have to compile my code with nvcc instead of visual studio compiler.

That is what I did, by setting the custom build rule for this file on CUDA runtime API. Everything works fine, no problem linking the whole project and when I debug the code, it steps inside the “separated” library where the thrust function is and just throws a bad allocation. Here is the small code I am trying to run. Any idea ? or should I use CUDPP ? Cheers

#include "StatTests.cuh"

void myfuncthrust()

  {// put three 1s in a device_vector

  thrust::device_vector<int> vec(5,0);

  vec[1] = 1;

  vec[3] = 1;

  vec[4] = 1;

// count the 1s

  int result = thrust::count(vec.begin(), vec.end(), 1);

 }