我在GPU(CUDA)上实现了一个程序,它只使用主机(在C ++中)来启动新内核。在设备计算期间,我需要 SVD 和求解系统 3x3(密集)矩阵,固定大小。
我有自己的SVD和求解器实现,但它不是数值稳定的(因此不可用)。由于我是C ++和CUDA的新手,我宁愿使用库。 (数字的东西很棘手)
现在我无法找到该库:
首选我也可以使用库进行常规矩阵运算(转置,反转,求和,乘法等),因为我自己的实现可能效率低,数值稳定。
关于如何实现这一目标的任何想法?
更新 似乎Eigen支持基本功能,如*,+,转置甚至特征值,但尚不支持SVD,反ect。这是在撰写本文时。
答案 0 :(得分:1)
根据website,一部分特征适用于固定大小矩阵(在您的情况下为3x3)来自Eigen 3.3。目前的稳定版本是3.2.6而3.3是alpha。我不知道CUDA是否支持特定的SVD。我建议尝试一个小的MCVE来查看它是否有效(以及你需要的其他功能),如果有的话,在你的项目中实现它。
答案 1 :(得分:0)
I'm having a similar problem; want to generate random vectors within a kernel function which requires performing cholesky/eigenvalue decompositions of NxN (N<=5) covariance matrices. Since, as you noted, the MAGMA and CULA libraries are not available from the device, and there seems to be no cuSOLVER device API yet, I've resorted to implementing these myself following algorithms outlined in, for example, Numerical Recipes in C. As for solving linear systems, I'd suggest checking out the cuBLAS (level 2 functions), as it provides some basic functionality. If you want to invert matrices, I'd suggest cublasmatinvBatched(). I haven't used it myself, will give it a try during the weekend, but from the description it sounds promising. Hope others will chime into this thread with better solutions...