我可以在GPU上进行这种并行计算吗?

Neo*_*ang 7 gpu opengl-es matrix ios

我有一个M*N整数矩阵,我需要遍历并计算每个元素M [i] [j]:

The integer which appears most often in the submatrix from (i-k,j-k) to (i+k, j+k).
Run Code Online (Sandbox Code Playgroud)

因此,结果是一个矩阵,每个单元格是原始矩阵中[i,j]周围的主导数.

矩阵可能非常大,我需要在紧密循环中执行此操作,因此我希望通过并行计算最小化操作时间.

我知道GPU擅长矩阵乘法,但看起来这不能简化为简单的矩阵乘法.(或者可以吗?)

是否有可能在GPU上并行计算每个单元?如果是,我想在iOS中实现这个,我应该使用什么编程接口,Metal?OpenGL的?

Gui*_*cal 3

是的,您可以在 GPU 上进行此计算。

Metal似乎既适用于图形计算,也适用于通用计算。所以你应该能够根据你的需要使用它(这里有一篇介绍它的文章:http ://memkite.com/blog/2014/12/15/data-parallel-programming-with-metal-and-swift-for -iphoneipad-gpu/ )

Accelerate也能满足我们的需求。

希望这有帮助。