Problem with Thrust in CUDA 4.0

I have been trying to use the inclusive prefix scan, but I keep getting an “Unhandled Exception” error. The code is as follows:

#include<thrust/scan.h>

n = 4

key = [2,1,0,1];

thrust::inclusive_scan(key, key + n, key);

I tried to follow the example given here:

http://code.google.com/p/thrust/wiki/QuickStartGuide#Prefix-Sums

I usually associate “Unhandled Exception” with trying to access a point outside an array, but I have also tried key+n-1 as well as key+1 in the middle term, both of which gave me the same “Unhandled Exception”.

Thanks for any help you guys can provide.

Even I am getting the same problem…

thrust::inclusive_scan(…) crashing.

I am using windows 7 enterprise edition (32 bit), GTX 580, CUDA 4.1, Visual Studio 2010, with code Generation set to compute_20,sm_20;

the same code is working fine with code Generation set to compute_10,sm_10;

Thanks in advance.

My guess is that you are compiling in Debug mode.

Unfortunately, nvcc 4.1 -G doesn’t support Thrust. To workaround the problem, switch to release mode or use sm_1X if you can.