博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
scatter and gather in thrust
阅读量:4041 次
发布时间:2019-05-24

本文共 1285 字,大约阅读时间需要 4 分钟。

#include 
#include
#include
...// mark even indices with a 1; odd indices with a 0int values[10] = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0};thrust::device_vector
d_values(values, values + 10);// scatter all even indices into the first half of the// range, and odd indices vice versaint map[10] = {0, 5, 1, 6, 2, 7, 3, 8, 4, 9};thrust::device_vector
d_map(map, map + 10);thrust::device_vector
d_output(10);thrust::scatter(thrust::device, d_values.begin(), d_values.end(), d_map.begin(), d_output.begin());// d_output is now {1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
#include 
#include
#include
...// mark even indices with a 1; odd indices with a 0int values[10] = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0};thrust::device_vector
d_values(values, values + 10);// gather all even indices into the first half of the range// and odd indices to the last half of the rangeint map[10] = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9};thrust::device_vector
d_map(map, map + 10);thrust::device_vector
d_output(10);thrust::gather(thrust::device, d_map.begin(), d_map.end(), d_values.begin(), d_output.begin());// d_output is now {1, 1, 1, 1, 1, 0, 0, 0, 0, 0}

在这里插入图片描述

你可能感兴趣的文章
计算机网络复习要点
查看>>
Variable property attributes or Modifiers in iOS
查看>>
NSNotificationCenter 用法总结
查看>>
C primer plus 基础总结(一)
查看>>
剑指offer算法题分析与整理(一)
查看>>
剑指offer算法题分析与整理(三)
查看>>
Ubuntu 13.10使用fcitx输入法
查看>>
pidgin-lwqq 安装
查看>>
mint/ubuntu安装搜狗输入法
查看>>
C++动态申请数组和参数传递问题
查看>>
opencv学习——在MFC中读取和显示图像
查看>>
retext出现Could not parse file contents, check if you have the necessary module installed解决方案
查看>>
Matlab与CUDA C的混合编程配置出现的问题及解决方案
查看>>
PaperDownloader——文献命名6起来
查看>>
如何将PaperDownloader下载的文献存放到任意位置
查看>>
C/C++中关于动态生成一维数组和二维数组的学习
查看>>
JVM最简生存指南
查看>>
Java的对象驻留
查看>>
logback高级特性使用(二) 自定义Pattern模板
查看>>
JVM并发机制探讨—内存模型、内存可见性和指令重排序
查看>>