From 783a88f8904b5758195f96c65c7e0b6e87f8a51e Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 01:00:07 -0400 Subject: Update DCLapack with the C helpers to cize stuff. --- redist/dclhelpers.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 redist/dclhelpers.c (limited to 'redist/dclhelpers.c') diff --git a/redist/dclhelpers.c b/redist/dclhelpers.c new file mode 100644 index 0000000..9d3d0eb --- /dev/null +++ b/redist/dclhelpers.c @@ -0,0 +1,63 @@ +#include "dclhelpers.h" +#define FLOAT DCL_FLOAT +#define DYNAMIC_INDEX +#include +#include "dclapack.h" + + +void dclPrint( const DCL_FLOAT * A, int n, int m ) +{ + PRINT( A, n, m ); +} + +void dclIdentity( DCL_FLOAT * A, int n ) +{ + IDENTITY( A, n ); +} + +void dclTransp( const DCL_FLOAT * A, DCL_FLOAT * B, int n, int m) +{ + TRANSP(A,B,n,m); +} + +void dclLU( const DCL_FLOAT * A, DCL_FLOAT * L, DCL_FLOAT * U, int * Piv, int n ) +{ + LU(A,L,U,Piv,n); +} + +void dclPivot( const DCL_FLOAT * A, DCL_FLOAT * B, int * Piv, int n, int m ) +{ + PIVOT(A,B,Piv,n,m); +} + +void dclLSub( const DCL_FLOAT * L, DCL_FLOAT * X, const DCL_FLOAT * B, int n, int m ) +{ + L_SUB(L,X,B,n,m); +} + +void dclUSub( const DCL_FLOAT * U, DCL_FLOAT * X, const DCL_FLOAT * B, int n, int m ) +{ + U_SUB(U,X,B,n,m); +} + +void dclInv( const DCL_FLOAT * A, DCL_FLOAT * Ainv, int n ) +{ + INV(A,Ainv,n,n); +} + +void dclMul( const DCL_FLOAT * A, const DCL_FLOAT * B, DCL_FLOAT * C, int n, int m, int p ) +{ + MUL(A,B,C,n,m,p); +} + +void dclMulAdd( const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT * D, int n, int m, int p ) +{ + MULADD(A,B,C,D,n,m,p); +} + +void dclGMulAdd( const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT * D, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ) +{ + GMULADD(A,B,C,D,alpha,beta,n,m,p); +} + + -- cgit v1.2.3 From 8b9a196232661bd6506a41b7ceca015d684086a8 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 01:13:28 -0400 Subject: Update variable ordering... --- redist/dclhelpers.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'redist/dclhelpers.c') diff --git a/redist/dclhelpers.c b/redist/dclhelpers.c index 9d3d0eb..2ee6c4a 100644 --- a/redist/dclhelpers.c +++ b/redist/dclhelpers.c @@ -15,49 +15,49 @@ void dclIdentity( DCL_FLOAT * A, int n ) IDENTITY( A, n ); } -void dclTransp( const DCL_FLOAT * A, DCL_FLOAT * B, int n, int m) +void dclTransp( DCL_FLOAT * R, const DCL_FLOAT * A, int n, int m ) { - TRANSP(A,B,n,m); + TRANSP(R,A,n,m); } -void dclLU( const DCL_FLOAT * A, DCL_FLOAT * L, DCL_FLOAT * U, int * Piv, int n ) +void dclLU( DCL_FLOAT * L, DCL_FLOAT * U, const DCL_FLOAT * A, int * Piv, int n ) { - LU(A,L,U,Piv,n); + LU(L,U,A,Piv,n); } -void dclPivot( const DCL_FLOAT * A, DCL_FLOAT * B, int * Piv, int n, int m ) +void dclPivot( DCL_FLOAT * R, const DCL_FLOAT * A, int * Piv, int n, int m ) { - PIVOT(A,B,Piv,n,m); + PIVOT(R,A,Piv,n,m); } -void dclLSub( const DCL_FLOAT * L, DCL_FLOAT * X, const DCL_FLOAT * B, int n, int m ) +void dclLSub( DCL_FLOAT * X, const DCL_FLOAT * L, const DCL_FLOAT * B, int n, int m ) { - L_SUB(L,X,B,n,m); + L_SUB(X,L,B,n,m); } -void dclUSub( const DCL_FLOAT * U, DCL_FLOAT * X, const DCL_FLOAT * B, int n, int m ) +void dclUSub( DCL_FLOAT * X, const DCL_FLOAT * U, const DCL_FLOAT * B, int n, int m ) { - U_SUB(U,X,B,n,m); + U_SUB(X,U,B,n,m); } -void dclInv( const DCL_FLOAT * A, DCL_FLOAT * Ainv, int n ) +void dclInv( DCL_FLOAT * Ainv, const DCL_FLOAT * A, int n ) { - INV(A,Ainv,n,n); + INV(Ainv,A,n,n); } -void dclMul( const DCL_FLOAT * A, const DCL_FLOAT * B, DCL_FLOAT * C, int n, int m, int p ) +void dclMul( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, int n, int m, int p ) { - MUL(A,B,C,n,m,p); + MUL(R,A,B,n,m,p); } -void dclMulAdd( const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT * D, int n, int m, int p ) +void dclMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, int n, int m, int p ) { - MULADD(A,B,C,D,n,m,p); + MULADD(R,A,B,C,n,m,p); } -void dclGMulAdd( const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT * D, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ) +void dclGMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ) { - GMULADD(A,B,C,D,alpha,beta,n,m,p); + GMULADD(R,A,B,C,alpha,beta,n,m,p); } -- cgit v1.2.3 From bcf08b95ab6daa7ac7bffe1449fa8a11cad2a02a Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 02:28:11 -0400 Subject: Get closer to functional. --- redist/dclhelpers.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'redist/dclhelpers.c') diff --git a/redist/dclhelpers.c b/redist/dclhelpers.c index 2ee6c4a..23c3ca5 100644 --- a/redist/dclhelpers.c +++ b/redist/dclhelpers.c @@ -60,4 +60,29 @@ void dclGMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const GMULADD(R,A,B,C,alpha,beta,n,m,p); } +/* dclGMulAdd( R, ((transA)?TRANS(A):A, (transB)?TRANS(B):B), C, alpha, beta, n, m, p ); */ +void dcldgemm( + char transA, + char transB, + int m, + int n, + int k, + DCL_FLOAT alpha, + const DCL_FLOAT* A, + int lda, //must be n + const DCL_FLOAT* B, + int ldb, //must be m + DCL_FLOAT beta, + const DCL_FLOAT * C, + int ldc //must be n + ) +{ + DCL_FLOAT * ta; + DCL_FLOAT * tb; + if( transA ) + { + ta = alloca( sizeof( DCL_FLOAT ) * n * m ); + + } +} -- cgit v1.2.3 From 08eec7a6bd5edc0fd1cae7f98d7788ea3905a467 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 03:05:21 -0400 Subject: Now wrangled with ability to use submatricies. --- redist/dclhelpers.c | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) (limited to 'redist/dclhelpers.c') diff --git a/redist/dclhelpers.c b/redist/dclhelpers.c index 23c3ca5..9fa9266 100644 --- a/redist/dclhelpers.c +++ b/redist/dclhelpers.c @@ -3,59 +3,59 @@ #define DYNAMIC_INDEX #include #include "dclapack.h" +#include - -void dclPrint( const DCL_FLOAT * A, int n, int m ) +void dclPrint( const DCL_FLOAT * A, int Ac, int n, int m ) { PRINT( A, n, m ); } -void dclIdentity( DCL_FLOAT * A, int n ) +void dclIdentity( DCL_FLOAT * I, int Ic, int n ) { - IDENTITY( A, n ); + IDENTITY( I, n ); } -void dclTransp( DCL_FLOAT * R, const DCL_FLOAT * A, int n, int m ) +void dclTransp( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, int n, int m ) { TRANSP(R,A,n,m); } -void dclLU( DCL_FLOAT * L, DCL_FLOAT * U, const DCL_FLOAT * A, int * Piv, int n ) +void dclLU( DCL_FLOAT * L, int Lc, DCL_FLOAT * U, int Uc, const DCL_FLOAT * A, int Ac, int * Piv, int n ) { LU(L,U,A,Piv,n); } -void dclPivot( DCL_FLOAT * R, const DCL_FLOAT * A, int * Piv, int n, int m ) +void dclPivot( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, int * Piv, int n, int m ) { PIVOT(R,A,Piv,n,m); } -void dclLSub( DCL_FLOAT * X, const DCL_FLOAT * L, const DCL_FLOAT * B, int n, int m ) +void dclLSub( DCL_FLOAT * X, int Xc, const DCL_FLOAT * L, int Lc, const DCL_FLOAT * B, int Bc, int n, int m ) { L_SUB(X,L,B,n,m); } -void dclUSub( DCL_FLOAT * X, const DCL_FLOAT * U, const DCL_FLOAT * B, int n, int m ) +void dclUSub( DCL_FLOAT * X, int Xc, const DCL_FLOAT * U, int Uc, const DCL_FLOAT * B, int Bc, int n, int m ) { U_SUB(X,U,B,n,m); } -void dclInv( DCL_FLOAT * Ainv, const DCL_FLOAT * A, int n ) +void dclInv( DCL_FLOAT * Ainv, int Ainvc, const DCL_FLOAT * A, int Ac, int n ) { INV(Ainv,A,n,n); } -void dclMul( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, int n, int m, int p ) +void dclMul( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, const DCL_FLOAT * B, int Bc, int n, int m, int p ) { MUL(R,A,B,n,m,p); } -void dclMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, int n, int m, int p ) +void dclMulAdd( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, const DCL_FLOAT * B, int Bc, const DCL_FLOAT * C, int Cc, int n, int m, int p ) { MULADD(R,A,B,C,n,m,p); } -void dclGMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ) +void dclGMulAdd( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, const DCL_FLOAT * B, int Bc, const DCL_FLOAT * C, int Cc, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ) { GMULADD(R,A,B,C,alpha,beta,n,m,p); } @@ -77,12 +77,26 @@ void dcldgemm( int ldc //must be n ) { - DCL_FLOAT * ta; - DCL_FLOAT * tb; + const DCL_FLOAT * ta; + const DCL_FLOAT * tb; if( transA ) { ta = alloca( sizeof( DCL_FLOAT ) * n * m ); - + //TRANSP( ta, A, n, m ); + } + else + ta = A; + + if( transB ) + { + tb = alloca( sizeof( DCL_FLOAT ) * n * m ); + //TRANSP( tb, B, n, m ); } + else + tb = B; + + + //XXX Tricky: In here, A is mxn + } -- cgit v1.2.3 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/dclhelpers.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'redist/dclhelpers.c') 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); } -- cgit v1.2.3 From 9115ffd3138b460707dd1ba45dd7f6fccde87a46 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 03:28:23 -0400 Subject: Test DCL. --- redist/dclhelpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'redist/dclhelpers.c') diff --git a/redist/dclhelpers.c b/redist/dclhelpers.c index c3725f8..fb6aba6 100644 --- a/redist/dclhelpers.c +++ b/redist/dclhelpers.c @@ -5,9 +5,9 @@ #include "dclapack.h" #include -void dclPrint( const DCL_FLOAT * A, int Ac, int n, int m ) +void dclPrint( const DCL_FLOAT * PMATRIX, int PMATRIXc, int n, int m ) { - PRINT( A, n, m ); + PRINT( PMATRIX, n, m ); } void dclIdentity( DCL_FLOAT * I, int Ic, int n ) -- cgit v1.2.3 From 0b9e66ad2ff686a4dcf8a6838f33edb203a1bff5 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Sat, 17 Mar 2018 09:32:22 -0600 Subject: Fixed gemm --- redist/dclhelpers.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'redist/dclhelpers.c') diff --git a/redist/dclhelpers.c b/redist/dclhelpers.c index fb6aba6..3e51fd2 100644 --- a/redist/dclhelpers.c +++ b/redist/dclhelpers.c @@ -1,9 +1,10 @@ #include "dclhelpers.h" #define FLOAT DCL_FLOAT #define DYNAMIC_INDEX -#include #include "dclapack.h" #include +#include +#include void dclPrint( const DCL_FLOAT * PMATRIX, int PMATRIXc, int n, int m ) { @@ -77,7 +78,7 @@ void dcldgemm( int Cc //must be n ) { - const DCL_FLOAT * ta; + const DCL_FLOAT *ta; const DCL_FLOAT * tb; int tac = Ac; int tbc = Bc; @@ -102,7 +103,7 @@ void dcldgemm( } else tb = B; - - GMULADD(C,ta,tb,C,alpha,beta,n,m,k); + printf("%d %d %d\n", tac, tbc, Cc); + GMULADD(C, ta, tb, C, alpha, beta, m, n, k); } -- cgit v1.2.3 From 04bd16aeb391e67716344268cf0f43d1f31f180a Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 14:21:20 -0400 Subject: Update dcl and test. --- redist/dclhelpers.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'redist/dclhelpers.c') diff --git a/redist/dclhelpers.c b/redist/dclhelpers.c index 3e51fd2..5b956b0 100644 --- a/redist/dclhelpers.c +++ b/redist/dclhelpers.c @@ -5,15 +5,23 @@ #include #include #include +#include void dclPrint( const DCL_FLOAT * PMATRIX, int PMATRIXc, int n, int m ) { PRINT( PMATRIX, n, m ); } -void dclIdentity( DCL_FLOAT * I, int Ic, int n ) +void dclIdentity( DCL_FLOAT * I, int Ic, int m, int n ) { - IDENTITY( I, n ); + IDENTITY( I, m, n ); +} + + +/* Returns the zero matrix */ +void dclZero( DCL_FLOAT * Z, int Zc, int m, int n ) +{ + memset( Z, 0, m*n*sizeof(DCL_FLOAT) ); } void dclTransp( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, int n, int m ) @@ -103,7 +111,7 @@ void dcldgemm( } else tb = B; - printf("%d %d %d\n", tac, tbc, Cc); + GMULADD(C, ta, tb, C, alpha, beta, m, n, k); } -- cgit v1.2.3