In cublas-4.1.28, is there a convention change in the function parameters?

StackOverflow https://stackoverflow.com/questions/13317121

  •  28-11-2021
  •  | 
  •  

سؤال

I want to do the following matrix-matrix multiplication by using cublas:

  cA(M by K) * cB(K by N) => cAout(M by N)

I assigned cA with K as the leading index, and cB with N as the leading index. According to cublas-4.0 handbook, I should do:

HANDLE_ERROR(cublasSgemm(hdl, CUBLAS_OP_N, CUBLAS_OP_N, M, K, N, &alpha, cA, K, cB, N, &beta, cAout, N));    

but it didn't work. Instead, the following code produces the expected results by literately switching cA and cB:

HANDLE_ERROR(cublasSgemm(hdl, CUBLAS_OP_N, CUBLAS_OP_N, N, K, M, &alpha, cB, N, cA, K, &beta, cAout, N));    

The cublas version I was using is 4.1.28. Is there a convention change in the function parameters? Thanks!

هل كانت مفيدة؟

المحلول

Recall that CUBLAS uses the column-major storage convention. Assuming these matrices are not part of some larger matrix, the leading dimension of cA is M, the leading dimension of cB is K, and the leading dimension of cAout is M. Your SGEMM call should therefore read

HANDLE_ERROR(cublasSgemm(hdl, CUBLAS_OP_N, CUBLAS_OP_N, M, K, N, &alpha, cA, M, cB, K, &beta, cAout, M));    
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top