From b3e7f433eec5bfcc5c62cbe343b2d231387ea9ec Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 26 Mar 2009 14:22:39 +0000 Subject: [PATCH] Added --- .gitattributes | 2 ++ src/h5_core/h5_mpi.c | 66 ++++++++++++++++++++++++++++++++++++ src/h5_core/h5_mpi_private.h | 31 +++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 src/h5_core/h5_mpi.c create mode 100644 src/h5_core/h5_mpi_private.h diff --git a/.gitattributes b/.gitattributes index 15431f7..27ad1bd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -390,6 +390,8 @@ src/h5_core/h5_hdf5.c -text src/h5_core/h5_hdf5_private.h -text src/h5_core/h5_maps.c -text src/h5_core/h5_maps.h -text +src/h5_core/h5_mpi.c -text +src/h5_core/h5_mpi_private.h -text src/h5_core/h5_openclose.c -text src/h5_core/h5_openclose.h -text src/h5_core/h5_qsort.c -text diff --git a/src/h5_core/h5_mpi.c b/src/h5_core/h5_mpi.c new file mode 100644 index 0000000..6600c84 --- /dev/null +++ b/src/h5_core/h5_mpi.c @@ -0,0 +1,66 @@ +#include + +#include "h5_core/h5_core.h" +#include "h5_core/h5_core_private.h" + +#ifdef PARALLEL_IO +h5_err_t +_h5_mpi_allgather ( + h5_file_t * const f, + const void * sendbuf, + const int sendcount, + const MPI_Datatype sendtype, + void * recvbuf, + const int recvcount, + const MPI_Datatype recvtype, + const MPI_Comm comm + ) { + int err = MPI_Allgather ( + sendbuf, + sendcount, + sendtype, + recvbuf, + recvcount, + recvtype, + comm ); + if ( err != MPI_SUCCESS ) + return h5_error ( + f, + H5_ERR_MPI, + "Cannot gather data." ); + return H5_SUCCESS; +} + +h5_err_t +_h5_mpi_comm_size ( + h5_file_t * const f, + MPI_comm comm, + int *size + ) { + int err = MPI_Comm_size ( comm, size ); + if ( err != MPI_SUCCESS ) + h5_error ( + f, + H5_ERR_MPI, + "Cannot get number of processes in my group." ); + + return H5_SUCCESS; +} + + +h5_err_t +_h5_mpi_comm_rank ( + h5_file_t * const f, + MPI_comm comm, + int *rank + ) { + int err = MPI_Comm_rank ( comm, rank ); + if ( err != MPI_SUCCESS ) + h5_error ( + f, + H5_ERR_MPI, + "Cannot get rank of the calling process in my group." ); + + return H5_SUCCESS; +} +#endif diff --git a/src/h5_core/h5_mpi_private.h b/src/h5_core/h5_mpi_private.h new file mode 100644 index 0000000..2ae698e --- /dev/null +++ b/src/h5_core/h5_mpi_private.h @@ -0,0 +1,31 @@ +#ifndef __H5_MPI_PRIVATE_H +#define __H5_MPI_PRIVATE_H + +#ifdef PARALLEL_IO +h5_err_t +_h5_mpi_allgather ( + h5_file_t * const f, + const void * sendbuf, + const int sendcount, + const MPI_Datatype sendtype, + void * recvbuf, + const int recvcount, + const MPI_Datatype recvtype, + const MPI_Comm comm + ); + +h5_err_t +_h5_mpi_comm_size ( + h5_file_t * const f, + MPI_comm comm, + int *size + ); + +h5_err_t +_h5_mpi_comm_rank ( + h5_file_t * const f, + MPI_comm comm, + int *rank + ); +#endif +#endif