25 idx_t *padjncy, *padjwgt, *padjcut;
47 kpwgts =
ismalloc(ncon*nparts, 0,
"ComputePartitionInfo: kpwgts");
49 for (i=0; i<nvtxs; i++) {
50 for (j=0; j<
ncon; j++)
51 kpwgts[where[i]*ncon+j] += vwgt[i*ncon+j];
56 1.0*nparts*kpwgts[
iargmax(nparts, kpwgts)]/(1.0*
isum(nparts, kpwgts, 1)),
57 1.0*nparts*vwgt[
iargmax(nvtxs, vwgt)]/(1.0*
isum(nparts, kpwgts, 1)));
61 for (j=0; j<
ncon; j++)
63 1.0*nparts*kpwgts[ncon*
iargmax_strd(nparts, kpwgts+j, ncon)+j]/(1.0*
isum(nparts, kpwgts+j, ncon)),
64 1.0*nparts*vwgt[ncon*
iargmax_strd(nvtxs, vwgt+j, ncon)+j]/(1.0*
isum(nparts, kpwgts+j, ncon)));
70 padjncy =
ismalloc(nparts*nparts, 0,
"ComputePartitionInfo: padjncy");
71 padjwgt =
ismalloc(nparts*nparts, 0,
"ComputePartitionInfo: padjwgt");
72 padjcut =
ismalloc(nparts*nparts, 0,
"ComputePartitionInfo: padjwgt");
74 iset(nparts, 0, kpwgts);
75 for (i=0; i<nvtxs; i++) {
76 for (j=xadj[i]; j<xadj[i+1]; j++) {
77 if (where[i] != where[adjncy[j]]) {
78 padjncy[where[
i]*nparts+where[adjncy[
j]]] = 1;
79 padjcut[where[
i]*nparts+where[adjncy[
j]]] += adjwgt[
j];
80 if (kpwgts[where[adjncy[j]]] == 0) {
81 padjwgt[where[
i]*nparts+where[adjncy[
j]]] += vsize[
i];
82 kpwgts[where[adjncy[
j]]] = 1;
86 for (j=xadj[i]; j<xadj[i+1]; j++)
87 kpwgts[where[adjncy[j]]] = 0;
91 kpwgts[i] =
isum(nparts, padjncy+i*nparts, 1);
92 printf(
"Min/Max/Avg/Bal # of adjacent subdomains: %5"PRIDX
" %5"PRIDX
" %5"PRIDX
" %7.3"PRREAL"\n",
93 kpwgts[
iargmin(nparts, kpwgts)], kpwgts[
iargmax(nparts, kpwgts)],
isum(nparts, kpwgts, 1)/nparts,
94 1.0*nparts*kpwgts[
iargmax(nparts, kpwgts)]/(1.0*
isum(nparts, kpwgts, 1)));
97 kpwgts[i] =
isum(nparts, padjcut+i*nparts, 1);
98 printf(
"Min/Max/Avg/Bal # of adjacent subdomain cuts: %5"PRIDX
" %5"PRIDX
" %5"PRIDX
" %7.3"PRREAL
"\n",
99 kpwgts[
iargmin(nparts, kpwgts)], kpwgts[
iargmax(nparts, kpwgts)],
isum(nparts, kpwgts, 1)/nparts,
100 1.0*nparts*kpwgts[
iargmax(nparts, kpwgts)]/(1.0*
isum(nparts, kpwgts, 1)));
103 kpwgts[i] =
isum(nparts, padjwgt+i*nparts, 1);
104 printf(
"Min/Max/Avg/Bal/Frac # of interface nodes: %5"PRIDX
" %5"PRIDX
" %5"PRIDX
" %7.3"PRREAL
" %7.3"PRREAL
"\n",
105 kpwgts[
iargmin(nparts, kpwgts)], kpwgts[
iargmax(nparts, kpwgts)],
isum(nparts, kpwgts, 1)/nparts,
106 1.0*nparts*kpwgts[
iargmax(nparts, kpwgts)]/(1.0*
isum(nparts, kpwgts, 1)), 1.0*
isum(nparts, kpwgts, 1)/(1.0*nvtxs));
109 if (mustfree == 1 || mustfree == 3) {
113 if (mustfree == 2 || mustfree == 3) {
118 gk_free((
void **)&kpwgts, &padjncy, &padjwgt, &padjcut,
LTERM);
131 nvtxs = graph->
nvtxs;
135 kpwgts =
ismalloc(nparts, 0,
"ComputePartitionInfo: kpwgts");
138 for (i=0; i<nvtxs; i++)
140 ubvec[0] = 1.0*nparts*kpwgts[
iargmax(nparts, kpwgts)]/(1.0*nvtxs);
143 for (j=0; j<
ncon; j++) {
144 iset(nparts, 0, kpwgts);
145 for (i=0; i<graph->
nvtxs; i++)
146 kpwgts[where[i]] += vwgt[i*ncon+j];
148 ubvec[
j] = 1.0*nparts*kpwgts[
iargmax(nparts, kpwgts)]/(1.0*
isum(nparts, kpwgts, 1));
166 kpwgts =
ismalloc(nparts, 0,
"ComputeElementBalance: kpwgts");
171 balance = 1.0*nparts*kpwgts[
iargmax(nparts, kpwgts)]/(1.0*
isum(nparts, kpwgts, 1));
idx_t idx_t idx_t idx_t * vwgt
real_t ComputeElementBalance(idx_t ne, idx_t nparts, idx_t *where)
idx_t idx_t idx_t idx_t idx_t idx_t idx_t * nparts
NonlinearFactorGraph graph
idx_t idx_t idx_t idx_t idx_t * vsize
void ComputePartitionInfoBipartite(graph_t *graph, idx_t nparts, idx_t *where)
idx_t idx_t idx_t idx_t idx_t idx_t idx_t real_t real_t * ubvec
idx_t idx_t idx_t idx_t idx_t idx_t * adjwgt
void gk_free(void **ptr1,...)
idx_t idx_t idx_t idx_t * where
idx_t idx_t idx_t * adjncy
void ComputePartitionBalance(graph_t *graph, idx_t nparts, idx_t *where, real_t *ubvec)