Loading src/estimate_work.c +38 −2 Original line number Diff line number Diff line #include "test_vbatch.h" void get_total_memory( int npatches, void get_total_memory( int noperator, int npatches, FpType **Amatrix_, int *ld_Amatrix_, FpType **Bmatrix_, int *ld_Bmatrix_, int left_patch_size_[], int right_patch_size_[], int nC_[], size_t *ptotal_memory_in_nbytes ) { double total_gflops = 0; Loading @@ -12,6 +14,35 @@ void get_total_memory( int npatches, double gmemBX = 0; double gmemXY = 0; size_t nbytes = 0; nbytes = sizeof(IntegerType)*npatches*npatches; IntegerType *nC_ = (IntegerType *) malloc(nbytes); assert( nC_ != 0 ); nbytes = sizeof(IntegerType)*npatches*npatches*noperator; IntegerType *gnnz_A_ = (IntegerType *) malloc( nbytes ); assert( gnnz_A_ != 0 ); nbytes = sizeof(IntegerType)*npatches*npatches*noperator; IntegerType *gnnz_B_ = (IntegerType *) malloc( nbytes ); assert( gnnz_B_ != 0 ); setup_nC( noperator, npatches, Amatrix_, ld_Amatrix_, Bmatrix_, ld_Bmatrix_, left_patch_size_, right_patch_size_, nC_, gnnz_A_, gnnz_B_ ); estimate_work( npatches, left_patch_size_, right_patch_size_, Loading @@ -25,6 +56,11 @@ void get_total_memory( int npatches, size_t total_memory_in_bytes = sizeof(FpType) * (gmemA + gmemB + gmemBX + gmemXY); free( nC_ ); free( gnnz_A_ ); free( gnnz_B_ ); *ptotal_memory_in_nbytes = total_memory_in_bytes; } Loading src/estimate_work.h +4 −2 Original line number Diff line number Diff line Loading @@ -17,10 +17,12 @@ void estimate_work( int npatches, double *pgmemXY ); extern void get_total_memory( int npatches, void get_total_memory( int noperator, int npatches, FpType **Amatrix_, int *ld_Amatrix_, FpType **Bmatrix_, int *ld_Bmatrix_, int left_patch_size_[], int right_patch_size_[], int nC_[], size_t *ptotal_memory_in_nbytes ); Loading src/setup_nC.c +2 −2 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ #define right_patch_size(ipatch) right_patch_size_[ (ipatch)-1] void setup_nC( int npatches, int noperator, void setup_nC( int noperator, int npatches, /* * --------- Loading src/setup_nC.h +2 −2 Original line number Diff line number Diff line Loading @@ -9,8 +9,8 @@ extern "C" { #endif extern void setup_nC( int npatches, int noperator, void setup_nC( int noperator, int npatches, /* * --------- * intent(in) Loading src/setup_sparse_batch.c +22 −87 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ #include "dmrg_vbatch.h" #include "dmrg_lapack.h" #include "setup_sparse_batch.h" #include "setup_nC.h" #ifndef MIN #define MIN(x,y) (((x) < (y))?(x):(y)) Loading Loading @@ -56,8 +57,10 @@ void setup_sparse_batch( ) #define left_patch_size(ipatch) left_patch_size_[ (ipatch)-1] #define right_patch_size(ipatch) right_patch_size_[ (ipatch)-1] #define left_patch_start(ipatch) left_patch_start_[ (ipatch)-1] #define right_patch_start(ipatch) right_patch_start_[ (ipatch)-1] #define xy_patch_start(ipatch) xy_patch_start_[ (ipatch)-1] #define hAbatch(i,j) hAbatch_[indx2f(i,j,ld_Abatch)] Loading Loading @@ -150,96 +153,28 @@ void setup_sparse_batch( in block (ipatch,jpatch) -------------------------------- */ #define nC(i,j) nC_[ indx2f(i,j,npatches)] IntegerType *nC_ = (IntegerType *) malloc(sizeof(IntegerType)*npatches*npatches); assert( nC_ != NULL ); #define nC(i,j) nC_[ indx2f(i,j,npatches)] { int ipatch = 0; int jpatch = 0; int ioperator = 0; for(jpatch=1; jpatch <= npatches; jpatch++) { for(ipatch=1; ipatch <= npatches; ipatch++) { nC(ipatch,jpatch) = 0; }; }; for(ioperator=1; ioperator <= noperator; ioperator++) { for(jpatch=1; jpatch <= npatches; jpatch++) { for(ipatch=1; ipatch <= npatches; ipatch++) { FpType *Amat_ = Amatrix(ipatch,jpatch,ioperator); FpType *Bmat_ = Bmatrix(ipatch,jpatch,ioperator); int ld_Amat = ld_Amatrix(ipatch,jpatch,ioperator); int ld_Bmat = ld_Bmatrix(ipatch,jpatch,ioperator); #define Amat(i,j) Amat_[indx2f(i,j,ld_Amat)] #define Bmat(i,j) Bmat_[indx2f(i,j,ld_Bmat)] int nrowA = left_patch_size(ipatch); int ncolA = left_patch_size(jpatch); int nrowB = right_patch_size(ipatch); int ncolB = right_patch_size(jpatch); int nnz_Amat = 0; int nnz_Bmat = 0; setup_nC( noperator, npatches, Amatrix_, ld_Amatrix_, Bmatrix_, ld_Bmatrix_, left_patch_size_, right_patch_size_, /* -------------------------------------------------------------- Note: treat a NULL pointer as pointer to a matrix of all zeros -------------------------------------------------------------- * ------------ * intent(inout) * ------------ */ if (Amat_ == NULL) { nnz_Amat = 0; } else { int ia = 0; int ja = 0; for(ja=1; ja <= ncolA; ja++) { for(ia=1; ia <= nrowA; ia++) { nnz_Amat += ((Amat(ia,ja) == 0)? 0 : 1); }; }; }; if (Bmat_ == NULL) { nnz_Bmat = 0; } else { int ib = 0; int jb = 0; for(jb=1; jb <= ncolB; jb++) { for(ib=1; ib <= nrowB; ib++) { nnz_Bmat += ((Bmat(ib,jb) == 0) ? 0 : 1); }; }; }; gnnz_A(ipatch,jpatch,ioperator) = nnz_Amat; gnnz_B(ipatch,jpatch,ioperator) = nnz_Bmat; &(nC(1,1)), &(gnnz_A(1,1,1)), &(gnnz_B(1,1,1)) ); int is_zero_Amat = (nnz_Amat == 0); int is_zero_Bmat = (nnz_Bmat == 0); if (is_zero_Amat || is_zero_Bmat) { /* --------------------------------------------------------- ignore this operator since kron(Amat,Bmat) is zero matrix --------------------------------------------------------- */ } else { /* ------------------------------------------ pair of non-zero Amat(k), Bmat(k) matrices ------------------------------------------ */ nC(ipatch,jpatch) = nC(ipatch,jpatch) + 1; }; }; /* end for jpatch */ }; /* end for ipatch */ }; /* end for ioperator */ }; /* -------------------------------------------------- Loading Loading
src/estimate_work.c +38 −2 Original line number Diff line number Diff line #include "test_vbatch.h" void get_total_memory( int npatches, void get_total_memory( int noperator, int npatches, FpType **Amatrix_, int *ld_Amatrix_, FpType **Bmatrix_, int *ld_Bmatrix_, int left_patch_size_[], int right_patch_size_[], int nC_[], size_t *ptotal_memory_in_nbytes ) { double total_gflops = 0; Loading @@ -12,6 +14,35 @@ void get_total_memory( int npatches, double gmemBX = 0; double gmemXY = 0; size_t nbytes = 0; nbytes = sizeof(IntegerType)*npatches*npatches; IntegerType *nC_ = (IntegerType *) malloc(nbytes); assert( nC_ != 0 ); nbytes = sizeof(IntegerType)*npatches*npatches*noperator; IntegerType *gnnz_A_ = (IntegerType *) malloc( nbytes ); assert( gnnz_A_ != 0 ); nbytes = sizeof(IntegerType)*npatches*npatches*noperator; IntegerType *gnnz_B_ = (IntegerType *) malloc( nbytes ); assert( gnnz_B_ != 0 ); setup_nC( noperator, npatches, Amatrix_, ld_Amatrix_, Bmatrix_, ld_Bmatrix_, left_patch_size_, right_patch_size_, nC_, gnnz_A_, gnnz_B_ ); estimate_work( npatches, left_patch_size_, right_patch_size_, Loading @@ -25,6 +56,11 @@ void get_total_memory( int npatches, size_t total_memory_in_bytes = sizeof(FpType) * (gmemA + gmemB + gmemBX + gmemXY); free( nC_ ); free( gnnz_A_ ); free( gnnz_B_ ); *ptotal_memory_in_nbytes = total_memory_in_bytes; } Loading
src/estimate_work.h +4 −2 Original line number Diff line number Diff line Loading @@ -17,10 +17,12 @@ void estimate_work( int npatches, double *pgmemXY ); extern void get_total_memory( int npatches, void get_total_memory( int noperator, int npatches, FpType **Amatrix_, int *ld_Amatrix_, FpType **Bmatrix_, int *ld_Bmatrix_, int left_patch_size_[], int right_patch_size_[], int nC_[], size_t *ptotal_memory_in_nbytes ); Loading
src/setup_nC.c +2 −2 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ #define right_patch_size(ipatch) right_patch_size_[ (ipatch)-1] void setup_nC( int npatches, int noperator, void setup_nC( int noperator, int npatches, /* * --------- Loading
src/setup_nC.h +2 −2 Original line number Diff line number Diff line Loading @@ -9,8 +9,8 @@ extern "C" { #endif extern void setup_nC( int npatches, int noperator, void setup_nC( int noperator, int npatches, /* * --------- * intent(in) Loading
src/setup_sparse_batch.c +22 −87 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ #include "dmrg_vbatch.h" #include "dmrg_lapack.h" #include "setup_sparse_batch.h" #include "setup_nC.h" #ifndef MIN #define MIN(x,y) (((x) < (y))?(x):(y)) Loading Loading @@ -56,8 +57,10 @@ void setup_sparse_batch( ) #define left_patch_size(ipatch) left_patch_size_[ (ipatch)-1] #define right_patch_size(ipatch) right_patch_size_[ (ipatch)-1] #define left_patch_start(ipatch) left_patch_start_[ (ipatch)-1] #define right_patch_start(ipatch) right_patch_start_[ (ipatch)-1] #define xy_patch_start(ipatch) xy_patch_start_[ (ipatch)-1] #define hAbatch(i,j) hAbatch_[indx2f(i,j,ld_Abatch)] Loading Loading @@ -150,96 +153,28 @@ void setup_sparse_batch( in block (ipatch,jpatch) -------------------------------- */ #define nC(i,j) nC_[ indx2f(i,j,npatches)] IntegerType *nC_ = (IntegerType *) malloc(sizeof(IntegerType)*npatches*npatches); assert( nC_ != NULL ); #define nC(i,j) nC_[ indx2f(i,j,npatches)] { int ipatch = 0; int jpatch = 0; int ioperator = 0; for(jpatch=1; jpatch <= npatches; jpatch++) { for(ipatch=1; ipatch <= npatches; ipatch++) { nC(ipatch,jpatch) = 0; }; }; for(ioperator=1; ioperator <= noperator; ioperator++) { for(jpatch=1; jpatch <= npatches; jpatch++) { for(ipatch=1; ipatch <= npatches; ipatch++) { FpType *Amat_ = Amatrix(ipatch,jpatch,ioperator); FpType *Bmat_ = Bmatrix(ipatch,jpatch,ioperator); int ld_Amat = ld_Amatrix(ipatch,jpatch,ioperator); int ld_Bmat = ld_Bmatrix(ipatch,jpatch,ioperator); #define Amat(i,j) Amat_[indx2f(i,j,ld_Amat)] #define Bmat(i,j) Bmat_[indx2f(i,j,ld_Bmat)] int nrowA = left_patch_size(ipatch); int ncolA = left_patch_size(jpatch); int nrowB = right_patch_size(ipatch); int ncolB = right_patch_size(jpatch); int nnz_Amat = 0; int nnz_Bmat = 0; setup_nC( noperator, npatches, Amatrix_, ld_Amatrix_, Bmatrix_, ld_Bmatrix_, left_patch_size_, right_patch_size_, /* -------------------------------------------------------------- Note: treat a NULL pointer as pointer to a matrix of all zeros -------------------------------------------------------------- * ------------ * intent(inout) * ------------ */ if (Amat_ == NULL) { nnz_Amat = 0; } else { int ia = 0; int ja = 0; for(ja=1; ja <= ncolA; ja++) { for(ia=1; ia <= nrowA; ia++) { nnz_Amat += ((Amat(ia,ja) == 0)? 0 : 1); }; }; }; if (Bmat_ == NULL) { nnz_Bmat = 0; } else { int ib = 0; int jb = 0; for(jb=1; jb <= ncolB; jb++) { for(ib=1; ib <= nrowB; ib++) { nnz_Bmat += ((Bmat(ib,jb) == 0) ? 0 : 1); }; }; }; gnnz_A(ipatch,jpatch,ioperator) = nnz_Amat; gnnz_B(ipatch,jpatch,ioperator) = nnz_Bmat; &(nC(1,1)), &(gnnz_A(1,1,1)), &(gnnz_B(1,1,1)) ); int is_zero_Amat = (nnz_Amat == 0); int is_zero_Bmat = (nnz_Bmat == 0); if (is_zero_Amat || is_zero_Bmat) { /* --------------------------------------------------------- ignore this operator since kron(Amat,Bmat) is zero matrix --------------------------------------------------------- */ } else { /* ------------------------------------------ pair of non-zero Amat(k), Bmat(k) matrices ------------------------------------------ */ nC(ipatch,jpatch) = nC(ipatch,jpatch) + 1; }; }; /* end for jpatch */ }; /* end for ipatch */ }; /* end for ioperator */ }; /* -------------------------------------------------- Loading