在 CUDA 内核中使用许多固定大小的矩阵

Working with many fixed-size matrices in CUDA kernels

我希望处理大约 4000 个固定大小(3x3、4x4)矩阵,进行矩阵求逆和特征分解等操作。

在我看来,最好的并行化方法是让许多 GPU 线程中的每一个都处理问题的单个实例。

有什么合理的方法吗?我已阅读:http://www.culatools.com/blog/2011/12/09/batched-operations/ 但据我所知,它总是 "being worked on" 且看不到解决方案。三年过去了,希望有个好的解决办法。

到目前为止,我看过:

在这一点上,我很想完全放弃在 GPU 上执行此操作。很遗憾,因为我希望算法的实时性能需要每 0.1 秒反转 4000 个 3x3 矩阵大约 100 次。

可以进行矩阵求逆的 cublas 函数 getrfBatched and getriBatched are designed for batch inversion of small matrices. This should be quicker than either dynamic parallelism or streams (your 2nd and 3rd approaches.) Also a batch solver is available in source code form。您需要在 developer.nvidia.com 以注册开发者身份登录才能访问此 link。

Also, I'm not sure if there is anything like cuBLAS that can also do eigendecomposition or SVD. (As far as I know, CULA does not support calling its routines from within kernels).

Cusolver 提供了一些 eigen solver functions。然而,它们不是批处理的,也不是从设备代码调用的,所以你面临着流作为除此之外的唯一选择。