From 492f54fb5e776420c43d1a5e86e140b756f07719 Mon Sep 17 00:00:00 2001 From: Kiran Varaganti Date: Sat, 22 May 2021 20:46:57 +0530 Subject: [PATCH] Fix a bug in bench_gemm.c When op(A) or op(B) = transpose - the leading dimensions of these matrices altered. Commented out the statements "if(transa) lda = ..." similarly for matrix B and corrected this mistake in both column and row storages. Provide a provision to call BLIS interfaces when row-major inputs are used. Change-Id: Id2041af219a64567471c14190f283274d1df2f7f --- bench/bench_gemm.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/bench/bench_gemm.c b/bench/bench_gemm.c index 3cea4c98e..5390a8d66 100755 --- a/bench/bench_gemm.c +++ b/bench/bench_gemm.c @@ -172,16 +172,16 @@ int main( int argc, char** argv ) // Since this bench app is run on logs generated by AOCL trace logs // - we have relaxed the checks on the input parameters. - // if A is transpose - A(lda x m), lda = max(1,k) - // if A is non-transpose - A (lda x k), lda = max(1,m) - // if B is transpose - B (ldb x k), ldb = max(1,n) - // if B is non-transpose - B (ldb x n), ldb = max(1,k) - // C is ldc x n - ldc = max(1, m) - if(transa) lda = k; + // if A is transpose - A(lda x m), lda >= max(1,k) + // if A is non-transpose - A (lda x k), lda >= max(1,m) + // if B is transpose - B (ldb x k), ldb >= max(1,n) + // if B is non-transpose - B (ldb x n), ldb >= max(1,k) + // C is ldc x n - ldc >= max(1, m) + //if(transa) lda = k; // We will end up overwriting lda bli_set_dims_with_trans( transa, m, k, &m_trans, &n_trans); bli_obj_create( dt, m_trans, n_trans, 1, lda, &a); - if(transb) ldb = n; + //if(transb) ldb = n; // we will end up overwriting ldb, ldb >= n bli_set_dims_with_trans( transb, k, n, &m_trans, &n_trans); bli_obj_create( dt, m_trans, n_trans, 1, ldb, &b); @@ -197,11 +197,17 @@ int main( int argc, char** argv ) // Since this bench app is run on logs generated by AOCL trace logs // - we have relaxed the checks on the input parameters. - if(transa) lda = m; + // if A is transpose - A(k x lda), lda >= max(1,m) + // if A is non-transpose - A (m x lda), lda >= max(1,k) + // if B is transpose - B (n x ldb), ldb >= max(1,k) + // if B is non-transpose - B (k x ldb ), ldb >= max(1,n) + // C is m x ldc - ldc >= max(1, n) + + //if(transa) lda = m; // this will overwrite lda bli_set_dims_with_trans(transa, m, k, &m_trans, &n_trans); bli_obj_create( dt, m_trans, n_trans, lda, 1, &a); - if(transb) ldb = k; + //if(transb) ldb = k; // this will overwrite ldb bli_set_dims_with_trans(transb, k, n, &m_trans, &n_trans); bli_obj_create( dt, m_trans, n_trans, ldb, 1, &b); @@ -213,15 +219,16 @@ int main( int argc, char** argv ) printf("Invalid storage scheme\n"); continue; } - -#ifndef CBLAS +#ifndef BLIS // Incase if we are using blis interface we don't have to check for col-storage. + #ifndef CBLAS if(bli_obj_col_stride(&c) == 1) { printf("BLAS APIs doesn't support row-storage: Enable CBLAS\n"); continue; } + #endif #endif - + #ifdef AOCL_MATRIX_INITIALISATION bli_randm( &a ); bli_randm( &b );