From f0c26bd1b0b8ffe05c0c5f04567a9b7aa47c3e6b Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 03:15:46 -0400 Subject: Update dclapack to do automatic size-of-array'ing --- redist/dclapack.h | 8 ++++++-- redist/dclhelpers.c | 28 +++++++++++++++++----------- redist/dclhelpers.h | 4 +--- 3 files changed, 24 insertions(+), 16 deletions(-) (limited to 'redist') diff --git a/redist/dclapack.h b/redist/dclapack.h index 1dc7b77..af8869c 100644 --- a/redist/dclapack.h +++ b/redist/dclapack.h @@ -9,10 +9,14 @@ #define _ABS(a) ( (a)<=0 ? 0-(a) : (a) ) +//Tricky: If you want to use this with pointers, instead of 2D arrays, you will +//need to #define DYNAMIC_INDEX, as well as, for all arrays, suffix their name +//with 'c' + #ifdef DYNAMIC_INDEX - #define _(A,O,P) A[O*A##c+P] + #define _(AM,O,P) AM[O*AM##c+P] #else - #define _(A,O,P) A[O][P] + #define _(AM,O,P) AM[O][P] #endif diff --git a/redist/dclhelpers.c b/redist/dclhelpers.c index 9fa9266..c3725f8 100644 --- a/redist/dclhelpers.c +++ b/redist/dclhelpers.c @@ -69,34 +69,40 @@ void dcldgemm( int k, DCL_FLOAT alpha, const DCL_FLOAT* A, - int lda, //must be n + int Ac, //must be n const DCL_FLOAT* B, - int ldb, //must be m + int Bc, //must be m DCL_FLOAT beta, - const DCL_FLOAT * C, - int ldc //must be n + DCL_FLOAT * C, + int Cc //must be n ) { const DCL_FLOAT * ta; const DCL_FLOAT * tb; + int tac = Ac; + int tbc = Bc; if( transA ) { - ta = alloca( sizeof( DCL_FLOAT ) * n * m ); - //TRANSP( ta, A, n, m ); + DCL_FLOAT * la = alloca( sizeof( DCL_FLOAT ) * n * m ); + const int lac = m; + TRANSP( la, A, n, m ); + ta = la; + tac = lac; } else ta = A; if( transB ) { - tb = alloca( sizeof( DCL_FLOAT ) * n * m ); - //TRANSP( tb, B, n, m ); + DCL_FLOAT * lb = alloca( sizeof( DCL_FLOAT ) * n * m ); + const int lbc = m; + TRANSP( lb, B, n, m ); + tb = lb; + tbc = lbc; } else tb = B; - - //XXX Tricky: In here, A is mxn - + GMULADD(C,ta,tb,C,alpha,beta,n,m,k); } diff --git a/redist/dclhelpers.h b/redist/dclhelpers.h index 5010e02..8779e1a 100644 --- a/redist/dclhelpers.h +++ b/redist/dclhelpers.h @@ -3,8 +3,6 @@ #define DCL_FLOAT FLT -//XXX XXX XXX WARNING XXX XXX XXX The argument order may be changing!!! - /* Prints matrix A of size[n][m] */ void dclPrint( const DCL_FLOAT * A, int Ac, int n, int m ); @@ -75,7 +73,7 @@ void dcldgemm( const DCL_FLOAT* B, int Bc, DCL_FLOAT beta, - const DCL_FLOAT * C, + DCL_FLOAT * C, int Cc ); -- cgit v1.2.3