4
我试图用thrust::transform
从device_vector
的每个元素减少一个恒定值。正如你所看到的,最后一行是不完整的。我试图从常量fLowestVal
的所有元素中减去,但不知道具体如何。如何通过常量递减device_vector的每个元素?
thrust::device_ptr<float> pWrapper(p);
thrust::device_vector<float> dVector(pWrapper, pWrapper + MAXX * MAXY);
float fLowestVal = *thrust::min_element(dVector.begin(), dVector.end(),thrust::minimum<float>());
// XXX What goes here?
thrust::transform(...);
另一个问题是:一旦我做我的device_vector
变化,将变化也适用于p
阵列?
谢谢!
#include <thrust/functional.h>
...
using thrust::placeholders;
thrust::for_each(vec.begin(), vec.end(), _1 -= val);
不寻常_1 -= val
语法意味着创建一个无名算符其工作是通过递减其第一个参数:
WOW贾里德这就是我一直在寻找!你能否详细说明for_each函数的性能? – 2012-03-13 06:13:16
@igalk像这些功能是带宽受限。表演应该“尽可能快地读写” – 2012-03-13 17:17:26