Search code examples
exceptionnvidiathrust

nvidia cuda thrust abort() called on find_if


I'm trying to execute some sample code from the Thrust Quick Start Guide. It's pasted below. What is killing me is that when I'm running it, I'm getting an exception thrown "R6010 -abort() has been called) whenever I hit the find_if.

I've tried this using both the 4.1 and 4.2 runtimes. I'm building this in Visual Studio 2010 Ultimate using the latest NSight release candidate (downloaded May 4th, 2012). My graphics card is an NVidia NVS 3100m.

I can run the vector addition sample generated in a new VS project (that doesn't use Thrust) and it works okay. Adding Thrust however gives me this weirdness.

Any suggestions are appreciated.

mj

thrust::device_vector<int> input(4);

input[0] = 0;
input[1] = 5;
input[2] = 3;
input[3] = 7;

thrust::device_vector<int>::iterator iter;

iter = thrust::find_if(input.begin(), input.end(), greater_than_four()); 
iter = thrust::find_if(input.begin(), input.end(), greater_than_ten());  

EDIT1

Another tidbit of information. I'm digging in deeper into this and seeing that an error is caught during cudaThreadSynchronize(). The message is "launch_closure_by_value".


Solution

  • I figured it out. The __host__ and __device__ tags were missing.

    struct greater_than_four
    {
    __host__ __device__
        bool operator()(int x)
        {
            return x > 4;
        }
    };