Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么矩阵的索引式列主序的 #7

Open
VeritasFutureKF opened this issue Jul 10, 2024 · 1 comment
Open

为什么矩阵的索引式列主序的 #7

VeritasFutureKF opened this issue Jul 10, 2024 · 1 comment

Comments

@VeritasFutureKF
Copy link

如题

@zhaosiyuan1098
Copy link

我对这里也比较感兴趣,个人理解是:

  • cublas为了适配Fortran,默认使用了列优先存储 。在test.cu的实际调用cublasSgemm(err, CUBLAS_OP_N, CUBLAS_OP_N, m, n, k, &alpha, dA, m, dB, k, &beta, dC_ref, m);中,根据api可推断确实使用的是列优先。
  • 当把 C / C++ 中行优先保存的二维数组 A 以一维形式输入 cublas 时,会被 cublas 理解为列优先存储。
  • 为了保证和cublas的一致性,且避免行列的混乱,统一使用了列主序,从kernel1.cu中的#define A(i,j) A[(i) + (j)*lda] #define B(i,j) B[(i) + (j)*ldb] #define C(i,j) C[(i) + (j)*ldc]中也可推断出kernel中的矩阵是列优先的。

不知道理解的对不对,烦请作者@yzhaiustc解答 ,谢谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants