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/comm.c | 213 +++++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/comm.c (limited to 'benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/comm.c') diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/comm.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/comm.c new file mode 100644 index 0000000..fb18789 --- /dev/null +++ b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/ParMETISLib/comm.c @@ -0,0 +1,213 @@ +/* + * 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; +} + -- cgit v1.3