24

For a matrix A, the documentation only states that the corresponding leading dimension parameter lda refers to the:

leading dimension of two-dimensional array used to store the matrix A

Thus I presume this is just the number of rows of A given CUBLAS' column major storage format. However, when we consider Op(A), what does the leading dimension refer to now?

mchen
  • 9,808
  • 17
  • 72
  • 125

2 Answers2

20

Nothing changes. The leading dimension always refers to the length of the first dimension of the array. The data order flags (normal, transpose, conjugate) only indicate to BLAS how the data within the array is stored. They have no effect on the array itself, which is always column major ordered and requires an LDA value for indexing in 2D.

So whether the matrix data is stored in transposed form or not, an m x n array always has LDA>=m.

talonmies
  • 70,661
  • 34
  • 192
  • 269
  • 6
    From your answer, I was ready to conclude that LDA = m. Why the > sign there? :/ +1 btw. Maybe this answer the question after all: http://icl.cs.utk.edu/lapack-forum/viewtopic.php?t=217 – gsamaras Jun 19 '15 at 11:01
  • 2
    @gsamaras: Think about when a BLAS call operates on a submatrix, or when hardware works better when the *pitch* of the matrix matches a memory controller page size, or cache line size or whatever. See http://stackoverflow.com/q/8206563/681865 – talonmies Jun 19 '15 at 11:12
  • 1
    Thanks! Your answer should be the accepted one there IMHO. "The LDA parameter in BLAS is effectively the stride of the matrix as it is laid out in linear memory." ||| Now, I want to jump on to the distributed case, so if you have some time, maybe you can take a looo at this question: http://stackoverflow.com/questions/30937544/confused-with-pdpotrf-arguments – gsamaras Jun 19 '15 at 11:56
7

If you are using row-major representation then the number of "columns" will be leading dimension and vice versa in column-major representation number of "rows".

khushnood
  • 95
  • 1
  • 6