0

I am running the following program in VS 2012 to try out the Thrust function find:

#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <thrust/find.h>
#include <thrust/device_vector.h>
#include <stdio.h>

int main() {
    thrust::device_vector<char> input(4);

    input[0] = 'a';
    input[1] = 'b';
    input[2] = 'c';
    input[3] = 'd';

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

    iter = thrust::find(input.begin(), input.end(), 'a');

    std::cout << "Index of a = " << iter - input.begin() << std::endl;

    return 0;
}

This is a modified version of a code example taken from http://docs.thrust.googlecode.com/hg/group__searching.html#ga99c7a59cef5b9f4cdbc70f37b2e221be

When I run this in Debug mode, my program crashes and I get the error Debug Error! ... R6010 - abort() has been called. However, running this in Release mode I just get my expected output Index of a = 0.

I know that the crash happens because of the line that includes the find function.

What might cause this to happen?

Louise K
  • 4,741
  • 3
  • 16
  • 17

1 Answers1

0

There are a few similar questions e.g. here

To quote a comment : "Thrust is known to not compile and run correctly when built for debugging"

And from the docs: "nvcc does not support device debugging Thrust code. Thrust functions compiled with (e.g., nvcc -G, nvcc --device-debug 0, etc.) will likely crash."

Community
  • 1
  • 1
doctorlove
  • 18,872
  • 2
  • 46
  • 62
  • I think I had come across that question, but I wasn't sure whether it was relevant as I use Visual Studio. I'm supposing that Visual Studio uses cuda-gdb (see https://developer.nvidia.com/cuda-gdb - "Developers should be sure to check out NVIDIA Nsight for integrated debugging and profiling. Nsight Eclipse Edition for Linux and MAC support, and Nsight Visual Studio Edition for Windows." This is on a CUDA-GDB page, so I'd assume so.) – Louise K May 29 '14 at 14:46
  • I've only done a little cuda, but it seemed to apply to both gcc and VS when I tried. – doctorlove May 29 '14 at 14:57
  • cuda-gdb is a linux only product, based on the well-known gdb debugger in linux. So it's not relevant to Windows. However, a debug CUDA project in VS adds the `-G` switch when compiling (using `nvcc`) and this is the crux of the issue, as indicated in the docs link provided in the answer. – Robert Crovella May 29 '14 at 15:11