使用GPU计算稀疏数据 [英] Computation on sparse data using GPU

查看:112
本文介绍了使用GPU计算稀疏数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Matlab中计算函数 f ( x )= exp(- x ),其中 x 是标量的向量.该函数是在GPU上计算得出的,例如

I'm computing a function f(x) = exp(-x) in Matlab, where x is a vector of scalars. The function is computed on GPU, e.g.

x_cpu = [4 5 11 1];
x = gpuArray(x_cpu);
f = exp(-x);

那么结果将是:

f = exp(-[4,5,11,1])= [0.183,0.0067,1.6702e-005,0.3679].

f = exp(-[4, 5, 11, 1]) = [0.183, 0.0067, 1.6702e-005, 0.3679].

请注意, f ( x (3))= f (11)= exp(-11)= 1.6702e-005 = 0.000016702,这是一个很小的值.因此,我想避免通过简单地设置 f ( x (i))=来计算所有 x (i)> 10的函数0.

Note that f(x(3)) = f(11) = exp(-11) = 1.6702e-005 = 0.000016702, which is a pretty small value. So, I would like to avoid computing the function for all x(i) > 10 by simply setting f(x(i)) = 0.

我可能可以将稀疏矩阵表示用于 x .但是,并行计算工具箱不支持对GPU上的稀疏矩阵进行操作.

I can probably use the sparse matrix representation for x. However, the Parallel Computing Toolbox does not support operations on sparse matrices on GPU.

您将如何处理?

推荐答案

尽管并行计算工具箱不支持GPU上的稀疏矩阵运算,但Jacket却支持.因此,一种可能的方法是简单地使用其他工具.

While the Parallel Computing Toolbox does not support sparse matrix operations on the GPU, Jacket does. So one possible approach is to simply use the different tool.

免责声明是我从事Jacket的工作,但我确实认为这对您有好处,因为它支持您想做的事情而PCT不做,并且支持

Disclaimer is that I work on Jacket, but I really do think it would be beneficial to you on this since it supports the things you want to do and that PCT does not do, and for reasons here.

这篇关于使用GPU计算稀疏数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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