From 11b308e7363e937966b035b4891db32b4eece3bf Mon Sep 17 00:00:00 2001 From: Tor Aamodt Date: Fri, 1 Oct 2010 08:55:28 -0800 Subject: integrating recent changes from fermi-test into fermi (i'll use "fermi" for more disruptive changes to the pipeline model such as updating the MSHRs and getting rid of the warp tracker, ripping out DWF, etc...) [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 7805] --- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/Makefile | 48 - .../3rdParty/ParMetis-3.1/ParMETISLib/adrivers.c | 117 -- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/akwayfm.c | 629 ---------- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/ametis.c | 272 ----- .../3rdParty/ParMetis-3.1/ParMETISLib/backcompat.c | 517 -------- .../ParMetis-3.1/ParMETISLib/balancemylink.c | 342 ------ .../DG/3rdParty/ParMetis-3.1/ParMETISLib/coarsen.c | 485 -------- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/comm.c | 213 ---- .../3rdParty/ParMetis-3.1/ParMETISLib/csrmatch.c | 88 -- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/debug.c | 247 ---- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/defs.h | 102 -- .../3rdParty/ParMetis-3.1/ParMETISLib/diffutil.c | 298 ----- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/fpqueue.c | 440 ------- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/frename.c | 322 ----- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/gkmetis.c | 331 ------ .../DG/3rdParty/ParMetis-3.1/ParMETISLib/grsetup.c | 274 ----- .../3rdParty/ParMetis-3.1/ParMETISLib/iidxsort.c | 152 --- .../3rdParty/ParMetis-3.1/ParMETISLib/iintsort.c | 157 --- .../3rdParty/ParMetis-3.1/ParMETISLib/ikeysort.c | 151 --- .../ParMetis-3.1/ParMETISLib/ikeyvalsort.c | 151 --- .../ParMetis-3.1/ParMETISLib/initbalance.c | 498 -------- .../ParMetis-3.1/ParMETISLib/initmsection.c | 242 ---- .../3rdParty/ParMetis-3.1/ParMETISLib/initpart.c | 252 ---- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/kmetis.c | 274 ----- .../ParMetis-3.1/ParMETISLib/kwaybalance.c | 456 ------- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/kwayfm.c | 599 ---------- .../3rdParty/ParMetis-3.1/ParMETISLib/kwayrefine.c | 239 ---- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/lmatch.c | 364 ------ .../DG/3rdParty/ParMetis-3.1/ParMETISLib/macros.h | 163 --- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/match.c | 320 ----- .../3rdParty/ParMetis-3.1/ParMETISLib/mdiffusion.c | 455 ------- .../3rdParty/ParMetis-3.1/ParMETISLib/mdrivers.c | 116 -- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/memory.c | 216 ---- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/mesh.c | 335 ------ .../DG/3rdParty/ParMetis-3.1/ParMETISLib/mmetis.c | 95 -- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/move.c | 338 ------ .../DG/3rdParty/ParMetis-3.1/ParMETISLib/msetup.c | 95 -- .../ParMetis-3.1/ParMETISLib/node_refine.c | 383 ------ .../DG/3rdParty/ParMetis-3.1/ParMETISLib/ometis.c | 188 --- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/order.c | 348 ------ .../ParMetis-3.1/ParMETISLib/parmetislib.h | 31 - .../DG/3rdParty/ParMetis-3.1/ParMETISLib/proto.h | 352 ------ .../DG/3rdParty/ParMetis-3.1/ParMETISLib/pspases.c | 167 --- .../3rdParty/ParMetis-3.1/ParMETISLib/redomylink.c | 175 --- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/remap.c | 181 --- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/rename.h | 290 ----- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/rmetis.c | 165 --- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/selectq.c | 340 ------ .../DG/3rdParty/ParMetis-3.1/ParMETISLib/serial.c | 1251 -------------------- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/setup.c | 219 ---- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/stat.c | 332 ------ .../3rdParty/ParMetis-3.1/ParMETISLib/stdheaders.h | 25 - .../DG/3rdParty/ParMetis-3.1/ParMETISLib/struct.h | 290 ----- .../CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/sync | 186 --- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/timer.c | 90 -- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/util.c | 983 --------------- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/wave.c | 241 ---- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/weird.c | 275 ----- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/xyzpart.c | 257 ---- 59 files changed, 17162 deletions(-) delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/Makefile delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/adrivers.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/akwayfm.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ametis.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/backcompat.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/balancemylink.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/coarsen.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/comm.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/csrmatch.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/debug.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/defs.h delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/diffutil.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/fpqueue.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/frename.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/gkmetis.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/grsetup.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/iidxsort.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/iintsort.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ikeysort.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ikeyvalsort.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initbalance.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initmsection.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initpart.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kmetis.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwaybalance.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwayfm.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwayrefine.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/lmatch.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/macros.h delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/match.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mdiffusion.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mdrivers.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/memory.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mesh.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mmetis.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/move.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/msetup.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/node_refine.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ometis.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/order.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/parmetislib.h delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/proto.h delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/pspases.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/redomylink.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/remap.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/rename.h delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/rmetis.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/selectq.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/serial.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/setup.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/stat.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/stdheaders.h delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/struct.h delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/sync delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/timer.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/util.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/wave.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/weird.c delete mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/xyzpart.c (limited to 'benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib') diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/Makefile b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/Makefile deleted file mode 100644 index 3281a07..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -include ../Makefile.in - - -CFLAGS = $(COPTIONS) $(OPTFLAGS) -I. $(INCDIR) - - -OBJS = comm.o util.o debug.o setup.o grsetup.o timer.o \ - node_refine.o initmsection.o order.o \ - xyzpart.o pspases.o frename.o \ - iintsort.o iidxsort.o ikeysort.o ikeyvalsort.o \ - kmetis.o gkmetis.o ometis.o \ - initpart.o match.o coarsen.o \ - kwayfm.o kwayrefine.o kwaybalance.o \ - remap.o stat.o fpqueue.o \ - ametis.o rmetis.o lmatch.o initbalance.o \ - mdiffusion.o diffutil.o wave.o \ - csrmatch.o redomylink.o balancemylink.o \ - selectq.o akwayfm.o serial.o move.o \ - mmetis.o mesh.o memory.o weird.o backcompat.o - -.c.o: - $(CC) $(CFLAGS) -c $*.c - - -../libparmetis.a: $(OBJS) - $(AR) $@ $(OBJS) - $(RANLIB) $@ - -clean: - rm -f *.o - -realclean: - rm -f *.o ; rm -f ../libparmetis.a - - -checkin: - @for file in *.[c,h]; \ - do \ - ci -u -m'Maintance' $$file;\ - done - -checkin2: - @for file in *.[c,h]; \ - do \ - ci $$file;\ - rcs -U $$file;\ - co $$file;\ - done diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/adrivers.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/adrivers.c deleted file mode 100644 index e9c5fe0..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/adrivers.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * adrivers.c - * - * This file contains the driving routines for the various parallel - * multilevel partitioning and repartitioning algorithms - * - * Started 11/19/96 - * George - * - * $Id: adrivers.c,v 1.5 2003/07/30 18:37:58 karypis Exp $ - * - */ - -#include - - - -/************************************************************************* -* This function is the driver for the adaptive refinement mode of ParMETIS -**************************************************************************/ -void Adaptive_Partition(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i; - int tewgt, tvsize; - float gtewgt, gtvsize; - float ubavg, lbavg, lbvec[MAXNCON]; - - /************************************/ - /* Set up important data structures */ - /************************************/ - SetUp(ctrl, graph, wspace); - - ubavg = savg(graph->ncon, ctrl->ubvec); - tewgt = idxsum(graph->nedges, graph->adjwgt); - tvsize = idxsum(graph->nvtxs, graph->vsize); - gtewgt = (float) GlobalSESum(ctrl, tewgt) + 1.0; /* The +1 were added to remove any FPE */ - gtvsize = (float) GlobalSESum(ctrl, tvsize) + 1.0; - ctrl->redist_factor = ctrl->redist_base * ((gtewgt/gtvsize)/ ctrl->edge_size_ratio); - - IFSET(ctrl->dbglvl, DBG_PROGRESS, rprintf(ctrl, "[%6d %8d %5d %5d][%d]\n", - graph->gnvtxs, GlobalSESum(ctrl, graph->nedges), GlobalSEMin(ctrl, graph->nvtxs), GlobalSEMax(ctrl, graph->nvtxs), ctrl->CoarsenTo)); - - if (graph->gnvtxs < 1.3*ctrl->CoarsenTo || - (graph->finer != NULL && graph->gnvtxs > graph->finer->gnvtxs*COARSEN_FRACTION)) { - - /***********************************************/ - /* Balance the partition on the coarsest graph */ - /***********************************************/ - graph->where = idxsmalloc(graph->nvtxs+graph->nrecv, -1, "graph->where"); - idxcopy(graph->nvtxs, graph->home, graph->where); - - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - lbavg = savg(graph->ncon, lbvec); - - if (lbavg > ubavg + 0.035 && ctrl->partType != REFINE_PARTITION) - Balance_Partition(ctrl, graph, wspace); - - if (ctrl->dbglvl&DBG_PROGRESS) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - rprintf(ctrl, "nvtxs: %10d, balance: ", graph->gnvtxs); - for (i=0; incon; i++) - rprintf(ctrl, "%.3f ", lbvec[i]); - rprintf(ctrl, "\n"); - } - - /* check if no coarsening took place */ - if (graph->finer == NULL) { - Moc_ComputePartitionParams(ctrl, graph, wspace); - Moc_KWayBalance(ctrl, graph, wspace, graph->ncon); - Moc_KWayAdaptiveRefine(ctrl, graph, wspace, NGR_PASSES); - } - } - else { - /*******************************/ - /* Coarsen it and partition it */ - /*******************************/ - switch (ctrl->ps_relation) { - case COUPLED: - Mc_LocalMatch_HEM(ctrl, graph, wspace); - break; - case DISCOUPLED: - default: - Moc_GlobalMatch_Balance(ctrl, graph, wspace); - break; - } - - Adaptive_Partition(ctrl, graph->coarser, wspace); - - /********************************/ - /* project partition and refine */ - /********************************/ - Moc_ProjectPartition(ctrl, graph, wspace); - Moc_ComputePartitionParams(ctrl, graph, wspace); - - if (graph->ncon > 1 && graph->level < 4) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - lbavg = savg(graph->ncon, lbvec); - - if (lbavg > ubavg + 0.025) { - Moc_KWayBalance(ctrl, graph, wspace, graph->ncon); - } - } - - Moc_KWayAdaptiveRefine(ctrl, graph, wspace, NGR_PASSES); - - if (ctrl->dbglvl&DBG_PROGRESS) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - rprintf(ctrl, "nvtxs: %10d, cut: %8d, balance: ", graph->gnvtxs, graph->mincut); - for (i=0; incon; i++) - rprintf(ctrl, "%.3f ", lbvec[i]); - rprintf(ctrl, "\n"); - } - } -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/akwayfm.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/akwayfm.c deleted file mode 100644 index 7579d8b..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/akwayfm.c +++ /dev/null @@ -1,629 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * makwayfm.c - * - * This file contains code that performs the k-way refinement - * - * Started 3/1/96 - * George - * - * $Id: akwayfm.c,v 1.3 2003/07/22 22:58:18 karypis Exp $ - */ - -#include - -#define ProperSide(c, from, other) \ - (((c) == 0 && (from)-(other) < 0) || ((c) == 1 && (from)-(other) > 0)) - - -/************************************************************************* -* This function performs k-way refinement -**************************************************************************/ -void Moc_KWayAdaptiveRefine(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace, int npasses) -{ - int h, i, ii, iii, j, k, c; - int pass, nvtxs, nedges, ncon; - int nmoves, nmoved; - int me, firstvtx, lastvtx, yourlastvtx; - int from, to = -1, oldto, oldcut, mydomain, yourdomain, imbalanced, overweight; - int npes = ctrl->npes, mype = ctrl->mype, nparts = ctrl->nparts; - int nlupd, nsupd, nnbrs, nchanged; - idxtype *xadj, *ladjncy, *adjwgt, *vtxdist; - idxtype *where, *tmp_where, *moved; - float *lnpwgts, *gnpwgts, *ognpwgts, *pgnpwgts, *movewgts, *overfill; - idxtype *update, *supdate, *rupdate, *pe_updates; - idxtype *changed, *perm, *pperm, *htable; - idxtype *peind, *recvptr, *sendptr; - KeyValueType *swchanges, *rwchanges; - RInfoType *rinfo, *myrinfo, *tmp_myrinfo, *tmp_rinfo; - EdgeType *tmp_edegrees, *my_edegrees, *your_edegrees; - float lbvec[MAXNCON], *nvwgt, *badmaxpwgt, *ubvec, *tpwgts, lbavg, ubavg; - float oldgain, gain; - float ipc_factor, redist_factor, vsize; - int *nupds_pe, ndirty, nclean, dptr; - int better, worse; - - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->KWayTmr)); - - /*************************/ - /* set up common aliases */ - /*************************/ - nvtxs = graph->nvtxs; - nedges = graph->nedges; - ncon = graph->ncon; - - vtxdist = graph->vtxdist; - xadj = graph->xadj; - ladjncy = graph->adjncy; - adjwgt = graph->adjwgt; - - firstvtx = vtxdist[mype]; - lastvtx = vtxdist[mype+1]; - - where = graph->where; - rinfo = graph->rinfo; - lnpwgts = graph->lnpwgts; - gnpwgts = graph->gnpwgts; - ubvec = ctrl->ubvec; - tpwgts = ctrl->tpwgts; - ipc_factor = ctrl->ipc_factor; - redist_factor = ctrl->redist_factor; - - nnbrs = graph->nnbrs; - peind = graph->peind; - recvptr = graph->recvptr; - sendptr = graph->sendptr; - - changed = idxmalloc(nvtxs, "AKWR: changed"); - rwchanges = wspace->pairs; - swchanges = rwchanges + recvptr[nnbrs]; - - /************************************/ - /* set up important data structures */ - /************************************/ - perm = idxmalloc(nvtxs, "AKWR: perm"); - pperm = idxmalloc(nparts, "AKWR: pperm"); - - update = idxmalloc(nvtxs, "AKWR: update"); - supdate = wspace->indices; - rupdate = supdate + recvptr[nnbrs]; - nupds_pe = imalloc(npes, "AKWR: nupds_pe"); - htable = idxsmalloc(nvtxs+graph->nrecv, 0, "AKWR: lhtable"); - badmaxpwgt = fmalloc(nparts*ncon, "badmaxpwgt"); - - for (i=0; inrecv, "AKWR: tmp_where"); - tmp_rinfo = (RInfoType *)GKmalloc(sizeof(RInfoType)*nvtxs, "AKWR: tmp_rinfo"); - tmp_edegrees = (EdgeType *)GKmalloc(sizeof(EdgeType)*nedges, "AKWR: tmp_edegrees"); - - idxcopy(nvtxs+graph->nrecv, where, tmp_where); - for (i=0; imincut; - if (mype == 0) - RandomPermute(nparts, pperm, 1); - MPI_Bcast((void *)pperm, nparts, IDX_DATATYPE, 0, ctrl->comm); -/* FastRandomPermute(nvtxs, perm, 1); */ - - /*****************************/ - /* move dirty vertices first */ - /*****************************/ - ndirty = 0; - for (i=0; iwhere, lbvec); - ubavg = savg(ncon, ubvec); - lbavg = savg(ncon, lbvec); - imbalanced = (lbavg > ubavg) ? 1 : 0; - - for (c=0; c<2; c++) { - scopy(ncon*nparts, gnpwgts, ognpwgts); - sset(ncon*nparts, 0.0, movewgts); - nmoved = 0; - - /**********************************************/ - /* PASS ONE -- record stats for desired moves */ - /**********************************************/ - for (iii=0; iiinvwgt+i*ncon; - vsize = (float)(graph->vsize[i]); - - for (h=0; h badmaxpwgt[to*ncon+h] && nvwgt[h] > 0.0) - break; - } - if (h == ncon) - break; - } - } - oldto = to; - - /* check if a subdomain was found that fits */ - if (k < tmp_rinfo[i].ndegrees) { - /**************************/ - /**************************/ - switch (ctrl->ps_relation) { - case COUPLED: - better = (oldto == mype) ? 1 : 0; - worse = (from == mype) ? 1 : 0; - break; - case DISCOUPLED: - default: - better = (oldto == graph->home[i]) ? 1 : 0; - worse = (from == graph->home[i]) ? 1 : 0; - break; - } - /**************************/ - /**************************/ - - oldgain = ipc_factor * (float)(my_edegrees[k].ewgt-tmp_rinfo[i].id); - if (better) oldgain += redist_factor * vsize; - if (worse) oldgain -= redist_factor * vsize; - - for (j=k+1; jps_relation) { - case COUPLED: - better = (to == mype) ? 1 : 0; - break; - case DISCOUPLED: - default: - better = (to == graph->home[i]) ? 1 : 0; - break; - } - /**************************/ - /**************************/ - - gain = ipc_factor * (float)(my_edegrees[j].ewgt-tmp_rinfo[i].id); - if (better) gain += redist_factor * vsize; - if (worse) gain -= redist_factor * vsize; - - for (h=0; h badmaxpwgt[to*ncon+h] && nvwgt[h] > 0.0) - break; - - if (h == ncon) { - if (gain > oldgain || - (fabs(gain-oldgain) < SMALLFLOAT && - IsHBalanceBetterTT(ncon,gnpwgts+oldto*ncon,gnpwgts+to*ncon,nvwgt,ubvec))){ - oldgain = gain; - oldto = to; - k = j; - } - } - } - } - to = oldto; - gain = oldgain; - - if (gain > 0.0 || - (gain > -1.0*SMALLFLOAT && - (imbalanced || graph->level > 3 || iii % 8 == 0) && - IsHBalanceBetterFT(ncon,gnpwgts+from*ncon,gnpwgts+to*ncon,nvwgt,ubvec))){ - - /****************************************/ - /* Update tmp arrays of the moved vertex */ - /****************************************/ - tmp_where[i] = to; - moved[nmoved++] = i; - for (h=0; h= nvtxs) - continue; - - me = ladjncy[j]; - mydomain = tmp_where[me]; - - myrinfo = tmp_rinfo+me; - your_edegrees = myrinfo->degrees; - - if (mydomain == from) { - INC_DEC(myrinfo->ed, myrinfo->id, adjwgt[j]); - } - else { - if (mydomain == to) { - INC_DEC(myrinfo->id, myrinfo->ed, adjwgt[j]); - } - } - - /* Remove contribution from the .ed of 'from' */ - if (mydomain != from) { - for (k=0; kndegrees; k++) { - if (your_edegrees[k].edge == from) { - if (your_edegrees[k].ewgt == adjwgt[j]) { - myrinfo->ndegrees--; - your_edegrees[k].edge = your_edegrees[myrinfo->ndegrees].edge; - your_edegrees[k].ewgt = your_edegrees[myrinfo->ndegrees].ewgt; - } - else { - your_edegrees[k].ewgt -= adjwgt[j]; - } - break; - } - } - } - - /* Add contribution to the .ed of 'to' */ - if (mydomain != to) { - for (k=0; kndegrees; k++) { - if (your_edegrees[k].edge == to) { - your_edegrees[k].ewgt += adjwgt[j]; - break; - } - } - if (k == myrinfo->ndegrees) { - your_edegrees[myrinfo->ndegrees].edge = to; - your_edegrees[myrinfo->ndegrees++].ewgt = adjwgt[j]; - } - } - } - } - } - } - - /******************************************/ - /* Let processors know the subdomain wgts */ - /* if all proposed moves commit. */ - /******************************************/ - MPI_Allreduce((void *)lnpwgts, (void *)pgnpwgts, nparts*ncon, MPI_FLOAT, MPI_SUM, ctrl->comm); - - /**************************/ - /* compute overfill array */ - /**************************/ - overweight = 0; - for (j=0; j ognpwgts[j*ncon+h]) - overfill[j*ncon+h] = (pgnpwgts[j*ncon+h]-badmaxpwgt[j*ncon+h]) / (pgnpwgts[j*ncon+h]-ognpwgts[j*ncon+h]); - else - overfill[j*ncon+h] = 0.0; - - overfill[j*ncon+h] = amax(overfill[j*ncon+h], 0.0); - overfill[j*ncon+h] *= movewgts[j*ncon+h]; - - if (overfill[j*ncon+h] > 0.0) - overweight = 1; - - ASSERTP(ctrl, ognpwgts[j*ncon+h] <= badmaxpwgt[j*ncon+h] || pgnpwgts[j*ncon+h] <= ognpwgts[j*ncon+h], - (ctrl, "%.4f %.4f %.4f\n", ognpwgts[j*ncon+h], badmaxpwgt[j*ncon+h], pgnpwgts[j*ncon+h])); - } - } - - /****************************************************/ - /* select moves to undo according to overfill array */ - /****************************************************/ - if (overweight == 1) { - for (iii=0; iiinvwgt+i*ncon; - my_edegrees = tmp_rinfo[i].degrees; - - for (k=0; k 0.0 && overfill[oldto*ncon+h] > nvwgt[h]/4.0) - break; - - /**********************************/ - /* nullify this move if necessary */ - /**********************************/ - if (k != tmp_rinfo[i].ndegrees && h != ncon) { - moved[iii] = -1; - from = oldto; - to = where[i]; - - for (h=0; h= nvtxs) - continue; - - me = ladjncy[j]; - mydomain = tmp_where[me]; - - myrinfo = tmp_rinfo+me; - your_edegrees = myrinfo->degrees; - - if (mydomain == from) { - INC_DEC(myrinfo->ed, myrinfo->id, adjwgt[j]); - } - else { - if (mydomain == to) { - INC_DEC(myrinfo->id, myrinfo->ed, adjwgt[j]); - } - } - - /* Remove contribution from the .ed of 'from' */ - if (mydomain != from) { - for (k=0; kndegrees; k++) { - if (your_edegrees[k].edge == from) { - if (your_edegrees[k].ewgt == adjwgt[j]) { - myrinfo->ndegrees--; - your_edegrees[k].edge = your_edegrees[myrinfo->ndegrees].edge; - your_edegrees[k].ewgt = your_edegrees[myrinfo->ndegrees].ewgt; - } - else { - your_edegrees[k].ewgt -= adjwgt[j]; - } - break; - } - } - } - - /* Add contribution to the .ed of 'to' */ - if (mydomain != to) { - for (k=0; kndegrees; k++) { - if (your_edegrees[k].edge == to) { - your_edegrees[k].ewgt += adjwgt[j]; - break; - } - } - if (k == myrinfo->ndegrees) { - your_edegrees[myrinfo->ndegrees].edge = to; - your_edegrees[myrinfo->ndegrees++].ewgt = adjwgt[j]; - } - } - } - } - } - } - - /*************************************************/ - /* PASS TWO -- commit the remainder of the moves */ - /*************************************************/ - nlupd = nsupd = nmoves = nchanged = 0; - for (iii=0; iiipexadj[i+1]-graph->pexadj[i] > 0) - changed[nchanged++] = i; - } - - /* Tell interested pe's the new where[] info for the interface vertices */ - CommChangedInterfaceData(ctrl, graph, nchanged, changed, where, swchanges, rwchanges, wspace->pv4); - - - IFSET(ctrl->dbglvl, DBG_RMOVEINFO, rprintf(ctrl, "\t[%d %d], [%.4f], [%d %d %d]\n", - pass, c, badmaxpwgt[0], GlobalSESum(ctrl, nmoves), GlobalSESum(ctrl, nsupd), GlobalSESum(ctrl, nlupd))); - - /*------------------------------------------------------------- - / Time to communicate with processors to send the vertices - / whose degrees need to be update. - /-------------------------------------------------------------*/ - /* Issue the receives first */ - for (i=0; icomm, ctrl->rreq+i); - - /* Issue the sends next. This needs some preporcessing */ - for (i=0; iimap[supdate[i]]; - } - iidxsort(nsupd, supdate); - - for (j=i=0; icomm, ctrl->sreq+i); - j = k; - } - - /* OK, now get into the loop waiting for the send/recv operations to finish */ - MPI_Waitall(nnbrs, ctrl->rreq, ctrl->statuses); - for (i=0; istatuses+i, IDX_DATATYPE, nupds_pe+i); - MPI_Waitall(nnbrs, ctrl->sreq, ctrl->statuses); - - - /*------------------------------------------------------------- - / Place the recieved to-be updated vertices into update[] - /-------------------------------------------------------------*/ - for (i=0; idegrees; - your_edegrees = tmp_myrinfo->degrees; - - graph->lmincut -= myrinfo->ed; - myrinfo->ndegrees = 0; - myrinfo->id = 0; - myrinfo->ed = 0; - - for (j=xadj[i]; jed += adjwgt[j]; - - for (k=0; kndegrees; k++) { - if (my_edegrees[k].edge == yourdomain) { - my_edegrees[k].ewgt += adjwgt[j]; - your_edegrees[k].ewgt += adjwgt[j]; - break; - } - } - if (k == myrinfo->ndegrees) { - my_edegrees[k].edge = yourdomain; - my_edegrees[k].ewgt = adjwgt[j]; - your_edegrees[k].edge = yourdomain; - your_edegrees[k].ewgt = adjwgt[j]; - myrinfo->ndegrees++; - } - ASSERT(ctrl, myrinfo->ndegrees <= xadj[i+1]-xadj[i]); - ASSERT(ctrl, tmp_myrinfo->ndegrees <= xadj[i+1]-xadj[i]); - - } - else { - myrinfo->id += adjwgt[j]; - } - } - graph->lmincut += myrinfo->ed; - - tmp_myrinfo->id = myrinfo->id; - tmp_myrinfo->ed = myrinfo->ed; - tmp_myrinfo->ndegrees = myrinfo->ndegrees; - } - - /* finally, sum-up the partition weights */ - MPI_Allreduce((void *)lnpwgts, (void *)gnpwgts, nparts*ncon, MPI_FLOAT, MPI_SUM, ctrl->comm); - } - graph->mincut = GlobalSESum(ctrl, graph->lmincut)/2; - - if (graph->mincut == oldcut) - break; - } - - GKfree((void **)&badmaxpwgt, (void **)&update, (void **)&nupds_pe, (void **)&htable, LTERM); - GKfree((void **)&changed, (void **)&pperm, (void **)&perm, (void **)&moved, LTERM); - GKfree((void **)&pgnpwgts, (void **)&ognpwgts, (void **)&overfill, (void **)&movewgts, LTERM); - GKfree((void **)&tmp_where, (void **)&tmp_rinfo, (void **)&tmp_edegrees, LTERM); - - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->KWayTmr)); -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ametis.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ametis.c deleted file mode 100644 index 6fac271..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ametis.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * ametis.c - * - * This is the entry point of parallel difussive repartitioning routines - * - * Started 10/19/96 - * George - * - * $Id: ametis.c,v 1.6 2003/07/25 04:01:03 karypis Exp $ - * - */ - -#include - - - -/*********************************************************************************** -* This function is the entry point of the parallel multilevel local diffusion -* algorithm. It uses parallel undirected diffusion followed by adaptive k-way -* refinement. This function utilizes local coarsening. -************************************************************************************/ -void ParMETIS_V3_AdaptiveRepart(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, - idxtype *vwgt, idxtype *vsize, idxtype *adjwgt, int *wgtflag, int *numflag, - int *ncon, int *nparts, float *tpwgts, float *ubvec, float *ipc2redist, - int *options, int *edgecut, idxtype *part, MPI_Comm *comm) -{ - int h, i; - int npes, mype; - CtrlType ctrl; - WorkSpaceType wspace; - GraphType *graph; - int tewgt, tvsize, nmoved, maxin, maxout, vtx_factor; - float gtewgt, gtvsize, avg, maximb; - int ps_relation, seed, dbglvl = 0; - int iwgtflag, inumflag, incon, inparts, ioptions[10]; - float iipc2redist, *itpwgts, iubvec[MAXNCON]; - - MPI_Comm_size(*comm, &npes); - MPI_Comm_rank(*comm, &mype); - - /********************************/ - /* Try and take care bad inputs */ - /********************************/ - if (options != NULL && options[0] == 1) - dbglvl = options[PMV3_OPTION_DBGLVL]; - CheckInputs(ADAPTIVE_PARTITION, npes, dbglvl, wgtflag, &iwgtflag, numflag, &inumflag, - ncon, &incon, nparts, &inparts, tpwgts, &itpwgts, ubvec, iubvec, - ipc2redist, &iipc2redist, options, ioptions, part, comm); - - /* ADD: take care of disconnected graph */ - /* ADD: take care of highly unbalanced vtxdist */ - /*********************************/ - /* Take care the nparts = 1 case */ - /*********************************/ - if (inparts == 1) { - idxset(vtxdist[mype+1]-vtxdist[mype], 0, part); - *edgecut = 0; - return; - } - - /**************************/ - /* Set up data structures */ - /**************************/ - if (inumflag == 1) - ChangeNumbering(vtxdist, xadj, adjncy, part, npes, mype, 1); - - /*****************************/ - /* Set up control structures */ - /*****************************/ - if (ioptions[0] == 1) { - dbglvl = ioptions[PMV3_OPTION_DBGLVL]; - seed = ioptions[PMV3_OPTION_SEED]; - ps_relation = (npes == inparts ? ioptions[PMV3_OPTION_PSR] : DISCOUPLED); - } - else { - dbglvl = GLOBAL_DBGLVL; - seed = GLOBAL_SEED; - ps_relation = (npes == inparts ? COUPLED : DISCOUPLED); - } - - SetUpCtrl(&ctrl, inparts, dbglvl, *comm); - vtx_factor = (amax(npes, inparts) > 256) ? 20 : 50; - ctrl.CoarsenTo = amin(vtxdist[npes]+1, vtx_factor*incon*amax(npes, inparts)); - ctrl.ipc_factor = iipc2redist; - ctrl.redist_factor = 1.0; - ctrl.redist_base = 1.0; - ctrl.seed = (seed == 0 ? mype : seed*mype); - ctrl.sync = GlobalSEMax(&ctrl, seed); - ctrl.partType = ADAPTIVE_PARTITION; - ctrl.ps_relation = ps_relation; - ctrl.tpwgts = itpwgts; - - graph = Moc_SetUpGraph(&ctrl, incon, vtxdist, xadj, vwgt, adjncy, adjwgt, &iwgtflag); - graph->vsize = (vsize == NULL ? idxsmalloc(graph->nvtxs, 1, "vsize") : vsize); - - graph->home = idxmalloc(graph->nvtxs, "home"); - if (ctrl.ps_relation == COUPLED) - idxset(graph->nvtxs, mype, graph->home); - else { - /* Downgrade the partition numbers if part[] has more partitions that nparts */ - for (i=0; invtxs; i++) - part[i] = (part[i] >= ctrl.nparts ? 0 : part[i]); - - idxcopy(graph->nvtxs, part, graph->home); - } - - tewgt = idxsum(graph->nedges, graph->adjwgt); - tvsize = idxsum(graph->nvtxs, graph->vsize); - gtewgt = (float) GlobalSESum(&ctrl, tewgt) + 1.0/graph->gnvtxs; /* The +1/graph->gnvtxs were added to remove any FPE */ - gtvsize = (float) GlobalSESum(&ctrl, tvsize) + 1.0/graph->gnvtxs; - ctrl.edge_size_ratio = gtewgt/gtvsize; - scopy(incon, iubvec, ctrl.ubvec); - - PreAllocateMemory(&ctrl, graph, &wspace); - - /***********************/ - /* Partition and Remap */ - /***********************/ - IFSET(ctrl.dbglvl, DBG_TIME, InitTimers(&ctrl)); - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.TotalTmr)); - - Adaptive_Partition(&ctrl, graph, &wspace); - ParallelReMapGraph(&ctrl, graph, &wspace); - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.TotalTmr)); - - idxcopy(graph->nvtxs, graph->where, part); - if (edgecut != NULL) - *edgecut = graph->mincut; - - /***********************/ - /* Take care of output */ - /***********************/ - IFSET(ctrl.dbglvl, DBG_TIME, PrintTimingInfo(&ctrl)); - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - - if (ctrl.dbglvl&DBG_INFO) { - Mc_ComputeMoveStatistics(&ctrl, graph, &nmoved, &maxin, &maxout); - rprintf(&ctrl, "Final %3d-way Cut: %6d \tBalance: ", inparts, graph->mincut); - avg = 0.0; - for (h=0; hgnpwgts[i*incon+h]/itpwgts[i*incon+h]); - avg += maximb; - rprintf(&ctrl, "%.3f ", maximb); - } - rprintf(&ctrl, "\nNMoved: %d %d %d %d\n", nmoved, maxin, maxout, maxin+maxout); - } - - /*************************************/ - /* Free memory, renumber, and return */ - /*************************************/ - GKfree((void **)&graph->lnpwgts, (void **)&graph->gnpwgts, (void **)&graph->nvwgt, (void **)(&graph->home), LTERM); - if (vsize == NULL) - GKfree((void **)(&graph->vsize), LTERM); - GKfree((void **)&itpwgts, LTERM); - FreeInitialGraphAndRemap(graph, iwgtflag); - FreeWSpace(&wspace); - FreeCtrl(&ctrl); - - if (inumflag == 1) - ChangeNumbering(vtxdist, xadj, adjncy, part, npes, mype, 0); - - return; -} - - - - -/************************************************************************* -* This function is the driver for the adaptive refinement mode of ParMETIS -**************************************************************************/ -void Adaptive_Partition(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i; - int tewgt, tvsize; - float gtewgt, gtvsize; - float ubavg, lbavg, lbvec[MAXNCON]; - - /************************************/ - /* Set up important data structures */ - /************************************/ - SetUp(ctrl, graph, wspace); - - ubavg = savg(graph->ncon, ctrl->ubvec); - tewgt = idxsum(graph->nedges, graph->adjwgt); - tvsize = idxsum(graph->nvtxs, graph->vsize); - gtewgt = (float) GlobalSESum(ctrl, tewgt) + 1.0/graph->gnvtxs; /* The +1/graph->gnvtxs were added to remove any FPE */ - gtvsize = (float) GlobalSESum(ctrl, tvsize) + 1.0/graph->gnvtxs; - ctrl->redist_factor = ctrl->redist_base * ((gtewgt/gtvsize)/ ctrl->edge_size_ratio); - - IFSET(ctrl->dbglvl, DBG_PROGRESS, rprintf(ctrl, "[%6d %8d %5d %5d][%d]\n", - graph->gnvtxs, GlobalSESum(ctrl, graph->nedges), GlobalSEMin(ctrl, graph->nvtxs), GlobalSEMax(ctrl, graph->nvtxs), ctrl->CoarsenTo)); - - if (graph->gnvtxs < 1.3*ctrl->CoarsenTo || - (graph->finer != NULL && graph->gnvtxs > graph->finer->gnvtxs*COARSEN_FRACTION)) { - - /***********************************************/ - /* Balance the partition on the coarsest graph */ - /***********************************************/ - graph->where = idxsmalloc(graph->nvtxs+graph->nrecv, -1, "graph->where"); - idxcopy(graph->nvtxs, graph->home, graph->where); - - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - lbavg = savg(graph->ncon, lbvec); - - if (lbavg > ubavg + 0.035 && ctrl->partType != REFINE_PARTITION) - Balance_Partition(ctrl, graph, wspace); - - if (ctrl->dbglvl&DBG_PROGRESS) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - rprintf(ctrl, "nvtxs: %10d, balance: ", graph->gnvtxs); - for (i=0; incon; i++) - rprintf(ctrl, "%.3f ", lbvec[i]); - rprintf(ctrl, "\n"); - } - - /* check if no coarsening took place */ - if (graph->finer == NULL) { - Moc_ComputePartitionParams(ctrl, graph, wspace); - Moc_KWayBalance(ctrl, graph, wspace, graph->ncon); - Moc_KWayAdaptiveRefine(ctrl, graph, wspace, NGR_PASSES); - } - } - else { - /*******************************/ - /* Coarsen it and partition it */ - /*******************************/ - switch (ctrl->ps_relation) { - case COUPLED: - Mc_LocalMatch_HEM(ctrl, graph, wspace); - break; - case DISCOUPLED: - default: - Moc_GlobalMatch_Balance(ctrl, graph, wspace); - break; - } - - Adaptive_Partition(ctrl, graph->coarser, wspace); - - /********************************/ - /* project partition and refine */ - /********************************/ - Moc_ProjectPartition(ctrl, graph, wspace); - Moc_ComputePartitionParams(ctrl, graph, wspace); - - if (graph->ncon > 1 && graph->level < 4) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - lbavg = savg(graph->ncon, lbvec); - - if (lbavg > ubavg + 0.025) { - Moc_KWayBalance(ctrl, graph, wspace, graph->ncon); - } - } - - Moc_KWayAdaptiveRefine(ctrl, graph, wspace, NGR_PASSES); - - if (ctrl->dbglvl&DBG_PROGRESS) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - rprintf(ctrl, "nvtxs: %10d, cut: %8d, balance: ", graph->gnvtxs, graph->mincut); - for (i=0; incon; i++) - rprintf(ctrl, "%.3f ", lbvec[i]); - rprintf(ctrl, "\n"); - } - } -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/backcompat.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/backcompat.c deleted file mode 100644 index b62d4bb..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/backcompat.c +++ /dev/null @@ -1,517 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * backcompat.c - * - * This file ensures backwards compatability with previous ParMETIS releases - * - * Started 10/19/96 - * George - * - * $Id: backcompat.c,v 1.2 2003/07/21 17:18:48 karypis Exp $ - * - */ - -#include - -/***************************************************************************** -* This function computes a partitioning. -*****************************************************************************/ -void ParMETIS_PartKway(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, - idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts, int *options, int *edgecut, - idxtype *part, MPI_Comm *comm) -{ - int i; - int ncon = 1; - float *tpwgts, ubvec[MAXNCON]; - int myoptions[10]; - - tpwgts = fmalloc(*nparts*ncon, "tpwgts"); - for (i=0; i<*nparts*ncon; i++) - tpwgts[i] = 1.0/(float)(*nparts); - for (i=0; i -#define PE 0 - -/************************************************************************* -* This function performs an edge-based FM refinement -**************************************************************************/ -int BalanceMyLink(CtrlType *ctrl, GraphType *graph, idxtype *home, int me, - int you, float *flows, float maxdiff, float *diff_cost, float *diff_lbavg, - float avgvwgt) -{ - int h, i, ii, j, k; - int nvtxs, ncon; - int nqueues, minval, maxval, higain, vtx, edge, totalv; - int from, to, qnum, index, nchanges, cut, tmp; - int pass, nswaps, nmoves, multiplier; - idxtype *xadj, *vsize, *adjncy, *adjwgt, *where, *ed, *id; - idxtype *hval, *nvpq, *inq, *map, *rmap, *ptr, *myqueue, *changes; - float *nvwgt, lbvec[MAXNCON], pwgts[MAXNCON*2], tpwgts[MAXNCON*2], my_wgt[MAXNCON]; - float newgain, oldgain = 0.0; - float lbavg, bestflow, mycost; - float ipc_factor, redist_factor, ftmp; - FPQueueType *queues; -int mype; -MPI_Comm_rank(MPI_COMM_WORLD, &mype); - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - xadj = graph->xadj; - nvwgt = graph->nvwgt; - vsize = graph->vsize; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - ipc_factor = ctrl->ipc_factor; - redist_factor = ctrl->redist_factor; - - hval = idxmalloc(nvtxs*7, "hval"); - id = hval + nvtxs; - ed = hval + nvtxs*2; - map = hval + nvtxs*3; - rmap = hval + nvtxs*4; - myqueue = hval + nvtxs*5; - changes = hval + nvtxs*6; - - sset(ncon*2, 0.0, pwgts); - for (h=0; h0; i--) - ptr[i] = ptr[i-1]; - ptr[0] = 0; - - /* initialize queues */ - for (i=0; i 0) { - FPQueueInit(queues+i, nvpq[i]); - FPQueueInit(queues+i+nqueues, nvpq[i]); - } - - /* compute internal/external degrees */ - idxset(nvtxs, 0, id); - idxset(nvtxs, 0, ed); - for (j=0; j fabs(flows[j])) j = h; - bestflow = fabs(flows[j]); - - nchanges = nmoves = 0; - for (ii=0; ii avgvwgt) - break; - } - else { - for (j=0; j fabs(flows[j])) j = h; - ftmp = fabs(flows[j]); - - if (ftmp < bestflow) { - bestflow = ftmp; - nchanges = 0; - } - else { - changes[nchanges++] = vtx; - } - - SWAP(id[vtx], ed[vtx], tmp); - - for (j=xadj[vtx]; j 0) { - FPQueueReset(queues+i); - FPQueueReset(queues+i+nqueues); - } - } - - if (nmoves == 0) - break; - } - - /***************************/ - /* compute 2-way imbalance */ - /***************************/ - sset(ncon, 0.0, my_wgt); - for (i=0; i 0) { - FPQueueFree(queues+i); - FPQueueFree(queues+i+nqueues); - } - - GKfree((void **)&hval, (void **)&nvpq, (void **)&ptr, (void **)&inq, (void **)&queues, LTERM); - return nswaps; -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/coarsen.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/coarsen.c deleted file mode 100644 index 70f48c2..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/coarsen.c +++ /dev/null @@ -1,485 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * mcoarsen.c - * - * This file contains code that performs graph coarsening - * - * Started 2/22/96 - * George - * - * $Id: coarsen.c,v 1.2 2003/07/21 17:18:48 karypis Exp $ - * - */ - -#include - - -/************************************************************************* -* This function creates the coarser graph -**************************************************************************/ -void Moc_Global_CreateCoarseGraph(CtrlType *ctrl, GraphType *graph, - WorkSpaceType *wspace, int cnvtxs) -{ - int h, i, j, k, l, ii, jj, ll, nnbrs, nvtxs, nedges, ncon; - int firstvtx, lastvtx, cfirstvtx, clastvtx, otherlastvtx; - int npes=ctrl->npes, mype=ctrl->mype; - int cnedges, nsend, nrecv, nkeepsize, nrecvsize, nsendsize, v, u; - idxtype *xadj, *ladjncy, *adjwgt, *vwgt, *vsize, *vtxdist, *home; - idxtype *match, *cmap, *rcmap, *scmap; - idxtype *cxadj, *cadjncy, *cadjwgt, *cvwgt, *cvsize = NULL, *chome = NULL, *cvtxdist; - idxtype *rsizes, *ssizes, *rlens, *slens, *rgraph, *sgraph, *perm; - idxtype *peind, *recvptr, *recvind; - float *nvwgt, *cnvwgt; - GraphType *cgraph; - KeyValueType *scand, *rcand; - int mask=(1<<13)-1, htable[8192], htableidx[8192]; - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - - vtxdist = graph->vtxdist; - xadj = graph->xadj; - vwgt = graph->vwgt; - vsize = graph->vsize; - nvwgt = graph->nvwgt; - home = graph->home; - ladjncy = graph->adjncy; - adjwgt = graph->adjwgt; - - match = graph->match; - - firstvtx = vtxdist[mype]; - lastvtx = vtxdist[mype+1]; - - cmap = graph->cmap = idxmalloc(nvtxs+graph->nrecv, "CreateCoarseGraph: cmap"); - - nnbrs = graph->nnbrs; - peind = graph->peind; - recvind = graph->recvind; - recvptr = graph->recvptr; - - /* Use wspace->indices as the tmp space for map of the boundary - * vertices that are sent and received */ - scmap = wspace->indices; - rcmap = cmap + nvtxs; - - - /* Initialize the coarser graph */ - cgraph = CreateGraph(); - cgraph->nvtxs = cnvtxs; - cgraph->ncon = ncon; - cgraph->level = graph->level+1; - cgraph->finer = graph; - graph->coarser = cgraph; - - - - /************************************************************* - * Obtain the vtxdist of the coarser graph - **************************************************************/ - cvtxdist = cgraph->vtxdist = idxmalloc(npes+1, "CreateCoarseGraph: cvtxdist"); - cvtxdist[npes] = cnvtxs; /* Use last position in the cvtxdist as a temp buffer */ - - MPI_Allgather((void *)(cvtxdist+npes), 1, IDX_DATATYPE, (void *)cvtxdist, 1, IDX_DATATYPE, ctrl->comm); - - MAKECSR(i, npes, cvtxdist); - - cgraph->gnvtxs = cvtxdist[npes]; - -#ifdef DEBUG_CONTRACT - PrintVector(ctrl, npes+1, 0, cvtxdist, "cvtxdist"); -#endif - - - /************************************************************* - * Construct the cmap vector - **************************************************************/ - cfirstvtx = cvtxdist[mype]; - clastvtx = cvtxdist[mype+1]; - - /* Create the cmap of what you know so far locally */ - cnvtxs = 0; - for (i=0; i= KEEP_BIT) { - k = match[i] - KEEP_BIT; - if (k>=firstvtx && k=firstvtx && knrecv, recvind, match[i])]; - } - } - - CommInterfaceData(ctrl, graph, cmap, scmap, rcmap); - - -#ifdef DEBUG_CONTRACT - PrintVector(ctrl, nvtxs, firstvtx, cmap, "Cmap"); -#endif - - - /************************************************************* - * Determine how many adjcency lists you need to send/receive. - **************************************************************/ - /* Use wspace->pairs as the tmp space for the boundary vertices that are sent and received */ - scand = wspace->pairs; - rcand = graph->rcand = (KeyValueType *)GKmalloc(recvptr[nnbrs]*sizeof(KeyValueType), "CreateCoarseGraph: rcand"); - - nkeepsize = nsend = nrecv = 0; - for (i=0; i=lastvtx) { /* This is comming from afar */ - rcand[nrecv].key = k; - rcand[nrecv].val = cmap[i] - cfirstvtx; /* Set it for use during the partition projection */ - ASSERT(ctrl, rcand[nrecv].val>=0 && rcand[nrecv].valpv1; - ssizes = wspace->pv2; - idxset(nnbrs, 0, ssizes); - idxset(nnbrs, 0, rsizes); - rlens = graph->rlens = idxmalloc(nnbrs+1, "CreateCoarseGraph: graph->rlens"); - slens = graph->slens = idxmalloc(nnbrs+1, "CreateCoarseGraph: graph->slens"); - - /* Take care the sending data first */ - ikeyvalsort(nsend, scand); - slens[0] = 0; - for (k=i=0; i 0) /* Issue a receive only if you are getting something */ - MPI_Irecv((void *)(rsizes+i), 1, IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->rreq+i); - } - - /* Take care the sending data next */ - for (i=0; i 0) /* Issue a send only if you are sending something */ - MPI_Isend((void *)(ssizes+i), 1, IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->sreq+i); - } - - /* OK, now get into the loop waiting for the operations to finish */ - for (i=0; i 0) - MPI_Wait(ctrl->rreq+i, &ctrl->status); - } - for (i=0; i 0) - MPI_Wait(ctrl->sreq+i, &ctrl->status); - } - - -#ifdef DEBUG_CONTRACT - PrintVector(ctrl, nnbrs, 0, rsizes, "rsizes"); - PrintVector(ctrl, nnbrs, 0, ssizes, "ssizes"); -#endif - - /************************************************************* - * Allocate memory for received/sent graphs and start sending - * and receiving data. - * rgraph and sgraph is a different data structure than CSR - * to facilitate single message exchange. - **************************************************************/ - nrecvsize = idxsum(nnbrs, rsizes); - nsendsize = idxsum(nnbrs, ssizes); - if ((4+ncon)*(nrecv+nsend) + 2*(nrecvsize+nsendsize) <= wspace->nlarge) { - rgraph = (idxtype *)wspace->degrees; - sgraph = rgraph + (4+ncon)*nrecv+2*nrecvsize; - } - else { - rgraph = idxmalloc((4+ncon)*nrecv+2*nrecvsize, "CreateCoarseGraph: rgraph"); - sgraph = idxmalloc((4+ncon)*nsend+2*nsendsize, "CreateCoarseGraph: sgraph"); - } - - /* Deal with the received portion first */ - for (l=i=0; i 0) { - MPI_Irecv((void *)(rgraph+l), (4+ncon)*(rlens[i+1]-rlens[i])+2*rsizes[i], IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->rreq+i); - l += (4+ncon)*(rlens[i+1]-rlens[i])+2*rsizes[i]; - } - } - - - /* Deal with the sent portion now */ - for (ll=l=i=0; i 0) { /* Issue a send only if you are sending something */ - for (k=slens[i]; kpartType == STATIC_PARTITION) ? -1 : vsize[ii]; - sgraph[ll++] = (ctrl->partType == STATIC_PARTITION) ? -1 : home[ii]; - for (jj=xadj[ii]; jjcomm, ctrl->sreq+i); - l = ll; - } - } - - /* OK, now get into the loop waiting for the operations to finish */ - for (i=0; i 0) - MPI_Wait(ctrl->rreq+i, &ctrl->status); - } - for (i=0; i 0) - MPI_Wait(ctrl->sreq+i, &ctrl->status); - } - - -#ifdef DEBUG_CONTRACT - rprintf(ctrl, "Graphs were sent!\n"); - PrintTransferedGraphs(ctrl, nnbrs, peind, slens, rlens, sgraph, rgraph); -#endif - - /************************************************************* - * Setup the mapping from indices returned by BSearch to - * those that are actually stored - **************************************************************/ - perm = idxsmalloc(recvptr[nnbrs], -1, "CreateCoarseGraph: perm"); - for (j=i=0; inrecv, recvind, rgraph[j]), j+ncon); */ - perm[BSearch(graph->nrecv, recvind, rgraph[j])] = j+1; - j += (4+ncon)+2*rgraph[j+1]; - } - - /************************************************************* - * Finally, create the coarser graph - **************************************************************/ - /* Allocate memory for the coarser graph, and fire up coarsening */ - cxadj = cgraph->xadj = idxmalloc(cnvtxs+1, "CreateCoarserGraph: cxadj"); - cvwgt = cgraph->vwgt = idxmalloc(cnvtxs*ncon, "CreateCoarserGraph: cvwgt"); - if (ctrl->partType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) { - cvsize = cgraph->vsize = idxmalloc(cnvtxs, "CreateCoarserGraph: cvsize"); - chome = cgraph->home = idxmalloc(cnvtxs, "CreateCoarserGraph: chome"); - } - cnvwgt = cgraph->nvwgt = fmalloc(cnvtxs*ncon, "CreateCoarserGraph: cnvwgt"); - cadjncy = idxmalloc(2*(nkeepsize+nrecvsize), "CreateCoarserGraph: cadjncy"); - cadjwgt = cadjncy + nkeepsize+nrecvsize; - - iset(8192, -1, htable); - - cxadj[0] = cnvtxs = cnedges = 0; - for (i=0; i= KEEP_BIT) { - v = firstvtx+i; - u = match[i]-KEEP_BIT; - - if (u>=firstvtx && u u) - continue; /* I have already collapsed it as (u,v) */ - - /* Collapse the v vertex first, which you know is local */ - for (h=0; hpartType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) { - cvsize[cnvtxs] = vsize[i]; - chome[cnvtxs] = home[i]; - } - nedges = 0; - - for (j=xadj[i]; j=firstvtx && upartType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) { - cvsize[cnvtxs] += vsize[u]; - /* chome[cnvtxs] = home[u]; */ - } - - for (j=xadj[u]; jnrecv, recvind, u)]; - for (h=0; hpartType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) { - cvsize[cnvtxs] += rgraph[u+1+ncon]; - chome[cnvtxs] = rgraph[u+2+ncon]; - } - for (j=0; jnedges = cnedges; - - /* ADD: In order to keep from having to change this too much */ - /* ADD: I kept vwgt array and recomputed nvwgt for each coarser graph */ - for (j=0; jnvwgt[j*ncon+h] = (float)(cvwgt[j*ncon+h])/(float)(ctrl->tvwgts[h]); - - cgraph->adjncy = idxmalloc(cnedges, "CreateCoarserGraph: cadjncy"); - cgraph->adjwgt = idxmalloc(cnedges, "CreateCoarserGraph: cadjwgt"); - idxcopy(cnedges, cadjncy, cgraph->adjncy); - idxcopy(cnedges, cadjwgt, cgraph->adjwgt); - free(cadjncy); - - free(perm); - - if (rgraph != (idxtype *)wspace->degrees) - GKfree((void **)&rgraph, (void **)&sgraph, LTERM); - -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/comm.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/comm.c deleted file mode 100644 index fb18789..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/comm.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * comm.c - * - * This function provides various high level communication functions - * - * $Id: comm.c,v 1.2 2003/07/21 17:18:48 karypis Exp $ - */ - -#include - - - -/************************************************************************* -* This function performs the gather/scatter for the boundary vertices -**************************************************************************/ -void CommInterfaceData(CtrlType *ctrl, GraphType *graph, idxtype *data, - idxtype *sendvector, idxtype *recvvector) -{ - int i, k, nnbrs, firstvtx; - idxtype *peind, *sendptr, *sendind, *recvptr, *recvind; - - firstvtx = graph->vtxdist[ctrl->mype]; - nnbrs = graph->nnbrs; - peind = graph->peind; - sendptr = graph->sendptr; - sendind = graph->sendind; - recvptr = graph->recvptr; - recvind = graph->recvind; - - /* Issue the receives first */ - for (i=0; icomm, ctrl->rreq+i); - } - - /* Issue the sends next */ - k = sendptr[nnbrs]; - for (i=0; icomm, ctrl->sreq+i); - } - - /* OK, now get into the loop waiting for the operations to finish */ - MPI_Waitall(nnbrs, ctrl->rreq, ctrl->statuses); - MPI_Waitall(nnbrs, ctrl->sreq, ctrl->statuses); - -} - - - -/************************************************************************* -* This function performs the gather/scatter for the boundary vertices -**************************************************************************/ -void CommChangedInterfaceData(CtrlType *ctrl, GraphType *graph, - int nchanged, idxtype *changed, idxtype *data, - KeyValueType *sendpairs, KeyValueType *recvpairs, idxtype *psendptr) -{ - int i, j, k, n, penum, nnbrs, firstvtx, nrecv; - idxtype *peind, *sendptr, *recvptr, *recvind, *pexadj, *peadjncy, *peadjloc; - KeyValueType *pairs; - - firstvtx = graph->vtxdist[ctrl->mype]; - nnbrs = graph->nnbrs; - nrecv = graph->nrecv; - peind = graph->peind; - sendptr = graph->sendptr; - recvptr = graph->recvptr; - recvind = graph->recvind; - pexadj = graph->pexadj; - peadjncy = graph->peadjncy; - peadjloc = graph->peadjloc; - - /* Issue the receives first */ - for (i=0; icomm, ctrl->rreq+i); - } - - if (nchanged != 0) { - idxcopy(ctrl->npes, sendptr, psendptr); - - /* Copy the changed values into the sendvector */ - for (i=0; icomm, ctrl->sreq+i); - } - } - else { - for (i=0; icomm, ctrl->sreq+i); - } - - /* OK, now get into the loop waiting for the operations to finish */ - for (i=0; irreq+i, &(ctrl->status)); - MPI_Get_count(&ctrl->status, IDX_DATATYPE, &n); - if (n != 0) { - n = n/2; - pairs = recvpairs+graph->recvptr[i]; - for (k=0; ksreq, ctrl->statuses); -} - - - -/************************************************************************* -* This function computes the max of a single element -**************************************************************************/ -int GlobalSEMax(CtrlType *ctrl, int value) -{ - int max; - - MPI_Allreduce((void *)&value, (void *)&max, 1, MPI_INT, MPI_MAX, ctrl->comm); - - return max; -} - -/************************************************************************* -* This function computes the max of a single element -**************************************************************************/ -double GlobalSEMaxDouble(CtrlType *ctrl, double value) -{ - double max; - - MPI_Allreduce((void *)&value, (void *)&max, 1, MPI_DOUBLE, MPI_MAX, ctrl->comm); - - return max; -} - - - -/************************************************************************* -* This function computes the max of a single element -**************************************************************************/ -int GlobalSEMin(CtrlType *ctrl, int value) -{ - int min; - - MPI_Allreduce((void *)&value, (void *)&min, 1, MPI_INT, MPI_MIN, ctrl->comm); - - return min; -} - -/************************************************************************* -* This function computes the max of a single element -**************************************************************************/ -int GlobalSESum(CtrlType *ctrl, int value) -{ - int sum; - - MPI_Allreduce((void *)&value, (void *)&sum, 1, MPI_INT, MPI_SUM, ctrl->comm); - - return sum; -} - - -/************************************************************************* -* This function computes the max of a single element -**************************************************************************/ -float GlobalSEMaxFloat(CtrlType *ctrl, float value) -{ - float max; - - MPI_Allreduce((void *)&value, (void *)&max, 1, MPI_FLOAT, MPI_MAX, ctrl->comm); - - return max; -} - - - -/************************************************************************* -* This function computes the max of a single element -**************************************************************************/ -float GlobalSEMinFloat(CtrlType *ctrl, float value) -{ - float min; - - MPI_Allreduce((void *)&value, (void *)&min, 1, MPI_FLOAT, MPI_MIN, ctrl->comm); - - return min; -} - -/************************************************************************* -* This function computes the max of a single element -**************************************************************************/ -float GlobalSESumFloat(CtrlType *ctrl, float value) -{ - float sum; - - MPI_Allreduce((void *)&value, (void *)&sum, 1, MPI_FLOAT, MPI_SUM, ctrl->comm); - - return sum; -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/csrmatch.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/csrmatch.c deleted file mode 100644 index ace7998..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/csrmatch.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * csrmatch.c - * - * This file contains the code that computes matchings - * - * Started 7/23/97 - * George - * - * $Id: csrmatch.c,v 1.2 2003/07/21 17:18:48 karypis Exp $ - * - */ - -#include - - - - -/************************************************************************* -* This function finds a matching using the HEM heuristic -**************************************************************************/ -void CSR_Match_SHEM(MatrixType *matrix, idxtype *match, idxtype *mlist, - idxtype *skip, int ncon) -{ - int h, i, ii, j; - int nrows, edge, maxidx, count; - float maxwgt; - idxtype *rowptr, *colind; - float *transfer; - KVType *links; - - nrows = matrix->nrows; - rowptr = matrix->rowptr; - colind = matrix->colind; - transfer = matrix->transfer; - - idxset(nrows, UNMATCHED, match); - - links = (KVType *)GKmalloc(sizeof(KVType)*nrows, "links"); - for (i=0; i - - -/************************************************************************* -* This function prints a vector stored in each processor -**************************************************************************/ -void PrintVector(CtrlType *ctrl, int n, int first, idxtype *vec, char *title) -{ - int i, penum; - - for (penum=0; penumnpes; penum++) { - if (ctrl->mype == penum) { - if (ctrl->mype == 0) - printf("%s\n", title); - printf("\t%3d. ", ctrl->mype); - for (i=0; icomm); - } -} - - -/************************************************************************* -* This function prints a vector stored in each processor -**************************************************************************/ -void PrintVector2(CtrlType *ctrl, int n, int first, idxtype *vec, char *title) -{ - int i, penum; - - for (penum=0; penumnpes; penum++) { - if (ctrl->mype == penum) { - if (ctrl->mype == 0) - printf("%s\n", title); - printf("\t%3d. ", ctrl->mype); - for (i=0; i=KEEP_BIT ? 1 : 0), (vec[i]>=KEEP_BIT ? vec[i]-KEEP_BIT : vec[i])); - printf("\n"); - fflush(stdout); - } - MPI_Barrier(ctrl->comm); - } -} - - -/************************************************************************* -* This function prints a vector stored in each processor -**************************************************************************/ -void PrintPairs(CtrlType *ctrl, int n, KeyValueType *pairs, char *title) -{ - int i, penum; - - for (penum=0; penumnpes; penum++) { - if (ctrl->mype == penum) { - if (ctrl->mype == 0) - printf("%s\n", title); - printf("\t%3d. ", ctrl->mype); - for (i=0; icomm); - } -} - - - -/************************************************************************* -* This function prints the local portion of the graph stored at each -* processor -**************************************************************************/ -void PrintGraph(CtrlType *ctrl, GraphType *graph) -{ - int i, j, penum; - int firstvtx; - - MPI_Barrier(ctrl->comm); - - firstvtx = graph->vtxdist[ctrl->mype]; - - for (penum=0; penumnpes; penum++) { - if (ctrl->mype == penum) { - printf("\t%d", penum); - for (i=0; invtxs; i++) { - if (i==0) - printf("\t%2d %2d\t", firstvtx+i, graph->vwgt[i]); - else - printf("\t\t%2d %2d\t", firstvtx+i, graph->vwgt[i]); - for (j=graph->xadj[i]; jxadj[i+1]; j++) - printf("[%d %d] ", graph->adjncy[j], graph->adjwgt[j]); - printf("\n"); - } - fflush(stdout); - } - MPI_Barrier(ctrl->comm); - } -} - - -/************************************************************************* -* This function prints the local portion of the graph stored at each -* processor along with degree information during refinement -**************************************************************************/ -void PrintGraph2(CtrlType *ctrl, GraphType *graph) -{ - int i, j, penum; - int firstvtx; - - MPI_Barrier(ctrl->comm); - - firstvtx = graph->vtxdist[ctrl->mype]; - - for (penum=0; penumnpes; penum++) { - if (ctrl->mype == penum) { - printf("\t%d", penum); - for (i=0; invtxs; i++) { - if (i==0) - printf("\t%2d %2d [%d %d %d]\t", firstvtx+i, graph->vwgt[i], graph->where[i], graph->rinfo[i].id, graph->rinfo[i].ed); - else - printf("\t\t%2d %2d [%d %d %d]\t", firstvtx+i, graph->vwgt[i], graph->where[i], graph->rinfo[i].id, graph->rinfo[i].ed); - for (j=graph->xadj[i]; jxadj[i+1]; j++) - printf("[%d %d] ", graph->adjncy[j], graph->adjwgt[j]); - printf("\n"); - } - fflush(stdout); - } - MPI_Barrier(ctrl->comm); - } -} - - -/************************************************************************* -* This function prints the information computed during setup -**************************************************************************/ -void PrintSetUpInfo(CtrlType *ctrl, GraphType *graph) -{ - int i, j, penum; - - MPI_Barrier(ctrl->comm); - - for (penum=0; penumnpes; penum++) { - if (ctrl->mype == penum) { - printf("PE: %d, nnbrs: %d\n", ctrl->mype, graph->nnbrs); - printf("\tSending...\n"); - for (i=0; innbrs; i++) { - printf("\t\tTo: %d: ", graph->peind[i]); - for (j=graph->sendptr[i]; jsendptr[i+1]; j++) - printf("%d ", graph->sendind[j]); - printf("\n"); - } - printf("\tReceiving...\n"); - for (i=0; innbrs; i++) { - printf("\t\tFrom: %d: ", graph->peind[i]); - for (j=graph->recvptr[i]; jrecvptr[i+1]; j++) - printf("%d ", graph->recvind[j]); - printf("\n"); - } - printf("\n"); - } - MPI_Barrier(ctrl->comm); - } - -} - - -/************************************************************************* -* This function prints information about the graphs that were sent/received -**************************************************************************/ -void PrintTransferedGraphs(CtrlType *ctrl, int nnbrs, idxtype *peind, idxtype *slens, - idxtype *rlens, idxtype *sgraph, idxtype *rgraph) -{ - int i, ii, jj, ll, penum; - - MPI_Barrier(ctrl->comm); - for (penum=0; penumnpes; penum++) { - if (ctrl->mype == penum) { - printf("PE: %d, nnbrs: %d", ctrl->mype, nnbrs); - for (ll=i=0; i 0) { - printf("\n\tTo %d\t", peind[i]); - for (ii=slens[i]; ii 0) { - printf("\n\tFrom %d\t", peind[i]); - for (ii=rlens[i]; iicomm); - } - -} - - -/************************************************************************* -* This function writes a graph in the format used by serial METIS -**************************************************************************/ -void WriteMetisGraph(int nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt) -{ - int i, j; - FILE *fp; - - fp = fopen("test.graph", "w"); - - fprintf(fp, "%d %d 11", nvtxs, xadj[nvtxs]/2); - for (i=0; i - - -/************************************************************************* -* This function computes the load for each subdomain -**************************************************************************/ -void SetUpConnectGraph(GraphType *graph, MatrixType *matrix, idxtype *workspace) -{ - int i, ii, j, jj, k, l; - int nvtxs, nrows; - idxtype *xadj, *adjncy, *where; - idxtype *rowptr, *colind; - idxtype *pcounts, *perm, *marker; - float *values; - - nvtxs = graph->nvtxs; - xadj = graph->xadj; - adjncy = graph->adjncy; - where = graph->where; - - nrows = matrix->nrows; - rowptr = matrix->rowptr; - colind = matrix->colind; - values = matrix->values; - - perm = workspace; - marker = idxset(nrows, -1, workspace+nvtxs); - pcounts = idxset(nrows+1, 0, workspace+nvtxs+nrows); - - for (i=0; i0; i--) - pcounts[i] = pcounts[i-1]; - pcounts[0] = 0; - - /************************/ - /* Construct the matrix */ - /************************/ - rowptr[0] = k = 0; - for (ii=0; iinnzs = rowptr[nrows]; - - return; -} - - -/************************************************************************* -* This function computes movement statistics for adaptive refinement -* schemes -**************************************************************************/ -void Mc_ComputeMoveStatistics(CtrlType *ctrl, GraphType *graph, int *nmoved, int *maxin, int *maxout) -{ - int i, nvtxs, nparts, myhome; - idxtype *vwgt, *where; - idxtype *lend, *gend, *lleft, *gleft, *lstart, *gstart; - - nvtxs = graph->nvtxs; - vwgt = graph->vwgt; - where = graph->where; - nparts = ctrl->nparts; - - lstart = idxsmalloc(nparts, 0, "ComputeMoveStatistics: lstart"); - gstart = idxsmalloc(nparts, 0, "ComputeMoveStatistics: gstart"); - lleft = idxsmalloc(nparts, 0, "ComputeMoveStatistics: lleft"); - gleft = idxsmalloc(nparts, 0, "ComputeMoveStatistics: gleft"); - lend = idxsmalloc(nparts, 0, "ComputeMoveStatistics: lend"); - gend = idxsmalloc(nparts, 0, "ComputeMoveStatistics: gend"); - - for (i=0; ips_relation == COUPLED) ? ctrl->mype : graph->home[i]; - lstart[myhome] += (graph->vsize == NULL) ? 1 : graph->vsize[i]; - lend[where[i]] += (graph->vsize == NULL) ? 1 : graph->vsize[i]; - if (where[i] != myhome) - lleft[myhome] += (graph->vsize == NULL) ? 1 : graph->vsize[i]; - } - - /* PrintVector(ctrl, ctrl->npes, 0, lend, "Lend: "); */ - - MPI_Allreduce((void *)lstart, (void *)gstart, nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); - MPI_Allreduce((void *)lleft, (void *)gleft, nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); - MPI_Allreduce((void *)lend, (void *)gend, nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); - - *nmoved = idxsum(nparts, gleft); - *maxout = gleft[idxamax(nparts, gleft)]; - for (i=0; invtxs; i++) { - if (graph->where[i] != home[i]) - totalv += (graph->vsize == NULL) ? graph->vwgt[i*graph->ncon] : graph->vsize[i]; - } - - return totalv; -} - - - -/************************************************************************* -* This function computes the load for each subdomain -**************************************************************************/ -void ComputeLoad(GraphType *graph, int nparts, float *load, float *tpwgts, int index) -{ - int i; - int nvtxs, ncon; - idxtype *where; - float *nvwgt; - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - where = graph->where; - nvwgt = graph->nvwgt; - - sset(nparts, 0.0, load); - - for (i=0; inrows; - rowptr = A->rowptr; - colind = A->colind; - values = A->values; - - /* Initial Setup */ - p = workspace; - r = workspace + n; - q = workspace + 2*n; - z = workspace + 3*n; - M = workspace + 4*n; - - for (i=0; i 0.0) { - error = snorm2(n, r) / bnrm2; - - if (error > tol) { - /* Begin Iterations */ - for (k=0; knrows; i++) - w[i] = 0.0; - - for (i = 0; i < A->nrows; i++) - for (j = A->rowptr[i]; j < A->rowptr[i+1]; j++) - w[i] += A->values[j] * v[A->colind[j]]; - - return; - } - - -/************************************************************************* -* This function sets up the transfer vectors -**************************************************************************/ -void ComputeTransferVector(int ncon, MatrixType *matrix, float *solution, - float *transfer, int index) -{ - int j, k; - int nrows; - idxtype *rowptr, *colind; - - nrows = matrix->nrows; - rowptr = matrix->rowptr; - colind = matrix->colind; - - for (j=0; j solution[colind[k]]) { - transfer[k*ncon+index] = solution[j] - solution[colind[k]]; - } - else { - transfer[k*ncon+index] = 0.0; - } - } - } -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/fpqueue.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/fpqueue.c deleted file mode 100644 index 11c617f..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/fpqueue.c +++ /dev/null @@ -1,440 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * fpqueue.c - * - * This file contains functions for manipulating the bucket list - * representation of the gains associated with each vertex in a graph. - * These functions are used by the refinement algorithms - * - * Started 9/2/94 - * George - * - * $Id: fpqueue.c,v 1.2 2003/07/21 17:18:48 karypis Exp $ - * - */ - -#include - - -/************************************************************************* -* This function initializes the data structures of the priority queue -**************************************************************************/ -void FPQueueInit(FPQueueType *queue, int maxnodes) -{ - queue->nnodes = 0; - queue->maxnodes = maxnodes; - queue->heap = NULL; - queue->locator = NULL; - - queue->heap = (FKeyValueType *) malloc(sizeof(FKeyValueType)*maxnodes); - queue->locator = (idxtype *) malloc(sizeof(idxtype)*maxnodes); - - idxset(maxnodes, -1, queue->locator); - -} - - -/************************************************************************* -* This function resets the buckets -**************************************************************************/ -void FPQueueReset(FPQueueType *queue) -{ - queue->nnodes = 0; - - idxset(queue->maxnodes, -1, queue->locator); - -} - - -/************************************************************************* -* This function frees the buckets -**************************************************************************/ -void FPQueueFree(FPQueueType *queue) -{ - - free(queue->heap); - free(queue->locator); - - queue->maxnodes = 0; -} - - -/************************************************************************* -* This function returns the number of nodes in the queue -**************************************************************************/ -int FPQueueGetSize(FPQueueType *queue) -{ - return queue->nnodes; -} - - -/************************************************************************* -* This function adds a node of certain gain into a partition -**************************************************************************/ -int FPQueueInsert(FPQueueType *queue, int node, float gain) -{ - int i, j; - idxtype *locator; - FKeyValueType *heap; - - ASSERTS(CheckHeapFloat(queue)); - - heap = queue->heap; - locator = queue->locator; - - ASSERTS(locator[node] == -1); - - i = queue->nnodes++; - while (i > 0) { - j = (i-1)/2; - if (heap[j].key < gain) { - heap[i] = heap[j]; - locator[heap[i].val] = i; - i = j; - } - else - break; - } - ASSERTS(i >= 0); - heap[i].key = gain; - heap[i].val = node; - locator[node] = i; - - ASSERTS(CheckHeapFloat(queue)); - - return 0; -} - - -/************************************************************************* -* This function deletes a node from a partition and reinserts it with -* an updated gain -**************************************************************************/ -int FPQueueDelete(FPQueueType *queue, int node) -{ - int i, j; - float newgain, oldgain; - idxtype *locator; - FKeyValueType *heap; - - heap = queue->heap; - locator = queue->locator; - - ASSERTS(locator[node] != -1); - ASSERTS(heap[locator[node]].val == node); - - ASSERTS(CheckHeapFloat(queue)); - - i = locator[node]; - locator[node] = -1; - - if (--queue->nnodes > 0 && heap[queue->nnodes].val != node) { - node = heap[queue->nnodes].val; - newgain = heap[queue->nnodes].key; - oldgain = heap[i].key; - - if (oldgain < newgain) { - /* Filter-up */ - while (i > 0) { - j = (i-1)>>1; - if (heap[j].key < newgain) { - heap[i] = heap[j]; - locator[heap[i].val] = i; - i = j; - } - else - break; - } - } - else { - /* Filter down */ - while ((j=2*i+1) < queue->nnodes) { - if (heap[j].key > newgain) { - if (j+1 < queue->nnodes && heap[j+1].key > heap[j].key) - j = j+1; - heap[i] = heap[j]; - locator[heap[i].val] = i; - i = j; - } - else if (j+1 < queue->nnodes && heap[j+1].key > newgain) { - j = j+1; - heap[i] = heap[j]; - locator[heap[i].val] = i; - i = j; - } - else - break; - } - } - - heap[i].key = newgain; - heap[i].val = node; - locator[node] = i; - } - - ASSERTS(CheckHeapFloat(queue)); - - return 0; -} - - - -/************************************************************************* -* This function deletes a node from a partition and reinserts it with -* an updated gain -**************************************************************************/ -int FPQueueUpdate(FPQueueType *queue, int node, float oldgain, float newgain) -{ - int i, j; - idxtype *locator; - FKeyValueType *heap; - - if (oldgain == newgain) - return 0; - - heap = queue->heap; - locator = queue->locator; - - ASSERTS(locator[node] != -1); - ASSERTS(heap[locator[node]].val == node); - ASSERTS(fabs(heap[locator[node]].key - oldgain) < SMALLFLOAT); - ASSERTS(CheckHeapFloat(queue)); - - i = locator[node]; - - if (oldgain < newgain) { - /* Filter-up */ - while (i > 0) { - j = (i-1)>>1; - if (heap[j].key < newgain) { - heap[i] = heap[j]; - locator[heap[i].val] = i; - i = j; - } - else - break; - } - } - else { - /* Filter down */ - while ((j=2*i+1) < queue->nnodes) { - if (heap[j].key > newgain) { - if (j+1 < queue->nnodes && heap[j+1].key > heap[j].key) - j = j+1; - heap[i] = heap[j]; - locator[heap[i].val] = i; - i = j; - } - else if (j+1 < queue->nnodes && heap[j+1].key > newgain) { - j = j+1; - heap[i] = heap[j]; - locator[heap[i].val] = i; - i = j; - } - else - break; - } - } - - heap[i].key = newgain; - heap[i].val = node; - locator[node] = i; - - ASSERTS(CheckHeapFloat(queue)); - - return 0; -} - - - -/************************************************************************* -* This function deletes a node from a partition and reinserts it with -* an updated gain -**************************************************************************/ -void FPQueueUpdateUp(FPQueueType *queue, int node, float oldgain, float newgain) -{ - int i, j; - idxtype *locator; - FKeyValueType *heap; - - if (oldgain == newgain) - return; - - heap = queue->heap; - locator = queue->locator; - - ASSERTS(locator[node] != -1); - ASSERTS(heap[locator[node]].val == node); - ASSERTS(heap[locator[node]].key == oldgain); - ASSERTS(CheckHeapFloat(queue)); - - - /* Here we are just filtering up since the newgain is greater than the oldgain */ - i = locator[node]; - while (i > 0) { - j = (i-1)>>1; - if (heap[j].key < newgain) { - heap[i] = heap[j]; - locator[heap[i].val] = i; - i = j; - } - else - break; - } - - heap[i].key = newgain; - heap[i].val = node; - locator[node] = i; - - ASSERTS(CheckHeapFloat(queue)); - -} - - -/************************************************************************* -* This function returns the vertex with the largest gain from a partition -* and removes the node from the bucket list -**************************************************************************/ -int FPQueueGetMax(FPQueueType *queue) -{ - int vtx, i, j, node; - float gain; - idxtype *locator; - FKeyValueType *heap; - - if (queue->nnodes == 0) - return -1; - - queue->nnodes--; - - heap = queue->heap; - locator = queue->locator; - - vtx = heap[0].val; - locator[vtx] = -1; - - if ((i = queue->nnodes) > 0) { - gain = heap[i].key; - node = heap[i].val; - i = 0; - while ((j=2*i+1) < queue->nnodes) { - if (heap[j].key > gain) { - if (j+1 < queue->nnodes && heap[j+1].key > heap[j].key) - j = j+1; - heap[i] = heap[j]; - locator[heap[i].val] = i; - i = j; - } - else if (j+1 < queue->nnodes && heap[j+1].key > gain) { - j = j+1; - heap[i] = heap[j]; - locator[heap[i].val] = i; - i = j; - } - else - break; - } - - heap[i].key = gain; - heap[i].val = node; - locator[node] = i; - } - - ASSERTS(CheckHeapFloat(queue)); - return vtx; -} - - -/************************************************************************* -* This function returns the vertex with the largest gain from a partition -**************************************************************************/ -int FPQueueSeeMaxVtx(FPQueueType *queue) -{ - int vtx; - - if (queue->nnodes == 0) - return -1; - - vtx = queue->heap[0].val; - - return vtx; -} - - -/************************************************************************* -* This function returns the vertex with the largest gain from a partition -**************************************************************************/ -float FPQueueSeeMaxGain(FPQueueType *queue) -{ - float gain; - - if (queue->nnodes == 0) - return 0.0; - - gain = queue->heap[0].key; - - return gain; -} - - -/************************************************************************* -* This function returns the vertex with the largest gain from a partition -**************************************************************************/ -float FPQueueGetKey(FPQueueType *queue) -{ - int key; - - if (queue->nnodes == 0) - return -1; - - key = queue->heap[0].key; - - return key; -} - -/************************************************************************* -* This function returns the number of nodes in the queue -**************************************************************************/ -int FPQueueGetQSize(FPQueueType *queue) -{ - return queue->nnodes; -} - - - - - - -/************************************************************************* -* This functions checks the consistency of the heap -**************************************************************************/ -int CheckHeapFloat(FPQueueType *queue) -{ - int i, j, nnodes; - idxtype *locator; - FKeyValueType *heap; - - heap = queue->heap; - locator = queue->locator; - nnodes = queue->nnodes; - - if (nnodes == 0) - return 1; - - ASSERTS(locator[heap[0].val] == 0); - for (i=1; imaxnodes; i++) { - if (locator[i] != -1) - j++; - } - ASSERTS(j == nnodes); - - return 1; -} diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/frename.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/frename.c deleted file mode 100644 index 551dd59..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/frename.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * frename.c - * - * This file contains some renaming routines to deal with different - * Fortran compilers. - * - * Started 6/1/98 - * George - * - * $Id: frename.c,v 1.4 2003/07/30 18:37:58 karypis Exp $ - * - */ - -#include - - - -/************************************************************************* -* Renaming macro (at least to save some typing :)) -**************************************************************************/ -#define FRENAME(name0, name1, name2, name3, name4, dargs, cargs) \ - void name1 dargs { name0 cargs; } \ - void name2 dargs { name0 cargs; } \ - void name3 dargs { name0 cargs; } \ - void name4 dargs { name0 cargs; } - - - - - - - - -/************************************************************************* -* Renames for Release 3.0 API -**************************************************************************/ -FRENAME(ParMETIS_V3_AdaptiveRepart, - PARMETIS_V3_ADAPTIVEREPART, - parmetis_v3_adaptiverepart, - parmetis_v3_adaptiverepart_, - parmetis_v3_adaptiverepart__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, - idxtype *vsize, idxtype *adjwgt, int *wgtflag, int *numflag, int *ncon, - int *nparts, float *tpwgts, float *ubvec, float *ipc2redist, - int *options, int *edgecut, idxtype *part, MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, vsize, adjwgt, wgtflag, numflag, ncon, - nparts, tpwgts, ubvec, ipc2redist, options, edgecut, part, comm) -) - -FRENAME(ParMETIS_V3_PartGeomKway, - PARMETIS_V3_PARTGEOMKWAY, - parmetis_v3_partgeomkway, - parmetis_v3_partgeomkway_, - parmetis_v3_partgeomkway__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, - idxtype *adjwgt, int *wgtflag, int *numflag, int *ndims, float *xyz, - int *ncon, int *nparts, float *tpwgts, float *ubvec, int *options, - int *edgecut, idxtype *part, MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ndims, xyz, - ncon, nparts, tpwgts, ubvec, options, edgecut, part, comm) -) - -FRENAME(ParMETIS_V3_PartGeom, - PARMETIS_V3_PARTGEOM, - parmetis_v3_partgeom, - parmetis_v3_partgeom_, - parmetis_v3_partgeom__, - (idxtype *vtxdist, int *ndims, float *xyz, idxtype *part, MPI_Comm *comm), - (vtxdist, ndims, xyz, part, comm) -) - -FRENAME(ParMETIS_V3_PartKway, - PARMETIS_V3_PARTKWAY, - parmetis_v3_partkway, - parmetis_v3_partkway_, - parmetis_v3_partkway__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, - int *wgtflag, int *numflag, int *ncon, int *nparts, float *tpwgts, float *ubvec, - int *options, int *edgecut, idxtype *part, MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ncon, nparts, tpwgts, - ubvec, options, edgecut, part, comm) -) - -FRENAME(ParMETIS_V3_Mesh2Dual, - PARMETIS_V3_MESH2DUAL, - parmetis_v3_mesh2dual, - parmetis_v3_mesh2dual_, - parmetis_v3_mesh2dual__, - (idxtype *elmdist, idxtype *eptr, idxtype *eind, int *numflag, int *ncommonnodes, - idxtype **xadj, idxtype **adjncy, MPI_Comm *comm), - (elmdist, eptr, eind, numflag, ncommonnodes, xadj, adjncy, comm) -) - -FRENAME(ParMETIS_V3_PartMeshKway, - PARMETIS_V3_PARTMESHKWAY, - parmetis_v3_partmeshkway, - parmetis_v3_partmeshkway_, - parmetis_v3_partmeshkway__, - (idxtype *elmdist, idxtype *eptr, idxtype *eind, idxtype *elmwgt, int *wgtflag, - int *numflag, int *ncon, int *ncommonnodes, int *nparts, float *tpwgts, - float *ubvec, int *options, int *edgecut, idxtype *part, MPI_Comm *comm), - (elmdist, eptr, eind, elmwgt, wgtflag, numflag, ncon, ncommonnodes, nparts, tpwgts, - ubvec, options, edgecut, part, comm) -) - -FRENAME(ParMETIS_V3_NodeND, - PARMETIS_V3_NODEND, - parmetis_v3_nodend, - parmetis_v3_nodend_, - parmetis_v3_nodend__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, int *numflag, int *options, - idxtype *order, idxtype *sizes, MPI_Comm *comm), - (vtxdist, xadj, adjncy, numflag, options, order, sizes, comm) -) - -FRENAME(ParMETIS_V3_RefineKway, - PARMETIS_V3_REFINEKWAY, - parmetis_v3_refinekway, - parmetis_v3_refinekway_, - parmetis_v3_refinekway__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, - int *wgtflag, int *numflag, int *ncon, int *nparts, float *tpwgts, float *ubvec, - int *options, int *edgecut, idxtype *part, MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ncon, nparts, tpwgts, - ubvec, options, edgecut, part, comm) -) - - -/************************************************************************* -* Renames for Release 2.0 API -**************************************************************************/ -FRENAME(ParMETIS_PartKway, - PARMETIS_PARTKWAY, - parmetis_partkway, - parmetis_partkway_, - parmetis_partkway__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, - int *wgtflag, int *numflag, int *nparts, int *options, int *edgecut, idxtype *part, - MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, nparts, options, edgecut, - part, comm) -) - -FRENAME(ParMETIS_PartGeomKway, - PARMETIS_PARTGEOMKWAY, - parmetis_partgeomkway, - parmetis_partgeomkway_, - parmetis_partgeomkway__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, - int *wgtflag, int *numflag, int *ndims, float *xyz, int *nparts, int *options, - int *edgecut, idxtype *part, MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ndims, xyz, nparts, options, - edgecut, part, comm) -) - -FRENAME(ParMETIS_PartGeom, - PARMETIS_PARTGEOM, - parmetis_partgeom, - parmetis_partgeom_, - parmetis_partgeom__, - (idxtype *vtxdist, int *ndims, float *xyz, idxtype *part, MPI_Comm *comm), - (vtxdist, ndims, xyz, part, comm) -) - -FRENAME(ParMETIS_PartGeomRefine, - PARMETIS_PARTGEOMREFINE, - parmetis_partgeomrefine, - parmetis_partgeomrefine_, - parmetis_partgeomrefine__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, - int *wgtflag, int *numflag, int *ndims, float *xyz, int *options, int *edgecut, - idxtype *part, MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ndims, xyz, options, - edgecut, part, comm) -) - -FRENAME(ParMETIS_RefineKway, - PARMETIS_REFINEKWAY, - parmetis_refinekway, - parmetis_refinekway_, - parmetis_refinekway__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, - int *wgtflag, int *numflag, int *options, int *edgecut, idxtype *part, MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, options, edgecut, part, comm) -) - -FRENAME(ParMETIS_RepartLDiffusion, - PARMETIS_REPARTLDIFUSSION, - parmetis_repartldiffusion, - parmetis_repartldiffusion_, - parmetis_repartldiffusion__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, - int *wgtflag, int *numflag, int *options, int *edgecut, idxtype *part, MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, options, edgecut, part, comm) -) - -FRENAME(ParMETIS_RepartGDiffusion, - PARMETIS_REPARTGDIFFUSION, - parmetis_repartgdiffusion, - parmetis_repartgdiffusion_, - parmetis_repartgdiffusion__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, - int *wgtflag, int *numflag, int *options, int *edgecut, idxtype *part, MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, options, edgecut, part, comm) -) - -FRENAME(ParMETIS_RepartRemap, - PARMETIS_REPARTREMAP, - parmetis_repartremap, - parmetis_repartremap_, - parmetis_repartremap__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, - int *wgtflag, int *numflag, int *options, int *edgecut, idxtype *part, MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, options, edgecut, part, comm) -) - -FRENAME(ParMETIS_RepartMLRemap, - PARMETIS_REPARTMLREMAP, - parmetis_repartmlremap, - parmetis_repartmlremap_, - parmetis_repartmlremap__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, - int *wgtflag, int *numflag, int *options, int *edgecut, idxtype *part, MPI_Comm *comm), - (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, options, edgecut, part, comm) -) - -FRENAME(ParMETIS_NodeND, - PARMETIS_NODEND, - parmetis_nodend, - parmetis_nodend_, - parmetis_nodend__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, int *numflag, int *options, - idxtype *order, idxtype *sizes, MPI_Comm *comm), - (vtxdist, xadj, adjncy, numflag, options, order, sizes, comm) -) - -FRENAME(ParMETIS_SerialNodeND, - PARMETIS_SERIALNODEND, - parmetis_serialnodend, - parmetis_serialnodend_, - parmetis_serialnodend__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, int *numflag, int *options, - idxtype *order, idxtype *sizes, MPI_Comm *comm), - (vtxdist, xadj, adjncy, numflag, options, order, sizes, comm) -) - - - - -/************************************************************************* -* Renames for Release 1.0 API -**************************************************************************/ -FRENAME(PARKMETIS, - PARKMETIS_, - parkmetis, - parkmetis_, - parkmetis__, - (idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt, - idxtype *part, int *options, MPI_Comm comm), - (vtxdist, xadj, vwgt, adjncy, adjwgt, part, options, comm) -) - -FRENAME(PARGKMETIS, - PARGKMETIS_, - pargkmetis, - pargkmetis_, - pargkmetis__, - (idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt, - int ndims, float *xyz, idxtype *part, int *options, MPI_Comm comm), - (vtxdist, xadj, vwgt, adjncy, adjwgt, ndims, xyz, part, options, comm) -) - -FRENAME(PARGRMETIS, - PARGRMETIS_, - pargrmetis, - pargrmetis_, - pargrmetis__, - (idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt, - int ndims, float *xyz, idxtype *part, int *options, MPI_Comm comm), - (vtxdist, xadj, vwgt, adjncy, adjwgt, ndims, xyz, part, options, comm) -) - -FRENAME(PARGMETIS, - PARGMETIS_, - pargmetis, - pargmetis_, - pargmetis__, - (idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, int ndims, float *xyz, - idxtype *part, int *options, MPI_Comm comm), - (vtxdist, xadj, adjncy, ndims, xyz, part, options, comm) -) - -FRENAME(PARRMETIS, - PARRMETIS_, - parrmetis, - parrmetis_, - parrmetis__, - (idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt, - idxtype *part, int *options, MPI_Comm comm), - (vtxdist, xadj, vwgt, adjncy, adjwgt, part, options, comm) -) - -FRENAME(PARUAMETIS, - PARUAMETIS_, - paruametis, - paruametis_, - paruametis__, - (idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt, - idxtype *part, int *options, MPI_Comm comm), - (vtxdist, xadj, vwgt, adjncy, adjwgt, part, options, comm) -) - -FRENAME(PARDAMETIS, - PARDAMETIS_, - pardametis, - pardametis_, - pardametis__, - (idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt, - idxtype *part, int *options, MPI_Comm comm), - (vtxdist, xadj, vwgt, adjncy, adjwgt, part, options, comm) -) - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/gkmetis.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/gkmetis.c deleted file mode 100644 index 8eb2382..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/gkmetis.c +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * gkmetis.c - * - * This is the entry point of parallel geometry based partitioning - * routines - * - * Started 10/19/96 - * George - * - * $Id: gkmetis.c,v 1.8 2003/07/31 16:23:30 karypis Exp $ - * - */ - -#include - - - - -/*********************************************************************************** -* This function is the entry point of the parallel kmetis algorithm that uses -* coordinates to compute an initial graph distribution. -************************************************************************************/ -void ParMETIS_V3_PartGeomKway(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, - idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *ndims, - float *xyz, int *ncon, int *nparts, float *tpwgts, float *ubvec, - int *options, int *edgecut, idxtype *part, MPI_Comm *comm) -{ - int h, i, j; - int nvtxs = -1, npes, mype; - int uwgtflag, cut, gcut, maxnvtxs; - int ltvwgts[MAXNCON]; - int moptions[10]; - CtrlType ctrl; - idxtype *uvwgt; - WorkSpaceType wspace; - GraphType *graph, *mgraph; - float avg, maximb, balance, *mytpwgts; - int seed, dbglvl = 0; - int iwgtflag, inumflag, incon, inparts, ioptions[10]; - float *itpwgts, iubvec[MAXNCON]; - - MPI_Comm_size(*comm, &npes); - MPI_Comm_rank(*comm, &mype); - - /********************************/ - /* Try and take care bad inputs */ - /********************************/ - if (options != NULL && options[0] == 1) - dbglvl = options[PMV3_OPTION_DBGLVL]; - - CheckInputs(STATIC_PARTITION, npes, dbglvl, wgtflag, &iwgtflag, numflag, &inumflag, - ncon, &incon, nparts, &inparts, tpwgts, &itpwgts, ubvec, iubvec, - NULL, NULL, options, ioptions, part, comm); - - - /*********************************/ - /* Take care the nparts = 1 case */ - /*********************************/ - if (inparts <= 1) { - idxset(vtxdist[mype+1]-vtxdist[mype], 0, part); - *edgecut = 0; - return; - } - - /******************************/ - /* Take care of npes = 1 case */ - /******************************/ - if (npes == 1 && inparts > 1) { - moptions[0] = 0; - nvtxs = vtxdist[1]; - - if (incon == 1) { - METIS_WPartGraphKway(&nvtxs, xadj, adjncy, vwgt, adjwgt, &iwgtflag, &inumflag, - &inparts, itpwgts, moptions, edgecut, part); - } - else { - /* ADD: this is because METIS does not support tpwgts for all constraints */ - mytpwgts = fmalloc(inparts, "mytpwgts"); - for (i=0; invwgt); graph->nvwgt = NULL; - - PreAllocateMemory(&ctrl, graph, &wspace); - - /*================================================================= - * Compute the initial npes-way partitioning geometric partitioning - =================================================================*/ - IFSET(ctrl.dbglvl, DBG_TIME, InitTimers(&ctrl)); - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.TotalTmr)); - - Coordinate_Partition(&ctrl, graph, *ndims, xyz, 1, &wspace); - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.TotalTmr)); - IFSET(ctrl.dbglvl, DBG_TIME, PrintTimingInfo(&ctrl)); - - /*================================================================= - * Move the graph according to the partitioning - =================================================================*/ - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.MoveTmr)); - - free(uvwgt); - graph->vwgt = ((iwgtflag&2) != 0) ? vwgt : idxsmalloc(graph->nvtxs*incon, 1, "vwgt"); - graph->ncon = incon; - j = ctrl.nparts; - ctrl.nparts = ctrl.npes; - mgraph = Moc_MoveGraph(&ctrl, graph, &wspace); - ctrl.nparts = j; - - /**********************************************************/ - /* Do the same functionality as Moc_SetUpGraph for mgraph */ - /**********************************************************/ - /* compute tvwgts */ - for (j=0; jnvtxs; i++) - for (j=0; jvwgt[i*incon+j]; - - for (j=0; jnvwgt = fmalloc(mgraph->nvtxs*incon, "mgraph->nvwgt"); - for (i=0; invtxs; i++) - for (j=0; jnvwgt[i*incon+j] = (float)(mgraph->vwgt[i*incon+j]) / (float)(ctrl.tvwgts[j]); - - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.MoveTmr)); - - if (ctrl.dbglvl&DBG_INFO) { - cut = 0; - for (i=0; invtxs; i++) - for (j=graph->xadj[i]; jxadj[i+1]; j++) - if (graph->where[i] != graph->where[graph->adjncy[j]]) - cut += graph->adjwgt[j]; - gcut = GlobalSESum(&ctrl, cut)/2; - maxnvtxs = GlobalSEMax(&ctrl, mgraph->nvtxs); - balance = (float)(maxnvtxs)/((float)(graph->gnvtxs)/(float)(npes)); - rprintf(&ctrl, "XYZ Cut: %6d \tBalance: %6.3f [%d %d %d]\n", - gcut, balance, maxnvtxs, graph->gnvtxs, npes); - - } - - /*================================================================= - * Set up the newly moved graph - =================================================================*/ - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.TotalTmr)); - - ctrl.nparts = inparts; - FreeWSpace(&wspace); - PreAllocateMemory(&ctrl, mgraph, &wspace); - - /*======================================================= - * Now compute the partition of the moved graph - =======================================================*/ - if (vtxdist[npes] < SMALLGRAPH || vtxdist[npes] < npes*20 || GlobalSESum(&ctrl, mgraph->nedges) == 0) { - IFSET(ctrl.dbglvl, DBG_INFO, rprintf(&ctrl, "Partitioning a graph of size %d serially\n", vtxdist[npes])); - PartitionSmallGraph(&ctrl, mgraph, &wspace); - } - else { - Moc_Global_Partition(&ctrl, mgraph, &wspace); - } - ParallelReMapGraph(&ctrl, mgraph, &wspace); - - /* Invert the ordering back to the original graph */ - ctrl.nparts = npes; - ProjectInfoBack(&ctrl, graph, part, mgraph->where, &wspace); - - *edgecut = mgraph->mincut; - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.TotalTmr)); - - /*******************/ - /* Print out stats */ - /*******************/ - IFSET(ctrl.dbglvl, DBG_TIME, PrintTimingInfo(&ctrl)); - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - - if (ctrl.dbglvl&DBG_INFO) { - rprintf(&ctrl, "Final %d-way CUT: %6d \tBalance: ", inparts, mgraph->mincut); - avg = 0.0; - for (h=0; hgnpwgts[i*incon+h]/itpwgts[i*incon+h]); - avg += maximb; - rprintf(&ctrl, "%.3f ", maximb); - } - rprintf(&ctrl, " avg: %.3f\n", avg/(float)incon); - } - - GKfree((void **)&itpwgts, LTERM); - FreeGraph(mgraph); - FreeInitialGraphAndRemap(graph, iwgtflag); - FreeWSpace(&wspace); - FreeCtrl(&ctrl); - - if (inumflag == 1) - ChangeNumbering(vtxdist, xadj, adjncy, part, npes, mype, 0); - -} - - - -/*********************************************************************************** -* This function is the entry point of the parallel ordering algorithm. -* This function assumes that the graph is already nice partitioned among the -* processors and then proceeds to perform recursive bisection. -************************************************************************************/ -void ParMETIS_V3_PartGeom(idxtype *vtxdist, int *ndims, float *xyz, idxtype *part, MPI_Comm *comm) -{ - int i, npes, mype, nvtxs, firstvtx, dbglvl; - idxtype *xadj, *adjncy; - CtrlType ctrl; - WorkSpaceType wspace; - GraphType *graph; - int zeroflg = 0; - - MPI_Comm_size(*comm, &npes); - MPI_Comm_rank(*comm, &mype); - - if (npes == 1) { - idxset(vtxdist[mype+1]-vtxdist[mype], 0, part); - return; - } - - /* Setup a fake graph to allow the rest of the code to work unchanged */ - dbglvl = 0; - - nvtxs = vtxdist[mype+1]-vtxdist[mype]; - firstvtx = vtxdist[mype]; - xadj = idxmalloc(nvtxs+1, "ParMETIS_PartGeom: xadj"); - adjncy = idxmalloc(nvtxs, "ParMETIS_PartGeom: adjncy"); - for (i=0; invtxs, graph->where, part); - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.TotalTmr)); - IFSET(ctrl.dbglvl, DBG_TIME, PrintTimingInfo(&ctrl)); - - FreeInitialGraphAndRemap(graph, 0); - FreeWSpace(&wspace); - FreeCtrl(&ctrl); - - GKfree((void **)&xadj, (void **)&adjncy, LTERM); -} - - - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/grsetup.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/grsetup.c deleted file mode 100644 index 7f10a8f..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/grsetup.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * mgrsetup.c - * - * This file contain various graph setting up routines - * - * Started 10/19/96 - * George - * - * $Id: grsetup.c,v 1.7 2003/07/23 00:54:55 karypis Exp $ - * - */ - -#include - - - -/************************************************************************* -* This function setsup the CtrlType structure -**************************************************************************/ -GraphType *Moc_SetUpGraph(CtrlType *ctrl, int ncon, idxtype *vtxdist, idxtype *xadj, - idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt, int *wgtflag) -{ - int i, j; - GraphType *graph; - int ltvwgts[MAXNCON]; - - graph = CreateGraph(); - graph->level = 0; - graph->gnvtxs = vtxdist[ctrl->npes]; - graph->nvtxs = vtxdist[ctrl->mype+1]-vtxdist[ctrl->mype]; - graph->ncon = ncon; - graph->nedges = xadj[graph->nvtxs]; - graph->xadj = xadj; - graph->vwgt = vwgt; - graph->adjncy = adjncy; - graph->adjwgt = adjwgt; - graph->vtxdist = vtxdist; - - - if (((*wgtflag)&2) == 0) - graph->vwgt = idxsmalloc(graph->nvtxs*ncon, 1, "Par_KMetis: vwgt"); - - if (((*wgtflag)&1) == 0) - graph->adjwgt = idxsmalloc(graph->nedges, 1, "Par_KMetis: adjwgt"); - - /* compute tvwgts */ - for (j=0; jnvtxs; i++) - for (j=0; jvwgt[i*ncon+j]; - - for (j=0; jtvwgts[j] = GlobalSESum(ctrl, ltvwgts[j]); - - /* check for zero wgt constraints */ - for (i=0; itvwgts[i] == 0) { - rprintf(ctrl, "ERROR: sum weight for constraint %d is zero\n", i); - MPI_Finalize(); - exit(-1); - } - } - - /* compute nvwgts */ - graph->nvwgt = fmalloc(graph->nvtxs*ncon, "graph->nvwgt"); - for (i=0; invtxs; i++) { - for (j=0; jnvwgt[i*ncon+j] = (float)(graph->vwgt[i*ncon+j]) / (float)(ctrl->tvwgts[j]); - } - - srand(ctrl->seed); - - return graph; -} - - -/************************************************************************* -* This function setsup the CtrlType structure -**************************************************************************/ -void SetUpCtrl(CtrlType *ctrl, int nparts, int dbglvl, MPI_Comm comm) -{ - - MPI_Comm_dup(comm, &(ctrl->gcomm)); - MPI_Comm_rank(ctrl->gcomm, &ctrl->mype); - MPI_Comm_size(ctrl->gcomm, &ctrl->npes); - - ctrl->dbglvl = dbglvl; - ctrl->nparts = nparts; /* Set the # of partitions is de-coupled from the # of domains */ - ctrl->comm = ctrl->gcomm; - ctrl->xyztype = XYZ_SPFILL; - - srand(ctrl->mype); -} - - -/************************************************************************* -* This function changes the numbering from 1 to 0 or 0 to 1 -**************************************************************************/ -void ChangeNumbering(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *part, int npes, int mype, int from) -{ - int i, nvtxs, nedges; - - if (from == 1) { /* Change it from 1 to 0 */ - for (i=0; invtxs; i++) { - for (j=graph->xadj[i]; jxadj[i+1]; j++) { - k = graph->xadj[i] + RandomInRange(graph->xadj[i+1]-graph->xadj[i]); - SWAP(graph->adjncy[j], graph->adjncy[k], tmp); - SWAP(graph->adjwgt[j], graph->adjwgt[k], tmp); - } - } -} - - -/************************************************************************* -* This function computes movement statistics for adaptive refinement -* schemes -**************************************************************************/ -void ComputeMoveStatistics(CtrlType *ctrl, GraphType *graph, int *nmoved, int *maxin, int *maxout) -{ - int i, j, nvtxs; - idxtype *vwgt, *where; - idxtype *lpvtxs, *gpvtxs; - - nvtxs = graph->nvtxs; - vwgt = graph->vwgt; - where = graph->where; - - lpvtxs = idxsmalloc(ctrl->nparts, 0, "ComputeMoveStatistics: lpvtxs"); - gpvtxs = idxsmalloc(ctrl->nparts, 0, "ComputeMoveStatistics: gpvtxs"); - - for (j=i=0; imype) - j++; - } - - /* PrintVector(ctrl, ctrl->npes, 0, lpvtxs, "Lpvtxs: "); */ - - MPI_Allreduce((void *)lpvtxs, (void *)gpvtxs, ctrl->nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); - - *nmoved = GlobalSESum(ctrl, j); - *maxout = GlobalSEMax(ctrl, j); - *maxin = GlobalSEMax(ctrl, gpvtxs[ctrl->mype]-(nvtxs-j)); - - GKfree((void **)&lpvtxs, (void **)&gpvtxs, LTERM); -} diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/iidxsort.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/iidxsort.c deleted file mode 100644 index 869748c..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/iidxsort.c +++ /dev/null @@ -1,152 +0,0 @@ -#include - - -/* Byte-wise swap two items of size SIZE. */ -#define QSSWAP(a, b, stmp) do { stmp = (a); (a) = (b); (b) = stmp; } while (0) - -/* Discontinue quicksort algorithm when partition gets below this size. - This particular magic number was chosen to work best on a Sun 4/260. */ -#define MAX_THRESH 20 - -/* Stack node declarations used to store unfulfilled partition obligations. */ -typedef struct { - idxtype *lo; - idxtype *hi; -} stack_node; - - -/* The next 4 #defines implement a very fast in-line stack abstraction. */ -#define STACK_SIZE (8 * sizeof(unsigned long int)) -#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) -#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) -#define STACK_NOT_EMPTY (stack < top) - - -void iidxsort(int total_elems, idxtype *pbase) -{ - idxtype pivot, stmp; - - if (total_elems == 0) - /* Avoid lossage with unsigned arithmetic below. */ - return; - - if (total_elems > MAX_THRESH) { - idxtype *lo = pbase; - idxtype *hi = &lo[total_elems - 1]; - stack_node stack[STACK_SIZE]; /* Largest size needed for 32-bit int!!! */ - stack_node *top = stack + 1; - - while (STACK_NOT_EMPTY) { - idxtype *left_ptr; - idxtype *right_ptr; - idxtype *mid = lo + ((hi - lo) >> 1); - - - if (*mid < *lo) - QSSWAP(*mid, *lo, stmp); - if (*hi < *mid) - QSSWAP(*mid, *hi, stmp); - else - goto jump_over; - if (*mid < *lo) - QSSWAP(*mid, *lo, stmp); - -jump_over:; - pivot = *mid; - left_ptr = lo + 1; - right_ptr = hi - 1; - - /* Here's the famous ``collapse the walls'' section of quicksort. - Gotta like those tight inner loops! They are the main reason - that this algorithm runs much faster than others. */ - do { - while (*left_ptr < pivot) - left_ptr++; - - while (pivot < *right_ptr) - right_ptr--; - - if (left_ptr < right_ptr) { - QSSWAP (*left_ptr, *right_ptr, stmp); - left_ptr++; - right_ptr--; - } - else if (left_ptr == right_ptr) { - left_ptr++; - right_ptr--; - break; - } - } while (left_ptr <= right_ptr); - - /* Set up pointers for next iteration. First determine whether - left and right partitions are below the threshold size. If so, - ignore one or both. Otherwise, push the larger partition's - bounds on the stack and continue sorting the smaller one. */ - - if ((size_t) (right_ptr - lo) <= MAX_THRESH) { - if ((size_t) (hi - left_ptr) <= MAX_THRESH) - /* Ignore both small partitions. */ - POP (lo, hi); - else - /* Ignore small left partition. */ - lo = left_ptr; - } - else if ((size_t) (hi - left_ptr) <= MAX_THRESH) - /* Ignore small right partition. */ - hi = right_ptr; - else if ((right_ptr - lo) > (hi - left_ptr)) { - /* Push larger left partition indices. */ - PUSH (lo, right_ptr); - lo = left_ptr; - } - else { - /* Push larger right partition indices. */ - PUSH (left_ptr, hi); - hi = right_ptr; - } - } - } - - /* Once the BASE_PTR array is partially sorted by quicksort the rest - is completely sorted using insertion sort, since this is efficient - for partitions below MAX_THRESH size. BASE_PTR points to the beginning - of the array to sort, and END_PTR points at the very last element in - the array (*not* one beyond it!). */ - - { - idxtype *end_ptr = &pbase[total_elems - 1]; - idxtype *tmp_ptr = pbase; - idxtype *thresh = (end_ptr < pbase + MAX_THRESH ? end_ptr : pbase + MAX_THRESH); - register idxtype *run_ptr; - - /* Find smallest element in first threshold and place it at the - array's beginning. This is the smallest array element, - and the operation speeds up insertion sort's inner loop. */ - - - for (run_ptr = tmp_ptr + 1; run_ptr <= thresh; run_ptr++) - if (*run_ptr < *tmp_ptr) - tmp_ptr = run_ptr; - - if (tmp_ptr != pbase) - QSSWAP(*tmp_ptr, *pbase, stmp); - - /* Insertion sort, running from left-hand-side up to right-hand-side. */ - run_ptr = pbase + 1; - while (++run_ptr <= end_ptr) { - tmp_ptr = run_ptr - 1; - while (*run_ptr < *tmp_ptr) - tmp_ptr--; - - tmp_ptr++; - if (tmp_ptr != run_ptr) { - idxtype elmnt = *run_ptr; - idxtype *mptr; - - for (mptr=run_ptr; mptr>tmp_ptr; mptr--) - *mptr = *(mptr-1); - *mptr = elmnt; - } - } - } -} diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/iintsort.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/iintsort.c deleted file mode 100644 index fb0e840..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/iintsort.c +++ /dev/null @@ -1,157 +0,0 @@ -#include - - -/* Byte-wise swap two items of size SIZE. */ -#define QSSWAP(a, b, stmp) do { stmp = (a); (a) = (b); (b) = stmp; } while (0) - -/* Discontinue quicksort algorithm when partition gets below this size. - This particular magic number was chosen to work best on a Sun 4/260. */ -#define MAX_THRESH 20 - -/* Stack node declarations used to store unfulfilled partition obligations. */ -typedef struct { - int *lo; - int *hi; -} stack_node; - - -/* The next 4 #defines implement a very fast in-line stack abstraction. */ -#define STACK_SIZE (8 * sizeof(unsigned long int)) -#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) -#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) -#define STACK_NOT_EMPTY (stack < top) - - -void iintsort(int total_elems, int *pbase) -{ - int pivot, stmp; - - if (total_elems == 0) - /* Avoid lossage with unsigned arithmetic below. */ - return; - - if (total_elems > MAX_THRESH) { - int *lo = pbase; - int *hi = &lo[total_elems - 1]; - stack_node stack[STACK_SIZE]; /* Largest size needed for 32-bit int!!! */ - stack_node *top = stack + 1; - - while (STACK_NOT_EMPTY) { - int *left_ptr; - int *right_ptr; - - /* Select median value from among LO, MID, and HI. Rearrange - LO and HI so the three values are sorted. This lowers the - probability of picking a pathological pivot value and - skips a comparison for both the LEFT_PTR and RIGHT_PTR. */ - - int *mid = lo + ((hi - lo) >> 1); - - if (*mid < *lo) - QSSWAP(*mid, *lo, stmp); - if (*hi < *mid) - QSSWAP(*mid, *hi, stmp); - else - goto jump_over; - if (*mid < *lo) - QSSWAP(*mid, *lo, stmp); - -jump_over:; - pivot = *mid; - left_ptr = lo + 1; - right_ptr = hi - 1; - - /* Here's the famous ``collapse the walls'' section of quicksort. - Gotta like those tight inner loops! They are the main reason - that this algorithm runs much faster than others. */ - do { - while (*left_ptr < pivot) - left_ptr++; - - while (pivot < *right_ptr) - right_ptr--; - - if (left_ptr < right_ptr) { - QSSWAP (*left_ptr, *right_ptr, stmp); - left_ptr++; - right_ptr--; - } - else if (left_ptr == right_ptr) { - left_ptr++; - right_ptr--; - break; - } - } while (left_ptr <= right_ptr); - - /* Set up pointers for next iteration. First determine whether - left and right partitions are below the threshold size. If so, - ignore one or both. Otherwise, push the larger partition's - bounds on the stack and continue sorting the smaller one. */ - - if ((size_t) (right_ptr - lo) <= MAX_THRESH) { - if ((size_t) (hi - left_ptr) <= MAX_THRESH) - /* Ignore both small partitions. */ - POP (lo, hi); - else - /* Ignore small left partition. */ - lo = left_ptr; - } - else if ((size_t) (hi - left_ptr) <= MAX_THRESH) - /* Ignore small right partition. */ - hi = right_ptr; - else if ((right_ptr - lo) > (hi - left_ptr)) { - /* Push larger left partition indices. */ - PUSH (lo, right_ptr); - lo = left_ptr; - } - else { - /* Push larger right partition indices. */ - PUSH (left_ptr, hi); - hi = right_ptr; - } - } - } - - /* Once the BASE_PTR array is partially sorted by quicksort the rest - is completely sorted using insertion sort, since this is efficient - for partitions below MAX_THRESH size. BASE_PTR points to the beginning - of the array to sort, and END_PTR points at the very last element in - the array (*not* one beyond it!). */ - - { - int *end_ptr = &pbase[total_elems - 1]; - int *tmp_ptr = pbase; - int *thresh = (end_ptr < pbase + MAX_THRESH ? end_ptr : pbase + MAX_THRESH); - register int *run_ptr; - - /* Find smallest element in first threshold and place it at the - array's beginning. This is the smallest array element, - and the operation speeds up insertion sort's inner loop. */ - - - for (run_ptr = tmp_ptr + 1; run_ptr <= thresh; run_ptr++) - if (*run_ptr < *tmp_ptr) - tmp_ptr = run_ptr; - - if (tmp_ptr != pbase) - QSSWAP(*tmp_ptr, *pbase, stmp); - - /* Insertion sort, running from left-hand-side up to right-hand-side. */ - run_ptr = pbase + 1; - while (++run_ptr <= end_ptr) { - tmp_ptr = run_ptr - 1; - while (*run_ptr < *tmp_ptr) - tmp_ptr--; - - tmp_ptr++; - if (tmp_ptr != run_ptr) { - int elmnt = *run_ptr; - int *mptr; - - for (mptr=run_ptr; mptr>tmp_ptr; mptr--) - *mptr = *(mptr-1); - *mptr = elmnt; - } - } - } -} diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ikeysort.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ikeysort.c deleted file mode 100644 index 14b4241..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ikeysort.c +++ /dev/null @@ -1,151 +0,0 @@ -#include - - -/* Byte-wise swap two items of size SIZE. */ -#define QSSWAP(a, b, stmp) do { stmp = (a); (a) = (b); (b) = stmp; } while (0) - -/* Discontinue quicksort algorithm when partition gets below this size. - This particular magic number was chosen to work best on a Sun 4/260. */ -#define MAX_THRESH 20 - -/* Stack node declarations used to store unfulfilled partition obligations. */ -typedef struct { - KeyValueType *lo; - KeyValueType *hi; -} stack_node; - - -/* The next 4 #defines implement a very fast in-line stack abstraction. */ -#define STACK_SIZE (8 * sizeof(unsigned long int)) -#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) -#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) -#define STACK_NOT_EMPTY (stack < top) - - -void ikeysort(int total_elems, KeyValueType *pbase) -{ - KeyValueType pivot, stmp; - - if (total_elems == 0) - /* Avoid lossage with unsigned arithmetic below. */ - return; - - if (total_elems > MAX_THRESH) { - KeyValueType *lo = pbase; - KeyValueType *hi = &lo[total_elems - 1]; - stack_node stack[STACK_SIZE]; /* Largest size needed for 32-bit int!!! */ - stack_node *top = stack + 1; - - while (STACK_NOT_EMPTY) { - KeyValueType *left_ptr; - KeyValueType *right_ptr; - KeyValueType *mid = lo + ((hi - lo) >> 1); - - if (mid->key < lo->key) - QSSWAP(*mid, *lo, stmp); - if (hi->key < mid->key) - QSSWAP(*mid, *hi, stmp); - else - goto jump_over; - if (mid->key < lo->key) - QSSWAP(*mid, *lo, stmp); - -jump_over:; - pivot = *mid; - left_ptr = lo + 1; - right_ptr = hi - 1; - - /* Here's the famous ``collapse the walls'' section of quicksort. - Gotta like those tight inner loops! They are the main reason - that this algorithm runs much faster than others. */ - do { - while (left_ptr->key < pivot.key) - left_ptr++; - - while (pivot.key < right_ptr->key) - right_ptr--; - - if (left_ptr < right_ptr) { - QSSWAP (*left_ptr, *right_ptr, stmp); - left_ptr++; - right_ptr--; - } - else if (left_ptr == right_ptr) { - left_ptr++; - right_ptr--; - break; - } - } while (left_ptr <= right_ptr); - - /* Set up pointers for next iteration. First determine whether - left and right partitions are below the threshold size. If so, - ignore one or both. Otherwise, push the larger partition's - bounds on the stack and continue sorting the smaller one. */ - - if ((size_t) (right_ptr - lo) <= MAX_THRESH) { - if ((size_t) (hi - left_ptr) <= MAX_THRESH) - /* Ignore both small partitions. */ - POP (lo, hi); - else - /* Ignore small left partition. */ - lo = left_ptr; - } - else if ((size_t) (hi - left_ptr) <= MAX_THRESH) - /* Ignore small right partition. */ - hi = right_ptr; - else if ((right_ptr - lo) > (hi - left_ptr)) { - /* Push larger left partition indices. */ - PUSH (lo, right_ptr); - lo = left_ptr; - } - else { - /* Push larger right partition indices. */ - PUSH (left_ptr, hi); - hi = right_ptr; - } - } - } - - /* Once the BASE_PTR array is partially sorted by quicksort the rest - is completely sorted using insertion sort, since this is efficient - for partitions below MAX_THRESH size. BASE_PTR points to the beginning - of the array to sort, and END_PTR points at the very last element in - the array (*not* one beyond it!). */ - - { - KeyValueType *end_ptr = &pbase[total_elems - 1]; - KeyValueType *tmp_ptr = pbase; - KeyValueType *thresh = (end_ptr < pbase + MAX_THRESH ? end_ptr : pbase + MAX_THRESH); - register KeyValueType *run_ptr; - - /* Find smallest element in first threshold and place it at the - array's beginning. This is the smallest array element, - and the operation speeds up insertion sort's inner loop. */ - - for (run_ptr = tmp_ptr + 1; run_ptr <= thresh; run_ptr++) - if (run_ptr->key < tmp_ptr->key) - tmp_ptr = run_ptr; - - if (tmp_ptr != pbase) - QSSWAP(*tmp_ptr, *pbase, stmp); - - /* Insertion sort, running from left-hand-side up to right-hand-side. */ - run_ptr = pbase + 1; - while (++run_ptr <= end_ptr) { - tmp_ptr = run_ptr - 1; - while (run_ptr->key < tmp_ptr->key) - tmp_ptr--; - - tmp_ptr++; - if (tmp_ptr != run_ptr) { - KeyValueType elmnt = *run_ptr; - KeyValueType *mptr; - - for (mptr=run_ptr; mptr>tmp_ptr; mptr--) - *mptr = *(mptr-1); - *mptr = elmnt; - } - } - } -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ikeyvalsort.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ikeyvalsort.c deleted file mode 100644 index 59dce52..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ikeyvalsort.c +++ /dev/null @@ -1,151 +0,0 @@ -#include - - -/* Byte-wise swap two items of size SIZE. */ -#define QSSWAP(a, b, stmp) do { stmp = (a); (a) = (b); (b) = stmp; } while (0) - -/* Discontinue quicksort algorithm when partition gets below this size. - This particular magic number was chosen to work best on a Sun 4/260. */ -#define MAX_THRESH 20 - -/* Stack node declarations used to store unfulfilled partition obligations. */ -typedef struct { - KeyValueType *lo; - KeyValueType *hi; -} stack_node; - - -/* The next 4 #defines implement a very fast in-line stack abstraction. */ -#define STACK_SIZE (8 * sizeof(unsigned long int)) -#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) -#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) -#define STACK_NOT_EMPTY (stack < top) - - -void ikeyvalsort(int total_elems, KeyValueType *pbase) -{ - KeyValueType pivot, stmp; - - if (total_elems == 0) - /* Avoid lossage with unsigned arithmetic below. */ - return; - - if (total_elems > MAX_THRESH) { - KeyValueType *lo = pbase; - KeyValueType *hi = &lo[total_elems - 1]; - stack_node stack[STACK_SIZE]; /* Largest size needed for 32-bit int!!! */ - stack_node *top = stack + 1; - - while (STACK_NOT_EMPTY) { - KeyValueType *left_ptr; - KeyValueType *right_ptr; - KeyValueType *mid = lo + ((hi - lo) >> 1); - - if (mid->key < lo->key || (mid->key == lo->key && mid->val < lo->val)) - QSSWAP(*mid, *lo, stmp); - if (hi->key < mid->key || (hi->key == mid->key && hi->val < mid->val)) - QSSWAP(*mid, *hi, stmp); - else - goto jump_over; - if (mid->key < lo->key || (mid->key == lo->key && mid->val < lo->val)) - QSSWAP(*mid, *lo, stmp); - -jump_over:; - pivot = *mid; - left_ptr = lo + 1; - right_ptr = hi - 1; - - /* Here's the famous ``collapse the walls'' section of quicksort. - Gotta like those tight inner loops! They are the main reason - that this algorithm runs much faster than others. */ - do { - while (left_ptr->key < pivot.key || (left_ptr->key == pivot.key && left_ptr->val < pivot.val)) - left_ptr++; - - while (pivot.key < right_ptr->key || (pivot.key == right_ptr->key && pivot.val < right_ptr->val)) - right_ptr--; - - if (left_ptr < right_ptr) { - QSSWAP (*left_ptr, *right_ptr, stmp); - left_ptr++; - right_ptr--; - } - else if (left_ptr == right_ptr) { - left_ptr++; - right_ptr--; - break; - } - } while (left_ptr <= right_ptr); - - /* Set up pointers for next iteration. First determine whether - left and right partitions are below the threshold size. If so, - ignore one or both. Otherwise, push the larger partition's - bounds on the stack and continue sorting the smaller one. */ - - if ((size_t) (right_ptr - lo) <= MAX_THRESH) { - if ((size_t) (hi - left_ptr) <= MAX_THRESH) - /* Ignore both small partitions. */ - POP (lo, hi); - else - /* Ignore small left partition. */ - lo = left_ptr; - } - else if ((size_t) (hi - left_ptr) <= MAX_THRESH) - /* Ignore small right partition. */ - hi = right_ptr; - else if ((right_ptr - lo) > (hi - left_ptr)) { - /* Push larger left partition indices. */ - PUSH (lo, right_ptr); - lo = left_ptr; - } - else { - /* Push larger right partition indices. */ - PUSH (left_ptr, hi); - hi = right_ptr; - } - } - } - - /* Once the BASE_PTR array is partially sorted by quicksort the rest - is completely sorted using insertion sort, since this is efficient - for partitions below MAX_THRESH size. BASE_PTR points to the beginning - of the array to sort, and END_PTR points at the very last element in - the array (*not* one beyond it!). */ - - { - KeyValueType *end_ptr = &pbase[total_elems - 1]; - KeyValueType *tmp_ptr = pbase; - KeyValueType *thresh = (end_ptr < pbase + MAX_THRESH ? end_ptr : pbase + MAX_THRESH); - register KeyValueType *run_ptr; - - /* Find smallest element in first threshold and place it at the - array's beginning. This is the smallest array element, - and the operation speeds up insertion sort's inner loop. */ - - for (run_ptr = tmp_ptr + 1; run_ptr <= thresh; run_ptr++) - if (run_ptr->key < tmp_ptr->key || (run_ptr->key == tmp_ptr->key && run_ptr->val < tmp_ptr->val)) - tmp_ptr = run_ptr; - - if (tmp_ptr != pbase) - QSSWAP(*tmp_ptr, *pbase, stmp); - - /* Insertion sort, running from left-hand-side up to right-hand-side. */ - run_ptr = pbase + 1; - while (++run_ptr <= end_ptr) { - tmp_ptr = run_ptr - 1; - while (run_ptr->key < tmp_ptr->key || (run_ptr->key == tmp_ptr->key && run_ptr->val < tmp_ptr->val)) - tmp_ptr--; - - tmp_ptr++; - if (tmp_ptr != run_ptr) { - KeyValueType elmnt = *run_ptr; - KeyValueType *mptr; - - for (mptr=run_ptr; mptr>tmp_ptr; mptr--) - *mptr = *(mptr-1); - *mptr = elmnt; - } - } - } -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initbalance.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initbalance.c deleted file mode 100644 index 9ec7a31..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initbalance.c +++ /dev/null @@ -1,498 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * initbalance.c - * - * This file contains code that computes an initial partitioning - * - * Started 3/4/96 - * George - * - * $Id: initbalance.c,v 1.4 2003/07/30 21:18:52 karypis Exp $ - */ - -#include - - -/************************************************************************* -* This function is the entry point of the initial balancing algorithm. -* This algorithm assembles the graph to all the processors and preceeds -* with the balancing step. -**************************************************************************/ -void Balance_Partition(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, j, mype, npes, nvtxs, nedges, ncon; - idxtype *vtxdist, *xadj, *adjncy, *adjwgt, *vwgt, *vsize; - idxtype *part, *lwhere, *home; - GraphType *agraph, cgraph; - CtrlType myctrl; - int lnparts, fpart, fpe, lnpes, ngroups, srnpes, srmype; - int twoparts=2, numflag = 0, wgtflag = 3, moptions[10], edgecut, max_cut; - int sr_pe, gd_pe, sr, gd, who_wins, *rcounts, *rdispls; - float my_cut, my_totalv, my_cost = -1.0, my_balance = -1.0, wsum; - float rating, max_rating, your_cost = -1.0, your_balance = -1.0; - float lbvec[MAXNCON], lbsum, min_lbsum, *mytpwgts, mytpwgts2[2], buffer[2]; - MPI_Status status; - MPI_Comm ipcomm, srcomm; - struct { - float cost; - int rank; - } lpecost, gpecost; - - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->InitPartTmr)); - - vtxdist = graph->vtxdist; - agraph = Moc_AssembleAdaptiveGraph(ctrl, graph, wspace); - nvtxs = cgraph.nvtxs = agraph->nvtxs; - nedges = cgraph.nedges = agraph->nedges; - ncon = cgraph.ncon = agraph->ncon; - - xadj = cgraph.xadj = idxmalloc(nvtxs*(5+ncon)+1+nedges*2, "U_IP: xadj"); - vwgt = cgraph.vwgt = xadj + nvtxs+1; - vsize = cgraph.vsize = xadj + nvtxs*(1+ncon)+1; - cgraph.where = agraph->where = part = xadj + nvtxs*(2+ncon)+1; - lwhere = xadj + nvtxs*(3+ncon)+1; - home = xadj + nvtxs*(4+ncon)+1; - adjncy = cgraph.adjncy = xadj + nvtxs*(5+ncon)+1; - adjwgt = cgraph.adjwgt = xadj + nvtxs*(5+ncon)+1 + nedges; - - /* ADD: this assumes that tpwgts for all constraints is the same */ - /* ADD: this is necessary because serial metis does not support the general case */ - mytpwgts = fsmalloc(ctrl->nparts, 0.0, "mytpwgts"); - for (i=0; inparts; i++) - for (j=0; jtpwgts[i*ncon+j]; - for (i=0; inparts; i++) - mytpwgts[i] /= (float)ncon; - - idxcopy(nvtxs+1, agraph->xadj, xadj); - idxcopy(nvtxs*ncon, agraph->vwgt, vwgt); - idxcopy(nvtxs, agraph->vsize, vsize); - idxcopy(nedges, agraph->adjncy, adjncy); - idxcopy(nedges, agraph->adjwgt, adjwgt); - - /****************************************/ - /****************************************/ - if (ctrl->ps_relation == DISCOUPLED) { - rcounts = imalloc(ctrl->npes, "rcounts"); - rdispls = imalloc(ctrl->npes+1, "rdispls"); - - for (i=0; inpes; i++) { - rdispls[i] = rcounts[i] = vtxdist[i+1]-vtxdist[i]; - } - MAKECSR(i, ctrl->npes, rdispls); - - MPI_Allgatherv((void *)graph->home, graph->nvtxs, IDX_DATATYPE, - (void *)part, rcounts, rdispls, IDX_DATATYPE, ctrl->comm); - - for (i=0; invtxs; i++) - home[i] = part[i]; - - GKfree((void **)&rcounts, (void **)&rdispls, LTERM); - } - else { - for (i=0; inpes; i++) - for (j=vtxdist[i]; jnvtxs; i++) { - if (part[i] >= ctrl->nparts) - part[i] = home[i] = part[i] % ctrl->nparts; - if (part[i] < 0) - part[i] = home[i] = (-1*part[i]) % ctrl->nparts; - } - /****************************************/ - /****************************************/ - - IFSET(ctrl->dbglvl, DBG_REFINEINFO, Moc_ComputeSerialBalance(ctrl, agraph, agraph->where, lbvec)); - IFSET(ctrl->dbglvl, DBG_REFINEINFO, rprintf(ctrl, "input cut: %d, balance: ", ComputeSerialEdgeCut(agraph))); - for (i=0; incon; i++) - IFSET(ctrl->dbglvl, DBG_REFINEINFO, rprintf(ctrl, "%.3f ", lbvec[i])); - IFSET(ctrl->dbglvl, DBG_REFINEINFO, rprintf(ctrl, "\n")); - - /****************************************/ - /* Split the processors into two groups */ - /****************************************/ - sr = (ctrl->mype % 2 == 0) ? 1 : 0; - gd = (ctrl->mype % 2 == 1) ? 1 : 0; - - if (graph->ncon > MAX_NCON_FOR_DIFFUSION || ctrl->npes == 1) { - sr = 1; - gd = 0; - } - - sr_pe = 0; - gd_pe = 1; - - MPI_Comm_split(ctrl->gcomm, sr, 0, &ipcomm); - MPI_Comm_rank(ipcomm, &mype); - MPI_Comm_size(ipcomm, &npes); - - myctrl.dbglvl = 0; - myctrl.mype = mype; - myctrl.npes = npes; - myctrl.comm = ipcomm; - myctrl.sync = ctrl->sync; - myctrl.seed = ctrl->seed; - myctrl.nparts = ctrl->nparts; - myctrl.ipc_factor = ctrl->ipc_factor; - myctrl.redist_factor = ctrl->redist_base; - myctrl.partType = ADAPTIVE_PARTITION; - myctrl.ps_relation = DISCOUPLED; - myctrl.tpwgts = ctrl->tpwgts; - icopy(ncon, ctrl->tvwgts, myctrl.tvwgts); - icopy(ncon, ctrl->ubvec, myctrl.ubvec); - - if (sr == 1) { - /*******************************************/ - /* Half of the processors do scratch-remap */ - /*******************************************/ - ngroups = amax(amin(RIP_SPLIT_FACTOR, npes), 1); - MPI_Comm_split(ipcomm, mype % ngroups, 0, &srcomm); - MPI_Comm_rank(srcomm, &srmype); - MPI_Comm_size(srcomm, &srnpes); - - moptions[0] = 0; - moptions[7] = ctrl->sync + (mype % ngroups) + 1; - - idxset(nvtxs, 0, lwhere); - lnparts = ctrl->nparts; - fpart = fpe = 0; - lnpes = srnpes; - while (lnpes > 1 && lnparts > 1) { - ASSERT(ctrl, agraph->nvtxs > 1); - /* Determine the weights of the partitions */ - mytpwgts2[0] = ssum(lnparts/2, mytpwgts+fpart); - mytpwgts2[1] = 1.0-mytpwgts2[0]; - - - if (agraph->ncon == 1) { - METIS_WPartGraphKway2(&agraph->nvtxs, agraph->xadj, agraph->adjncy, agraph->vwgt, - agraph->adjwgt, &wgtflag, &numflag, &twoparts, mytpwgts2, moptions, &edgecut, - part); - } - else { - METIS_mCPartGraphRecursive2(&agraph->nvtxs, &ncon, agraph->xadj, agraph->adjncy, - agraph->vwgt, agraph->adjwgt, &wgtflag, &numflag, &twoparts, mytpwgts2, - moptions, &edgecut, part); - } - - wsum = ssum(lnparts/2, mytpwgts+fpart); - sscale(lnparts/2, 1.0/wsum, mytpwgts+fpart); - sscale(lnparts-lnparts/2, 1.0/(1.0-wsum), mytpwgts+fpart+lnparts/2); - - /* I'm picking the left branch */ - if (srmype < fpe+lnpes/2) { - Moc_KeepPart(agraph, wspace, part, 0); - lnpes = lnpes/2; - lnparts = lnparts/2; - } - else { - Moc_KeepPart(agraph, wspace, part, 1); - fpart = fpart + lnparts/2; - fpe = fpe + lnpes/2; - lnpes = lnpes - lnpes/2; - lnparts = lnparts - lnparts/2; - } - } - - /* In case srnpes is greater than or equal to nparts */ - if (lnparts == 1) { - /* Only the first process will assign labels (for the reduction to work) */ - if (srmype == fpe) { - for (i=0; invtxs; i++) - lwhere[agraph->label[i]] = fpart; - } - } - /* In case srnpes is smaller than nparts */ - else { - if (ncon == 1) - METIS_WPartGraphKway2(&agraph->nvtxs, agraph->xadj, agraph->adjncy, agraph->vwgt, - agraph->adjwgt, &wgtflag, &numflag, &lnparts, mytpwgts+fpart, moptions, - &edgecut, part); - else - METIS_mCPartGraphRecursive2(&agraph->nvtxs, &ncon, agraph->xadj, agraph->adjncy, - agraph->vwgt, agraph->adjwgt, &wgtflag, &numflag, &lnparts, mytpwgts+fpart, - moptions, &edgecut, part); - - for (i=0; invtxs; i++) - lwhere[agraph->label[i]] = fpart + part[i]; - } - - MPI_Allreduce((void *)lwhere, (void *)part, nvtxs, IDX_DATATYPE, MPI_SUM, srcomm); - - edgecut = ComputeSerialEdgeCut(&cgraph); - Moc_ComputeSerialBalance(ctrl, &cgraph, part, lbvec); - lbsum = ssum(ncon, lbvec); - MPI_Allreduce((void *)&edgecut, (void *)&max_cut, 1, MPI_INT, MPI_MAX, ipcomm); - MPI_Allreduce((void *)&lbsum, (void *)&min_lbsum, 1, MPI_FLOAT, MPI_MIN, ipcomm); - lpecost.rank = ctrl->mype; - lpecost.cost = lbsum; - if (min_lbsum < UNBALANCE_FRACTION * (float)(ncon)) { - if (lbsum < UNBALANCE_FRACTION * (float)(ncon)) - lpecost.cost = (float)edgecut; - else - lpecost.cost = (float)max_cut + lbsum; - } - MPI_Allreduce((void *)&lpecost, (void *)&gpecost, 1, MPI_FLOAT_INT, MPI_MINLOC, ipcomm); - - if (ctrl->mype == gpecost.rank && ctrl->mype != sr_pe) { - MPI_Send((void *)part, nvtxs, IDX_DATATYPE, sr_pe, 1, ctrl->comm); - } - - if (ctrl->mype != gpecost.rank && ctrl->mype == sr_pe) { - MPI_Recv((void *)part, nvtxs, IDX_DATATYPE, gpecost.rank, 1, ctrl->comm, &status); - } - - if (ctrl->mype == sr_pe) { - idxcopy(nvtxs, part, lwhere); - SerialRemap(&cgraph, ctrl->nparts, home, lwhere, part, ctrl->tpwgts); - } - - MPI_Comm_free(&srcomm); - } - /**************************************/ - /* The other half do global diffusion */ - /**************************************/ - else { - /******************************************************************/ - /* The next stmt is required to balance out the sr MPI_Comm_split */ - /******************************************************************/ - MPI_Comm_split(ipcomm, MPI_UNDEFINED, 0, &srcomm); - - if (ncon == 1) { - rating = WavefrontDiffusion(&myctrl, agraph, home); - Moc_ComputeSerialBalance(ctrl, &cgraph, part, lbvec); - lbsum = ssum(ncon, lbvec); - - /* Determine which PE computed the best partitioning */ - MPI_Allreduce((void *)&rating, (void *)&max_rating, 1, MPI_FLOAT, MPI_MAX, ipcomm); - MPI_Allreduce((void *)&lbsum, (void *)&min_lbsum, 1, MPI_FLOAT, MPI_MIN, ipcomm); - - lpecost.rank = ctrl->mype; - lpecost.cost = lbsum; - if (min_lbsum < UNBALANCE_FRACTION * (float)(ncon)) { - if (lbsum < UNBALANCE_FRACTION * (float)(ncon)) - lpecost.cost = rating; - else - lpecost.cost = max_rating + lbsum; - } - - MPI_Allreduce((void *)&lpecost, (void *)&gpecost, 1, MPI_FLOAT_INT, MPI_MINLOC, ipcomm); - - /* Now send this to the coordinating processor */ - if (ctrl->mype == gpecost.rank && ctrl->mype != gd_pe) - MPI_Send((void *)part, nvtxs, IDX_DATATYPE, gd_pe, 1, ctrl->comm); - - if (ctrl->mype != gpecost.rank && ctrl->mype == gd_pe) - MPI_Recv((void *)part, nvtxs, IDX_DATATYPE, gpecost.rank, 1, ctrl->comm, &status); - - if (ctrl->mype == gd_pe) { - idxcopy(nvtxs, part, lwhere); - SerialRemap(&cgraph, ctrl->nparts, home, lwhere, part, ctrl->tpwgts); - } - } - else { - Moc_Diffusion(&myctrl, agraph, graph->vtxdist, agraph->where, home, wspace, N_MOC_GD_PASSES); - } - } - - if (graph->ncon <= MAX_NCON_FOR_DIFFUSION) { - if (ctrl->mype == sr_pe || ctrl->mype == gd_pe) { - /********************************************************************/ - /* The coordinators from each group decide on the best partitioning */ - /********************************************************************/ - my_cut = (float) ComputeSerialEdgeCut(&cgraph); - my_totalv = (float) Mc_ComputeSerialTotalV(&cgraph, home); - Moc_ComputeSerialBalance(ctrl, &cgraph, part, lbvec); - my_balance = ssum(cgraph.ncon, lbvec); - my_balance /= (float) cgraph.ncon; - my_cost = ctrl->ipc_factor * my_cut + REDIST_WGT * ctrl->redist_base * my_totalv; - - IFSET(ctrl->dbglvl, DBG_REFINEINFO, printf("%s initial cut: %.1f, totalv: %.1f, balance: %.3f\n", - (ctrl->mype == sr_pe ? "scratch-remap" : "diffusion"), my_cut, my_totalv, my_balance)); - - if (ctrl->mype == gd_pe) { - buffer[0] = my_cost; - buffer[1] = my_balance; - MPI_Send((void *)buffer, 2, MPI_FLOAT, sr_pe, 1, ctrl->comm); - } - else { - MPI_Recv((void *)buffer, 2, MPI_FLOAT, gd_pe, 1, ctrl->comm, &status); - your_cost = buffer[0]; - your_balance = buffer[1]; - } - } - - if (ctrl->mype == sr_pe) { - who_wins = gd_pe; - if ((my_balance < 1.1 && your_balance > 1.1) || - (my_balance < 1.1 && your_balance < 1.1 && my_cost < your_cost) || - (my_balance > 1.1 && your_balance > 1.1 && my_balance < your_balance)) { - who_wins = sr_pe; - } - } - - MPI_Bcast((void *)&who_wins, 1, MPI_INT, sr_pe, ctrl->comm); - } - else { - who_wins = sr_pe; - } - - MPI_Bcast((void *)part, nvtxs, IDX_DATATYPE, who_wins, ctrl->comm); - idxcopy(graph->nvtxs, part+vtxdist[ctrl->mype], graph->where); - - MPI_Comm_free(&ipcomm); - GKfree((void **)&xadj, (void **)&mytpwgts, LTERM); - -/* For whatever reason, FreeGraph crashes here...so explicitly free the memory. - FreeGraph(agraph); -*/ - GKfree((void **)&agraph->xadj, (void **)&agraph->adjncy, (void **)&agraph->vwgt, (void **)&agraph->nvwgt, LTERM); - GKfree((void **)&agraph->vsize, (void **)&agraph->adjwgt, (void **)&agraph->label, LTERM); - GKfree((void **)&agraph, LTERM); - - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->InitPartTmr)); - -} - - -/* NOTE: this subroutine should work for static, adaptive, single-, and multi-contraint */ -/************************************************************************* -* This function assembles the graph into a single processor -**************************************************************************/ -GraphType *Moc_AssembleAdaptiveGraph(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, j, k, l, gnvtxs, nvtxs, ncon, gnedges, nedges, gsize; - idxtype *xadj, *vwgt, *vsize, *adjncy, *adjwgt, *vtxdist, *imap; - idxtype *axadj, *aadjncy, *aadjwgt, *avwgt, *avsize = NULL, *alabel; - idxtype *mygraph, *ggraph; - int *rcounts, *rdispls, mysize; - float *anvwgt; - GraphType *agraph; - - gnvtxs = graph->gnvtxs; - nvtxs = graph->nvtxs; - ncon = graph->ncon; - nedges = graph->xadj[nvtxs]; - xadj = graph->xadj; - vwgt = graph->vwgt; - vsize = graph->vsize; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - vtxdist = graph->vtxdist; - imap = graph->imap; - - /*************************************************************/ - /* Determine the # of idxtype to receive from each processor */ - /*************************************************************/ - rcounts = imalloc(ctrl->npes, "AssembleGraph: rcounts"); - switch (ctrl->partType) { - case STATIC_PARTITION: - mysize = (1+ncon)*nvtxs + 2*nedges; - break; - case ADAPTIVE_PARTITION: - case REFINE_PARTITION: - mysize = (2+ncon)*nvtxs + 2*nedges; - break; - default: - printf("WARNING: bad value for ctrl->partType %d\n", ctrl->partType); - break; - } - MPI_Allgather((void *)(&mysize), 1, MPI_INT, (void *)rcounts, 1, MPI_INT, ctrl->comm); - - rdispls = imalloc(ctrl->npes+1, "AssembleGraph: rdispls"); - rdispls[0] = 0; - for (i=1; inpes+1; i++) - rdispls[i] = rdispls[i-1] + rcounts[i-1]; - - /* Construct the one-array storage format of the assembled graph */ - mygraph = (mysize <= wspace->maxcore ? wspace->core : idxmalloc(mysize, "AssembleGraph: mygraph")); - for (k=i=0; ipartType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) - mygraph[k++] = vsize[i]; - for (j=xadj[i]; jnpes]; - ggraph = (gsize <= wspace->maxcore-mysize ? wspace->core+mysize : idxmalloc(gsize, "AssembleGraph: ggraph")); - MPI_Allgatherv((void *)mygraph, mysize, IDX_DATATYPE, (void *)ggraph, rcounts, rdispls, IDX_DATATYPE, ctrl->comm); - - GKfree((void **)&rcounts, (void **)&rdispls, LTERM); - if (mysize > wspace->maxcore) - free(mygraph); - - agraph = CreateGraph(); - agraph->nvtxs = gnvtxs; - switch (ctrl->partType) { - case STATIC_PARTITION: - agraph->nedges = gnedges = (gsize-(1+ncon)*gnvtxs)/2; - break; - case ADAPTIVE_PARTITION: - case REFINE_PARTITION: - agraph->nedges = gnedges = (gsize-(2+ncon)*gnvtxs)/2; - break; - default: - printf("WARNING: bad value for ctrl->partType %d\n", ctrl->partType); - agraph->nedges = gnedges = -1; - break; - } - - agraph->ncon = ncon; - - /*******************************************/ - /* Allocate memory for the assembled graph */ - /*******************************************/ - axadj = agraph->xadj = idxmalloc(gnvtxs+1, "AssembleGraph: axadj"); - avwgt = agraph->vwgt = idxmalloc(gnvtxs*ncon, "AssembleGraph: avwgt"); - anvwgt = agraph->nvwgt = fmalloc(gnvtxs*ncon, "AssembleGraph: anvwgt"); - aadjncy = agraph->adjncy = idxmalloc(gnedges, "AssembleGraph: adjncy"); - aadjwgt = agraph->adjwgt = idxmalloc(gnedges, "AssembleGraph: adjwgt"); - alabel = agraph->label = idxmalloc(gnvtxs, "AssembleGraph: alabel"); - if (ctrl->partType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) - avsize = agraph->vsize = idxmalloc(gnvtxs, "AssembleGraph: avsize"); - - for (k=j=i=0; ipartType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) - avsize[i] = ggraph[k++]; - for (l=0; lvwgt[i*ncon+j]) / (float)(ctrl->tvwgts[j]); - - for (i=0; i wspace->maxcore-mysize) - free(ggraph); - - return agraph; -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initmsection.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initmsection.c deleted file mode 100644 index 63c7c35..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initmsection.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * initmsection.c - * - * This file contains code that performs the k-way multisection - * - * Started 6/3/97 - * George - * - * $Id: initmsection.c,v 1.2 2003/07/21 17:18:49 karypis Exp $ - */ - -#include - - -#define DEBUG_IPART_ - - - -/************************************************************************* -* This function is the entry point of the initial partitioning algorithm. -* This algorithm assembles the graph to all the processors and preceed -* serially. -**************************************************************************/ -void InitMultisection(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, lpecut[2], gpecut[2], mypart, moptions[10]; - idxtype *vtxdist, *gwhere = NULL, *part, *label; - GraphType *agraph; - int *sendcounts, *displs; - MPI_Comm newcomm, labelcomm; - - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->InitPartTmr)); - - /* Assemble the graph and do the necessary pre-processing */ - agraph = AssembleMultisectedGraph(ctrl, graph, wspace); - part = agraph->where; - agraph->where = NULL; - - /* Split the processors into groups so that each one can do a bisection */ - mypart = ctrl->mype%(ctrl->nparts/2); - MPI_Comm_split(ctrl->comm, mypart, 0, &newcomm); - - /* Each processor keeps the graphs that it only needs and bisects it */ - agraph->ncon = 1; /* needed for Moc_KeepPart */ - Moc_KeepPart(agraph, wspace, part, mypart); - label = agraph->label; /* Save this because ipart may need it */ - agraph->label = NULL; - - /* Bisect the graph and construct the separator */ - switch (ctrl->ipart) { - case ISEP_EDGE: - moptions[0] = 1; - moptions[1] = 3; - moptions[2] = 1; - moptions[3] = 1; - moptions[4] = 0; - moptions[7] = ctrl->mype; - - agraph->where = idxmalloc(agraph->nvtxs, "InitMultisection: agraph->where"); - - METIS_EdgeComputeSeparator(&agraph->nvtxs, agraph->xadj, agraph->adjncy, - agraph->vwgt, agraph->adjwgt, moptions, &agraph->mincut, agraph->where); - break; - case ISEP_NODE: - moptions[0] = 1; - moptions[1] = 3; - moptions[2] = 1; - moptions[3] = 2; - moptions[4] = 0; - moptions[7] = ctrl->mype; - - agraph->where = idxmalloc(agraph->nvtxs, "InitMultisection: agraph->where"); - - METIS_NodeComputeSeparator(&agraph->nvtxs, agraph->xadj, agraph->adjncy, agraph->vwgt, - agraph->adjwgt, moptions, &agraph->mincut, agraph->where); - break; - default: - errexit("Unknown ISEP type!\n"); - } - - for (i=0; invtxs; i++) { - ASSERT(ctrl, agraph->where[i]>=0 && agraph->where[i]<=2); - if (agraph->where[i] == 2) - agraph->where[i] = ctrl->nparts+2*mypart; - else - agraph->where[i] += 2*mypart; - } - - /* Determine which PE got the minimum cut */ - lpecut[0] = agraph->mincut; - MPI_Comm_rank(newcomm, lpecut+1); - MPI_Allreduce(lpecut, gpecut, 1, MPI_2INT, MPI_MINLOC, newcomm); - - /* myprintf(ctrl, "Nvtxs: %d, Mincut: %d, GMincut: %d, %d\n", agraph->nvtxs, agraph->mincut, gpecut[0], gpecut[1]); */ - - /* Send the best where to the root processor of this partition */ - if (lpecut[1] == gpecut[1] && gpecut[1] != 0) - MPI_Send((void *)agraph->where, agraph->nvtxs, IDX_DATATYPE, 0, 1, newcomm); - if (lpecut[1] == 0 && gpecut[1] != 0) - MPI_Recv((void *)agraph->where, agraph->nvtxs, IDX_DATATYPE, gpecut[1], 1, newcomm, &ctrl->status); - - /* Create a communicator that stores all the i-th processors of the newcomm */ - MPI_Comm_split(ctrl->comm, lpecut[1], 0, &labelcomm); - - /* Map the separator back to agraph. This is inefficient! */ - if (lpecut[1] == 0) { - gwhere = idxsmalloc(graph->gnvtxs, 0, "InitMultisection: gwhere"); - for (i=0; invtxs; i++) - gwhere[label[i]] = agraph->where[i]; - } - - free(agraph->where); - agraph->where = part; - - if (lpecut[1] == 0) { - MPI_Reduce((void *)gwhere, (void *)agraph->where, graph->gnvtxs, IDX_DATATYPE, MPI_SUM, 0, labelcomm); - free(gwhere); - } - - /* The minimum PE performs the Scatter */ - vtxdist = graph->vtxdist; - ASSERT(ctrl, graph->where != NULL); - free(graph->where); /* Remove the propagated down where info */ - graph->where = idxmalloc(graph->nvtxs+graph->nrecv, "InitPartition: where"); - - sendcounts = imalloc(ctrl->npes, "InitPartitionNew: sendcounts"); - displs = imalloc(ctrl->npes, "InitPartitionNew: displs"); - - for (i=0; inpes; i++) { - sendcounts[i] = vtxdist[i+1]-vtxdist[i]; - displs[i] = vtxdist[i]; - } - - MPI_Scatterv((void *)agraph->where, sendcounts, displs, IDX_DATATYPE, - (void *)graph->where, graph->nvtxs, IDX_DATATYPE, 0, ctrl->comm); - - GKfree((void **)&sendcounts, (void **)&displs, (void **)&label, LTERM); - - FreeGraph(agraph); - - MPI_Comm_free(&newcomm); - MPI_Comm_free(&labelcomm); - - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->InitPartTmr)); - -} - - - - -/************************************************************************* -* This function assembles the graph into a single processor -**************************************************************************/ -GraphType *AssembleMultisectedGraph(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, j, k, l, gnvtxs, nvtxs, gnedges, nedges, gsize; - idxtype *xadj, *vwgt, *where, *adjncy, *adjwgt, *vtxdist, *imap; - idxtype *axadj, *aadjncy, *aadjwgt, *avwgt, *awhere, *alabel; - idxtype *mygraph, *ggraph; - int *recvcounts, *displs, mysize; - GraphType *agraph; - - gnvtxs = graph->gnvtxs; - nvtxs = graph->nvtxs; - nedges = graph->xadj[nvtxs]; - xadj = graph->xadj; - vwgt = graph->vwgt; - where = graph->where; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - vtxdist = graph->vtxdist; - imap = graph->imap; - - /* Determine the # of idxtype to receive from each processor */ - recvcounts = imalloc(ctrl->npes, "AssembleGraph: recvcounts"); - mysize = 3*nvtxs + 2*nedges; - MPI_Allgather((void *)(&mysize), 1, MPI_INT, (void *)recvcounts, 1, MPI_INT, ctrl->comm); - - displs = imalloc(ctrl->npes+1, "AssembleGraph: displs"); - displs[0] = 0; - for (i=1; inpes+1; i++) - displs[i] = displs[i-1] + recvcounts[i-1]; - - /* Construct the one-array storage format of the assembled graph */ - mygraph = (mysize <= wspace->maxcore ? wspace->core : idxmalloc(mysize, "AssembleGraph: mygraph")); - for (k=i=0; inpes]; - ggraph = (gsize <= wspace->maxcore-mysize ? wspace->core+mysize : idxmalloc(gsize, "AssembleGraph: ggraph")); - MPI_Allgatherv((void *)mygraph, mysize, IDX_DATATYPE, (void *)ggraph, recvcounts, displs, IDX_DATATYPE, ctrl->comm); - - GKfree((void **)&recvcounts, (void **)&displs, LTERM); - if (mysize > wspace->maxcore) - free(mygraph); - - agraph = CreateGraph(); - agraph->nvtxs = gnvtxs; - agraph->nedges = gnedges = (gsize-3*gnvtxs)/2; - - /* Allocate memory for the assembled graph */ - axadj = agraph->xadj = idxmalloc(gnvtxs+1, "AssembleGraph: axadj"); - avwgt = agraph->vwgt = idxmalloc(gnvtxs, "AssembleGraph: avwgt"); - awhere = agraph->where = idxmalloc(gnvtxs, "AssembleGraph: awhere"); - aadjncy = agraph->adjncy = idxmalloc(gnedges, "AssembleGraph: adjncy"); - aadjwgt = agraph->adjwgt = idxmalloc(gnedges, "AssembleGraph: adjwgt"); - alabel = agraph->label = idxmalloc(gnvtxs, "AssembleGraph: alabel"); - - for (k=j=i=0; i wspace->maxcore-mysize) - free(ggraph); - - return agraph; -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initpart.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initpart.c deleted file mode 100644 index 40b8d95..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/initpart.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * initpart.c - * - * This file contains code that performs log(p) parallel multilevel - * recursive bissection - * - * Started 3/4/96 - * George - * - * $Id: initpart.c,v 1.2 2003/07/21 17:18:49 karypis Exp $ - */ - -#include - - -#define DEBUG_IPART_ - - - -/************************************************************************* -* This function is the entry point of the initial partition algorithm -* that does recursive bissection. -* This algorithm assembles the graph to all the processors and preceeds -* by parallelizing the recursive bisection step. -**************************************************************************/ -void Moc_InitPartition_RB(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, j; - int ncon, mype, npes, gnvtxs, ngroups; - idxtype *xadj, *adjncy, *adjwgt, *vwgt; - idxtype *part, *gwhere0, *gwhere1; - idxtype *tmpwhere, *tmpvwgt, *tmpxadj, *tmpadjncy, *tmpadjwgt; - GraphType *agraph; - int lnparts, fpart, fpe, lnpes; - int twoparts=2, numflag = 0, wgtflag = 3, moptions[10], edgecut, max_cut; - float *mytpwgts, mytpwgts2[2], lbvec[MAXNCON], lbsum, min_lbsum, wsum; - MPI_Comm ipcomm; - struct { - float sum; - int rank; - } lpesum, gpesum; - - ncon = graph->ncon; - ngroups = amax(amin(RIP_SPLIT_FACTOR, ctrl->npes), 1); - - IFSET(ctrl->dbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->InitPartTmr)); - - agraph = Moc_AssembleAdaptiveGraph(ctrl, graph, wspace); - part = idxmalloc(agraph->nvtxs, "Moc_IP_RB: part"); - xadj = idxmalloc(agraph->nvtxs+1, "Moc_IP_RB: xadj"); - adjncy = idxmalloc(agraph->nedges, "Moc_IP_RB: adjncy"); - adjwgt = idxmalloc(agraph->nedges, "Moc_IP_RB: adjwgt"); - vwgt = idxmalloc(agraph->nvtxs*ncon, "Moc_IP_RB: vwgt"); - - idxcopy(agraph->nvtxs*ncon, agraph->vwgt, vwgt); - idxcopy(agraph->nvtxs+1, agraph->xadj, xadj); - idxcopy(agraph->nedges, agraph->adjncy, adjncy); - idxcopy(agraph->nedges, agraph->adjwgt, adjwgt); - - MPI_Comm_split(ctrl->gcomm, ctrl->mype % ngroups, 0, &ipcomm); - MPI_Comm_rank(ipcomm, &mype); - MPI_Comm_size(ipcomm, &npes); - - gnvtxs = agraph->nvtxs; - - gwhere0 = idxsmalloc(gnvtxs, 0, "Moc_IP_RB: gwhere0"); - gwhere1 = idxmalloc(gnvtxs, "Moc_IP_RB: gwhere1"); - - /* ADD: this assumes that tpwgts for all constraints is the same */ - /* ADD: this is necessary because serial metis does not support the general case */ - mytpwgts = fsmalloc(ctrl->nparts, 0.0, "mytpwgts"); - for (i=0; inparts; i++) - for (j=0; jtpwgts[i*ncon+j]; - for (i=0; inparts; i++) - mytpwgts[i] /= (float)ncon; - - /* Go into the recursive bisection */ - /* ADD: consider changing this to breadth-first type bisection */ - moptions[0] = 0; - moptions[7] = ctrl->sync + (ctrl->mype % ngroups) + 1; - - lnparts = ctrl->nparts; - fpart = fpe = 0; - lnpes = npes; - while (lnpes > 1 && lnparts > 1) { - /* Determine the weights of the partitions */ - mytpwgts2[0] = ssum(lnparts/2, mytpwgts+fpart); - mytpwgts2[1] = 1.0-mytpwgts2[0]; - - if (ncon == 1) - METIS_WPartGraphKway2(&agraph->nvtxs, agraph->xadj, agraph->adjncy, - agraph->vwgt, agraph->adjwgt, &wgtflag, &numflag, &twoparts, mytpwgts2, - moptions, &edgecut, part); - else { - METIS_mCPartGraphRecursive2(&agraph->nvtxs, &ncon, agraph->xadj, - agraph->adjncy, agraph->vwgt, agraph->adjwgt, &wgtflag, &numflag, - &twoparts, mytpwgts2, moptions, &edgecut, part); - } - - wsum = ssum(lnparts/2, mytpwgts+fpart); - sscale(lnparts/2, 1.0/wsum, mytpwgts+fpart); - sscale(lnparts-lnparts/2, 1.0/(1.0-wsum), mytpwgts+fpart+lnparts/2); - - /* I'm picking the left branch */ - if (mype < fpe+lnpes/2) { - Moc_KeepPart(agraph, wspace, part, 0); - lnpes = lnpes/2; - lnparts = lnparts/2; - } - else { - Moc_KeepPart(agraph, wspace, part, 1); - fpart = fpart + lnparts/2; - fpe = fpe + lnpes/2; - lnpes = lnpes - lnpes/2; - lnparts = lnparts - lnparts/2; - } - } - - /* In case npes is greater than or equal to nparts */ - if (lnparts == 1) { - /* Only the first process will assign labels (for the reduction to work) */ - if (mype == fpe) { - for (i=0; invtxs; i++) - gwhere0[agraph->label[i]] = fpart; - } - } - /* In case npes is smaller than nparts */ - else { - if (ncon == 1) - METIS_WPartGraphKway2(&agraph->nvtxs, agraph->xadj, agraph->adjncy, - agraph->vwgt, agraph->adjwgt, &wgtflag, &numflag, &lnparts, mytpwgts+fpart, - moptions, &edgecut, part); - else - METIS_mCPartGraphRecursive2(&agraph->nvtxs, &ncon, agraph->xadj, - agraph->adjncy, agraph->vwgt, agraph->adjwgt, &wgtflag, &numflag, - &lnparts, mytpwgts+fpart, moptions, &edgecut, part); - - for (i=0; invtxs; i++) - gwhere0[agraph->label[i]] = fpart + part[i]; - } - - MPI_Allreduce((void *)gwhere0, (void *)gwhere1, gnvtxs, IDX_DATATYPE, MPI_SUM, ipcomm); - - if (ngroups > 1) { - tmpxadj = agraph->xadj; - tmpadjncy = agraph->adjncy; - tmpadjwgt = agraph->adjwgt; - tmpvwgt = agraph->vwgt; - tmpwhere = agraph->where; - agraph->xadj = xadj; - agraph->adjncy = adjncy; - agraph->adjwgt = adjwgt; - agraph->vwgt = vwgt; - agraph->where = gwhere1; - agraph->vwgt = vwgt; - agraph->nvtxs = gnvtxs; - Moc_ComputeSerialBalance(ctrl, agraph, gwhere1, lbvec); - lbsum = ssum(ncon, lbvec); - - edgecut = ComputeSerialEdgeCut(agraph); - MPI_Allreduce((void *)&edgecut, (void *)&max_cut, 1, MPI_INT, MPI_MAX, ctrl->gcomm); - MPI_Allreduce((void *)&lbsum, (void *)&min_lbsum, 1, MPI_FLOAT, MPI_MIN, ctrl->gcomm); - - lpesum.sum = lbsum; - if (min_lbsum < UNBALANCE_FRACTION * (float)(ncon)) { - if (lbsum < UNBALANCE_FRACTION * (float)(ncon)) - lpesum.sum = (float) (edgecut); - else - lpesum.sum = (float) (max_cut); - } - - MPI_Comm_rank(ctrl->gcomm, &(lpesum.rank)); - MPI_Allreduce((void *)&lpesum, (void *)&gpesum, 1, MPI_FLOAT_INT, MPI_MINLOC, ctrl->gcomm); - MPI_Bcast((void *)gwhere1, gnvtxs, IDX_DATATYPE, gpesum.rank, ctrl->gcomm); - - agraph->xadj = tmpxadj; - agraph->adjncy = tmpadjncy; - agraph->adjwgt = tmpadjwgt; - agraph->vwgt = tmpvwgt; - agraph->where = tmpwhere; - } - - idxcopy(graph->nvtxs, gwhere1+graph->vtxdist[ctrl->mype], graph->where); - - FreeGraph(agraph); - MPI_Comm_free(&ipcomm); - GKfree((void **)&gwhere0, (void **)&gwhere1, (void **)&mytpwgts, (void **)&part, (void **)&xadj, (void **)&adjncy, (void **)&adjwgt, (void **)&vwgt, LTERM); - - IFSET(ctrl->dbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->InitPartTmr)); - -} - - -/************************************************************************* -* This function keeps one parts -**************************************************************************/ -void Moc_KeepPart(GraphType *graph, WorkSpaceType *wspace, idxtype *part, int mypart) -{ - int h, i, j, k; - int nvtxs, ncon, mynvtxs, mynedges; - idxtype *xadj, *vwgt, *adjncy, *adjwgt, *label; - idxtype *rename; - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - xadj = graph->xadj; - vwgt = graph->vwgt; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - label = graph->label; - - rename = idxmalloc(nvtxs, "Moc_KeepPart: rename"); - - for (mynvtxs=0, i=0; invtxs = mynvtxs; - graph->nedges = mynedges; - - free(rename); -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kmetis.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kmetis.c deleted file mode 100644 index 2ad20e3..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kmetis.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * kmetis.c - * - * This is the entry point of Moc_PARMETIS_PartGraphKway - * - * Started 10/19/96 - * George - * - * $Id: kmetis.c,v 1.9 2003/07/31 16:27:27 karypis Exp $ - * - */ - -#include - - -/*********************************************************************************** -* This function is the entry point of the parallel k-way multilevel partitionioner. -* This function assumes nothing about the graph distribution. -* It is the general case. -************************************************************************************/ -void ParMETIS_V3_PartKway(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, - idxtype *adjwgt, int *wgtflag, int *numflag, int *ncon, int *nparts, - float *tpwgts, float *ubvec, int *options, int *edgecut, idxtype *part, - MPI_Comm *comm) -{ - int h, i; - int nvtxs = -1, npes, mype; - CtrlType ctrl; - WorkSpaceType wspace; - GraphType *graph; - float avg, maximb, *mytpwgts; - int moptions[10]; - int seed, dbglvl = 0; - int iwgtflag, inumflag, incon, inparts, ioptions[10]; - float *itpwgts, iubvec[MAXNCON]; - - MPI_Comm_size(*comm, &npes); - MPI_Comm_rank(*comm, &mype); - - - /********************************/ - /* Try and take care bad inputs */ - /********************************/ - if (options != NULL && options[0] == 1) - dbglvl = options[PMV3_OPTION_DBGLVL]; - - CheckInputs(STATIC_PARTITION, npes, dbglvl, wgtflag, &iwgtflag, numflag, &inumflag, ncon, - &incon, nparts, &inparts, tpwgts, &itpwgts, ubvec, iubvec, NULL, NULL, - options, ioptions, part, comm); - - - /*********************************/ - /* Take care the nparts = 1 case */ - /*********************************/ - if (inparts <= 1) { - idxset(vtxdist[mype+1]-vtxdist[mype], 0, part); - *edgecut = 0; - return; - } - - /******************************/ - /* Take care of npes = 1 case */ - /******************************/ - if (npes == 1 && inparts > 1) { - moptions[0] = 0; - nvtxs = vtxdist[1]; - - if (incon == 1) { - METIS_WPartGraphKway(&nvtxs, xadj, adjncy, vwgt, adjwgt, &iwgtflag, &inumflag, - &inparts, itpwgts, moptions, edgecut, part); - } - else { - /* ADD: this is because METIS does not support tpwgts for all constraints */ - mytpwgts = fmalloc(inparts, "mytpwgts"); - for (i=0; inedges) == 0) { - IFSET(ctrl.dbglvl, DBG_INFO, rprintf(&ctrl, "Partitioning a graph of size %d serially\n", vtxdist[npes])); - PartitionSmallGraph(&ctrl, graph, &wspace); - } - else { - /***********************/ - /* Partition the graph */ - /***********************/ - Moc_Global_Partition(&ctrl, graph, &wspace); - ParallelReMapGraph(&ctrl, graph, &wspace); - } - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.TotalTmr)); - - idxcopy(graph->nvtxs, graph->where, part); - *edgecut = graph->mincut; - - /*******************/ - /* Print out stats */ - /*******************/ - IFSET(ctrl.dbglvl, DBG_TIME, PrintTimingInfo(&ctrl)); - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - - if (ctrl.dbglvl&DBG_INFO) { - rprintf(&ctrl, "Final %d-way CUT: %6d \tBalance: ", inparts, graph->mincut); - avg = 0.0; - for (h=0; hgnpwgts[i*incon+h]/itpwgts[i*incon+h]); - avg += maximb; - rprintf(&ctrl, "%.3f ", maximb); - } - rprintf(&ctrl, " avg: %.3f\n", avg/(float)incon); - } - - GKfree((void **)&itpwgts, (void **)&graph->lnpwgts, (void **)&graph->gnpwgts, (void **)&graph->nvwgt, LTERM); - FreeInitialGraphAndRemap(graph, iwgtflag); - FreeWSpace(&wspace); - FreeCtrl(&ctrl); - - if (inumflag == 1) - ChangeNumbering(vtxdist, xadj, adjncy, part, npes, mype, 0); - -} - - - -/************************************************************************* -* This function is the driver to the multi-constraint partitioning algorithm. -**************************************************************************/ -void Moc_Global_Partition(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, ncon, nparts; - float ftmp, ubavg, lbavg, lbvec[MAXNCON]; - - ncon = graph->ncon; - nparts = ctrl->nparts; - ubavg = savg(graph->ncon, ctrl->ubvec); - - SetUp(ctrl, graph, wspace); - - if (ctrl->dbglvl&DBG_PROGRESS) { - rprintf(ctrl, "[%6d %8d %5d %5d] [%d] [", graph->gnvtxs, GlobalSESum(ctrl, graph->nedges), - GlobalSEMin(ctrl, graph->nvtxs), GlobalSEMax(ctrl, graph->nvtxs), ctrl->CoarsenTo); - for (i=0; invwgt[samin_strd(graph->nvtxs, graph->nvwgt+i, ncon)*ncon+i])); - rprintf(ctrl, "] ["); - for (i=0; invwgt[samax_strd(graph->nvtxs, graph->nvwgt+i, ncon)*ncon+i])); - rprintf(ctrl, "]\n"); - } - - if (graph->gnvtxs < 1.3*ctrl->CoarsenTo || - (graph->finer != NULL && - graph->gnvtxs > graph->finer->gnvtxs*COARSEN_FRACTION)) { - - /* Done with coarsening. Find a partition */ - graph->where = idxmalloc(graph->nvtxs+graph->nrecv, "graph->where"); - Moc_InitPartition_RB(ctrl, graph, wspace); - - if (ctrl->dbglvl&DBG_PROGRESS) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - rprintf(ctrl, "nvtxs: %10d, balance: ", graph->gnvtxs); - for (i=0; incon; i++) - rprintf(ctrl, "%.3f ", lbvec[i]); - rprintf(ctrl, "\n"); - } - - /* In case no coarsening took place */ - if (graph->finer == NULL) { - Moc_ComputePartitionParams(ctrl, graph, wspace); - Moc_KWayFM(ctrl, graph, wspace, NGR_PASSES); - } - } - else { - Moc_GlobalMatch_Balance(ctrl, graph, wspace); - - Moc_Global_Partition(ctrl, graph->coarser, wspace); - - Moc_ProjectPartition(ctrl, graph, wspace); - Moc_ComputePartitionParams(ctrl, graph, wspace); - - if (graph->ncon > 1 && graph->level < 3) { - for (i=0; ignpwgts+i, ncon); - if (ftmp != 0.0) - lbvec[i] = (float)(nparts) * - graph->gnpwgts[samax_strd(nparts, graph->gnpwgts+i, ncon)*ncon+i]/ftmp; - else - lbvec[i] = 1.0; - } - lbavg = savg(graph->ncon, lbvec); - - if (lbavg > ubavg + 0.035) { - if (ctrl->dbglvl&DBG_PROGRESS) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - rprintf(ctrl, "nvtxs: %10d, cut: %8d, balance: ", graph->gnvtxs, graph->mincut); - for (i=0; incon; i++) - rprintf(ctrl, "%.3f ", lbvec[i]); - rprintf(ctrl, "\n"); - } - - Moc_KWayBalance(ctrl, graph, wspace, graph->ncon); - } - } - - Moc_KWayFM(ctrl, graph, wspace, NGR_PASSES); - - if (ctrl->dbglvl&DBG_PROGRESS) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - rprintf(ctrl, "nvtxs: %10d, cut: %8d, balance: ", graph->gnvtxs, graph->mincut); - for (i=0; incon; i++) - rprintf(ctrl, "%.3f ", lbvec[i]); - rprintf(ctrl, "\n"); - } - - if (graph->level != 0) - GKfree((void **)&graph->lnpwgts, (void **)&graph->gnpwgts, LTERM); - } - - return; -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwaybalance.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwaybalance.c deleted file mode 100644 index 003ec7c..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwaybalance.c +++ /dev/null @@ -1,456 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * mkwaybalance.c - * - * This file contains code that performs the k-way refinement - * - * Started 3/1/96 - * George - * - * $Id: kwaybalance.c,v 1.2 2003/07/21 17:18:49 karypis Exp $ - */ - -#include - -#define ProperSide(c, from, other) \ - (((c) == 0 && (from)-(other) < 0) || ((c) == 1 && (from)-(other) > 0)) - -/************************************************************************* -* This function performs k-way refinement -**************************************************************************/ -void Moc_KWayBalance(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace, int npasses) -{ - int h, i, ii, iii, j, k, c; - int pass, nvtxs, nedges, ncon; - int nmoves, nmoved, nswaps; -/* int gnswaps; */ - int me, firstvtx, lastvtx, yourlastvtx; - int from, to = -1, oldto, oldcut, mydomain, yourdomain, imbalanced; - int npes = ctrl->npes, mype = ctrl->mype, nparts = ctrl->nparts; - int nlupd, nsupd, nnbrs, nchanged; - idxtype *xadj, *ladjncy, *adjwgt, *vtxdist; - idxtype *where, *tmp_where, *moved; - float *lnpwgts, *gnpwgts; - idxtype *update, *supdate, *rupdate, *pe_updates; - idxtype *changed, *perm, *pperm, *htable; - idxtype *peind, *recvptr, *sendptr; - KeyValueType *swchanges, *rwchanges; - RInfoType *rinfo, *myrinfo, *tmp_myrinfo, *tmp_rinfo; - EdgeType *tmp_edegrees, *my_edegrees, *your_edegrees; - float lbvec[MAXNCON], *nvwgt, *badmaxpwgt, *ubvec, *tpwgts, lbavg, ubavg; - int *nupds_pe; -/* int ndirty, nclean, dptr; */ - - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->KWayTmr)); - - /*************************/ - /* set up common aliases */ - /*************************/ - nvtxs = graph->nvtxs; - nedges = graph->nedges; - ncon = graph->ncon; - - vtxdist = graph->vtxdist; - xadj = graph->xadj; - ladjncy = graph->adjncy; - adjwgt = graph->adjwgt; - - firstvtx = vtxdist[mype]; - lastvtx = vtxdist[mype+1]; - - where = graph->where; - rinfo = graph->rinfo; - lnpwgts = graph->lnpwgts; - gnpwgts = graph->gnpwgts; - ubvec = ctrl->ubvec; - tpwgts = ctrl->tpwgts; - - nnbrs = graph->nnbrs; - peind = graph->peind; - recvptr = graph->recvptr; - sendptr = graph->sendptr; - - changed = idxmalloc(nvtxs, "KWR: changed"); - rwchanges = wspace->pairs; - swchanges = rwchanges + recvptr[nnbrs]; - - /************************************/ - /* set up important data structures */ - /************************************/ - perm = idxmalloc(nvtxs, "KWR: perm"); - pperm = idxmalloc(nparts, "KWR: pperm"); - - update = idxmalloc(nvtxs, "KWR: update"); - supdate = wspace->indices; - rupdate = supdate + recvptr[nnbrs]; - nupds_pe = imalloc(npes, "KWR: nupds_pe"); - htable = idxsmalloc(nvtxs+graph->nrecv, 0, "KWR: lhtable"); - badmaxpwgt = fmalloc(nparts*ncon, "badmaxpwgt"); - - for (i=0; inrecv, "KWR: tmp_where"); - tmp_rinfo = (RInfoType *)GKmalloc(sizeof(RInfoType)*nvtxs, "KWR: tmp_rinfo"); - tmp_edegrees = (EdgeType *)GKmalloc(sizeof(EdgeType)*nedges, "KWR: tmp_edegrees"); - - idxcopy(nvtxs+graph->nrecv, where, tmp_where); - for (i=0; imincut; - if (mype == 0) - RandomPermute(nparts, pperm, 1); - MPI_Bcast((void *)pperm, nparts, IDX_DATATYPE, 0, ctrl->comm); - FastRandomPermute(nvtxs, perm, 1); - - /*****************************/ - /* move dirty vertices first */ - /*****************************/ -/* - ndirty = 0; - for (i=0; iwhere, lbvec); - ubavg = savg(ncon, ubvec); - lbavg = savg(ncon, lbvec); - imbalanced = (lbavg > ubavg) ? 1 : 0; - - for (c=0; c<2; c++) { - nmoved = 0; - - /**********************************************/ - /* PASS ONE -- record stats for desired moves */ - /**********************************************/ - for (iii=0; iiinvwgt+i*ncon; - - for (h=0; h= tmp_rinfo[i].id) { - my_edegrees = tmp_rinfo[i].degrees; - - for (k=0; k= nvtxs) - continue; - - me = ladjncy[j]; - mydomain = tmp_where[me]; - - myrinfo = tmp_rinfo+me; - your_edegrees = myrinfo->degrees; - - if (mydomain == from) { - INC_DEC(myrinfo->ed, myrinfo->id, adjwgt[j]); - } - else { - if (mydomain == to) { - INC_DEC(myrinfo->id, myrinfo->ed, adjwgt[j]); - } - } - - /* Remove contribution from the .ed of 'from' */ - if (mydomain != from) { - for (k=0; kndegrees; k++) { - if (your_edegrees[k].edge == from) { - if (your_edegrees[k].ewgt == adjwgt[j]) { - myrinfo->ndegrees--; - your_edegrees[k].edge = your_edegrees[myrinfo->ndegrees].edge; - your_edegrees[k].ewgt = your_edegrees[myrinfo->ndegrees].ewgt; - } - else { - your_edegrees[k].ewgt -= adjwgt[j]; - } - break; - } - } - } - - /* Add contribution to the .ed of 'to' */ - if (mydomain != to) { - for (k=0; kndegrees; k++) { - if (your_edegrees[k].edge == to) { - your_edegrees[k].ewgt += adjwgt[j]; - break; - } - } - if (k == myrinfo->ndegrees) { - your_edegrees[myrinfo->ndegrees].edge = to; - your_edegrees[myrinfo->ndegrees++].ewgt = adjwgt[j]; - } - } - } - } - } - } - } - - /*************************************************/ - /* PASS TWO -- commit the remainder of the moves */ - /*************************************************/ - nlupd = nsupd = nmoves = nchanged = 0; - for (iii=0; iiipexadj[i+1]-graph->pexadj[i] > 0) - changed[nchanged++] = i; - } - - /* Tell interested pe's the new where[] info for the interface vertices */ - CommChangedInterfaceData(ctrl, graph, nchanged, changed, where, - swchanges, rwchanges, wspace->pv4); - - - IFSET(ctrl->dbglvl, DBG_RMOVEINFO, - rprintf(ctrl, "\t[%d %d], [%.4f], [%d %d %d]\n", - pass, c, badmaxpwgt[0], - GlobalSESum(ctrl, nmoves), - GlobalSESum(ctrl, nsupd), - GlobalSESum(ctrl, nlupd))); - - /*------------------------------------------------------------- - / Time to communicate with processors to send the vertices - / whose degrees need to be update. - /-------------------------------------------------------------*/ - /* Issue the receives first */ - for (i=0; icomm, ctrl->rreq+i); - } - - /* Issue the sends next. This needs some preporcessing */ - for (i=0; iimap[supdate[i]]; - } - iidxsort(nsupd, supdate); - - for (j=i=0; icomm, ctrl->sreq+i); - j = k; - } - - /* OK, now get into the loop waiting for the send/recv operations to finish */ - MPI_Waitall(nnbrs, ctrl->rreq, ctrl->statuses); - for (i=0; istatuses+i, IDX_DATATYPE, nupds_pe+i); - MPI_Waitall(nnbrs, ctrl->sreq, ctrl->statuses); - - - /*------------------------------------------------------------- - / Place the recieved to-be updated vertices into update[] - /-------------------------------------------------------------*/ - for (i=0; idegrees; - your_edegrees = tmp_myrinfo->degrees; - - graph->lmincut -= myrinfo->ed; - myrinfo->ndegrees = 0; - myrinfo->id = 0; - myrinfo->ed = 0; - - for (j=xadj[i]; jed += adjwgt[j]; - - for (k=0; kndegrees; k++) { - if (my_edegrees[k].edge == yourdomain) { - my_edegrees[k].ewgt += adjwgt[j]; - your_edegrees[k].ewgt += adjwgt[j]; - break; - } - } - if (k == myrinfo->ndegrees) { - my_edegrees[k].edge = yourdomain; - my_edegrees[k].ewgt = adjwgt[j]; - your_edegrees[k].edge = yourdomain; - your_edegrees[k].ewgt = adjwgt[j]; - myrinfo->ndegrees++; - } - ASSERT(ctrl, myrinfo->ndegrees <= xadj[i+1]-xadj[i]); - ASSERT(ctrl, tmp_myrinfo->ndegrees <= xadj[i+1]-xadj[i]); - - } - else { - myrinfo->id += adjwgt[j]; - } - } - graph->lmincut += myrinfo->ed; - - tmp_myrinfo->id = myrinfo->id; - tmp_myrinfo->ed = myrinfo->ed; - tmp_myrinfo->ndegrees = myrinfo->ndegrees; - } - - /* finally, sum-up the partition weights */ - MPI_Allreduce((void *)lnpwgts, (void *)gnpwgts, nparts*ncon, - MPI_FLOAT, MPI_SUM, ctrl->comm); - } - graph->mincut = GlobalSESum(ctrl, graph->lmincut)/2; - - if (graph->mincut == oldcut) - break; - } - -/* - gnswaps = GlobalSESum(ctrl, nswaps); - if (mype == 0) - printf("niters: %d, nswaps: %d\n", pass+1, gnswaps); -*/ - - GKfree((void **)&badmaxpwgt, (void **)&update, (void **)&nupds_pe, (void **)&htable, LTERM); - GKfree((void **)&changed, (void **)&pperm, (void **)&perm, (void **)&moved, LTERM); - GKfree((void **)&tmp_where, (void **)&tmp_rinfo, (void **)&tmp_edegrees, LTERM); - - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->KWayTmr)); -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwayfm.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwayfm.c deleted file mode 100644 index 4d0849b..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwayfm.c +++ /dev/null @@ -1,599 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * mkwayfm.c - * - * This file contains code that performs the k-way refinement - * - * Started 3/1/96 - * George - * - * $Id: kwayfm.c,v 1.3 2003/07/22 20:29:05 karypis Exp $ - */ - -#include - -#define ProperSide(c, from, other) \ - (((c) == 0 && (from)-(other) < 0) || ((c) == 1 && (from)-(other) > 0)) - -/************************************************************************* -* This function performs k-way refinement -**************************************************************************/ -void Moc_KWayFM(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace, int npasses) -{ - int h, i, ii, iii, j, k, c; - int pass, nvtxs, nedges, ncon; - int nmoves, nmoved, nswaps, nzgswaps; -/* int gnswaps, gnzgswaps; */ - int me, firstvtx, lastvtx, yourlastvtx; - int from, to = -1, oldto, oldcut, mydomain, yourdomain, imbalanced, overweight; - int npes = ctrl->npes, mype = ctrl->mype, nparts = ctrl->nparts; - int nlupd, nsupd, nnbrs, nchanged; - idxtype *xadj, *ladjncy, *adjwgt, *vtxdist; - idxtype *where, *tmp_where, *moved; - float *lnpwgts, *gnpwgts, *ognpwgts, *pgnpwgts, *movewgts, *overfill; - idxtype *update, *supdate, *rupdate, *pe_updates; - idxtype *changed, *perm, *pperm, *htable; - idxtype *peind, *recvptr, *sendptr; - KeyValueType *swchanges, *rwchanges; - RInfoType *rinfo, *myrinfo, *tmp_myrinfo, *tmp_rinfo; - EdgeType *tmp_edegrees, *my_edegrees, *your_edegrees; - float lbvec[MAXNCON], *nvwgt, *badmaxpwgt, *ubvec, *tpwgts, lbavg, ubavg; - int *nupds_pe; - - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->KWayTmr)); - - /*************************/ - /* set up common aliases */ - /*************************/ - nvtxs = graph->nvtxs; - nedges = graph->nedges; - ncon = graph->ncon; - - vtxdist = graph->vtxdist; - xadj = graph->xadj; - ladjncy = graph->adjncy; - adjwgt = graph->adjwgt; - - firstvtx = vtxdist[mype]; - lastvtx = vtxdist[mype+1]; - - where = graph->where; - rinfo = graph->rinfo; - lnpwgts = graph->lnpwgts; - gnpwgts = graph->gnpwgts; - ubvec = ctrl->ubvec; - tpwgts = ctrl->tpwgts; - - nnbrs = graph->nnbrs; - peind = graph->peind; - recvptr = graph->recvptr; - sendptr = graph->sendptr; - - changed = idxmalloc(nvtxs, "KWR: changed"); - rwchanges = wspace->pairs; - swchanges = rwchanges + recvptr[nnbrs]; - - /************************************/ - /* set up important data structures */ - /************************************/ - perm = idxmalloc(nvtxs, "KWR: perm"); - pperm = idxmalloc(nparts, "KWR: pperm"); - - update = idxmalloc(nvtxs, "KWR: update"); - supdate = wspace->indices; - rupdate = supdate + recvptr[nnbrs]; - nupds_pe = imalloc(npes, "KWR: nupds_pe"); - htable = idxsmalloc(nvtxs+graph->nrecv, 0, "KWR: lhtable"); - badmaxpwgt = fmalloc(nparts*ncon, "badmaxpwgt"); - - for (i=0; inrecv, "KWR: tmp_where"); - tmp_rinfo = (RInfoType *)GKmalloc(sizeof(RInfoType)*nvtxs, "KWR: tmp_rinfo"); - tmp_edegrees = (EdgeType *)GKmalloc(sizeof(EdgeType)*nedges, "KWR: tmp_edegrees"); - - idxcopy(nvtxs+graph->nrecv, where, tmp_where); - for (i=0; icomm); - FastRandomPermute(nvtxs, perm, 1); - oldcut = graph->mincut; - - /* check to see if the partitioning is imbalanced */ - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - ubavg = savg(ncon, ubvec); - lbavg = savg(ncon, lbvec); - imbalanced = (lbavg > ubavg) ? 1 : 0; - - for (c=0; c<2; c++) { - scopy(ncon*nparts, gnpwgts, ognpwgts); - sset(ncon*nparts, 0.0, movewgts); - nmoved = 0; - - /**********************************************/ - /* PASS ONE -- record stats for desired moves */ - /**********************************************/ - for (iii=0; iiinvwgt+i*ncon; - - for (h=0; h= tmp_rinfo[i].id) { - my_edegrees = tmp_rinfo[i].degrees; - - for (k=0; k badmaxpwgt[to*ncon+h] && nvwgt[h] > 0.0) - break; - - if (h == ncon) - break; - } - } - oldto = to; - - /* check if a subdomain was found that fits */ - if (k < tmp_rinfo[i].ndegrees) { - for (j=k+1; j badmaxpwgt[to*ncon+h] && nvwgt[h] > 0.0) - break; - - if (h == ncon) { - if (my_edegrees[j].ewgt > my_edegrees[k].ewgt || - (my_edegrees[j].ewgt == my_edegrees[k].ewgt && - IsHBalanceBetterTT(ncon,gnpwgts+oldto*ncon,gnpwgts+to*ncon,nvwgt,ubvec))){ - k = j; - oldto = my_edegrees[k].edge; - } - } - } - } - to = oldto; - - if (my_edegrees[k].ewgt > tmp_rinfo[i].id || - (my_edegrees[k].ewgt == tmp_rinfo[i].id && - (imbalanced || graph->level > 3 || iii % 8 == 0) && - IsHBalanceBetterFT(ncon,gnpwgts+from*ncon,gnpwgts+to*ncon,nvwgt,ubvec))){ - - /****************************************/ - /* Update tmp arrays of the moved vertex */ - /****************************************/ - tmp_where[i] = to; - moved[nmoved++] = i; - for (h=0; h= nvtxs) - continue; - - me = ladjncy[j]; - mydomain = tmp_where[me]; - - myrinfo = tmp_rinfo+me; - your_edegrees = myrinfo->degrees; - - if (mydomain == from) { - INC_DEC(myrinfo->ed, myrinfo->id, adjwgt[j]); - } - else { - if (mydomain == to) { - INC_DEC(myrinfo->id, myrinfo->ed, adjwgt[j]); - } - } - - /* Remove contribution from the .ed of 'from' */ - if (mydomain != from) { - for (k=0; kndegrees; k++) { - if (your_edegrees[k].edge == from) { - if (your_edegrees[k].ewgt == adjwgt[j]) { - myrinfo->ndegrees--; - your_edegrees[k].edge = your_edegrees[myrinfo->ndegrees].edge; - your_edegrees[k].ewgt = your_edegrees[myrinfo->ndegrees].ewgt; - } - else { - your_edegrees[k].ewgt -= adjwgt[j]; - } - break; - } - } - } - - /* Add contribution to the .ed of 'to' */ - if (mydomain != to) { - for (k=0; kndegrees; k++) { - if (your_edegrees[k].edge == to) { - your_edegrees[k].ewgt += adjwgt[j]; - break; - } - } - if (k == myrinfo->ndegrees) { - your_edegrees[myrinfo->ndegrees].edge = to; - your_edegrees[myrinfo->ndegrees++].ewgt = adjwgt[j]; - } - } - } - } - } - } - } - - /******************************************/ - /* Let processors know the subdomain wgts */ - /* if all proposed moves commit. */ - /******************************************/ - MPI_Allreduce((void *)lnpwgts, (void *)pgnpwgts, nparts*ncon, - MPI_FLOAT, MPI_SUM, ctrl->comm); - - /**************************/ - /* compute overfill array */ - /**************************/ - overweight = 0; - for (j=0; j ognpwgts[j*ncon+h]) { - overfill[j*ncon+h] = - (pgnpwgts[j*ncon+h]-badmaxpwgt[j*ncon+h]) / - (pgnpwgts[j*ncon+h]-ognpwgts[j*ncon+h]); - } - else { - overfill[j*ncon+h] = 0.0; - } - - overfill[j*ncon+h] = amax(overfill[j*ncon+h], 0.0); - overfill[j*ncon+h] *= movewgts[j*ncon+h]; - - if (overfill[j*ncon+h] > 0.0) - overweight = 1; - - ASSERTP(ctrl, ognpwgts[j*ncon+h] <= badmaxpwgt[j*ncon+h] || - pgnpwgts[j*ncon+h] <= ognpwgts[j*ncon+h], - (ctrl, "%.4f %.4f %.4f\n", ognpwgts[j*ncon+h], - badmaxpwgt[j*ncon+h], pgnpwgts[j*ncon+h])); - } - } - - /****************************************************/ - /* select moves to undo according to overfill array */ - /****************************************************/ - if (overweight == 1) { - for (iii=0; iiinvwgt+i*ncon; - my_edegrees = tmp_rinfo[i].degrees; - - for (k=0; k 0.0 && overfill[oldto*ncon+h] > nvwgt[h]/4.0) - break; - - /**********************************/ - /* nullify this move if necessary */ - /**********************************/ - if (k != tmp_rinfo[i].ndegrees && h != ncon) { - moved[iii] = -1; - from = oldto; - to = where[i]; - - for (h=0; h= nvtxs) - continue; - - me = ladjncy[j]; - mydomain = tmp_where[me]; - - myrinfo = tmp_rinfo+me; - your_edegrees = myrinfo->degrees; - - if (mydomain == from) { - INC_DEC(myrinfo->ed, myrinfo->id, adjwgt[j]); - } - else { - if (mydomain == to) { - INC_DEC(myrinfo->id, myrinfo->ed, adjwgt[j]); - } - } - - /* Remove contribution from the .ed of 'from' */ - if (mydomain != from) { - for (k=0; kndegrees; k++) { - if (your_edegrees[k].edge == from) { - if (your_edegrees[k].ewgt == adjwgt[j]) { - myrinfo->ndegrees--; - your_edegrees[k].edge = your_edegrees[myrinfo->ndegrees].edge; - your_edegrees[k].ewgt = your_edegrees[myrinfo->ndegrees].ewgt; - } - else { - your_edegrees[k].ewgt -= adjwgt[j]; - } - break; - } - } - } - - /* Add contribution to the .ed of 'to' */ - if (mydomain != to) { - for (k=0; kndegrees; k++) { - if (your_edegrees[k].edge == to) { - your_edegrees[k].ewgt += adjwgt[j]; - break; - } - } - if (k == myrinfo->ndegrees) { - your_edegrees[myrinfo->ndegrees].edge = to; - your_edegrees[myrinfo->ndegrees++].ewgt = adjwgt[j]; - } - } - } - } - } - } - - /*************************************************/ - /* PASS TWO -- commit the remainder of the moves */ - /*************************************************/ - nlupd = nsupd = nmoves = nchanged = 0; - for (iii=0; iiipexadj[i+1]-graph->pexadj[i] > 0) - changed[nchanged++] = i; - } - - /* Tell interested pe's the new where[] info for the interface vertices */ - CommChangedInterfaceData(ctrl, graph, nchanged, changed, where, - swchanges, rwchanges, wspace->pv4); - - - IFSET(ctrl->dbglvl, DBG_RMOVEINFO, - rprintf(ctrl, "\t[%d %d], [%.4f], [%d %d %d]\n", - pass, c, badmaxpwgt[0], - GlobalSESum(ctrl, nmoves), - GlobalSESum(ctrl, nsupd), - GlobalSESum(ctrl, nlupd))); - - /*------------------------------------------------------------- - / Time to communicate with processors to send the vertices - / whose degrees need to be update. - /-------------------------------------------------------------*/ - /* Issue the receives first */ - for (i=0; icomm, ctrl->rreq+i); - } - - /* Issue the sends next. This needs some preporcessing */ - for (i=0; iimap[supdate[i]]; - } - iidxsort(nsupd, supdate); - - for (j=i=0; icomm, ctrl->sreq+i); - j = k; - } - - /* OK, now get into the loop waiting for the send/recv operations to finish */ - MPI_Waitall(nnbrs, ctrl->rreq, ctrl->statuses); - for (i=0; istatuses+i, IDX_DATATYPE, nupds_pe+i); - MPI_Waitall(nnbrs, ctrl->sreq, ctrl->statuses); - - - /*------------------------------------------------------------- - / Place the recieved to-be updated vertices into update[] - /-------------------------------------------------------------*/ - for (i=0; idegrees; - your_edegrees = tmp_myrinfo->degrees; - - graph->lmincut -= myrinfo->ed; - myrinfo->ndegrees = 0; - myrinfo->id = 0; - myrinfo->ed = 0; - - for (j=xadj[i]; jed += adjwgt[j]; - - for (k=0; kndegrees; k++) { - if (my_edegrees[k].edge == yourdomain) { - my_edegrees[k].ewgt += adjwgt[j]; - your_edegrees[k].ewgt += adjwgt[j]; - break; - } - } - if (k == myrinfo->ndegrees) { - my_edegrees[k].edge = yourdomain; - my_edegrees[k].ewgt = adjwgt[j]; - your_edegrees[k].edge = yourdomain; - your_edegrees[k].ewgt = adjwgt[j]; - myrinfo->ndegrees++; - } - ASSERT(ctrl, myrinfo->ndegrees <= xadj[i+1]-xadj[i]); - ASSERT(ctrl, tmp_myrinfo->ndegrees <= xadj[i+1]-xadj[i]); - - } - else { - myrinfo->id += adjwgt[j]; - } - } - graph->lmincut += myrinfo->ed; - - tmp_myrinfo->id = myrinfo->id; - tmp_myrinfo->ed = myrinfo->ed; - tmp_myrinfo->ndegrees = myrinfo->ndegrees; - } - - /* finally, sum-up the partition weights */ - MPI_Allreduce((void *)lnpwgts, (void *)gnpwgts, nparts*ncon, - MPI_FLOAT, MPI_SUM, ctrl->comm); - } - graph->mincut = GlobalSESum(ctrl, graph->lmincut)/2; - - if (graph->mincut == oldcut) - break; - } - -/* - gnswaps = GlobalSESum(ctrl, nswaps); - gnzgswaps = GlobalSESum(ctrl, nzgswaps); - if (mype == 0) - printf("niters: %d, nswaps: %d, nzgswaps: %d\n", pass+1, gnswaps, gnzgswaps); -*/ - - GKfree((void **)&badmaxpwgt, (void **)&update, (void **)&nupds_pe, (void **)&htable, LTERM); - GKfree((void **)&changed, (void **)&pperm, (void **)&perm, (void **)&moved, LTERM); - GKfree((void **)&pgnpwgts, (void **)&ognpwgts, (void **)&overfill, (void **)&movewgts, LTERM); - GKfree((void **)&tmp_where, (void **)&tmp_rinfo, (void **)&tmp_edegrees, LTERM); - - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->KWayTmr)); -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwayrefine.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwayrefine.c deleted file mode 100644 index e4b776e..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/kwayrefine.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * medge_refine.c - * - * This file contains code that performs the k-way refinement - * - * Started 3/1/96 - * George - * - * $Id: kwayrefine.c,v 1.2 2003/07/21 17:18:49 karypis Exp $ - */ - -#include - -#define ProperSide(c, from, other) \ - (((c) == 0 && (from)-(other) < 0) || ((c) == 1 && (from)-(other) > 0)) - -/************************************************************************* -* This function projects a partition. -**************************************************************************/ -void Moc_ProjectPartition(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, nvtxs, nnbrs = -1, firstvtx, cfirstvtx; - idxtype *match, *cmap, *where, *cwhere; - idxtype *peind, *slens = NULL, *rlens = NULL; - KeyValueType *rcand, *scand = NULL; - GraphType *cgraph; - - - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->ProjectTmr)); - - cgraph = graph->coarser; - cwhere = cgraph->where; - cfirstvtx = cgraph->vtxdist[ctrl->mype]; - - nvtxs = graph->nvtxs; - match = graph->match; - cmap = graph->cmap; - where = graph->where = idxmalloc(nvtxs+graph->nrecv, "ProjectPartition: graph->where"); - firstvtx = graph->vtxdist[ctrl->mype]; - - - if (graph->match_type == MATCH_GLOBAL) { /* Only if global matching is on */ - /*------------------------------------------------------------ - / Start the transmission of the remote where information - /------------------------------------------------------------*/ - scand = wspace->pairs; - nnbrs = graph->nnbrs; - peind = graph->peind; - slens = graph->slens; - rlens = graph->rlens; - rcand = graph->rcand; - - /* Issue the receives first */ - for (i=0; i 0) /* Issue a receive only if you are getting something */ - MPI_Irecv((void *)(scand+slens[i]), 2*(slens[i+1]-slens[i]), IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->rreq+i); - } - -#ifdef DEBUG_PROJECT - PrintPairs(ctrl, rlens[nnbrs], rcand, "rcand"); -#endif - - /* Put the where[rcand[].key] into the val field */ - for (i=0; i= 0 && rcand[i].val < cgraph->nvtxs); - rcand[i].val = cwhere[rcand[i].val]; - } - -#ifdef DEBUG_PROJECT - PrintPairs(ctrl, rlens[nnbrs], rcand, "rcand"); - PrintVector(ctrl, nvtxs, firstvtx, cmap, "cmap"); -#endif - - /* Issue the sends next */ - for (i=0; i 0) /* Issue a send only if you are sending something */ - MPI_Isend((void *)(rcand+rlens[i]), 2*(rlens[i+1]-rlens[i]), IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->sreq+i); - } - } - - /*------------------------------------------------------------ - / Project local vertices first - /------------------------------------------------------------*/ - for (i=0; i= KEEP_BIT) { - ASSERT(ctrl, cmap[i]-cfirstvtx>=0 && cmap[i]-cfirstvtxnvtxs); - where[i] = cwhere[cmap[i]-cfirstvtx]; - } - } - - if (graph->match_type == MATCH_GLOBAL) { /* Only if global matching is on */ - /*------------------------------------------------------------ - / Wait for the nonblocking operations to finish - /------------------------------------------------------------*/ - for (i=0; i 0) - MPI_Wait(ctrl->sreq+i, &ctrl->status); - } - for (i=0; i 0) - MPI_Wait(ctrl->rreq+i, &ctrl->status); - } - -#ifdef DEBUG_PROJECT - PrintPairs(ctrl, slens[nnbrs], scand, "scand"); -#endif - - /*------------------------------------------------------------ - / Project received vertices now - /------------------------------------------------------------*/ - for (i=0; i=0 && scand[i].key-firstvtxnvtxs, (ctrl, "%d %d %d\n", scand[i].key, firstvtx, graph->nvtxs)); - where[scand[i].key-firstvtx] = scand[i].val; - } - } - - - FreeGraph(graph->coarser); - graph->coarser = NULL; - - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->ProjectTmr)); -} - - - -/************************************************************************* -* This function computes the initial id/ed -**************************************************************************/ -void Moc_ComputePartitionParams(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int h, i, j, k; - int nvtxs, ncon; - int firstvtx, lastvtx; - idxtype *xadj, *ladjncy, *adjwgt, *vtxdist; - float *lnpwgts, *gnpwgts; - idxtype *where, *swhere, *rwhere; - RInfoType *rinfo, *myrinfo; - EdgeType *edegrees; - int me, other; - - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->KWayInitTmr)); - - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - - vtxdist = graph->vtxdist; - xadj = graph->xadj; - ladjncy = graph->adjncy; - adjwgt = graph->adjwgt; - - where = graph->where; - rinfo = graph->rinfo = (RInfoType *)GKmalloc(sizeof(RInfoType)*nvtxs, "CPP: rinfo"); - lnpwgts = graph->lnpwgts = fmalloc(ctrl->nparts*ncon, "CPP: lnpwgts"); - gnpwgts = graph->gnpwgts = fmalloc(ctrl->nparts*ncon, "CPP: gnpwgts"); - - sset(ctrl->nparts*ncon, 0, lnpwgts); - - firstvtx = vtxdist[ctrl->mype]; - lastvtx = vtxdist[ctrl->mype+1]; - - /*------------------------------------------------------------ - / Send/Receive the where information of interface vertices - /------------------------------------------------------------*/ - swhere = wspace->indices; - rwhere = where + nvtxs; - - CommInterfaceData(ctrl, graph, where, swhere, rwhere); - -#ifdef DEBUG_COMPUTEPPARAM - PrintVector(ctrl, nvtxs, firstvtx, where, "where"); -#endif - - ASSERT(ctrl, wspace->nlarge >= xadj[nvtxs]); - - /*------------------------------------------------------------ - / Compute now the id/ed degrees - /------------------------------------------------------------*/ - graph->lmincut = 0; - for (i=0; invwgt[i*ncon+h]; - - myrinfo->degrees = wspace->degrees + xadj[i]; - myrinfo->ndegrees = myrinfo->id = myrinfo->ed = 0; - - for (j=xadj[i]; jid += adjwgt[j]; - else - myrinfo->ed += adjwgt[j]; - } - - - if (myrinfo->ed > 0) { /* Time to do some serious work */ - graph->lmincut += myrinfo->ed; - edegrees = myrinfo->degrees; - - for (j=xadj[i]; jndegrees; k++) { - if (edegrees[k].edge == other) { - edegrees[k].ewgt += adjwgt[j]; - break; - } - } - if (k == myrinfo->ndegrees) { - edegrees[k].edge = other; - edegrees[k].ewgt = adjwgt[j]; - myrinfo->ndegrees++; - } - ASSERT(ctrl, myrinfo->ndegrees <= xadj[i+1]-xadj[i]); - } - } - } - } - -#ifdef DEBUG_COMPUTEPPARAM - PrintVector(ctrl, ctrl->nparts*ncon, 0, lnpwgts, "lnpwgts"); -#endif - - /* Finally, sum-up the partition weights */ - MPI_Allreduce((void *)lnpwgts, (void *)gnpwgts, ctrl->nparts*ncon, MPI_FLOAT, MPI_SUM, ctrl->comm); - - graph->mincut = GlobalSESum(ctrl, graph->lmincut)/2; - -#ifdef DEBUG_COMPUTEPPARAM - PrintVector(ctrl, ctrl->nparts*ncon, 0, gnpwgts, "gnpwgts"); -#endif - - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->KWayInitTmr)); -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/lmatch.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/lmatch.c deleted file mode 100644 index d8601ef..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/lmatch.c +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * coarsen.c - * - * This file contains code that finds a matching and performs the coarsening - * - * Started 2/22/96 - * George - * - * $Id: lmatch.c,v 1.2 2003/07/21 17:18:50 karypis Exp $ - * - */ - -#include - - -/************************************************************************* -* This function finds a HEM matching between local vertices only -**************************************************************************/ -void Mc_LocalMatch_HEM(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int h, i, ii, j, k; - int nvtxs, ncon, cnvtxs, firstvtx, maxi, maxidx, edge; - idxtype *xadj, *ladjncy, *adjwgt, *vtxdist, *home, *myhome, *shome, *rhome; - idxtype *perm, *match; - float maxnvwgt, *nvwgt; - - graph->match_type = MATCH_LOCAL; - maxnvwgt = 1.0/((float)(ctrl->nparts)*MAXVWGT_FACTOR); - - IFSET(ctrl->dbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->MatchTmr)); - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - xadj = graph->xadj; - nvwgt = graph->nvwgt; - ladjncy = graph->adjncy; - adjwgt = graph->adjwgt; - home = graph->home; - - vtxdist = graph->vtxdist; - firstvtx = vtxdist[ctrl->mype]; - - match = graph->match = idxmalloc(nvtxs+graph->nrecv, "HEM_Match: match"); - myhome = idxsmalloc(nvtxs+graph->nrecv, UNMATCHED, "HEM_Match: myhome"); - - idxset(nvtxs, UNMATCHED, match); - idxset(graph->nrecv, 0, match+nvtxs); /* Easy way to handle remote vertices */ - - /*------------------------------------------------------------ - / Send/Receive the home information of interface vertices - /------------------------------------------------------------*/ - if (ctrl->partType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) { - idxcopy(nvtxs, home, myhome); - shome = wspace->indices; - rhome = myhome + nvtxs; - CommInterfaceData(ctrl, graph, myhome, shome, rhome); - } - - /************************************************************* - * Go now and find a local matching - *************************************************************/ - perm = wspace->indices; - FastRandomPermute(nvtxs, perm, 1); - cnvtxs = 0; - for (ii=0; ii maxnvwgt) - break; - - if (h == ncon) { - for (j=xadj[i]; j= nvtxs) - continue; - - for (h=0; h maxnvwgt) - break; - - if (h == ncon) { - if (match[edge] == UNMATCHED && - (maxi == -1 || - adjwgt[maxi] < adjwgt[j] || - (adjwgt[maxi] == adjwgt[j] && - BetterVBalance(ncon,nvwgt+i*ncon,nvwgt+maxidx*ncon,nvwgt+edge*ncon) >= 0))) { - maxi = j; - maxidx = edge; - } - } - } - } - - if (maxi != -1) { - k = ladjncy[maxi]; - if (i <= k) { - match[i] = firstvtx+k + KEEP_BIT; - match[k] = firstvtx+i; - } - else { - match[i] = firstvtx+k; - match[k] = firstvtx+i + KEEP_BIT; - } - } - else { - match[i] = (firstvtx+i) + KEEP_BIT; - } - cnvtxs++; - } - } - - CommInterfaceData(ctrl, graph, match, wspace->indices, match+nvtxs); - GKfree((void **)(&myhome), LTERM); - -#ifdef DEBUG_MATCH - PrintVector2(ctrl, nvtxs, firstvtx, match, "Match1"); -#endif - - - if (ctrl->dbglvl&DBG_MATCHINFO) { - PrintVector2(ctrl, nvtxs, firstvtx, match, "Match"); - myprintf(ctrl, "Cnvtxs: %d\n", cnvtxs); - rprintf(ctrl, "Done with matching...\n"); - } - - IFSET(ctrl->dbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->MatchTmr)); - - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->ContractTmr)); - Mc_Local_CreateCoarseGraph(ctrl, graph, wspace, cnvtxs); - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->ContractTmr)); - -} - - - - - -/************************************************************************* -* This function creates the coarser graph -**************************************************************************/ -void Mc_Local_CreateCoarseGraph(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace, int cnvtxs) -{ - int h, i, j, k, l; - int nvtxs, ncon, nedges, firstvtx, cfirstvtx; - int npes=ctrl->npes, mype=ctrl->mype; - int cnedges, v, u; - idxtype *xadj, *vwgt, *vsize, *ladjncy, *adjwgt, *vtxdist, *where, *home; - idxtype *match, *cmap; - idxtype *cxadj, *cvwgt, *cvsize = NULL, *cadjncy, *cadjwgt, *cvtxdist, *chome = NULL, *cwhere = NULL; - float *cnvwgt; - GraphType *cgraph; - int mask=(1<<13)-1, htable[8192], htableidx[8192]; - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - - vtxdist = graph->vtxdist; - xadj = graph->xadj; - vwgt = graph->vwgt; - home = graph->home; - vsize = graph->vsize; - ladjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - match = graph->match; - - firstvtx = vtxdist[mype]; - - cmap = graph->cmap = idxmalloc(nvtxs+graph->nrecv, "CreateCoarseGraph: cmap"); - - /* Initialize the coarser graph */ - cgraph = CreateGraph(); - cgraph->nvtxs = cnvtxs; - cgraph->level = graph->level+1; - cgraph->ncon = ncon; - - cgraph->finer = graph; - graph->coarser = cgraph; - - - /************************************************************* - * Obtain the vtxdist of the coarser graph - **************************************************************/ - cvtxdist = cgraph->vtxdist = idxmalloc(npes+1, "CreateCoarseGraph: cvtxdist"); - cvtxdist[npes] = cnvtxs; /* Use last position in the cvtxdist as a temp buffer */ - - MPI_Allgather((void *)(cvtxdist+npes), 1, IDX_DATATYPE, (void *)cvtxdist, 1, IDX_DATATYPE, ctrl->comm); - - MAKECSR(i, npes, cvtxdist); - - cgraph->gnvtxs = cvtxdist[npes]; - -#ifdef DEBUG_CONTRACT - PrintVector(ctrl, npes+1, 0, cvtxdist, "cvtxdist"); -#endif - - - /************************************************************* - * Construct the cmap vector - **************************************************************/ - cfirstvtx = cvtxdist[mype]; - - /* Create the cmap of what you know so far locally */ - cnvtxs = 0; - for (i=0; i= KEEP_BIT) { - k = match[i] - KEEP_BIT; - if (kindices, cmap+nvtxs); - - -#ifdef DEBUG_CONTRACT - PrintVector(ctrl, nvtxs, firstvtx, cmap, "Cmap"); -#endif - - - - /************************************************************* - * Finally, create the coarser graph - **************************************************************/ - /* Allocate memory for the coarser graph, and fire up coarsening */ - cxadj = cgraph->xadj = idxmalloc(cnvtxs+1, "CreateCoarserGraph: cxadj"); - cvwgt = cgraph->vwgt = idxmalloc(cnvtxs*ncon, "CreateCoarserGraph: cvwgt"); - cnvwgt = cgraph->nvwgt = fmalloc(cnvtxs*ncon, "CreateCoarserGraph: cnvwgt"); - if (ctrl->partType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) - chome = cgraph->home = idxmalloc(cnvtxs, "CreateCoarserGraph: chome"); - if (vsize != NULL) - cvsize = cgraph->vsize = idxmalloc(cnvtxs, "CreateCoarserGraph: cvsize"); - if (where != NULL) - cwhere = cgraph->where = idxmalloc(cnvtxs, "CreateCoarserGraph: cwhere"); - cadjncy = idxmalloc(2*graph->nedges, "CreateCoarserGraph: cadjncy"); - cadjwgt = cadjncy+graph->nedges; - - iset(8192, -1, htable); - - cxadj[0] = cnvtxs = cnedges = 0; - for (i=0; i u) - continue; /* I have already collapsed it as (u,v) */ - - /* Collapse the v vertex first, which you know that is local */ - for (h=0; hpartType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) - chome[cnvtxs] = home[i]; - if (vsize != NULL) - cvsize[cnvtxs] = vsize[i]; - if (where != NULL) - cwhere[cnvtxs] = where[i]; - nedges = 0; - - for (j=xadj[i]; jnedges = cnedges; - - for (j=0; jnvwgt[j*ncon+h] = (float)(cvwgt[j*ncon+h])/(float)(ctrl->tvwgts[h]); - - cgraph->adjncy = idxmalloc(cnedges, "CreateCoarserGraph: cadjncy"); - cgraph->adjwgt = idxmalloc(cnedges, "CreateCoarserGraph: cadjwgt"); - idxcopy(cnedges, cadjncy, cgraph->adjncy); - idxcopy(cnedges, cadjwgt, cgraph->adjwgt); - GKfree((void **)&cadjncy, (void **)&graph->where, LTERM); /* Note that graph->where works fine even if it is NULL */ - -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/macros.h b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/macros.h deleted file mode 100644 index 31861f7..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/macros.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * macros.h - * - * This file contains macros used in multilevel - * - * Started 9/25/94 - * George - * - * $Id: macros.h,v 1.8 2003/07/21 19:11:46 karypis Exp $ - * - */ - - -/************************************************************************* -* The following macro returns a random number in the specified range -**************************************************************************/ -#define RandomInRange(u) ((int)(1.0*(u)*rand()/(RAND_MAX+1.0))) - -#define amax(a, b) ((a) >= (b) ? (a) : (b)) -#define amin(a, b) ((a) >= (b) ? (b) : (a)) - -#define AND(a, b) ((a) < 0 ? ((-(a))&(b)) : ((a)&(b))) -#define OR(a, b) ((a) < 0 ? -((-(a))|(b)) : ((a)|(b))) -#define XOR(a, b) ((a) < 0 ? -((-(a))^(b)) : ((a)^(b))) - -#define SWAP(a, b, tmp) \ - do {(tmp) = (a); (a) = (b); (b) = (tmp);} while(0) - -#define INC_DEC(a, b, val) \ - do {(a) += (val); (b) -= (val);} while(0) - - -#define icopy(n, a, b) memcpy((b), (a), sizeof(int)*(n)) -#define scopy(n, a, b) memcpy((b), (a), sizeof(float)*(n)) -#define idxcopy(n, a, b) memcpy((b), (a), sizeof(idxtype)*(n)) - -#define HASHFCT(key, size) ((key)%(size)) - - -/************************************************************************* -* Timer macros -**************************************************************************/ -#define cleartimer(tmr) (tmr = 0.0) -#define starttimer(tmr) (tmr -= MPI_Wtime()) -#define stoptimer(tmr) (tmr += MPI_Wtime()) -#define gettimer(tmr) (tmr) - - -/************************************************************************* -* This macro is used to handle dbglvl -**************************************************************************/ -#define IFSET(a, flag, cmd) if ((a)&(flag)) (cmd); - -/************************************************************************* -* These macros are used for debuging memory leaks -**************************************************************************/ -#ifdef DMALLOC -#define imalloc(n, msg) (malloc(sizeof(int)*(n))) -#define fmalloc(n, msg) (malloc(sizeof(float)*(n))) -#define idxmalloc(n, msg) (malloc(sizeof(idxtype)*(n))) -#define ismalloc(n, val, msg) (iset((n), (val), malloc(sizeof(int)*(n)))) -#define idxsmalloc(n, val, msg) (idxset((n), (val), malloc(sizeof(idxtype)*(n)))) -#define GKmalloc(a, b) (malloc(a)) -#endif - -#ifdef DMALLOC -# define MALLOC_CHECK(ptr); -/* -# define MALLOC_CHECK(ptr) \ - if (malloc_verify((ptr)) == DMALLOC_VERIFY_ERROR) { \ - printf("***MALLOC_CHECK failed on line %d of file %s: " #ptr "\n", \ - __LINE__, __FILE__); \ - abort(); \ - } -*/ -#else -# define MALLOC_CHECK(ptr) ; -#endif - -/************************************************************************* -* This macro converts a length array in a CSR one -**************************************************************************/ -#define MAKECSR(i, n, a) \ - do { \ - for (i=1; i0; i--) a[i] = a[i-1]; \ - a[0] = 0; \ - } while(0) - - -#define SHIFTCSR(i, n, a) \ - do { \ - for (i=n; i>0; i--) a[i] = a[i-1]; \ - a[0] = 0; \ - } while(0) - - - -#ifdef DEBUG -# define ASSERT(ctrl, expr) \ - if (!(expr)) { \ - myprintf(ctrl, "***ASSERTION failed on line %d of file %s: " #expr "\n", \ - __LINE__, __FILE__); \ - abort(); \ - } -#else -# define ASSERT(ctrl, expr) ; -#endif - -#ifdef DEBUG -# define ASSERTP(ctrl, expr, msg) \ - if (!(expr)) { \ - myprintf(ctrl, "***ASSERTION failed on line %d of file %s:" #expr "\n", \ - __LINE__, __FILE__); \ - myprintf msg ; \ - abort(); \ - } -#else -# define ASSERTP(ctrl, expr,msg) ; -#endif - -#ifdef DEBUGS -# define ASSERTS(expr) \ - if (!(expr)) { \ - printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \ - __LINE__, __FILE__); \ - abort(); \ - } -#else -# define ASSERTS(expr) ; -#endif - -#ifdef DEBUGS -# define ASSERTSP(expr, msg) \ - if (!(expr)) { \ - printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \ - __LINE__, __FILE__); \ - printf msg ; \ - abort(); \ - } -#else -# define ASSERTSP(expr, msg) ; -#endif - -/************************************************************************* - * * These macros insert and remove nodes from the boundary list - * **************************************************************************/ -#define BNDInsert(nbnd, bndind, bndptr, vtx) \ - do { \ - bndind[nbnd] = vtx; \ - bndptr[vtx] = nbnd++;\ - } while(0) - -#define BNDDelete(nbnd, bndind, bndptr, vtx) \ - do { \ - bndind[bndptr[vtx]] = bndind[--nbnd]; \ - bndptr[bndind[nbnd]] = bndptr[vtx]; \ - bndptr[vtx] = -1; \ - } while(0) - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/match.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/match.c deleted file mode 100644 index 89bfa62..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/match.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * mmatch.c - * - * This file contains code that finds a matching - * - * Started 2/22/96 - * George - * - * $Id: match.c,v 1.2 2003/07/21 17:18:50 karypis Exp $ - * - */ - -#include - - -/************************************************************************* -* This function finds a matching -**************************************************************************/ -void Moc_GlobalMatch_Balance(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int h, i, ii, j, k; - int nnbrs, nvtxs, ncon, cnvtxs, firstvtx, lastvtx, maxi, maxidx, nkept; - int otherlastvtx, nrequests, nchanged, pass, nmatched, wside; - idxtype *xadj, *ladjncy, *adjwgt, *vtxdist, *home, *myhome, *shome, *rhome; - idxtype *match, *rmatch, *smatch; - idxtype *peind, *sendptr, *recvptr; - idxtype *perm, *iperm, *nperm, *changed; - float *nvwgt, maxnvwgt; - int *nreqs_pe; - KeyValueType *match_requests, *match_granted, *pe_requests; - - maxnvwgt = 1.0/((float)(ctrl->nparts)*MAXNVWGT_FACTOR); - - graph->match_type = MATCH_GLOBAL; - - IFSET(ctrl->dbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->MatchTmr)); - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - xadj = graph->xadj; - ladjncy = graph->adjncy; - adjwgt = graph->adjwgt; - home = graph->home; - nvwgt = graph->nvwgt; - - vtxdist = graph->vtxdist; - firstvtx = vtxdist[ctrl->mype]; - lastvtx = vtxdist[ctrl->mype+1]; - - match = graph->match = idxsmalloc(nvtxs+graph->nrecv, UNMATCHED, "HEM_Match: match"); - myhome = idxsmalloc(nvtxs+graph->nrecv, UNMATCHED, "HEM_Match: myhome"); - - /*------------------------------------------------------------ - / Send/Receive the home information of interface vertices - /------------------------------------------------------------*/ - if (ctrl->partType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) { - idxcopy(nvtxs, home, myhome); - shome = wspace->indices; - rhome = myhome + nvtxs; - CommInterfaceData(ctrl, graph, myhome, shome, rhome); - } - - nnbrs = graph->nnbrs; - peind = graph->peind; - sendptr = graph->sendptr; - recvptr = graph->recvptr; - - /* Use wspace->indices as the tmp space for matching info of the boundary - * vertices that are sent and received */ - rmatch = match + nvtxs; - smatch = wspace->indices; - changed = smatch+graph->nsend; - - /* Use wspace->indices as the tmp space for match requests of the boundary - * vertices that are sent and received */ - match_requests = wspace->pairs; - match_granted = match_requests + graph->nsend; - - nreqs_pe = ismalloc(nnbrs, 0, "Match_HEM: nreqs_pe"); - - nkept = graph->gnvtxs/ctrl->npes - nvtxs; - - perm = (idxtype *)wspace->degrees; - iperm = perm + nvtxs; - FastRandomPermute(nvtxs, perm, 1); - for (i=0; i maxnvwgt) { - break; - } - - if (h != ncon) { - match[i] = TOO_HEAVY; - nchanged++; - } - } - if (GlobalSESum(ctrl, nchanged) > 0) { - IFSET(ctrl->dbglvl, DBG_PROGRESS, - rprintf(ctrl, "We found %d heavy vertices!\n", GlobalSESum(ctrl, nchanged))); - CommInterfaceData(ctrl, graph, match, smatch, rmatch); - } - - - for (nmatched=pass=0; passlevel+pass)%2; - nchanged = nrequests = 0; - for (ii=nmatched; ii= 0))) { - maxi = j; - maxidx = k; - } - } - - if (maxi != -1) { - k = ladjncy[maxi]; - if (k < nvtxs) { /* Take care the local vertices first */ - /* Here we give preference the local matching by granting it right away */ - if (i <= k) { - match[i] = firstvtx+k + KEEP_BIT; - match[k] = firstvtx+i; - } - else { - match[i] = firstvtx+k; - match[k] = firstvtx+i + KEEP_BIT; - } - changed[nchanged++] = i; - changed[nchanged++] = k; - } - else { /* Take care any remote boundary vertices */ - match[k] = MAYBE_MATCHED; - /* Alternate among which vertices will issue the requests */ - if ((wside ==0 && firstvtx+i < graph->imap[k]) || (wside == 1 && firstvtx+i > graph->imap[k])) { - match[i] = MAYBE_MATCHED; - match_requests[nrequests].key = graph->imap[k]; - match_requests[nrequests].val = firstvtx+i; - nrequests++; - } - } - } - } - } - - -#ifdef DEBUG_MATCH - PrintVector2(ctrl, nvtxs, firstvtx, match, "Match1"); - myprintf(ctrl, "[c: %2d] Nlocal: %d, Nrequests: %d\n", c, nlocal, nrequests); -#endif - - - /*********************************************************** - * Exchange the match_requests, requests for me are stored in - * match_granted - ************************************************************/ - /* Issue the receives first. Note that from each PE can receive a maximum - of the interface node that it needs to send it in the case of a mat-vec */ - for (i=0; icomm, ctrl->rreq+i); - } - - /* Issue the sends next. This needs some work */ - ikeysort(nrequests, match_requests); - for (j=i=0; icomm, ctrl->sreq+i); - j = k; - } - - /* OK, now get into the loop waiting for the operations to finish */ - MPI_Waitall(nnbrs, ctrl->rreq, ctrl->statuses); - for (i=0; istatuses+i, IDX_DATATYPE, nreqs_pe+i); - nreqs_pe[i] = nreqs_pe[i]/2; /* Adjust for pairs of IDX_DATATYPE */ - } - MPI_Waitall(nnbrs, ctrl->sreq, ctrl->statuses); - - - /*********************************************************** - * Now, go and service the requests that you received in - * match_granted - ************************************************************/ - RandomPermute(nnbrs, nperm, 0); - for (ii=0; ii= firstvtx && k < lastvtx, (ctrl, "%d %d %d %d %d\n", firstvtx, lastvtx, k, j, peind[i])); - /* myprintf(ctrl, "Requesting a match %d %d\n", pe_requests[j].key, pe_requests[j].val); */ - if (match[k-firstvtx] == UNMATCHED) { /* Bingo, lets grant this request */ - changed[nchanged++] = k-firstvtx; - if (nkept >= 0) { /* Flip a coin for who gets it */ - match[k-firstvtx] = pe_requests[j].val + KEEP_BIT; - nkept--; - } - else { - match[k-firstvtx] = pe_requests[j].val; - pe_requests[j].key += KEEP_BIT; - nkept++; - } - /* myprintf(ctrl, "Request from pe:%d (%d %d) granted!\n", peind[i], pe_requests[j].val, pe_requests[j].key); */ - } - else { /* We are not granting the request */ - /* myprintf(ctrl, "Request from pe:%d (%d %d) not granted!\n", peind[i], pe_requests[j].val, pe_requests[j].key); */ - pe_requests[j].key = UNMATCHED; - } - } - } - - - /*********************************************************** - * Exchange the match_granted information. It is stored in - * match_requests - ************************************************************/ - /* Issue the receives first. Note that from each PE can receive a maximum - of the interface node that it needs to send during the case of a mat-vec */ - for (i=0; icomm, ctrl->rreq+i); - } - - /* Issue the sends next. */ - for (i=0; icomm, ctrl->sreq+i); - } - - /* OK, now get into the loop waiting for the operations to finish */ - MPI_Waitall(nnbrs, ctrl->rreq, ctrl->statuses); - for (i=0; istatuses+i, IDX_DATATYPE, nreqs_pe+i); - nreqs_pe[i] = nreqs_pe[i]/2; /* Adjust for pairs of IDX_DATATYPE */ - } - MPI_Waitall(nnbrs, ctrl->sreq, ctrl->statuses); - - - /*********************************************************** - * Now, go and through the match_requests and update local - * match information for the matchings that were granted. - ************************************************************/ - for (i=0; ipv4); - } - - /* Traverse the vertices and those that were unmatched, match them with themselves */ - cnvtxs = 0; - for (i=0; i= KEEP_BIT) { /* A matched vertex which I get to keep */ - cnvtxs++; - } - } - - if (ctrl->dbglvl&DBG_MATCHINFO) { - PrintVector2(ctrl, nvtxs, firstvtx, match, "Match"); - myprintf(ctrl, "Cnvtxs: %d\n", cnvtxs); - rprintf(ctrl, "Done with matching...\n"); - } - - GKfree((void **)(&myhome), (void **)(&nreqs_pe), LTERM); - - IFSET(ctrl->dbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->MatchTmr)); - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->ContractTmr)); - - Moc_Global_CreateCoarseGraph(ctrl, graph, wspace, cnvtxs); - - IFSET(ctrl->dbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->ContractTmr)); - -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mdiffusion.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mdiffusion.c deleted file mode 100644 index 6c02138..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mdiffusion.c +++ /dev/null @@ -1,455 +0,0 @@ -/* * Copyright 1997, Regents of the University of Minnesota - * - * mdiffusion.c - * - * This file contains code that performs mc-diffusion - * - * Started 9/16/99 - * George - * - * $Id: mdiffusion.c,v 1.2 2003/07/21 17:18:50 karypis Exp $ - */ - -#include - -#define PE -1 - -/************************************************************************* -* This function is the entry point of the initial partitioning algorithm. -* This algorithm assembles the graph to all the processors and preceed -* serially. -**************************************************************************/ -int Moc_Diffusion(CtrlType *ctrl, GraphType *graph, idxtype *vtxdist, - idxtype *where, idxtype *home, WorkSpaceType *wspace, int npasses) -{ - int h, i, j; - int nvtxs, nedges, ncon, pass, iter, domain, processor; - int nparts, mype, npes, nlinks, me, you, wsize; - int nvisited, nswaps = -1, tnswaps, done, alldone = -1; - idxtype *rowptr, *colind, *diff_where, *sr_where, *ehome, *map, *rmap; - idxtype *pack, *unpack, *match, *proc2sub, *sub2proc; - idxtype *visited, *gvisited; - float *transfer, *npwgts, maxdiff, minflow, maxflow; - float lbavg, oldlbavg, ubavg, lbvec[MAXNCON]; - float diff_flows[MAXNCON], sr_flows[MAXNCON]; - float diff_lbavg, sr_lbavg, diff_cost, sr_cost; - idxtype *rbuffer, *sbuffer; - int *rcount, *rdispl; - float *solution, *load, *workspace; - EdgeType *degrees; - MatrixType matrix; - GraphType *egraph; - RInfoType *rinfo; - - if (graph->ncon > 3) - return 0; - - nvtxs = graph->nvtxs; - nedges = graph->nedges; - ncon = graph->ncon; - - nparts = ctrl->nparts; - mype = ctrl->mype; - npes = ctrl->npes; - ubavg = savg(ncon, ctrl->ubvec); - - /********************************************/ - /* initialize variables and allocate memory */ - /********************************************/ - load = fmalloc(nparts*(2+ncon)+nedges*(1+ncon), "load"); - solution = load + nparts; - npwgts = graph->gnpwgts = load + 2*nparts; - matrix.values = load + (2+ncon)*nparts; - transfer = matrix.transfer = load + (2+ncon)*nparts + nedges; - - proc2sub = idxmalloc(amax(nparts, npes*2), "Mc_Diffusion: proc2sub"); - sub2proc = idxmalloc(nparts*3+nedges+1, "Mc_Diffusion: match"); - match = sub2proc + nparts; - rowptr = matrix.rowptr = sub2proc + 2*nparts; - colind = matrix.colind = sub2proc + 3*nparts + 1; - - rcount = imalloc(2*npes+1, "Mc_Diffusion: rcount"); - rdispl = rcount + npes; - - pack = idxmalloc(nvtxs*8, "Mc_Diffusion: pack"); - unpack = pack + nvtxs; - rbuffer = pack + 2*nvtxs; - sbuffer = pack + 3*nvtxs; - map = pack + 4*nvtxs; - rmap = pack + 5*nvtxs; - diff_where = pack + 6*nvtxs; - ehome = pack + 7*nvtxs; - - wsize = amax(sizeof(float)*nparts*6, sizeof(idxtype)*(nvtxs+nparts*2+1)); - workspace = (float *)GKmalloc(wsize, "Moc_Diffusion: workspace"); - degrees = GKmalloc(nedges*sizeof(EdgeType), "Mc_Diffusion: degrees"); - rinfo = graph->rinfo = GKmalloc(nvtxs*sizeof(RInfoType), "Mc_Diffusion: rinfo"); - - /******************************************/ - /* construct subdomain connectivity graph */ - /******************************************/ - matrix.nrows = nparts; - SetUpConnectGraph(graph, &matrix, (idxtype *)workspace); - nlinks = (matrix.nnzs-nparts) / 2; - - visited = idxmalloc(matrix.nnzs*2, "visited"); - gvisited = visited + matrix.nnzs; - - for (pass=0; passtpwgts, h); - - lbvec[h] = (load[samax(nparts, load)]+1.0/(float)nparts) * (float)nparts; - - ConjGrad2(&matrix, load, solution, 0.001, workspace); - ComputeTransferVector(ncon, &matrix, solution, transfer, h); - } - - oldlbavg = savg(ncon, lbvec); - tnswaps = 0; - maxdiff = 0.0; - for (i=0; i maxdiff) ? maxflow - minflow : maxdiff; - } - } - - while (nvisited < nlinks) { - - /******************************************/ - /* compute independent sets of subdomains */ - /******************************************/ - idxset(amax(nparts, npes*2), UNMATCHED, proc2sub); - CSR_Match_SHEM(&matrix, match, proc2sub, gvisited, ncon); - - /*****************************/ - /* Set up the packing arrays */ - /*****************************/ - idxset(nparts, UNMATCHED, sub2proc); - for (i=0; i0; i--) - rdispl[i] = rdispl[i-1]; - rdispl[0] = 0; - - idxset(nvtxs, UNMATCHED, pack); - for (i=0; i 0.0) - diff_flows[h] = -1.0 * transfer[j*ncon+h]; - break; - } - } - - nswaps = 1; - scopy(ncon, diff_flows, sr_flows); - - idxset(nvtxs, 0, sbuffer); - for (i=0; invtxs, egraph->where, diff_where); - for (j=0; jnvtxs; j++) - ehome[j] = home[map[j]]; - - RedoMyLink(ctrl, egraph, ehome, me, you, sr_flows, &sr_cost, &sr_lbavg); - - if (ncon <= 4) { - sr_where = egraph->where; - egraph->where = diff_where; - - nswaps = BalanceMyLink(ctrl, egraph, ehome, me, you, diff_flows, maxdiff, &diff_cost, &diff_lbavg, 1.0/(float)nvtxs); - - if ((sr_lbavg < diff_lbavg && - (diff_lbavg >= ubavg-1.0 || sr_cost == diff_cost)) || - (sr_lbavg < ubavg-1.0 && sr_cost < diff_cost)) { - for (i=0; invtxs; i++) - where[map[i]] = sr_where[i]; - } - else { - for (i=0; invtxs; i++) - where[map[i]] = diff_where[i]; - } - } - else { - for (i=0; invtxs; i++) - where[map[i]] = egraph->where[i]; - } - - GKfree((void **)&egraph->xadj, (void **)&egraph->nvwgt, (void **)&egraph->adjncy, LTERM); - GKfree((void **)&egraph, LTERM); - } - - /**********************/ - /* Pack the flow data */ - /**********************/ - idxset(nvtxs, UNMATCHED, sbuffer); - for (i=0; icomm); - - - /************************/ - /* Unpack the flow data */ - /************************/ - for (i=0; icomm); - nvisited = idxsum(matrix.nnzs, gvisited)/2; - tnswaps += GlobalSESum(ctrl, nswaps); - - if (iter++ == NGD_PASSES) - break; - } - - /*****************************/ - /* perform serial refinement */ - /*****************************/ - Moc_ComputeSerialPartitionParams(graph, nparts, degrees); - Moc_SerialKWayAdaptRefine(graph, nparts, home, ctrl->ubvec, 10); - - - /****************************/ - /* check for early breakout */ - /****************************/ - for (h=0; h= oldlbavg || - lbavg <= ubavg + 0.035 - ) - done = 1; - - alldone = GlobalSEMax(ctrl, done); - if (alldone == 1) - break; - } - - /*******************************************************/ - /* ensure that all subdomains have at least one vertex */ - /*******************************************************/ -/* - idxset(nparts, 0, match); - for (i=0; imype == PE) printf("WARNING: empty subdomain %d in Moc_Diffusion\n", me); - you = idxamax(nparts, match); - for (i=0; ignpwgts = NULL; - graph->rinfo = NULL; - - return 0; -} - - -/************************************************************************* -* This function extracts a subgraph from a graph given an indicator array. -**************************************************************************/ -GraphType *ExtractGraph(CtrlType *ctrl, GraphType *graph, idxtype *indicator, - idxtype *map, idxtype *rmap) -{ - int h, i, j; - int nvtxs, envtxs, enedges, ncon; - int vtx, count; - idxtype *xadj, *vsize, *adjncy, *adjwgt, *where; - idxtype *exadj, *evsize, *eadjncy, *eadjwgt, *ewhere; - float *nvwgt, *envwgt; - GraphType *egraph; - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - xadj = graph->xadj; - nvwgt = graph->nvwgt; - vsize = graph->vsize; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - - count = 0; - for (i=0; invtxs = count; - egraph->ncon = graph->ncon; - - exadj = egraph->xadj = idxmalloc(envtxs*3+1, "exadj"); - ewhere = egraph->where = exadj + envtxs + 1; - evsize = egraph->vsize = exadj + 2*envtxs + 1; - - envwgt = egraph->nvwgt = fmalloc(envtxs*ncon, "envwgt"); - - /************************************************/ - /* compute xadj, where, nvwgt, and vsize arrays */ - /************************************************/ - idxset(envtxs+1, 0, exadj); - for (i=0; ipartType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) - evsize[i] = vsize[vtx]; - - for (j=xadj[vtx]; jnedges = exadj[envtxs]; - eadjncy = egraph->adjncy = idxmalloc(enedges*2, "eadjncy"); - eadjwgt = egraph->adjwgt = eadjncy + enedges; - - for (i=0; i0; i--) - exadj[i] = exadj[i-1]; - exadj[0] = 0; - - return egraph; -} diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mdrivers.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mdrivers.c deleted file mode 100644 index 467df79..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mdrivers.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * mdrivers.c - * - * This file contains the driving routines for the various parallel - * multilevel partitioning and repartitioning algorithms - * - * Started 11/19/96 - * George - * - * $Id: mdrivers.c,v 1.3 2003/07/22 20:29:06 karypis Exp $ - * - */ - -#include - - - -/************************************************************************* -* This function is the driver to the multi-constraint partitioning algorithm. -**************************************************************************/ -void Moc_Global_Partition(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, ncon, nparts; - float ftmp, ubavg, lbavg, lbvec[MAXNCON]; - - ncon = graph->ncon; - nparts = ctrl->nparts; - ubavg = savg(graph->ncon, ctrl->ubvec); - - SetUp(ctrl, graph, wspace); - - if (ctrl->dbglvl&DBG_PROGRESS) { - rprintf(ctrl, "[%6d %8d %5d %5d] [%d] [", graph->gnvtxs, GlobalSESum(ctrl, graph->nedges), - GlobalSEMin(ctrl, graph->nvtxs), GlobalSEMax(ctrl, graph->nvtxs), ctrl->CoarsenTo); - for (i=0; invwgt[samin_strd(graph->nvtxs, graph->nvwgt+i, ncon)*ncon+i])); - rprintf(ctrl, "] ["); - for (i=0; invwgt[samax_strd(graph->nvtxs, graph->nvwgt+i, ncon)*ncon+i])); - rprintf(ctrl, "]\n"); - } - - if (graph->gnvtxs < 1.3*ctrl->CoarsenTo || - (graph->finer != NULL && - graph->gnvtxs > graph->finer->gnvtxs*COARSEN_FRACTION)) { - - /* Done with coarsening. Find a partition */ - graph->where = idxmalloc(graph->nvtxs+graph->nrecv, "graph->where"); - Moc_InitPartition_RB(ctrl, graph, wspace); - - if (ctrl->dbglvl&DBG_PROGRESS) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - rprintf(ctrl, "nvtxs: %10d, balance: ", graph->gnvtxs); - for (i=0; incon; i++) - rprintf(ctrl, "%.3f ", lbvec[i]); - rprintf(ctrl, "\n"); - } - - /* In case no coarsening took place */ - if (graph->finer == NULL) { - Moc_ComputePartitionParams(ctrl, graph, wspace); - Moc_KWayFM(ctrl, graph, wspace, NGR_PASSES); - } - } - else { - Moc_GlobalMatch_Balance(ctrl, graph, wspace); - - Moc_Global_Partition(ctrl, graph->coarser, wspace); - - Moc_ProjectPartition(ctrl, graph, wspace); - Moc_ComputePartitionParams(ctrl, graph, wspace); - - if (graph->ncon > 1 && graph->level < 3) { - for (i=0; ignpwgts+i, ncon); - if (ftmp != 0.0) - lbvec[i] = (float)(nparts) * - graph->gnpwgts[samax_strd(nparts, graph->gnpwgts+i, ncon)*ncon+i]/ftmp; - else - lbvec[i] = 1.0; - } - lbavg = savg(graph->ncon, lbvec); - - if (lbavg > ubavg + 0.035) { - if (ctrl->dbglvl&DBG_PROGRESS) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - rprintf(ctrl, "nvtxs: %10d, cut: %8d, balance: ", graph->gnvtxs, graph->mincut); - for (i=0; incon; i++) - rprintf(ctrl, "%.3f ", lbvec[i]); - rprintf(ctrl, "\n"); - } - - Moc_KWayBalance(ctrl, graph, wspace, graph->ncon); - } - } - - Moc_KWayFM(ctrl, graph, wspace, NGR_PASSES); - - if (ctrl->dbglvl&DBG_PROGRESS) { - Moc_ComputeParallelBalance(ctrl, graph, graph->where, lbvec); - rprintf(ctrl, "nvtxs: %10d, cut: %8d, balance: ", graph->gnvtxs, graph->mincut); - for (i=0; incon; i++) - rprintf(ctrl, "%.3f ", lbvec[i]); - rprintf(ctrl, "\n"); - } - - if (graph->level != 0) - GKfree((void **)&graph->lnpwgts, (void **)&graph->gnpwgts, LTERM); - } - - return; -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/memory.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/memory.c deleted file mode 100644 index a8eeaff..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/memory.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * memory.c - * - * This file contains routines that deal with memory allocation - * - * Started 2/24/96 - * George - * - * $Id: memory.c,v 1.3 2003/07/30 18:37:59 karypis Exp $ - * - */ - -#include - - -/************************************************************************* -* This function allocate various pools of memory -**************************************************************************/ -void PreAllocateMemory(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - wspace->nlarge = 2*graph->nedges; - - wspace->maxcore = 8*graph->nedges+1; - wspace->core = idxmalloc(wspace->maxcore, "PreAllocateMemory: wspace->core"); - - wspace->pairs = (KeyValueType *)wspace->core; - wspace->indices = (idxtype *)(wspace->pairs + wspace->nlarge); - wspace->degrees = (EdgeType *)(wspace->indices + wspace->nlarge); - - - wspace->pv1 = idxmalloc(ctrl->nparts+ctrl->npes+1, "PreAllocateMemory: wspace->pv?"); - wspace->pv2 = idxmalloc(ctrl->nparts+ctrl->npes+1, "PreAllocateMemory: wspace->pv?"); - wspace->pv3 = idxmalloc(ctrl->nparts+ctrl->npes+1, "PreAllocateMemory: wspace->pv?"); - wspace->pv4 = idxmalloc(ctrl->nparts+ctrl->npes+1, "PreAllocateMemory: wspace->pv?"); - - wspace->pepairs1 = (KeyValueType *)GKmalloc(sizeof(KeyValueType)*(ctrl->nparts+ctrl->npes+1), "PreAllocateMemory: wspace->pepairs?"); - wspace->pepairs2 = (KeyValueType *)GKmalloc(sizeof(KeyValueType)*(ctrl->nparts+ctrl->npes+1), "PreAllocateMemory: wspace->pepairs?"); - -} - - -/************************************************************************* -* This function de-allocate various pools of memory -**************************************************************************/ -void FreeWSpace(WorkSpaceType *wspace) -{ - - GKfree((void **)&wspace->core, - (void **)&wspace->pv1, - (void **)&wspace->pv2, - (void **)&wspace->pv3, - (void **)&wspace->pv4, - (void **)&wspace->pepairs1, - (void **)&wspace->pepairs2, - LTERM); -} - - -/************************************************************************* -* This function de-allocates memory allocated for the control structures -**************************************************************************/ -void FreeCtrl(CtrlType *ctrl) -{ - MPI_Comm_free(&(ctrl->gcomm)); -} - - -/************************************************************************* -* This function creates a CoarseGraphType data structure and initializes -* the various fields -**************************************************************************/ -GraphType *CreateGraph(void) -{ - GraphType *graph; - - graph = (GraphType *)GKmalloc(sizeof(GraphType), "CreateCoarseGraph: graph"); - - InitGraph(graph); - - return graph; -} - - -/************************************************************************* -* This function creates a CoarseGraphType data structure and initializes -* the various fields -**************************************************************************/ -void InitGraph(GraphType *graph) -{ - graph->gnvtxs = graph->nvtxs = graph->nedges = graph->nsep = -1; - graph->nnbrs = graph->nrecv = graph->nsend = graph->nlocal = -1; - graph->xadj = graph->vwgt = graph->vsize = graph->adjncy = graph->adjwgt = NULL; - graph->nvwgt = NULL; - graph->vtxdist = NULL; - graph->match = graph->cmap = NULL; - graph->label = NULL; - - graph->peind = NULL; - graph->sendptr = graph->sendind = graph->recvptr = graph->recvind = NULL; - graph->imap = NULL; - graph->pexadj = graph->peadjncy = graph->peadjloc = NULL; - graph->lperm = NULL; - - graph->slens = graph->rlens = NULL; - graph->rcand = NULL; - - graph->where = graph->home = graph->lpwgts = graph->gpwgts = NULL; - graph->lnpwgts = graph->gnpwgts = NULL; - graph->rinfo = NULL; - - graph->nrinfo = NULL; - graph->sepind = NULL; - - graph->coarser = graph->finer = NULL; - -} - -/************************************************************************* -* This function deallocates any memory stored in a graph -**************************************************************************/ -void FreeGraph(GraphType *graph) -{ - - GKfree((void **)&graph->xadj, - (void **)&graph->vwgt, - (void **)&graph->nvwgt, - (void **)&graph->vsize, - (void **)&graph->adjncy, - (void **)&graph->adjwgt, - (void **)&graph->vtxdist, - (void **)&graph->match, - (void **)&graph->cmap, - (void **)&graph->lperm, - (void **)&graph->label, - (void **)&graph->where, - (void **)&graph->home, - (void **)&graph->rinfo, - (void **)&graph->nrinfo, - (void **)&graph->sepind, - (void **)&graph->lpwgts, - (void **)&graph->gpwgts, - (void **)&graph->lnpwgts, - (void **)&graph->gnpwgts, - (void **)&graph->peind, - (void **)&graph->sendptr, - (void **)&graph->sendind, - (void **)&graph->recvptr, - (void **)&graph->recvind, - (void **)&graph->imap, - (void **)&graph->rlens, - (void **)&graph->slens, - (void **)&graph->rcand, - (void **)&graph->pexadj, - (void **)&graph->peadjncy, - (void **)&graph->peadjloc, - LTERM); - - free(graph); -} - - - -/************************************************************************* -* This function deallocates any memory stored in a graph -**************************************************************************/ -void FreeInitialGraphAndRemap(GraphType *graph, int wgtflag) -{ - int i, nedges; - idxtype *adjncy, *imap; - - nedges = graph->nedges; - adjncy = graph->adjncy; - imap = graph->imap; - - if (imap != NULL) { - for (i=0; imatch, - (void **)&graph->cmap, - (void **)&graph->lperm, - (void **)&graph->where, - (void **)&graph->label, - (void **)&graph->rinfo, - (void **)&graph->nrinfo, - (void **)&graph->nvwgt, - (void **)&graph->lpwgts, - (void **)&graph->gpwgts, - (void **)&graph->lnpwgts, - (void **)&graph->gnpwgts, - (void **)&graph->sepind, - (void **)&graph->peind, - (void **)&graph->sendptr, - (void **)&graph->sendind, - (void **)&graph->recvptr, - (void **)&graph->recvind, - (void **)&graph->imap, - (void **)&graph->rlens, - (void **)&graph->slens, - (void **)&graph->rcand, - (void **)&graph->pexadj, - (void **)&graph->peadjncy, - (void **)&graph->peadjloc, - LTERM); - - if ((wgtflag&2) == 0) - GKfree((void **)&graph->vwgt, (void **)&graph->vsize, LTERM); - if ((wgtflag&1) == 0) - GKfree((void **)&graph->adjwgt, LTERM); - - free(graph); -} diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mesh.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mesh.c deleted file mode 100644 index 57a80c0..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mesh.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * mesh.c - * - * This file contains routines for constructing the dual graph of a mesh. - * Assumes that each processor has at least one mesh element. - * - * Started 10/19/94 - * George - * - * $Id: mesh.c,v 1.11 2003/07/25 04:01:04 karypis Exp $ - * - */ - -#include - - -/************************************************************************* -* This function converts a mesh into a dual graph -**************************************************************************/ -void ParMETIS_V3_Mesh2Dual(idxtype *elmdist, idxtype *eptr, idxtype *eind, - int *numflag, int *ncommonnodes, idxtype **xadj, - idxtype **adjncy, MPI_Comm *comm) -{ - int i, j, jj, k, kk, m; - int npes, mype, pe, count, mask, pass; - int nelms, lnns, my_nns, node; - int firstelm, firstnode, lnode, nrecv, nsend; - int *scounts, *rcounts, *sdispl, *rdispl; - idxtype *nodedist, *nmap, *auxarray; - idxtype *gnptr, *gnind, *nptr, *nind, *myxadj, *myadjncy = NULL; - idxtype *sbuffer, *rbuffer, *htable; - KeyValueType *nodelist, *recvbuffer; - idxtype ind[200], wgt[200]; - int gmaxnode, gminnode; - CtrlType ctrl; - - - SetUpCtrl(&ctrl, -1, 0, *comm); - - npes = ctrl.npes; - mype = ctrl.mype; - - nelms = elmdist[mype+1]-elmdist[mype]; - - if (*numflag == 1) - ChangeNumberingMesh2(elmdist, eptr, eind, NULL, NULL, NULL, npes, mype, 1); - - mask = (1<<11)-1; - - /*****************************/ - /* Determine number of nodes */ - /*****************************/ - gminnode = GlobalSEMin(&ctrl, eind[idxamin(eptr[nelms], eind)]); - for (i=0; i 0); - - /* construct node distribution array */ - nodedist = idxsmalloc(npes+1, 0, "nodedist"); - for (nodedist[0]=0, i=0,j=gmaxnode+1; i nodelist[i-1].key) - count++; - } - - lnns = count; - nmap = idxmalloc(lnns, "nmap"); - - /* renumber the nodes of the elements array */ - count = 1; - nmap[0] = nodelist[0].key; - eind[nodelist[0].val] = 0; - nodelist[0].val = auxarray[nodelist[0].val]; /* Store the local element ID */ - for (i=1; i nodelist[i-1].key) { - nmap[count] = nodelist[i].key; - count++; - } - eind[nodelist[i].val] = count-1; - nodelist[i].val = auxarray[nodelist[i].val]; /* Store the local element ID */ - } - MPI_Barrier(*comm); - - /**********************************************************/ - /* perform comms necessary to construct node-element list */ - /**********************************************************/ - iset(npes, 0, scounts); - for (pe=i=0; i= nodedist[pe+1]) - pe++; - scounts[pe] += 2; - } - ASSERTS(pe < npes); - - MPI_Alltoall((void *)scounts, 1, MPI_INT, (void *)rcounts, 1, MPI_INT, *comm); - - icopy(npes, scounts, sdispl); - MAKECSR(i, npes, sdispl); - - icopy(npes, rcounts, rdispl); - MAKECSR(i, npes, rdispl); - - ASSERTS(sdispl[npes] == eptr[nelms]*2); - - nrecv = rdispl[npes]/2; - recvbuffer = (KeyValueType *)GKmalloc(amax(1, nrecv)*sizeof(KeyValueType), "recvbuffer"); - - MPI_Alltoallv((void *)nodelist, scounts, sdispl, IDX_DATATYPE, (void *)recvbuffer, - rcounts, rdispl, IDX_DATATYPE, *comm); - - /**************************************/ - /* construct global node-element list */ - /**************************************/ - gnptr = idxsmalloc(my_nns+1, 0, "gnptr"); - - for (i=0; i= 0 && lnode < my_nns) - - gnptr[lnode]++; - } - } - MAKECSR(i, my_nns, gnptr); - - gnind = idxmalloc(amax(1, gnptr[my_nns]), "gnind"); - for (pe=0; pe= *ncommonnodes) { - if (pass == 0) - myxadj[i]++; - else - myadjncy[myxadj[i]++] = ind[j]; - } - } - } - - if (pass == 0) { - MAKECSR(i, nelms, myxadj); - myadjncy = *adjncy = idxmalloc(myxadj[nelms], "adjncy"); - } - else { - SHIFTCSR(i, nelms, myxadj); - } - } - - /*****************************************/ - /* correctly renumber the elements array */ - /*****************************************/ - for (i=0; i - - -/*********************************************************************************** -* This function is the entry point of the parallel k-way multilevel mesh partitionioner. -* This function assumes nothing about the mesh distribution. -* It is the general case. -************************************************************************************/ -void ParMETIS_V3_PartMeshKway(idxtype *elmdist, idxtype *eptr, idxtype *eind, idxtype *elmwgt, - int *wgtflag, int *numflag, int *ncon, int *ncommonnodes, int *nparts, - float *tpwgts, float *ubvec, int *options, int *edgecut, idxtype *part, - MPI_Comm *comm) -{ - int i, nvtxs, nedges, gnedges, npes, mype; - idxtype *xadj, *adjncy; - timer TotalTmr, Mesh2DualTmr, ParMETISTmr; - CtrlType ctrl; - - /********************************/ - /* Try and take care bad inputs */ - /********************************/ - if (elmdist == NULL || eptr == NULL || eind == NULL || wgtflag == NULL || - numflag == NULL || ncon == NULL || ncommonnodes == NULL || nparts == NULL || - tpwgts == NULL || ubvec == NULL || options == NULL || edgecut == NULL || - part == NULL || comm == NULL) { - printf("ERROR: One or more required parameters is NULL. Aborting.\n"); - abort(); - } - if (((*wgtflag)&2) && elmwgt == NULL) { - printf("ERROR: elmwgt == NULL when vertex weights were specified. Aborting.\n"); - abort(); - } - - - SetUpCtrl(&ctrl, *nparts, (options[0] == 1 ? options[PMV3_OPTION_DBGLVL] : 0), *comm); - npes = ctrl.npes; - mype = ctrl.mype; - - cleartimer(TotalTmr); - cleartimer(Mesh2DualTmr); - cleartimer(ParMETISTmr); - - MPI_Barrier(ctrl.comm); - starttimer(TotalTmr); - starttimer(Mesh2DualTmr); - - ParMETIS_V3_Mesh2Dual(elmdist, eptr, eind, numflag, ncommonnodes, &xadj, &adjncy, &(ctrl.comm)); - - if (ctrl.dbglvl&DBG_INFO) { - nvtxs = elmdist[mype+1]-elmdist[mype]; - nedges = xadj[nvtxs] + (*numflag == 0 ? 0 : -1); - rprintf(&ctrl, "Completed Dual Graph -- Nvtxs: %d, Nedges: %d \n", - elmdist[npes], GlobalSESum(&ctrl, nedges)); - } - - MPI_Barrier(ctrl.comm); - stoptimer(Mesh2DualTmr); - - - /***********************/ - /* Partition the graph */ - /***********************/ - starttimer(ParMETISTmr); - - ParMETIS_V3_PartKway(elmdist, xadj, adjncy, elmwgt, NULL, wgtflag, numflag, ncon, - nparts, tpwgts, ubvec, options, edgecut, part, &(ctrl.comm)); - - MPI_Barrier(ctrl.comm); - stoptimer(ParMETISTmr); - stoptimer(TotalTmr); - - IFSET(ctrl.dbglvl, DBG_TIME, PrintTimer(&ctrl, Mesh2DualTmr, " Mesh2Dual")); - IFSET(ctrl.dbglvl, DBG_TIME, PrintTimer(&ctrl, ParMETISTmr, " ParMETIS")); - IFSET(ctrl.dbglvl, DBG_TIME, PrintTimer(&ctrl, TotalTmr, " Total")); - - GKfree((void **)&xadj, (void **)&adjncy, LTERM); - - FreeCtrl(&ctrl); - - return; -} diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/move.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/move.c deleted file mode 100644 index 06a8e5c..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/move.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * mmove.c - * - * This file contains functions that move the graph given a partition - * - * Started 11/22/96 - * George - * - * $Id: move.c,v 1.3 2003/07/31 16:23:30 karypis Exp $ - * - */ - -#include - -/************************************************************************* -* This function moves the graph, and returns a new graph. -* This routine can be called with or without performing refinement. -* In the latter case it allocates and computes lpwgts itself. -**************************************************************************/ -GraphType *Moc_MoveGraph(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int h, i, ii, j, jj, nvtxs, ncon, nparts; - idxtype *xadj, *vwgt, *adjncy, *adjwgt, *mvtxdist; - idxtype *where, *newlabel, *lpwgts, *gpwgts; - idxtype *sgraph, *rgraph; - KeyValueType *sinfo, *rinfo; - GraphType *mgraph; - - nparts = ctrl->nparts; - ASSERT(ctrl, nparts == ctrl->npes); - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - xadj = graph->xadj; - vwgt = graph->vwgt; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - - mvtxdist = idxmalloc(nparts+1, "MoveGraph: mvtxdist"); - - /* Let's do a prefix scan to determine the labeling of the nodes given */ - lpwgts = wspace->pv1; - gpwgts = wspace->pv2; - sinfo = wspace->pepairs1; - rinfo = wspace->pepairs2; - for (i=0; icomm); - MPI_Allreduce((void *)lpwgts, (void *)mvtxdist, nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); - - MAKECSR(i, nparts, mvtxdist); - - /* gpwgts[i] will store the label of the first vertex for each domain in each processor */ - for (i=0; inrecv, "MoveGraph: newlabel"); - - for (i=0; iindices, newlabel+nvtxs); - - /* Now lets tell everybody what and from where he will get it. Assume nparts == npes */ - MPI_Alltoall((void *)sinfo, 2, IDX_DATATYPE, (void *)rinfo, 2, IDX_DATATYPE, ctrl->comm); - - /* Use lpwgts and gpwgts as pointers to where data will be received and send */ - lpwgts[0] = 0; /* Send part */ - gpwgts[0] = 0; /* Received part */ - for (i=0; i wspace->maxcore) { - /* Adjust core memory, incase the graph was originally very memory unbalanced */ - free(wspace->core); - wspace->maxcore = lpwgts[nparts]+4*gpwgts[nparts]; /* In spirit of the 8*nedges */ - wspace->core = idxmalloc(wspace->maxcore, "Moc_MoveGraph: wspace->core"); - } - - sgraph = wspace->core; - rgraph = wspace->core + lpwgts[nparts]; - - /* Issue the receives first */ - for (i=0; i 0) - MPI_Irecv((void *)(rgraph+gpwgts[i]), gpwgts[i+1]-gpwgts[i], IDX_DATATYPE, i, 1, ctrl->comm, ctrl->rreq+i); - else - ASSERT(ctrl, gpwgts[i+1]-gpwgts[i] == 0); - } - - /* Assemble the graph to be sent and send it */ - for (i=0; i0; i--) - lpwgts[i] = lpwgts[i-1]; - lpwgts[0] = 0; - - for (i=0; i 0) - MPI_Isend((void *)(sgraph+lpwgts[i]), lpwgts[i+1]-lpwgts[i], IDX_DATATYPE, i, 1, ctrl->comm, ctrl->sreq+i); - else - ASSERT(ctrl, lpwgts[i+1]-lpwgts[i] == 0); - } - -/* -#ifdef DMALLOC - ASSERT(ctrl, dmalloc_verify(NULL) == DMALLOC_VERIFY_NOERROR); -#endif -*/ - - /* Wait for the send/recv to finish */ - for (i=0; i 0) - MPI_Wait(ctrl->sreq+i, &ctrl->status); - } - for (i=0; i 0) - MPI_Wait(ctrl->rreq+i, &ctrl->status); - } - - /* OK, now go and put the graph into GraphType Format */ - mgraph = CreateGraph(); - mgraph->gnvtxs = graph->gnvtxs; - mgraph->ncon = ncon; - mgraph->level = 0; - mgraph->nvtxs = mgraph->nedges = 0; - for (i=0; invtxs += rinfo[i].key; - mgraph->nedges += rinfo[i].val; - } - nvtxs = mgraph->nvtxs; - xadj = mgraph->xadj = idxmalloc(nvtxs+1, "MMG: mgraph->xadj"); - vwgt = mgraph->vwgt = idxmalloc(nvtxs*ncon, "MMG: mgraph->vwgt"); - adjncy = mgraph->adjncy = idxmalloc(mgraph->nedges, "MMG: mgraph->adjncy"); - adjwgt = mgraph->adjwgt = idxmalloc(mgraph->nedges, "MMG: mgraph->adjwgt"); - mgraph->vtxdist = mvtxdist; - - for (jj=ii=i=0; inedges, (ctrl, "%d %d\n", jj, mgraph->nedges)); - ASSERTP(ctrl, ii == gpwgts[nparts], (ctrl, "%d %d %d %d %d\n", ii, gpwgts[nparts], jj, mgraph->nedges, nvtxs)); - - free(newlabel); - -#ifdef DEBUG - IFSET(ctrl->dbglvl, DBG_INFO, rprintf(ctrl, "Checking moved graph...\n")); - CheckMGraph(ctrl, mgraph); - IFSET(ctrl->dbglvl, DBG_INFO, rprintf(ctrl, "Moved graph is consistent.\n")); -#endif - - return mgraph; -} - - -/************************************************************************* -* This function is used to transfer information from the moved graph -* back to the original graph. The information is transfered from array -* minfo to array info. The routine assumes that graph->where is left intact -* and it is used to get the inverse mapping information. -* The routine assumes that graph->where corresponds to a npes-way partition. -**************************************************************************/ -void ProjectInfoBack(CtrlType *ctrl, GraphType *graph, idxtype *info, idxtype *minfo, - WorkSpaceType *wspace) -{ - int i, nvtxs, nparts; - idxtype *where, *auxinfo, *sinfo, *rinfo; - - nparts = ctrl->npes; - - nvtxs = graph->nvtxs; - where = graph->where; - - sinfo = wspace->pv1; - rinfo = wspace->pv2; - - /* Find out in rinfo how many entries are received per partition */ - idxset(nparts, 0, rinfo); - for (i=0; icomm); - - MAKECSR(i, nparts, sinfo); - MAKECSR(i, nparts, rinfo); - - /* allocate memory for auxinfo */ - auxinfo = idxmalloc(rinfo[nparts], "ProjectInfoBack: auxinfo"); - - /*----------------------------------------------------------------- - * Now, go and send back the minfo - -----------------------------------------------------------------*/ - for (i=0; i 0) - MPI_Irecv((void *)(auxinfo+rinfo[i]), rinfo[i+1]-rinfo[i], IDX_DATATYPE, i, 1, ctrl->comm, ctrl->rreq+i); - } - - for (i=0; i 0) - MPI_Isend((void *)(minfo+sinfo[i]), sinfo[i+1]-sinfo[i], IDX_DATATYPE, i, 1, ctrl->comm, ctrl->sreq+i); - } - - /* Wait for the send/recv to finish */ - for (i=0; i 0) - MPI_Wait(ctrl->rreq+i, &ctrl->status); - } - for (i=0; i 0) - MPI_Wait(ctrl->sreq+i, &ctrl->status); - } - - /* Scatter the info received in auxinfo back to info. */ - for (i=0; inparts; - - nvtxs = graph->nvtxs; - xadj = graph->xadj; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - - mvtxdist = idxmalloc(nparts+1, "MoveGraph: mvtxdist"); - - /* Let's do a prefix scan to determine the labeling of the nodes given */ - lpwgts = wspace->pv1; - gpwgts = wspace->pv2; - - /* Here we care about the count and not total weight (diff since graph may be weighted */ - idxset(nparts, 0, lpwgts); - for (i=0; icomm); - MPI_Allreduce((void *)lpwgts, (void *)mvtxdist, nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); - - MAKECSR(i, nparts, mvtxdist); - - for (i=0; invtxs; - xadj = graph->xadj; - adjncy = graph->adjncy; - vtxdist = graph->vtxdist; - - firstvtx = vtxdist[ctrl->mype]; - lastvtx = vtxdist[ctrl->mype+1]; - - for (i=0; i= firstvtx && adjncy[j] < lastvtx) { - k = adjncy[j]-firstvtx; - for (jj=xadj[k]; jj - - - -/************************************************************************* -* This function setsup the CtrlType structure -**************************************************************************/ -MeshType *SetUpMesh(int *etype, int *ncon, idxtype *elmdist, idxtype *elements, - idxtype *elmwgt, int *wgtflag, MPI_Comm *comm) -{ - MeshType *mesh; - int i, npes, mype; - int esizes[5] = {-1, 3, 4, 8, 4}; - int maxnode, gmaxnode, minnode, gminnode; - - MPI_Comm_size(*comm, &npes); - MPI_Comm_rank(*comm, &mype); - - mesh = CreateMesh(); - mesh->elmdist = elmdist; - mesh->gnelms = elmdist[npes]; - mesh->nelms = elmdist[mype+1]-elmdist[mype]; - mesh->elements = elements; - mesh->elmwgt = elmwgt; - mesh->etype = *etype; - mesh->ncon = *ncon; - mesh->esize = esizes[*etype]; - - if (((*wgtflag)&1) == 0) { - mesh->elmwgt = idxsmalloc(mesh->nelms*mesh->ncon, 1, "SetUpMesh: elmwgt"); - } - - minnode = elements[idxamin(mesh->nelms*mesh->esize, elements)]; - MPI_Allreduce((void *)&minnode, (void *)&gminnode, 1, MPI_INT, MPI_MIN, *comm); - for (i=0; inelms*mesh->esize; i++) - elements[i] -= gminnode; - mesh->gminnode = gminnode; - - maxnode = elements[idxamax(mesh->nelms*mesh->esize, elements)]; - MPI_Allreduce((void *)&maxnode, (void *)&gmaxnode, 1, MPI_INT, MPI_MAX, *comm); - mesh->gnns = gmaxnode+1; - - return mesh; -} - -/************************************************************************* -* This function creates a MeshType data structure and initializes -* the various fields -**************************************************************************/ -MeshType *CreateMesh(void) -{ - MeshType *mesh; - - mesh = (MeshType *)GKmalloc(sizeof(MeshType), "CreateMesh: mesh"); - - InitMesh(mesh); - - return mesh; -} - -/************************************************************************* -* This function initializes the various fields of a MeshType. -**************************************************************************/ -void InitMesh(MeshType *mesh) -{ - - mesh->etype = -1; - mesh->gnelms = -1; - mesh->gnns = -1; - mesh->nelms = -1; - mesh->nns = -1; - mesh->ncon = -1; - mesh->esize = -1; - mesh->gminnode = 0; - mesh->elmdist = NULL; - mesh->elements = NULL; - mesh->elmwgt = NULL; - - return; -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/node_refine.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/node_refine.c deleted file mode 100644 index 3f57aa7..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/node_refine.c +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * node_refine.c - * - * This file contains code that performs the k-way refinement - * - * Started 3/1/96 - * George - * - * $Id: node_refine.c,v 1.2 2003/07/21 17:18:50 karypis Exp $ - */ - -#include - -#define PackWeightWhereInfo(a, b) (((a)<<10) + (b)) -#define SelectWhere(a) ((a)%1024) -#define SelectWeight(a) (((a)>>10)) - - - -/************************************************************************* -* This function computes the initial id/ed -**************************************************************************/ -void ComputeNodePartitionParams(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, j, nparts, nvtxs, nsep, firstvtx, lastvtx; - idxtype *xadj, *ladjncy, *adjwgt, *vtxdist, *vwgt, *lpwgts, *gpwgts, *sepind; - idxtype *where, *swhere, *rwhere; - NRInfoType *rinfo, *myrinfo; - int me, other, otherwgt; - - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->KWayInitTmr)); - - nvtxs = graph->nvtxs; - nparts = ctrl->nparts; - - vtxdist = graph->vtxdist; - xadj = graph->xadj; - ladjncy = graph->adjncy; - adjwgt = graph->adjwgt; - vwgt = graph->vwgt; - - where = graph->where; - rinfo = graph->nrinfo = (NRInfoType *)GKmalloc(sizeof(NRInfoType)*nvtxs, "ComputeNodePartitionParams: rinfo"); - lpwgts = graph->lpwgts = idxsmalloc(2*nparts, 0, "ComputePartitionParams: lpwgts"); - gpwgts = graph->gpwgts = idxmalloc(2*nparts, "ComputePartitionParams: gpwgts"); - sepind = graph->sepind = idxmalloc(nvtxs, "ComputePartitionParams: sepind"); - - firstvtx = vtxdist[ctrl->mype]; - lastvtx = vtxdist[ctrl->mype+1]; - - /*------------------------------------------------------------ - / Send/Receive the where information of interface vertices. - / Also use this to also encode the vwgt information of this - / vertex. This is a hack, but it should work for now! - /------------------------------------------------------------*/ - swhere = wspace->indices; - rwhere = where + nvtxs; - - for (i=0; i= 0 && where[i] < 2*nparts, (ctrl, "%d\n", where[i]) ); - where[i] = PackWeightWhereInfo(vwgt[i], where[i]); - } - - CommInterfaceData(ctrl, graph, where, swhere, rwhere); - - /*------------------------------------------------------------ - / Compute now the degrees - /------------------------------------------------------------*/ - for (nsep=i=0; i= 0 && me < 2*nparts); - lpwgts[me] += vwgt[i]; - - if (me >= nparts) { /* If it is a separator vertex */ - sepind[nsep++] = i; - lpwgts[2*nparts-1] += vwgt[i]; - - myrinfo = rinfo+i; - myrinfo->edegrees[0] = myrinfo->edegrees[1] = 0; - - for (j=xadj[i]; jedegrees[other%2] += otherwgt; - } - } - } - graph->nsep = nsep; - - /* Finally, sum-up the partition weights */ - MPI_Allreduce((void *)lpwgts, (void *)gpwgts, 2*nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); - graph->mincut = gpwgts[2*nparts-1]; - -#ifdef XX - /* Print Weight information */ - if (ctrl->mype == 0) { - for (i=0; idbglvl, DBG_TIME, stoptimer(ctrl->KWayInitTmr)); -} - - - -/************************************************************************* -* This function performs k-way refinement -**************************************************************************/ -void KWayNodeRefine(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace, int npasses, float ubfraction) -{ - int i, ii, j, k, pass, nvtxs, firstvtx, lastvtx, otherlastvtx, c, nmoves, - nlupd, nsupd, nnbrs, nchanged, nsep; - int npes = ctrl->npes, mype = ctrl->mype, nparts = ctrl->nparts; - idxtype *xadj, *ladjncy, *adjwgt, *vtxdist, *vwgt; - idxtype *where, *lpwgts, *gpwgts, *sepind; - idxtype *peind, *recvptr, *sendptr; - idxtype *update, *supdate, *rupdate, *pe_updates, *htable, *changed; - idxtype *badminpwgt, *badmaxpwgt; - KeyValueType *swchanges, *rwchanges; - int *nupds_pe; - NRInfoType *rinfo, *myrinfo; - int from, me, other, otherwgt, oldcut; - - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->KWayTmr)); - - nvtxs = graph->nvtxs; - - vtxdist = graph->vtxdist; - xadj = graph->xadj; - ladjncy = graph->adjncy; - adjwgt = graph->adjwgt; - vwgt = graph->vwgt; - - firstvtx = vtxdist[mype]; - lastvtx = vtxdist[mype+1]; - - where = graph->where; - rinfo = graph->nrinfo; - lpwgts = graph->lpwgts; - gpwgts = graph->gpwgts; - - nsep = graph->nsep; - sepind = graph->sepind; - - nnbrs = graph->nnbrs; - peind = graph->peind; - recvptr = graph->recvptr; - sendptr = graph->sendptr; - - changed = idxmalloc(nvtxs, "KWayRefine: changed"); - rwchanges = wspace->pairs; - swchanges = rwchanges + recvptr[nnbrs]; - - update = idxmalloc(nvtxs, "KWayRefine: update"); - supdate = wspace->indices; - rupdate = supdate + recvptr[nnbrs]; - nupds_pe = imalloc(npes, "KWayRefine: nupds_pe"); - - htable = idxsmalloc(nvtxs+graph->nrecv, 0, "KWayRefine: lhtable"); - - badminpwgt = wspace->pv1; - badmaxpwgt = wspace->pv2; - - for (i=0; idbglvl, DBG_REFINEINFO, PrintNodeBalanceInfo(ctrl, nparts, gpwgts, badminpwgt, badmaxpwgt, 1)); - - for (pass=0; passmincut; - - for (c=0; c<2; c++) { - for (i=0; i= nparts); - - /* Go through the loop if gain is possible for the separator vertex */ - if (rinfo[i].edegrees[(c+1)%2] <= vwgt[i]) { - other = from%nparts+c; /* It is one-sided move so we know where it goes */ - - if (gpwgts[other]+vwgt[i] > badmaxpwgt[other]) { - /* printf("Skip because of weight! %d\n", vwgt[i]-rinfo[i].edegrees[(c+1)%2]); */ - continue; /* We cannot move it there because it gets too heavy */ - } - - /* Update where, weight, and ID/ED information of the vertex you moved */ - where[i] = PackWeightWhereInfo(vwgt[i], other); - - /* Remove this vertex from the sepind. Note the trick for looking at the sepind[ii] again */ - sepind[ii--] = sepind[--nsep]; - - /* myprintf(ctrl, "Vertex %d [%d %d] is moving to %d from %d [%d]\n", i+firstvtx, vwgt[i], rinfo[i].edegrees[(c+1)%2], other, from, SelectWhere(where[i])); */ - - lpwgts[from] -= vwgt[i]; - lpwgts[2*nparts-1] -= vwgt[i]; - lpwgts[other] += vwgt[i]; - gpwgts[other] += vwgt[i]; - - /* - * Put the vertices adjacent to i that belong to either the separator or - * the (c+1)%2 partition into the update array - */ - for (j=xadj[i]; jpexadj[i+1]-graph->pexadj[i] > 0) - changed[nchanged++] = i; - } - } - - /* myprintf(ctrl, "nmoves: %d, nlupd: %d, nsupd: %d\n", nmoves, nlupd, nsupd); */ - - /* Tell everybody interested what the new where[] info is for the interface vertices */ - CommChangedInterfaceData(ctrl, graph, nchanged, changed, where, swchanges, rwchanges, wspace->pv4); - - - IFSET(ctrl->dbglvl, DBG_RMOVEINFO, rprintf(ctrl, "\t[%d %d], [%d %d %d]\n", - pass, c, GlobalSESum(ctrl, nmoves), GlobalSESum(ctrl, nsupd), GlobalSESum(ctrl, nlupd))); - - - /*------------------------------------------------------------- - / Time to communicate with processors to send the vertices - / whose degrees need to be update. - /-------------------------------------------------------------*/ - /* Issue the receives first */ - for (i=0; icomm, ctrl->rreq+i); - } - - /* Issue the sends next. This needs some preporcessing */ - for (i=0; iimap[supdate[i]]; - } - iidxsort(nsupd, supdate); - - for (j=i=0; icomm, ctrl->sreq+i); - j = k; - } - - /* OK, now get into the loop waiting for the send/recv operations to finish */ - MPI_Waitall(nnbrs, ctrl->rreq, ctrl->statuses); - for (i=0; istatuses+i, IDX_DATATYPE, nupds_pe+i); - MPI_Waitall(nnbrs, ctrl->sreq, ctrl->statuses); - - - /*------------------------------------------------------------- - / Place the received to-be updated vertices into update[] - /-------------------------------------------------------------*/ - for (i=0; ipexadj[i+1]-graph->pexadj[i] > 0) - changed[nchanged++] = i; - - lpwgts[SelectWhere(where[i])] += vwgt[i]; - lpwgts[2*nparts-1] += vwgt[i]; - /* myprintf(ctrl, "Vertex %d moves into the separator from %d to %d\n", i+firstvtx, me, SelectWhere(where[i])); */ - } - } - - /* Tell everybody interested what the new where[] info is for the interface vertices */ - CommChangedInterfaceData(ctrl, graph, nchanged, changed, where, swchanges, rwchanges, wspace->pv4); - - - /*------------------------------------------------------------- - / Update the rinfo of the vertices in the update[] array - /-------------------------------------------------------------*/ - for (ii=0; ii= nparts) { /* If it is a separator vertex */ - /* myprintf(ctrl, "Updating %d %d\n", i+firstvtx, me); */ - - myrinfo = rinfo+i; - myrinfo->edegrees[0] = myrinfo->edegrees[1] = 0; - - for (j=xadj[i]; jedegrees[other%2] += otherwgt; - } - } - } - - /* Finally, sum-up the partition weights */ - MPI_Allreduce((void *)lpwgts, (void *)gpwgts, 2*nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); - graph->mincut = gpwgts[2*nparts-1]; - - IFSET(ctrl->dbglvl, DBG_REFINEINFO, PrintNodeBalanceInfo(ctrl, nparts, gpwgts, badminpwgt, badmaxpwgt, 0)); - } - - if (graph->mincut == oldcut) - break; - } - - /* Go and clear-up the where array */ - for (i=0; inrecv; i++) - where[i] = SelectWhere(where[i]); - - GKfree((void **)&update, (void **)&nupds_pe, (void **)&htable, (void **)&changed, LTERM); - - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->KWayTmr)); -} - - - - -/************************************************************************* -* This function prints balance information for the parallel k-section -* refinement algorithm -**************************************************************************/ -void PrintNodeBalanceInfo(CtrlType *ctrl, int nparts, idxtype *gpwgts, idxtype *badminpwgt, idxtype *badmaxpwgt, int title) -{ - int i; - - if (ctrl->mype == 0) { - if (title) - printf("K-way sep-refinement: TotalSep: %d, ", gpwgts[2*nparts-1]); - else - printf("\tTotalSep: %d, ", gpwgts[2*nparts-1]); - - for (i=0; icomm); -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ometis.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ometis.c deleted file mode 100644 index 1a461f1..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/ometis.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * ometis.c - * - * This is the entry point of parallel ordering - * - * Started 10/19/96 - * George - * - * $Id: ometis.c,v 1.4 2003/07/25 04:01:04 karypis Exp $ - * - */ - -#include - - - - -/*********************************************************************************** -* This function is the entry point of the parallel ordering algorithm. -* This function assumes that the graph is already nice partitioned among the -* processors and then proceeds to perform recursive bisection. -************************************************************************************/ -void ParMETIS_V3_NodeND(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, int *numflag, - int *options, idxtype *order, idxtype *sizes, MPI_Comm *comm) -{ - int i, j; - int ltvwgts[MAXNCON]; - int nparts, npes, mype, wgtflag = 0, seed = GLOBAL_SEED; - CtrlType ctrl; - WorkSpaceType wspace; - GraphType *graph, *mgraph; - idxtype *morder; - int minnvtxs; - - MPI_Comm_size(*comm, &npes); - MPI_Comm_rank(*comm, &mype); - nparts = npes; - - if (!ispow2(npes)) { - if (mype == 0) - printf("Error: The number of processors must be a power of 2!\n"); - return; - } - - if (vtxdist[npes] < (int)((float)(npes*npes)*1.2)) { - if (mype == 0) - printf("Error: Too many processors for this many vertices.\n"); - return; - } - - minnvtxs = vtxdist[1]-vtxdist[0]; - for (i=0; incon = 1; - mgraph = Moc_MoveGraph(&ctrl, graph, &wspace); - MALLOC_CHECK(NULL); - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.MoveTmr)); - - /*======================================================= - * Now compute an ordering of the moved graph - =======================================================*/ - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.TotalTmr)); - - FreeWSpace(&wspace); - PreAllocateMemory(&ctrl, mgraph, &wspace); - - ctrl.ipart = ISEP_NODE; - ctrl.CoarsenTo = amin(vtxdist[npes]+1, amax(20*npes, 1000)); - - /* compute tvwgts */ - for (j=0; jncon; j++) - ltvwgts[j] = 0; - - for (i=0; invtxs; i++) - for (j=0; jncon; j++) - ltvwgts[j] += mgraph->vwgt[i*mgraph->ncon+j]; - - for (j=0; jncon; j++) - ctrl.tvwgts[j] = GlobalSESum(&ctrl, ltvwgts[j]); - - mgraph->nvwgt = fmalloc(mgraph->nvtxs*mgraph->ncon, "mgraph->nvwgt"); - for (i=0; invtxs; i++) - for (j=0; jncon; j++) - mgraph->nvwgt[i*mgraph->ncon+j] = (float)(mgraph->vwgt[i*mgraph->ncon+j]) / (float)(ctrl.tvwgts[j]); - - - morder = idxmalloc(mgraph->nvtxs, "PAROMETIS: morder"); - MultilevelOrder(&ctrl, mgraph, morder, sizes, &wspace); - - MALLOC_CHECK(NULL); - - /* Invert the ordering back to the original graph */ - ProjectInfoBack(&ctrl, graph, order, morder, &wspace); - - MALLOC_CHECK(NULL); - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.TotalTmr)); - IFSET(ctrl.dbglvl, DBG_TIME, PrintTimingInfo(&ctrl)); - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - - free(ctrl.tpwgts); - free(morder); - FreeGraph(mgraph); - FreeInitialGraphAndRemap(graph, 0); - FreeWSpace(&wspace); - FreeCtrl(&ctrl); - - if (*numflag == 1) - ChangeNumbering(vtxdist, xadj, adjncy, order, npes, mype, 0); - - MALLOC_CHECK(NULL); -} - - -/*********************************************************************************** -* This function is the entry point of the parallel ordering algorithm. -* This function assumes that the graph is already nice partitioned among the -* processors and then proceeds to perform recursive bisection. -************************************************************************************/ -void PAROMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt, - idxtype *order, idxtype *sizes, int *options, MPI_Comm comm) -{ - int numflag, newoptions[5]; - - newoptions[0] = 1; - newoptions[PMV3_OPTION_DBGLVL] = options[4]; - newoptions[PMV3_OPTION_SEED] = GLOBAL_SEED; - - numflag = options[3]; - - ParMETIS_V3_NodeND(vtxdist, xadj, adjncy, &numflag, newoptions, order, sizes, &comm); - - options[0] = -1; - -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/order.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/order.c deleted file mode 100644 index a73c87b..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/order.c +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * order.c - * - * This file contains the driving routines for the multilevel ordering algorithm - * - * Started 5/3/97 - * George - * - * $Id: order.c,v 1.2 2003/07/21 17:18:50 karypis Exp $ - * - */ - -#define DEBUG_ORDER_ - -#include - -/************************************************************************* -* This is the top level ordering routine -**************************************************************************/ -void MultilevelOrder(CtrlType *ctrl, GraphType *graph, idxtype *order, idxtype *sizes, WorkSpaceType *wspace) -{ - int i, nparts, nvtxs, npes; - idxtype *perm, *lastnode, *morder, *porder; - GraphType *mgraph; - - npes = ctrl->npes; - nvtxs = graph->nvtxs; - - perm = idxmalloc(nvtxs, "MultilevelOrder: perm"); - lastnode = idxsmalloc(4*npes, -1, "MultilevelOrder: lastnode"); - - for (i=0; ignvtxs; - - idxset(nvtxs, -1, order); - - sizes[0] = 2*npes-1; - - graph->where = idxsmalloc(nvtxs, 0, "MultilevelOrder: graph->where"); - - for (nparts=2; nparts<=ctrl->npes; nparts*=2) { - ctrl->nparts = nparts; - - Order_Partition(ctrl, graph, wspace); - - LabelSeparators(ctrl, graph, lastnode, perm, order, sizes, wspace); - - CompactGraph(ctrl, graph, perm, wspace); - - if (ctrl->CoarsenTo < 100*nparts) { - ctrl->CoarsenTo = 1.5*ctrl->CoarsenTo; - } - ctrl->CoarsenTo = amin(ctrl->CoarsenTo, graph->gnvtxs-1); - } - - - /*----------------------------------------------------------------- - / Move the graph so that each processor gets its partition - -----------------------------------------------------------------*/ - IFSET(ctrl->dbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->MoveTmr)); - - SetUp(ctrl, graph, wspace); - graph->ncon = 1; /*needed for Moc_MoveGraph */ - mgraph = Moc_MoveGraph(ctrl, graph, wspace); - - /* Fill in the sizes[] array for the local part. Just the vtxdist of the mgraph */ - for (i=0; ivtxdist[i+1]-mgraph->vtxdist[i]; - - porder = idxmalloc(graph->nvtxs, "MultilevelOrder: porder"); - morder = idxmalloc(mgraph->nvtxs, "MultilevelOrder: morder"); - - IFSET(ctrl->dbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->MoveTmr)); - - /* Find the local ordering */ - LocalNDOrder(ctrl, mgraph, morder, lastnode[2*(ctrl->npes+ctrl->mype)]-mgraph->nvtxs, wspace); - - /* Project the ordering back to the before-move graph */ - ProjectInfoBack(ctrl, graph, porder, morder, wspace); - - /* Copy the ordering from porder to order using perm */ - for (i=0; invtxs; i++) { - ASSERT(ctrl, order[perm[i]] == -1); - order[perm[i]] = porder[i]; - } - - FreeGraph(mgraph); - GKfree((void **)&perm, (void **)&lastnode, (void **)&porder, (void **)&morder, LTERM); - - /* PrintVector(ctrl, 2*npes-1, 0, sizes, "SIZES"); */ -} - - -/************************************************************************* -* This function is used to assign labels to the nodes in the separators -* It uses the appropriate entry in the lastnode array to select label -* boundaries and adjusts it for the next level -**************************************************************************/ -void LabelSeparators(CtrlType *ctrl, GraphType *graph, idxtype *lastnode, idxtype *perm, idxtype *order, idxtype *sizes, WorkSpaceType *wspace) -{ - int i, nvtxs, nparts, sid; - idxtype *where, *lpwgts, *gpwgts, *sizescan; - - nparts = ctrl->nparts; - - nvtxs = graph->nvtxs; - where = graph->where; - lpwgts = graph->lpwgts; - gpwgts = graph->gpwgts; - - /* Compute the local size of the separator. This is required in case the - * graph has vertex weights */ - idxset(2*nparts, 0, lpwgts); - for (i=0; icomm); - MPI_Allreduce((void *)lpwgts, (void *)gpwgts, 2*nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); - -#ifdef DEBUG_ORDER - PrintVector(ctrl, 2*nparts, 0, lpwgts, "Lpwgts"); - PrintVector(ctrl, 2*nparts, 0, sizescan, "SizeScan"); - PrintVector(ctrl, 2*nparts, 0, lastnode, "LastNode"); -#endif - - /* Fillin the sizes[] array */ - for (i=nparts-2; i>=0; i-=2) - sizes[--sizes[0]] = gpwgts[nparts+i]; - - if (ctrl->dbglvl&DBG_INFO) { - if (ctrl->mype == 0) { - printf("SepSizes: "); - for (i=0; icomm); - } - - for (i=0; i<2*nparts; i++) - sizescan[i] -= lpwgts[i]; - - for (i=0; i= nparts) { - sid = where[i]; - sizescan[sid]++; - ASSERT(ctrl, order[perm[i]] == -1); - order[perm[i]] = lastnode[sid] - sizescan[sid]; - /* myprintf(ctrl, "order[%d] = %d, %d\n", perm[i], order[perm[i]], sid); */ - } - } - - /* Update lastnode array */ - idxcopy(2*nparts, lastnode, sizescan); - for (i=0; inparts; - npes = ctrl->npes; - - nvtxs = graph->nvtxs; - xadj = graph->xadj; - ladjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - - if (graph->cmap == NULL) - graph->cmap = idxmalloc(nvtxs+graph->nrecv, "CompactGraph: cmap"); - cmap = graph->cmap; - - vtxdist = graph->vtxdist; - - /************************************************************* - * Construct the cvtxdist of the contracted graph. Uses the fact - * that lpwgts stores the local non separator vertices. - **************************************************************/ - cvtxdist = wspace->pv1; - cnvtxs = cvtxdist[npes] = idxsum(nparts, graph->lpwgts); - - MPI_Allgather((void *)(cvtxdist+npes), 1, IDX_DATATYPE, (void *)cvtxdist, 1, IDX_DATATYPE, ctrl->comm); - MAKECSR(i, npes, cvtxdist); - -#ifdef DEBUG_ORDER - PrintVector(ctrl, npes+1, 0, cvtxdist, "cvtxdist"); -#endif - - - /************************************************************* - * Construct the cmap vector - **************************************************************/ - cfirstvtx = cvtxdist[ctrl->mype]; - - /* Create the cmap of what you know so far locally */ - for (cnvtxs=0, i=0; iindices, cmap+nvtxs); - - - /************************************************************* - * Finally, compact the graph - **************************************************************/ - newwhere = idxmalloc(cnvtxs, "CompactGraph: newwhere"); - cnvtxs = l = 0; - for (i=0; ivwgt[cnvtxs] = graph->vwgt[i]; - newwhere[cnvtxs] = where[i]; - cnvtxs++; - } - } - for (i=cnvtxs; i>0; i--) - xadj[i] = xadj[i-1]; - xadj[0] = 0; - - GKfree((void **)&graph->match, (void **)&graph->cmap, (void **)&graph->lperm, (void **)&graph->where, (void **)&graph->label, (void **)&graph->rinfo, - (void **)&graph->nrinfo, (void **)&graph->lpwgts, (void **)&graph->gpwgts, (void **)&graph->sepind, (void **)&graph->peind, - (void **)&graph->sendptr, (void **)&graph->sendind, (void **)&graph->recvptr, (void **)&graph->recvind, - (void **)&graph->imap, (void **)&graph->rlens, (void **)&graph->slens, (void **)&graph->rcand, (void **)&graph->pexadj, - (void **)&graph->peadjncy, (void **)&graph->peadjloc, LTERM); - - graph->nvtxs = cnvtxs; - graph->nedges = l; - graph->gnvtxs = cvtxdist[npes]; - idxcopy(npes+1, cvtxdist, graph->vtxdist); - graph->where = newwhere; - -} - - -/************************************************************************* -* This function orders the locally stored graph using MMD. -* The vertices will be ordered from firstnode onwards. -**************************************************************************/ -void LocalNDOrder(CtrlType *ctrl, GraphType *graph, idxtype *order, int firstnode, WorkSpaceType *wspace) -{ - int i, j, nvtxs, firstvtx, lastvtx; - idxtype *xadj, *adjncy; - idxtype *perm, *iperm; - int numflag=0, options[10]; - - nvtxs = graph->nvtxs; - xadj = graph->xadj; - adjncy = graph->adjncy; - - firstvtx = graph->vtxdist[ctrl->mype]; - lastvtx = graph->vtxdist[ctrl->mype+1]; - - /* Relabel the vertices so that they are in local index space */ - for (i=0; i=firstvtx && adjncy[j]maxcore); - - perm = wspace->core; - iperm = perm + nvtxs + 5; - - options[0] = 0; - METIS_NodeND(&nvtxs, xadj, adjncy, &numflag, options, perm, iperm); - - for (i=0; i=0 && iperm[i]ncon = 1; - - IFSET(ctrl->dbglvl, DBG_PROGRESS, rprintf(ctrl, "[%6d %8d %5d %5d][%d][%d]\n", - graph->gnvtxs, GlobalSESum(ctrl, graph->nedges), GlobalSEMin(ctrl, graph->nvtxs), - GlobalSEMax(ctrl, graph->nvtxs), ctrl->CoarsenTo, - GlobalSEMax(ctrl, graph->vwgt[idxamax(graph->nvtxs, graph->vwgt)]))); - - if (graph->gnvtxs < 1.3*ctrl->CoarsenTo || (graph->finer != NULL && graph->gnvtxs > graph->finer->gnvtxs*COARSEN_FRACTION)) { - /* Compute the initial npart-way multisection */ - InitMultisection(ctrl, graph, wspace); - - if (graph->finer == NULL) { /* Do that only of no-coarsening took place */ - ComputeNodePartitionParams(ctrl, graph, wspace); - KWayNodeRefine(ctrl, graph, wspace, 2*NGR_PASSES, ORDER_UNBALANCE_FRACTION); - } - } - else { /* Coarsen it and the partition it */ - Mc_LocalMatch_HEM(ctrl, graph, wspace); - - Order_Partition(ctrl, graph->coarser, wspace); - - Moc_ProjectPartition(ctrl, graph, wspace); - ComputeNodePartitionParams(ctrl, graph, wspace); - KWayNodeRefine(ctrl, graph, wspace, 2*NGR_PASSES, ORDER_UNBALANCE_FRACTION); - } -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/parmetislib.h b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/parmetislib.h deleted file mode 100644 index 36c1041..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/parmetislib.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * par_metis.h - * - * This file includes all necessary header files - * - * Started 8/27/94 - * George - * - * $Id: parmetislib.h,v 1.2 2003/07/21 17:50:22 karypis Exp $ - */ - -/* -#define DEBUG 1 -#define DMALLOC 1 -*/ - -#include -#include "../parmetis.h" - -#ifdef DMALLOC -#include -#endif - -#include -#include -#include -#include -#include - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/proto.h b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/proto.h deleted file mode 100644 index bbab2e5..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/proto.h +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * proto.h - * - * This file contains header files - * - * Started 10/19/95 - * George - * - * $Id: proto.h,v 1.11 2003/07/25 13:52:03 karypis Exp $ - * - */ - -/* kmetis.c */ -void Moc_Global_Partition(CtrlType *, GraphType *, WorkSpaceType *); - -/* mmetis.c */ - -/* gkmetis.c */ - -/* match.c */ -void Moc_GlobalMatch_Balance(CtrlType *, GraphType *, WorkSpaceType *); - -/* coarsen.c */ -void Moc_Global_CreateCoarseGraph(CtrlType *, GraphType *, WorkSpaceType *, int); - -/* initpart.c */ -void Moc_InitPartition_RB(CtrlType *, GraphType *, WorkSpaceType *); -void Moc_KeepPart(GraphType *, WorkSpaceType *, idxtype *, int); - -/* kwayrefine.c */ -void Moc_ProjectPartition(CtrlType *, GraphType *, WorkSpaceType *); -void Moc_ComputePartitionParams(CtrlType *, GraphType *, WorkSpaceType *); - -/* kwayfm.c */ -void Moc_KWayFM(CtrlType *, GraphType *, WorkSpaceType *, int); - -/* kwaybalance.c */ -void Moc_KWayBalance(CtrlType *, GraphType *, WorkSpaceType *, int); - -/* remap.c */ -void ParallelReMapGraph(CtrlType *, GraphType *, WorkSpaceType *); -void ParallelTotalVReMap(CtrlType *, idxtype *, idxtype *, WorkSpaceType *, int, int); -int SimilarTpwgts(float *, int, int, int); - -/* move.c */ -GraphType *Moc_MoveGraph(CtrlType *, GraphType *, WorkSpaceType *); -/* move.c */ -void CheckMGraph(CtrlType *, GraphType *); -void ProjectInfoBack(CtrlType *, GraphType *, idxtype *, idxtype *, WorkSpaceType *); -void FindVtxPerm(CtrlType *, GraphType *, idxtype *, WorkSpaceType *); - -/* memory.c */ -void PreAllocateMemory(CtrlType *, GraphType *, WorkSpaceType *); -void FreeWSpace(WorkSpaceType *); -void FreeCtrl(CtrlType *); -GraphType *CreateGraph(void); -void InitGraph(GraphType *); -void FreeGraph(GraphType *); -void FreeInitialGraphAndRemap(GraphType *, int); - - -/* ametis.c */ -void Adaptive_Partition(CtrlType *, GraphType *, WorkSpaceType *); - -/* rmetis.c */ - - -/* lmatch.c */ -void Mc_LocalMatch_HEM(CtrlType *, GraphType *, WorkSpaceType *); -void Mc_Local_CreateCoarseGraph(CtrlType *, GraphType *, WorkSpaceType *, int); - -/* wave.c */ -float WavefrontDiffusion(CtrlType *, GraphType *, idxtype *); - -/* balancemylink.c */ -int BalanceMyLink(CtrlType *, GraphType *, idxtype *, int, int, float *, float, float *, float *, float); - -/* redomylink.c */ -void RedoMyLink(CtrlType *, GraphType *, idxtype *, int, int, float *, float *, float *); - -/* initbalance.c */ -void Balance_Partition(CtrlType *, GraphType *, WorkSpaceType *); -GraphType *Moc_AssembleAdaptiveGraph(CtrlType *, GraphType *, WorkSpaceType *); - -/* mdiffusion.c */ -int Moc_Diffusion(CtrlType *, GraphType *, idxtype *, idxtype *, idxtype *, WorkSpaceType *, int); -GraphType *ExtractGraph(CtrlType *, GraphType *, idxtype *, idxtype *, idxtype *); - -/* diffutil.c */ -void SetUpConnectGraph(GraphType *, MatrixType *, idxtype *); -void Mc_ComputeMoveStatistics(CtrlType *, GraphType *, int *, int *, int *); - int Mc_ComputeSerialTotalV(GraphType *, idxtype *); -void ComputeLoad(GraphType *, int, float *, float *, int); -void ConjGrad2(MatrixType *, float *, float *, float, float *); -void mvMult2(MatrixType *, float *, float *); -void ComputeTransferVector(int, MatrixType *, float *, float *, int); -int ComputeSerialEdgeCut(GraphType *); -int ComputeSerialTotalV(GraphType *, idxtype *); - -/* akwayfm.c */ -void Moc_KWayAdaptiveRefine(CtrlType *, GraphType *, WorkSpaceType *, int); - -/* selectq.c */ -void Moc_DynamicSelectQueue(int, int, int, int, idxtype *, float *, int *, int *, int, float, float); -int Moc_HashVwgts(int, float *); -int Moc_HashVRank(int, int *); - - -/* csrmatch.c */ -void CSR_Match_SHEM(MatrixType *, idxtype *, idxtype *, idxtype *, int); - -/* serial.c */ -void Moc_SerialKWayAdaptRefine(GraphType *, int, idxtype *, float *, int); -void Moc_ComputeSerialPartitionParams(GraphType *, int, EdgeType *); -int AreAllHVwgtsBelow(int, float, float *, float, float *, float *); -void ComputeHKWayLoadImbalance(int, int, float *, float *); -void SerialRemap(GraphType *, int, idxtype *, idxtype *, idxtype *, float *); -int SSMIncKeyCmp(const void *, const void *); -void Moc_Serial_FM_2WayRefine(GraphType *, float *, int); -void Serial_SelectQueue(int, float *, float *, int *, int *, FPQueueType [MAXNCON][2]); -int Serial_BetterBalance(int, float *, float *, float *); -float Serial_Compute2WayHLoadImbalance(int, float *, float *); -void Moc_Serial_Balance2Way(GraphType *, float *, float); -void Moc_Serial_Init2WayBalance(GraphType *, float *); -int Serial_SelectQueueOneWay(int, float *, float *, int, FPQueueType [MAXNCON][2]); -void Moc_Serial_Compute2WayPartitionParams(GraphType *); -int Serial_AreAnyVwgtsBelow(int, float, float *, float, float *, float *); - -/* weird.c */ -void PartitionSmallGraph(CtrlType *, GraphType *, WorkSpaceType *); -void CheckInputs(int partType, int npes, int dbglvl, int *wgtflag, int *iwgtflag, - int *numflag, int *inumflag, int *ncon, int *incon, int *nparts, - int *inparts, float *tpwgts, float **itpwgts, float *ubvec, - float *iubvec, float *ipc2redist, float *iipc2redist, int *options, - int *ioptions, idxtype *part, MPI_Comm *comm); - -/* mesh.c */ - -/* ometis.c */ - -/* pspases.c */ -GraphType *AssembleEntireGraph(CtrlType *, idxtype *, idxtype *, idxtype *); - -/* node_refine.c */ -void ComputeNodePartitionParams0(CtrlType *, GraphType *, WorkSpaceType *); -void ComputeNodePartitionParams(CtrlType *, GraphType *, WorkSpaceType *); -void KWayNodeRefine0(CtrlType *, GraphType *, WorkSpaceType *, int, float); -void KWayNodeRefine(CtrlType *, GraphType *, WorkSpaceType *, int, float); -void KWayNodeRefine2(CtrlType *, GraphType *, WorkSpaceType *, int, float); -void PrintNodeBalanceInfo(CtrlType *, int, idxtype *, idxtype *, idxtype *, int); - -/* initmsection.c */ -void InitMultisection(CtrlType *, GraphType *, WorkSpaceType *); -GraphType *AssembleMultisectedGraph(CtrlType *, GraphType *, WorkSpaceType *); - -/* order.c */ -void MultilevelOrder(CtrlType *, GraphType *, idxtype *, idxtype *, WorkSpaceType *); -void LabelSeparators(CtrlType *, GraphType *, idxtype *, idxtype *, idxtype *, idxtype *, WorkSpaceType *); -void CompactGraph(CtrlType *, GraphType *, idxtype *, WorkSpaceType *); -void LocalOrder(CtrlType *, GraphType *, idxtype *, int, WorkSpaceType *); -void LocalNDOrder(CtrlType *, GraphType *, idxtype *, int, WorkSpaceType *); -void Order_Partition(CtrlType *, GraphType *, WorkSpaceType *); - -/* xyzpart.c */ -void Coordinate_Partition(CtrlType *, GraphType *, int, float *, int, WorkSpaceType *); -void PartSort(CtrlType *, GraphType *, KeyValueType *, WorkSpaceType *); - - -/* fpqueue.c */ -void FPQueueInit(FPQueueType *, int); -void FPQueueReset(FPQueueType *); -void FPQueueFree(FPQueueType *); -int FPQueueGetSize(FPQueueType *); -int FPQueueInsert(FPQueueType *, int, float); -int FPQueueDelete(FPQueueType *, int); -int FPQueueUpdate(FPQueueType *, int, float, float); -void FPQueueUpdateUp(FPQueueType *, int, float, float); -int FPQueueGetMax(FPQueueType *); -int FPQueueSeeMaxVtx(FPQueueType *); -float FPQueueSeeMaxGain(FPQueueType *); -float FPQueueGetKey(FPQueueType *); -int FPQueueGetQSize(FPQueueType *); -int CheckHeapFloat(FPQueueType *); - -/* stat.c */ -void Moc_ComputeSerialBalance(CtrlType *, GraphType *, idxtype *, float *); -void Moc_ComputeParallelBalance(CtrlType *, GraphType *, idxtype *, float *); -void Moc_PrintThrottleMatrix(CtrlType *, GraphType *, float *); -void Moc_ComputeRefineStats(CtrlType *, GraphType *, float *); - -/* debug.c */ -void PrintVector(CtrlType *, int, int, idxtype *, char *); -void PrintVector2(CtrlType *, int, int, idxtype *, char *); -void PrintPairs(CtrlType *, int, KeyValueType *, char *); -void PrintGraph(CtrlType *, GraphType *); -void PrintGraph2(CtrlType *, GraphType *); -void PrintSetUpInfo(CtrlType *ctrl, GraphType *graph); -void PrintTransferedGraphs(CtrlType *, int, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *); -void WriteMetisGraph(int, idxtype *, idxtype *, idxtype *, idxtype *); - -/* comm.c */ -void CommInterfaceData(CtrlType *, GraphType *, idxtype *, idxtype *, idxtype *); -void CommChangedInterfaceData(CtrlType *, GraphType *, int, idxtype *, idxtype *, KeyValueType *, KeyValueType *, idxtype *); -int GlobalSEMax(CtrlType *, int); -double GlobalSEMaxDouble(CtrlType *, double); -int GlobalSEMin(CtrlType *, int); -int GlobalSESum(CtrlType *, int); -float GlobalSEMaxFloat(CtrlType *, float); -float GlobalSEMinFloat(CtrlType *, float); -float GlobalSESumFloat(CtrlType *, float); - -/* util.c */ -void errexit(char *,...); -void myprintf(CtrlType *, char *f_str,...); -void rprintf(CtrlType *, char *f_str,...); -#ifndef DMALLOC -int *imalloc(int, char *); -idxtype *idxmalloc(int, char *); -float *fmalloc(int, char *); -int *ismalloc(int, int, char *); -idxtype *idxsmalloc(int, idxtype, char *); -void *GKmalloc(int, char *); -#endif -/*void GKfree(void **,...); */ -int *iset(int n, int val, int *x); -idxtype * idxset(int n, idxtype val, idxtype *x); -int idxamax(int n, idxtype *x); -int idxamin(int n, idxtype *x); -int idxasum(int n, idxtype *x); -float snorm2(int, float *); -float sdot(int n, float *, float *); -void saxpy(int, float, float *, float *); -void ikeyvalsort_org(int, KeyValueType *); -int IncKeyValueCmp(const void *, const void *); -void dkeyvalsort(int, KeyValueType *); -int DecKeyValueCmp(const void *, const void *); -int BSearch(int, idxtype *, int); -void RandomPermute(int, idxtype *, int); -void FastRandomPermute(int, idxtype *, int); -int ispow2(int); -int log2Int(int); -void BucketSortKeysDec(int, int, idxtype *, idxtype *); -float *sset(int n, float val, float *x); -int iamax(int, int *); -int idxamax_strd(int, idxtype *, int); -int idxamin_strd(int, idxtype *, int); -int samax_strd(int, float *, int); -int sfamax(int, float *); -int samin_strd(int, float *, int); -float idxavg(int, idxtype *); -float savg(int, float *); -int samax(int, float *); -int sfavg(int n, float *x); -int samax2(int, float *); -int samin(int, float *); -int idxsum(int, idxtype *); -int idxsum_strd(int, idxtype *, int); -void idxadd(int, idxtype *, idxtype *); -float ssum(int, float *); -float ssum_strd(int, float *, int); -void sscale(int, float, float *); -void saneg(int, float *); -float BetterVBalance(int, float *, float *, float *); -int IsHBalanceBetterTT(int, float *, float *, float *, float *); -int IsHBalanceBetterFT(int, float *, float *, float *, float *); -int myvalkeycompare(const void *, const void *); -int imyvalkeycompare(const void *, const void *); -float *fsmalloc(int, float, char *); -void saxpy2(int, float, float *, int, float *, int); -void GetThreeMax(int, float *, int *, int *, int *); - -/* qsort_special.c */ -void iidxsort(int, idxtype *); -void iintsort(int, int *); -void ikeysort(int, KeyValueType *); -void ikeyvalsort(int, KeyValueType *); - -/* grsetup.c */ -GraphType *Moc_SetUpGraph(CtrlType *, int, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *, int *); -void SetUpCtrl(CtrlType *ctrl, int, int, MPI_Comm); -void ChangeNumbering(idxtype *, idxtype *, idxtype *, idxtype *, int, int, int); -void ChangeNumberingMesh(idxtype *, idxtype *, idxtype *, idxtype *, idxtype *, int, int, int, int); -void ChangeNumberingMesh2(idxtype *elmdist, idxtype *eptr, idxtype *eind, - idxtype *xadj, idxtype *adjncy, idxtype *part, - int npes, int mype, int from); -void GraphRandomPermute(GraphType *); -void ComputeMoveStatistics(CtrlType *, GraphType *, int *, int *, int *); - -/* timer.c */ -void InitTimers(CtrlType *); -void PrintTimingInfo(CtrlType *); -void PrintTimer(CtrlType *, timer, char *); - -/* setup.c */ -void SetUp(CtrlType *, GraphType *, WorkSpaceType *); -int Home_PE(int, int, idxtype *, int); - - -/*********************/ -/* METIS subroutines */ -/*********************/ -void METIS_WPartGraphKway2(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); -void METIS_mCPartGraphRecursive2(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); -int MCMlevelRecursiveBisection2(CtrlType *, GraphType *, int, float *, idxtype *, float, int); -void METIS_PartGraphKway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); -void METIS_mCPartGraphKway(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); -void METIS_EdgeComputeSeparator(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, idxtype *); -void METIS_NodeComputeSeparator(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, idxtype *); -void METIS_NodeND(int *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); -void METIS_NodeNDP(int, idxtype *, idxtype *, int, int *, idxtype *, idxtype *, idxtype *); - - - -/***********************/ -/* TESTing subroutines */ -/***********************/ - -/* pio.c */ -void ParallelReadGraph(GraphType *, char *, MPI_Comm); -void Moc_ParallelWriteGraph(CtrlType *, GraphType *, char *, int, int); -void ReadTestGraph(GraphType *, char *, MPI_Comm); -float *ReadTestCoordinates(GraphType *, char *, int, MPI_Comm); -void ReadMetisGraph(char *, int *, idxtype **, idxtype **); -void Moc_SerialReadGraph(GraphType *, char *, int *, MPI_Comm); -void Moc_SerialReadMetisGraph(char *, int *, int *, int *, int *, idxtype **, idxtype **, idxtype **, idxtype **, int *); - -/* adaptgraph */ -void AdaptGraph(GraphType *, int, MPI_Comm); -void AdaptGraph2(GraphType *, int, MPI_Comm); -void Mc_AdaptGraph(GraphType *, idxtype *, int, int, MPI_Comm); - -/* ptest.c */ -void TestParMetis(char *, MPI_Comm); - -/* NEW_ptest.c */ -void TestParMetis_V3(char *, MPI_Comm); -int ComputeRealCut(idxtype *, idxtype *, char *, MPI_Comm); -int ComputeRealCut2(idxtype *, idxtype *, idxtype *, idxtype *, char *, MPI_Comm); -void TestMoveGraph(GraphType *, GraphType *, idxtype *, MPI_Comm); -GraphType *SetUpGraph(CtrlType *, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *, int); - -/* mienio.c */ -void mienIO(MeshType *, char *, int, int, MPI_Comm); - -/* meshio.c */ -void ParallelReadMesh(MeshType *, char *, MPI_Comm); - -/* parmetis.c */ -void ChangeToFortranNumbering(idxtype *, idxtype *, idxtype *, int, int); - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/pspases.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/pspases.c deleted file mode 100644 index 8b7a182..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/pspases.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * pspases.c - * - * This file contains ordering routines that are to be used with the - * parallel Cholesky factorization code PSPASES - * - * Started 10/14/97 - * George - * - * $Id: pspases.c,v 1.3 2003/07/21 17:18:53 karypis Exp $ - * - */ - -#include - - -/*********************************************************************************** -* This function is the entry point of the serial ordering algorithm. -************************************************************************************/ -void ParMETIS_SerialNodeND(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, int *numflag, - int *options, idxtype *order, idxtype *sizes, MPI_Comm *comm) -{ - int i, npes, mype, seroptions[10]; - CtrlType ctrl; - GraphType *agraph; - idxtype *perm=NULL, *iperm=NULL; - int *sendcount, *displs; - - MPI_Comm_size(*comm, &npes); - MPI_Comm_rank(*comm, &mype); - - if (!ispow2(npes)) { - if (mype == 0) - printf("Error: The number of processors must be a power of 2!\n"); - return; - } - - if (*numflag == 1) - ChangeNumbering(vtxdist, xadj, adjncy, order, npes, mype, 1); - - SetUpCtrl(&ctrl, npes, options[OPTION_DBGLVL], *comm); - - IFSET(ctrl.dbglvl, DBG_TIME, InitTimers(&ctrl)); - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.TotalTmr)); - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.MoveTmr)); - - agraph = AssembleEntireGraph(&ctrl, vtxdist, xadj, adjncy); - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.MoveTmr)); - - - if (mype == 0) { - perm = idxmalloc(agraph->nvtxs, "PAROMETISS: perm"); - iperm = idxmalloc(agraph->nvtxs, "PAROMETISS: iperm"); - - seroptions[0] = 0; - /* - seroptions[1] = 3; - seroptions[2] = 1; - seroptions[3] = 2; - seroptions[4] = 128; - seroptions[5] = 1; - seroptions[6] = 0; - seroptions[7] = 1; - */ - - METIS_NodeNDP(agraph->nvtxs, agraph->xadj, agraph->adjncy, npes, seroptions, perm, iperm, sizes); - } - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.MoveTmr)); - - /* Broadcast the sizes array */ - MPI_Bcast((void *)sizes, 2*npes, IDX_DATATYPE, 0, ctrl.gcomm); - - /* Scatter the iperm */ - sendcount = imalloc(npes, "PAROMETISS: sendcount"); - displs = imalloc(npes, "PAROMETISS: displs"); - for (i=0; ixadj, (void **)&agraph->adjncy, (void **)&perm, (void **)&iperm, (void **)&sendcount, (void **)&displs, LTERM); - free(agraph); - FreeCtrl(&ctrl); - - if (*numflag == 1) - ChangeNumbering(vtxdist, xadj, adjncy, order, npes, mype, 0); - -} - - - -/************************************************************************* -* This function assembles the graph into a single processor -**************************************************************************/ -GraphType *AssembleEntireGraph(CtrlType *ctrl, idxtype *vtxdist, idxtype *xadj, idxtype *adjncy) -{ - int i, gnvtxs, nvtxs, gnedges, nedges; - int npes = ctrl->npes, mype = ctrl->mype; - idxtype *axadj, *aadjncy; - int *recvcounts, *displs; - GraphType *agraph; - - gnvtxs = vtxdist[npes]; - nvtxs = vtxdist[mype+1]-vtxdist[mype]; - nedges = xadj[nvtxs]; - - recvcounts = imalloc(npes, "AssembleGraph: recvcounts"); - displs = imalloc(npes+1, "AssembleGraph: displs"); - - /* Gather all the xadj arrays first */ - for (i=0; icomm); - - MAKECSR(i, nvtxs, xadj); - MAKECSR(i, gnvtxs, axadj); - - /* Gather all the adjncy arrays next */ - /* Determine the # of edges stored at each processor */ - MPI_Allgather((void *)(&nedges), 1, MPI_INT, (void *)recvcounts, 1, MPI_INT, ctrl->comm); - - displs[0] = 0; - for (i=1; icomm); - - /* myprintf(ctrl, "Gnvtxs: %d, Gnedges: %d\n", gnvtxs, gnedges); */ - - agraph = CreateGraph(); - agraph->nvtxs = gnvtxs; - agraph->nedges = gnedges; - agraph->xadj = axadj; - agraph->adjncy = aadjncy; - - return agraph; -} diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/redomylink.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/redomylink.c deleted file mode 100644 index 98b6810..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/redomylink.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * redomylink.c - * - * This file contains code that implements the edge-based FM refinement - * - * Started 7/23/97 - * George - * - * $Id: redomylink.c,v 1.2 2003/07/21 17:18:53 karypis Exp $ - */ - -#include -#define PE 0 - -/************************************************************************* -* This function performs an edge-based FM refinement -**************************************************************************/ -void RedoMyLink(CtrlType *ctrl, GraphType *graph, idxtype *home, int me, - int you, float *flows, float *sr_cost, float *sr_lbavg) -{ - int h, i, r; - int nvtxs, nedges, ncon; - int pass, lastseed, totalv; - idxtype *xadj, *adjncy, *adjwgt, *where, *vsize; - idxtype *costwhere, *lbwhere, *selectwhere; - idxtype *rdata, *ed, *id, *bndptr, *bndind, *perm; - float *nvwgt, mycost; - float lbavg, lbvec[MAXNCON]; - float best_lbavg, other_lbavg = -1.0, bestcost, othercost = -1.0; - float npwgts[2*MAXNCON], pwgts[MAXNCON*2], tpwgts[MAXNCON*2]; - float ipc_factor, redist_factor, ftmp; -int mype; -MPI_Comm_rank(MPI_COMM_WORLD, &mype); - - nvtxs = graph->nvtxs; - nedges = graph->nedges; - ncon = graph->ncon; - xadj = graph->xadj; - nvwgt = graph->nvwgt; - vsize = graph->vsize; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - ipc_factor = ctrl->ipc_factor; - redist_factor = ctrl->redist_factor; - - /**************************/ - /* set up data structures */ - /**************************/ - rdata = idxmalloc(7*nvtxs, "rdata"); - id = graph->sendind = rdata; - ed = graph->recvind = rdata + nvtxs; - bndptr = graph->sendptr = rdata + 2*nvtxs; - bndind = graph->recvptr = rdata + 3*nvtxs; - costwhere = rdata + 4*nvtxs; - lbwhere = rdata + 5*nvtxs; - perm = rdata + 6*nvtxs; - graph->gnpwgts = npwgts; - - RandomPermute(nvtxs, perm, 1); - idxcopy(nvtxs, where, costwhere); - idxcopy(nvtxs, where, lbwhere); - - /*****************************/ - /* compute target pwgts */ - /*****************************/ - sset(ncon*2, 0.0, pwgts); - for (h=0; h0; pass--) { - idxset(nvtxs, 1, where); - - /***************************/ - /* find seed vertices */ - /***************************/ - r = perm[lastseed] % nvtxs; - lastseed = (lastseed+1) % nvtxs; - where[r] = 0; - - Moc_Serial_Compute2WayPartitionParams(graph); - Moc_Serial_Init2WayBalance(graph, tpwgts); - Moc_Serial_FM_2WayRefine(graph, tpwgts, 4); - Moc_Serial_Balance2Way(graph, tpwgts, 1.02); - Moc_Serial_FM_2WayRefine(graph, tpwgts, 4); - - for (i=0; imincut)*ipc_factor + (float)totalv*redist_factor; - - if (bestcost >= mycost) { - bestcost = mycost; - other_lbavg = lbavg; - idxcopy(nvtxs, where, costwhere); - } - - if (best_lbavg >= lbavg) { - best_lbavg = lbavg; - othercost = mycost; - idxcopy(nvtxs, where, lbwhere); - } - } - - if (other_lbavg <= .05) { - selectwhere = costwhere; - *sr_cost = bestcost; - *sr_lbavg = other_lbavg; - } - else { - selectwhere = lbwhere; - *sr_cost = othercost; - *sr_lbavg = best_lbavg; - } - - idxcopy(nvtxs, selectwhere, where); - - GKfree((void **)&rdata, LTERM); - return; -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/remap.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/remap.c deleted file mode 100644 index 31f186b..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/remap.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * premap.c - * - * This file contains code that computes the assignment of processors to - * partition numbers so that it will minimize the redistribution cost - * - * Started 4/16/98 - * George - * - * $Id: remap.c,v 1.2 2003/07/21 17:18:53 karypis Exp $ - * - */ - -#include - -/************************************************************************* -* This function remaps that graph so that it will minimize the -* redistribution cost -**************************************************************************/ -void ParallelReMapGraph(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, nvtxs, nparts; - idxtype *where, *vsize, *map, *lpwgts; - - IFSET(ctrl->dbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->RemapTmr)); - - if (ctrl->npes != ctrl->nparts) { - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->RemapTmr)); - return; - } - - nvtxs = graph->nvtxs; - where = graph->where; - vsize = graph->vsize; - nparts = ctrl->nparts; - - map = wspace->pv1; - lpwgts = idxset(nparts, 0, wspace->pv2); - - for (i=0; incon); - - for (i=0; idbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->RemapTmr)); -} - - -/************************************************************************* -* This function computes the assignment using the the objective the -* minimization of the total volume of data that needs to move -**************************************************************************/ -void ParallelTotalVReMap(CtrlType *ctrl, idxtype *lpwgts, idxtype *map, - WorkSpaceType *wspace, int npasses, int ncon) -{ - int i, ii, j, k, nparts, mype; - int pass, maxipwgt, nmapped, oldwgt, newwgt, done; - idxtype *rowmap, *mylpwgts; - KeyValueType *recv, send; - int nsaved, gnsaved; - - mype = ctrl->mype; - nparts = ctrl->nparts; - recv = (KeyValueType *)GKmalloc(sizeof(KeyValueType)*nparts, "remap: recv"); - mylpwgts = idxmalloc(nparts, "mylpwgts"); - - done = nmapped = 0; - idxset(nparts, -1, map); - rowmap = idxset(nparts, -1, wspace->pv3); - idxcopy(nparts, lpwgts, mylpwgts); - for (pass=0; pass 0 && !done) { - send.key = -mylpwgts[maxipwgt]; - send.val = mype*nparts+maxipwgt; - } - else { - send.key = 0; - send.val = -1; - } - - /* each processor sends its selection */ - MPI_Allgather((void *)&send, 2, IDX_DATATYPE, (void *)recv, 2, IDX_DATATYPE, ctrl->comm); - - ikeysort(nparts, recv); - if (recv[0].key == 0) - break; - - /* now make as many assignments as possible */ - for (ii=0; iitpwgts, ncon, j, k)) { - map[j] = k; - rowmap[k] = j; - nmapped++; - mylpwgts[j] = 0; - if (mype == k) - done = 1; - } - - if (nmapped == nparts) - break; - } - - if (nmapped == nparts) - break; - } - - /* Map unmapped partitions */ - if (nmapped < nparts) { - for (i=j=0; jtpwgts, ncon, i, j)) { - map[j] = i; - rowmap[i] = j; - nmapped++; - break; - } - } - } - } - } - - /* check to see if remapping fails (due to dis-similar tpwgts) */ - /* if remapping fails, revert to original mapping */ - if (nmapped < nparts) { - for (i=0; idbglvl, DBG_REMAP, rprintf(ctrl, "Savings from parallel remapping: %0\n")); - } - else { - /* check for a savings */ - oldwgt = lpwgts[mype]; - newwgt = lpwgts[rowmap[mype]]; - nsaved = newwgt - oldwgt; - gnsaved = GlobalSESum(ctrl, nsaved); - - /* undo everything if we don't see a savings */ - if (gnsaved <= 0) { - for (i=0; idbglvl, DBG_REMAP, rprintf(ctrl, "Savings from parallel remapping: %d\n", amax(0,gnsaved))); - } - - GKfree((void **)&recv, (void **)&mylpwgts, LTERM); - -} - - -/************************************************************************* -* This function computes the assignment using the the objective the -* minimization of the total volume of data that needs to move -**************************************************************************/ -int SimilarTpwgts(float *tpwgts, int ncon, int s1, int s2) -{ - int i; - - for (i=0; i SMALLFLOAT) - break; - - if (i == ncon) - return 1; - - return 0; -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/rename.h b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/rename.h deleted file mode 100644 index d993257..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/rename.h +++ /dev/null @@ -1,290 +0,0 @@ -/* kmetis.c */ -#define Moc_Global_Partition Moc_Global_Partition__ - -/* mmetis.c */ - -/* gkmetis.c */ - -/* match.c */ -#define Moc_GlobalMatch_Balance Moc_GlobalMatch_Balance__ - -/* coarsen.c */ -#define Moc_Global_CreateCoarseGraph Moc_Global_CreateCoarseGraph__ - -/* initpart.c */ -#define Moc_InitPartition_RB Moc_InitPartition_RB__ -#define Moc_KeepPart Moc_KeepPart__ - -/* kwayrefine.c */ -#define Moc_ProjectPartition Moc_ProjectPartition__ -#define Moc_ComputePartitionParams Moc_ComputePartitionParams__ - -/* kwayfm.c */ -#define Moc_KWayFM Moc_KWayFM__ - -/* kwaybalance.c */ -#define Moc_KWayBalance Moc_KWayBalance__ - -/* remap.c */ -#define ParallelReMapGraph ParallelReMapGraph__ -#define ParallelTotalVReMap ParallelTotalVReMap__ -#define SimilarTpwgts SimilarTpwgts__ - -/* move.c */ -#define Moc_MoveGraph Moc_MoveGraph__ -#define CheckMGraph CheckMGraph__ -#define ProjectInfoBack ProjectInfoBack__ -#define FindVtxPerm FindVtxPerm__ - -/* memory.c */ -#define PreAllocateMemory PreAllocateMemory__ -#define FreeWSpace FreeWSpace__ -#define FreeCtrl FreeCtrl__ -#define CreateGraph CreateGraph__ -#define InitGraph InitGraph__ -#define FreeGraph FreeGraph__ -#define FreeInitialGraphAndRemap FreeInitialGraphAndRemap__ - - -/************************/ -/* Adaptive subroutines */ -/************************/ -/* ametis.c */ -#define Adaptive_Partition Adaptive_Partition__ - -/* rmetis.c */ - -/* lmatch.c */ -#define Mc_LocalMatch_HEM Mc_LocalMatch_HEM__ -#define Mc_Local_CreateCoarseGraph Mc_Local_CreateCoarseGraph__ - -/* wave.c */ -#define WavefrontDiffusion WavefrontDiffusion__ - -/* balancemylink.c */ -#define BalanceMyLink BalanceMyLink__ - -/* redomylink.c */ -#define RedoMyLink RedoMyLink__ - -/* initbalance.c */ -#define Balance_Partition Balance_Partition__ -#define Moc_AssembleAdaptiveGraph Moc_AssembleAdaptiveGraph__ - -/* mdiffusion.c */ -#define Moc_Diffusion Moc_Diffusion__ -#define ExtractGraph ExtractGraph__ - -/* diffutil.c */ -#define SetUpConnectGraph SetUpConnectGraph__ -#define Mc_ComputeMoveStatistics Mc_ComputeMoveStatistics__ -#define Mc_ComputeSerialTotalV Mc_ComputeSerialTotalV__ -#define ComputeLoad ComputeLoad__ -#define ConjGrad2 ConjGrad2__ -#define mvMult2 mvMult2__ -#define ComputeTransferVector ComputeTransferVector__ -#define ComputeSerialEdgeCut ComputeSerialEdgeCut__ -#define ComputeSerialTotalV ComputeSerialTotalV__ - -/* akwayfm.c */ -#define Moc_KWayAdaptiveRefine Moc_KWayAdaptiveRefine__ - -/* selectq.c */ -#define Moc_DynamicSelectQueue Moc_DynamicSelectQueue__ -#define Moc_HashVwgts Moc_HashVwgts__ -#define Moc_HashVRank Moc_HashVRank__ - -/* csrmatch.c */ -#define CSR_Match_SHEM CSR_Match_SHEM__ - -/* serial.c */ -#define Moc_SerialKWayAdaptRefine Moc_SerialKWayAdaptRefine__ -#define Moc_ComputeSerialPartitionParams Moc_ComputeSerialPartitionParams__ -#define AreAllHVwgtsBelow AreAllHVwgtsBelow__ -#define ComputeHKWayLoadImbalance ComputeHKWayLoadImbalance__ -#define SerialRemap SerialRemap__ -#define SSMIncKeyCmp SSMIncKeyCmp__ -#define Moc_Serial_FM_2WayRefine Moc_Serial_FM_2WayRefine__ -#define Serial_SelectQueue Serial_SelectQueue__ -#define Serial_BetterBalance Serial_BetterBalance__ -#define Serial_Compute2WayHLoadImbalance Serial_Compute2WayHLoadImbalance__ -#define Moc_Serial_Balance2Way Moc_Serial_Balance2Way__ -#define Moc_Serial_Init2WayBalance Moc_Serial_Init2WayBalance__ -#define Serial_SelectQueueOneWay Serial_SelectQueueOneWay__ -#define Moc_Serial_Compute2WayPartitionParams Moc_Serial_Compute2WayPartitionParams__ -#define Serial_AreAnyVwgtsBelow Serial_AreAnyVwgtsBelow__ - -/* weird.c */ -#define PartitionSmallGraph PartitionSmallGraph__ -#define CheckInputs CheckInputs__ - - -/****************************/ -/* Mesh to Dual subroutines */ -/****************************/ -/* mesh.c */ -/* msetup.c */ -#define SetUpMesh SetUpMesh__ -#define CreateMesh CreateMesh__ -#define InitMesh InitMesh__ - - -/************************/ -/* Ordering subroutines */ -/************************/ -/* ometis.c */ -/* pspases.c */ -#define AssembleEntireGraph AssembleEntireGraph__ - -/* node_refine.c */ -#define ComputeNodePartitionParams0 ComputeNodePartitionParams0__ -#define ComputeNodePartitionParams ComputeNodePartitionParams__ -#define KWayNodeRefine0 KWayNodeRefine0__ -#define KWayNodeRefine KWayNodeRefine__ -#define KWayNodeRefine2 KWayNodeRefine2__ -#define PrintNodeBalanceInfo PrintNodeBalanceInfo__ - -/* initmsection.c */ -#define InitMultisection InitMultisection__ -#define AssembleMultisectedGraph AssembleMultisectedGraph__ - -/* order.c */ -#define MultilevelOrder MultilevelOrder__ -#define LabelSeparators LabelSeparators__ -#define CompactGraph CompactGraph__ -#define LocalOrder LocalOrder__ -#define LocalNDOrder LocalNDOrder__ -#define Order_Partition Order_Partition__ - -/* xyzpart.c */ -#define Coordinate_Partition Coordinate_Partition__ -#define PartSort PartSort__ - -/***********************/ -/* Utility subroutines */ -/***********************/ -/* fpqueue.c */ -#define FPQueueInit FPQueueInit__ -#define FPQueueReset FPQueueReset__ -#define FPQueueFree FPQueueFree__ -#define FPQueueGetSize FPQueueGetSize__ -#define FPQueueInsert FPQueueInsert__ -#define FPQueueDelete FPQueueDelete__ -#define FPQueueUpdate FPQueueUpdate__ -#define FPQueueUpdateUp FPQueueUpdateUp__ -#define FPQueueGetMax FPQueueGetMax__ -#define FPQueueSeeMaxVtx FPQueueSeeMaxVtx__ -#define FPQueueSeeMaxGain FPQueueSeeMaxGain__ -#define FPQueueGetKey FPQueueGetKey__ -#define FPQueueGetQSize FPQueueGetQSize__ -#define CheckHeapFloat CheckHeapFloat__ - -/* stat.c */ -#define Moc_ComputeSerialBalance Moc_ComputeSerialBalance__ -#define Moc_ComputeParallelBalance Moc_ComputeParallelBalance__ -#define Moc_PrintThrottleMatrix Moc_PrintThrottleMatrix__ -#define Moc_ComputeRefineStats Moc_ComputeRefineStats__ - -/* debug.c */ -#define PrintVector PrintVector__ -#define PrintVector2 PrintVector2__ -#define PrintPairs PrintPairs__ -#define PrintGraph PrintGraph__ -#define PrintGraph2 PrintGraph2__ -#define PrintSetUpInfo PrintSetUpInfo__ -#define PrintTransferedGraphs PrintTransferedGraphs__ -#define WriteMetisGraph WriteMetisGraph__ - -/* comm.c */ -#define CommInterfaceData CommInterfaceData__ -#define CommChangedInterfaceData CommChangedInterfaceData__ -#define GlobalSEMax GlobalSEMax__ -#define GlobalSEMaxDouble GlobalSEMaxDouble__ -#define GlobalSEMin GlobalSEMin__ -#define GlobalSESum GlobalSESum__ -#define GlobalSEMaxFloat GlobalSEMaxFloat__ -#define GlobalSEMinFloat GlobalSEMinFloat__ -#define GlobalSESumFloat GlobalSESumFloat__ - -/* util.c */ -#define errexit errexit__ -#define myprintf myprintf__ -#define rprintf rprintf__ -#define imalloc imalloc__ -#define idxmalloc idxmalloc__ -#define fmalloc fmalloc__ -#define ismalloc ismalloc__ -#define idxsmalloc idxsmalloc__ -#define GKmalloc GKmalloc__ -#define GKfree GKfree__ -#define iset iset__ -#define idxset idxset__ -#define idxamax idxamax__ -#define idxamin idxamin__ -#define idxasum idxasum__ -#define snorm2 snorm2__ -#define sdot sdot__ -#define saxpy saxpy__ -#define ikeyvalsort_org ikeyvalsort_org__ -#define IncKeyValueCmp IncKeyValueCmp__ -#define dkeyvalsort dkeyvalsort__ -#define DecKeyValueCmp DecKeyValueCmp__ -#define BSearch BSearch__ -#define RandomPermute RandomPermute__ -#define FastRandomPermute FastRandomPermute__ -#define ispow2 ispow2__ -#define log2Int log2Int__ -#define BucketSortKeysDec BucketSortKeysDec__ -#define sset sset__ -#define iamax iamax__ -#define idxamax_strd idxamax_strd__ -#define idxamin_strd idxamin_strd__ -#define samax_strd samax_strd__ -#define sfamax sfamax__ -#define samin_strd samin_strd__ -#define idxavg idxavg__ -#define savg savg__ -#define samax samax__ -#define sfavg sfavg__ -#define samax2 samax2__ -#define samin samin__ -#define idxsum idxsum__ -#define idxsum_strd idxsum_strd__ -#define idxadd idxadd__ -#define ssum ssum__ -#define ssum_strd ssum_strd__ -#define sscale sscale__ -#define saneg saneg__ -#define BetterVBalance BetterVBalance__ -#define IsHBalanceBetterTT IsHBalanceBetterTT__ -#define IsHBalanceBetterFT IsHBalanceBetterFT__ -#define myvalkeycompare myvalkeycompare__ -#define imyvalkeycompare imyvalkeycompare__ -#define fsmalloc fsmalloc__ -#define saxpy2 saxpy2__ -#define GetThreeMax GetThreeMax__ - -/* qsort_special.c */ -#define iidxsort iidxsort__ -#define iintsort iintsort__ -#define ikeysort ikeysort__ -#define ikeyvalsort ikeyvalsort__ - -/* grsetup.c */ -#define Moc_SetUpGraph Moc_SetUpGraph__ -#define SetUpCtrl SetUpCtrl__ -#define ChangeNumbering ChangeNumbering__ -#define ChangeNumberingMesh ChangeNumberingMesh__ -#define GraphRandomPermute GraphRandomPermute__ -#define ComputeMoveStatistics ComputeMoveStatistics__ - -/* timer.c */ -#define InitTimers InitTimers__ -#define PrintTimingInfo PrintTimingInfo__ -#define PrintTimer PrintTimer__ - -/* setup.c */ -#define SetUp SetUp__ -#define Home_PE Home_PE__ - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/rmetis.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/rmetis.c deleted file mode 100644 index 3755209..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/rmetis.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * rmetis.c - * - * This is the entry point of the partitioning refinement routine - * - * Started 10/19/96 - * George - * - * $Id: rmetis.c,v 1.5 2003/07/25 04:01:05 karypis Exp $ - * - */ - -#include - - - -/*********************************************************************************** -* This function is the entry point of the parallel multilevel local diffusion -* algorithm. It uses parallel undirected diffusion followed by adaptive k-way -* refinement. This function utilizes local coarsening. -************************************************************************************/ -void ParMETIS_V3_RefineKway(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, - idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *ncon, - int *nparts, float *tpwgts, float *ubvec, int *options, int *edgecut, - idxtype *part, MPI_Comm *comm) -{ - int h, i; - int npes, mype; - CtrlType ctrl; - WorkSpaceType wspace; - GraphType *graph; - int tewgt, tvsize, nmoved, maxin, maxout; - float gtewgt, gtvsize, avg, maximb; - int ps_relation, seed, dbglvl = 0; - int iwgtflag, inumflag, incon, inparts, ioptions[10]; - float *itpwgts, iubvec[MAXNCON]; - - MPI_Comm_size(*comm, &npes); - MPI_Comm_rank(*comm, &mype); - - /********************************/ - /* Try and take care bad inputs */ - /********************************/ - if (options != NULL && options[0] == 1) - dbglvl = options[PMV3_OPTION_DBGLVL]; - CheckInputs(REFINE_PARTITION, npes, dbglvl, wgtflag, &iwgtflag, numflag, &inumflag, - ncon, &incon, nparts, &inparts, tpwgts, &itpwgts, ubvec, iubvec, - NULL, NULL, options, ioptions, part, comm); - - /* ADD: take care of disconnected graph */ - /* ADD: take care of highly unbalanced vtxdist */ - /*********************************/ - /* Take care the nparts = 1 case */ - /*********************************/ - if (inparts <= 1) { - idxset(vtxdist[mype+1]-vtxdist[mype], 0, part); - *edgecut = 0; - return; - } - - /**************************/ - /* Set up data structures */ - /**************************/ - if (inumflag == 1) - ChangeNumbering(vtxdist, xadj, adjncy, part, npes, mype, 1); - - /*****************************/ - /* Set up control structures */ - /*****************************/ - if (ioptions[0] == 1) { - dbglvl = ioptions[PMV3_OPTION_DBGLVL]; - seed = ioptions[PMV3_OPTION_SEED]; - ps_relation = (npes == inparts) ? ioptions[PMV3_OPTION_PSR] : DISCOUPLED; - } - else { - dbglvl = GLOBAL_DBGLVL; - seed = GLOBAL_SEED; - ps_relation = (npes == inparts) ? COUPLED : DISCOUPLED; - } - - SetUpCtrl(&ctrl, inparts, dbglvl, *comm); - ctrl.CoarsenTo = amin(vtxdist[npes]+1, 50*incon*amax(npes, inparts)); - ctrl.ipc_factor = 1000.0; - ctrl.redist_factor = 1.0; - ctrl.redist_base = 1.0; - ctrl.seed = (seed == 0) ? mype : seed*mype; - ctrl.sync = GlobalSEMax(&ctrl, seed); - ctrl.partType = REFINE_PARTITION; - ctrl.ps_relation = ps_relation; - ctrl.tpwgts = itpwgts; - - graph = Moc_SetUpGraph(&ctrl, incon, vtxdist, xadj, vwgt, adjncy, adjwgt, &iwgtflag); - graph->vsize = idxsmalloc(graph->nvtxs, 1, "vsize"); - - graph->home = idxmalloc(graph->nvtxs, "home"); - if (ctrl.ps_relation == COUPLED) - idxset(graph->nvtxs, mype, graph->home); - else - idxcopy(graph->nvtxs, part, graph->home); - - tewgt = idxsum(graph->nedges, graph->adjwgt); - tvsize = idxsum(graph->nvtxs, graph->vsize); - gtewgt = (float) GlobalSESum(&ctrl, tewgt) + 1.0/graph->gnvtxs; - gtvsize = (float) GlobalSESum(&ctrl, tvsize) + 1.0/graph->gnvtxs; - ctrl.edge_size_ratio = gtewgt/gtvsize; - scopy(incon, iubvec, ctrl.ubvec); - - PreAllocateMemory(&ctrl, graph, &wspace); - - /***********************/ - /* Partition and Remap */ - /***********************/ - IFSET(ctrl.dbglvl, DBG_TIME, InitTimers(&ctrl)); - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.TotalTmr)); - - Adaptive_Partition(&ctrl, graph, &wspace); - ParallelReMapGraph(&ctrl, graph, &wspace); - - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.TotalTmr)); - - idxcopy(graph->nvtxs, graph->where, part); - if (edgecut != NULL) - *edgecut = graph->mincut; - - /***********************/ - /* Take care of output */ - /***********************/ - IFSET(ctrl.dbglvl, DBG_TIME, PrintTimingInfo(&ctrl)); - IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm)); - - if (ctrl.dbglvl&DBG_INFO) { - Mc_ComputeMoveStatistics(&ctrl, graph, &nmoved, &maxin, &maxout); - rprintf(&ctrl, "Final %3d-way Cut: %6d \tBalance: ", inparts, graph->mincut); - avg = 0.0; - for (h=0; hgnpwgts[i*incon+h]/itpwgts[i*incon+h]); - avg += maximb; - rprintf(&ctrl, "%.3f ", maximb); - } - rprintf(&ctrl, "\nNMoved: %d %d %d %d\n", nmoved, maxin, maxout, maxin+maxout); - } - - /*************************************/ - /* Free memory, renumber, and return */ - /*************************************/ - GKfree((void **)&graph->lnpwgts, (void **)&graph->gnpwgts, (void **)&graph->nvwgt, (void **)(&graph->home), (void **)(&graph->vsize), LTERM); - - GKfree((void **)&itpwgts, LTERM); - FreeInitialGraphAndRemap(graph, iwgtflag); - FreeWSpace(&wspace); - FreeCtrl(&ctrl); - - if (inumflag == 1) - ChangeNumbering(vtxdist, xadj, adjncy, part, npes, mype, 0); - - return; -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/selectq.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/selectq.c deleted file mode 100644 index 5ec9109..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/selectq.c +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * selectq.c - * - * This file contains the driving routines for multilevel k-way refinement - * - * Started 7/28/97 - * George - * - * $Id: selectq.c,v 1.2 2003/07/21 17:18:53 karypis Exp $ - */ - -#include - -/************************************************************************* -* This stuff is hardcoded for up to four constraints -**************************************************************************/ -void Moc_DynamicSelectQueue(int nqueues, int ncon, int subdomain1, int subdomain2, - idxtype *currentq, float *flows, int *from, int *qnum, int minval, float avgvwgt, - float maxdiff) -{ - int i, j; - int hash, index = -1, current; - int cand[MAXNCON], rank[MAXNCON], dont_cares[MAXNCON]; - int nperms, perm[24][5]; - float sign = 0.0; - KVType array[MAXNCON]; -int mype; -MPI_Comm_rank(MPI_COMM_WORLD, &mype); - - *qnum = -1; - - if (*from == -1) { - for (i=0; iavgvwgt*MOC_GD_GRANULARITY_FACTOR) { - *from = subdomain1; - sign = 1.0; - index = 0; - } - - if (flows[array[ncon-1].key]<-1.0*avgvwgt*MOC_GD_GRANULARITY_FACTOR) { - *from = subdomain2; - sign = -1.0; - index = nqueues; - } - - if (*from == -1) { - return; - } - } - else { - ASSERTS(*from == subdomain1 || *from == subdomain2); - - if (*from == subdomain1) { - sign = 1.0; - index = 0; - } - else { - sign = -1.0; - index = nqueues; - } - } - - for (i=0; i 0) { - *qnum = hash; - return; - } - } - - return; -} - - -/************************************************************************* -* This function sorts the nvwgts of a vertex and returns a hashed value -**************************************************************************/ -int Moc_HashVwgts(int ncon, float *nvwgt) -{ - int i; - int multiplier, retval; - int rank[MAXNCON]; - KVType array[MAXNCON]; - - - for (i=0; i - - -/************************************************************************* -* This function performs k-way refinement -**************************************************************************/ -void Moc_SerialKWayAdaptRefine(GraphType *graph, int nparts, idxtype *home, - float *orgubvec, int npasses) -{ - int i, ii, iii, j, k; - int nvtxs, ncon, pass, nmoves, myndegrees; - int from, me, myhome, to, oldcut, gain, tmp; - idxtype *xadj, *adjncy, *adjwgt; - idxtype *where; - EdgeType *mydegrees; - RInfoType *rinfo, *myrinfo; - float *npwgts, *nvwgt, *minwgt, *maxwgt, ubvec[MAXNCON]; - int gain_is_greater, gain_is_same, fit_in_to, fit_in_from, going_home; - int zero_gain, better_balance_ft, better_balance_tt; - KeyValueType *cand; -int mype; -MPI_Comm_rank(MPI_COMM_WORLD, &mype); - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - xadj = graph->xadj; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - rinfo = graph->rinfo; - npwgts = graph->gnpwgts; - - /* Setup the weight intervals of the various subdomains */ - cand = (KeyValueType *)GKmalloc(nvtxs*sizeof(KeyValueType), "cand"); - minwgt = fmalloc(nparts*ncon, "minwgt"); - maxwgt = fmalloc(nparts*ncon, "maxwgt"); - - ComputeHKWayLoadImbalance(ncon, nparts, npwgts, ubvec); - for (i=0; imincut; - - for (i=0; ied >= myrinfo->id) { - from = where[i]; - myhome = home[i]; - nvwgt = graph->nvwgt+i*ncon; - - if (myrinfo->id > 0 && - AreAllHVwgtsBelow(ncon, 1.0, npwgts+from*ncon, -1.0, nvwgt, minwgt+from*ncon)) - continue; - - mydegrees = myrinfo->degrees; - myndegrees = myrinfo->ndegrees; - - for (k=0; kid; - if (gain >= 0 && - (AreAllHVwgtsBelow(ncon, 1.0, npwgts+to*ncon, 1.0, nvwgt, maxwgt+to*ncon) || - IsHBalanceBetterFT(ncon,npwgts+from*ncon,npwgts+to*ncon,nvwgt,ubvec))) { - break; - } - } - - /* break out if you did not find a candidate */ - if (k == myndegrees) - continue; - - for (j=k+1; j mydegrees[k].ewgt); - fit_in_to = AreAllHVwgtsBelow(ncon,1.0,npwgts+to*ncon,1.0,nvwgt,maxwgt+to*ncon); - better_balance_ft = IsHBalanceBetterFT(ncon,npwgts+from*ncon, - npwgts+to*ncon,nvwgt,ubvec); - better_balance_tt = IsHBalanceBetterTT(ncon,npwgts+mydegrees[k].edge*ncon, - npwgts+to*ncon,nvwgt,ubvec); - - if ( - (gain_is_greater && - (fit_in_to || - better_balance_ft) - ) - || - (gain_is_same && - ( - (fit_in_to && - going_home) - || - better_balance_tt - ) - ) - ) { - k = j; - } - } - - to = mydegrees[k].edge; - going_home = (myhome == to); - zero_gain = (mydegrees[k].ewgt == myrinfo->id); - - fit_in_from = AreAllHVwgtsBelow(ncon,1.0,npwgts+from*ncon,0.0,npwgts+from*ncon, - maxwgt+from*ncon); - better_balance_ft = IsHBalanceBetterFT(ncon,npwgts+from*ncon, - npwgts+to*ncon,nvwgt,ubvec); - - if (zero_gain && - !going_home && - !better_balance_ft && - fit_in_from) - continue; - - /*===================================================================== - * If we got here, we can now move the vertex from 'from' to 'to' - *======================================================================*/ - graph->mincut -= mydegrees[k].ewgt-myrinfo->id; - - /* Update where, weight, and ID/ED information of the vertex you moved */ - saxpy2(ncon, 1.0, nvwgt, 1, npwgts+to*ncon, 1); - saxpy2(ncon, -1.0, nvwgt, 1, npwgts+from*ncon, 1); - where[i] = to; - myrinfo->ed += myrinfo->id-mydegrees[k].ewgt; - SWAP(myrinfo->id, mydegrees[k].ewgt, tmp); - - if (mydegrees[k].ewgt == 0) { - myrinfo->ndegrees--; - mydegrees[k].edge = mydegrees[myrinfo->ndegrees].edge; - mydegrees[k].ewgt = mydegrees[myrinfo->ndegrees].ewgt; - } - else - mydegrees[k].edge = from; - - /* Update the degrees of adjacent vertices */ - for (j=xadj[i]; jdegrees; - - if (me == from) { - INC_DEC(myrinfo->ed, myrinfo->id, adjwgt[j]); - } - else { - if (me == to) { - INC_DEC(myrinfo->id, myrinfo->ed, adjwgt[j]); - } - } - - /* Remove contribution of the ed from 'from' */ - if (me != from) { - for (k=0; kndegrees; k++) { - if (mydegrees[k].edge == from) { - if (mydegrees[k].ewgt == adjwgt[j]) { - myrinfo->ndegrees--; - mydegrees[k].edge = mydegrees[myrinfo->ndegrees].edge; - mydegrees[k].ewgt = mydegrees[myrinfo->ndegrees].ewgt; - } - else - mydegrees[k].ewgt -= adjwgt[j]; - break; - } - } - } - - /* Add contribution of the ed to 'to' */ - if (me != to) { - for (k=0; kndegrees; k++) { - if (mydegrees[k].edge == to) { - mydegrees[k].ewgt += adjwgt[j]; - break; - } - } - if (k == myrinfo->ndegrees) { - mydegrees[myrinfo->ndegrees].edge = to; - mydegrees[myrinfo->ndegrees++].ewgt = adjwgt[j]; - } - } - - } - nmoves++; - } - } - - if (graph->mincut == oldcut) - break; - } - - GKfree((void **)&minwgt, (void **)&maxwgt, (void **)&cand, LTERM); - - return; -} - - -/************************************************************************* -* This function computes the initial id/ed -**************************************************************************/ -void Moc_ComputeSerialPartitionParams(GraphType *graph, int nparts, - EdgeType *degrees) -{ - int i, j, k; - int nvtxs, nedges, ncon, mincut, me, other; - idxtype *xadj, *adjncy, *adjwgt, *where; - RInfoType *rinfo, *myrinfo; - EdgeType *mydegrees; - float *nvwgt, *npwgts; -int mype; -MPI_Comm_rank(MPI_COMM_WORLD, &mype); - - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - xadj = graph->xadj; - nvwgt = graph->nvwgt; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - rinfo = graph->rinfo; - - npwgts = sset(ncon*nparts, 0.0, graph->gnpwgts); - - /*------------------------------------------------------------ - / Compute now the id/ed degrees - /------------------------------------------------------------*/ - nedges = mincut = 0; - for (i=0; iid = myrinfo->ed = myrinfo->ndegrees = 0; - myrinfo->degrees = degrees + nedges; - nedges += xadj[i+1]-xadj[i]; - - for (j=xadj[i]; jid += adjwgt[j]; - } - else { - myrinfo->ed += adjwgt[j]; - } - } - - mincut += myrinfo->ed; - - /* Time to compute the particular external degrees */ - if (myrinfo->ed > 0) { - mydegrees = myrinfo->degrees; - - for (j=xadj[i]; jndegrees; k++) { - if (mydegrees[k].edge == other) { - mydegrees[k].ewgt += adjwgt[j]; - break; - } - } - if (k == myrinfo->ndegrees) { - mydegrees[myrinfo->ndegrees].edge = other; - mydegrees[myrinfo->ndegrees++].ewgt = adjwgt[j]; - } - } - } - } - } - - graph->mincut = mincut/2; - - return; -} - - -/************************************************************************* -* This function checks if the vertex weights of two vertices are below -* a given set of values -**************************************************************************/ -int AreAllHVwgtsBelow(int ncon, float alpha, float *vwgt1, float beta, float *vwgt2, float *limit) -{ - int i; - - for (i=0; i limit[i]) - return 0; - - return 1; -} - - -/************************************************************************* -* This function computes the load imbalance over all the constrains -* For now assume that we just want balanced partitionings -**************************************************************************/ -void ComputeHKWayLoadImbalance(int ncon, int nparts, float *npwgts, float *lbvec) -{ - int i, j; - float max; - - for (i=0; i max) - max = npwgts[j*ncon+i]; - } - - lbvec[i] = max*nparts; - } -} - - -/************************************************************** -* This subroutine remaps a partitioning on a single processor -**************************************************************/ -void SerialRemap(GraphType *graph, int nparts, idxtype *base, idxtype *scratch, - idxtype *remap, float *tpwgts) -{ - int i, ii, j, k; - int nvtxs, nmapped, max_mult; - int from, to, current_from, smallcount, bigcount; - KeyValueType *flowto, *bestflow; - KeyKeyValueType *sortvtx; - idxtype *vsize, *htable, *map, *rowmap; - - nvtxs = graph->nvtxs; - vsize = graph->vsize; - max_mult = amin(MAX_NPARTS_MULTIPLIER, nparts); - - sortvtx = (KeyKeyValueType *)GKmalloc(nvtxs*sizeof(KeyKeyValueType), "sortvtx"); - flowto = (KeyValueType *)GKmalloc((nparts*max_mult+nparts)*sizeof(KeyValueType), "flowto"); - bestflow = flowto+nparts; - map = htable = idxsmalloc(nparts*2, -1, "htable"); - rowmap = map+nparts; - - for (i=0; i current_from) { - /* reset the hash table */ - for (j=0; jncon, j, k)) { - map[j] = k; - rowmap[k] = j; - nmapped++; - } - - if (nmapped == nparts) - break; - } - - - /* remap the rest */ - /* it may help try remapping to the same label first */ - if (nmapped < nparts) { - for (j=0; jncon, i, j)) { - map[j] = i; - rowmap[i] = j; - nmapped++; - break; - } - } - } - } - } - - /* check to see if remapping fails (due to dis-similar tpwgts) */ - /* if remapping fails, revert to original mapping */ - if (nmapped < nparts) - for (i=0; ikey1 > second->key1) - return 1; - - if (first->key1 < second->key1) - return -1; - - if (first->key2 < second->key2) - return 1; - - if (first->key2 > second->key2) - return -1; - - return 0; -} - - -/************************************************************************* -* This function performs an edge-based FM refinement -**************************************************************************/ -void Moc_Serial_FM_2WayRefine(GraphType *graph, float *tpwgts, int npasses) -{ - int i, ii, j, k; - int kwgt, nvtxs, ncon, nbnd, nswaps, from, to, pass, limit, tmp, cnum; - idxtype *xadj, *adjncy, *adjwgt, *where, *id, *ed, *bndptr, *bndind; - idxtype *moved, *swaps, *qnum; - float *nvwgt, *npwgts, mindiff[MAXNCON], origbal, minbal, newbal; - FPQueueType parts[MAXNCON][2]; - int higain, oldgain, mincut, initcut, newcut, mincutorder; - float rtpwgts[MAXNCON*2]; - KeyValueType *cand; -int mype; -MPI_Comm_rank(MPI_COMM_WORLD, &mype); - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - xadj = graph->xadj; - nvwgt = graph->nvwgt; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - id = graph->sendind; - ed = graph->recvind; - npwgts = graph->gnpwgts; - bndptr = graph->sendptr; - bndind = graph->recvptr; - - moved = idxmalloc(nvtxs, "moved"); - swaps = idxmalloc(nvtxs, "swaps"); - qnum = idxmalloc(nvtxs, "qnum"); - cand = (KeyValueType *)GKmalloc(nvtxs*sizeof(KeyValueType), "cand"); - - limit = amin(amax(0.01*nvtxs, 25), 150); - - /* Initialize the queues */ - for (i=0; imincut; - for (i=0; ignvtxs; - - for (i=0; i limit) { /* We hit the limit, undo last move */ - newcut += (ed[higain]-id[higain]); - saxpy2(ncon, 1.0, nvwgt+higain*ncon, 1, npwgts+from*ncon, 1); - saxpy2(ncon, -1.0, nvwgt+higain*ncon, 1, npwgts+to*ncon, 1); - break; - } - - where[higain] = to; - moved[higain] = nswaps; - swaps[nswaps] = higain; - - /************************************************************** - * Update the id[i]/ed[i] values of the affected nodes - ***************************************************************/ - SWAP(id[higain], ed[higain], tmp); - if (ed[higain] == 0 && xadj[higain] < xadj[higain+1]) - BNDDelete(nbnd, bndind, bndptr, higain); - - for (j=xadj[higain]; j 0) { /* It will now become a boundary vertex */ - BNDInsert(nbnd, bndind, bndptr, k); - if (moved[k] == -1) - FPQueueInsert(&parts[qnum[k]][where[k]], k, (float)(ed[k]-id[k])); - } - } - } - } - - /**************************************************************** - * Roll back computations - *****************************************************************/ - for (i=0; imincutorder; nswaps--) { - higain = swaps[nswaps]; - - to = where[higain] = (where[higain]+1)%2; - SWAP(id[higain], ed[higain], tmp); - if (ed[higain] == 0 && bndptr[higain] != -1 && xadj[higain] < xadj[higain+1]) - BNDDelete(nbnd, bndind, bndptr, higain); - else if (ed[higain] > 0 && bndptr[higain] == -1) - BNDInsert(nbnd, bndind, bndptr, higain); - - saxpy2(ncon, 1.0, nvwgt+higain*ncon, 1, npwgts+to*ncon, 1); - saxpy2(ncon, -1.0, nvwgt+higain*ncon, 1, npwgts+((to+1)%2)*ncon, 1); - for (j=xadj[higain]; j 0) - BNDInsert(nbnd, bndind, bndptr, k); - } - } - - graph->mincut = mincut; - graph->gnvtxs = nbnd; - - if (mincutorder == -1 || mincut == initcut) - break; - } - - for (i=0; i= maxdiff) { - maxdiff = npwgts[part*ncon+i]-tpwgts[part*ncon+i]; - *from = part; - *cnum = i; - } - } - } - - if (*from != -1 && FPQueueGetQSize(&queues[*cnum][*from]) == 0) { - /* The desired queue is empty, select a node from that side anyway */ - for (i=0; i 0) { - max = npwgts[(*from)*ncon + i]; - *cnum = i; - break; - } - } - - for (i++; i max && FPQueueGetQSize(&queues[i][*from]) > 0) { - max = npwgts[(*from)*ncon + i]; - *cnum = i; - } - } - } - - - /* Check to see if you can focus on the cut */ - if (maxdiff <= 0.0 || *from == -1) { - maxgain = -100000.0; - - for (part=0; part<2; part++) { - for (i=0; i 0 && - FPQueueSeeMaxGain(&queues[i][part]) > maxgain) { - maxgain = FPQueueSeeMaxGain(&queues[i][part]); - *from = part; - *cnum = i; - } - } - } - } - - return; -} - -/************************************************************************* -* This function checks if the balance achieved is better than the diff -* For now, it uses a 2-norm measure -**************************************************************************/ -int Serial_BetterBalance(int ncon, float *npwgts, float *tpwgts, float *diff) -{ - int i; - float ndiff[MAXNCON]; - - for (i=0; invtxs; - ncon = graph->ncon; - xadj = graph->xadj; - nvwgt = graph->nvwgt; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - id = graph->sendind; - ed = graph->recvind; - npwgts = graph->gnpwgts; - bndptr = graph->sendptr; - bndind = graph->recvptr; - - moved = idxmalloc(nvtxs, "moved"); - swaps = idxmalloc(nvtxs, "swaps"); - qnum = idxmalloc(nvtxs, "qnum"); - cand = (KeyValueType *)GKmalloc(nvtxs*sizeof(KeyValueType), "cand"); - - - limit = amin(amax(0.01*nvtxs, 15), 100); - - /* Initialize the queues */ - for (i=0; i qsizes[j][from] && - nvwgt[i*ncon+qnum[i]] < 1.3*nvwgt[i*ncon+j]) { - qsizes[qnum[i]][from]--; - qsizes[j][from]++; - qnum[i] = j; - } - } - } - } - } - - - for (i=0; imincut; - mincutorder = -1; - - idxset(nvtxs, -1, moved); - - /* Insert all nodes in the priority queues */ - nbnd = graph->gnvtxs; - for (i=0; i limit) { /* We hit the limit, undo last move */ - newcut += (ed[higain]-id[higain]); - saxpy2(ncon, 1.0, nvwgt+higain*ncon, 1, npwgts+from*ncon, 1); - saxpy2(ncon, -1.0, nvwgt+higain*ncon, 1, npwgts+to*ncon, 1); - break; - } - - where[higain] = to; - moved[higain] = nswaps; - swaps[nswaps] = higain; - - /************************************************************** - * Update the id[i]/ed[i] values of the affected nodes - ***************************************************************/ - SWAP(id[higain], ed[higain], tmp); - if (ed[higain] == 0 && bndptr[higain] != -1 && xadj[higain] < xadj[higain+1]) - BNDDelete(nbnd, bndind, bndptr, higain); - if (ed[higain] > 0 && bndptr[higain] == -1) - BNDInsert(nbnd, bndind, bndptr, higain); - - for (j=xadj[higain]; j 0 && bndptr[k] == -1) - BNDInsert(nbnd, bndind, bndptr, k); - } - } - - - /**************************************************************** - * Roll back computations - *****************************************************************/ - for (nswaps--; nswaps>mincutorder; nswaps--) { - higain = swaps[nswaps]; - - to = where[higain] = (where[higain]+1)%2; - SWAP(id[higain], ed[higain], tmp); - if (ed[higain] == 0 && bndptr[higain] != -1 && xadj[higain] < xadj[higain+1]) - BNDDelete(nbnd, bndind, bndptr, higain); - else if (ed[higain] > 0 && bndptr[higain] == -1) - BNDInsert(nbnd, bndind, bndptr, higain); - - saxpy2(ncon, 1.0, nvwgt+higain*ncon, 1, npwgts+to*ncon, 1); - saxpy2(ncon, -1.0, nvwgt+higain*ncon, 1, npwgts+((to+1)%2)*ncon, 1); - for (j=xadj[higain]; j 0) - BNDInsert(nbnd, bndind, bndptr, k); - } - } - - graph->mincut = mincut; - graph->gnvtxs = nbnd; - - - for (i=0; invtxs; - ncon = graph->ncon; - xadj = graph->xadj; - adjncy = graph->adjncy; - nvwgt = graph->nvwgt; - adjwgt = graph->adjwgt; - where = graph->where; - id = graph->sendind; - ed = graph->recvind; - npwgts = graph->gnpwgts; - bndptr = graph->sendptr; - bndind = graph->recvptr; - - qnum = idxmalloc(nvtxs, "qnum"); - cand = (KeyValueType *)GKmalloc(nvtxs*sizeof(KeyValueType), "cand"); - - /* This is called for initial partitioning so we know from where to pick nodes */ - from = 1; - to = (from+1)%2; - - for (i=0; i 0) - FPQueueInsert(&parts[qnum[i]][0], i, (float)(ed[i]-id[i])); - else - FPQueueInsert(&parts[qnum[i]][1], i, (float)(ed[i]-id[i])); - } - } - - mincut = graph->mincut; - nbnd = graph->gnvtxs; - for (nswaps=0; nswaps 0 && bndptr[higain] == -1) - BNDInsert(nbnd, bndind, bndptr, higain); - - for (j=xadj[higain]; j 0 && bndptr[k] == -1) { /* It moves in boundary */ - FPQueueDelete(&parts[qnum[k]][1], k); - FPQueueInsert(&parts[qnum[k]][0], k, (float)(ed[k]-id[k])); - } - else { /* It must be in the boundary already */ - FPQueueUpdate(&parts[qnum[k]][0], k, (float)(oldgain), (float)(ed[k]-id[k])); - } - } - - /* Update its boundary information */ - if (ed[k] == 0 && bndptr[k] != -1) - BNDDelete(nbnd, bndind, bndptr, k); - else if (ed[k] > 0 && bndptr[k] == -1) - BNDInsert(nbnd, bndind, bndptr, k); - } - } - - graph->mincut = mincut; - graph->gnvtxs = nbnd; - - for (i=0; i= max && - FPQueueGetQSize(&queues[i][0]) + FPQueueGetQSize(&queues[i][1]) > 0) { - max = npwgts[from*ncon+i]-tpwgts[i]; - cnum = i; - } - } - - return cnum; -} - - -/************************************************************************* -* This function computes the initial id/ed -**************************************************************************/ -void Moc_Serial_Compute2WayPartitionParams(GraphType *graph) -{ - int i, j, me, nvtxs, ncon, nbnd, mincut; - idxtype *xadj, *adjncy, *adjwgt; - float *nvwgt, *npwgts; - idxtype *id, *ed, *where; - idxtype *bndptr, *bndind; - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - xadj = graph->xadj; - nvwgt = graph->nvwgt; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - - npwgts = sset(2*ncon, 0.0, graph->gnpwgts); - id = idxset(nvtxs, 0, graph->sendind); - ed = idxset(nvtxs, 0, graph->recvind); - bndptr = idxset(nvtxs, -1, graph->sendptr); - bndind = graph->recvptr; - - /*------------------------------------------------------------ - / Compute now the id/ed degrees - /------------------------------------------------------------*/ - nbnd = mincut = 0; - for (i=0; i 0 || xadj[i] == xadj[i+1]) { - mincut += ed[i]; - bndptr[i] = nbnd; - bndind[nbnd++] = i; - } - } - - graph->mincut = mincut/2; - graph->gnvtxs = nbnd; - -} - -/************************************************************************* -* This function checks if the vertex weights of two vertices are below -* a given set of values -**************************************************************************/ -int Serial_AreAnyVwgtsBelow(int ncon, float alpha, float *vwgt1, float beta, float *vwgt2, float *limit) -{ - int i; - - for (i=0; invtxs; i++) { - for (j=graph->xadj[i]; jxadj[i+1]; j++) - if (graph->where[i] != graph->where[graph->adjncy[j]]) - cut += graph->adjwgt[j]; - } - graph->mincut = cut/2; - - return graph->mincut; -} - -/************************************************************************* -* This function computes the TotalV of a serial graph. -**************************************************************************/ -int ComputeSerialTotalV(GraphType *graph, idxtype *home) -{ - int i; - int totalv = 0; - - for (i=0; invtxs; i++) - if (graph->where[i] != home[i]) - totalv += (graph->vsize == NULL) ? graph->vwgt[i] : graph->vsize[i]; - - return totalv; -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/setup.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/setup.c deleted file mode 100644 index 682a31d..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/setup.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * setup.c - * - * This file contains functions that setup the various communication - * data structures for parallel KWAY - * - * Started 2/21/96 - * George - * - * $Id: setup.c,v 1.3 2003/07/31 16:23:30 karypis Exp $ - * - */ - - -#include - -#define DEBUG_SETUPINFO_ - - -/************************************************************************* -* This function tests the repeated shmem_put -**************************************************************************/ -void SetUp(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, j, k, islocal, penum, gnvtxs, nvtxs, nlocal, firstvtx, lastvtx, nsend, nrecv, nnbrs, nadj; - int npes=ctrl->npes, mype=ctrl->mype; - idxtype *vtxdist, *xadj, *adjncy; - idxtype *peind, *recvptr, *recvind, *sendptr, *sendind; - idxtype *receive, *pemap, *imap, *lperm; - idxtype *pexadj, *peadjncy, *peadjloc, *startsind; - KeyValueType *recvrequests, *sendrequests, *adjpairs; - - IFSET(ctrl->dbglvl, DBG_TIME, MPI_Barrier(ctrl->comm)); - IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->SetupTmr)); - - gnvtxs = graph->gnvtxs; - nvtxs = graph->nvtxs; - vtxdist = graph->vtxdist; - xadj = graph->xadj; - adjncy = graph->adjncy; - - firstvtx = vtxdist[mype]; - lastvtx = vtxdist[mype+1]; - - pemap = wspace->pv1; - idxset(npes, -1, pemap); - - lperm = graph->lperm = idxmalloc(nvtxs, "SetUp: graph->lperm"); - for (i=0; iindices; /* Use the large global received array for now */ - adjpairs = wspace->pairs; - - for (nlocal = nadj = i = 0; i= firstvtx && k < lastvtx) { - adjncy[j] = k-firstvtx; - continue; /* local vertex */ - } - adjpairs[nadj].key = k; - adjpairs[nadj++].val = j; - islocal = 0; - } - if (islocal) { - lperm[i] = lperm[nlocal]; - lperm[nlocal++] = i; - } - } - - /* Take care the received part now */ - ikeysort(nadj, adjpairs); - adjpairs[nadj].key = gnvtxs+1; /* Boundary condition */ - for (nrecv=i=0; ipeind = idxmalloc(npes, "SetUp: peind"); - recvptr = graph->recvptr = idxmalloc(npes+1, "SetUp: recvptr"); - recvind = graph->recvind = idxmalloc(nrecv, "SetUp: recvind"); - - /* Take care of the received portion */ - idxcopy(nrecv, receive, recvind); /* Copy the vertices to be received into recvind */ - - i = nnbrs = recvptr[0] = 0; - for (penum=0; penum= vtxdist[penum+1]) - break; - } - if (j > i) { - peind[nnbrs] = penum; - recvptr[++nnbrs] = j; - i = j; - } - } - - - /************************************************************* - * Determine what you need to send - *************************************************************/ - /* Tell the other processors what they need to send you */ - recvrequests = wspace->pepairs1; - sendrequests = wspace->pepairs2; - for (i=0; icomm); - - - sendptr = graph->sendptr = idxmalloc(npes+1, "SetUp: sendptr"); - startsind = wspace->pv2; - for (j=i=0; i 0) { - sendptr[j] = sendrequests[i].key; - startsind[j] = sendrequests[i].val; - j++; - } - } - ASSERT(ctrl, nnbrs == j); - MAKECSR(i, j, sendptr); - - nsend = sendptr[nnbrs]; - sendind = graph->sendind = idxmalloc(nsend, "SetUp: sendind"); - - - /* Issue the receives for sendind */ - for (i=0; icomm, ctrl->rreq+i); - } - - /* Issue the sends. My recvind[penum] becomes penum's sendind[mype] */ - for (i=0; icomm, ctrl->sreq+i); - } - - MPI_Waitall(nnbrs, ctrl->rreq, ctrl->statuses); - MPI_Waitall(nnbrs, ctrl->sreq, ctrl->statuses); - - - - /* Create the peadjncy data structure for sparse boundary exchanges */ - pexadj = graph->pexadj = idxsmalloc(nvtxs+1, 0, "SetUp: pexadj"); - peadjncy = graph->peadjncy = idxmalloc(nsend, "SetUp: peadjncy"); - peadjloc = graph->peadjloc = idxmalloc(nsend, "SetUp: peadjloc"); - - for (i=0; i= firstvtx && sendind[i] < lastvtx, (ctrl, "%d %d %d\n", sendind[i], firstvtx, lastvtx)); - pexadj[sendind[i]-firstvtx]++; - } - MAKECSR(i, nvtxs, pexadj); - - for (i=0; i0; i--) - pexadj[i] = pexadj[i-1]; - pexadj[0] = 0; - - - graph->nnbrs = nnbrs; - graph->nrecv = nrecv; - graph->nsend = nsend; - graph->nlocal = nlocal; - - - /* Create the inverse map from ladjncy to adjncy */ - imap = graph->imap = idxmalloc(nvtxs+nrecv, "SetUp: imap"); - for (i=0; inlarge is large enough for nrecv and nsend */ - if (wspace->nlarge < nrecv+nsend) { - free(wspace->indices); - free(wspace->pairs); - wspace->nlarge = nrecv+nsend; - wspace->indices = idxmalloc(wspace->nlarge, "SetUp: wspace->indices"); - wspace->pairs = (KeyValueType *)GKmalloc(sizeof(KeyValueType)*wspace->nlarge, "SetUp: wspace->pairs"); - } - - IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->SetupTmr)); - -#ifdef DEBUG_SETUPINFO - rprintf(ctrl, "[%5d %5d] \tl:[%5d %5d] \ts:[%5d, %5d] \tr:[%5d, %5d]\n", - GlobalSEMin(ctrl, nvtxs), GlobalSEMax(ctrl, nvtxs), - GlobalSEMin(ctrl, nlocal), GlobalSEMax(ctrl, nlocal), - GlobalSEMin(ctrl, nsend), GlobalSEMax(ctrl, nsend), - GlobalSEMin(ctrl, nrecv), GlobalSEMax(ctrl, nrecv)); - - PrintSetUpInfo(ctrl, graph); -#endif -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/stat.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/stat.c deleted file mode 100644 index 4a32bc8..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/stat.c +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * stat.c - * - * This file computes various statistics - * - * Started 7/25/97 - * George - * - * $Id: stat.c,v 1.3 2003/07/23 00:54:56 karypis Exp $ - * - */ - -#include - - - -/************************************************************************* -* This function computes the balance of the partitioning -**************************************************************************/ -void Moc_ComputeSerialBalance(CtrlType *ctrl, GraphType *graph, idxtype *where, float *ubvec) -{ - int i, j, nvtxs, ncon, nparts; - idxtype *pwgts, *tvwgts, *vwgt; - float *tpwgts, maximb; - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - vwgt = graph->vwgt; - nparts = ctrl->nparts; - tpwgts = ctrl->tpwgts; - - pwgts = idxsmalloc(nparts*ncon, 0, "pwgts"); - tvwgts = idxsmalloc(ncon, 0, "tvwgts"); - - for (i=0; invtxs; i++) { - for (j=0; jncon; - nvtxs = graph->nvtxs; - nvwgt = graph->nvwgt; - nparts = ctrl->nparts; - tpwgts = ctrl->tpwgts; - - lnpwgts = fmalloc(nparts*ncon, "CPB: lnpwgts"); - gnpwgts = fmalloc(nparts*ncon, "CPB: gnpwgts"); - sset(nparts*ncon, 0.0, lnpwgts); - sset(ncon, 1.0, lminvwgts); - - for (i=0; i 0.0 && lminvwgts[j] > nvwgt[i*ncon+j] ? nvwgt[i*ncon+j] : lminvwgts[j]); - } - } - - MPI_Allreduce((void *)(lnpwgts), (void *)(gnpwgts), nparts*ncon, MPI_FLOAT, MPI_SUM, ctrl->comm); - MPI_Allreduce((void *)(lminvwgts), (void *)(gminvwgts), ncon, MPI_FLOAT, 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("%.3f ", matrix[j]); - printf("\n"); - fflush(stdout); - } - MPI_Barrier(ctrl->comm); - } - - if (ctrl->mype == 0) { - printf("****************************\n"); - fflush(stdout); - } - MPI_Barrier(ctrl->comm); - - return; -} - - -/************************************************************************* -* This function computes stats for refinement -**************************************************************************/ -void Moc_ComputeRefineStats(CtrlType *ctrl, GraphType *graph, float *ubvec) -{ - int h, i, j, k; - int nvtxs, ncon; - idxtype *xadj, *adjncy, *adjwgt, *where; - float *nvwgt, *lnpwgts, *gnpwgts; - RInfoType *rinfo; - int mype = ctrl->mype, nparts = ctrl->nparts; - idxtype *gborder, *border, *gfrom, *from, *gto, *to, *connect, *gconnect; - idxtype gain[20] = {0}, ggain[20]; - int lnborders, gnborders; - int bestgain, pmoves, gpmoves, other; - float tpwgts[MAXNCON], badmaxpwgt[MAXNCON]; - int HIST_FACTOR = graph->level + 1; - - nvtxs = graph->nvtxs; - ncon = graph->ncon; - xadj = graph->xadj; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - lnpwgts = graph->lnpwgts; - gnpwgts = graph->gnpwgts; - rinfo = graph->rinfo; - - connect = idxsmalloc(nparts*nparts, 0, "CRS: connect"); - gconnect = idxmalloc(nparts*nparts, "CRS: gconnect"); - border = idxsmalloc(nparts, 0, "CRS: border"); - gborder = idxmalloc(nparts, "CRS: gborder"); - from = idxsmalloc(nparts, 0, "CRS: from"); - gfrom = idxmalloc(nparts, "CRS: gfrom"); - to = idxsmalloc(nparts, 0, "CRS: to"); - gto = idxmalloc(nparts, "CRS: gto"); - - for (h=0; hcomm); - if (mype == 0) { - printf("connectivity\n"); - for (i=0; i 0) { - lnborders++; - border[where[i]]++; - } - - MPI_Reduce((void *)border, (void *)gborder, nparts, IDX_DATATYPE, MPI_SUM, 0, ctrl->comm); - gnborders = GlobalSESum(ctrl, lnborders); - if (mype == 0) { - printf("number of borders: %d\n", gnborders); - for (i=0; invwgt+i*ncon; - - for (j=0; j badmaxpwgt[h]) - break; - - if (h == ncon) - break; - } - - if (j < rinfo[i].ndegrees) { - pmoves++; - from[where[i]]++; - to[other]++; - for (k=j+1; k badmaxpwgt[h]) - break; - - if (h == ncon) { - pmoves++; - from[where[i]]++; - to[other]++; - } - } - } - } - - gpmoves = GlobalSESum(ctrl, pmoves); - MPI_Reduce((void *)from, (void *)gfrom, nparts, IDX_DATATYPE, MPI_SUM, 0, ctrl->comm); - MPI_Reduce((void *)to, (void *)gto, nparts, IDX_DATATYPE, MPI_SUM, 0, ctrl->comm); - - if (mype == 0) { - printf("possible moves: %d\n", gpmoves); - printf("from "); - for (i=0; i 0) { - bestgain = rinfo[i].degrees[0].ewgt-rinfo[i].id; - for (j=0; j= 10) { - gain[19]++; - continue; - } - - if (bestgain / HIST_FACTOR < -10) { - gain[0]++; - continue; - } - - gain[(bestgain/HIST_FACTOR)+10]++; - } - } - - MPI_Reduce((void *)gain, (void *)ggain, 20, IDX_DATATYPE, MPI_SUM, 0, ctrl->comm); - if (mype == 0) { - printf("gain histogram (buckets of %d)\n", HIST_FACTOR); - for (i=0; i<20; i++) { - if (i == 10 || i == 11) - printf(" "); - printf("%d ", ggain[i]); - } - printf("\n\n"); - } - - - - - /***************************************/ - if (mype == 0) printf("******************************\n"); - if (mype == 0) printf("******************************\n"); - - GKfree((void **)&gconnect, (void **)&connect, (void **)&gborder, (void **)&border, (void **)&gfrom, (void **)&from, (void **)>o, (void **)&to, LTERM); - return; -} diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/stdheaders.h b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/stdheaders.h deleted file mode 100644 index e30f989..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/stdheaders.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * stdheaders.h - * - * This file includes all necessary header files - * - * Started 8/27/94 - * George - * - * $Id: stdheaders.h,v 1.4 2003/07/25 14:31:47 karypis Exp $ - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/struct.h b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/struct.h deleted file mode 100644 index 3016c5e..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/struct.h +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * struct.h - * - * This file contains data structures for ILU routines. - * - * Started 9/26/95 - * George - * - * $Id: struct.h,v 1.2 2003/07/21 17:50:22 karypis Exp $ - */ - -/* Indexes are as long as integers for now */ -#ifdef IDXTYPE_INT -#define IDX_DATATYPE MPI_INT -#define MAX_INT INT_MAX -#define MIN_INT INT_MIN -#else -#define IDX_DATATYPE MPI_SHORT -#define MAX_INT SHRT_MAX -#define MIN_INT SHRT_MIN -#endif - - -/************************************************************************* -* The following data structure stores key-value pair -**************************************************************************/ -struct KeyValueType { - idxtype key; - idxtype val; -}; - -typedef struct KeyValueType KeyValueType; - -/************************************************************************* -* The following data structure stores key-value pair -**************************************************************************/ -struct KVType { - int key; - float val; -}; - -typedef struct KVType KVType; - - -/************************************************************************* -* The following data structure stores key-value pair -**************************************************************************/ -struct FKeyValueType { - float key; - idxtype val; -}; - -typedef struct FKeyValueType FKeyValueType; - -/************************************************************************* -* The following data structure stores key-key-value triplets -**************************************************************************/ -struct KeyKeyValueType { - idxtype key1, key2; - idxtype val; -}; - -typedef struct KeyKeyValueType KeyKeyValueType; - -/************************************************************************* -* The following data structure is used to store the buckets for the -* refinment algorithms -**************************************************************************/ -struct PQueueType { - int nnodes; - int maxnnodes; - idxtype *perm, *iperm, *values; - /* iperm[i] stores where the ith entry is located - perm[i] stores the entry that is located in the ith position */ -}; - -typedef struct PQueueType PQueueType; - - -/************************************************************************* -* The following data structure is used to store the buckets for the -* refinment algorithms -**************************************************************************/ -struct FPQueueType { - int type; /* The type of the representation used */ - int nnodes; - int maxnodes; - - /* Heap version of the data structure */ - FKeyValueType *heap; - idxtype *locator; -}; - -typedef struct FPQueueType FPQueueType; - -/************************************************************************* -* The following data structure stores an edge -**************************************************************************/ -struct edgedef { - idxtype edge; - idxtype ewgt; -}; -typedef struct edgedef EdgeType; - - -/************************************************************************* -* This data structure holds various working space data -**************************************************************************/ -struct workspacedef { - idxtype *core; /* Where pairs, indices, and degrees are coming from */ - int maxcore; - - int nlarge; /* The size of 'Large' */ - - KeyValueType *pairs; /* Large pair array used during setup */ - idxtype *indices; /* Large array of indxtype used for various purposes */ - - /* Auxiliary parameters */ - idxtype *pv1, *pv2, *pv3, *pv4; /* Vectors of npes+1 size used in various places */ - KeyValueType *pepairs1, *pepairs2; - - EdgeType *degrees; -}; - -typedef struct workspacedef WorkSpaceType; - - -/************************************************************************* -* The following data structure holds information on degrees for k-way -* partition -**************************************************************************/ -struct rinfodef { - int id, ed; /* ID/ED of edges */ - int ndegrees; /* The number of different ext-degrees */ - EdgeType *degrees; /* List of edges */ -}; - -typedef struct rinfodef RInfoType; - - -/************************************************************************* -* The following data structure holds information on degrees for k-way -* partition -**************************************************************************/ -struct nrinfodef { - int edegrees[2]; -}; - -typedef struct nrinfodef NRInfoType; - - -/************************************************************************* -* The following data structure stores a sparse matrix in CSR format -* The diagonal entry is in the first position of each row. -**************************************************************************/ -struct matrixdef { - int nrows, nnzs; /* Number of rows and nonzeros in the matrix */ - idxtype *rowptr; - idxtype *colind; - float *values; - float *transfer; -}; - -typedef struct matrixdef MatrixType; - - -/************************************************************************* -* This data structure holds the input graph -**************************************************************************/ -struct graphdef { - int gnvtxs, nvtxs, nedges, ncon, nobj; - idxtype *xadj; /* Pointers to the locally stored vertices */ - idxtype *vwgt; /* Vertex weights */ - float *nvwgt; /* Vertex weights */ - idxtype *vsize; /* Vertex size */ - idxtype *adjncy; /* Array that stores the adjacency lists of nvtxs */ - idxtype *adjwgt; /* Array that stores the weights of the adjacency lists */ - idxtype *vtxdist; /* Distribution of vertices */ - - idxtype *match; - idxtype *cmap; - - idxtype *label; - - /* Communication/Setup parameters */ - int nnbrs, nrecv, nsend; /* The number of neighboring processors */ - idxtype *peind; /* Array of size nnbrs storing the neighboring PEs */ - idxtype *sendptr, *sendind; /* CSR format of the vertices that are sent */ - idxtype *recvptr, *recvind; /* CSR format of the vertices that are received */ - idxtype *imap; /* The inverse map of local to global indices */ - idxtype *pexadj, *peadjncy, - *peadjloc; /* CSR format of the PEs each vertex is adjancent to */ - - int nlocal; /* Number of interior vertices */ - idxtype *lperm; /* lperm[0:nlocal] points to interior vertices, the rest are interface */ - - /* Communication parameters for projecting the partition. - * These are computed during CreateCoarseGraph and used during projection - * Note that during projection, the meaning of received and sent is reversed! */ - idxtype *rlens, *slens; /* Arrays of size nnbrs of how many vertices you are sending and receiving */ - KeyValueType *rcand; - - - /* Partition parameters */ - idxtype *where, *home; - idxtype *lpwgts, *gpwgts; - float *lnpwgts, *gnpwgts; - RInfoType *rinfo; - - /* Node refinement information */ - NRInfoType *nrinfo; - int nsep; /* The number of vertices in the separator */ - idxtype *sepind; /* The indices of the vertices in the separator */ - - int lmincut, mincut; - - int level; - int match_type; - int edgewgt_type; - - struct graphdef *coarser, *finer; -}; - -typedef struct graphdef GraphType; - - -/************************************************************************* -* The following data type implements a timer -**************************************************************************/ -typedef double timer; - - -/************************************************************************* -* The following structure stores information used by parallel kmetis -**************************************************************************/ -struct controldef { - int mype, npes; /* Info about the parallel system */ - int CoarsenTo; /* The # of vertices in the coarsest graph */ - int dbglvl; /* Controls the debuging output of the program */ - int nparts; /* The number of partitions */ - int foldf; /* What is the folding factor */ - int ipart; /* The type of initial partitioning */ - int xyztype; /* The type of coordinate indexing */ - int seed; /* Random number seed */ - int sync; /* Random number seed */ - float *tpwgts; /* Target subdomain weights */ - int tvwgts[MAXNCON]; - float ubvec[MAXNCON]; - int partType; - int ps_relation; - - float redist_factor, redist_base, ipc_factor; - float edge_size_ratio; - MatrixType *matrix; - - MPI_Comm gcomm; - MPI_Comm comm; /* MPI Communicator */ - MPI_Request sreq[MAX_PES], - rreq[MAX_PES]; /* MPI send and receive requests */ - MPI_Status statuses[MAX_PES]; - MPI_Status status; - - /* Various Timers */ - timer TotalTmr, InitPartTmr, MatchTmr, ContractTmr, CoarsenTmr, RefTmr, - SetupTmr, ColorTmr, ProjectTmr, KWayInitTmr, KWayTmr, MoveTmr, - RemapTmr, AuxTmr1, AuxTmr2, AuxTmr3, AuxTmr4, AuxTmr5, AuxTmr6; -}; - -typedef struct controldef CtrlType; - - - -/************************************************************************* -* The following data structure stores a mesh. -**************************************************************************/ -struct meshdef { - int etype; - int gnelms, gnns; - int nelms, nns; - int ncon; - int esize, gminnode; - idxtype *elmdist; - idxtype *elements; - idxtype *elmwgt; -}; - -typedef struct meshdef MeshType; - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/sync b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/sync deleted file mode 100644 index 11a0cfb..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/sync +++ /dev/null @@ -1,186 +0,0 @@ -adrivers.c: ubavg = savg(graph->ncon, ctrl->ubvec); -adrivers.c: ctrl->redist_factor = ctrl->redist_base * ((gtewgt/gtvsize)/ ctrl->edge_size_ratio); -adrivers.c: IFSET(ctrl->dbglvl, DBG_PROGRESS, rprintf(ctrl, "[%6d %8d %5d %5d][%d]\n", -adrivers.c: graph->gnvtxs, GlobalSESum(ctrl, graph->nedges), GlobalSEMin(ctrl, graph->nvtxs), GlobalSEMax(ctrl, graph->nvtxs), ctrl->CoarsenTo)); -adrivers.c: if (graph->gnvtxs < 1.3*ctrl->CoarsenTo || -adrivers.c: if (lbavg > ubavg + 0.035 && ctrl->partType != REFINE_PARTITION) -adrivers.c: if (ctrl->dbglvl&DBG_PROGRESS) { -adrivers.c: switch (ctrl->ps_relation) { -adrivers.c: if (ctrl->dbglvl&DBG_PROGRESS) { -akwayfm.c: int npes = ctrl->npes, mype = ctrl->mype, nparts = ctrl->nparts; -akwayfm.c: IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->KWayTmr)); -akwayfm.c: ubvec = ctrl->ubvec; -akwayfm.c: tpwgts = ctrl->tpwgts; -akwayfm.c: ipc_factor = ctrl->ipc_factor; -akwayfm.c: redist_factor = ctrl->redist_factor; -akwayfm.c: MPI_Bcast((void *)pperm, nparts, IDX_DATATYPE, 0, ctrl->comm); -akwayfm.c: switch (ctrl->ps_relation) { -akwayfm.c: switch (ctrl->ps_relation) { -akwayfm.c: MPI_Allreduce((void *)lnpwgts, (void *)pgnpwgts, nparts*ncon, MPI_FLOAT, MPI_SUM, ctrl->comm); -akwayfm.c: IFSET(ctrl->dbglvl, DBG_RMOVEINFO, rprintf(ctrl, "\t[%d %d], [%.4f], [%d %d %d]\n", -akwayfm.c: MPI_Irecv((void *)(rupdate+sendptr[i]), sendptr[i+1]-sendptr[i], IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->rreq+i); -akwayfm.c: MPI_Isend((void *)(supdate+j), k-j, IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->sreq+i); -akwayfm.c: MPI_Waitall(nnbrs, ctrl->rreq, ctrl->statuses); -akwayfm.c: MPI_Get_count(ctrl->statuses+i, IDX_DATATYPE, nupds_pe+i); -akwayfm.c: MPI_Waitall(nnbrs, ctrl->sreq, ctrl->statuses); -akwayfm.c: MPI_Allreduce((void *)lnpwgts, (void *)gnpwgts, nparts*ncon, MPI_FLOAT, MPI_SUM, ctrl->comm); -akwayfm.c: IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->KWayTmr)); -balancemylink.c: ipc_factor = ctrl->ipc_factor; -balancemylink.c: redist_factor = ctrl->redist_factor; -coarsen.c: int npes=ctrl->npes, mype=ctrl->mype; -coarsen.c: MPI_Allgather((void *)(cvtxdist+npes), 1, IDX_DATATYPE, (void *)cvtxdist, 1, IDX_DATATYPE, ctrl->comm); -coarsen.c: MPI_Irecv((void *)(rsizes+i), 1, IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->rreq+i); -coarsen.c: MPI_Isend((void *)(ssizes+i), 1, IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->sreq+i); -coarsen.c: MPI_Wait(ctrl->rreq+i, &ctrl->status); -coarsen.c: MPI_Wait(ctrl->sreq+i, &ctrl->status); -coarsen.c: MPI_Irecv((void *)(rgraph+l), (4+ncon)*(rlens[i+1]-rlens[i])+2*rsizes[i], IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->rreq+i); -coarsen.c: sgraph[ll++] = (ctrl->partType == STATIC_PARTITION) ? -1 : vsize[ii]; -coarsen.c: sgraph[ll++] = (ctrl->partType == STATIC_PARTITION) ? -1 : home[ii]; -coarsen.c: MPI_Isend((void *)(sgraph+l), ll-l, IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->sreq+i); -coarsen.c: MPI_Wait(ctrl->rreq+i, &ctrl->status); -coarsen.c: MPI_Wait(ctrl->sreq+i, &ctrl->status); -coarsen.c: if (ctrl->partType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) { -coarsen.c: if (ctrl->partType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) { -coarsen.c: if (ctrl->partType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) { -coarsen.c: if (ctrl->partType == ADAPTIVE_PARTITION || ctrl->partType == REFINE_PARTITION) { -coarsen.c: cgraph->nvwgt[j*ncon+h] = (float)(cvwgt[j*ncon+h])/(float)(ctrl->tvwgts[h]); -comm.c: firstvtx = graph->vtxdist[ctrl->mype]; -comm.c: peind[i], 1, ctrl->comm, ctrl->rreq+i); -comm.c: peind[i], 1, ctrl->comm, ctrl->sreq+i); -comm.c: MPI_Waitall(nnbrs, ctrl->rreq, ctrl->statuses); -comm.c: MPI_Waitall(nnbrs, ctrl->sreq, ctrl->statuses); -comm.c: firstvtx = graph->vtxdist[ctrl->mype]; -comm.c: peind[i], 1, ctrl->comm, ctrl->rreq+i); -comm.c: idxcopy(ctrl->npes, sendptr, psendptr); -comm.c: peind[i], 1, ctrl->comm, ctrl->sreq+i); -comm.c: MPI_Isend((void *)(sendpairs), 0, IDX_DATATYPE, peind[i], 1, ctrl->comm, ctrl->sreq+i); -comm.c: MPI_Wait(ctrl->rreq+i, &(ctrl->status)); -comm.c: MPI_Get_count(&ctrl->status, IDX_DATATYPE, &n); -comm.c: MPI_Waitall(nnbrs, ctrl->sreq, ctrl->statuses); -comm.c: MPI_Allreduce((void *)&value, (void *)&max, 1, MPI_INT, MPI_MAX, ctrl->comm); -comm.c: MPI_Allreduce((void *)&value, (void *)&max, 1, MPI_DOUBLE, MPI_MAX, ctrl->comm); -comm.c: MPI_Allreduce((void *)&value, (void *)&min, 1, MPI_INT, MPI_MIN, ctrl->comm); -comm.c: MPI_Allreduce((void *)&value, (void *)&sum, 1, MPI_INT, MPI_SUM, ctrl->comm); -comm.c: MPI_Allreduce((void *)&value, (void *)&max, 1, MPI_FLOAT, MPI_MAX, ctrl->comm); -comm.c: MPI_Allreduce((void *)&value, (void *)&min, 1, MPI_FLOAT, MPI_MIN, ctrl->comm); -comm.c: MPI_Allreduce((void *)&value, (void *)&sum, 1, MPI_FLOAT, MPI_SUM, ctrl->comm); -debug.c: for (penum=0; penumnpes; penum++) { -debug.c: if (ctrl->mype == penum) { -debug.c: if (ctrl->mype == 0) -debug.c: printf("\t%3d. ", ctrl->mype); -debug.c: MPI_Barrier(ctrl->comm); -debug.c: for (penum=0; penumnpes; penum++) { -debug.c: if (ctrl->mype == penum) { -debug.c: if (ctrl->mype == 0) -debug.c: printf("\t%3d. ", ctrl->mype); -debug.c: MPI_Barrier(ctrl->comm); -debug.c: for (penum=0; penumnpes; penum++) { -debug.c: if (ctrl->mype == penum) { -debug.c: if (ctrl->mype == 0) -debug.c: printf("\t%3d. ", ctrl->mype); -debug.c: MPI_Barrier(ctrl->comm); -debug.c: MPI_Barrier(ctrl->comm); -debug.c: firstvtx = graph->vtxdist[ctrl->mype]; -debug.c: for (penum=0; penumnpes; penum++) { -debug.c: if (ctrl->mype == penum) { -debug.c: MPI_Barrier(ctrl->comm); -debug.c: MPI_Barrier(ctrl->comm); -debug.c: firstvtx = graph->vtxdist[ctrl->mype]; -debug.c: for (penum=0; penumnpes; penum++) { -debug.c: if (ctrl->mype == penum) { -debug.c: MPI_Barrier(ctrl->comm); -debug.c: MPI_Barrier(ctrl->comm); -debug.c: for (penum=0; penumnpes; penum++) { -debug.c: if (ctrl->mype == penum) { -debug.c: printf("PE: %d, nnbrs: %d\n", ctrl->mype, graph->nnbrs); -debug.c: MPI_Barrier(ctrl->comm); -debug.c: MPI_Barrier(ctrl->comm); -debug.c: for (penum=0; penumnpes; penum++) { -debug.c: if (ctrl->mype == penum) { -debug.c: printf("PE: %d, nnbrs: %d", ctrl->mype, nnbrs); -debug.c: MPI_Barrier(ctrl->comm); -diffutil.c: nparts = ctrl->nparts; -diffutil.c: myhome = (ctrl->ps_relation == COUPLED) ? ctrl->mype : graph->home[i]; -diffutil.c: /* PrintVector(ctrl, ctrl->npes, 0, lend, "Lend: "); */ -diffutil.c: MPI_Allreduce((void *)lstart, (void *)gstart, nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); -diffutil.c: MPI_Allreduce((void *)lleft, (void *)gleft, nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); -diffutil.c: MPI_Allreduce((void *)lend, (void *)gend, nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); -grsetup.c: graph->gnvtxs = vtxdist[ctrl->npes]; -grsetup.c: graph->nvtxs = vtxdist[ctrl->mype+1]-vtxdist[ctrl->mype]; -grsetup.c: ctrl->tvwgts[j] = GlobalSESum(ctrl, ltvwgts[j]); -grsetup.c: if (ctrl->tvwgts[i] == 0) { -grsetup.c: graph->nvwgt[i*ncon+j] = (float)(graph->vwgt[i*ncon+j]) / (float)(ctrl->tvwgts[j]); -grsetup.c: srand(ctrl->seed); -grsetup.c: MPI_Comm_dup(comm, &(ctrl->gcomm)); -grsetup.c: MPI_Comm_rank(ctrl->gcomm, &ctrl->mype); -grsetup.c: MPI_Comm_size(ctrl->gcomm, &ctrl->npes); -grsetup.c: ctrl->dbglvl = dbglvl; -grsetup.c: ctrl->nparts = nparts; /* Set the # of partitions is de-coupled from the # of domains */ -grsetup.c: ctrl->comm = ctrl->gcomm; -grsetup.c: ctrl->xyztype = XYZ_SPFILL; -grsetup.c: srand(ctrl->mype); -grsetup.c: lpvtxs = idxsmalloc(ctrl->nparts, 0, "ComputeMoveStatistics: lpvtxs"); -grsetup.c: gpvtxs = idxsmalloc(ctrl->nparts, 0, "ComputeMoveStatistics: gpvtxs"); -grsetup.c: if (where[i] != ctrl->mype) -grsetup.c: /* PrintVector(ctrl, ctrl->npes, 0, lpvtxs, "Lpvtxs: "); */ -grsetup.c: MPI_Allreduce((void *)lpvtxs, (void *)gpvtxs, ctrl->nparts, IDX_DATATYPE, MPI_SUM, ctrl->comm); -grsetup.c: *maxin = GlobalSEMax(ctrl, gpvtxs[ctrl->mype]-(nvtxs-j)); -initbalance.c: IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->InitPartTmr)); -initbalance.c: mytpwgts = fsmalloc(ctrl->nparts, 0.0, "mytpwgts"); -initbalance.c: for (i=0; inparts; i++) -initbalance.c: mytpwgts[i] += ctrl->tpwgts[i*ncon+j]; -initbalance.c: for (i=0; inparts; i++) -initbalance.c: if (ctrl->ps_relation == DISCOUPLED) { -initbalance.c: rcounts = imalloc(ctrl->npes, "rcounts"); -initbalance.c: rdispls = imalloc(ctrl->npes+1, "rdispls"); -initbalance.c: for (i=0; inpes; i++) { -initbalance.c: MAKECSR(i, ctrl->npes, rdispls); -initbalance.c: (void *)part, rcounts, rdispls, IDX_DATATYPE, ctrl->comm); -initbalance.c: for (i=0; inpes; i++) -initbalance.c: if (part[i] >= ctrl->nparts) -initbalance.c: part[i] = home[i] = part[i] % ctrl->nparts; -initbalance.c: part[i] = home[i] = (-1*part[i]) % ctrl->nparts; -initbalance.c: IFSET(ctrl->dbglvl, DBG_REFINEINFO, Moc_ComputeSerialBalance(ctrl, agraph, agraph->where, lbvec)); -initbalance.c: IFSET(ctrl->dbglvl, DBG_REFINEINFO, rprintf(ctrl, "input cut: %d, balance: ", ComputeSerialEdgeCut(agraph))); -initbalance.c: IFSET(ctrl->dbglvl, DBG_REFINEINFO, rprintf(ctrl, "%.3f ", lbvec[i])); -initbalance.c: IFSET(ctrl->dbglvl, DBG_REFINEINFO, rprintf(ctrl, "\n")); -initbalance.c: sr = (ctrl->mype % 2 == 0) ? 1 : 0; -initbalance.c: gd = (ctrl->mype % 2 == 1) ? 1 : 0; -initbalance.c: if (graph->ncon > MAX_NCON_FOR_DIFFUSION || ctrl->npes == 1) { -initbalance.c: MPI_Comm_split(ctrl->gcomm, sr, 0, &ipcomm); -initbalance.c: myctrl.sync = ctrl->sync; -initbalance.c: myctrl.seed = ctrl->seed; -initbalance.c: myctrl.nparts = ctrl->nparts; -initbalance.c: myctrl.ipc_factor = ctrl->ipc_factor; -initbalance.c: myctrl.redist_factor = ctrl->redist_base; -initbalance.c: myctrl.tpwgts = ctrl->tpwgts; -initbalance.c: icopy(ncon, ctrl->tvwgts, myctrl.tvwgts); -initbalance.c: icopy(ncon, ctrl->ubvec, myctrl.ubvec); -initbalance.c: moptions[7] = ctrl->sync + (mype % ngroups) + 1; -initbalance.c: lnparts = ctrl->nparts; -initbalance.c: lpecost.rank = ctrl->mype; -initbalance.c: if (ctrl->mype == gpecost.rank && ctrl->mype != sr_pe) { -initbalance.c: MPI_Send((void *)part, nvtxs, IDX_DATATYPE, sr_pe, 1, ctrl->comm); -initbalance.c: if (ctrl->mype != gpecost.rank && ctrl->mype == sr_pe) { -initbalance.c: MPI_Recv((void *)part, nvtxs, IDX_DATATYPE, gpecost.rank, 1, ctrl->comm, &status); -initbalance.c: if (ctrl->mype == sr_pe) { -initbalance.c: SerialRemap(&cgraph, ctrl->nparts, home, lwhere, part, ctrl->tpwgts); -initbalance.c: lpecost.rank = ctrl->mype; -initbalance.c: if (ctrl->mype == gpecost.rank && ctrl->mype != gd_pe) -initbalance.c: MPI_Send((void *)part, nvtxs, IDX_DATATYPE, gd_pe, 1, ctrl->comm); -initbalance.c: if (ctrl->mype != gpecost.rank && ctrl->mype == gd_pe) -initbalance.c: MPI_Recv((void *)part, nvtxs, IDX_DATATYPE, gpecost.rank, 1, ctrl->comm, &status); -initbalance.c: if (ctrl->mype == gd_pe) { -initbalance.c: SerialRemap(&cgraph, ctrl->nparts, home, lwhere, part, ctrl->tpwgts); -initbalance.c: if (ctrl->mype == sr_pe || ctrl->mype == gd_pe) { -initbalance.c: my_cost = ctrl->ipc_factor * my_cut + REDIST_WGT * ctrl->redist_base * my_totalv; -initbalance.c: IFSET(ctrl->dbglvl, DBG_REFINEINFO, printf("%s initial cut: %.1f, totalv: %.1f, balance: %.3f\n", -initbalance.c: (ctrl->mype == sr_pe ? "scratch-remap" : "diffusion"), my_cut, my_totalv, my_balance)); -initbalance.c: if (ctrl->mype == gd_pe) { -initbalance.c: MPI_Send((void *)buffer, 2, MPI_FLOAT, sr_pe, 1, ctrl->comm); -initbalance.c: MPI_Recv((void *)buffer, 2, MPI_FLOAT, gd_pe, 1, ctrl->comm, &status); -initbalance.c: if (ctrl->mype == sr_pe) { -initbalance.c: MPI_Bcast((void *)&who_wins, 1, MPI_INT, sr_pe, ctrl->comm); -initbalance.c: MPI_Bcast((void *)part, nvtxs, IDX_DATATYPE, who_wins, ctrl->comm); -initbalance.c: idxcopy(graph->nvtxs, part+vtxdist[ctrl->mype], graph->where); -initbalance.c: IFSET(ctrl->dbglvl, DBG_TIME, stoptim \ No newline at end of file diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/timer.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/timer.c deleted file mode 100644 index 73cc11a..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/timer.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * timer.c - * - * This file contain various timing routines - * - * Started 10/19/96 - * George - * - * $Id: timer.c,v 1.2 2003/07/21 17:18:54 karypis Exp $ - * - */ - -#include - - - - -/************************************************************************* -* This function initializes the various timers -**************************************************************************/ -void InitTimers(CtrlType *ctrl) -{ - cleartimer(ctrl->TotalTmr); - cleartimer(ctrl->InitPartTmr); - cleartimer(ctrl->MatchTmr); - cleartimer(ctrl->ContractTmr); - cleartimer(ctrl->CoarsenTmr); - cleartimer(ctrl->RefTmr); - cleartimer(ctrl->SetupTmr); - cleartimer(ctrl->ProjectTmr); - cleartimer(ctrl->KWayInitTmr); - cleartimer(ctrl->KWayTmr); - cleartimer(ctrl->MoveTmr); - cleartimer(ctrl->RemapTmr); - - cleartimer(ctrl->AuxTmr1); - cleartimer(ctrl->AuxTmr2); - cleartimer(ctrl->AuxTmr3); - cleartimer(ctrl->AuxTmr4); - cleartimer(ctrl->AuxTmr5); - cleartimer(ctrl->AuxTmr6); -} - - -/************************************************************************* -* This function prints timing information about KMETIS -**************************************************************************/ -void PrintTimingInfo(CtrlType *ctrl) -{ -/* PrintTimer(ctrl, ctrl->CoarsenTmr, " Coarsening"); */ - PrintTimer(ctrl, ctrl->SetupTmr, " Setup"); - PrintTimer(ctrl, ctrl->MatchTmr, " Matching"); - PrintTimer(ctrl, ctrl->ContractTmr, "Contraction"); - PrintTimer(ctrl, ctrl->InitPartTmr, " InitPart"); -/* PrintTimer(ctrl, ctrl->RefTmr, " Refinement"); */ - PrintTimer(ctrl, ctrl->ProjectTmr, " Project"); - PrintTimer(ctrl, ctrl->KWayInitTmr, " Initialize"); - PrintTimer(ctrl, ctrl->KWayTmr, " K-way"); - PrintTimer(ctrl, ctrl->MoveTmr, " Move"); - PrintTimer(ctrl, ctrl->RemapTmr, " Remap"); - PrintTimer(ctrl, ctrl->TotalTmr, " Total"); - PrintTimer(ctrl, ctrl->AuxTmr1, " Aux1"); - PrintTimer(ctrl, ctrl->AuxTmr2, " Aux2"); - PrintTimer(ctrl, ctrl->AuxTmr3, " Aux3"); - PrintTimer(ctrl, ctrl->AuxTmr4, " Aux4"); - PrintTimer(ctrl, ctrl->AuxTmr5, " Aux5"); - PrintTimer(ctrl, ctrl->AuxTmr6, " Aux6"); -} - - -/************************************************************************* -* This function prints timer stat -**************************************************************************/ -void PrintTimer(CtrlType *ctrl, timer tmr, char *msg) -{ - double sum, max, tsec; - - tsec = gettimer(tmr); - MPI_Reduce((void *)&tsec, (void *)&sum, 1, MPI_DOUBLE, MPI_SUM, 0, ctrl->comm); - - tsec = gettimer(tmr); - MPI_Reduce((void *)&tsec, (void *)&max, 1, MPI_DOUBLE, MPI_MAX, 0, ctrl->comm); - - if (ctrl->mype == 0 && sum != 0.0) - printf("%s: Max: %7.3f, Sum: %7.3f, Balance: %7.3f\n", - msg, (float)max, (float)sum, (float)(max*ctrl->npes/sum)); -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/util.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/util.c deleted file mode 100644 index 34c657d..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/util.c +++ /dev/null @@ -1,983 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * util.c - * - * This function contains various utility routines - * - * Started 9/28/95 - * George - * - * $Id: util.c,v 1.2 2003/07/21 17:18:54 karypis Exp $ - */ - -#include - - -/************************************************************************* -* This function prints an error message and exits -**************************************************************************/ -void errexit(char *f_str,...) -{ - va_list argp; - char out1[256], out2[256]; - - va_start(argp, f_str); - vsprintf(out1, f_str, argp); - va_end(argp); - - sprintf(out2, "Error! %s", out1); - - fprintf(stdout, out2); - fflush(stdout); - - abort(); -} - - -/************************************************************************* -* This function prints an error message and exits -**************************************************************************/ -void myprintf(CtrlType *ctrl, char *f_str,...) -{ - va_list argp; - char out1[256], out2[256]; - - va_start(argp, f_str); - vsprintf(out1, f_str, argp); - va_end(argp); - - sprintf(out2, "[%2d] %s", ctrl->mype, out1); - - fprintf(stdout, out2); - fflush(stdout); - -} - - - -/************************************************************************* -* This function prints an error message and exits -**************************************************************************/ -void rprintf(CtrlType *ctrl, char *f_str,...) -{ - va_list argp; - - if (ctrl->mype == 0) { - va_start(argp, f_str); - vfprintf(stdout, f_str, argp); - va_end(argp); - } - - fflush(stdout); - - MPI_Barrier(ctrl->comm); - -} - - -#ifndef DMALLOC -/************************************************************************* -* The following function allocates an array of integers -**************************************************************************/ -int *imalloc(int n, char *msg) -{ - if (n == 0) - return NULL; - - return (int *)GKmalloc(sizeof(int)*n, msg); -} - - -/************************************************************************* -* The following function allocates an array of integers -**************************************************************************/ -idxtype *idxmalloc(int n, char *msg) -{ - if (n == 0) - return NULL; - - return (idxtype *)GKmalloc(sizeof(idxtype)*n, msg); -} - - -/************************************************************************* -* The following function allocates an array of float -**************************************************************************/ -float *fmalloc(int n, char *msg) -{ - if (n == 0) - return NULL; - - return (float *)GKmalloc(sizeof(float)*n, msg); -} - - -/************************************************************************* -* The follwoing function allocates an array of integers -**************************************************************************/ -int *ismalloc(int n, int ival, char *msg) -{ - if (n == 0) - return NULL; - - return iset(n, ival, (int *)GKmalloc(sizeof(int)*n, msg)); -} - - - -/************************************************************************* -* The follwoing function allocates an array of integers -**************************************************************************/ -idxtype *idxsmalloc(int n, idxtype ival, char *msg) -{ - if (n == 0) - return NULL; - - return idxset(n, ival, (idxtype *)GKmalloc(sizeof(idxtype)*n, msg)); -} - - -/************************************************************************* -* This function is my wrapper around malloc -**************************************************************************/ -void *GKmalloc(int nbytes, char *msg) -{ - void *ptr; - - if (nbytes == 0) - return NULL; - - ptr = (void *)malloc(nbytes); - if (ptr == NULL) - errexit("***Memory allocation failed for %s. Requested size: %d bytes", msg, nbytes); - - return ptr; -} -#endif - -/************************************************************************* -* This function is my wrapper around free, allows multiple pointers -**************************************************************************/ -void GKfree(void **ptr1,...) -{ - va_list plist; - void **ptr; - - if (*ptr1 != NULL) - free(*ptr1); - *ptr1 = NULL; - - va_start(plist, ptr1); - - while ((ptr = va_arg(plist, void **)) != LTERM) { - if (*ptr != NULL) - free(*ptr); - *ptr = NULL; - } - - va_end(plist); -} - - -/************************************************************************* -* These functions set the values of a vector -**************************************************************************/ -int *iset(int n, int val, int *x) -{ - int i; - - for (i=0; i x[max] ? i : max); - - return max; -} - - -/************************************************************************* -* These functions return the index of the minimum element in a vector -**************************************************************************/ -int idxamin(int n, idxtype *x) -{ - int i, min=0; - - for (i=1; ikey != n2->key ? n1->key - n2->key : n1->val - n2->val); -} - - - -/************************************************************************* -* This function sorts an array of type KeyValueType in increasing order -**************************************************************************/ -void dkeyvalsort(int n, KeyValueType *nodes) -{ - qsort((void *)nodes, (size_t)n, (size_t)sizeof(KeyValueType), DecKeyValueCmp); -} - - -/************************************************************************* -* This function compares 2 KeyValueType variables for sorting in inc order -**************************************************************************/ -int DecKeyValueCmp(const void *v1, const void *v2) -{ - KeyValueType *n1, *n2; - - n1 = (KeyValueType *)v1; - n2 = (KeyValueType *)v2; - - return n2->key - n1->key; - -} - - - -/************************************************************************* -* This function does a binary search on an array for a key and returns -* the index -**************************************************************************/ -int BSearch(int n, idxtype *array, int key) -{ - int a=0, b=n, c; - - while (b-a > 8) { - c = (a+b)>>1; - if (array[c] > key) - b = c; - else - a = c; - } - - for (c=a; c>1); - return (a > 1 ? 0 : 1); -} - -/************************************************************************* -* This function returns the log2(x) -**************************************************************************/ -int log2Int(int a) -{ - int i; - - for (i=1; a > 1; i++, a = a>>1); - return i-1; -} - - -/************************************************************************* -* These functions set the values of a vector -**************************************************************************/ -float *sset(int n, float val, float *x) -{ - int i; - - for (i=0; i x[max] ? i : max); - - return max; -} - - -/************************************************************************* -* These functions return the index of the maximum element in a vector -**************************************************************************/ -int samax_strd(int n, float *x, int incx) -{ - int i; - int max=0; - - n *= incx; - for (i=incx; i x[max] ? i : max); - - return max/incx; -} - - -/************************************************************************* -* These functions return the index of the maximum element in a vector -**************************************************************************/ -int sfamax(int n, float *x) -{ - int i; - int max=0; - - for (i=1; i fabs(x[max]) ? i : max); - - return max; -} - - - -/************************************************************************* -* These functions return the index of the maximum element in a vector -**************************************************************************/ -int samin_strd(int n, float *x, int incx) -{ - int i; - int min=0; - - n *= incx; - for (i=incx; i x[max] ? i : max); - - return max/incx; -} - - -/************************************************************************* -* These functions return the index of the maximum element in a vector -**************************************************************************/ -int idxamin_strd(int n, idxtype *x, int incx) -{ - int i, min=0; - - n *= incx; - for (i=incx; i x[max] ? i : max); - - return max; -} - - -/************************************************************************* -* These functions return the index of the maximum element in a vector -**************************************************************************/ -int sfavg(int n, float *x) -{ - int i; - float total = 0.0; - - if (n == 0) - return 0.0; - - for (i=0; i x[1]) { - max1 = 0; - max2 = 1; - } - else { - max1 = 1; - max2 = 0; - } - - for (i=2; i x[max1]) { - max2 = max1; - max1 = i; - } - else if (x[i] > x[max2]) - max2 = i; - } - - return max2; -} - - -/************************************************************************* -* These functions return the index of the minimum element in a vector -**************************************************************************/ -int samin(int n, float *x) -{ - int i, min=0; - - for (i=1; i=0; n--) - y[n] += x[n]; -} - - -/************************************************************************* -* This function sums the entries in an array -**************************************************************************/ -float ssum(int n, float *x) -{ - int i; - float sum = 0.0; - - for (i=0; i m11) - return 0; - if (m22 < m12) - return 1; - if (m22 > m12) - return 0; - - return sm2 < sm1; -} - -/************************************************************************* -* This is a comparison function -**************************************************************************/ -int myvalkeycompare(const void *fptr, const void *sptr) -{ - KVType *first, *second; - - first = (KVType *)(fptr); - second = (KVType *)(sptr); - - if (first->val > second->val) - return 1; - - if (first->val < second->val) - return -1; - - return 0; -} - -/************************************************************************* -* This is the inverse comparison function -**************************************************************************/ -int imyvalkeycompare(const void *fptr, const void *sptr) -{ - KVType *first, *second; - - first = (KVType *)(fptr); - second = (KVType *)(sptr); - - if (first->val > second->val) - return -1; - - if (first->val < second->val) - return 1; - - return 0; -} - - -/************************************************************************* -* The following function allocates and sets an array of floats -**************************************************************************/ -float *fsmalloc(int n, float fval, char *msg) -{ - if (n == 0) - return NULL; - - return sset(n, fval, (float *)GKmalloc(sizeof(float)*n, msg)); -} - - -/************************************************************************* -* This function computes a 2-norm -**************************************************************************/ -void saxpy2(int n, float alpha, float *x, int incx, float *y, int incy) -{ - int i; - - for (i=0; i x[*first]) { - *third = *second; - *second = *first; - *first = i; - continue; - } - - if (*second == -1 || x[i] > x[*second]) { - *third = *second; - *second = i; - continue; - } - - if (*third == -1 || x[i] > x[*third]) - *third = i; - } - - return; -} diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/wave.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/wave.c deleted file mode 100644 index 0f1cb3f..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/wave.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * wave.c - * - * This file contains code for directed diffusion at the coarsest graph - * - * Started 5/19/97, Kirk, George - * - * $Id: wave.c,v 1.3 2003/07/22 21:47:18 karypis Exp $ - * - */ - -#include - -/************************************************************************* -* This function performs a k-way directed diffusion -**************************************************************************/ -float WavefrontDiffusion(CtrlType *ctrl, GraphType *graph, idxtype *home) -{ - int ii, i, j, k, l, nvtxs, nedges, nparts; - int from, to, edge, done, nswaps, noswaps, totalv, wsize; - int npasses, first, second, third, mind, maxd; - idxtype *xadj, *adjncy, *adjwgt, *where, *perm; - idxtype *rowptr, *colind, *ed, *psize; - float *transfer, *tmpvec; - float balance = -1.0, *load, *solution, *workspace; - float *nvwgt, *npwgts, flowFactor, cost, ubfactor; - MatrixType matrix; - KeyValueType *cand; - int ndirty, nclean, dptr, clean; - - nvtxs = graph->nvtxs; - nedges = graph->nedges; - xadj = graph->xadj; - nvwgt = graph->nvwgt; - adjncy = graph->adjncy; - adjwgt = graph->adjwgt; - where = graph->where; - nparts = ctrl->nparts; - ubfactor = ctrl->ubvec[0]; - matrix.nrows = nparts; - - flowFactor = 0.35; - flowFactor = (ctrl->mype == 2) ? 0.50 : flowFactor; - flowFactor = (ctrl->mype == 3) ? 0.75 : flowFactor; - flowFactor = (ctrl->mype == 4) ? 1.00 : flowFactor; - - /* allocate memory */ - solution = fmalloc(4*nparts+2*nedges, "WavefrontDiffusion: solution"); - tmpvec = solution + nparts; - npwgts = solution + 2*nparts; - load = solution + 3*nparts; - matrix.values = solution + 4*nparts; - transfer = matrix.transfer = solution + 4*nparts + nedges; - - perm = idxmalloc(2*nvtxs+2*nparts+nedges+1, "WavefrontDiffusion: perm"); - ed = perm + nvtxs; - psize = perm + 2*nvtxs; - rowptr = matrix.rowptr = perm + 2*nvtxs + nparts; - colind = matrix.colind = perm + 2*nvtxs + 2*nparts + 1; - - wsize = amax(sizeof(float)*nparts*6, sizeof(idxtype)*(nvtxs+nparts*2+1)); - workspace = (float *)GKmalloc(wsize, "WavefrontDiffusion: workspace"); - cand = (KeyValueType *)GKmalloc(nvtxs*sizeof(KeyValueType), "WavefrontDiffusion: cand"); - - - /*****************************/ - /* Populate empty subdomains */ - /*****************************/ - idxset(nparts, 0, psize); - for (i=0; itpwgts, 0); - done = 0; - - npasses = amin(nparts/2, NGD_PASSES); - for (l=0; lmype); - goto CleanUpAndExit; - } - } - - ConjGrad2(&matrix, load, solution, 0.001, workspace); - ComputeTransferVector(1, &matrix, solution, transfer, 0); - - GetThreeMax(nparts, load, &first, &second, &third); - - if (l%3 == 0) { - FastRandomPermute(nvtxs, perm, 1); - } - else { - /*****************************/ - /* move dirty vertices first */ - /*****************************/ - ndirty = 0; - for (i=0; imype == 0) { - for (j=nvtxs, k=0, ii=0; iimype == 0) ? cand[ii].val : perm[ii]; - from = where[i]; - - /* don't move out the last vertex in a subdomain */ - if (psize[from] == 1) - continue; - - clean = (from == home[i]) ? 1 : 0; - - /* only move from top three or dirty vertices */ - if (from != first && from != second && from != third && clean) - continue; - - /* Scatter the sparse transfer row into the dense tmpvec row */ - for (j=rowptr[from]+1; j (flowFactor * nvwgt[i])) { - tmpvec[to] -= nvwgt[i]; - INC_DEC(psize[to], psize[from], 1); - INC_DEC(npwgts[to], npwgts[from], nvwgt[i]); - INC_DEC(load[to], load[from], nvwgt[i]); - where[i] = to; - nswaps++; - - /* Update external degrees */ - ed[i] = 0; - for (k=xadj[i]; k 0) - break; - - noswaps = (nswaps > 0) ? 0 : 1; - if (GlobalSESum(ctrl, noswaps) > ctrl->npes/2) - break; - - } - } - - graph->mincut = ComputeSerialEdgeCut(graph); - totalv = Mc_ComputeSerialTotalV(graph, home); - cost = ctrl->ipc_factor * (float)graph->mincut + ctrl->redist_factor * (float)totalv; - - -CleanUpAndExit: - GKfree((void **)&solution, (void **)&perm, (void **)&workspace, (void **)&cand, LTERM); - - return cost; -} - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/weird.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/weird.c deleted file mode 100644 index 69d0e5d..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/weird.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * weird.c - * - * This file contain various graph setting up routines - * - * Started 10/19/96 - * George - * - * $Id: weird.c,v 1.9 2003/07/31 16:27:28 karypis Exp $ - * - */ - -#include - - - -/************************************************************************* -* This function computes a partitioning of a small graph -**************************************************************************/ -void PartitionSmallGraph(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace) -{ - int i, h, ncon, nparts, npes, mype; - int moptions[10]; - int mynumflag, mywgtflag, me; - idxtype *mypart; - int lpecut[2], gpecut[2]; - GraphType *agraph; - int *sendcounts, *displs; - float *mytpwgts, *gnpwgts, *lnpwgts; - - ncon = graph->ncon; - nparts = ctrl->nparts; - - MPI_Comm_size(ctrl->comm, &npes); - MPI_Comm_rank(ctrl->comm, &mype); - - SetUp(ctrl, graph, wspace); - graph->where = idxmalloc(graph->nvtxs+graph->nrecv, "PartitionSmallGraph: where"); - agraph = Moc_AssembleAdaptiveGraph(ctrl, graph, wspace); - mypart = idxmalloc(agraph->nvtxs, "mypart"); - - moptions[0] = 0; - moptions[7] = ctrl->sync + mype; - mynumflag = 0; - mywgtflag = 3; - if (ncon == 1) { - METIS_WPartGraphKway2(&agraph->nvtxs, agraph->xadj, agraph->adjncy, agraph->vwgt, - agraph->adjwgt, &mywgtflag, &mynumflag, &nparts, ctrl->tpwgts, moptions, - &graph->mincut, mypart); - } - else { - mytpwgts = fmalloc(nparts, "mytpwgts"); - for (i=0; itpwgts[i*ncon]; - - METIS_mCPartGraphRecursive2(&agraph->nvtxs, &ncon, agraph->xadj, agraph->adjncy, - agraph->vwgt, agraph->adjwgt, &mywgtflag, &mynumflag, &nparts, mytpwgts, - moptions, &graph->mincut, mypart); - - free(mytpwgts); - } - - lpecut[0] = graph->mincut; - lpecut[1] = mype; - MPI_Allreduce(lpecut, gpecut, 1, MPI_2INT, MPI_MINLOC, ctrl->comm); - graph->mincut = gpecut[0]; - - if (lpecut[1] == gpecut[1] && gpecut[1] != 0) - MPI_Send((void *)mypart, agraph->nvtxs, IDX_DATATYPE, 0, 1, ctrl->comm); - if (lpecut[1] == 0 && gpecut[1] != 0) - MPI_Recv((void *)mypart, agraph->nvtxs, IDX_DATATYPE, gpecut[1], 1, ctrl->comm, &ctrl->status); - - sendcounts = imalloc(npes, "sendcounts"); - displs = imalloc(npes, "displs"); - - for (i=0; ivtxdist[i+1]-graph->vtxdist[i]; - displs[i] = graph->vtxdist[i]; - } - - MPI_Scatterv((void *)mypart, sendcounts, displs, IDX_DATATYPE, - (void *)graph->where, graph->nvtxs, IDX_DATATYPE, 0, ctrl->comm); - - lnpwgts = graph->lnpwgts = fmalloc(nparts*ncon, "lnpwgts"); - gnpwgts = graph->gnpwgts = fmalloc(nparts*ncon, "gnpwgts"); - sset(nparts*ncon, 0, lnpwgts); - for (i=0; invtxs; i++) { - me = graph->where[i]; - for (h=0; hnvwgt[i*ncon+h]; - } - MPI_Allreduce((void *)lnpwgts, (void *)gnpwgts, nparts*ncon, MPI_FLOAT, MPI_SUM, ctrl->comm); - GKfree((void**)&mypart, (void**)&sendcounts, (void**)&displs, LTERM); - FreeGraph(agraph); - - return; -} - - - -/************************************************************************* -* This function checks the inputs for the partitioning routines -**************************************************************************/ -void CheckInputs(int partType, int npes, int dbglvl, int *wgtflag, int *iwgtflag, - int *numflag, int *inumflag, int *ncon, int *incon, int *nparts, - int *inparts, float *tpwgts, float **itpwgts, float *ubvec, - float *iubvec, float *ipc2redist, float *iipc2redist, int *options, - int *ioptions, idxtype *part, MPI_Comm *comm) -{ - int i, j; - int doweabort, doiabort = 0; - float tsum, *myitpwgts; - int mgcnums[5] = {-1, 2, 3, 4, 2}; - - /**************************************/ - if (part == NULL) { - doiabort = 1; - IFSET(dbglvl, DBG_INFO, printf("ERROR: part array is set to NULL.\n")); - } - /**************************************/ - - - /**************************************/ - if (wgtflag == NULL) { - *iwgtflag = 0; - IFSET(dbglvl, DBG_INFO, printf("WARNING: wgtflag is NULL. Using a value of 0.\n")); - } - else { - *iwgtflag = *wgtflag; - } - /**************************************/ - - - /**************************************/ - if (numflag == NULL) { - *inumflag = 0; - IFSET(dbglvl, DBG_INFO, printf("WARNING: numflag is NULL. Using a value of 0.\n")); - } - else { - if (*numflag != 0 && *numflag != 1) { - IFSET(dbglvl, DBG_INFO, printf("WARNING: bad value for numflag %d. Using a value of 0.\n", *numflag)); - *inumflag = 0; - } - else { - *inumflag = *numflag; - } - } - /**************************************/ - - - /**************************************/ - if (ncon == NULL) { - *incon = 1; - IFSET(dbglvl, DBG_INFO, printf("WARNING: ncon is NULL. Using a value of 1.\n")); - } - else { - if (*ncon < 1 || *ncon > MAXNCON) { - IFSET(dbglvl, DBG_INFO, printf("WARNING: bad value for ncon %d. Using a value of 1.\n", *ncon)); - *incon = 1; - } - else { - *incon = *ncon; - } - } - /**************************************/ - - - /**************************************/ - if (nparts == NULL) { - *inparts = npes; - IFSET(dbglvl, DBG_INFO, printf("WARNING: nparts is NULL. Using a value of %d.\n", npes)); - } - else { - if (*nparts < 1 || *nparts > MAX_NPARTS) { - IFSET(dbglvl, DBG_INFO, printf("WARNING: bad value for nparts %d. Using a value of %d.\n", *nparts, npes)); - *inparts = npes; - } - else { - *inparts = *nparts; - } - } - /**************************************/ - - - /**************************************/ - myitpwgts = *itpwgts = fmalloc((*inparts)*(*incon), "CheckInputs: itpwgts"); - if (tpwgts == NULL) { - sset((*inparts)*(*incon), 1.0/(float)(*inparts), myitpwgts); - IFSET(dbglvl, DBG_INFO, printf("WARNING: tpwgts is NULL. Setting all array elements to %.3f.\n", 1.0/(float)(*inparts))); - } - else { - for (i=0; i<*incon; i++) { - tsum = 0.0; - for (j=0; j<*inparts; j++) { - tsum += tpwgts[j*(*incon)+i]; - } - if (fabs(1.0-tsum) < SMALLFLOAT) - tsum = 1.0; - for (j=0; j<*inparts; j++) - myitpwgts[j*(*incon)+i] = tpwgts[j*(*incon)+i] / tsum; - } - } - /**************************************/ - - - /**************************************/ - if (ubvec == NULL) { - sset(*incon, 1.05, iubvec); - IFSET(dbglvl, DBG_INFO, printf("WARNING: ubvec is NULL. Setting all array elements to 1.05.\n")); - } - else { - for (i=0; i<*incon; i++) { - if (ubvec[i] < 1.0 || ubvec[i] > (float)(*inparts)) { - iubvec[i] = 1.05; - IFSET(dbglvl, DBG_INFO, printf("WARNING: bad value for ubvec[%d]: %.3f. Setting value to 1.05.[%d]\n", i, ubvec[i], *inparts)); - } - else { - iubvec[i] = ubvec[i]; - } - } - } - /**************************************/ - - - /**************************************/ - if (partType == ADAPTIVE_PARTITION) { - if (ipc2redist != NULL) { - if (*ipc2redist < SMALLFLOAT || *ipc2redist > 1000000.0) { - IFSET(dbglvl, DBG_INFO, printf("WARNING: bad value for ipc2redist %.3f. Using a value of 1000.\n", *ipc2redist)); - *iipc2redist = 1000.0; - } - else { - *iipc2redist = *ipc2redist; - } - } - else { - IFSET(dbglvl, DBG_INFO, printf("WARNING: ipc2redist is NULL. Using a value of 1000.\n")); - *iipc2redist = 1000.0; - } - } - /**************************************/ - - - /**************************************/ - if (options == NULL) { - ioptions[0] = 0; - IFSET(dbglvl, DBG_INFO, printf("WARNING: options is NULL. Using defaults\n")); - } - else { - ioptions[0] = options[0]; - ioptions[1] = options[1]; - ioptions[2] = options[2]; - if (partType == ADAPTIVE_PARTITION || partType == REFINE_PARTITION) - ioptions[3] = options[3]; - } - /**************************************/ - - - /**************************************/ - if (comm == NULL) { - IFSET(dbglvl, DBG_INFO, printf("ERROR: comm is NULL. Aborting\n")); - abort(); - } - else { - MPI_Allreduce((void *)&doiabort, (void *)&doweabort, 1, MPI_INT, MPI_MAX, *comm); - if (doweabort > 0) - abort(); - } - /**************************************/ - -} - - diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/xyzpart.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/xyzpart.c deleted file mode 100644 index e538034..0000000 --- a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/xyzpart.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * xyzpart.c - * - * This file contains code that implements a coordinate based partitioning - * - * Started 7/11/97 - * George - * - * $Id: xyzpart.c,v 1.3 2003/07/30 18:37:59 karypis Exp $ - * - */ - -#include - - -/************************************************************************* -* This function implements a simple coordinate based partitioning -**************************************************************************/ -void Coordinate_Partition(CtrlType *ctrl, GraphType *graph, int ndims, float *xyz, - int setup, WorkSpaceType *wspace) -{ - int i, j, k, nvtxs, firstvtx, icoord, coords[3]; - idxtype *vtxdist; - float max[3], min[3], gmin[3], gmax[3], shift[3], scale[3]; - KeyValueType *cand; - - if (setup) - SetUp(ctrl, graph, wspace); - else - graph->nrecv = 0; - - nvtxs = graph->nvtxs; - vtxdist = graph->vtxdist; - - firstvtx = vtxdist[ctrl->mype]; - - cand = (KeyValueType *)GKmalloc(nvtxs*sizeof(KeyValueType), "Coordinate_Partition: cand"); - - /* Compute parameters for coordinate transformation */ - for (k=0; k max[k]) - max[k] = xyz[i*ndims+k]; - } - } - - /* Compute global min and max */ - MPI_Allreduce((void *)min, (void *)gmin, ndims, MPI_FLOAT, MPI_MIN, ctrl->comm); - MPI_Allreduce((void *)max, (void *)gmax, ndims, MPI_FLOAT, MPI_MAX, ctrl->comm); - - /* myprintf(ctrl, "Coordinate Range: %e %e, Global %e %e\n", min[0], max[0], gmin[0], gmax[0]); */ - - for (k=0; kxyztype) { - case XYZ_XCOORD: - for (i=0; i=0 && cand[i].key<=1000000); - cand[i].val = firstvtx+i; - } - break; - case XYZ_SPFILL: - for (i=0; i=0; j--) { - for (k=0; knpes, mype=ctrl->mype, firstvtx, lastvtx; - idxtype *scounts, *rcounts, *vtxdist, *perm; - KeyValueType *relmnts, *mypicks, *allpicks; - - nvtxs = graph->nvtxs; - vtxdist = graph->vtxdist; - - scounts = wspace->pv1; - rcounts = wspace->pv2; - - /* Allocate memory for the splitters */ - mypicks = (KeyValueType *)GKmalloc(sizeof(KeyValueType)*(npes+1), "ParSort: mypicks"); - allpicks = (KeyValueType *)GKmalloc(sizeof(KeyValueType)*npes*npes, "ParSort: allpicks"); - - /* Sort the local elements */ - ikeysort(nvtxs, elmnts); - - /* Select the local npes-1 equally spaced elements */ - for (i=1; icomm); - - /* PrintPairs(ctrl, npes*(npes-1), allpicks, "Allpicks"); */ - - /* Sort all the picks */ - ikeyvalsort(npes*(npes-1), allpicks); - - /* PrintPairs(ctrl, npes*(npes-1), allpicks, "Allpicks"); */ - - /* Select the final splitters. Set the boundaries to simplify coding */ - for (i=1; icomm); - -/* - PrintVector(ctrl, npes, 0, scounts, "Scounts"); - PrintVector(ctrl, npes, 0, rcounts, "Rcounts"); -*/ - - /* Allocate memory for sorted elements and receive them */ - MAKECSR(i, npes, scounts); - MAKECSR(i, npes, rcounts); - nrecv = rcounts[npes]; - if (wspace->nlarge >= nrecv) - relmnts = (KeyValueType *)wspace->pairs; - else - relmnts = (KeyValueType *)GKmalloc(sizeof(KeyValueType)*nrecv, "ParSort: relmnts"); - - /* Issue the receives first */ - for (i=0; icomm, ctrl->rreq+i); - - /* Issue the sends next */ - for (i=0; icomm, ctrl->sreq+i); - - MPI_Waitall(npes, ctrl->rreq, ctrl->statuses); - MPI_Waitall(npes, ctrl->sreq, ctrl->statuses); - - - /* OK, now do the local sort of the relmnts. Use perm to keep track original order */ - perm = idxmalloc(nrecv, "ParSort: perm"); - for (i=0; icomm); - firstvtx = lastvtx-nrecv; - - /*myprintf(ctrl, "first, last: %d %d\n", firstvtx, lastvtx); */ - - for (j=0, i=0; i firstvtx) { /* Found the first PE that is passed me */ - if (vtxdist[i+1] >= lastvtx) { - /* myprintf(ctrl, "Shifting %d elements to processor %d\n", lastvtx-firstvtx, i); */ - for (k=0; k= lastvtx) - break; - } - - /* Reverse the ordering on the relmnts[].val */ - for (i=0; i=0 && relmnts[i].keycomm, ctrl->rreq+i); - - /* Issue the sends next */ - for (i=0; icomm, ctrl->sreq+i); - - MPI_Waitall(npes, ctrl->rreq, ctrl->statuses); - MPI_Waitall(npes, ctrl->sreq, ctrl->statuses); - - - /* Construct a partition for the graph */ - graph->where = idxmalloc(graph->nvtxs+graph->nrecv, "PartSort: graph->where"); - firstvtx = vtxdist[mype]; - for (i=0; i=0 && elmnts[i].key=vtxdist[mype] && elmnts[i].valwhere[elmnts[i].val-firstvtx] = elmnts[i].key; - } - - - GKfree((void **)&mypicks, (void **)&allpicks, (void **)&perm, LTERM); - if (wspace->nlarge < nrecv) - free(relmnts); - -} - -- cgit v1.3