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

查看:279
本文介绍了使用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?

推荐答案

>根据talonmies的答案,从CUBLAS V2 api(CUDA 4.0)开始,返回值可以是一个设备指针。参考他的答案。但是如果你使用V1 API,它是一个单一的值,所以将它作为参数传递给使用它的内核很简单;你不需要一个明确的 cudaMemcpy

从Tesla K20 GPU和CUDA 5开始,您将能够调用CUBLAS例程设备内核使用CUDA动态并行性。这意味着你可以从 __ 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天全站免登陆