33 int main(
int argc,
char *argv[])
39 MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
40 if (provided < MPI_THREAD_SERIALIZED)
42 printf(
"ERROR: The MPI library does not have MPI_THREAD_SERIALIZED support\n");
43 MPI_Abort(MPI_COMM_WORLD, 1);
48 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
49 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
56 printf(
"Usage (input): ./mpipspgemm <GridRows> <GridCols> <Layers> <matA> <matB> <matC> <algo>\n");
57 printf(
"Example: ./mpipspgemm 4 4 2 matA.mtx matB.mtx matB.mtx threaded\n");
58 printf(
"algo: outer | column | threaded \n");
63 unsigned GRROWS = (unsigned) atoi(argv[1]);
64 unsigned GRCOLS = (unsigned) atoi(argv[2]);
65 unsigned C_FACTOR = (unsigned) atoi(argv[3]);
66 CCGrid CMG(C_FACTOR, GRCOLS);
70 SpParHelper::Print(
"This version of the Combinatorial BLAS only works on a square logical processor grid\n");
71 MPI_Barrier(MPI_COMM_WORLD);
72 MPI_Abort(MPI_COMM_WORLD, 1);
75 int layer_length = GRROWS*GRCOLS;
76 if(layer_length * C_FACTOR != nprocs)
78 SpParHelper::Print(
"The product of <GridRows> <GridCols> <Replicas> does not match the number of processes\n");
79 MPI_Barrier(MPI_COMM_WORLD);
80 MPI_Abort(MPI_COMM_WORLD, 1);
90 string fileA(argv[4]);
91 string fileB(argv[5]);
92 string fileC(argv[6]);
95 shared_ptr<CommGrid> layerGrid;
99 double t01 = MPI_Wtime();
109 if(myrank == 0) cout <<
"Matrices read and replicated along layers : time " << MPI_Wtime() - t01 << endl;
111 type = string(argv[7]);
113 if(type ==
string(
"outer"))
115 for(
int k=0; k<
ITERS; k++)
118 splitC =
multiply(splitA, splitB, CMG,
true,
false);
119 if (controlC == *splitC)
120 SpParHelper::Print(
"Outer product multiplication working correctly\n");
122 SpParHelper::Print(
"ERROR in Outer product multiplication, go fix it!\n");
127 else if(type ==
string(
"column"))
130 for(
int k=0; k<
ITERS; k++)
132 splitC =
multiply(splitA, splitB, CMG,
false,
false);
133 if (controlC == *splitC)
134 SpParHelper::Print(
"Col-heap multiplication working correctly\n");
136 SpParHelper::Print(
"ERROR in Col-heap multiplication, go fix it!\n");
144 for(
int k=0; k<
ITERS; k++)
146 splitC =
multiply(splitA, splitB, CMG,
false,
true);
147 if (controlC == *splitC)
148 SpParHelper::Print(
"Col-heap-threaded multiplication working correctly\n");
150 SpParHelper::Print(
"ERROR in Col-heap-threaded multiplication, go fix it!\n");
void SplitMat(CCGrid &CMG, SpDCCols< IT, NT > *localmat, SpDCCols< IT, NT > &splitmat, bool rowsplit=false)
int main(int argc, char *argv[])
SpDCCols< IT, NT > * multiply(SpDCCols< IT, NT > &splitA, SpDCCols< IT, NT > &splitB, CCGrid &CMG, bool isBT, bool threaded)
void Transpose()
Mutator version, replaces the calling object.