8#include "CombBLAS/CombBLAS.h"
9#include "CombBLAS/CommGrid3D.h"
10#include "CombBLAS/SpParMat3D.h"
11#include "CombBLAS/ParFriends.h"
41int main(
int argc,
char* argv[])
44 MPI_Init(&argc, &argv);
45 MPI_Comm_size(MPI_COMM_WORLD,&
nprocs);
46 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
51 cout <<
"Usage: ./<Binary> <MatrixA> " << endl;
57 string Aname(argv[1]);
59 shared_ptr<CommGrid> fullWorld;
60 fullWorld.reset(
new CommGrid(MPI_COMM_WORLD, 0, 0) );
83 double Abcasttime = 0;
84 double Abcasttime_prev;
85 double Bbcasttime = 0;
86 double Bbcasttime_prev;
90 std::shared_ptr<CommGrid> GridC =
ProductGrid((
A.getcommgrid()).get(), (
B.getcommgrid()).get(), stages, dummy, dummy);
97 for(
int phases = 1; phases <= 256; phases = phases * 2){
98 if(myrank == 0) fprintf(stderr,
"Running with phase: %d\n", phases);
99 for(
int it = 0; it < 3; it++){
103 std::vector< DER > PiecesOfB;
104 DER CopyB = *(
B.seqptr());
106 CopyB.ColSplit(phases, PiecesOfB);
107 MPI_Barrier(GridC->GetWorld());
109 IT ** ARecvSizes = SpHelper::allocate2D<IT>(DER::esscount, stages);
110 IT ** BRecvSizes = SpHelper::allocate2D<IT>(DER::esscount, stages);
112 SpParHelper::GetSetSizes( *(
A.seqptr()), ARecvSizes, (
A.getcommgrid())->GetRowWorld());
118 int Aself = (
A.getcommgrid())->GetRankInProcRow();
119 int Bself = (
B.getcommgrid())->GetRankInProcCol();
124 for(
int p = 0; p < phases; ++p)
126 SpParHelper::GetSetSizes( PiecesOfB[p], BRecvSizes, (
B.getcommgrid())->GetColWorld());
127 for(
int i = 0; i < stages; ++i)
136 if(i == Aself) ARecv =
A.seqptr();
138 ess.resize(DER::esscount);
139 for(
int j=0; j< DER::esscount; ++j)
140 ess[j] = ARecvSizes[j][i];
143 MPI_Barrier(
A.getcommgrid()->GetWorld());
146 MPI_Barrier(
A.getcommgrid()->GetWorld());
148 Abcasttime += (t1-t0);
152 if(i == Bself) BRecv = &(PiecesOfB[p]);
154 ess.resize(DER::esscount);
155 for(
int j=0; j< DER::esscount; ++j)
156 ess[j] = BRecvSizes[j][i];
159 MPI_Barrier(
A.getcommgrid()->GetWorld());
161 SpParHelper::BCastMatrix(GridC->GetColWorld(), *BRecv, ess, i);
162 MPI_Barrier(
A.getcommgrid()->GetWorld());
164 Bbcasttime += (t1-t0);
170 if(BRecv != NULL)
delete BRecv;
181 fprintf(stderr,
"Iteration : %d - Abcasttime: %lf\n", it, Abcasttime);
182 fprintf(stderr,
"Iteration : %d - Bbcasttime: %lf\n", it, Bbcasttime);
185 if(myrank == 0) fprintf(stderr,
"\n\n++++++++++++++++++++++++++++++++++++++++++++\n\n\n\n");
int main(int argc, char *argv[])
double cblas_allgathertime
double cblas_alltoalltime
SpParMat< int64_t, NT, DCCols > MPI_DCCols
SpDCCols< int64_t, NT > DCCols
void iota(IT globalsize, NT first)
void ParallelReadMM(const std::string &filename, bool onebased, _BinaryOperation BinOp)
std::shared_ptr< CommGrid > getcommgrid() const
shared_ptr< CommGrid > ProductGrid(CommGrid *gridA, CommGrid *gridB, int &innerdim, int &Aoffset, int &Boffset)
Compute the maximum of two values.
void deallocate2D(T **array, I m)