forked from lijiext/lammps
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11307 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
418e9cf0bb
commit
98655f672e
191
src/STUBS/mpi.c
191
src/STUBS/mpi.c
|
@ -101,17 +101,25 @@ double MPI_Wtime()
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
static int stubtypesize(MPI_Datatype datatype)
|
||||
{
|
||||
if (datatype == MPI_INT) return sizeof(int);
|
||||
else if (datatype == MPI_FLOAT) return sizeof(float);
|
||||
else if (datatype == MPI_DOUBLE) return sizeof(double);
|
||||
else if (datatype == MPI_CHAR) return sizeof(char);
|
||||
else if (datatype == MPI_BYTE) return sizeof(char);
|
||||
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);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int MPI_Type_size(MPI_Datatype datatype, int *size)
|
||||
{
|
||||
if (datatype == MPI_INT) *size = sizeof(int);
|
||||
else if (datatype == MPI_FLOAT) *size = sizeof(float);
|
||||
else if (datatype == MPI_DOUBLE) *size = sizeof(double);
|
||||
else if (datatype == MPI_CHAR) *size = sizeof(char);
|
||||
else if (datatype == MPI_BYTE) *size = sizeof(char);
|
||||
else if (datatype == MPI_LONG) *size = sizeof(long);
|
||||
else if (datatype == MPI_LONG_LONG) *size = sizeof(uint64_t);
|
||||
else if (datatype == MPI_DOUBLE_INT) *size = sizeof(double_int);
|
||||
if (size == NULL) return MPI_ERR_ARG;
|
||||
|
||||
*size = stubtypesize(datatype);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -226,6 +234,40 @@ int MPI_Comm_free(MPI_Comm *comm) {return 0;}
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
MPI_Fint MPI_Comm_c2f(MPI_Comm comm) { return comm; };
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
MPI_Comm MPI_Comm_f2c(MPI_Fint comm) { return comm; };
|
||||
|
||||
//* ---------------------------------------------------------------------- */
|
||||
|
||||
int MPI_Comm_group(MPI_Comm comm, MPI_Group *group)
|
||||
{
|
||||
*group = comm;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm)
|
||||
{
|
||||
*newcomm = group;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup)
|
||||
{
|
||||
if (n > 0)
|
||||
*newgroup = MPI_COMM_WORLD;
|
||||
else
|
||||
*newgroup = group;
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int MPI_Cart_create(MPI_Comm comm_old, int ndims, int *dims, int *periods,
|
||||
int reorder, MPI_Comm *comm_cart)
|
||||
{
|
||||
|
@ -277,15 +319,7 @@ int MPI_Bcast(void *buf, int count, MPI_Datatype datatype,
|
|||
int MPI_Allreduce(void *sendbuf, void *recvbuf, int count,
|
||||
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
|
||||
{
|
||||
int n;
|
||||
if (datatype == MPI_INT) n = count*sizeof(int);
|
||||
else if (datatype == MPI_FLOAT) n = count*sizeof(float);
|
||||
else if (datatype == MPI_DOUBLE) n = count*sizeof(double);
|
||||
else if (datatype == MPI_CHAR) n = count*sizeof(char);
|
||||
else if (datatype == MPI_BYTE) n = count*sizeof(char);
|
||||
else if (datatype == MPI_LONG) n = count*sizeof(long);
|
||||
else if (datatype == MPI_LONG_LONG) n = count*sizeof(uint64_t);
|
||||
else if (datatype == MPI_DOUBLE_INT) n = count*sizeof(double_int);
|
||||
int n = count * stubtypesize(datatype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
|
@ -300,15 +334,7 @@ int MPI_Reduce(void *sendbuf, void *recvbuf, int count,
|
|||
MPI_Datatype datatype, MPI_Op op,
|
||||
int root, MPI_Comm comm)
|
||||
{
|
||||
int n;
|
||||
if (datatype == MPI_INT) n = count*sizeof(int);
|
||||
else if (datatype == MPI_FLOAT) n = count*sizeof(float);
|
||||
else if (datatype == MPI_DOUBLE) n = count*sizeof(double);
|
||||
else if (datatype == MPI_CHAR) n = count*sizeof(char);
|
||||
else if (datatype == MPI_BYTE) n = count*sizeof(char);
|
||||
else if (datatype == MPI_LONG) n = count*sizeof(long);
|
||||
else if (datatype == MPI_LONG_LONG) n = count*sizeof(uint64_t);
|
||||
else if (datatype == MPI_DOUBLE_INT) n = count*sizeof(double_int);
|
||||
int n = count * stubtypesize(datatype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
|
@ -321,15 +347,7 @@ int MPI_Reduce(void *sendbuf, void *recvbuf, int count,
|
|||
int MPI_Scan(void *sendbuf, void *recvbuf, int count,
|
||||
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
|
||||
{
|
||||
int n;
|
||||
if (datatype == MPI_INT) n = count*sizeof(int);
|
||||
else if (datatype == MPI_FLOAT) n = count*sizeof(float);
|
||||
else if (datatype == MPI_DOUBLE) n = count*sizeof(double);
|
||||
else if (datatype == MPI_CHAR) n = count*sizeof(char);
|
||||
else if (datatype == MPI_BYTE) n = count*sizeof(char);
|
||||
else if (datatype == MPI_LONG) n = count*sizeof(long);
|
||||
else if (datatype == MPI_LONG_LONG) n = count*sizeof(uint64_t);
|
||||
else if (datatype == MPI_DOUBLE_INT) n = count*sizeof(double_int);
|
||||
int n = count * stubtypesize(datatype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
|
@ -344,15 +362,7 @@ int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
|||
void *recvbuf, int recvcount, MPI_Datatype recvtype,
|
||||
MPI_Comm comm)
|
||||
{
|
||||
int n;
|
||||
if (sendtype == MPI_INT) n = sendcount*sizeof(int);
|
||||
else if (sendtype == MPI_FLOAT) n = sendcount*sizeof(float);
|
||||
else if (sendtype == MPI_DOUBLE) n = sendcount*sizeof(double);
|
||||
else if (sendtype == MPI_CHAR) n = sendcount*sizeof(char);
|
||||
else if (sendtype == MPI_BYTE) n = sendcount*sizeof(char);
|
||||
else if (sendtype == MPI_LONG) n = sendcount*sizeof(long);
|
||||
else if (sendtype == MPI_LONG_LONG) n = sendcount*sizeof(uint64_t);
|
||||
else if (sendtype == MPI_DOUBLE_INT) n = sendcount*sizeof(double_int);
|
||||
int n = sendcount * stubtypesize(sendtype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
|
@ -367,15 +377,7 @@ int MPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
|||
void *recvbuf, int *recvcounts, int *displs,
|
||||
MPI_Datatype recvtype, MPI_Comm comm)
|
||||
{
|
||||
int n;
|
||||
if (sendtype == MPI_INT) n = sendcount*sizeof(int);
|
||||
else if (sendtype == MPI_FLOAT) n = sendcount*sizeof(float);
|
||||
else if (sendtype == MPI_DOUBLE) n = sendcount*sizeof(double);
|
||||
else if (sendtype == MPI_CHAR) n = sendcount*sizeof(char);
|
||||
else if (sendtype == MPI_BYTE) n = sendcount*sizeof(char);
|
||||
else if (sendtype == MPI_LONG) n = sendcount*sizeof(long);
|
||||
else if (sendtype == MPI_LONG_LONG) n = sendcount*sizeof(uint64_t);
|
||||
else if (sendtype == MPI_DOUBLE_INT) n = sendcount*sizeof(double_int);
|
||||
int n = sendcount * stubtypesize(sendtype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
|
@ -389,15 +391,7 @@ int MPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
|||
int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
|
||||
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
|
||||
{
|
||||
int n;
|
||||
if (datatype == MPI_INT) n = *recvcounts*sizeof(int);
|
||||
else if (datatype == MPI_FLOAT) n = *recvcounts*sizeof(float);
|
||||
else if (datatype == MPI_DOUBLE) n = *recvcounts*sizeof(double);
|
||||
else if (datatype == MPI_CHAR) n = *recvcounts*sizeof(char);
|
||||
else if (datatype == MPI_BYTE) n = *recvcounts*sizeof(char);
|
||||
else if (datatype == MPI_LONG) n = *recvcounts*sizeof(long);
|
||||
else if (datatype == MPI_LONG_LONG) n = *recvcounts*sizeof(uint64_t);
|
||||
else if (datatype == MPI_DOUBLE_INT) n = *recvcounts*sizeof(double_int);
|
||||
int n = *recvcounts * stubtypesize(datatype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
|
@ -412,15 +406,7 @@ int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
|||
void *recvbuf, int recvcount, MPI_Datatype recvtype,
|
||||
int root, MPI_Comm comm)
|
||||
{
|
||||
int n;
|
||||
if (sendtype == MPI_INT) n = sendcount*sizeof(int);
|
||||
else if (sendtype == MPI_FLOAT) n = sendcount*sizeof(float);
|
||||
else if (sendtype == MPI_DOUBLE) n = sendcount*sizeof(double);
|
||||
else if (sendtype == MPI_CHAR) n = sendcount*sizeof(char);
|
||||
else if (sendtype == MPI_BYTE) n = sendcount*sizeof(char);
|
||||
else if (sendtype == MPI_LONG) n = sendcount*sizeof(long);
|
||||
else if (sendtype == MPI_LONG_LONG) n = sendcount*sizeof(uint64_t);
|
||||
else if (sendtype == MPI_DOUBLE_INT) n = sendcount*sizeof(double_int);
|
||||
int n = sendcount * stubtypesize(sendtype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
|
@ -435,15 +421,7 @@ int MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
|||
void *recvbuf, int *recvcounts, int *displs,
|
||||
MPI_Datatype recvtype, int root, MPI_Comm comm)
|
||||
{
|
||||
int n;
|
||||
if (sendtype == MPI_INT) n = sendcount*sizeof(int);
|
||||
else if (sendtype == MPI_FLOAT) n = sendcount*sizeof(float);
|
||||
else if (sendtype == MPI_DOUBLE) n = sendcount*sizeof(double);
|
||||
else if (sendtype == MPI_CHAR) n = sendcount*sizeof(char);
|
||||
else if (sendtype == MPI_BYTE) n = sendcount*sizeof(char);
|
||||
else if (sendtype == MPI_LONG) n = sendcount*sizeof(long);
|
||||
else if (sendtype == MPI_LONG_LONG) n = sendcount*sizeof(uint64_t);
|
||||
else if (sendtype == MPI_DOUBLE_INT) n = sendcount*sizeof(double_int);
|
||||
int n = sendcount * stubtypesize(sendtype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
|
@ -458,15 +436,7 @@ int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
|||
void *recvbuf, int recvcount, MPI_Datatype recvtype,
|
||||
int root, MPI_Comm comm)
|
||||
{
|
||||
int n;
|
||||
if (sendtype == MPI_INT) n = recvcount*sizeof(int);
|
||||
else if (sendtype == MPI_FLOAT) n = recvcount*sizeof(float);
|
||||
else if (sendtype == MPI_DOUBLE) n = recvcount*sizeof(double);
|
||||
else if (sendtype == MPI_CHAR) n = recvcount*sizeof(char);
|
||||
else if (sendtype == MPI_BYTE) n = recvcount*sizeof(char);
|
||||
else if (sendtype == MPI_LONG) n = recvcount*sizeof(long);
|
||||
else if (sendtype == MPI_LONG_LONG) n = recvcount*sizeof(uint64_t);
|
||||
else if (sendtype == MPI_DOUBLE_INT) n = recvcount*sizeof(double_int);
|
||||
int n = recvcount * stubtypesize(recvtype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
|
@ -482,17 +452,42 @@ int MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
|
|||
MPI_Datatype sendtype, void *recvbuf, int recvcount,
|
||||
MPI_Datatype recvtype, int root, MPI_Comm comm)
|
||||
{
|
||||
int n;
|
||||
if (sendtype == MPI_INT) n = recvcount*sizeof(int);
|
||||
else if (sendtype == MPI_FLOAT) n = recvcount*sizeof(float);
|
||||
else if (sendtype == MPI_DOUBLE) n = recvcount*sizeof(double);
|
||||
else if (sendtype == MPI_CHAR) n = recvcount*sizeof(char);
|
||||
else if (sendtype == MPI_BYTE) n = recvcount*sizeof(char);
|
||||
else if (sendtype == MPI_LONG) n = recvcount*sizeof(long);
|
||||
else if (sendtype == MPI_LONG_LONG) n = recvcount*sizeof(uint64_t);
|
||||
else if (sendtype == MPI_DOUBLE_INT) n = recvcount*sizeof(double_int);
|
||||
int n = recvcount * stubtypesize(recvtype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/* copy values from data1 to data2 */
|
||||
|
||||
int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
||||
void *recvbuf, int recvcount, MPI_Datatype recvtype,
|
||||
MPI_Comm comm)
|
||||
{
|
||||
int n = sendcount * stubtypesize(sendtype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/* copy values from data1 to data2 */
|
||||
|
||||
int MPI_Alltoallv(void *sendbuf, int *sendcounts, int *sdispls,
|
||||
MPI_Datatype sendtype,
|
||||
void *recvbuf, int *recvcounts, int *rdispls,
|
||||
MPI_Datatype recvtype, MPI_Comm comm)
|
||||
{
|
||||
int n = *sendcounts * stubtypesize(sendtype);
|
||||
|
||||
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
|
||||
memcpy(recvbuf,sendbuf,n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
|
||||
#include "stdlib.h"
|
||||
|
||||
#ifdef LMP_MPIIO
|
||||
#error Cannot build serial LAMMPS with MPIIO package
|
||||
#endif
|
||||
|
||||
/* use C bindings for MPI interface */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -30,7 +26,8 @@ extern "C" {
|
|||
|
||||
#define MPI_COMM_WORLD 0
|
||||
|
||||
#define MPI_SUCCESS 0
|
||||
#define MPI_SUCCESS 0
|
||||
#define MPI_ERR_ARG -1
|
||||
|
||||
#define MPI_INT 1
|
||||
#define MPI_FLOAT 2
|
||||
|
@ -50,13 +47,17 @@ extern "C" {
|
|||
|
||||
#define MPI_UNDEFINED -1
|
||||
#define MPI_COMM_NULL -1
|
||||
#define MPI_GROUP_EMPTY -1
|
||||
|
||||
#define MPI_ANY_SOURCE -1
|
||||
#define MPI_STATUS_IGNORE NULL
|
||||
|
||||
#define MPI_Comm int
|
||||
#define MPI_Request int
|
||||
#define MPI_Datatype int
|
||||
#define MPI_Op int
|
||||
#define MPI_Fint int
|
||||
#define MPI_Group int
|
||||
#define MPI_Offset long
|
||||
|
||||
#define MPI_IN_PLACE NULL
|
||||
|
@ -107,6 +108,11 @@ int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count);
|
|||
int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *comm_out);
|
||||
int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *comm_out);
|
||||
int MPI_Comm_free(MPI_Comm *comm);
|
||||
MPI_Fint MPI_Comm_c2f(MPI_Comm comm);
|
||||
MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
|
||||
int MPI_Comm_group(MPI_Comm comm, MPI_Group *group);
|
||||
int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm);
|
||||
int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup);
|
||||
|
||||
int MPI_Cart_create(MPI_Comm comm_old, int ndims, int *dims, int *periods,
|
||||
int reorder, MPI_Comm *comm_cart);
|
||||
|
@ -116,6 +122,7 @@ 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_Barrier(MPI_Comm comm);
|
||||
int MPI_Bcast(void *buf, int count, MPI_Datatype datatype,
|
||||
int root, MPI_Comm comm);
|
||||
|
@ -145,6 +152,14 @@ int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
|||
int MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
|
||||
MPI_Datatype sendtype, void *recvbuf, int recvcount,
|
||||
MPI_Datatype recvtype, int root, MPI_Comm comm);
|
||||
int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
||||
void *recvbuf, int recvcount, MPI_Datatype recvtype,
|
||||
MPI_Comm comm);
|
||||
int MPI_Alltoallv(void *sendbuf, int *sendcounts, int *sdispls,
|
||||
MPI_Datatype sendtype,
|
||||
void *recvbuf, int *recvcounts, int *rdispls,
|
||||
MPI_Datatype recvtype, MPI_Comm comm);
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue