From 69f2911e04ffb1b19eef1fafb8c040af271f656e Mon Sep 17 00:00:00 2001 From: Tor Aamodt Date: Thu, 15 Jul 2010 18:09:46 -0800 Subject: creating branch for adding support for CUDA 3.x and Fermi [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 6829] --- .../DG/3rdParty/ParMetis-3.1/ParMETISLib/mesh.c | 335 +++++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mesh.c (limited to 'benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mesh.c') diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mesh.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mesh.c new file mode 100644 index 0000000..57a80c0 --- /dev/null +++ b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/mesh.c @@ -0,0 +1,335 @@ +/* + * 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