繁体   English   中英

VS程序在调试而不是发布模式下崩溃?

[英]VS program crashes in debug but not release mode?

我正在VS 2012中运行以下程序以尝试Thrust函数查找:

#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 Debug Error! ... R6010 - abort() has been called 但是,在Release模式下运行它,我得到的期望输出Index of a = 0

我知道崩溃是由于包含find函数的行而发生的。

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

有一些类似的问题,例如这里

引用一条评论:“已知在构建调试时,Thrust无法编译并正确运行”

并且从文档中得出:“ nvcc不支持设备调试Thrust代码。使用(例如nvcc -G,nvcc --device-debug 0等)编译的Thrust函数可能会崩溃。”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM