From 7cd0d58e85616e9bfb4d0db6d644dc15d174fe9e Mon Sep 17 00:00:00 2001 From: sjplimp Date: Tue, 29 Jul 2014 15:29:09 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12221 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/STUBS/mpi.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++- src/STUBS/mpi.h | 10 +++++++ src/rcb.cpp | 4 +-- 3 files changed, 90 insertions(+), 3 deletions(-) diff --git a/src/STUBS/mpi.c b/src/STUBS/mpi.c index 5f865c4031..891fd80ce7 100644 --- a/src/STUBS/mpi.c +++ b/src/STUBS/mpi.c @@ -20,7 +20,7 @@ #include #include "mpi.h" -/* lo-level data structure */ +/* data structure for double/int */ struct _mpi_double_int { double value; @@ -28,6 +28,15 @@ struct _mpi_double_int { }; typedef struct _mpi_double_int double_int; +/* extra MPI_Datatypes registered by MPI_Type_contiguous */ + +#define MAXEXTRA_DATATYPE 16 + +int nextra_datatype; +MPI_Datatype *ptr_datatype[MAXEXTRA_DATATYPE]; +int index_datatype[MAXEXTRA_DATATYPE]; +int size_datatype[MAXEXTRA_DATATYPE]; + /* ---------------------------------------------------------------------- */ /* MPI Functions */ /* ---------------------------------------------------------------------- */ @@ -101,6 +110,8 @@ double MPI_Wtime() /* ---------------------------------------------------------------------- */ +/* include sizes of user defined datatypes, stored in extra lists */ + static int stubtypesize(MPI_Datatype datatype) { if (datatype == MPI_INT) return sizeof(int); @@ -111,6 +122,12 @@ static int stubtypesize(MPI_Datatype datatype) else if (datatype == MPI_LONG) return sizeof(long); else if (datatype == MPI_LONG_LONG) return sizeof(uint64_t); else if (datatype == MPI_DOUBLE_INT) return sizeof(double_int); + else { + int i; + for (i = 0; i < nextra_datatype; i++) + if (datatype == index_datatype[i]) return size_datatype[i]; + } + return 0; } /* ---------------------------------------------------------------------- */ @@ -305,6 +322,66 @@ int MPI_Cart_rank(MPI_Comm comm, int *coords, int *rank) /* ---------------------------------------------------------------------- */ +/* store size of user datatype in extra lists */ + +int MPI_Type_contiguous(int count, MPI_Datatype oldtype, + MPI_Datatype *newtype) +{ + if (nextra_datatype = MAXEXTRA_DATATYPE) return -1; + ptr_datatype[nextra_datatype] = newtype; + index_datatype[nextra_datatype] = -(nextra_datatype + 1); + size_datatype[nextra_datatype] = count * stubtypesize(oldtype); + nextra_datatype++; + return 0; +} + +/* ---------------------------------------------------------------------- */ + +/* set value of user datatype to internal negative index, + based on match of ptr */ + +int MPI_Type_commit(MPI_Datatype *datatype) +{ + int i; + for (i = 0; i < nextra_datatype; i++) + if (datatype == ptr_datatype[i]) *datatype = index_datatype[i]; + return 0; +} + +/* ---------------------------------------------------------------------- */ + +/* remove user datatype from extra lists */ + +int MPI_Type_free(MPI_Datatype *datatype) +{ + int i; + for (i = 0; i < nextra_datatype; i++) + if (datatype == ptr_datatype[i]) { + ptr_datatype[i] = ptr_datatype[nextra_datatype-1]; + index_datatype[i] = index_datatype[nextra_datatype-1]; + size_datatype[i] = size_datatype[nextra_datatype-1]; + nextra_datatype--; + break; + } + return 0; +} + +/* ---------------------------------------------------------------------- */ + +int MPI_Op_create(MPI_User_function *function, int commute, MPI_Op *op) +{ + return 0; +} + +/* ---------------------------------------------------------------------- */ + +int MPI_Op_free(MPI_Op *op) +{ + return 0; +} + +/* ---------------------------------------------------------------------- */ + int MPI_Barrier(MPI_Comm comm) {return 0;} /* ---------------------------------------------------------------------- */ diff --git a/src/STUBS/mpi.h b/src/STUBS/mpi.h index bbd1186ea8..86bd6db341 100644 --- a/src/STUBS/mpi.h +++ b/src/STUBS/mpi.h @@ -64,6 +64,9 @@ extern "C" { #define MPI_MAX_PROCESSOR_NAME 128 +typedef void MPI_User_function(void *invec, void *inoutvec, + int *len, MPI_Datatype *datatype); + /* MPI data structs */ struct _MPI_Status { @@ -122,6 +125,13 @@ int MPI_Cart_shift(MPI_Comm comm, int direction, int displ, int *source, int *dest); int MPI_Cart_rank(MPI_Comm comm, int *coords, int *rank); +int MPI_Type_contiguous(int count, MPI_Datatype oldtype, + MPI_Datatype *newtype); +int MPI_Type_commit(MPI_Datatype *datatype); +int MPI_Type_free(MPI_Datatype *datatype); + +int MPI_Op_create(MPI_User_function *function, int commute, MPI_Op *op); +int MPI_Op_free(MPI_Op *op); int MPI_Barrier(MPI_Comm comm); int MPI_Bcast(void *buf, int count, MPI_Datatype datatype, diff --git a/src/rcb.cpp b/src/rcb.cpp index cf4e12d213..de3f9f3ba6 100644 --- a/src/rcb.cpp +++ b/src/rcb.cpp @@ -101,8 +101,8 @@ RCB::~RCB() sets noriginal,nfinal,nkeep,recvproc,recvindex,lo,hi all proc particles will be inside or on surface of 3-d box defined by final lo/hi - // NOTE: worry about re-use of data structs for fix balance - // NOTE: should I get rid of wt all together, will it be used? + // NOTE: worry about re-use of data structs for fix balance? + // NOTE: could get rid of wt all together, will it be used? ------------------------------------------------------------------------- */ void RCB::compute(int dimension, int n, double **x, double *wt,