当前位置: 首页 > wzjs >正文

phpcms双语网站怎么做传媒网站

phpcms双语网站怎么做,传媒网站,怎么知道网站是谁做的,手机网站内容设计方案Thrust库中的Gather和Scatter操作 Thrust是CUDA提供的一个类似于C STL的并行算法库,其中包含两个重要的数据操作:gather(聚集)和scatter(散开)。 Gather操作 Gather操作从一个源数组中按照指定的索引收集元素到目标数组中。 函数原型: t…

Thrust库中的Gather和Scatter操作

Thrust是CUDA提供的一个类似于C++ STL的并行算法库,其中包含两个重要的数据操作:gather(聚集)和scatter(散开)。

Gather操作

Gather操作从一个源数组中按照指定的索引收集元素到目标数组中。

函数原型:

template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator gather(InputIterator1 map_first, InputIterator1 map_last,InputIterator2 input_first, OutputIterator result);

工作方式:

result[i] = input[map[i]] 对于 map中的每个索引i

示例:

#include <thrust/gather.h>
#include <thrust/device_vector.h>// 源数据
thrust::device_vector<int> input(4);
input[0] = 10; input[1] = 20; input[2] = 30; input[3] = 40;// 索引映射
thrust::device_vector<int> map(3);
map[0] = 3; map[1] = 1; map[2] = 2;// 目标向量
thrust::device_vector<int> result(3);// 执行gather操作
thrust::gather(map.begin(), map.end(), input.begin(), result.begin());
// result现在包含 [40, 20, 30]

Scatter操作

Scatter操作将源数组的元素按照指定的索引分散到目标数组中。

函数原型:

template<typename InputIterator1, typename InputIterator2, typename InputIterator3, typename OutputIterator>
OutputIterator scatter(InputIterator1 first, InputIterator1 last,InputIterator2 map_first, InputIterator3 stencil,OutputIterator result);

工作方式:

result[map[i]] = input[i] 对于 map中的每个索引i

示例:

#include <thrust/scatter.h>
#include <thrust/device_vector.h>// 源数据
thrust::device_vector<int> input(3);
input[0] = 10; input[1] = 20; input[2] = 30;// 索引映射
thrust::device_vector<int> map(3);
map[0] = 3; map[1] = 1; map[2] = 2;// 目标向量(需要足够大)
thrust::device_vector<int> result(4);// 执行scatter操作
thrust::scatter(input.begin(), input.end(), map.begin(), result.begin());
// result现在包含 [0, 20, 30, 10] (初始值为0)

应用场景

  1. 数据重排:当需要按照特定顺序重新排列数据时
  2. 稀疏矩阵操作:在稀疏矩阵计算中高效地访问非零元素
  3. 数据库操作:实现类似SQL中的选择和投影操作
  4. 图像处理:像素重映射操作

变体函数

Thrust还提供了一些变体函数:

  • gather_if:带条件的gather操作
  • scatter_if:带条件的scatter操作
  • stable_scatter:保持相对顺序的scatter操作

这些操作在GPU上高度优化,能够充分利用并行计算能力,比在CPU上实现的类似操作要快得多。

http://www.dtcms.com/wzjs/345210.html

相关文章:

  • 菏泽网站设计培训网络推广公司加盟
  • 建设网站的企业费用网络营销策划书结构
  • 广州家具网站建设文章代写
  • 鞍山最新通知今天网站seo哪家做的好
  • 成立一个做网站的公司上海短视频seo优化网站
  • 湘潭网站建设企业百度一下你就知道官网
  • 蔬菜基地做网站合适吗友情链接的形式有哪些
  • 上海模板网站套餐百度用户服务中心电话
  • 莱芜做网站公司山东济南seo整站优化费用
  • 南海建设局网站怎么建立自己的网站
  • 黔江做网站seo网站推广经理
  • 正规小说分销平台seo快速排名软件网站
  • 太原市免费网站建设超链接友情外链查询
  • 重庆网站建设安全哪个网站百度收录快
  • 1280的界面网站做多宽广州seo推广培训
  • 北京欢迎你网站制作公司线上it培训机构
  • 用axure做网站石家庄全网seo
  • 知名企业网站建设案例合肥网络公司
  • 渭南建网站适合中层管理的培训
  • 手机版 pc 版本 网站 跳转 seo海豹直播nba
  • 动态网页技术厦门百度seo
  • 济南网站制作运营推广的公司
  • 邳州哪家做百度推广网站网站优化比较好的公司
  • 门户网站开发 系统介绍seo中文含义
  • 网站设计草图世界新闻最新消息
  • 用户体验好的网站广州网站优化工具
  • 域名网站排名短信营销平台
  • seo北京网站推广百度关键词排名神器
  • 农村网站平台建设方案南京网络优化培训
  • 创建自己的网站需要准备什么网站排名在线优化工具