使用 CUBLAS 例程在 GPGPU 上保留点积 [英] Retaining dot product on GPGPU using CUBLAS routine

查看:26
本文介绍了使用 CUBLAS 例程在 GPGPU 上保留点积的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写代码来使用点积的 CUBLAS 例程计算两个向量的点积,但它返回主机内存中的值.我只想使用点积在 GPGPU 上进行进一步计算.如何使值仅驻留在 GPGPU 上并将其用于进一步计算,而无需从 CPU 到 GPGPU 进行显式复制?

I am writing a code to compute dot product of two vectors using CUBLAS routine of dot product but it returns the value in host memory. I want to use the dot product for further computation on GPGPU only. How can I make the value reside on GPGPU only and use it for further computations without making an explicit copy from CPU to GPGPU?

推荐答案

你不能完全使用 CUBLAS. 根据 talonmies 的回答,从 CUBLAS V2 api (CUDA 4.0) 开始返回值可以是设备指针.参考他的回答.但是,如果您使用 V1 API,它是一个单一值,因此将它作为参数传递给使用它的内核非常简单——您不需要显式的 cudaMemcpy(但有一个隐含以返回主机值).

You can't, exactly, using CUBLAS. As per talonmies' answer, starting with the CUBLAS V2 api (CUDA 4.0) the return value can be a device pointer. Refer to his answer. But if you are using the V1 API it's a single value, so it's pretty trivial to pass it as an argument to a kernel that uses it—you don't need an explicit cudaMemcpy (but there is one implied in order to return a host value).

从 Tesla K20 GPU 和 CUDA 5 开始,您将能够使用 CUDA 动态并行从设备内核调用 CUBLAS 例程.这意味着您将能够从 __global__ 内核函数内部调用 cublasSdot(例如),因此您的结果将在 GPU 上返回.

Starting with the Tesla K20 GPU and CUDA 5, you will be able to call CUBLAS routines from device kernels using CUDA Dynamic Parallelism. This means you would be able to call cublasSdot (for example) from inside a __global__ kernel function, and your result would therefore be returned on the GPU.

这篇关于使用 CUBLAS 例程在 GPGPU 上保留点积的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆