16 MPI_Comm_size(MPI_COMM_WORLD,&
nprocs);
17 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
22 ifstream inputa(
"matrixA.txt");
23 ifstream inputb(
"matrixB.txt");
24 if(!(inputa.is_open() && inputb.is_open()))
26 cerr <<
"One of the input files doesn't exist\n";
42 C.SpGEMM <PT> (
A,
B,
false,
false);
54 vector< SpTuples<int,double> *> tomerge;
55 tomerge.push_back(C_tuples);
56 tomerge.push_back(C_tt);
69 vector<string> prefixes;
72 prefixes.push_back(
"largeseq");
75 prefixes.push_back(
"massiveseq");
78 for(
int i=0; i< prefixes.size(); i++)
80 ifstream input1, input2;
83 string inputname1 = prefixes[i] + string(
"/input1_0");
84 string inputname2 = prefixes[i] + string(
"/input2_0");
85 input1.open(inputname1.c_str());
86 input2.open(inputname2.c_str());
87 if(!(input1.is_open() && input2.is_open()))
89 cerr <<
"One of the input files doesn't exist\n";
97 bigA.
Split(bigA1, bigA2);
101 bigA.
Merge(bigA1, bigA2);
113 string outputnameC = prefixes[i] + string(
"/colbycol");
114 ofstream outputC(outputnameC.c_str());
118 struct timeval tempo1, tempo2;
121 long elapsed_seconds;
122 long elapsed_useconds;
124 gettimeofday(&tempo1, NULL);
126 gettimeofday(&tempo2, NULL);
127 elapsed_seconds = tempo2.tv_sec - tempo1.tv_sec;
128 elapsed_useconds = tempo2.tv_usec - tempo1.tv_usec;
130 elapsed_time = (elapsed_seconds + ((double) elapsed_useconds)/1000000.0);
131 printf(
"ColByCol time = %.5f seconds\n", elapsed_time);
141 string outputnameCT = prefixes[i] + string(
"/outerproduct");
142 ofstream outputCT(outputnameCT.c_str());
143 outputCT << (*bigC_t);
147 gettimeofday(&tempo1, NULL);
149 gettimeofday(&tempo2, NULL);
150 elapsed_seconds = tempo2.tv_sec - tempo1.tv_sec;
151 elapsed_useconds = tempo2.tv_usec - tempo1.tv_usec;
153 elapsed_time = (elapsed_seconds + ((double) elapsed_useconds)/1000000.0);
154 printf(
"OuterProduct time = %.5f seconds\n", elapsed_time);
156 input1.seekg (0, ios::beg);
157 input2.seekg (0, ios::beg);
159 vector< SpTuples<int,double> *> tomerge;
160 tomerge.push_back(bigC);
161 tomerge.push_back(bigC_t);
169 string outputnametwice = prefixes[i] + string(
"/twice");
170 ofstream outputtw(outputnametwice.c_str());
174 cerr <<
"Begin Parallel" << endl;
177 typedef SpParMat <int, double, SpDCCols<int,double> > PARSPMAT;
180 cerr <<
"A and B constructed"<< endl;
182 A_par.ReadDistribute(input1, 0);
185 int parnnzA = A_par.getnnz();
186 int parmA = A_par.getnrow();
187 int parnA = A_par.getncol();
189 cout <<
"A_par has " << parnnzA <<
" nonzeros and " << parmA <<
"-by-" << parnA <<
" dimensions" << endl;
191 B_par.ReadDistribute(input2, 0);
193 int parnnzB = B_par.getnnz();
194 int parmB = B_par.getnrow();
195 int parnB = B_par.getncol();
198 cout <<
"B_par has " << parnnzB <<
" nonzeros and " << parmB <<
"-by-" << parnB <<
" dimensions" << endl;
203 int parnnzC = C_par.getnnz();
204 int parmC = C_par.getnrow();
205 int parnC = C_par.getncol();
209 cout <<
"C_par has " << parnnzC <<
" nonzeros and " << parmC <<
"-by-" << parnC <<
" dimensions" << endl;
SpTuples< IU, NUO > * MultiplyReturnTuples(const SpMat< IU, NU1, DER1 > &A, const SpMat< IU, NU2, DER2 > &B, bool isAT, bool isBT, bool clearA=false, bool clearB=false)
SpParMat< IU, NUO, UDERO > Mult_AnXBn_Synch(SpParMat< IU, NU1, UDERA > &A, SpParMat< IU, NU2, UDERB > &B, bool clearA=false, bool clearB=false)
SpTuples< IU, NU > MergeAll(const std::vector< SpTuples< IU, NU > * > &ArrSpTups, IU mstar=0, IU nstar=0, bool delarrs=false)