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] --- .../3rdParty/ParMetis-3.1/ParMETISLib/diffutil.c | 298 +++++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/diffutil.c (limited to 'benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/diffutil.c') diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/diffutil.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/diffutil.c new file mode 100644 index 0000000..f31da64 --- /dev/null +++ b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/diffutil.c @@ -0,0 +1,298 @@ +/* + * Copyright 1997, Regents of the University of Minnesota + * + * wavefrontK.c + * + * This file contains code for the initial directed diffusion at the coarsest + * graph + * + * Started 5/19/97, Kirk, George + * + * $Id: diffutil.c,v 1.2 2003/07/21 17:18:48 karypis Exp $ + * + */ + +#include + + +/************************************************************************* +* 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; + } + } + } +} + -- cgit v1.3