COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
InducedSubgraphsTest.cpp
Go to the documentation of this file.
1#include <mpi.h>
2#include <iostream>
3#include <functional>
4#include <algorithm>
5#include <vector>
6#include <sstream>
7#include "CombBLAS/CombBLAS.h"
8
9int main(int argc, char *argv[])
10{
11 int nprocs, myrank;
12 MPI_Init(&argc, &argv);
13 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
14 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
15
16 if (argc < 3) {
17 if (!myrank)
18 std::cerr << "Usage: ./Subgraphs2ProcsTest <MatrixA> <VectorAssignments>" << std::endl;
19 MPI_Finalize();
20 return -1;
21 }
22 {
23 if (!myrank) std::cerr << "processor grid: (" << std::sqrt(nprocs) << " x " << std::sqrt(nprocs) << ")" << std::endl;
24
25 std::shared_ptr<combblas::CommGrid> fullWorld;
26 fullWorld.reset(new combblas::CommGrid(MPI_COMM_WORLD, 0, 0));
27
29 combblas::FullyDistVec<int, int> assignments(A.getcommgrid());
30
31 A.ParallelReadMM(std::string(argv[1]), true, combblas::maximum<double>());
32 assignments.ParallelRead(std::string(argv[2]), true, combblas::maximum<int>());
33
34 std::vector<int> local_idx_map;
35
36 combblas::SpCCols<int, double> locmat = A.InducedSubgraphs2Procs(assignments, local_idx_map);
37
38 for (auto colit = locmat.begcol(); colit != locmat.endcol(); ++colit) {
39 for (auto nzit = locmat.begnz(colit); nzit != locmat.endnz(colit); ++nzit) {
40 std::cout << myrank << ": " << local_idx_map[nzit.rowid()]+1 << "\t" << local_idx_map[colit.colid()]+1 << "\t" << nzit.value() << std::endl;
41 }
42 }
43 std::cout << std::endl;
44
45 }
46
47 MPI_Finalize();
48 return 0;
49}
int main()
Definition Driver.cpp:12
int nprocs
Definition comms.cpp:55
double A