52 int main(
int argc,
char* argv[])
55 MPI_Init(&argc, &argv);
56 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
57 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
63 cout <<
"Usage: ./ReduceTest <MatrixA> <SumColumns> <SumRows>" << endl;
64 cout <<
"<Matrix>,<SumColumns>,<SumRows> are absolute addresses, and files should be in triples format" << endl;
70 string Aname(argv[1]);
71 string Bname(argv[2]);
72 string Cname(argv[3]);
74 ifstream inputB(Bname.c_str());
75 ifstream inputC(Cname.c_str());
76 MPI_Barrier(MPI_COMM_WORLD);
78 shared_ptr<CommGrid> fullWorld;
79 fullWorld.reset(
new CommGrid(MPI_COMM_WORLD, 0, 0) );
86 colsums.ReadDistribute(inputB, 0);
87 rowsums.ReadDistribute(inputC, 0);
91 A.
Reduce(rowsums_control,
Row, std::plus<double>() , 0.0);
92 A.
Reduce(colsums_control,
Column, std::plus<double>() , 0.0);
94 if (rowsums_control == rowsums && colsums_control == colsums)
96 SpParHelper::Print(
"Reduction via summation working correctly\n");
100 SpParHelper::Print(
"ERROR in Reduce via summation, go fix it!\n");
FullyDistVec< IT, NT > Reduce(Dim dim, _BinaryOperation __binary_op, NT id, _UnaryOperation __unary_op) const
std::shared_ptr< CommGrid > getcommgrid() const
int main(int argc, char *argv[])
void ReadDistribute(const std::string &filename, int master, bool nonum, HANDLER handler, bool transpose=false, bool pario=false)
SpDCCols< int, NT > DCCols
SpParMat< int, NT, DCCols > MPI_DCCols