[英]VS program crashes in debug but not release mode?
I am running the following program in VS 2012 to try out the Thrust function find: 我正在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;
}
This is a modified version of a code example taken from http://docs.thrust.googlecode.com/hg/group__searching.html#ga99c7a59cef5b9f4cdbc70f37b2e221be 这是取自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
当我在“调试”模式下运行此程序时,程序崩溃,并且出现错误“
Debug Error! ... R6010 - abort() has been called
Debug Error! ... R6010 - abort() has been called
. Debug Error! ... R6010 - abort() has been called
。 However, running this in Release mode I just get my expected output Index of a = 0
. 但是,在Release模式下运行它,我得到的期望输出
Index of a = 0
。
I know that the crash happens because of the line that includes the find function. 我知道崩溃是由于包含find函数的行而发生的。
What might cause this to happen? 是什么原因导致这种情况发生?
There are a few similar questions eg here 有一些类似的问题,例如这里
To quote a comment : "Thrust is known to not compile and run correctly when built for debugging" 引用一条评论:“已知在构建调试时,Thrust无法编译并正确运行”
And from the docs : "nvcc does not support device debugging Thrust code. Thrust functions compiled with (eg, nvcc -G, nvcc --device-debug 0, etc.) will likely crash." 并且从文档中得出:“ nvcc不支持设备调试Thrust代码。使用(例如nvcc -G,nvcc --device-debug 0等)编译的Thrust函数可能会崩溃。”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.