parsec icon indicating copy to clipboard operation
parsec copied to clipboard

parsec_matrix_define_triangle swaps Upper/Lower Triangular matrices?

Open abouteiller opened this issue 5 years ago • 4 comments

Original report by Omri Mor (Bitbucket: omrimor2, GitHub: omor1).


diag = /* 0 if includes diagonal, 1 otherwise */
if (uplo == matrix_Upper) {
  nmax = n-diag;
  for (i = diag; i < n; i++) {
    unsigned int mm = i + 1 - diag;
    blocklens[i] = mm < m ? mm : m;
    indices[i]   = i * ld;
  }
} else if (uplo == matrix_Lower) {
  nmax = n >= (m-diag) ? m-diag : n;
  for (i = 0; i < nmax; i++) {
    blocklens[i] = m - i - diag;
    indices[i]   = i * ld + i + diag;
  }
  diag = 0;
}
parsec_type_create_indexed(nmax, blocklens+diag, indices+diag, oldtype, &tmp);

Unless I’m misreading this or fundamentally misunderstanding how PaRSEC treats upper and lower triangular matrices, the definitions of the two here are swapped. An upper triangular matrix should have min(n, m) rows, with the first row having m elements, the next having m-1, and so forth, until the last row has 1 element. A lower triangular matrix has n rows, with the first have 1 element, the following 2, and so forth, until it caps at min(n, m) elements.

Unless PaRSEC uses column-major storage order, in which case n is the number of columns, rather than rows, as I’d understood it?

abouteiller avatar Aug 04 '20 01:08 abouteiller

Original comment by Omri Mor (Bitbucket: omrimor2, GitHub: omor1).


This is in parsec/data_dist/matrix/matrixtypes.c.

abouteiller avatar Aug 04 '20 01:08 abouteiller

Original comment by Omri Mor (Bitbucket: omrimor2, GitHub: omor1).


Actually, looking into the code of DPLASMA, it seems like CBLAS is called with CblasColMajor, so I suppose that column-major order is used. I certainly wish that we had more documentation in the code about this…

abouteiller avatar Aug 04 '20 01:08 abouteiller

Original comment by George Bosilca (Bitbucket: bosilca, GitHub: bosilca).


The default storage type is Lapack, and it is defined in matrix.h as column major.

abouteiller avatar Aug 04 '20 03:08 abouteiller

Original comment by George Bosilca (Bitbucket: bosilca, GitHub: bosilca).


We need documentation on the storage type used in the base matrix types.

abouteiller avatar Aug 04 '20 03:08 abouteiller