如何在GPU中添加数组的元素

如何在GPU中添加数组的元素

本文介绍了如何在GPU中添加数组的元素?任何类似于CUBLAS中的cublasDasum的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以执行来并行计算数组的元素。
但是我有点难以跟随它。我看到在cublas,有一个称为 cublasDasum 的函数,它将元素的绝对值相加。似乎应该有一个非常类似的功能,总结元素,而不是绝对值。有任何方式,我可以找到 cublasDasum 的源代码,看看这是怎么做的?

I know I can do the parallel reduction to sum up the elements of an array in parallel.But it is a little difficult for me to follow it. I saw that in cublas, there is this function called cublasDasum that sums up the absolute values of the elements. It seems there should be a very similar function that sums up the elements, not the absolute values. Is there any way I can find the source code of cublasDasum and see how this is done?

添加数组是一个基本的操作。我不能相信没有这样的功能,它...。

Adding up an array is such a basic operation. I can't believe that there is no such a function that does it ... .

推荐答案

看看答案了一些好的想法。 使用简化操作非常简单。

Take a look at the answers here for some good ideas. Thrust has pretty easy to use reduction operations.

您可以通过将矩阵的所有元素视为1 x N数组,创建N x 1的数组,然后执行 cublasDgemm 操作。

You can sum all the elements of a matrix by treating it as a 1 x N array, creating an N x 1 array of ones, and doing a cublasDgemm operation.

我不认为你会在任何地方找到cublas的源代码。

I don't think you're going to find the source code for cublas anywhere.

这篇关于如何在GPU中添加数组的元素?任何类似于CUBLAS中的cublasDasum的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 12:38