VS程序在调试时崩溃但不是发布模式?

时间:2014-05-29 14:22:55

标签: c++ visual-studio-2012 cuda thrust

我在VS 2012中运行以下程序来试用Thrust函数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;
}

这是取自http://docs.thrust.googlecode.com/hg/group__searching.html#ga99c7a59cef5b9f4cdbc70f37b2e221be

的代码示例的修改版本

当我在调试模式下运行时,程序崩溃,我收到错误Debug Error! ... R6010 - abort() has been called。但是,在发布模式下运行此功能,我只能获得预期的输出Index of a = 0

我知道崩溃的发生是因为包含find函数的行。

可能导致这种情况发生的原因是什么?

1 个答案:

答案 0 :(得分:0)

有一些类似的问题,例如here

引用评论:&#34;当为调试而构建时,已知Thrust无法正确编译和运行&#34;

来自docs:&#34; nvcc不支持设备调试Thrust代码。用(例如,nvcc -G,nvcc --device-debug 0等)编译的推力函数可能会崩溃。&#34;