gpt4 book ai didi

cuda - 直接在主机上访问设备矢量元素的最快方法

转载 作者:行者123 更新时间:2023-12-01 02:40:17 25 4
gpt4 key购买 nike

引用下页http://code.google.com/p/thrust/wiki/QuickStartGuide#Vectors .请参阅第二段,它说

Also note that individual elements of a device_vector can be accessed using the standard bracket notation. However, because each of these accesses requires a call to cudaMemcpy, they should be used sparingly. We'll look at some more efficient techniques later.



我搜索了整个文档,但找不到更有效的技术。有谁知道最快的方法来做到这一点?即如何以最快的速度访问主机上的设备向量/设备指针?

最佳答案

指南中提到的“更有效的技术”是 Thrust 算法。一次访问(或跨 PCI-E 总线复制)数百万个元素比访问单个元素更有效,因为 CPU/GPU 通信的固定成本被摊销。

没有比调用 cudaMemcpy 更快地将数据从 GPU 复制到 CPU 的方法了。 ,因为它是 CUDA 程序员实现任务的最原始方式。

关于cuda - 直接在主机上访问设备矢量元素的最快方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8660333/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com