From 91bde7d315e8561b992b41bba603b78f7fab909b Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 15 Jul 2017 22:02:53 +0200 Subject: [PATCH 1/3] Exchange rows and cols in final omatcopy with BlasTrans This is MicMuc's patch from #899 --- interface/zimatcopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/zimatcopy.c b/interface/zimatcopy.c index 0bb0e4eed..6e9c6d263 100644 --- a/interface/zimatcopy.c +++ b/interface/zimatcopy.c @@ -238,7 +238,7 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows, if ( trans == BlasTrans ) { OMATCOPY_K_RT(*rows, *cols, alpha[0], alpha[1], a, *lda, b, *ldb ); - OMATCOPY_K_RN(*rows, *cols, (FLOAT) 1.0, (FLOAT) 0.0 , b, *ldb, a, *ldb ); + OMATCOPY_K_RN(*cols, *rows, (FLOAT) 1.0, (FLOAT) 0.0 , b, *ldb, a, *ldb ); free(b); return; } From d1c5b8f91362126d0963f40f87cccb72d7177b22 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 20 Jul 2017 20:51:06 +0200 Subject: [PATCH 2/3] Add files via upload --- interface/zimatcopy.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/interface/zimatcopy.c b/interface/zimatcopy.c index 6e9c6d263..3479c489b 100644 --- a/interface/zimatcopy.c +++ b/interface/zimatcopy.c @@ -125,9 +125,9 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows, BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME)); return; } - #ifdef NEW_IMATCOPY if (*lda == *ldb) { +fprintf(stderr," lda=ldb, new_imatcopy in place\n"); if ( order == BlasColMajor ) { @@ -141,7 +141,7 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows, } if ( trans == BlasTrans ) { - IMATCOPY_K_CT(*rows, *cols, alpha[0], alpha[1], a, *lda ); + IMATCOPY_K_CT(*cols, *rows, alpha[0], alpha[1], a, *lda ); } if ( trans == BlasTransConj ) { @@ -161,6 +161,7 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows, } if ( trans == BlasTrans ) { +fprintf(stderr,"rows trans inplace\n"); IMATCOPY_K_RT(*rows, *cols, alpha[0], alpha[1], a, *lda ); } if ( trans == BlasTransConj ) @@ -171,7 +172,7 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows, return; } #endif - +fprintf(stderr,"lda: %d ldb:%d\n",*lda,*ldb); if ( *lda > *ldb ) msize = (*lda) * (*ldb) * sizeof(FLOAT) * 2; else @@ -205,14 +206,14 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows, if ( trans == BlasTrans ) { OMATCOPY_K_CT(*rows, *cols, alpha[0], alpha[1], a, *lda, b, *ldb ); - OMATCOPY_K_CN(*rows, *cols, (FLOAT) 1.0, (FLOAT) 0.0 , b, *ldb, a, *ldb ); + OMATCOPY_K_CN(*cols, *rows, (FLOAT) 1.0, (FLOAT) 0.0 , b, *ldb, a, *ldb ); free(b); return; } if ( trans == BlasTransConj ) { OMATCOPY_K_CTC(*rows, *cols, alpha[0], alpha[1], a, *lda, b, *ldb ); - OMATCOPY_K_CN(*rows, *cols, (FLOAT) 1.0, (FLOAT) 0.0 , b, *ldb, a, *ldb ); + OMATCOPY_K_CN(*cols, *rows, (FLOAT) 1.0, (FLOAT) 0.0 , b, *ldb, a, *ldb ); free(b); return; } @@ -245,7 +246,7 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows, if ( trans == BlasTransConj ) { OMATCOPY_K_RTC(*rows, *cols, alpha[0], alpha[1], a, *lda, b, *ldb ); - OMATCOPY_K_RN(*rows, *cols, (FLOAT) 1.0, (FLOAT) 0.0 , b, *ldb, a, *ldb ); + OMATCOPY_K_RN(*cols, *rows, (FLOAT) 1.0, (FLOAT) 0.0 , b, *ldb, a, *ldb ); free(b); return; } From 376048156b3ea5774ee2c28d25f7641150b8b1db Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Fri, 21 Jul 2017 11:20:15 +0200 Subject: [PATCH 3/3] Use in-place transform shortcut only if matrix is square --- interface/zimatcopy.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/interface/zimatcopy.c b/interface/zimatcopy.c index 3479c489b..87964e20d 100644 --- a/interface/zimatcopy.c +++ b/interface/zimatcopy.c @@ -126,8 +126,7 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows, return; } #ifdef NEW_IMATCOPY - if (*lda == *ldb) { -fprintf(stderr," lda=ldb, new_imatcopy in place\n"); + if (*lda == *ldb && *cols == *rows) { if ( order == BlasColMajor ) { @@ -141,7 +140,7 @@ fprintf(stderr," lda=ldb, new_imatcopy in place\n"); } if ( trans == BlasTrans ) { - IMATCOPY_K_CT(*cols, *rows, alpha[0], alpha[1], a, *lda ); + IMATCOPY_K_CT(*rows, *cols, alpha[0], alpha[1], a, *lda ); } if ( trans == BlasTransConj ) { @@ -161,7 +160,6 @@ fprintf(stderr," lda=ldb, new_imatcopy in place\n"); } if ( trans == BlasTrans ) { -fprintf(stderr,"rows trans inplace\n"); IMATCOPY_K_RT(*rows, *cols, alpha[0], alpha[1], a, *lda ); } if ( trans == BlasTransConj ) @@ -172,7 +170,7 @@ fprintf(stderr,"rows trans inplace\n"); return; } #endif -fprintf(stderr,"lda: %d ldb:%d\n",*lda,*ldb); + if ( *lda > *ldb ) msize = (*lda) * (*ldb) * sizeof(FLOAT) * 2; else @@ -181,7 +179,7 @@ fprintf(stderr,"lda: %d ldb:%d\n",*lda,*ldb); b = malloc(msize); if ( b == NULL ) { - printf("Memory alloc failed\n"); + printf("Memory alloc failed in zimatcopy\n"); exit(1); }