SuperLU Distributed 8.2.1
Distributed memory sparse direct solver
zHWPM_CombBLAS.hpp
Go to the documentation of this file.
1
22#ifndef zHWPM_CombBLAS_h
23#define zHWPM_CombBLAS_h
24
25#include "CombBLAS/CombBLAS.h"
26#include "ApproxWeightPerfectMatching.h"
27#include "superlu_zdefs.h"
28
29
54void
56{
57 NRformat_loc *Astore;
58 int_t i, irow, fst_row, j, jcol, m, n, m_loc;
59 int_t lirow, ljcol;
60 int_t nnz_loc; /* number of local nonzeros */
61 doublecomplex *nzval_a;
62 int iam, p, procs;
63 int_t *perm=nullptr; // placeholder for load balancing permutation for CombBLAS
64 procs = grid->nprow * grid->npcol;
65
66 if(grid->nprow != grid->npcol)
67 {
68 printf("HWPM only supports square process grid. Retuning without a permutation.\n");
69 }
70 combblas::SpParMat < int_t, double, combblas::SpDCCols<int_t,double> > Adcsc(grid->comm);
71 std::vector< std::vector < std::tuple<int_t,int_t,double> > > data(procs);
72
73 /* ------------------------------------------------------------
74 INITIALIZATION.
75 ------------------------------------------------------------*/
76 iam = grid->iam;
77#if ( DEBUGlevel>=1 )
78 CHECK_MALLOC(iam, "Enter pdCSR_loc_to_2DBlock()");
79#endif
80 Astore = (NRformat_loc *) A->Store;
81 n = A->ncol;
82 m = A->nrow;
83 m_loc = Astore->m_loc;
84 fst_row = Astore->fst_row;
85
86 /* ------------------------------------------------------------
87 FIRST PASS OF A:
88 COUNT THE NUMBER OF NONZEROS TO BE SENT TO EACH PROCESS,
89 THEN ALLOCATE SPACE.
90 Re-distribute A from distributed CSR storage to 2D block storage
91 conforming CombBLAS API.
92 ------------------------------------------------------------*/
93 nzval_a = (doublecomplex *) Astore->nzval;
94 nnz_loc = Astore->nnz_loc;
95 double *nzval_abs = doubleMalloc_dist(nnz_loc);
96 for (i = 0; i < nnz_loc; ++i) nzval_abs[i] = slud_z_abs1(&nzval_a[i]);
97
98 nnz_loc = 0;
99 for (i = 0; i < m_loc; ++i) {
100 for (j = Astore->rowptr[i]; j < Astore->rowptr[i+1]; ++j) {
101 if(perm != NULL)
102 {
103 irow = perm[i+fst_row]; /* Row number in P*A*P^T */
104 jcol = perm[Astore->colind[j]]; /* Column number in P*A*P^T */
105 }
106 else
107 {
108 irow = i+fst_row;
109 jcol = Astore->colind[j];
110 }
111 p = Adcsc.Owner(m, n , irow, jcol, lirow, ljcol);
112 ++nnz_loc;
113 data[p].push_back(std::make_tuple(lirow,ljcol,nzval_abs[j]));
114 }
115 }
116
117 Adcsc.SparseCommon(data, nnz_loc, m, n, std::plus<double>());
118 combblas::FullyDistVec<int_t, int_t> mateRow2Col ( Adcsc.getcommgrid(), m, (int_t) -1);
119 combblas::FullyDistVec<int_t, int_t> mateCol2Row ( Adcsc.getcommgrid(), n, (int_t) -1);
120 combblas::AWPM(Adcsc, mateRow2Col, mateCol2Row,true);
121
122 // now gather the matching vector
123 MPI_Comm World = mateRow2Col.getcommgrid()->GetWorld();
124 int * rdispls = new int[procs];
125 int sendcnt = mateRow2Col.LocArrSize();
126 int * recvcnt = new int[procs];
127 MPI_Allgather(&sendcnt, 1, MPI_INT, recvcnt, 1, MPI_INT, World);
128 rdispls[0] = 0;
129 for(int i=0; i<procs-1; ++i)
130 {
131 rdispls[i+1] = rdispls[i] + recvcnt[i];
132 }
133 int_t *senddata = (int_t *)mateRow2Col.GetLocArr();
134
135 MPI_Allgatherv(senddata, sendcnt, combblas::MPIType<int_t>(), ScalePermstruct->perm_r, recvcnt, rdispls, combblas::MPIType<int_t>(), World);
136
137 delete[] rdispls;
138 delete[] recvcnt;
139 SUPERLU_FREE(nzval_abs);
140
141#if ( DEBUGlevel>=1 )
142 CHECK_MALLOC(iam, "Exit zHWPM_CombBLAS()");
143#endif
144}
145
146#endif /* zHWPM_CombBLAS_h */
double slud_z_abs1(doublecomplex *)
Definition: dcomplex_dist.c:82
double * doubleMalloc_dist(int_t n)
Definition: dmemory_dist.c:155
int j
Definition: dutil_dist.c:248
int i
Definition: dutil_dist.c:248
int int_t
Definition: superlu_defs.h:114
#define CHECK_MALLOC(pnum, where)
Definition: util_dist.h:50
#define SUPERLU_FREE(addr)
Definition: util_dist.h:48
Definition: supermatrix.h:176
void * nzval
Definition: supermatrix.h:180
int_t * rowptr
Definition: supermatrix.h:181
int_t nnz_loc
Definition: supermatrix.h:177
int_t * colind
Definition: supermatrix.h:183
int_t m_loc
Definition: supermatrix.h:178
int_t fst_row
Definition: supermatrix.h:179
Definition: supermatrix.h:54
void * Store
Definition: supermatrix.h:62
int_t nrow
Definition: supermatrix.h:60
int_t ncol
Definition: supermatrix.h:61
Definition: dcomplex.h:30
Definition: superlu_defs.h:388
int_t nprow
Definition: superlu_defs.h:393
int_t npcol
Definition: superlu_defs.h:394
MPI_Comm comm
Definition: superlu_defs.h:389
int iam
Definition: superlu_defs.h:392
Definition: superlu_zdefs.h:76
int_t * perm_r
Definition: superlu_zdefs.h:80
Distributed SuperLU data types and function prototypes.
void zGetHWPM(SuperMatrix *A, gridinfo_t *grid, zScalePermstruct_t *ScalePermstruct)
Definition: zHWPM_CombBLAS.hpp:55