我刚刚开始使用 Thrust 库。我正在尝试在设备上制作一个长度为 5 的向量。她我只是设置第一个元素的成员vec[0]
#include<thrust/device_vector.h>
#include<iostream>
.
.
.
thrust::device_vector<uint2> vec(5);
vec[0]=make_uint2(4,5);
std::cout<<vec[0].x<<std::endl;
但是对于上面的代码,我得到了错误
error: class "thrust::device_reference<uint2>" has no member "x"
1 error detected in the compilation of "/tmp/tmpxft_000020dc_00000000-4_test.cpp1.ii".
我哪里错了?我认为访问本机 CUDA 矢量数据类型的成员(例如uint2
with.x
和.y
)是正确的做法。