/* * Copyright 1997, Regents of the University of Minnesota * * stat.c * * This file computes various statistics * * Started 7/25/97 * George * * $Id: stat.c 10578 2011-07-14 18:10:15Z karypis $ * */ #include /************************************************************************* * This function computes the balance of the partitioning **************************************************************************/ void ComputeSerialBalance(ctrl_t *ctrl, graph_t *graph, idx_t *where, real_t *ubvec) { idx_t i, j, nvtxs, ncon, nparts; idx_t *pwgts, *tvwgts, *vwgt; real_t *tpwgts, maximb; nvtxs = graph->nvtxs; ncon = graph->ncon; vwgt = graph->vwgt; nparts = ctrl->nparts; tpwgts = ctrl->tpwgts; pwgts = ismalloc(nparts*ncon, 0, "pwgts"); tvwgts = ismalloc(ncon, 0, "tvwgts"); for (i=0; invtxs; i++) { for (j=0; jncon; nvtxs = graph->nvtxs; nvwgt = graph->nvwgt; nparts = ctrl->nparts; tpwgts = ctrl->tpwgts; lminvwgts = rset(ncon, 1.0, rwspacemalloc(ctrl, ncon)); gminvwgts = rwspacemalloc(ctrl, ncon); lnpwgts = rset(nparts*ncon, 0.0, rwspacemalloc(ctrl, nparts*ncon)); gnpwgts = rwspacemalloc(ctrl, nparts*ncon); for (i=0; i 0.0 && lminvwgts[j] > nvwgt[i*ncon+j] ? nvwgt[i*ncon+j] : lminvwgts[j]); } } gkMPI_Allreduce((void *)(lnpwgts), (void *)(gnpwgts), nparts*ncon, REAL_T, MPI_SUM, ctrl->comm); gkMPI_Allreduce((void *)(lminvwgts), (void *)(gminvwgts), ncon, REAL_T, MPI_MIN, ctrl->comm); /* The +gminvwgts[j] in the following code is to deal with bad cases of tpwgts[i*ncon+j] == 0 */ for (j=0; jnpes; i++) { if (i == ctrl->mype) { for (j=0; jnpes; j++) printf("%.3"PRREAL" ", matrix[j]); printf("\n"); fflush(stdout); } gkMPI_Barrier(ctrl->comm); } if (ctrl->mype == 0) { printf("****************************\n"); fflush(stdout); } gkMPI_Barrier(ctrl->comm); return; } /***********************************************************************************/ /*! This function prints post-partitioning information */ /***********************************************************************************/ void PrintPostPartInfo(ctrl_t *ctrl, graph_t *graph, idx_t movestats) { idx_t i, j, ncon, nmoved, maxin, maxout, nparts; real_t maximb, *tpwgts; ncon = graph->ncon; nparts = ctrl->nparts; tpwgts = ctrl->tpwgts; rprintf(ctrl, "Final %3"PRIDX"-way Cut: %6"PRIDX" \tBalance: ", nparts, graph->mincut); for (j=0; jgnpwgts[i*ncon+j]/tpwgts[i*ncon+j]); rprintf(ctrl, "%.3"PRREAL" ", maximb); } if (movestats) { Mc_ComputeMoveStatistics(ctrl, graph, &nmoved, &maxin, &maxout); rprintf(ctrl, "\nNMoved: %"PRIDX" %"PRIDX" %"PRIDX" %"PRIDX"\n", nmoved, maxin, maxout, maxin+maxout); } else { rprintf(ctrl, "\n"); } } /************************************************************************* * This function computes movement statistics for adaptive refinement * schemes **************************************************************************/ void ComputeMoveStatistics(ctrl_t *ctrl, graph_t *graph, idx_t *nmoved, idx_t *maxin, idx_t *maxout) { idx_t i, j, nvtxs; idx_t *vwgt, *where; idx_t *lpvtxs, *gpvtxs; nvtxs = graph->nvtxs; vwgt = graph->vwgt; where = graph->where; lpvtxs = ismalloc(ctrl->nparts, 0, "ComputeMoveStatistics: lpvtxs"); gpvtxs = ismalloc(ctrl->nparts, 0, "ComputeMoveStatistics: gpvtxs"); for (j=i=0; imype) j++; } /* PrintVector(ctrl, ctrl->npes, 0, lpvtxs, "Lpvtxs: "); */ gkMPI_Allreduce((void *)lpvtxs, (void *)gpvtxs, ctrl->nparts, IDX_T, MPI_SUM, ctrl->comm); *nmoved = GlobalSESum(ctrl, j); *maxout = GlobalSEMax(ctrl, j); *maxin = GlobalSEMax(ctrl, gpvtxs[ctrl->mype]-(nvtxs-j)); gk_free((void **)&lpvtxs, (void **)&gpvtxs, LTERM); }