Skip to content

Commit

Permalink
Improve matcopy interface
Browse files Browse the repository at this point in the history
* rows = 0 or cols = 0 is now a legal input and
  takes quick return path
* Follow BLAS/LAPACK convention that the leading
  dimensions must be at least 1.
  • Loading branch information
angsch committed Nov 11, 2023
1 parent 273f4e8 commit 5ffbe64
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 48 deletions.
22 changes: 12 additions & 10 deletions interface/imatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,29 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows,

if ( order == BlasColMajor)
{
if ( trans == BlasNoTrans && *ldb < *rows ) info = 8;
if ( trans == BlasTrans && *ldb < *cols ) info = 8;
if ( trans == BlasNoTrans && *ldb < MAX(1,*rows) ) info = 8;
if ( trans == BlasTrans && *ldb < MAX(1,*cols) ) info = 8;
}
if ( order == BlasRowMajor)
{
if ( trans == BlasNoTrans && *ldb < *cols ) info = 8;
if ( trans == BlasTrans && *ldb < *rows ) info = 8;
if ( trans == BlasNoTrans && *ldb < MAX(1,*cols) ) info = 8;
if ( trans == BlasTrans && *ldb < MAX(1,*rows) ) info = 8;
}

if ( order == BlasColMajor && *lda < *rows ) info = 7;
if ( order == BlasRowMajor && *lda < *cols ) info = 7;
if ( *cols <= 0 ) info = 4;
if ( *rows <= 0 ) info = 3;
if ( trans < 0 ) info = 2;
if ( order < 0 ) info = 1;
if ( order == BlasColMajor && *lda < MAX(1,*rows) ) info = 7;
if ( order == BlasRowMajor && *lda < MAX(1,*cols) ) info = 7;
if ( *cols < 0 ) info = 4;
if ( *rows < 0 ) info = 3;
if ( trans < 0 ) info = 2;
if ( order < 0 ) info = 1;

if (info >= 0) {
BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
return;
}

if ((*rows == 0) || (*cols == 0)) return;

#ifdef NEW_IMATCOPY
if ( *lda == *ldb ) {
if ( order == BlasColMajor )
Expand Down
22 changes: 12 additions & 10 deletions interface/omatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,29 @@ void CNAME(enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows,
#endif
if ( order == BlasColMajor)
{
if ( trans == BlasNoTrans && *ldb < *rows ) info = 9;
if ( trans == BlasTrans && *ldb < *cols ) info = 9;
if ( trans == BlasNoTrans && *ldb < MAX(1,*rows) ) info = 9;
if ( trans == BlasTrans && *ldb < MAX(1,*cols) ) info = 9;
}
if ( order == BlasRowMajor)
{
if ( trans == BlasNoTrans && *ldb < *cols ) info = 9;
if ( trans == BlasTrans && *ldb < *rows ) info = 9;
if ( trans == BlasNoTrans && *ldb < MAX(1,*cols) ) info = 9;
if ( trans == BlasTrans && *ldb < MAX(1,*rows) ) info = 9;
}

if ( order == BlasColMajor && *lda < *rows ) info = 7;
if ( order == BlasRowMajor && *lda < *cols ) info = 7;
if ( *cols <= 0 ) info = 4;
if ( *rows <= 0 ) info = 3;
if ( trans < 0 ) info = 2;
if ( order < 0 ) info = 1;
if ( order == BlasColMajor && *lda < MAX(1,*rows) ) info = 7;
if ( order == BlasRowMajor && *lda < MAX(1,*cols) ) info = 7;
if ( *cols < 0 ) info = 4;
if ( *rows < 0 ) info = 3;
if ( trans < 0 ) info = 2;
if ( order < 0 ) info = 1;

if (info >= 0) {
BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
return;
}

if ((*rows == 0) || (*cols == 0)) return;

if ( order == BlasColMajor )
{
if ( trans == BlasNoTrans )
Expand Down
30 changes: 16 additions & 14 deletions interface/zimatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,33 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows,

if ( order == BlasColMajor)
{
if ( trans == BlasNoTrans && *ldb < *rows ) info = 9;
if ( trans == BlasConj && *ldb < *rows ) info = 9;
if ( trans == BlasTrans && *ldb < *cols ) info = 9;
if ( trans == BlasTransConj && *ldb < *cols ) info = 9;
if ( trans == BlasNoTrans && *ldb < MAX(1,*rows) ) info = 9;
if ( trans == BlasConj && *ldb < MAX(1,*rows) ) info = 9;
if ( trans == BlasTrans && *ldb < MAX(1,*cols) ) info = 9;
if ( trans == BlasTransConj && *ldb < MAX(1,*cols) ) info = 9;
}
if ( order == BlasRowMajor)
{
if ( trans == BlasNoTrans && *ldb < *cols ) info = 9;
if ( trans == BlasConj && *ldb < *cols ) info = 9;
if ( trans == BlasTrans && *ldb < *rows ) info = 9;
if ( trans == BlasTransConj && *ldb < *rows ) info = 9;
if ( trans == BlasNoTrans && *ldb < MAX(1,*cols) ) info = 9;
if ( trans == BlasConj && *ldb < MAX(1,*cols) ) info = 9;
if ( trans == BlasTrans && *ldb < MAX(1,*rows) ) info = 9;
if ( trans == BlasTransConj && *ldb < MAX(1,*rows) ) info = 9;
}

if ( order == BlasColMajor && *lda < *rows ) info = 7;
if ( order == BlasRowMajor && *lda < *cols ) info = 7;
if ( *cols <= 0 ) info = 4;
if ( *rows <= 0 ) info = 3;
if ( trans < 0 ) info = 2;
if ( order < 0 ) info = 1;
if ( order == BlasColMajor && *lda < MAX(1,*rows) ) info = 7;
if ( order == BlasRowMajor && *lda < MAX(1,*cols) ) info = 7;
if ( *cols < 0 ) info = 4;
if ( *rows < 0 ) info = 3;
if ( trans < 0 ) info = 2;
if ( order < 0 ) info = 1;

if (info >= 0) {
BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
return;
}

if ((*rows == 0) || (*cols == 0)) return;

#ifdef NEW_IMATCOPY
if (*lda == *ldb ) {
if ( order == BlasColMajor )
Expand Down
30 changes: 16 additions & 14 deletions interface/zomatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,33 @@ void CNAME(enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows,
#endif
if ( order == BlasColMajor)
{
if ( trans == BlasNoTrans && *ldb < *rows ) info = 9;
if ( trans == BlasConj && *ldb < *rows ) info = 9;
if ( trans == BlasTrans && *ldb < *cols ) info = 9;
if ( trans == BlasTransConj && *ldb < *cols ) info = 9;
if ( trans == BlasNoTrans && *ldb < MAX(1,*rows) ) info = 9;
if ( trans == BlasConj && *ldb < MAX(1,*rows) ) info = 9;
if ( trans == BlasTrans && *ldb < MAX(1,*cols) ) info = 9;
if ( trans == BlasTransConj && *ldb < MAX(1,*cols) ) info = 9;
}
if ( order == BlasRowMajor)
{
if ( trans == BlasNoTrans && *ldb < *cols ) info = 9;
if ( trans == BlasConj && *ldb < *cols ) info = 9;
if ( trans == BlasTrans && *ldb < *rows ) info = 9;
if ( trans == BlasTransConj && *ldb < *rows ) info = 9;
if ( trans == BlasNoTrans && *ldb < MAX(1,*cols) ) info = 9;
if ( trans == BlasConj && *ldb < MAX(1,*cols) ) info = 9;
if ( trans == BlasTrans && *ldb < MAX(1,*rows) ) info = 9;
if ( trans == BlasTransConj && *ldb < MAX(1,*rows) ) info = 9;
}

if ( order == BlasColMajor && *lda < *rows ) info = 7;
if ( order == BlasRowMajor && *lda < *cols ) info = 7;
if ( *cols <= 0 ) info = 4;
if ( *rows <= 0 ) info = 3;
if ( trans < 0 ) info = 2;
if ( order < 0 ) info = 1;
if ( order == BlasColMajor && *lda < MAX(1,*rows) ) info = 7;
if ( order == BlasRowMajor && *lda < MAX(1,*cols) ) info = 7;
if ( *cols < 0 ) info = 4;
if ( *rows < 0 ) info = 3;
if ( trans < 0 ) info = 2;
if ( order < 0 ) info = 1;

if (info >= 0) {
BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
return;
}

if ((*rows == 0) || (*cols == 0)) return;

if ( order == BlasColMajor )
{

Expand Down

0 comments on commit 5ffbe64

Please sign in to comment.