我正在 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 http://docs.thrust.googlecode.com/hg/group__searching.html#ga99c7a59cef5b9f4cdbc70f37b2e221be
当我在调试模式下运行此程序时,我的程序崩溃并收到错误Debug Error! ... R6010 - abort() has been called
。但是,在发布模式下运行它我只是得到了预期的输出Index of a = 0
.
我知道崩溃是由于包含 find 函数的行而发生的。
什么可能导致这种情况发生?
还有一些类似的问题,例如here https://stackoverflow.com/questions/17703990/cuda-gdb-crashes-with-thrust-cuda-release-5-5
引用评论:“已知 Thrust 在为调试而构建时无法正确编译和运行”
并从docs https://code.google.com/p/thrust/wiki/Debugging:“nvcc 不支持设备调试 Thrust 代码。使用(例如 nvcc -G、nvcc --device-debug 0 等)编译的 Thrust 函数可能会崩溃。”
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)