* C++ MPI bindings. MPI:: only
This commit was SVN r1712.
Этот коммит содержится в:
родитель
ecadbacf2c
Коммит
000644007f
@ -156,6 +156,23 @@ else
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# C++
|
||||
#
|
||||
|
||||
AC_MSG_CHECKING([if want C++ bindings])
|
||||
AC_ARG_ENABLE(cxx,
|
||||
AC_HELP_STRING([--enable-cxx],
|
||||
[enable C++ MPI bindings (default: enabled)]))
|
||||
if test "$enable_cxx" != "no"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
WANT_MPI_CXX_SUPPORT=1
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
WANT_MPI_CXX_SUPPORT=0
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Do we want to disable weak symbols for some reason?
|
||||
#
|
||||
|
@ -281,6 +281,13 @@ AC_CHECK_SIZEOF(bool)
|
||||
OMPI_C_GET_ALIGNMENT(bool, OMPI_ALIGNMENT_CXX_BOOL)
|
||||
AC_LANG_RESTORE
|
||||
|
||||
# check if we want C++ support
|
||||
|
||||
AM_CONDITIONAL(WANT_MPI_CXX_BINDINGS,
|
||||
test "$WANT_MPI_CXX_SUPPORT" = 1)
|
||||
AC_DEFINE_UNQUOTED(OMPI_WANT_CXX_BINDINGS, $WANT_MPI_CXX_SUPPORT,
|
||||
[Whether we want MPI cxx support or not])
|
||||
|
||||
|
||||
##################################
|
||||
# Fortran
|
||||
|
@ -1442,4 +1442,19 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Conditional MPI 2 C++ bindings support. Include if:
|
||||
* - We want C++ bindings support
|
||||
* - We are not building OMPI itself
|
||||
* - We are using a C++ compiler
|
||||
*/
|
||||
|
||||
#if defined(OMPI_WANT_CXX_BINDINGS)
|
||||
#if !defined(OMPI_BUILDING) || !OMPI_BUILDING
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#include "mpi/cxx/mpicxx.h"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* OMPI_MPI_H */
|
||||
|
@ -7,8 +7,6 @@ include $(top_srcdir)/config/Makefile.options
|
||||
|
||||
noinst_LTLIBRARIES = libmpi_bindings.la
|
||||
|
||||
SUBDIRS = c cxx f77 f90
|
||||
|
||||
# See if configure found a valid f77 compiler
|
||||
|
||||
if OMPI_WANT_F77_BINDINGS
|
||||
@ -25,5 +23,13 @@ else
|
||||
f90_lib =
|
||||
endif
|
||||
|
||||
if WANT_MPI_CXX_BINDINGS
|
||||
cxx_lib =
|
||||
else
|
||||
cxx_lib =
|
||||
endif
|
||||
|
||||
SUBDIRS = c cxx f77 f90
|
||||
|
||||
libmpi_bindings_la_SOURCES =
|
||||
libmpi_bindings_la_LIBADD = c/libmpi_c.la $(f77_lib) $(f90_lib)
|
||||
libmpi_bindings_la_LIBADD = c/libmpi_c.la $(f77_lib) $(f90_lib) $(cxx_lib)
|
||||
|
@ -5,5 +5,52 @@
|
||||
|
||||
include $(top_srcdir)/config/Makefile.options
|
||||
|
||||
# JMS: Need more stuff here -- only compile if we're making the C++
|
||||
# profiling layer
|
||||
if WANT_MPI_CXX_BINDINGS
|
||||
|
||||
mpi_lib = libmpi_cxx.la
|
||||
|
||||
lib_LTLIBRARIES = libmpi_cxx.la
|
||||
libmpi_cxx_la_SOURCES = \
|
||||
mpicxx.cc \
|
||||
intercepts.cc \
|
||||
comm.cc
|
||||
|
||||
headers = \
|
||||
mpicxx.h \
|
||||
constants.h \
|
||||
file.h \
|
||||
functions.h \
|
||||
datatype.h \
|
||||
exception.h \
|
||||
op.h \
|
||||
status.h \
|
||||
request.h \
|
||||
group.h \
|
||||
comm.h \
|
||||
errhandler.h \
|
||||
intracomm.h \
|
||||
info.h \
|
||||
win.h \
|
||||
topology.h \
|
||||
intercomm.h \
|
||||
datatype_inln.h \
|
||||
file_inln.h \
|
||||
functions_inln.h \
|
||||
request_inln.h \
|
||||
comm_inln.h \
|
||||
intracomm_inln.h \
|
||||
info_inln.h \
|
||||
win_inln.h \
|
||||
topology_inln.h \
|
||||
intercomm_inln.h \
|
||||
group_inln.h \
|
||||
op_inln.h \
|
||||
errhandler_inln.h \
|
||||
status_inln.h
|
||||
|
||||
ompidir = $(includedir)/ompi/mpi/cxx
|
||||
ompi_HEADERS = \
|
||||
$(headers)
|
||||
else
|
||||
ompidir = $(includedir)
|
||||
endif
|
||||
|
126
src/mpi/cxx/comm.cc
Обычный файл
126
src/mpi/cxx/comm.cc
Обычный файл
@ -0,0 +1,126 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
#include "ompi_config.h"
|
||||
#include "mpi/cxx/mpicxx.h"
|
||||
#include "threads/mutex.h"
|
||||
|
||||
//
|
||||
// These functions are all not inlined because they need to use locks to
|
||||
// protect the handle maps and it would be bad to have those in headers
|
||||
// because that would require that we always install the lock headers.
|
||||
// Instead we take the function call hit (we're locking - who cares about
|
||||
// a function call. And these aren't exactly the performance critical
|
||||
// functions) and make everyone's life easier.
|
||||
//
|
||||
|
||||
|
||||
// construction
|
||||
MPI::Comm::Comm()
|
||||
{
|
||||
if (mpi_comm_map_mutex == NULL)
|
||||
mpi_comm_map_mutex = OBJ_NEW(ompi_mutex_t);
|
||||
if (mpi_err_map_mutex == NULL)
|
||||
mpi_err_map_mutex = OBJ_NEW(ompi_mutex_t);
|
||||
if (key_fn_map_mutex == NULL)
|
||||
key_fn_map_mutex = OBJ_NEW(ompi_mutex_t);
|
||||
}
|
||||
|
||||
// copy
|
||||
MPI::Comm::Comm(const Comm_Null& data) : Comm_Null(data)
|
||||
{
|
||||
if (mpi_comm_map_mutex == NULL)
|
||||
mpi_comm_map_mutex = OBJ_NEW(ompi_mutex_t);
|
||||
if (mpi_err_map_mutex == NULL)
|
||||
mpi_err_map_mutex = OBJ_NEW(ompi_mutex_t);
|
||||
if (key_fn_map_mutex == NULL)
|
||||
key_fn_map_mutex = OBJ_NEW(ompi_mutex_t);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MPI::Comm::Free(void)
|
||||
{
|
||||
MPI_Comm save = mpi_comm;
|
||||
(void)MPI_Comm_free(&mpi_comm);
|
||||
|
||||
OMPI_THREAD_LOCK(mpi_comm_map_mutex);
|
||||
if (MPI::Comm::mpi_comm_map[save] != 0)
|
||||
delete MPI::Comm::mpi_comm_map[save];
|
||||
MPI::Comm::mpi_comm_map.erase(save);
|
||||
OMPI_THREAD_UNLOCK(mpi_comm_map_mutex);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MPI::Comm::Set_errhandler(const MPI::Errhandler& errhandler)
|
||||
{
|
||||
my_errhandler = (MPI::Errhandler *)&errhandler;
|
||||
OMPI_THREAD_LOCK(mpi_err_map_mutex);
|
||||
MPI::Comm::mpi_err_map[mpi_comm] = this;
|
||||
OMPI_THREAD_UNLOCK(mpi_err_map_mutex);
|
||||
(void)MPI_Errhandler_set(mpi_comm, errhandler);
|
||||
}
|
||||
|
||||
|
||||
//JGS I took the const out because it causes problems when trying to
|
||||
//call this function with the predefined NULL_COPY_FN etc.
|
||||
int
|
||||
MPI::Comm::Create_keyval(MPI::Comm::_MPI2CPP_COPYATTRFN_* comm_copy_attr_fn,
|
||||
MPI::Comm::_MPI2CPP_DELETEATTRFN_* comm_delete_attr_fn,
|
||||
void* extra_state)
|
||||
{
|
||||
int keyval;
|
||||
(void)MPI_Keyval_create(copy_attr_intercept, delete_attr_intercept,
|
||||
&keyval, extra_state);
|
||||
key_pair_t* copy_and_delete =
|
||||
new key_pair_t(comm_copy_attr_fn, comm_delete_attr_fn);
|
||||
OMPI_THREAD_LOCK(key_fn_map_mutex);
|
||||
MPI::Comm::key_fn_map[keyval] = copy_and_delete;
|
||||
OMPI_THREAD_UNLOCK(key_fn_map_mutex);
|
||||
return keyval;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MPI::Comm::Free_keyval(int& comm_keyval)
|
||||
{
|
||||
int save = comm_keyval;
|
||||
(void)MPI_Keyval_free(&comm_keyval);
|
||||
OMPI_THREAD_LOCK(key_fn_map_mutex);
|
||||
if (MPI::Comm::key_fn_map[save] != 0)
|
||||
delete MPI::Comm::key_fn_map[save];
|
||||
MPI::Comm::key_fn_map.erase(save);
|
||||
OMPI_THREAD_UNLOCK(key_fn_map_mutex);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MPI::Comm::Set_attr(int comm_keyval, const void* attribute_val) const
|
||||
{
|
||||
CommType type;
|
||||
int status;
|
||||
|
||||
(void)MPI_Comm_test_inter(mpi_comm, &status);
|
||||
if (status) {
|
||||
type = eIntercomm;
|
||||
}
|
||||
else {
|
||||
(void)MPI_Topo_test(mpi_comm, &status);
|
||||
if (status == MPI_CART)
|
||||
type = eCartcomm;
|
||||
else if (status == MPI_GRAPH)
|
||||
type = eGraphcomm;
|
||||
else
|
||||
type = eIntracomm;
|
||||
}
|
||||
OMPI_THREAD_LOCK(mpi_comm_map_mutex);
|
||||
if (MPI::Comm::mpi_comm_map[mpi_comm] == 0) {
|
||||
comm_pair_t* comm_type = new comm_pair_t((Comm*) this, type);
|
||||
MPI::Comm::mpi_comm_map[mpi_comm] = comm_type;
|
||||
}
|
||||
OMPI_THREAD_UNLOCK(mpi_comm_map_mutex);
|
||||
(void)MPI_Attr_put(mpi_comm, comm_keyval, (void*) attribute_val);
|
||||
}
|
356
src/mpi/cxx/comm.h
Обычный файл
356
src/mpi/cxx/comm.h
Обычный файл
@ -0,0 +1,356 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
class Comm_Null {
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// friend class PMPI::Comm_Null;
|
||||
#endif
|
||||
public:
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
// construction
|
||||
inline Comm_Null() { }
|
||||
// copy
|
||||
inline Comm_Null(const Comm_Null& data) : pmpi_comm(data.pmpi_comm) { }
|
||||
// inter-language operability
|
||||
inline Comm_Null(const MPI_Comm& data) : pmpi_comm(data) { }
|
||||
|
||||
inline Comm_Null(const PMPI::Comm_Null& data) : pmpi_comm(data) { }
|
||||
|
||||
// destruction
|
||||
//JGS virtual inline ~Comm_Null() { }
|
||||
|
||||
inline Comm_Null& operator=(const Comm_Null& data) {
|
||||
pmpi_comm = data.pmpi_comm;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// comparison
|
||||
inline bool operator==(const Comm_Null& data) const {
|
||||
return (bool) (pmpi_comm == data.pmpi_comm); }
|
||||
|
||||
inline bool operator!=(const Comm_Null& data) const {
|
||||
return (bool) (pmpi_comm != data.pmpi_comm);}
|
||||
|
||||
// inter-language operability (conversion operators)
|
||||
inline operator MPI_Comm() const { return pmpi_comm; }
|
||||
// inline operator MPI_Comm*() /*const JGS*/ { return pmpi_comm; }
|
||||
inline operator const PMPI::Comm_Null&() const { return pmpi_comm; }
|
||||
|
||||
#else
|
||||
|
||||
// construction
|
||||
inline Comm_Null() : mpi_comm(MPI_COMM_NULL) { }
|
||||
// copy
|
||||
inline Comm_Null(const Comm_Null& data) : mpi_comm(data.mpi_comm) { }
|
||||
// inter-language operability
|
||||
inline Comm_Null(const MPI_Comm& data) : mpi_comm(data) { }
|
||||
|
||||
// destruction
|
||||
//JGS virtual inline ~Comm_Null() { }
|
||||
|
||||
// comparison
|
||||
// JGS make sure this is right (in other classes too)
|
||||
inline bool operator==(const Comm_Null& data) const {
|
||||
return (bool) (mpi_comm == data.mpi_comm); }
|
||||
|
||||
inline bool operator!=(const Comm_Null& data) const {
|
||||
return (bool) !(*this == data);}
|
||||
|
||||
// inter-language operability (conversion operators)
|
||||
inline operator MPI_Comm() const { return mpi_comm; }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
PMPI::Comm_Null pmpi_comm;
|
||||
#else
|
||||
MPI_Comm mpi_comm;
|
||||
#endif
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class Comm : public Comm_Null {
|
||||
public:
|
||||
|
||||
typedef void Errhandler_fn(Comm&, int*, ...);
|
||||
typedef int Copy_attr_function(const Comm& oldcomm, int comm_keyval,
|
||||
void* extra_state, void* attribute_val_in,
|
||||
void* attribute_val_out,
|
||||
bool& flag);
|
||||
typedef int Delete_attr_function(Comm& comm, int comm_keyval,
|
||||
void* attribute_val,
|
||||
void* extra_state);
|
||||
#if !0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
#define _MPI2CPP_ERRHANDLERFN_ Errhandler_fn
|
||||
#define _MPI2CPP_COPYATTRFN_ Copy_attr_function
|
||||
#define _MPI2CPP_DELETEATTRFN_ Delete_attr_function
|
||||
#endif
|
||||
|
||||
// construction
|
||||
Comm();
|
||||
|
||||
// copy
|
||||
Comm(const Comm_Null& data);
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
Comm(const Comm& data) :
|
||||
Comm_Null(data),
|
||||
pmpi_comm((const PMPI::Comm&) data) { }
|
||||
|
||||
// inter-language operability
|
||||
Comm(const MPI_Comm& data) : Comm_Null(data), pmpi_comm(data) { }
|
||||
|
||||
Comm(const PMPI::Comm& data) :
|
||||
Comm_Null((const PMPI::Comm_Null&)data),
|
||||
pmpi_comm(data) { }
|
||||
|
||||
operator const PMPI::Comm&() const { return pmpi_comm; }
|
||||
|
||||
// assignment
|
||||
Comm& operator=(const Comm& data) {
|
||||
this->Comm_Null::operator=(data);
|
||||
pmpi_comm = data.pmpi_comm;
|
||||
return *this;
|
||||
}
|
||||
Comm& operator=(const Comm_Null& data) {
|
||||
this->Comm_Null::operator=(data);
|
||||
MPI_Comm tmp = data;
|
||||
pmpi_comm = tmp;
|
||||
return *this;
|
||||
}
|
||||
// inter-language operability
|
||||
Comm& operator=(const MPI_Comm& data) {
|
||||
this->Comm_Null::operator=(data);
|
||||
pmpi_comm = data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#else
|
||||
Comm(const Comm& data) : Comm_Null(data.mpi_comm) { }
|
||||
// inter-language operability
|
||||
Comm(const MPI_Comm& data) : Comm_Null(data) { }
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Point-to-Point
|
||||
//
|
||||
|
||||
virtual void Send(const void *buf, int count,
|
||||
const Datatype & datatype, int dest, int tag) const;
|
||||
|
||||
virtual void Recv(void *buf, int count, const Datatype & datatype,
|
||||
int source, int tag, Status & status) const;
|
||||
|
||||
|
||||
virtual void Recv(void *buf, int count, const Datatype & datatype,
|
||||
int source, int tag) const;
|
||||
|
||||
virtual void Bsend(const void *buf, int count,
|
||||
const Datatype & datatype, int dest, int tag) const;
|
||||
|
||||
virtual void Ssend(const void *buf, int count,
|
||||
const Datatype & datatype, int dest, int tag) const ;
|
||||
|
||||
virtual void Rsend(const void *buf, int count,
|
||||
const Datatype & datatype, int dest, int tag) const;
|
||||
|
||||
virtual Request Isend(const void *buf, int count,
|
||||
const Datatype & datatype, int dest, int tag) const;
|
||||
|
||||
virtual Request Ibsend(const void *buf, int count, const
|
||||
Datatype & datatype, int dest, int tag) const;
|
||||
|
||||
virtual Request Issend(const void *buf, int count,
|
||||
const Datatype & datatype, int dest, int tag) const;
|
||||
|
||||
virtual Request Irsend(const void *buf, int count,
|
||||
const Datatype & datatype, int dest, int tag) const;
|
||||
|
||||
virtual Request Irecv(void *buf, int count,
|
||||
const Datatype & datatype, int source, int tag) const;
|
||||
|
||||
virtual bool Iprobe(int source, int tag, Status & status) const;
|
||||
|
||||
virtual bool Iprobe(int source, int tag) const;
|
||||
|
||||
virtual void Probe(int source, int tag, Status & status) const;
|
||||
|
||||
virtual void Probe(int source, int tag) const;
|
||||
|
||||
virtual Prequest Send_init(const void *buf, int count,
|
||||
const Datatype & datatype, int dest,
|
||||
int tag) const;
|
||||
|
||||
virtual Prequest Bsend_init(const void *buf, int count,
|
||||
const Datatype & datatype, int dest,
|
||||
int tag) const;
|
||||
|
||||
virtual Prequest Ssend_init(const void *buf, int count,
|
||||
const Datatype & datatype, int dest,
|
||||
int tag) const;
|
||||
|
||||
virtual Prequest Rsend_init(const void *buf, int count,
|
||||
const Datatype & datatype, int dest,
|
||||
int tag) const;
|
||||
|
||||
virtual Prequest Recv_init(void *buf, int count,
|
||||
const Datatype & datatype, int source,
|
||||
int tag) const;
|
||||
|
||||
virtual void Sendrecv(const void *sendbuf, int sendcount,
|
||||
const Datatype & sendtype, int dest, int sendtag,
|
||||
void *recvbuf, int recvcount,
|
||||
const Datatype & recvtype, int source,
|
||||
int recvtag, Status & status) const;
|
||||
|
||||
virtual void Sendrecv(const void *sendbuf, int sendcount,
|
||||
const Datatype & sendtype, int dest, int sendtag,
|
||||
void *recvbuf, int recvcount,
|
||||
const Datatype & recvtype, int source,
|
||||
int recvtag) const;
|
||||
|
||||
virtual void Sendrecv_replace(void *buf, int count,
|
||||
const Datatype & datatype, int dest,
|
||||
int sendtag, int source,
|
||||
int recvtag, Status & status) const;
|
||||
|
||||
virtual void Sendrecv_replace(void *buf, int count,
|
||||
const Datatype & datatype, int dest,
|
||||
int sendtag, int source,
|
||||
int recvtag) const;
|
||||
|
||||
//
|
||||
// Groups, Contexts, and Communicators
|
||||
//
|
||||
|
||||
virtual Group Get_group() const;
|
||||
|
||||
virtual int Get_size() const;
|
||||
|
||||
virtual int Get_rank() const;
|
||||
|
||||
static int Compare(const Comm & comm1, const Comm & comm2);
|
||||
|
||||
virtual Comm& Clone() const = 0;
|
||||
|
||||
virtual void Free(void);
|
||||
|
||||
virtual bool Is_inter() const;
|
||||
|
||||
|
||||
//
|
||||
// Process Creation
|
||||
//
|
||||
|
||||
virtual void Disconnect();
|
||||
|
||||
static Intercomm Get_parent();
|
||||
|
||||
static Intercomm Join(const int fd);
|
||||
|
||||
//
|
||||
//External Interfaces
|
||||
//
|
||||
|
||||
virtual void Get_name(char * comm_name, int& resultlen) const;
|
||||
|
||||
virtual void Set_name(const char* comm_name);
|
||||
|
||||
//
|
||||
//Process Topologies
|
||||
//
|
||||
|
||||
virtual int Get_topology() const;
|
||||
|
||||
//
|
||||
// Environmental Inquiry
|
||||
//
|
||||
|
||||
virtual void Abort(int errorcode);
|
||||
|
||||
//
|
||||
// Errhandler
|
||||
//
|
||||
|
||||
virtual void Set_errhandler(const Errhandler& errhandler);
|
||||
|
||||
virtual Errhandler Get_errhandler() const;
|
||||
|
||||
//JGS took out const below from fn arg
|
||||
static Errhandler Create_errhandler(Comm::Errhandler_fn* function);
|
||||
|
||||
//
|
||||
// Keys and Attributes
|
||||
//
|
||||
|
||||
//JGS I took the const out because it causes problems when trying to
|
||||
//call this function with the predefined NULL_COPY_FN etc.
|
||||
static int Create_keyval(Copy_attr_function* comm_copy_attr_fn,
|
||||
Delete_attr_function* comm_delete_attr_fn,
|
||||
void* extra_state);
|
||||
|
||||
static void Free_keyval(int& comm_keyval);
|
||||
|
||||
virtual void Set_attr(int comm_keyval, const void* attribute_val) const;
|
||||
|
||||
virtual bool Get_attr(int comm_keyval, void* attribute_val) const;
|
||||
|
||||
virtual void Delete_attr(int comm_keyval);
|
||||
|
||||
static int NULL_COPY_FN(const Comm& oldcomm, int comm_keyval,
|
||||
void* extra_state, void* attribute_val_in,
|
||||
void* attribute_val_out, bool& flag);
|
||||
|
||||
static int DUP_FN(const Comm& oldcomm, int comm_keyval,
|
||||
void* extra_state, void* attribute_val_in,
|
||||
void* attribute_val_out, bool& flag);
|
||||
|
||||
static int NULL_DELETE_FN(Comm& comm, int comm_keyval, void* attribute_val,
|
||||
void* extra_state);
|
||||
|
||||
|
||||
//#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// virtual const PMPI::Comm& get_pmpi_comm() const { return pmpi_comm; }
|
||||
//#endif
|
||||
|
||||
private:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
PMPI::Comm pmpi_comm;
|
||||
#endif
|
||||
|
||||
#if ! 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
public: // JGS hmmm, these used by errhandler_intercept
|
||||
// should make it a friend
|
||||
|
||||
Errhandler* my_errhandler;
|
||||
|
||||
typedef ::std::pair<Comm*, CommType> comm_pair_t;
|
||||
typedef ::std::map<MPI_Comm, comm_pair_t*> mpi_comm_map_t;
|
||||
static mpi_comm_map_t mpi_comm_map;
|
||||
static ompi_mutex_t *mpi_comm_map_mutex;
|
||||
|
||||
typedef ::std::map<MPI_Comm, Comm*> mpi_err_map_t;
|
||||
static mpi_err_map_t mpi_err_map;
|
||||
static ompi_mutex_t *mpi_err_map_mutex;
|
||||
|
||||
typedef ::std::pair<Comm::_MPI2CPP_COPYATTRFN_*, Comm::_MPI2CPP_DELETEATTRFN_*> key_pair_t;
|
||||
typedef ::std::map<int, key_pair_t*> key_fn_map_t;
|
||||
static key_fn_map_t key_fn_map;
|
||||
static ompi_mutex_t *key_fn_map_mutex;
|
||||
|
||||
void init() {
|
||||
my_errhandler = (Errhandler*)0;
|
||||
}
|
||||
#endif
|
||||
|
||||
};
|
460
src/mpi/cxx/comm_inln.h
Обычный файл
460
src/mpi/cxx/comm_inln.h
Обычный файл
@ -0,0 +1,460 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
//
|
||||
// Point-to-Point
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Comm::Send(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
(void)MPI_Send((void *)buf, count, datatype, dest, tag, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Recv(void *buf, int count, const MPI::Datatype & datatype,
|
||||
int source, int tag, MPI::Status & status) const
|
||||
{
|
||||
(void)MPI_Recv(buf, count, datatype, source, tag, mpi_comm, &status.mpi_status);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Recv(void *buf, int count, const MPI::Datatype & datatype,
|
||||
int source, int tag) const
|
||||
{
|
||||
(void)MPI_Recv(buf, count, datatype, source,
|
||||
tag, mpi_comm, MPI_STATUS_IGNORE);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Bsend(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
(void)MPI_Bsend((void *)buf, count, datatype,
|
||||
dest, tag, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Ssend(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
(void)MPI_Ssend((void *)buf, count, datatype, dest,
|
||||
tag, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Rsend(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
(void)MPI_Rsend((void *)buf, count, datatype,
|
||||
dest, tag, mpi_comm);
|
||||
}
|
||||
|
||||
inline MPI::Request
|
||||
MPI::Comm::Isend(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
MPI_Request request;
|
||||
(void)MPI_Isend((void *)buf, count, datatype,
|
||||
dest, tag, mpi_comm, &request);
|
||||
return request;
|
||||
}
|
||||
|
||||
inline MPI::Request
|
||||
MPI::Comm::Ibsend(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
MPI_Request request;
|
||||
(void)MPI_Ibsend((void *)buf, count, datatype,
|
||||
dest, tag, mpi_comm, &request);
|
||||
return request;
|
||||
}
|
||||
|
||||
inline MPI::Request
|
||||
MPI::Comm::Issend(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
MPI_Request request;
|
||||
(void)MPI_Issend((void *)buf, count, datatype,
|
||||
dest, tag, mpi_comm, &request);
|
||||
return request;
|
||||
}
|
||||
|
||||
inline MPI::Request
|
||||
MPI::Comm::Irsend(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
MPI_Request request;
|
||||
(void)MPI_Irsend((void *) buf, count, datatype,
|
||||
dest, tag, mpi_comm, &request);
|
||||
return request;
|
||||
}
|
||||
|
||||
inline MPI::Request
|
||||
MPI::Comm::Irecv(void *buf, int count,
|
||||
const MPI::Datatype & datatype, int source, int tag) const
|
||||
{
|
||||
MPI_Request request;
|
||||
(void)MPI_Irecv(buf, count, datatype, source,
|
||||
tag, mpi_comm, &request);
|
||||
return request;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
MPI::Comm::Iprobe(int source, int tag, MPI::Status & status) const
|
||||
{
|
||||
int t;
|
||||
(void)MPI_Iprobe(source, tag, mpi_comm, &t, &status.mpi_status);
|
||||
return (bool) t;
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Comm::Iprobe(int source, int tag) const
|
||||
{
|
||||
int t;
|
||||
(void)MPI_Iprobe(source, tag, mpi_comm, &t, MPI_STATUS_IGNORE);
|
||||
return (bool) t;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Probe(int source, int tag, MPI::Status & status) const
|
||||
{
|
||||
(void)MPI_Probe(source, tag, mpi_comm, &status.mpi_status);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Probe(int source, int tag) const
|
||||
{
|
||||
(void)MPI_Probe(source, tag, mpi_comm, MPI_STATUS_IGNORE);
|
||||
}
|
||||
|
||||
inline MPI::Prequest
|
||||
MPI::Comm::Send_init(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
MPI_Request request;
|
||||
(void)MPI_Send_init((void *)buf, count, datatype,
|
||||
dest, tag, mpi_comm, &request);
|
||||
return request;
|
||||
}
|
||||
|
||||
inline MPI::Prequest
|
||||
MPI::Comm::Bsend_init(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
MPI_Request request;
|
||||
(void)MPI_Bsend_init((void *)buf, count, datatype,
|
||||
dest, tag, mpi_comm, &request);
|
||||
return request;
|
||||
}
|
||||
|
||||
inline MPI::Prequest
|
||||
MPI::Comm::Ssend_init(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
MPI_Request request;
|
||||
(void)MPI_Ssend_init((void *)buf, count, datatype,
|
||||
dest, tag, mpi_comm, &request);
|
||||
return request;
|
||||
}
|
||||
|
||||
inline MPI::Prequest
|
||||
MPI::Comm::Rsend_init(const void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest, int tag) const
|
||||
{
|
||||
MPI_Request request;
|
||||
(void)MPI_Rsend_init((void *)buf, count, datatype,
|
||||
dest, tag, mpi_comm, &request);
|
||||
return request;
|
||||
}
|
||||
|
||||
inline MPI::Prequest
|
||||
MPI::Comm::Recv_init(void *buf, int count,
|
||||
const MPI::Datatype & datatype, int source, int tag) const
|
||||
{
|
||||
MPI_Request request;
|
||||
(void)MPI_Recv_init(buf, count, datatype, source,
|
||||
tag, mpi_comm, &request);
|
||||
return request;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Sendrecv(const void *sendbuf, int sendcount,
|
||||
const MPI::Datatype & sendtype, int dest, int sendtag,
|
||||
void *recvbuf, int recvcount,
|
||||
const MPI::Datatype & recvtype, int source,
|
||||
int recvtag, MPI::Status & status) const
|
||||
{
|
||||
(void)MPI_Sendrecv((void *)sendbuf, sendcount,
|
||||
sendtype,
|
||||
dest, sendtag, recvbuf, recvcount,
|
||||
recvtype,
|
||||
source, recvtag, mpi_comm, &status.mpi_status);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Sendrecv(const void *sendbuf, int sendcount,
|
||||
const MPI::Datatype & sendtype, int dest, int sendtag,
|
||||
void *recvbuf, int recvcount,
|
||||
const MPI::Datatype & recvtype, int source,
|
||||
int recvtag) const
|
||||
{
|
||||
(void)MPI_Sendrecv((void *)sendbuf, sendcount,
|
||||
sendtype,
|
||||
dest, sendtag, recvbuf, recvcount,
|
||||
recvtype,
|
||||
source, recvtag, mpi_comm, MPI_STATUS_IGNORE);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Sendrecv_replace(void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest,
|
||||
int sendtag, int source,
|
||||
int recvtag, MPI::Status & status) const
|
||||
{
|
||||
(void)MPI_Sendrecv_replace(buf, count, datatype, dest,
|
||||
sendtag, source, recvtag, mpi_comm,
|
||||
&status.mpi_status);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Sendrecv_replace(void *buf, int count,
|
||||
const MPI::Datatype & datatype, int dest,
|
||||
int sendtag, int source,
|
||||
int recvtag) const
|
||||
{
|
||||
(void)MPI_Sendrecv_replace(buf, count, datatype, dest,
|
||||
sendtag, source, recvtag, mpi_comm,
|
||||
MPI_STATUS_IGNORE);
|
||||
}
|
||||
|
||||
//
|
||||
// Groups, Contexts, and Communicators
|
||||
//
|
||||
|
||||
inline MPI::Group
|
||||
MPI::Comm::Get_group() const
|
||||
{
|
||||
MPI_Group group;
|
||||
(void)MPI_Comm_group(mpi_comm, &group);
|
||||
return group;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Comm::Get_size() const
|
||||
{
|
||||
int size;
|
||||
(void)MPI_Comm_size (mpi_comm, &size);
|
||||
return size;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Comm::Get_rank() const
|
||||
{
|
||||
int rank;
|
||||
(void)MPI_Comm_rank (mpi_comm, &rank);
|
||||
return rank;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Comm::Compare(const MPI::Comm & comm1,
|
||||
const MPI::Comm & comm2)
|
||||
{
|
||||
int result;
|
||||
(void)MPI_Comm_compare(comm1, comm2, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
MPI::Comm::Is_inter() const
|
||||
{
|
||||
int t;
|
||||
(void)MPI_Comm_test_inter(mpi_comm, &t);
|
||||
return (bool) t;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Process Creation and Managemnt
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Comm::Disconnect()
|
||||
{
|
||||
(void) MPI_Comm_disconnect(&mpi_comm);
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Comm::Get_parent()
|
||||
{
|
||||
MPI_Comm parent;
|
||||
MPI_Comm_get_parent(&parent);
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Comm::Join(const int fd)
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void) MPI_Comm_join((int) fd, &newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
//
|
||||
// External Interfaces
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Comm::Get_name(char* comm_name, int& resultlen) const
|
||||
{
|
||||
(void) MPI_Comm_get_name(mpi_comm, comm_name, &resultlen);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Set_name(const char* comm_name)
|
||||
{
|
||||
(void) MPI_Comm_set_name(mpi_comm, (char *)comm_name);
|
||||
}
|
||||
|
||||
//
|
||||
//Process Topologies
|
||||
//
|
||||
|
||||
inline int
|
||||
MPI::Comm::Get_topology() const
|
||||
{
|
||||
int status;
|
||||
(void)MPI_Topo_test(mpi_comm, &status);
|
||||
return status;
|
||||
}
|
||||
|
||||
//
|
||||
// Environmental Inquiry
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Comm::Abort(int errorcode)
|
||||
{
|
||||
(void)MPI_Abort(mpi_comm, errorcode);
|
||||
}
|
||||
|
||||
//
|
||||
// These C++ bindings are for MPI-2.
|
||||
// The MPI-1.2 functions called below are all
|
||||
// going to be deprecated and replaced in MPI-2.
|
||||
//
|
||||
|
||||
inline MPI::Errhandler
|
||||
MPI::Comm::Get_errhandler() const
|
||||
{
|
||||
return *my_errhandler;
|
||||
}
|
||||
|
||||
inline MPI::Errhandler
|
||||
MPI::Comm::Create_errhandler(MPI::Comm::_MPI2CPP_ERRHANDLERFN_* function)
|
||||
{
|
||||
MPI_Errhandler errhandler;
|
||||
// $%%@#%# AIX/POE 2.3.0.0 makes us put in this cast here
|
||||
(void)MPI_Errhandler_create((MPI_Handler_function*) errhandler_intercept,
|
||||
&errhandler);
|
||||
MPI::Errhandler temp(errhandler);
|
||||
temp.handler_fn = (void(*)(MPI::Comm&, int*, ...))function;
|
||||
return temp;
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Comm::Get_attr(int comm_keyval, void* attribute_val) const
|
||||
{
|
||||
int flag;
|
||||
(void)MPI_Attr_get(mpi_comm, comm_keyval, attribute_val, &flag);
|
||||
return (bool)flag;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Comm::Delete_attr(int comm_keyval)
|
||||
{
|
||||
(void)MPI_Attr_delete(mpi_comm, comm_keyval);
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Comm::NULL_COPY_FN(const MPI::Comm& oldcomm, int comm_keyval,
|
||||
void* extra_state, void* attribute_val_in,
|
||||
void* attribute_val_out, bool& flag)
|
||||
{
|
||||
#if SIZEOF_BOOL != SIZEOF_INT
|
||||
int f = (int)flag;
|
||||
int ret;
|
||||
if (MPI_NULL_COPY_FN != 0) {
|
||||
|
||||
// Portland pgCC 5.0-2 has a bug that we have to workaround here.
|
||||
// MPI_NULL_COPY_FN is actually a #define for ((MPI_Copy_function
|
||||
// *) 0). If we try to invoke it, such as:
|
||||
// ret = MPI_NULL_COPY_FN(...);
|
||||
// the preprocessor will resolve this to:
|
||||
// ret = ((MPI_Copy_function *) 0)(...);
|
||||
// which should be fine. But unfortunately, pgCC 5.0-2 makes this
|
||||
// into a real symbol that will refuse to link. The workaround is
|
||||
// to assign this into a temp variable and then invoke through the
|
||||
// function pointer. This shouldn't be necessary. :-(
|
||||
|
||||
MPI_Copy_function *stupid_compiler = MPI_NULL_COPY_FN;
|
||||
ret = stupid_compiler(oldcomm, comm_keyval, extra_state, attribute_val_in,
|
||||
attribute_val_out, &f);
|
||||
flag = (bool)f;
|
||||
} else {
|
||||
ret = MPI_SUCCESS;
|
||||
flag = true;
|
||||
}
|
||||
return ret;
|
||||
#else
|
||||
if (MPI_NULL_COPY_FN != 0) {
|
||||
|
||||
// See note above.
|
||||
|
||||
MPI_Copy_function *stupid_compiler = MPI_NULL_COPY_FN;
|
||||
return stupid_compiler(oldcomm, comm_keyval, extra_state,
|
||||
attribute_val_in, attribute_val_out, (int*)&flag);
|
||||
} else
|
||||
return MPI_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Comm::DUP_FN(const MPI::Comm& oldcomm, int comm_keyval,
|
||||
void* extra_state, void* attribute_val_in,
|
||||
void* attribute_val_out, bool& flag)
|
||||
{
|
||||
#if SIZEOF_BOOL != SIZEOF_INT
|
||||
int f = (int)flag;
|
||||
int ret;
|
||||
ret = MPI_DUP_FN(oldcomm, comm_keyval, extra_state, attribute_val_in,
|
||||
attribute_val_out, &f);
|
||||
flag = (bool) f;
|
||||
return ret;
|
||||
#else
|
||||
return MPI_DUP_FN(oldcomm, comm_keyval, extra_state, attribute_val_in,
|
||||
attribute_val_out, (int*)&flag);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Comm::NULL_DELETE_FN(MPI::Comm& comm, int comm_keyval, void* attribute_val,
|
||||
void* extra_state)
|
||||
{
|
||||
if (MPI_NULL_DELETE_FN != 0) {
|
||||
|
||||
// See note in MPI_NULL_COPY_FN.
|
||||
|
||||
MPI_Delete_function *stupid_compiler = MPI_NULL_DELETE_FN;
|
||||
return stupid_compiler(comm, comm_keyval, attribute_val, extra_state);
|
||||
} else
|
||||
return MPI_SUCCESS;
|
||||
}
|
||||
|
210
src/mpi/cxx/constants.h
Обычный файл
210
src/mpi/cxx/constants.h
Обычный файл
@ -0,0 +1,210 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
// return codes
|
||||
extern const int SUCCESS;
|
||||
extern const int ERR_BUFFER;
|
||||
extern const int ERR_COUNT;
|
||||
extern const int ERR_TYPE;
|
||||
extern const int ERR_TAG ;
|
||||
extern const int ERR_COMM;
|
||||
extern const int ERR_RANK;
|
||||
extern const int ERR_REQUEST;
|
||||
extern const int ERR_ROOT;
|
||||
extern const int ERR_GROUP;
|
||||
extern const int ERR_OP;
|
||||
extern const int ERR_TOPOLOGY;
|
||||
extern const int ERR_DIMS;
|
||||
extern const int ERR_ARG;
|
||||
extern const int ERR_UNKNOWN;
|
||||
extern const int ERR_TRUNCATE;
|
||||
extern const int ERR_OTHER;
|
||||
extern const int ERR_INTERN;
|
||||
extern const int ERR_PENDING;
|
||||
extern const int ERR_IN_STATUS;
|
||||
extern const int ERR_LASTCODE;
|
||||
|
||||
extern const int ERR_BASE;
|
||||
extern const int ERR_INFO_VALUE;
|
||||
extern const int ERR_INFO_KEY;
|
||||
extern const int ERR_INFO_NOKEY;
|
||||
extern const int ERR_KEYVAL;
|
||||
extern const int ERR_NAME;
|
||||
extern const int ERR_NO_MEM;
|
||||
extern const int ERR_SERVICE;
|
||||
extern const int ERR_SPAWN;
|
||||
extern const int ERR_WIN;
|
||||
|
||||
|
||||
// assorted constants
|
||||
extern const void* BOTTOM;
|
||||
extern const int PROC_NULL;
|
||||
extern const int ANY_SOURCE;
|
||||
extern const int ANY_TAG;
|
||||
extern const int UNDEFINED;
|
||||
extern const int BSEND_OVERHEAD;
|
||||
extern const int KEYVAL_INVALID;
|
||||
|
||||
// error-handling specifiers
|
||||
extern const Errhandler ERRORS_ARE_FATAL;
|
||||
extern const Errhandler ERRORS_RETURN;
|
||||
extern const Errhandler ERRORS_THROW_EXCEPTIONS;
|
||||
|
||||
// maximum sizes for strings
|
||||
extern const int MAX_PROCESSOR_NAME;
|
||||
extern const int MAX_ERROR_STRING;
|
||||
extern const int MAX_INFO_KEY;
|
||||
extern const int MAX_INFO_VAL;
|
||||
extern const int MAX_PORT_NAME;
|
||||
extern const int MAX_OBJECT_NAME;
|
||||
|
||||
// elementary datatypes (C / C++)
|
||||
extern const Datatype CHAR;
|
||||
extern const Datatype SHORT;
|
||||
extern const Datatype INT;
|
||||
extern const Datatype LONG;
|
||||
extern const Datatype SIGNED_CHAR;
|
||||
extern const Datatype UNSIGNED_CHAR;
|
||||
extern const Datatype UNSIGNED_SHORT;
|
||||
extern const Datatype UNSIGNED;
|
||||
extern const Datatype UNSIGNED_LONG;
|
||||
extern const Datatype FLOAT;
|
||||
extern const Datatype DOUBLE;
|
||||
extern const Datatype LONG_DOUBLE;
|
||||
extern const Datatype BYTE;
|
||||
extern const Datatype PACKED;
|
||||
extern const Datatype WCHAR;
|
||||
|
||||
// datatypes for reductions functions (C / C++)
|
||||
extern const Datatype FLOAT_INT;
|
||||
extern const Datatype DOUBLE_INT;
|
||||
extern const Datatype LONG_INT;
|
||||
extern const Datatype TWOINT;
|
||||
extern const Datatype SHORT_INT;
|
||||
extern const Datatype LONG_DOUBLE_INT;
|
||||
|
||||
// elementary datatype (Fortran)
|
||||
extern const Datatype INTEGER;
|
||||
extern const Datatype REAL;
|
||||
extern const Datatype DOUBLE_PRECISION;
|
||||
extern const Datatype F_COMPLEX;
|
||||
extern const Datatype LOGICAL;
|
||||
extern const Datatype CHARACTER;
|
||||
|
||||
// datatype for reduction functions (Fortran)
|
||||
extern const Datatype TWOREAL;
|
||||
extern const Datatype TWODOUBLE_PRECISION;
|
||||
extern const Datatype TWOINTEGER;
|
||||
|
||||
// optional datatypes (Fortran)
|
||||
extern const Datatype INTEGER1;
|
||||
extern const Datatype INTEGER2;
|
||||
extern const Datatype INTEGER4;
|
||||
extern const Datatype REAL2;
|
||||
extern const Datatype REAL4;
|
||||
extern const Datatype REAL8;
|
||||
|
||||
// optional datatype (C / C++)
|
||||
extern const Datatype LONG_LONG;
|
||||
extern const Datatype UNSIGNED_LONG_LONG;
|
||||
|
||||
// c++ types
|
||||
extern const Datatype BOOL;
|
||||
extern const Datatype COMPLEX;
|
||||
extern const Datatype DOUBLE_COMPLEX;
|
||||
extern const Datatype LONG_DOUBLE_COMPLEX;
|
||||
|
||||
// special datatypes for contstruction of derived datatypes
|
||||
extern const Datatype UB;
|
||||
extern const Datatype LB;
|
||||
|
||||
// datatype decoding constants
|
||||
extern const int COMBINER_NAMED;
|
||||
extern const int COMBINER_DUP;
|
||||
extern const int COMBINER_CONTIGUOUS;
|
||||
extern const int COMBINER_VECTOR;
|
||||
extern const int COMBINER_HVECTOR_INTEGER;
|
||||
extern const int COMBINER_HVECTOR;
|
||||
extern const int COMBINER_INDEXED;
|
||||
extern const int COMBINER_HINDEXED_INTEGER;
|
||||
extern const int COMBINER_HINDEXED;
|
||||
extern const int COMBINER_INDEXED_BLOCK;
|
||||
extern const int COMBINER_STRUCT_INTEGER;
|
||||
extern const int COMBINER_STRUCT;
|
||||
extern const int COMBINER_SUBARRAY;
|
||||
extern const int COMBINER_DARRAY;
|
||||
extern const int COMBINER_F90_REAL;
|
||||
extern const int COMBINER_F90_COMPLEX;
|
||||
extern const int COMBINER_F90_INTEGER;
|
||||
extern const int COMBINER_RESIZED;
|
||||
|
||||
// thread constants
|
||||
extern const int THREAD_SINGLE;
|
||||
extern const int THREAD_FUNNELED;
|
||||
extern const int THREAD_SERIALIZED;
|
||||
extern const int THREAD_MULTIPLE;
|
||||
|
||||
// reserved communicators
|
||||
// JGS these can not be const because Set_errhandler is not const
|
||||
extern Intracomm COMM_WORLD;
|
||||
extern Intracomm COMM_SELF;
|
||||
|
||||
// results of communicator and group comparisons
|
||||
extern const int IDENT;
|
||||
extern const int CONGRUENT;
|
||||
extern const int SIMILAR;
|
||||
extern const int UNEQUAL;
|
||||
|
||||
// environmental inquiry keys
|
||||
extern const int TAG_UB;
|
||||
extern const int IO;
|
||||
extern const int HOST;
|
||||
extern const int WTIME_IS_GLOBAL;
|
||||
extern const int UNIVERSE_SIZE;
|
||||
extern const int APPNUM;
|
||||
extern const int WIN_BASE;
|
||||
extern const int WIN_SIZE;
|
||||
extern const int WIN_DISP_UNIT;
|
||||
|
||||
// collective operations
|
||||
extern const Op MAX;
|
||||
extern const Op MIN;
|
||||
extern const Op SUM;
|
||||
extern const Op PROD;
|
||||
extern const Op MAXLOC;
|
||||
extern const Op MINLOC;
|
||||
extern const Op BAND;
|
||||
extern const Op BOR;
|
||||
extern const Op BXOR;
|
||||
extern const Op LAND;
|
||||
extern const Op LOR;
|
||||
extern const Op LXOR;
|
||||
extern const Op REPLACE;
|
||||
|
||||
// null handles
|
||||
extern const Group GROUP_NULL;
|
||||
extern const Win WIN_NULL;
|
||||
extern const Info INFO_NULL;
|
||||
//extern const Comm COMM_NULL;
|
||||
//extern const MPI_Comm COMM_NULL;
|
||||
extern Comm_Null COMM_NULL;
|
||||
extern const Datatype DATATYPE_NULL;
|
||||
extern Request REQUEST_NULL;
|
||||
extern const Op OP_NULL;
|
||||
extern const Errhandler ERRHANDLER_NULL;
|
||||
|
||||
// constants specifying empty or ignored input
|
||||
extern const char** ARGV_NULL;
|
||||
extern const char*** ARGVS_NULL;
|
||||
|
||||
// empty group
|
||||
extern const Group GROUP_EMPTY;
|
||||
|
||||
// topologies
|
||||
extern const int GRAPH;
|
||||
extern const int CART;
|
||||
|
||||
|
183
src/mpi/cxx/datatype.h
Обычный файл
183
src/mpi/cxx/datatype.h
Обычный файл
@ -0,0 +1,183 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
class Datatype {
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// friend class PMPI::Datatype;
|
||||
#endif
|
||||
public:
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
// construction
|
||||
inline Datatype() { }
|
||||
|
||||
// inter-language operability
|
||||
inline Datatype(const MPI_Datatype &i) : pmpi_datatype(i) { }
|
||||
|
||||
// copy / assignment
|
||||
inline Datatype(const Datatype& dt) : pmpi_datatype(dt.pmpi_datatype) { }
|
||||
|
||||
inline Datatype(const PMPI::Datatype& dt) : pmpi_datatype(dt) { }
|
||||
|
||||
inline virtual ~Datatype() {}
|
||||
|
||||
inline Datatype& operator=(const Datatype& dt) {
|
||||
pmpi_datatype = dt.pmpi_datatype; return *this; }
|
||||
|
||||
// comparison
|
||||
inline bool operator== (const Datatype &a) const
|
||||
{ return (bool) (pmpi_datatype == a.pmpi_datatype); }
|
||||
|
||||
inline bool operator!= (const Datatype &a) const
|
||||
{ return (bool) !(*this == a); }
|
||||
|
||||
// inter-language operability
|
||||
inline Datatype& operator= (const MPI_Datatype &i)
|
||||
{ pmpi_datatype = i; return *this; }
|
||||
|
||||
inline operator MPI_Datatype() const { return (MPI_Datatype)pmpi_datatype; }
|
||||
// inline operator MPI_Datatype* ()/* JGS const */ { return pmpi_datatype; }
|
||||
|
||||
inline operator const PMPI::Datatype&() const { return pmpi_datatype; }
|
||||
|
||||
inline const PMPI::Datatype& pmpi() const { return pmpi_datatype; }
|
||||
|
||||
#else
|
||||
|
||||
// construction / destruction
|
||||
inline Datatype() : mpi_datatype(MPI_DATATYPE_NULL) { }
|
||||
inline virtual ~Datatype() {}
|
||||
// inter-language operability
|
||||
inline Datatype(const MPI_Datatype &i) : mpi_datatype(i) { }
|
||||
|
||||
// copy / assignment
|
||||
inline Datatype(const Datatype& dt) : mpi_datatype(dt.mpi_datatype) { }
|
||||
inline Datatype& operator=(const Datatype& dt) {
|
||||
mpi_datatype = dt.mpi_datatype; return *this; }
|
||||
|
||||
// comparison
|
||||
inline bool operator== (const Datatype &a) const
|
||||
{ return (bool) (mpi_datatype == a.mpi_datatype); }
|
||||
|
||||
inline bool operator!= (const Datatype &a) const
|
||||
{ return (bool) !(*this == a); }
|
||||
|
||||
// inter-language operability
|
||||
inline Datatype& operator= (const MPI_Datatype &i)
|
||||
{ mpi_datatype = i; return *this; }
|
||||
|
||||
inline operator MPI_Datatype () const { return mpi_datatype; }
|
||||
// inline operator MPI_Datatype* ()/* JGS const */ { return &mpi_datatype; }
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// User Defined Functions
|
||||
//
|
||||
typedef int Copy_attr_function(const Datatype& oldtype,
|
||||
int type_keyval,
|
||||
void* extra_state,
|
||||
const void* attribute_val_in,
|
||||
void* attribute_val_out,
|
||||
bool& flag);
|
||||
|
||||
typedef int Delete_attr_function(Datatype& type, int type_keyval,
|
||||
void* attribute_val, void* extra_state);
|
||||
|
||||
//
|
||||
// Point-to-Point Communication
|
||||
//
|
||||
|
||||
virtual Datatype Create_contiguous(int count) const;
|
||||
|
||||
virtual Datatype Create_vector(int count, int blocklength,
|
||||
int stride) const;
|
||||
|
||||
virtual Datatype Create_indexed(int count,
|
||||
const int array_of_blocklengths[],
|
||||
const int array_of_displacements[]) const;
|
||||
|
||||
static Datatype Create_struct(int count, const int array_of_blocklengths[],
|
||||
const Aint array_of_displacements[],
|
||||
const Datatype array_if_types[]);
|
||||
|
||||
virtual Datatype Create_hindexed(int count, const int array_of_blocklengths[],
|
||||
const Aint array_of_displacements[]) const;
|
||||
|
||||
virtual Datatype Create_hvector(int count, int blocklength, Aint stride) const;
|
||||
|
||||
virtual int Get_size() const;
|
||||
|
||||
virtual void Get_extent(Aint& lb, Aint& extent) const;
|
||||
|
||||
virtual void Commit();
|
||||
|
||||
virtual void Free();
|
||||
|
||||
virtual void Pack(const void* inbuf, int incount, void *outbuf,
|
||||
int outsize, int& position, const Comm &comm) const;
|
||||
|
||||
virtual void Unpack(const void* inbuf, int insize, void *outbuf, int outcount,
|
||||
int& position, const Comm& comm) const;
|
||||
|
||||
virtual int Pack_size(int incount, const Comm& comm) const;
|
||||
|
||||
//
|
||||
// Miscellany
|
||||
//
|
||||
virtual Datatype Create_subarray(int ndims, const int array_of_sizes[],
|
||||
const int array_of_subsizes[],
|
||||
const int array_of_starts[], int order)
|
||||
const;
|
||||
|
||||
//
|
||||
// External Interfaces
|
||||
//
|
||||
|
||||
virtual Datatype Dup() const;
|
||||
|
||||
static int Create_keyval(Copy_attr_function* type_copy_attr_fn,
|
||||
Delete_attr_function* type_delete_attr_fn,
|
||||
void* extra_state);
|
||||
|
||||
virtual void Delete_attr(int type_keyval);
|
||||
|
||||
static void Free_keyval(int& type_keyval);
|
||||
|
||||
virtual bool Get_attr(int type_keyval, void* attribute_val) const;
|
||||
|
||||
virtual void Get_contents(int max_integers, int max_addresses,
|
||||
int max_datatypes, int array_of_integers[],
|
||||
Aint array_of_addresses[],
|
||||
Datatype array_of_datatypes[]) const;
|
||||
|
||||
virtual void Get_envelope(int& num_integers, int& num_addresses,
|
||||
int& num_datatypes, int& combiner) const;
|
||||
|
||||
virtual void Get_name(char* type_name, int& resultlen) const;
|
||||
|
||||
virtual void Set_attr(int type_keyval, const void* attribute_val);
|
||||
|
||||
virtual void Set_name(const char* type_name);
|
||||
|
||||
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
private:
|
||||
PMPI::Datatype pmpi_datatype;
|
||||
#else
|
||||
protected:
|
||||
MPI_Datatype mpi_datatype;
|
||||
#endif
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
267
src/mpi/cxx/datatype_inln.h
Обычный файл
267
src/mpi/cxx/datatype_inln.h
Обычный файл
@ -0,0 +1,267 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Point-to-Point Communication
|
||||
//
|
||||
|
||||
inline MPI::Datatype
|
||||
MPI::Datatype::Create_contiguous(int count) const
|
||||
{
|
||||
MPI_Datatype newtype;
|
||||
(void)MPI_Type_contiguous(count, mpi_datatype, &newtype);
|
||||
return newtype;
|
||||
}
|
||||
|
||||
inline MPI::Datatype
|
||||
MPI::Datatype::Create_vector(int count, int blocklength,
|
||||
int stride) const
|
||||
{
|
||||
MPI_Datatype newtype;
|
||||
(void)MPI_Type_vector(count, blocklength, stride, mpi_datatype, &newtype);
|
||||
return newtype;
|
||||
}
|
||||
|
||||
inline MPI::Datatype
|
||||
MPI::Datatype::Create_indexed(int count,
|
||||
const int array_of_blocklengths[],
|
||||
const int array_of_displacements[]) const
|
||||
{
|
||||
MPI_Datatype newtype;
|
||||
(void)MPI_Type_indexed(count, (int *) array_of_blocklengths,
|
||||
(int *) array_of_displacements, mpi_datatype, &newtype);
|
||||
return newtype;
|
||||
}
|
||||
|
||||
inline MPI::Datatype
|
||||
MPI::Datatype::Create_struct(int count, const int array_of_blocklengths[],
|
||||
const MPI::Aint array_of_displacements[],
|
||||
const MPI::Datatype array_of_types[])
|
||||
{
|
||||
MPI_Datatype newtype;
|
||||
int i;
|
||||
MPI_Datatype* type_array = new MPI_Datatype[count];
|
||||
for (i=0; i < count; i++)
|
||||
type_array[i] = array_of_types[i];
|
||||
|
||||
(void)MPI_Type_create_struct(count, (int*)array_of_blocklengths,
|
||||
(MPI_Aint*)array_of_displacements,
|
||||
type_array, &newtype);
|
||||
delete[] type_array;
|
||||
return newtype;
|
||||
}
|
||||
|
||||
inline MPI::Datatype
|
||||
MPI::Datatype::Create_hindexed(int count, const int array_of_blocklengths[],
|
||||
const MPI::Aint array_of_displacements[]) const
|
||||
{
|
||||
MPI_Datatype newtype;
|
||||
(void)MPI_Type_create_hindexed(count, (int*)array_of_blocklengths,
|
||||
(MPI_Aint*)array_of_displacements,
|
||||
mpi_datatype, &newtype) ;
|
||||
return newtype;
|
||||
}
|
||||
|
||||
inline MPI::Datatype
|
||||
MPI::Datatype::Create_hvector(int count, int blocklength,
|
||||
MPI::Aint stride) const
|
||||
{
|
||||
MPI_Datatype newtype;
|
||||
(void)MPI_Type_create_hvector(count, blocklength, (MPI_Aint)stride,
|
||||
mpi_datatype, &newtype);
|
||||
|
||||
return newtype;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Datatype::Get_size() const
|
||||
{
|
||||
int size;
|
||||
(void)MPI_Type_size(mpi_datatype, &size);
|
||||
return size;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Get_extent(MPI::Aint& lb, MPI::Aint& extent) const
|
||||
{
|
||||
(void)MPI_Type_get_extent(mpi_datatype, &lb, &extent);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Commit()
|
||||
{
|
||||
(void)MPI_Type_commit(&mpi_datatype);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Free()
|
||||
{
|
||||
(void)MPI_Type_free(&mpi_datatype);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Pack(const void* inbuf, int incount,
|
||||
void *outbuf, int outsize,
|
||||
int& position, const MPI::Comm &comm) const
|
||||
{
|
||||
(void)MPI_Pack((void *) inbuf, incount, mpi_datatype, outbuf,
|
||||
outsize, &position, comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Unpack(const void* inbuf, int insize,
|
||||
void *outbuf, int outcount, int& position,
|
||||
const MPI::Comm& comm) const
|
||||
{
|
||||
(void)MPI_Unpack((void *) inbuf, insize, &position,
|
||||
outbuf, outcount, mpi_datatype, comm);
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Datatype::Pack_size(int incount, const MPI::Comm& comm) const
|
||||
{
|
||||
int size;
|
||||
(void)MPI_Pack_size(incount, mpi_datatype, comm, &size);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Miscalleny
|
||||
//
|
||||
|
||||
inline MPI::Datatype
|
||||
MPI::Datatype::Create_subarray(int ndims, const int array_of_sizes[],
|
||||
const int array_of_subsizes[],
|
||||
const int array_of_starts[], int order)
|
||||
const
|
||||
{
|
||||
MPI_Datatype type;
|
||||
(void) MPI_Type_create_subarray(ndims, (int *) array_of_sizes,
|
||||
(int *) array_of_subsizes, (int *) array_of_starts,
|
||||
order, mpi_datatype, &type);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// External Interfaces
|
||||
//
|
||||
|
||||
|
||||
inline MPI::Datatype
|
||||
MPI::Datatype::Dup() const
|
||||
{
|
||||
MPI_Datatype type;
|
||||
(void) MPI_Type_dup(mpi_datatype, &type);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
MPI::Datatype::Create_keyval(MPI::Datatype::Copy_attr_function*
|
||||
type_copy_attr_fn,
|
||||
MPI::Datatype::Delete_attr_function*
|
||||
type_delete_attr_fn, void* extra_state)
|
||||
{
|
||||
int key;
|
||||
(void) MPI_Type_create_keyval((MPI_Type_copy_attr_function *)
|
||||
type_copy_attr_fn,
|
||||
(MPI_Type_delete_attr_function *)
|
||||
type_delete_attr_fn, &key, extra_state);
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Delete_attr(int type_keyval)
|
||||
{
|
||||
(void) MPI_Type_delete_attr(mpi_datatype, type_keyval);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Free_keyval(int& type_keyval)
|
||||
{
|
||||
(void) MPI_Type_free_keyval(&type_keyval);
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
MPI::Datatype::Get_attr(int type_keyval,
|
||||
void* attribute_val) const
|
||||
{
|
||||
int ret;
|
||||
(void) MPI_Type_get_attr(mpi_datatype, type_keyval, attribute_val, &ret);
|
||||
return (bool) ret;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Get_contents(int max_integers, int max_addresses,
|
||||
int max_datatypes, int array_of_integers[],
|
||||
MPI::Aint array_of_addresses[],
|
||||
MPI::Datatype array_of_datatypes[])
|
||||
const
|
||||
{
|
||||
(void) MPI_Type_get_contents(mpi_datatype, max_integers, max_addresses,
|
||||
max_datatypes, (int *)array_of_integers,
|
||||
(MPI_Aint*) array_of_addresses,
|
||||
(MPI_Datatype *) array_of_datatypes);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Get_envelope(int& num_integers, int& num_addresses,
|
||||
int& num_datatypes, int& combiner) const
|
||||
{
|
||||
(void) MPI_Type_get_envelope(mpi_datatype, &num_integers, &num_addresses,
|
||||
&num_datatypes, &combiner);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Get_name(char* type_name, int& resultlen) const
|
||||
{
|
||||
(void) MPI_Type_get_name(mpi_datatype, type_name, &resultlen);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Set_attr(int type_keyval, const void* attribute_val)
|
||||
{
|
||||
(void) MPI_Type_set_attr(mpi_datatype, type_keyval, (void *) attribute_val);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Datatype::Set_name(const char* type_name)
|
||||
{
|
||||
(void) MPI_Type_set_name(mpi_datatype, (char *)type_name);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//
|
||||
// User Defined Functions
|
||||
//
|
||||
|
||||
typedef int MPI::Datatype::Copy_attr_function(const Datatype& oldtype,
|
||||
int type_keyval,
|
||||
void* extra_state,
|
||||
void* attribute_val_in,
|
||||
void* attribute_val_out,
|
||||
bool& flag);
|
||||
|
||||
typedef int MPI::Datatype::Delete_attr_function(Datatype& type,
|
||||
int type_keyval,
|
||||
void* attribute_val,
|
||||
void* extra_state);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
128
src/mpi/cxx/errhandler.h
Обычный файл
128
src/mpi/cxx/errhandler.h
Обычный файл
@ -0,0 +1,128 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
class Errhandler {
|
||||
public:
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
// construction / destruction
|
||||
inline Errhandler() { }
|
||||
|
||||
inline virtual ~Errhandler() { }
|
||||
|
||||
inline Errhandler(const MPI_Errhandler &i)
|
||||
: pmpi_errhandler(i) { }
|
||||
|
||||
// copy / assignment
|
||||
inline Errhandler(const Errhandler& e)
|
||||
: pmpi_errhandler(e.pmpi_errhandler) { }
|
||||
|
||||
inline Errhandler(const PMPI::Errhandler& e)
|
||||
: pmpi_errhandler(e) { }
|
||||
|
||||
inline Errhandler& operator=(const Errhandler& e) {
|
||||
pmpi_errhandler = e.pmpi_errhandler; return *this; }
|
||||
|
||||
// comparison
|
||||
inline bool operator==(const Errhandler &a) {
|
||||
return (bool)(pmpi_errhandler == a.pmpi_errhandler); }
|
||||
|
||||
inline bool operator!=(const Errhandler &a) {
|
||||
return (bool)!(*this == a); }
|
||||
|
||||
// inter-language operability
|
||||
inline Errhandler& operator= (const MPI_Errhandler &i) {
|
||||
pmpi_errhandler = i; return *this; }
|
||||
|
||||
inline operator MPI_Errhandler() const { return pmpi_errhandler; }
|
||||
|
||||
// inline operator MPI_Errhandler*() { return pmpi_errhandler; }
|
||||
|
||||
inline operator const PMPI::Errhandler&() const { return pmpi_errhandler; }
|
||||
|
||||
#else
|
||||
|
||||
// construction / destruction
|
||||
inline Errhandler()
|
||||
: mpi_errhandler(MPI_ERRHANDLER_NULL) {}
|
||||
|
||||
inline virtual ~Errhandler() { }
|
||||
|
||||
inline Errhandler(const MPI_Errhandler &i)
|
||||
: mpi_errhandler(i) {}
|
||||
|
||||
// copy / assignment
|
||||
inline Errhandler(const Errhandler& e)
|
||||
: handler_fn(e.handler_fn), mpi_errhandler(e.mpi_errhandler) { }
|
||||
|
||||
inline Errhandler& operator=(const Errhandler& e)
|
||||
{
|
||||
mpi_errhandler = e.mpi_errhandler;
|
||||
handler_fn = e.handler_fn;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// comparison
|
||||
inline bool operator==(const Errhandler &a) {
|
||||
return (bool)(mpi_errhandler == a.mpi_errhandler); }
|
||||
|
||||
inline bool operator!=(const Errhandler &a) {
|
||||
return (bool)!(*this == a); }
|
||||
|
||||
// inter-language operability
|
||||
inline Errhandler& operator= (const MPI_Errhandler &i) {
|
||||
mpi_errhandler = i; return *this; }
|
||||
|
||||
inline operator MPI_Errhandler() const { return mpi_errhandler; }
|
||||
|
||||
// inline operator MPI_Errhandler*() { return &mpi_errhandler; }
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Errhandler access functions
|
||||
//
|
||||
|
||||
virtual void Free();
|
||||
|
||||
#if !0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
Comm::Errhandler_fn* handler_fn;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
PMPI::Errhandler pmpi_errhandler;
|
||||
#else
|
||||
MPI_Errhandler mpi_errhandler;
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
// took out the friend decls
|
||||
//private:
|
||||
|
||||
//this is for ERRORS_THROW_EXCEPTIONS
|
||||
//this is called from MPI::Real_init
|
||||
inline void init() const {
|
||||
#if ! 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// $%%@#%# AIX/POE 2.3.0.0 makes us put in this cast here
|
||||
(void)MPI_Errhandler_create((MPI_Handler_function*) &throw_excptn_fctn,
|
||||
(MPI_Errhandler *) &mpi_errhandler);
|
||||
#else
|
||||
pmpi_errhandler.init();
|
||||
#endif
|
||||
}
|
||||
|
||||
//this is for ERRORS_THROW_EXCEPTIONS
|
||||
//this is called from MPI::Finalize
|
||||
inline void free() const {
|
||||
#if ! 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
(void)MPI_Errhandler_free((MPI_Errhandler *) &mpi_errhandler);
|
||||
#else
|
||||
pmpi_errhandler.free();
|
||||
#endif
|
||||
}
|
||||
};
|
35
src/mpi/cxx/errhandler_inln.h
Обычный файл
35
src/mpi/cxx/errhandler_inln.h
Обычный файл
@ -0,0 +1,35 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
inline PMPI::Errhandler::Errhandler(const PMPI::Errhandler& e)
|
||||
: handler_fn(e.handler_fn), mpi_errhandler(e.mpi_errhandler) { }
|
||||
|
||||
inline PMPI::Errhandler&
|
||||
PMPI::Errhandler::operator=(const PMPI::Errhandler& e)
|
||||
{
|
||||
handler_fn = e.handler_fn;
|
||||
mpi_errhandler = e.mpi_errhandler;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool
|
||||
PMPI::Errhandler::operator==(const PMPI::Errhandler &a)
|
||||
{
|
||||
return (MPI2CPP_BOOL_T)(mpi_errhandler == a.mpi_errhandler);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
inline void
|
||||
MPI::Errhandler::Free()
|
||||
{
|
||||
(void)MPI_Errhandler_free(&mpi_errhandler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
60
src/mpi/cxx/exception.h
Обычный файл
60
src/mpi/cxx/exception.h
Обычный файл
@ -0,0 +1,60 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
class Exception {
|
||||
public:
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
inline Exception(int ec) : pmpi_exception(ec) { }
|
||||
|
||||
int Get_error_code() const;
|
||||
|
||||
int Get_error_class() const;
|
||||
|
||||
const char* Get_error_string() const;
|
||||
|
||||
#else
|
||||
|
||||
inline Exception(int ec) : error_code(ec), error_string(0), error_class(-1) {
|
||||
(void)MPI_Error_class(error_code, &error_class);
|
||||
int resultlen;
|
||||
error_string = new char[MAX_ERROR_STRING];
|
||||
(void)MPI_Error_string(error_code, error_string, &resultlen);
|
||||
}
|
||||
inline ~Exception() {
|
||||
delete[] error_string;
|
||||
}
|
||||
// Better put in a copy constructor here since we have a string;
|
||||
// copy by value (from the default copy constructor) would be
|
||||
// disasterous.
|
||||
inline Exception(const Exception& a)
|
||||
: error_code(a.error_code), error_class(a.error_class)
|
||||
{
|
||||
error_string = new char[MAX_ERROR_STRING];
|
||||
// Rather that force an include of <string.h>, especially this
|
||||
// late in the game (recall that this file is included deep in
|
||||
// other .h files), we'll just do the copy ourselves.
|
||||
for (int i = 0; i < MAX_ERROR_STRING; i++)
|
||||
error_string[i] = a.error_string[i];
|
||||
}
|
||||
|
||||
inline int Get_error_code() const { return error_code; }
|
||||
|
||||
inline int Get_error_class() const { return error_class; }
|
||||
|
||||
inline const char* Get_error_string() const { return error_string; }
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
PMPI::Exception pmpi_exception;
|
||||
#else
|
||||
int error_code;
|
||||
char* error_string;
|
||||
int error_class;
|
||||
#endif
|
||||
};
|
258
src/mpi/cxx/file.h
Обычный файл
258
src/mpi/cxx/file.h
Обычный файл
@ -0,0 +1,258 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
class File {
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// friend class P;
|
||||
|
||||
#endif
|
||||
friend class MPI::Comm; //so I can access pmpi_file data member in comm.cc
|
||||
friend class MPI::Request; //and also from request.cc
|
||||
|
||||
public:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
// construction / destruction
|
||||
File() { }
|
||||
virtual ~File() { }
|
||||
|
||||
|
||||
// copy / assignment
|
||||
File(const File& data) : pmpi_file(data.pmpi_file) { }
|
||||
|
||||
File(const MPI_File &i) : pmpi_file(i) { }
|
||||
|
||||
File& operator=(const File& data) {
|
||||
pmpi_file = data.pmpi_file; return *this; }
|
||||
|
||||
// comparison, don't need for file
|
||||
|
||||
// inter-language operability
|
||||
File& operator= (const MPI_File &i) {
|
||||
pmpi_file = i; return *this; }
|
||||
operator MPI_File () const { return pmpi_file; }
|
||||
// operator MPI_File* () const { return pmpi_file; }
|
||||
operator const PMPI::File&() const { return pmpi_file; }
|
||||
|
||||
#else
|
||||
|
||||
File() { }
|
||||
// copy
|
||||
File(const File& data) : mpi_file(data.mpi_file) { }
|
||||
|
||||
File(const MPI_File &i) : mpi_file(i) { }
|
||||
|
||||
virtual ~File() { }
|
||||
|
||||
File& operator=(const File& data) {
|
||||
mpi_file = data.mpi_file; return *this; }
|
||||
|
||||
// comparison, don't need for file
|
||||
|
||||
// inter-language operability
|
||||
File& operator= (const MPI_File &i) {
|
||||
mpi_file = i; return *this; }
|
||||
operator MPI_File () const { return mpi_file; }
|
||||
// operator MPI_File* () const { return (MPI_File*)&mpi_file; }
|
||||
|
||||
#endif
|
||||
|
||||
// from the I/o chapter of MPI - 2
|
||||
|
||||
void Close();
|
||||
|
||||
static void Delete(const char* filename, const MPI::Info& info);
|
||||
|
||||
int Get_amode() const;
|
||||
|
||||
bool Get_atomicity() const;
|
||||
|
||||
MPI::Offset Get_byte_offset(const MPI::Offset disp) const;
|
||||
|
||||
MPI::Group Get_group() const;
|
||||
|
||||
MPI::Info Get_info() const;
|
||||
|
||||
MPI::Offset Get_position() const;
|
||||
|
||||
MPI::Offset Get_position_shared() const;
|
||||
|
||||
MPI::Offset Get_size() const;
|
||||
|
||||
MPI::Aint Get_type_extent(const MPI::Datatype& datatype) const;
|
||||
|
||||
void Get_view(MPI::Offset& disp, MPI::Datatype& etype,
|
||||
MPI::Datatype& filetype, char* datarep) const;
|
||||
|
||||
MPI::Request Iread(void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
MPI::Request Iread_at(MPI::Offset offset, void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
MPI::Request Iread_shared(void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
MPI::Request Iwrite(const void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
MPI::Request Iwrite_at(MPI::Offset offset, const void* buf,
|
||||
int count, const MPI::Datatype& datatype);
|
||||
|
||||
MPI::Request Iwrite_shared(const void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
static MPI::File Open(const MPI::Intracomm& comm,
|
||||
const char* filename, int amode,
|
||||
const MPI::Info& info);
|
||||
|
||||
void Preallocate(MPI::Offset size);
|
||||
|
||||
void Read(void* buf, int count, const MPI::Datatype& datatype);
|
||||
|
||||
void Read(void* buf, int count, const MPI::Datatype& datatype,
|
||||
MPI::Status& status);
|
||||
|
||||
void Read_all(void* buf, int count, const MPI::Datatype& datatype);
|
||||
|
||||
void Read_all(void* buf, int count, const MPI::Datatype& datatype,
|
||||
MPI::Status& status);
|
||||
|
||||
void Read_all_begin(void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Read_all_end(void* buf);
|
||||
|
||||
void Read_all_end(void* buf, MPI::Status& status);
|
||||
|
||||
void Read_at(MPI::Offset offset,
|
||||
void* buf, int count, const MPI::Datatype& datatype);
|
||||
|
||||
void Read_at(MPI::Offset offset, void* buf, int count,
|
||||
const MPI::Datatype& datatype, MPI::Status& status);
|
||||
|
||||
void Read_at_all(MPI::Offset offset, void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Read_at_all(MPI::Offset offset, void* buf, int count,
|
||||
const MPI::Datatype& datatype, MPI::Status& status);
|
||||
|
||||
void Read_at_all_begin(MPI::Offset offset, void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Read_at_all_end(void* buf);
|
||||
|
||||
void Read_at_all_end(void* buf, MPI::Status& status);
|
||||
|
||||
void Read_ordered(void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Read_ordered(void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status);
|
||||
|
||||
void Read_ordered_begin(void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Read_ordered_end(void* buf);
|
||||
|
||||
void Read_ordered_end(void* buf, MPI::Status& status);
|
||||
|
||||
void Read_shared(void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Read_shared(void* buf, int count,
|
||||
const MPI::Datatype& datatype, MPI::Status& status);
|
||||
|
||||
void Seek(MPI::Offset offset, int whence);
|
||||
|
||||
void Seek_shared(MPI::Offset offset, int whence);
|
||||
|
||||
void Set_atomicity(bool flag);
|
||||
|
||||
void Set_info(const MPI::Info& info);
|
||||
|
||||
void Set_size(MPI::Offset size);
|
||||
|
||||
void Set_view(MPI::Offset disp, const MPI::Datatype& etype,
|
||||
const MPI::Datatype& filetype, const char* datarep,
|
||||
const MPI::Info& info);
|
||||
|
||||
void Sync();
|
||||
|
||||
void Write(const void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Write(const void* buf, int count,
|
||||
const MPI::Datatype& datatype, MPI::Status& status);
|
||||
|
||||
void Write_all(const void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Write_all(const void* buf, int count,
|
||||
const MPI::Datatype& datatype, MPI::Status& status);
|
||||
|
||||
void Write_all_begin(const void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Write_all_end(const void* buf);
|
||||
|
||||
void Write_all_end(const void* buf, MPI::Status& status);
|
||||
|
||||
void Write_at(MPI::Offset offset, const void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Write_at(MPI::Offset offset, const void* buf, int count,
|
||||
const MPI::Datatype& datatype, MPI::Status& status);
|
||||
|
||||
void Write_at_all(MPI::Offset offset, const void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Write_at_all(MPI::Offset offset, const void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status);
|
||||
|
||||
void Write_at_all_begin(MPI::Offset offset, const void* buf,
|
||||
int count, const MPI::Datatype& datatype);
|
||||
|
||||
void Write_at_all_end(const void* buf);
|
||||
|
||||
void Write_at_all_end(const void* buf, MPI::Status& status);
|
||||
|
||||
void Write_ordered(const void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Write_ordered(const void* buf, int count,
|
||||
const MPI::Datatype& datatype, MPI::Status& status);
|
||||
|
||||
void Write_ordered_begin(const void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Write_ordered_end(const void* buf);
|
||||
|
||||
void Write_ordered_end(const void* buf, MPI::Status& status);
|
||||
|
||||
void Write_shared(const void* buf, int count,
|
||||
const MPI::Datatype& datatype);
|
||||
|
||||
void Write_shared(const void* buf, int count,
|
||||
const MPI::Datatype& datatype, MPI::Status& status);
|
||||
|
||||
MPI::Errhandler Get_errhandler() const;
|
||||
|
||||
void Set_errhandler(const MPI::Errhandler& errhandler);
|
||||
|
||||
typedef void Errhandler_fn(MPI::File &, int *, ... );
|
||||
|
||||
protected:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
PMPI::File pmpi_file;
|
||||
|
||||
#else
|
||||
MPI_File mpi_file;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
639
src/mpi/cxx/file_inln.h
Обычный файл
639
src/mpi/cxx/file_inln.h
Обычный файл
@ -0,0 +1,639 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::File::Close()
|
||||
{
|
||||
(void) MPI_File_close(&mpi_file);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Delete(const char* filename, const MPI::Info& info)
|
||||
{
|
||||
(void) MPI_File_delete((char*)filename, info);
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
MPI::File::Get_amode() const
|
||||
{
|
||||
int amode;
|
||||
(void) MPI_File_get_amode(mpi_file, &amode);
|
||||
return amode;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
MPI::File::Get_atomicity() const
|
||||
{
|
||||
int flag;
|
||||
(void) MPI_File_get_atomicity(mpi_file, &flag);
|
||||
return (bool)flag;
|
||||
}
|
||||
|
||||
inline MPI::Offset
|
||||
MPI::File::Get_byte_offset(const MPI::Offset disp) const
|
||||
{
|
||||
MPI_Offset offset, ldisp;
|
||||
ldisp = disp;
|
||||
(void) MPI_File_get_byte_offset(mpi_file, ldisp, &offset);
|
||||
return offset;
|
||||
}
|
||||
|
||||
inline MPI::Group
|
||||
MPI::File::Get_group() const
|
||||
{
|
||||
MPI_Group group;
|
||||
(void) MPI_File_get_group(mpi_file, &group);
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Info
|
||||
MPI::File::Get_info() const
|
||||
{
|
||||
MPI_Info info_used;
|
||||
(void) MPI_File_get_info(mpi_file, &info_used);
|
||||
return info_used;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Offset
|
||||
MPI::File::Get_position() const
|
||||
{
|
||||
MPI_Offset offset;
|
||||
(void) MPI_File_get_position(mpi_file, &offset);
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Offset
|
||||
MPI::File::Get_position_shared() const
|
||||
{
|
||||
MPI_Offset offset;
|
||||
(void) MPI_File_get_position_shared(mpi_file, &offset);
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Offset
|
||||
MPI::File::Get_size() const
|
||||
{
|
||||
MPI_Offset offset;
|
||||
(void) MPI_File_get_size(mpi_file, &offset);
|
||||
return offset;
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Aint
|
||||
MPI::File::Get_type_extent(const MPI::Datatype& datatype) const
|
||||
{
|
||||
MPI_Aint extent;
|
||||
(void) MPI_File_get_type_extent(mpi_file, datatype, &extent);
|
||||
return extent;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Get_view(MPI::Offset& disp,
|
||||
MPI::Datatype& etype,
|
||||
MPI::Datatype& filetype,
|
||||
char* datarep) const
|
||||
{
|
||||
MPI_Datatype type, ftype;
|
||||
type = etype;
|
||||
ftype = filetype;
|
||||
MPI::Offset odisp = disp;
|
||||
|
||||
(void) MPI_File_get_view(mpi_file, &odisp, &type, &ftype,
|
||||
datarep);
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Request
|
||||
MPI::File::Iread(void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Request req;
|
||||
(void) MPI_File_iread(mpi_file, buf, count, datatype, &req);
|
||||
return req;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Request
|
||||
MPI::File::Iread_at(MPI::Offset offset, void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Request req;
|
||||
(void) MPI_File_iread_at(mpi_file, offset, buf, count, datatype, &req);
|
||||
return req;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Request
|
||||
MPI::File::Iread_shared(void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Request req;
|
||||
(void) MPI_File_iread_shared(mpi_file, buf, count, datatype, &req);
|
||||
return req;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Request
|
||||
MPI::File::Iwrite(const void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Request req;
|
||||
(void) MPI_File_iwrite(mpi_file, (void*) buf, count, datatype, &req);
|
||||
return req;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Request
|
||||
MPI::File::Iwrite_at(MPI::Offset offset, const void* buf,
|
||||
int count, const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Request req;
|
||||
(void) MPI_File_iwrite_at(mpi_file, offset, (void*) buf, count, datatype,
|
||||
&req);
|
||||
return req;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Request
|
||||
MPI::File::Iwrite_shared(const void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Request req;
|
||||
(void) MPI_File_iwrite_shared(mpi_file, (void*) buf, count, datatype, &req);
|
||||
return req;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::File
|
||||
MPI::File::Open(const MPI::Intracomm& comm,
|
||||
const char* filename, int amode,
|
||||
const MPI::Info& info)
|
||||
{
|
||||
MPI_File fh;
|
||||
(void) MPI_File_open(comm, (char*) filename, amode, info, &fh);
|
||||
return fh;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Preallocate(MPI::Offset size)
|
||||
{
|
||||
(void) MPI_File_preallocate(mpi_file, size);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read(void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_read(mpi_file, buf, count, datatype, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read(void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_read(mpi_file, buf, count, datatype, &status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_all(void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_read_all(mpi_file, buf, count, datatype, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_all(void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_read_all(mpi_file, buf, count, datatype, &status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_all_begin(void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
(void) MPI_File_read_all_begin(mpi_file, buf, count, datatype);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_all_end(void* buf)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_read_all_end(mpi_file, buf, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_all_end(void* buf, MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_read_all_end(mpi_file, buf, &status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_at(MPI::Offset offset,
|
||||
void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_read_at(mpi_file, offset, buf, count, datatype, &status);
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_at(MPI::Offset offset, void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_read_at(mpi_file, offset, buf, count, datatype,
|
||||
&status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_at_all(MPI::Offset offset, void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_read_at_all(mpi_file, offset, buf, count, datatype, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_at_all(MPI::Offset offset, void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_read_at_all(mpi_file, offset, buf, count, datatype,
|
||||
&status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_at_all_begin(MPI::Offset offset,
|
||||
void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
(void) MPI_File_read_at_all_begin(mpi_file, offset, buf, count, datatype);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_at_all_end(void* buf)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_read_at_all_end(mpi_file, buf, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_at_all_end(void* buf, MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_read_at_all_end(mpi_file, buf, &status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_ordered(void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_read_ordered(mpi_file, buf, count, datatype, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_ordered(void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_read_ordered(mpi_file, buf, count, datatype,
|
||||
&status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_ordered_begin(void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
(void) MPI_File_read_ordered_begin(mpi_file, buf, count, datatype);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_ordered_end(void* buf)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_read_ordered_end(mpi_file, buf, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_ordered_end(void* buf, MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_read_ordered_end(mpi_file, buf, &status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_shared(void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_read_shared(mpi_file, buf, count, datatype, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Read_shared(void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_read_shared(mpi_file, buf, count, datatype,
|
||||
&status.mpi_status);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::File::Seek(MPI::Offset offset, int whence)
|
||||
{
|
||||
(void) MPI_File_seek(mpi_file, offset, whence);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Seek_shared(MPI::Offset offset, int whence)
|
||||
{
|
||||
(void) MPI_File_seek_shared(mpi_file, offset, whence);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Set_atomicity(bool flag)
|
||||
{
|
||||
(void) MPI_File_set_atomicity(mpi_file, flag);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Set_info(const MPI::Info& info)
|
||||
{
|
||||
(void) MPI_File_set_info(mpi_file, info);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Set_size(MPI::Offset size)
|
||||
{
|
||||
(void) MPI_File_set_size(mpi_file, size);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Set_view(MPI::Offset disp,
|
||||
const MPI::Datatype& etype,
|
||||
const MPI::Datatype& filetype,
|
||||
const char* datarep,
|
||||
const MPI::Info& info)
|
||||
{
|
||||
(void) MPI_File_set_view(mpi_file, disp, etype, filetype, (char*) datarep,
|
||||
info);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Sync()
|
||||
{
|
||||
(void) MPI_File_sync(mpi_file);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write(const void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_write(mpi_file, (void*) buf, count, datatype, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write(const void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_write(mpi_file, (void*) buf, count, datatype,
|
||||
&status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_all(const void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_write_all(mpi_file, (void*) buf, count, datatype, &status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_all(const void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_write_all(mpi_file, (void*) buf, count, datatype,
|
||||
&status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_all_begin(const void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
(void) MPI_File_write_all_begin(mpi_file, (void*) buf, count, datatype);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_all_end(const void* buf)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_write_all_end(mpi_file, (void*) buf, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_all_end(const void* buf, MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_write_all_end(mpi_file, (void*) buf, &status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_at(MPI::Offset offset,
|
||||
const void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_write_at(mpi_file, offset, (void*) buf, count,
|
||||
datatype, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_at(MPI::Offset offset,
|
||||
const void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_write_at(mpi_file, offset, (void*) buf, count,
|
||||
datatype, &status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_at_all(MPI::Offset offset,
|
||||
const void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_write_at_all(mpi_file, offset, (void*) buf, count,
|
||||
datatype, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_at_all(MPI::Offset offset,
|
||||
const void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_write_at_all(mpi_file, offset, (void*) buf, count,
|
||||
datatype, &status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_at_all_begin(MPI::Offset offset,
|
||||
const void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
(void) MPI_File_write_at_all_begin(mpi_file, offset, (void*) buf, count,
|
||||
datatype);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_at_all_end(const void* buf)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_write_at_all_end(mpi_file, (void*) buf, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_at_all_end(const void* buf, MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_write_at_all_end(mpi_file, (void*) buf, &status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_ordered(const void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_write_ordered(mpi_file, (void*) buf, count, datatype,
|
||||
&status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_ordered(const void* buf, int count,
|
||||
const MPI::Datatype& datatype,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_write_ordered(mpi_file, (void*) buf, count, datatype,
|
||||
&status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_ordered_begin(const void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
(void) MPI_File_write_ordered_begin(mpi_file, (void*) buf, count, datatype);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_ordered_end(const void* buf)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_write_ordered_end(mpi_file, (void*) buf, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_ordered_end(const void* buf,
|
||||
MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_write_ordered_end(mpi_file, (void*) buf, &status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_shared(const void* buf, int count,
|
||||
const MPI::Datatype& datatype)
|
||||
{
|
||||
MPI_Status status;
|
||||
(void) MPI_File_write_shared(mpi_file, (void*) buf, count,
|
||||
datatype, &status);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::File::Write_shared(const void* buf, int count,
|
||||
const MPI::Datatype& datatype, MPI::Status& status)
|
||||
{
|
||||
(void) MPI_File_write_shared(mpi_file, (void*) buf, count,
|
||||
datatype, &status.mpi_status);
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Errhandler
|
||||
MPI::File::Get_errhandler() const
|
||||
{
|
||||
MPI_Errhandler err;
|
||||
(void) MPI_File_get_errhandler(mpi_file, &err);
|
||||
return err;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::File::Set_errhandler(const MPI::Errhandler& errhandler)
|
||||
{
|
||||
(void) MPI_File_set_errhandler(mpi_file, errhandler);
|
||||
}
|
125
src/mpi/cxx/functions.h
Обычный файл
125
src/mpi/cxx/functions.h
Обычный файл
@ -0,0 +1,125 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
//
|
||||
// Point-to-Point Communication
|
||||
//
|
||||
|
||||
void
|
||||
Attach_buffer(void* buffer, int size);
|
||||
|
||||
int
|
||||
Detach_buffer(void*& buffer);
|
||||
|
||||
//
|
||||
// Process Topologies
|
||||
//
|
||||
|
||||
void
|
||||
Compute_dims(int nnodes, int ndims, int dims[]);
|
||||
|
||||
//
|
||||
// Environmental Inquiry
|
||||
//
|
||||
|
||||
void
|
||||
Get_processor_name(char* name, int& resultlen);
|
||||
|
||||
void
|
||||
Get_error_string(int errorcode, char* string, int& resultlen);
|
||||
|
||||
int
|
||||
Get_error_class(int errorcode);
|
||||
|
||||
double
|
||||
Wtime();
|
||||
|
||||
double
|
||||
Wtick();
|
||||
|
||||
void
|
||||
Init(int& argc, char**& argv);
|
||||
|
||||
void
|
||||
Init();
|
||||
|
||||
void
|
||||
Real_init();
|
||||
|
||||
void
|
||||
Finalize();
|
||||
|
||||
bool
|
||||
Is_initialized();
|
||||
|
||||
//
|
||||
// External Interfaces
|
||||
//
|
||||
|
||||
int
|
||||
Init_thread(int &argc, char**&argv, int required);
|
||||
|
||||
int
|
||||
Init_thread(int required);
|
||||
|
||||
bool
|
||||
Is_thread_main();
|
||||
|
||||
int
|
||||
Query_thread();
|
||||
|
||||
|
||||
//
|
||||
// Miscellany
|
||||
//
|
||||
|
||||
|
||||
void*
|
||||
Alloc_mem(Aint size, const Info& info);
|
||||
|
||||
|
||||
void
|
||||
Free_mem(void* base);
|
||||
|
||||
//
|
||||
// Process Creation
|
||||
//
|
||||
|
||||
void
|
||||
Close_port(const char* port_name);
|
||||
|
||||
|
||||
void
|
||||
Lookup_name(const char* service_name, const Info& info, char* port_name);
|
||||
|
||||
|
||||
void
|
||||
Open_port(const Info& info, char* port_name);
|
||||
|
||||
|
||||
void
|
||||
Publish_name(const char* service_name, const Info& info,
|
||||
const char* port_name);
|
||||
|
||||
void
|
||||
Unpublish_name(const char* service_name, const Info& info,
|
||||
const char* port_name);
|
||||
|
||||
//
|
||||
// Profiling
|
||||
//
|
||||
|
||||
void
|
||||
Pcontrol(const int level, ...);
|
||||
|
||||
void
|
||||
Get_version(int& version, int& subversion);
|
||||
|
||||
MPI::Aint
|
||||
Get_address(void* location);
|
||||
|
||||
|
||||
|
||||
|
254
src/mpi/cxx/functions_inln.h
Обычный файл
254
src/mpi/cxx/functions_inln.h
Обычный файл
@ -0,0 +1,254 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
#include <string.h>
|
||||
|
||||
//
|
||||
// Point-to-Point Communication
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Attach_buffer(void* buffer, int size)
|
||||
{
|
||||
(void)MPI_Buffer_attach(buffer, size);
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Detach_buffer(void*& buffer)
|
||||
{
|
||||
int size;
|
||||
(void)MPI_Buffer_detach(&buffer, &size);
|
||||
return size;
|
||||
}
|
||||
|
||||
//
|
||||
// Process Topologies
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Compute_dims(int nnodes, int ndims, int dims[])
|
||||
{
|
||||
(void)MPI_Dims_create(nnodes, ndims, dims);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Environmental Inquiry
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Get_processor_name(char* name, int& resultlen)
|
||||
{
|
||||
(void)MPI_Get_processor_name(name, &resultlen);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Get_error_string(int errorcode, char* string, int& resultlen)
|
||||
{
|
||||
(void)MPI_Error_string(errorcode, string, &resultlen);
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Get_error_class(int errorcode)
|
||||
{
|
||||
int errorclass;
|
||||
(void)MPI_Error_class(errorcode, &errorclass);
|
||||
return errorclass;
|
||||
}
|
||||
|
||||
inline double
|
||||
MPI::Wtime()
|
||||
{
|
||||
return (MPI_Wtime());
|
||||
}
|
||||
|
||||
inline double
|
||||
MPI::Wtick()
|
||||
{
|
||||
return (MPI_Wtick());
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Real_init()
|
||||
{
|
||||
// This is here even though ERRORS_THROW_EXCEPTIONS is a const
|
||||
// function; there's no way around this. :-(
|
||||
MPI::ERRORS_THROW_EXCEPTIONS.init();
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Init(int& argc, char**& argv)
|
||||
{
|
||||
(void)MPI_Init(&argc, &argv);
|
||||
Real_init();
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Init()
|
||||
{
|
||||
(void)MPI_Init(0, 0);
|
||||
Real_init();
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Finalize()
|
||||
{
|
||||
// Prevent a memory leak by calling this hidden "free" function here
|
||||
// (even though ERRORS_THROW_EXCEPTIONS is a const object)
|
||||
MPI::ERRORS_THROW_EXCEPTIONS.free();
|
||||
(void)MPI_Finalize();
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Is_initialized()
|
||||
{
|
||||
int t;
|
||||
(void)MPI_Initialized(&t);
|
||||
return (bool) t;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// External Interfaces
|
||||
//
|
||||
|
||||
inline int
|
||||
MPI::Init_thread(int required)
|
||||
{
|
||||
int provided;
|
||||
(void) MPI_Init_thread(0, NULL, required, &provided);
|
||||
Real_init();
|
||||
return provided;
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
MPI::Init_thread(int& argc, char**& argv, int required)
|
||||
{
|
||||
int provided;
|
||||
(void) MPI_Init_thread(&argc, &argv, required, &provided);
|
||||
Real_init();
|
||||
return provided;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
MPI::Is_thread_main()
|
||||
{
|
||||
int flag;
|
||||
(void) MPI_Is_thread_main(&flag);
|
||||
return ((flag == 1) ? true : false);
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
MPI::Query_thread()
|
||||
{
|
||||
int provided;
|
||||
(void) MPI_Query_thread(&provided);
|
||||
return provided;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Miscellany
|
||||
//
|
||||
|
||||
|
||||
inline void*
|
||||
MPI::Alloc_mem(MPI::Aint size, const MPI::Info& info)
|
||||
{
|
||||
void* baseptr;
|
||||
(void) MPI_Alloc_mem(size, info, &baseptr);
|
||||
return baseptr;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Free_mem(void* base)
|
||||
{
|
||||
(void) MPI_Free_mem(base);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Process Creation
|
||||
//
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Close_port(const char* port_name)
|
||||
{
|
||||
(void) MPI_Close_port((char *) port_name);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Lookup_name(const char * service_name,
|
||||
const MPI::Info& info,
|
||||
char* port_name)
|
||||
{
|
||||
(void) MPI_Lookup_name((char *) service_name, info, port_name);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Open_port(const MPI::Info& info, char* port_name)
|
||||
{
|
||||
(void) MPI_Open_port(info, port_name);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Publish_name(const char* service_name,
|
||||
const MPI::Info& info,
|
||||
const char* port_name)
|
||||
{
|
||||
(void) MPI_Publish_name((char *) service_name, info,
|
||||
(char *) port_name);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Unpublish_name(const char* service_name,
|
||||
const MPI::Info& info,
|
||||
const char* port_name)
|
||||
{
|
||||
(void)MPI_Unpublish_name((char *) service_name, info,
|
||||
(char *) port_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Profiling
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Pcontrol(const int level, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, level);
|
||||
|
||||
(void)MPI_Pcontrol(level, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Get_version(int& version, int& subversion)
|
||||
{
|
||||
(void)MPI_Get_version(&version, &subversion);
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Aint
|
||||
MPI::Get_address(void* location)
|
||||
{
|
||||
MPI::Aint ret;
|
||||
MPI_Get_address(location, &ret);
|
||||
return ret;
|
||||
}
|
109
src/mpi/cxx/group.h
Обычный файл
109
src/mpi/cxx/group.h
Обычный файл
@ -0,0 +1,109 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
class Group {
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// friend class PMPI::Group;
|
||||
#endif
|
||||
public:
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
// construction
|
||||
inline Group() { }
|
||||
inline Group(const MPI_Group &i) : pmpi_group(i) { }
|
||||
// copy
|
||||
inline Group(const Group& g) : pmpi_group(g.pmpi_group) { }
|
||||
|
||||
inline Group(const PMPI::Group& g) : pmpi_group(g) { }
|
||||
|
||||
inline virtual ~Group() {}
|
||||
|
||||
Group& operator=(const Group& g) {
|
||||
pmpi_group = g.pmpi_group; return *this;
|
||||
}
|
||||
|
||||
// comparison
|
||||
inline bool operator== (const Group &a) {
|
||||
return (bool)(pmpi_group == a.pmpi_group);
|
||||
}
|
||||
inline bool operator!= (const Group &a) {
|
||||
return (bool)!(*this == a);
|
||||
}
|
||||
|
||||
// inter-language operability
|
||||
Group& operator= (const MPI_Group &i) { pmpi_group = i; return *this; }
|
||||
inline operator MPI_Group () const { return pmpi_group.mpi(); }
|
||||
// inline operator MPI_Group* () const { return pmpi_group; }
|
||||
inline operator const PMPI::Group&() const { return pmpi_group; }
|
||||
|
||||
const PMPI::Group& pmpi() { return pmpi_group; }
|
||||
#else
|
||||
|
||||
// construction
|
||||
inline Group() : mpi_group(MPI_GROUP_NULL) { }
|
||||
inline Group(const MPI_Group &i) : mpi_group(i) { }
|
||||
|
||||
// copy
|
||||
inline Group(const Group& g) : mpi_group(g.mpi_group) { }
|
||||
|
||||
inline virtual ~Group() {}
|
||||
|
||||
inline Group& operator=(const Group& g) { mpi_group = g.mpi_group; return *this; }
|
||||
|
||||
// comparison
|
||||
inline bool operator== (const Group &a) { return (bool)(mpi_group == a.mpi_group); }
|
||||
inline bool operator!= (const Group &a) { return (bool)!(*this == a); }
|
||||
|
||||
// inter-language operability
|
||||
inline Group& operator= (const MPI_Group &i) { mpi_group = i; return *this; }
|
||||
inline operator MPI_Group () const { return mpi_group; }
|
||||
// inline operator MPI_Group* () const { return (MPI_Group*)&mpi_group; }
|
||||
|
||||
inline MPI_Group mpi() const { return mpi_group; }
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Groups, Contexts, and Communicators
|
||||
//
|
||||
|
||||
virtual int Get_size() const;
|
||||
|
||||
virtual int Get_rank() const;
|
||||
|
||||
static void Translate_ranks (const Group& group1, int n, const int ranks1[],
|
||||
const Group& group2, int ranks2[]);
|
||||
|
||||
static int Compare(const Group& group1, const Group& group2);
|
||||
|
||||
static Group Union(const Group &group1, const Group &group2);
|
||||
|
||||
static Group Intersect(const Group &group1, const Group &group2);
|
||||
|
||||
static Group Difference(const Group &group1, const Group &group2);
|
||||
|
||||
virtual Group Incl(int n, const int ranks[]) const;
|
||||
|
||||
virtual Group Excl(int n, const int ranks[]) const;
|
||||
|
||||
virtual Group Range_incl(int n, const int ranges[][3]) const;
|
||||
|
||||
virtual Group Range_excl(int n, const int ranges[][3]) const;
|
||||
|
||||
virtual void Free();
|
||||
|
||||
protected:
|
||||
#if ! 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
MPI_Group mpi_group;
|
||||
#endif
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
private:
|
||||
PMPI::Group pmpi_group;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
102
src/mpi/cxx/group_inln.h
Обычный файл
102
src/mpi/cxx/group_inln.h
Обычный файл
@ -0,0 +1,102 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
//
|
||||
// Groups, Contexts, and Communicators
|
||||
//
|
||||
|
||||
inline int
|
||||
MPI::Group::Get_size() const
|
||||
{
|
||||
int size;
|
||||
(void)MPI_Group_size(mpi_group, &size);
|
||||
return size;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Group::Get_rank() const
|
||||
{
|
||||
int rank;
|
||||
(void)MPI_Group_rank(mpi_group, &rank);
|
||||
return rank;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Group::Translate_ranks (const MPI::Group& group1, int n,
|
||||
const int ranks1[],
|
||||
const MPI::Group& group2, int ranks2[])
|
||||
{
|
||||
(void)MPI_Group_translate_ranks(group1, n, (int*)ranks1, group2, (int*)ranks2);
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Group::Compare(const MPI::Group& group1, const MPI::Group& group2)
|
||||
{
|
||||
int result;
|
||||
(void)MPI_Group_compare(group1, group2, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline MPI::Group
|
||||
MPI::Group::Union(const MPI::Group &group1, const MPI::Group &group2)
|
||||
{
|
||||
MPI_Group newgroup;
|
||||
(void)MPI_Group_union(group1, group2, &newgroup);
|
||||
return newgroup;
|
||||
}
|
||||
|
||||
inline MPI::Group
|
||||
MPI::Group::Intersect(const MPI::Group &group1, const MPI::Group &group2)
|
||||
{
|
||||
MPI_Group newgroup;
|
||||
(void)MPI_Group_intersection( group1, group2, &newgroup);
|
||||
return newgroup;
|
||||
}
|
||||
|
||||
inline MPI::Group
|
||||
MPI::Group::Difference(const MPI::Group &group1, const MPI::Group &group2)
|
||||
{
|
||||
MPI_Group newgroup;
|
||||
(void)MPI_Group_difference(group1, group2, &newgroup);
|
||||
return newgroup;
|
||||
}
|
||||
|
||||
inline MPI::Group
|
||||
MPI::Group::Incl(int n, const int ranks[]) const
|
||||
{
|
||||
MPI_Group newgroup;
|
||||
(void)MPI_Group_incl(mpi_group, n, (int*)ranks, &newgroup);
|
||||
return newgroup;
|
||||
}
|
||||
|
||||
inline MPI::Group
|
||||
MPI::Group::Excl(int n, const int ranks[]) const
|
||||
{
|
||||
MPI_Group newgroup;
|
||||
(void)MPI_Group_excl(mpi_group, n, (int*)ranks, &newgroup);
|
||||
return newgroup;
|
||||
}
|
||||
|
||||
inline MPI::Group
|
||||
MPI::Group::Range_incl(int n, const int ranges[][3]) const
|
||||
{
|
||||
MPI_Group newgroup;
|
||||
(void)MPI_Group_range_incl(mpi_group, n, (int(*)[3])ranges, &newgroup);
|
||||
return newgroup;
|
||||
}
|
||||
|
||||
inline MPI::Group
|
||||
MPI::Group::Range_excl(int n, const int ranges[][3]) const
|
||||
{
|
||||
MPI_Group newgroup;
|
||||
(void)MPI_Group_range_excl(mpi_group, n, (int(*)[3])ranges, &newgroup);
|
||||
return newgroup;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Group::Free()
|
||||
{
|
||||
(void)MPI_Group_free(&mpi_group);
|
||||
}
|
88
src/mpi/cxx/info.h
Обычный файл
88
src/mpi/cxx/info.h
Обычный файл
@ -0,0 +1,88 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
class Info {
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// friend class PMPI::Info;
|
||||
#endif
|
||||
friend class MPI::Comm; //so I can access pmpi_info data member in comm.cc
|
||||
friend class MPI::Request; //and also from request.cc
|
||||
|
||||
public:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
// construction / destruction
|
||||
Info() { }
|
||||
virtual ~Info() {}
|
||||
|
||||
|
||||
// copy / assignment
|
||||
Info(const Info& data) : pmpi_info(data.pmpi_info) { }
|
||||
|
||||
Info(const MPI_Info &i) : pmpi_info(i) { }
|
||||
|
||||
Info& operator=(const Info& data) {
|
||||
pmpi_info = data.pmpi_info; return *this; }
|
||||
|
||||
// comparison, don't need for info
|
||||
|
||||
// inter-language operability
|
||||
Info& operator= (const MPI_Info &i) {
|
||||
pmpi_info = i; return *this; }
|
||||
operator MPI_Info () const { return pmpi_info; }
|
||||
// operator MPI_Info* () const { return pmpi_info; }
|
||||
operator const PMPI::Info&() const { return pmpi_info; }
|
||||
|
||||
|
||||
#else
|
||||
|
||||
Info() { }
|
||||
// copy
|
||||
Info(const Info& data) : mpi_info(data.mpi_info) { }
|
||||
|
||||
Info(const MPI_Info &i) : mpi_info(i) { }
|
||||
|
||||
virtual ~Info() {}
|
||||
|
||||
Info& operator=(const Info& data) {
|
||||
mpi_info = data.mpi_info; return *this; }
|
||||
|
||||
// comparison, don't need for info
|
||||
|
||||
// inter-language operability
|
||||
Info& operator= (const MPI_Info &i) {
|
||||
mpi_info = i; return *this; }
|
||||
operator MPI_Info () const { return mpi_info; }
|
||||
// operator MPI_Info* () const { return (MPI_Info*)&mpi_info; }
|
||||
|
||||
#endif
|
||||
|
||||
static Info Create();
|
||||
|
||||
virtual void Delete(const char* key);
|
||||
|
||||
virtual Info Dup() const;
|
||||
|
||||
virtual void Free();
|
||||
|
||||
virtual bool Get(const char* key, int valuelen, char* value) const;
|
||||
|
||||
virtual int Get_nkeys() const;
|
||||
|
||||
virtual void Get_nthkey(int n, char* key) const;
|
||||
|
||||
virtual bool Get_valuelen(const char* key, int& valuelen) const;
|
||||
|
||||
virtual void Set(const char* key, const char* value);
|
||||
|
||||
protected:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
PMPI::Info pmpi_info;
|
||||
#else
|
||||
MPI_Info mpi_info;
|
||||
#endif
|
||||
|
||||
};
|
69
src/mpi/cxx/info_inln.h
Обычный файл
69
src/mpi/cxx/info_inln.h
Обычный файл
@ -0,0 +1,69 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
inline MPI::Info
|
||||
MPI::Info::Create()
|
||||
{
|
||||
MPI_Info newinfo;
|
||||
(void) MPI_Info_create(&newinfo);
|
||||
return newinfo;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Info::Delete(const char* key)
|
||||
{
|
||||
(void)MPI_Info_delete(mpi_info, (char*)key);
|
||||
}
|
||||
|
||||
inline MPI::Info
|
||||
MPI::Info::Dup() const
|
||||
{
|
||||
MPI_Info newinfo;
|
||||
(void)MPI_Info_dup(mpi_info, &newinfo);
|
||||
return newinfo;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Info::Free()
|
||||
{
|
||||
(void) MPI_Info_free(&mpi_info);
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Info::Get(const char* key, int valuelen, char* value) const
|
||||
{
|
||||
int flag;
|
||||
(void)MPI_Info_get(mpi_info, (char*)key, valuelen, value, &flag);
|
||||
return (bool) flag;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Info::Get_nkeys() const
|
||||
{
|
||||
int nkeys;
|
||||
MPI_Info_get_nkeys(mpi_info, &nkeys);
|
||||
return nkeys;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Info::Get_nthkey(int n, char* key) const
|
||||
{
|
||||
(void) MPI_Info_get_nthkey(mpi_info, n, key);
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Info::Get_valuelen(const char* key, int& valuelen) const
|
||||
{
|
||||
int flag;
|
||||
(void) MPI_Info_get_valuelen(mpi_info, (char*)key, &valuelen, &flag);
|
||||
return (bool) flag;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Info::Set(const char* key, const char* value)
|
||||
{
|
||||
(void) MPI_Info_set(mpi_info, (char*)key, (char*)value);
|
||||
}
|
168
src/mpi/cxx/intercepts.cc
Обычный файл
168
src/mpi/cxx/intercepts.cc
Обычный файл
@ -0,0 +1,168 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
#include "mpicxx.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C"
|
||||
void throw_excptn_fctn(MPI_Comm *, int *errcode, ...)
|
||||
{
|
||||
#if OMPI_HAVE_CXX_EXCEPTION_SUPPORT
|
||||
throw(MPI::Exception(*errcode));
|
||||
#else
|
||||
// Ick. This is really ugly, but necesary if someone uses a C compiler
|
||||
// and -lmpi++ (which can legally happen in the LAM MPI implementation,
|
||||
// and probably in MPICH and others who include -lmpi++ by default in their
|
||||
// wrapper compilers)
|
||||
fprintf(stderr, "MPI 2 C++ exception throwing is disabled, MPI::mpi_errno has the error code\n");
|
||||
MPI::mpi_errno = *errcode;
|
||||
#endif
|
||||
}
|
||||
|
||||
MPI::Comm::mpi_comm_map_t MPI::Comm::mpi_comm_map;
|
||||
MPI::Comm::mpi_err_map_t MPI::Comm::mpi_err_map;
|
||||
MPI::Comm::key_fn_map_t MPI::Comm::key_fn_map;
|
||||
|
||||
ompi_mutex_t *MPI::Comm::mpi_comm_map_mutex = NULL;
|
||||
ompi_mutex_t *MPI::Comm::mpi_err_map_mutex = NULL;
|
||||
ompi_mutex_t *MPI::Comm::key_fn_map_mutex = NULL;
|
||||
|
||||
extern "C"
|
||||
void
|
||||
errhandler_intercept(MPI_Comm *mpi_comm, int *err, ...)
|
||||
{
|
||||
MPI::Comm* comm = MPI::Comm::mpi_err_map[*mpi_comm];
|
||||
if (comm && comm->my_errhandler) {
|
||||
va_list ap;
|
||||
va_start(ap, err);
|
||||
comm->my_errhandler->handler_fn(*comm, err, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
MPI::Op* MPI::Intracomm::current_op;
|
||||
|
||||
extern "C" void
|
||||
op_intercept(void *invec, void *outvec, int *len, MPI_Datatype *datatype)
|
||||
{
|
||||
MPI::Op* op = MPI::Intracomm::current_op;
|
||||
MPI::Datatype thedata = *datatype;
|
||||
((MPI::User_function*)op->op_user_function)(invec, outvec, *len, thedata);
|
||||
//JGS the above cast is a bit of a hack, I'll explain:
|
||||
// the type for the PMPI::Op::op_user_function is PMPI::User_function
|
||||
// but what it really stores is the user's MPI::User_function supplied when
|
||||
// the user did an Op::Init. We need to cast the function pointer back to
|
||||
// the MPI::User_function. The reason the PMPI::Op::op_user_function was
|
||||
// not declared a MPI::User_function instead of a PMPI::User_function is
|
||||
// that without namespaces we cannot do forward declarations.
|
||||
// Anyway, without the cast the code breaks on HP LAM with the aCC compiler.
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
copy_attr_intercept(MPI_Comm oldcomm, int keyval,
|
||||
void *extra_state, void *attribute_val_in,
|
||||
void *attribute_val_out, int *flag)
|
||||
{
|
||||
int ret = 0;
|
||||
MPI::Comm::key_pair_t* copy_and_delete =
|
||||
MPI::Comm::key_fn_map[keyval];
|
||||
MPI::Comm::Copy_attr_function* copy_fn;
|
||||
copy_fn = copy_and_delete->first;
|
||||
|
||||
MPI::Comm::comm_pair_t *comm_type =
|
||||
MPI::Comm::mpi_comm_map[oldcomm];
|
||||
|
||||
// Just in case...
|
||||
|
||||
if (comm_type == 0)
|
||||
return MPI::ERR_OTHER;
|
||||
|
||||
MPI::Intracomm intracomm;
|
||||
MPI::Intercomm intercomm;
|
||||
MPI::Graphcomm graphcomm;
|
||||
MPI::Cartcomm cartcomm;
|
||||
|
||||
int thetype = (int)comm_type->second;
|
||||
bool bflag = (bool)*flag;
|
||||
|
||||
switch (thetype) {
|
||||
case eIntracomm:
|
||||
intracomm = MPI::Intracomm(*comm_type->first);
|
||||
ret = copy_fn(intracomm, keyval, extra_state,
|
||||
attribute_val_in, attribute_val_out, bflag);
|
||||
break;
|
||||
case eIntercomm:
|
||||
intercomm = MPI::Intercomm(*comm_type->first);
|
||||
ret = copy_fn(intercomm, keyval, extra_state,
|
||||
attribute_val_in, attribute_val_out, bflag);
|
||||
break;
|
||||
case eGraphcomm:
|
||||
graphcomm = MPI::Graphcomm(*comm_type->first);
|
||||
ret = copy_fn(graphcomm, keyval, extra_state,
|
||||
attribute_val_in, attribute_val_out, bflag);
|
||||
break;
|
||||
case eCartcomm:
|
||||
cartcomm = MPI::Cartcomm(*comm_type->first);
|
||||
ret = copy_fn(cartcomm, keyval, extra_state,
|
||||
attribute_val_in, attribute_val_out, bflag);
|
||||
break;
|
||||
}
|
||||
|
||||
*flag = (int)bflag;
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
delete_attr_intercept(MPI_Comm comm, int keyval,
|
||||
void *attribute_val, void *extra_state)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
MPI::Comm::key_pair_t *copy_and_delete =
|
||||
MPI::Comm::key_fn_map[keyval];
|
||||
|
||||
MPI::Comm::Delete_attr_function* delete_fn;
|
||||
delete_fn = copy_and_delete->second;
|
||||
|
||||
MPI::Comm::comm_pair_t *comm_type =
|
||||
MPI::Comm::mpi_comm_map[comm];
|
||||
|
||||
// Just in case...
|
||||
|
||||
if (comm_type == 0)
|
||||
return MPI::ERR_OTHER;
|
||||
|
||||
MPI::Intracomm intracomm;
|
||||
MPI::Intercomm intercomm;
|
||||
MPI::Graphcomm graphcomm;
|
||||
MPI::Cartcomm cartcomm;
|
||||
|
||||
int thetype = (long)(comm_type->second);
|
||||
|
||||
if (delete_fn > (MPI::Comm::Delete_attr_function*) 100) {
|
||||
switch (thetype) {
|
||||
case eIntracomm:
|
||||
intracomm = MPI::Intracomm(*comm_type->first);
|
||||
ret = delete_fn(intracomm, keyval, attribute_val, extra_state);
|
||||
break;
|
||||
case eIntercomm:
|
||||
intercomm = MPI::Intercomm(*comm_type->first);
|
||||
ret = delete_fn(intercomm, keyval, attribute_val, extra_state);
|
||||
break;
|
||||
case eGraphcomm:
|
||||
graphcomm = MPI::Graphcomm(*comm_type->first);
|
||||
ret = delete_fn(graphcomm, keyval, attribute_val, extra_state);
|
||||
break;
|
||||
case eCartcomm:
|
||||
cartcomm = MPI::Cartcomm(*comm_type->first);
|
||||
ret = delete_fn(cartcomm, keyval, attribute_val, extra_state);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
ret = MPI::ERR_OTHER;
|
||||
return ret;
|
||||
}
|
||||
|
85
src/mpi/cxx/intercomm.h
Обычный файл
85
src/mpi/cxx/intercomm.h
Обычный файл
@ -0,0 +1,85 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
class Intercomm : public Comm {
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// friend class PMPI::Intercomm;
|
||||
#endif
|
||||
public:
|
||||
|
||||
// construction
|
||||
Intercomm() : Comm(MPI_COMM_NULL) { }
|
||||
// copy
|
||||
Intercomm(const Comm_Null& data) : Comm(data) { }
|
||||
// inter-language operability
|
||||
Intercomm(const MPI_Comm& data) : Comm(data) { }
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// copy
|
||||
Intercomm(const Intercomm& data) : Comm(data), pmpi_comm(data.pmpi_comm) { }
|
||||
Intercomm(const PMPI::Intercomm& d) :
|
||||
Comm((const PMPI::Comm&)d), pmpi_comm(d) { }
|
||||
|
||||
// assignment
|
||||
Intercomm& operator=(const Intercomm& data) {
|
||||
Comm::operator=(data);
|
||||
pmpi_comm = data.pmpi_comm; return *this; }
|
||||
Intercomm& operator=(const Comm_Null& data) {
|
||||
Comm::operator=(data);
|
||||
Intercomm& ic = (Intercomm&)data;
|
||||
pmpi_comm = ic.pmpi_comm; return *this; }
|
||||
// inter-language operability
|
||||
Intercomm& operator=(const MPI_Comm& data) {
|
||||
Comm::operator=(data);
|
||||
pmpi_comm = PMPI::Intercomm(data); return *this; }
|
||||
#else
|
||||
// copy
|
||||
Intercomm(const Intercomm& data) : Comm(data.mpi_comm) { }
|
||||
// assignment
|
||||
Intercomm& operator=(const Intercomm& data) {
|
||||
mpi_comm = data.mpi_comm; return *this; }
|
||||
Intercomm& operator=(const Comm_Null& data) {
|
||||
mpi_comm = data; return *this; }
|
||||
// inter-language operability
|
||||
Intercomm& operator=(const MPI_Comm& data) {
|
||||
mpi_comm = data; return *this; }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Groups, Contexts, and Communicators
|
||||
//
|
||||
|
||||
Intercomm Dup() const;
|
||||
|
||||
virtual Intercomm& Clone() const;
|
||||
|
||||
virtual int Get_remote_size() const;
|
||||
|
||||
virtual Group Get_remote_group() const;
|
||||
|
||||
virtual Intracomm Merge(bool high);
|
||||
|
||||
|
||||
//
|
||||
// Extended Collective Operations
|
||||
//
|
||||
|
||||
virtual Intercomm Create(const Group& group) const;
|
||||
|
||||
virtual Intercomm Split(int color, int key) const;
|
||||
|
||||
|
||||
//#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// virtual const PMPI::Comm& get_pmpi_comm() const { return pmpi_comm; }
|
||||
//#endif
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
private:
|
||||
PMPI::Intercomm pmpi_comm;
|
||||
#endif
|
||||
};
|
66
src/mpi/cxx/intercomm_inln.h
Обычный файл
66
src/mpi/cxx/intercomm_inln.h
Обычный файл
@ -0,0 +1,66 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Intercomm::Dup() const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Comm_dup(mpi_comm, &newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
inline MPI::Intercomm&
|
||||
MPI::Intercomm::Clone() const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Comm_dup(mpi_comm, &newcomm);
|
||||
MPI::Intercomm* dup = new MPI::Intercomm(newcomm);
|
||||
return *dup;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Intercomm::Get_remote_size() const
|
||||
{
|
||||
int size;
|
||||
(void)MPI_Comm_remote_size(mpi_comm, &size);
|
||||
return size;
|
||||
}
|
||||
|
||||
inline MPI::Group
|
||||
MPI::Intercomm::Get_remote_group() const
|
||||
{
|
||||
MPI_Group group;
|
||||
(void)MPI_Comm_remote_group(mpi_comm, &group);
|
||||
return group;
|
||||
}
|
||||
|
||||
inline MPI::Intracomm
|
||||
MPI::Intercomm::Merge(bool high)
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Intercomm_merge(mpi_comm, (int)high, &newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Extended Collective Operations
|
||||
//
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Intercomm::Create(const Group& group) const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void) MPI_Comm_create(mpi_comm, (MPI_Group) group, &newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Intercomm::Split(int color, int key) const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void) MPI_Comm_split(mpi_comm, color, key, &newcomm);
|
||||
return newcomm;
|
||||
}
|
222
src/mpi/cxx/intracomm.h
Обычный файл
222
src/mpi/cxx/intracomm.h
Обычный файл
@ -0,0 +1,222 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
class Intracomm : public Comm {
|
||||
public:
|
||||
|
||||
// construction
|
||||
Intracomm() { }
|
||||
// copy
|
||||
Intracomm(const Comm_Null& data) : Comm(data) { }
|
||||
// inter-language operability
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
//NOTE: it is extremely important that Comm(data) happens below
|
||||
// because there is a not only pmpi_comm in this Intracomm but
|
||||
// there is also a pmpi_comm in the inherited Comm part. Both
|
||||
// of these pmpi_comm's need to be initialized with the same
|
||||
// MPI_Comm object. Also the assignment operators must take this
|
||||
// into account.
|
||||
Intracomm(const Intracomm& data) : Comm(data), pmpi_comm(data) { }
|
||||
|
||||
Intracomm(const MPI_Comm& data) : Comm(data), pmpi_comm(data) { }
|
||||
|
||||
Intracomm(const PMPI::Intracomm& data)
|
||||
: Comm((const PMPI::Comm&)data), pmpi_comm(data) { }
|
||||
|
||||
// assignment
|
||||
Intracomm& operator=(const Intracomm& data) {
|
||||
Comm::operator=(data);
|
||||
pmpi_comm = data.pmpi_comm;
|
||||
return *this;
|
||||
}
|
||||
Intracomm& operator=(const Comm_Null& data) {
|
||||
Comm::operator=(data);
|
||||
pmpi_comm = (PMPI::Intracomm)data; return *this;
|
||||
}
|
||||
// inter-language operability
|
||||
Intracomm& operator=(const MPI_Comm& data) {
|
||||
Comm::operator=(data);
|
||||
pmpi_comm = data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#else
|
||||
Intracomm(const Intracomm& data) : Comm(data.mpi_comm) { }
|
||||
|
||||
inline Intracomm(const MPI_Comm& data);
|
||||
|
||||
// assignment
|
||||
Intracomm& operator=(const Intracomm& data) {
|
||||
mpi_comm = data.mpi_comm; return *this;
|
||||
}
|
||||
|
||||
Intracomm& operator=(const Comm_Null& data) {
|
||||
mpi_comm = data; return *this;
|
||||
}
|
||||
|
||||
// inter-language operability
|
||||
Intracomm& operator=(const MPI_Comm& data) {
|
||||
mpi_comm = data; return *this; }
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Collective Communication
|
||||
//
|
||||
|
||||
virtual void
|
||||
Barrier() const;
|
||||
|
||||
virtual void
|
||||
Bcast(void *buffer, int count,
|
||||
const Datatype& datatype, int root) const;
|
||||
|
||||
virtual void
|
||||
Gather(const void *sendbuf, int sendcount,
|
||||
const Datatype & sendtype,
|
||||
void *recvbuf, int recvcount,
|
||||
const Datatype & recvtype, int root) const;
|
||||
|
||||
virtual void
|
||||
Gatherv(const void *sendbuf, int sendcount,
|
||||
const Datatype & sendtype, void *recvbuf,
|
||||
const int recvcounts[], const int displs[],
|
||||
const Datatype & recvtype, int root) const;
|
||||
|
||||
virtual void
|
||||
Scatter(const void *sendbuf, int sendcount,
|
||||
const Datatype & sendtype,
|
||||
void *recvbuf, int recvcount,
|
||||
const Datatype & recvtype, int root) const;
|
||||
|
||||
virtual void
|
||||
Scatterv(const void *sendbuf, const int sendcounts[],
|
||||
const int displs[], const Datatype & sendtype,
|
||||
void *recvbuf, int recvcount,
|
||||
const Datatype & recvtype, int root) const;
|
||||
|
||||
virtual void
|
||||
Allgather(const void *sendbuf, int sendcount,
|
||||
const Datatype & sendtype, void *recvbuf,
|
||||
int recvcount, const Datatype & recvtype) const;
|
||||
|
||||
virtual void
|
||||
Allgatherv(const void *sendbuf, int sendcount,
|
||||
const Datatype & sendtype, void *recvbuf,
|
||||
const int recvcounts[], const int displs[],
|
||||
const Datatype & recvtype) const;
|
||||
|
||||
virtual void
|
||||
Alltoall(const void *sendbuf, int sendcount,
|
||||
const Datatype & sendtype, void *recvbuf,
|
||||
int recvcount, const Datatype & recvtype) const;
|
||||
|
||||
virtual void
|
||||
Alltoallv(const void *sendbuf, const int sendcounts[],
|
||||
const int sdispls[], const Datatype & sendtype,
|
||||
void *recvbuf, const int recvcounts[],
|
||||
const int rdispls[], const Datatype & recvtype) const;
|
||||
|
||||
virtual void
|
||||
Alltoallw(const void *sendbuf, const int sendcounts[],
|
||||
const int sdispls[], const Datatype sendtypes[],
|
||||
void *recvbuf, const int recvcounts[],
|
||||
const int rdispls[], const Datatype recvtypes[]) const;
|
||||
|
||||
virtual void
|
||||
Reduce(const void *sendbuf, void *recvbuf, int count,
|
||||
const Datatype & datatype, const Op & op,
|
||||
int root) const;
|
||||
|
||||
|
||||
virtual void
|
||||
Allreduce(const void *sendbuf, void *recvbuf, int count,
|
||||
const Datatype & datatype, const Op & op) const;
|
||||
|
||||
virtual void
|
||||
Reduce_scatter(const void *sendbuf, void *recvbuf,
|
||||
int recvcounts[],
|
||||
const Datatype & datatype,
|
||||
const Op & op) const;
|
||||
|
||||
virtual void
|
||||
Scan(const void *sendbuf, void *recvbuf, int count,
|
||||
const Datatype & datatype, const Op & op) const;
|
||||
|
||||
virtual void
|
||||
Exscan(const void *sendbuf, void *recvbuf, int count,
|
||||
const Datatype & datatype, const Op & op) const;
|
||||
|
||||
Intracomm
|
||||
Dup() const;
|
||||
|
||||
|
||||
virtual Intracomm& Clone() const;
|
||||
|
||||
virtual Intracomm
|
||||
Create(const Group& group) const;
|
||||
|
||||
virtual Intracomm
|
||||
Split(int color, int key) const;
|
||||
|
||||
virtual Intercomm
|
||||
Create_intercomm(int local_leader, const Comm& peer_comm,
|
||||
int remote_leader, int tag) const;
|
||||
|
||||
virtual Cartcomm
|
||||
Create_cart(int ndims, const int dims[],
|
||||
const bool periods[], bool reorder) const;
|
||||
|
||||
virtual Graphcomm
|
||||
Create_graph(int nnodes, const int index[],
|
||||
const int edges[], bool reorder) const;
|
||||
|
||||
|
||||
//
|
||||
// Process Creation and Management
|
||||
//
|
||||
|
||||
virtual Intercomm Accept(const char* port_name, const Info& info, int root)
|
||||
const;
|
||||
|
||||
virtual Intercomm Connect(const char* port_name, const Info& info, int root)
|
||||
const;
|
||||
|
||||
virtual Intercomm Spawn(const char* command, const char* argv[],
|
||||
int maxprocs, const Info& info, int root) const;
|
||||
|
||||
virtual Intercomm Spawn(const char* command, const char* argv[],
|
||||
int maxprocs, const Info& info,
|
||||
int root, int array_of_errcodes[]) const;
|
||||
|
||||
virtual Intercomm Spawn_multiple(int count, const char* array_of_commands[],
|
||||
const char** array_of_argv[],
|
||||
const int array_of_maxprocs[],
|
||||
const Info array_of_info[], int root);
|
||||
|
||||
virtual Intercomm Spawn_multiple(int count, const char* array_of_commands[],
|
||||
const char** array_of_argv[],
|
||||
const int array_of_maxprocs[],
|
||||
const Info array_of_info[], int root,
|
||||
int array_of_errcodes[]);
|
||||
|
||||
|
||||
//#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// virtual const PMPI::Comm& get_pmpi_comm() const { return pmpi_comm; }
|
||||
//#endif
|
||||
protected:
|
||||
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
PMPI::Intracomm pmpi_comm;
|
||||
#endif
|
||||
|
||||
public: // JGS see above about friend decls
|
||||
#if ! 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
static Op* current_op;
|
||||
#endif
|
||||
|
||||
};
|
353
src/mpi/cxx/intracomm_inln.h
Обычный файл
353
src/mpi/cxx/intracomm_inln.h
Обычный файл
@ -0,0 +1,353 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
inline
|
||||
MPI::Intracomm::Intracomm(const MPI_Comm& data) {
|
||||
int flag;
|
||||
if (MPI::Is_initialized() && (data != MPI_COMM_NULL)) {
|
||||
(void)MPI_Comm_test_inter(data, &flag);
|
||||
if (flag)
|
||||
mpi_comm = MPI_COMM_NULL;
|
||||
else
|
||||
mpi_comm = data;
|
||||
}
|
||||
else {
|
||||
mpi_comm = data;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Collective Communication
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Barrier() const
|
||||
{
|
||||
(void)MPI_Barrier(mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Bcast(void *buffer, int count,
|
||||
const MPI::Datatype& datatype, int root) const
|
||||
{
|
||||
(void)MPI_Bcast(buffer, count, datatype, root, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Gather(const void *sendbuf, int sendcount,
|
||||
const MPI::Datatype & sendtype,
|
||||
void *recvbuf, int recvcount,
|
||||
const MPI::Datatype & recvtype, int root) const
|
||||
{
|
||||
(void)MPI_Gather((void *)sendbuf, sendcount, sendtype,
|
||||
recvbuf, recvcount, recvtype, root, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Gatherv(const void *sendbuf, int sendcount,
|
||||
const MPI::Datatype & sendtype, void *recvbuf,
|
||||
const int recvcounts[], const int displs[],
|
||||
const MPI::Datatype & recvtype, int root) const
|
||||
{
|
||||
(void)MPI_Gatherv((void *)sendbuf, sendcount, sendtype,
|
||||
recvbuf, (int *)recvcounts, (int *)displs,
|
||||
recvtype, root, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Scatter(const void *sendbuf, int sendcount,
|
||||
const MPI::Datatype & sendtype,
|
||||
void *recvbuf, int recvcount,
|
||||
const MPI::Datatype & recvtype, int root) const
|
||||
{
|
||||
(void)MPI_Scatter((void *)sendbuf, sendcount, sendtype,
|
||||
recvbuf, recvcount, recvtype, root, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Scatterv(const void *sendbuf, const int sendcounts[],
|
||||
const int displs[], const MPI::Datatype & sendtype,
|
||||
void *recvbuf, int recvcount,
|
||||
const MPI::Datatype & recvtype, int root) const
|
||||
{
|
||||
(void)MPI_Scatterv((void *)sendbuf, (int *) sendcounts,
|
||||
(int *) displs, sendtype,
|
||||
recvbuf, recvcount, recvtype,
|
||||
root, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Allgather(const void *sendbuf, int sendcount,
|
||||
const MPI::Datatype & sendtype, void *recvbuf,
|
||||
int recvcount, const MPI::Datatype & recvtype) const
|
||||
{
|
||||
(void)MPI_Allgather((void *) sendbuf, sendcount,
|
||||
sendtype, recvbuf, recvcount,
|
||||
recvtype, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Allgatherv(const void *sendbuf, int sendcount,
|
||||
const MPI::Datatype & sendtype, void *recvbuf,
|
||||
const int recvcounts[], const int displs[],
|
||||
const MPI::Datatype & recvtype) const
|
||||
{
|
||||
(void)MPI_Allgatherv((void *)sendbuf, sendcount,
|
||||
sendtype, recvbuf,
|
||||
(int *) recvcounts, (int *) displs,
|
||||
recvtype, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Alltoall(const void *sendbuf, int sendcount,
|
||||
const MPI::Datatype & sendtype, void *recvbuf,
|
||||
int recvcount, const MPI::Datatype & recvtype) const
|
||||
{
|
||||
(void)MPI_Alltoall((void *) sendbuf, sendcount,
|
||||
sendtype, recvbuf, recvcount,
|
||||
recvtype, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Alltoallv(const void *sendbuf, const int sendcounts[],
|
||||
const int sdispls[], const MPI::Datatype & sendtype,
|
||||
void *recvbuf, const int recvcounts[],
|
||||
const int rdispls[], const MPI::Datatype & recvtype) const
|
||||
{
|
||||
(void)MPI_Alltoallv((void *) sendbuf, (int *) sendcounts,
|
||||
(int *) sdispls, sendtype, recvbuf,
|
||||
(int *) recvcounts, (int *) rdispls,
|
||||
recvtype,mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Alltoallw(const void *sendbuf, const int sendcounts[],
|
||||
const int sdispls[], const Datatype sendtypes[],
|
||||
void *recvbuf, const int recvcounts[],
|
||||
const int rdispls[], const Datatype recvtypes[]) const
|
||||
{
|
||||
(void)MPI_Alltoallw((void *) sendbuf, (int *) sendcounts,
|
||||
(int *) sdispls, (MPI_Datatype *) sendtypes, recvbuf,
|
||||
(int *) recvcounts, (int *) rdispls,
|
||||
(MPI_Datatype *) recvtypes, mpi_comm);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Reduce(const void *sendbuf, void *recvbuf, int count,
|
||||
const MPI::Datatype & datatype, const MPI::Op& op,
|
||||
int root) const
|
||||
{
|
||||
current_op = (MPI::Op*)&op;
|
||||
(void)MPI_Reduce((void*)sendbuf, recvbuf, count, datatype, op, root, mpi_comm);
|
||||
current_op = (Op*)0;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Allreduce(const void *sendbuf, void *recvbuf, int count,
|
||||
const MPI::Datatype & datatype, const MPI::Op& op) const
|
||||
{
|
||||
current_op = (MPI::Op*)&op;
|
||||
(void)MPI_Allreduce ((void*)sendbuf, recvbuf, count, datatype, op, mpi_comm);
|
||||
current_op = (Op*)0;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Reduce_scatter(const void *sendbuf, void *recvbuf,
|
||||
int recvcounts[],
|
||||
const MPI::Datatype & datatype,
|
||||
const MPI::Op& op) const
|
||||
{
|
||||
current_op = (MPI::Op*)&op;
|
||||
(void)MPI_Reduce_scatter((void*)sendbuf, recvbuf, recvcounts,
|
||||
datatype, op, mpi_comm);
|
||||
current_op = (Op*)0;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Scan(const void *sendbuf, void *recvbuf, int count,
|
||||
const MPI::Datatype & datatype, const MPI::Op& op) const
|
||||
{
|
||||
current_op = (MPI::Op*)&op;
|
||||
(void)MPI_Scan((void *)sendbuf, recvbuf, count, datatype, op, mpi_comm);
|
||||
current_op = (Op*)0;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Intracomm::Exscan(const void *sendbuf, void *recvbuf, int count,
|
||||
const MPI::Datatype & datatype,
|
||||
const MPI::Op& op) const
|
||||
{
|
||||
current_op = (MPI::Op*)&op;
|
||||
(void)MPI_Exscan((void *)sendbuf, recvbuf, count, datatype, op, mpi_comm);
|
||||
current_op = (Op*)0;
|
||||
}
|
||||
|
||||
inline MPI::Intracomm
|
||||
MPI::Intracomm::Dup() const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Comm_dup(mpi_comm, &newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
inline MPI::Intracomm&
|
||||
MPI::Intracomm::Clone() const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Comm_dup(mpi_comm, &newcomm);
|
||||
MPI::Intracomm* dup = new MPI::Intracomm(newcomm);
|
||||
return *dup;
|
||||
}
|
||||
|
||||
inline MPI::Intracomm
|
||||
MPI::Intracomm::Create(const MPI::Group& group) const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Comm_create(mpi_comm, group, &newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
inline MPI::Intracomm
|
||||
MPI::Intracomm::Split(int color, int key) const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Comm_split(mpi_comm, color, key, &newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Intracomm::Create_intercomm(int local_leader,
|
||||
const MPI::Comm& peer_comm,
|
||||
int remote_leader, int tag) const
|
||||
{
|
||||
MPI_Comm newintercomm;
|
||||
(void)MPI_Intercomm_create(mpi_comm, local_leader, peer_comm,
|
||||
remote_leader, tag, &newintercomm);
|
||||
return newintercomm;
|
||||
}
|
||||
|
||||
inline MPI::Cartcomm
|
||||
MPI::Intracomm::Create_cart(int ndims, const int dims[],
|
||||
const bool periods[], bool reorder) const
|
||||
{
|
||||
int *int_periods = new int [ndims];
|
||||
for (int i=0; i<ndims; i++)
|
||||
int_periods[i] = (int) periods[i];
|
||||
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Cart_create(mpi_comm, ndims, (int*)dims,
|
||||
int_periods, (int)reorder, &newcomm);
|
||||
delete [] int_periods;
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
inline MPI::Graphcomm
|
||||
MPI::Intracomm::Create_graph(int nnodes, const int index[],
|
||||
const int edges[], bool reorder) const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Graph_create(mpi_comm, nnodes, (int*)index,
|
||||
(int*)edges, (int)reorder, &newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Process Creation and Management
|
||||
//
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Intracomm::Accept(const char* port_name,
|
||||
const MPI::Info& info,
|
||||
int root) const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void) MPI_Comm_accept((char *) port_name, info, root, mpi_comm,
|
||||
&newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Intracomm::Connect(const char* port_name,
|
||||
const MPI::Info& info,
|
||||
int root) const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void) MPI_Comm_connect((char *) port_name, info, root, mpi_comm,
|
||||
&newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Intracomm::Spawn(const char* command, const char* argv[],
|
||||
int maxprocs, const MPI::Info& info,
|
||||
int root) const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void) MPI_Comm_spawn((char *) command, (char **) argv, maxprocs,
|
||||
info, root, mpi_comm, &newcomm,
|
||||
(int *)MPI_ERRCODES_IGNORE);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Intracomm::Spawn(const char* command, const char* argv[],
|
||||
int maxprocs, const MPI::Info& info,
|
||||
int root, int array_of_errcodes[]) const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void) MPI_Comm_spawn((char *) command, (char **) argv, maxprocs,
|
||||
info, root, mpi_comm, &newcomm,
|
||||
array_of_errcodes);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Intracomm::Spawn_multiple(int count,
|
||||
const char* array_of_commands[],
|
||||
const char** array_of_argv[],
|
||||
const int array_of_maxprocs[],
|
||||
const Info array_of_info[], int root)
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
MPI_Comm_spawn_multiple(count, (char **) array_of_commands,
|
||||
(char ***) array_of_argv, (int *) array_of_maxprocs,
|
||||
(MPI_Info *) array_of_info, root,
|
||||
mpi_comm, &newcomm, (int *)MPI_ERRCODES_IGNORE);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Intercomm
|
||||
MPI::Intracomm::Spawn_multiple(int count,
|
||||
const char* array_of_commands[],
|
||||
const char** array_of_argv[],
|
||||
const int array_of_maxprocs[],
|
||||
const Info array_of_info[], int root,
|
||||
int array_of_errcodes[])
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
MPI_Comm_spawn_multiple(count, (char **) array_of_commands,
|
||||
(char ***) array_of_argv, (int *) array_of_maxprocs,
|
||||
(MPI_Info *) array_of_info, root,
|
||||
mpi_comm, &newcomm, array_of_errcodes);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
222
src/mpi/cxx/mpicxx.cc
Обычный файл
222
src/mpi/cxx/mpicxx.cc
Обычный файл
@ -0,0 +1,222 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
|
||||
//
|
||||
|
||||
#include "mpicxx.h"
|
||||
|
||||
namespace MPI {
|
||||
|
||||
#if ! OMPI_HAVE_CXX_EXCEPTION_SUPPORT
|
||||
int mpi_errno = MPI_SUCCESS;
|
||||
#endif
|
||||
|
||||
|
||||
const void* BOTTOM = (void*) MPI_BOTTOM;
|
||||
|
||||
// return codes
|
||||
const int SUCCESS = MPI_SUCCESS;
|
||||
const int ERR_BUFFER = MPI_ERR_COUNT;
|
||||
const int ERR_TYPE = MPI_ERR_TYPE;
|
||||
const int ERR_TAG = MPI_ERR_TAG;
|
||||
const int ERR_COMM = MPI_ERR_COMM;
|
||||
const int ERR_RANK = MPI_ERR_RANK;
|
||||
const int ERR_REQUEST = MPI_ERR_REQUEST;
|
||||
const int ERR_ROOT = MPI_ERR_ROOT;
|
||||
const int ERR_GROUP = MPI_ERR_GROUP;
|
||||
const int ERR_OP = MPI_ERR_OP;
|
||||
const int ERR_TOPOLOGY = MPI_ERR_TOPOLOGY;
|
||||
const int ERR_DIMS = MPI_ERR_DIMS;
|
||||
const int ERR_ARG = MPI_ERR_ARG;
|
||||
const int ERR_UNKNOWN = MPI_ERR_UNKNOWN;
|
||||
const int ERR_TRUNCATE = MPI_ERR_TRUNCATE;
|
||||
const int ERR_OTHER = MPI_ERR_OTHER;
|
||||
const int ERR_INTERN = MPI_ERR_INTERN;
|
||||
|
||||
const int ERR_BASE = MPI_ERR_BASE;
|
||||
const int ERR_INFO_VALUE = MPI_ERR_INFO_VALUE;
|
||||
const int ERR_INFO_KEY = MPI_ERR_INFO_KEY;
|
||||
const int ERR_INFO_NOKEY = MPI_ERR_INFO_NOKEY;
|
||||
const int ERR_KEYVAL = MPI_ERR_KEYVAL;
|
||||
const int ERR_NAME = MPI_ERR_NAME;
|
||||
const int ERR_NO_MEM = MPI_ERR_NO_MEM;
|
||||
const int ERR_SERVICE = MPI_ERR_SERVICE;
|
||||
const int ERR_SPAWN = MPI_ERR_SPAWN;
|
||||
const int ERR_WIN = MPI_ERR_WIN;
|
||||
|
||||
const int ERR_PENDING = MPI_ERR_PENDING;
|
||||
const int ERR_IN_STATUS = MPI_ERR_IN_STATUS;
|
||||
const int ERR_LASTCODE = MPI_ERR_LASTCODE;
|
||||
|
||||
// assorted constants
|
||||
const int PROC_NULL = MPI_PROC_NULL;
|
||||
const int ANY_SOURCE = MPI_ANY_SOURCE;
|
||||
const int ANY_TAG = MPI_ANY_TAG;
|
||||
const int UNDEFINED = MPI_UNDEFINED;
|
||||
const int BSEND_OVERHEAD = MPI_BSEND_OVERHEAD;
|
||||
const int KEYVAL_INVALID = MPI_KEYVAL_INVALID;
|
||||
|
||||
// error-handling specifiers
|
||||
const Errhandler ERRORS_ARE_FATAL(MPI_ERRORS_ARE_FATAL);
|
||||
const Errhandler ERRORS_RETURN(MPI_ERRORS_RETURN);
|
||||
const Errhandler ERRORS_THROW_EXCEPTIONS(MPI_ERRORS_RETURN);
|
||||
//JGS: the MPI_ERRORS_RETURN function in ERRORS_THROW_EXCEPTIONS gets replaced
|
||||
//by the throw_exptn_fctn in Init)
|
||||
|
||||
// maximum sizes for strings
|
||||
const int MAX_PROCESSOR_NAME = MPI_MAX_PROCESSOR_NAME;
|
||||
const int MAX_ERROR_STRING = MPI_MAX_ERROR_STRING;
|
||||
const int MAX_INFO_KEY = MPI_MAX_INFO_KEY;
|
||||
const int MAX_INFO_VAL = MPI_MAX_INFO_VAL;
|
||||
const int MAX_PORT_NAME = MPI_MAX_PORT_NAME;
|
||||
const int MAX_OBJECT_NAME = MPI_MAX_OBJECT_NAME;
|
||||
|
||||
// elementary datatypes
|
||||
const Datatype CHAR(MPI_CHAR);
|
||||
const Datatype SHORT(MPI_SHORT);
|
||||
const Datatype INT(MPI_INT);
|
||||
const Datatype LONG(MPI_LONG);
|
||||
const Datatype UNSIGNED_CHAR(MPI_UNSIGNED_CHAR);
|
||||
const Datatype UNSIGNED_SHORT(MPI_UNSIGNED_SHORT);
|
||||
const Datatype UNSIGNED(MPI_UNSIGNED);
|
||||
const Datatype UNSIGNED_LONG(MPI_UNSIGNED_LONG);
|
||||
const Datatype FLOAT(MPI_FLOAT);
|
||||
const Datatype DOUBLE(MPI_DOUBLE);
|
||||
const Datatype LONG_DOUBLE(MPI_LONG_DOUBLE);
|
||||
const Datatype BYTE(MPI_BYTE);
|
||||
const Datatype PACKED(MPI_PACKED);
|
||||
const Datatype WCHAR(MPI_WCHAR);
|
||||
|
||||
// datatypes for reductions functions (C / C++)
|
||||
const Datatype FLOAT_INT(MPI_FLOAT_INT);
|
||||
const Datatype DOUBLE_INT(MPI_DOUBLE_INT);
|
||||
const Datatype LONG_INT(MPI_LONG_INT);
|
||||
const Datatype TWOINT(MPI_2INT);
|
||||
const Datatype SHORT_INT(MPI_SHORT_INT);
|
||||
const Datatype LONG_DOUBLE_INT(MPI_LONG_DOUBLE);
|
||||
|
||||
#if OMPI_WANT_F77_BINDINGS
|
||||
// elementary datatype (Fortran)
|
||||
const Datatype INTEGER(ompi_mpi_integer);
|
||||
const Datatype REAL(ompi_mpi_real);
|
||||
const Datatype DOUBLE_PRECISION(ompi_mpi_dblprec);
|
||||
const Datatype F_COMPLEX(ompi_mpi_cplex);
|
||||
const Datatype LOGICAL(ompi_mpi_logic);
|
||||
const Datatype CHARACTER(ompi_mpi_character);
|
||||
|
||||
// datatype for reduction functions (Fortran)
|
||||
const Datatype TWOREAL(ompi_mpi_2real);
|
||||
const Datatype TWODOUBLE_PRECISION(ompi_mpi_2dblprec);
|
||||
const Datatype TWOINTEGER(ompi_mpi_2integer);
|
||||
|
||||
// optional datatypes (Fortran)
|
||||
const Datatype INTEGER2(ompi_mpi_integer);
|
||||
const Datatype REAL2(ompi_mpi_real);
|
||||
const Datatype INTEGER1(ompi_mpi_char);
|
||||
const Datatype INTEGER4(ompi_mpi_short);
|
||||
const Datatype REAL4(ompi_mpi_real);
|
||||
const Datatype REAL8(ompi_mpi_double);
|
||||
|
||||
#endif // OMPI_WANT_f77_BINDINGS
|
||||
|
||||
// optional datatype (C / C++)
|
||||
const Datatype UNSIGNED_LONG_LONG(MPI_UNSIGNED_LONG_LONG);
|
||||
const Datatype LONG_LONG(MPI_LONG_LONG);
|
||||
|
||||
// c++ types
|
||||
const Datatype BOOL(ompi_mpi_cxx_bool);
|
||||
const Datatype COMPLEX(ompi_mpi_cxx_cplex);
|
||||
const Datatype DOUBLE_COMPLEX(ompi_mpi_cxx_dblcplex);
|
||||
const Datatype LONG_DOUBLE_COMPLEX(ompi_mpi_cxx_ldblcplex);
|
||||
|
||||
// datatype decoding constants
|
||||
const int COMBINER_NAMED = MPI_COMBINER_NAMED;
|
||||
const int COMBINER_DUP = MPI_COMBINER_DUP;
|
||||
const int COMBINER_CONTIGUOUS = MPI_COMBINER_CONTIGUOUS;
|
||||
const int COMBINER_VECTOR = MPI_COMBINER_VECTOR;
|
||||
const int COMBINER_HVECTOR_INTEGER = MPI_COMBINER_HVECTOR_INTEGER;
|
||||
const int COMBINER_HVECTOR = MPI_COMBINER_HVECTOR;
|
||||
const int COMBINER_INDEXED = MPI_COMBINER_INDEXED;
|
||||
const int COMBINER_HINDEXED_INTEGER = MPI_COMBINER_HINDEXED_INTEGER;
|
||||
const int COMBINER_HINDEXED = MPI_COMBINER_HINDEXED;
|
||||
const int COMBINER_INDEXED_BLOCK = MPI_COMBINER_INDEXED_BLOCK;
|
||||
const int COMBINER_STRUCT_INTEGER = MPI_COMBINER_STRUCT_INTEGER;
|
||||
const int COMBINER_STRUCT = MPI_COMBINER_STRUCT;
|
||||
const int COMBINER_SUBARRAY = MPI_COMBINER_SUBARRAY;
|
||||
const int COMBINER_DARRAY = MPI_COMBINER_DARRAY;
|
||||
const int COMBINER_F90_REAL = MPI_COMBINER_F90_REAL;
|
||||
const int COMBINER_F90_COMPLEX = MPI_COMBINER_F90_COMPLEX;
|
||||
const int COMBINER_F90_INTEGER = MPI_COMBINER_F90_INTEGER;
|
||||
const int COMBINER_RESIZED = MPI_COMBINER_RESIZED;
|
||||
|
||||
// thread constants
|
||||
const int THREAD_SINGLE = MPI_THREAD_SINGLE;
|
||||
const int THREAD_FUNNELED = MPI_THREAD_FUNNELED;
|
||||
const int THREAD_SERIALIZED = MPI_THREAD_SERIALIZED;
|
||||
const int THREAD_MULTIPLE = MPI_THREAD_MULTIPLE;
|
||||
|
||||
// reserved communicators
|
||||
Intracomm COMM_WORLD(MPI_COMM_WORLD);
|
||||
Intracomm COMM_SELF(MPI_COMM_SELF);
|
||||
|
||||
// results of communicator and group comparisons
|
||||
const int IDENT = MPI_IDENT;
|
||||
const int CONGRUENT = MPI_CONGRUENT;
|
||||
const int SIMILAR = MPI_SIMILAR;
|
||||
const int UNEQUAL = MPI_UNEQUAL;
|
||||
|
||||
// environmental inquiry keys
|
||||
const int TAG_UB = MPI_TAG_UB;
|
||||
const int IO = MPI_IO;
|
||||
const int HOST = MPI_HOST;
|
||||
const int WTIME_IS_GLOBAL = MPI_WTIME_IS_GLOBAL;
|
||||
const int UNIVERSE_SIZE = MPI_UNIVERSE_SIZE;
|
||||
const int APPNUM = MPI_APPNUM;
|
||||
const int WIN_BASE = MPI_WIN_BASE;
|
||||
const int WIN_SIZE = MPI_WIN_SIZE;
|
||||
const int WIN_DISP_UNIT = MPI_WIN_DISP_UNIT;
|
||||
|
||||
// collective operations
|
||||
const Op MAX(MPI_MAX);
|
||||
const Op MIN(MPI_MIN);
|
||||
const Op SUM(MPI_SUM);
|
||||
const Op PROD(MPI_PROD);
|
||||
const Op MAXLOC(MPI_MAXLOC);
|
||||
const Op MINLOC(MPI_MINLOC);
|
||||
const Op BAND(MPI_BAND);
|
||||
const Op BOR(MPI_BOR);
|
||||
const Op BXOR(MPI_BXOR);
|
||||
const Op LAND(MPI_LAND);
|
||||
const Op LOR(MPI_LOR);
|
||||
const Op LXOR(MPI_LXOR);
|
||||
const Op REPLACE(MPI_REPLACE);
|
||||
|
||||
// null handles
|
||||
const Group GROUP_NULL = MPI_GROUP_NULL;
|
||||
const Win WIN_NULL = MPI_WIN_NULL;
|
||||
const Info INFO_NULL = MPI_INFO_NULL;
|
||||
//const Comm COMM_NULL = MPI_COMM_NULL;
|
||||
//const MPI_Comm COMM_NULL = MPI_COMM_NULL;
|
||||
Comm_Null COMM_NULL;
|
||||
const Datatype DATATYPE_NULL = MPI_DATATYPE_NULL;
|
||||
Request REQUEST_NULL = MPI_REQUEST_NULL;
|
||||
const Op OP_NULL = MPI_OP_NULL;
|
||||
const Errhandler ERRHANDLER_NULL;
|
||||
|
||||
// constants specifying empty or ignored input
|
||||
const char** ARGV_NULL = (const char**) MPI_ARGV_NULL;
|
||||
const char*** ARGVS_NULL = (const char***) MPI_ARGVS_NULL;
|
||||
|
||||
// empty group
|
||||
const Group GROUP_EMPTY(MPI_GROUP_EMPTY);
|
||||
|
||||
// topologies
|
||||
const int GRAPH = MPI_GRAPH;
|
||||
const int CART = MPI_CART;
|
||||
|
||||
// special datatypes for contstruction of derived datatypes
|
||||
const Datatype UB(MPI_UB);
|
||||
const Datatype LB(MPI_LB);
|
||||
|
||||
}; /* namespace MPI */
|
138
src/mpi/cxx/mpicxx.h
Обычный файл
138
src/mpi/cxx/mpicxx.h
Обычный файл
@ -0,0 +1,138 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
#ifndef MPIPP_H
|
||||
#define MPIPP_H
|
||||
|
||||
//
|
||||
// Let's ensure that we're really in C++, and some errant programmer
|
||||
// hasn't included <mpicxx.h> just "for completeness"
|
||||
//
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
|
||||
#include "ompi_config.h"
|
||||
#include <mpi.h>
|
||||
|
||||
// we include all this here so that we escape the silly namespacing issues
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
// forward declare so that we can still do inlining
|
||||
struct ompi_mutex_t;
|
||||
|
||||
//JGS: this is used for implementing user functions for MPI::Op
|
||||
extern "C" void
|
||||
op_intercept(void *invec, void *outvec, int *len, MPI_Datatype *datatype);
|
||||
|
||||
//JGS: this is used as the MPI_Handler_function for
|
||||
// the mpi_errhandler in ERRORS_THROW_EXCEPTIONS
|
||||
extern "C" void
|
||||
throw_excptn_fctn(MPI_Comm* comm, int* errcode, ...);
|
||||
|
||||
extern "C" void
|
||||
errhandler_intercept(MPI_Comm * mpi_comm, int * err, ...);
|
||||
|
||||
|
||||
//used for attr intercept functions
|
||||
enum CommType { eIntracomm, eIntercomm, eCartcomm, eGraphcomm};
|
||||
|
||||
extern "C" int
|
||||
copy_attr_intercept(MPI_Comm oldcomm, int keyval,
|
||||
void *extra_state, void *attribute_val_in,
|
||||
void *attribute_val_out, int *flag);
|
||||
|
||||
extern "C" int
|
||||
delete_attr_intercept(MPI_Comm comm, int keyval,
|
||||
void *attribute_val, void *extra_state);
|
||||
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
#include "mpi/cxx/pmpicxx.h"
|
||||
#endif
|
||||
|
||||
namespace MPI {
|
||||
|
||||
#if ! OMPI_HAVE_CXX_EXCEPTION_SUPPORT
|
||||
extern int mpi_errno;
|
||||
#endif
|
||||
|
||||
class Comm_Null;
|
||||
class Comm;
|
||||
class Intracomm;
|
||||
class Intercomm;
|
||||
class Graphcomm;
|
||||
class Cartcomm;
|
||||
class Datatype;
|
||||
class Errhandler;
|
||||
class Group;
|
||||
class Op;
|
||||
class Request;
|
||||
class Status;
|
||||
class Info;
|
||||
class Win;
|
||||
class File;
|
||||
|
||||
typedef MPI_Aint Aint;
|
||||
typedef MPI_Offset Offset;
|
||||
|
||||
#include "mpi/cxx/constants.h"
|
||||
#include "mpi/cxx/functions.h"
|
||||
#include "mpi/cxx/datatype.h"
|
||||
|
||||
typedef void User_function(const void* invec, void* inoutvec, int len,
|
||||
const Datatype& datatype);
|
||||
|
||||
#include "mpi/cxx/exception.h"
|
||||
#include "mpi/cxx/op.h"
|
||||
#include "mpi/cxx/status.h"
|
||||
#include "mpi/cxx/request.h" //includes class Prequest
|
||||
#include "mpi/cxx/group.h"
|
||||
#include "mpi/cxx/comm.h"
|
||||
#include "mpi/cxx/errhandler.h"
|
||||
#include "mpi/cxx/intracomm.h"
|
||||
#include "mpi/cxx/topology.h" //includes Cartcomm and Graphcomm
|
||||
#include "mpi/cxx/intercomm.h"
|
||||
#include "mpi/cxx/info.h"
|
||||
#include "mpi/cxx/win.h"
|
||||
#include "mpi/cxx/file.h"
|
||||
|
||||
}
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
#include "mpi/cxx/pop_inln.h"
|
||||
#include "mpi/cxx/pgroup_inln.h"
|
||||
#include "mpi/cxx/pstatus_inln.h"
|
||||
#include "mpi/cxx/prequest_inln.h"
|
||||
#endif
|
||||
|
||||
//
|
||||
// These are the "real" functions, whether prototyping is enabled
|
||||
// or not. These functions are assigned to either the MPI::XXX class
|
||||
// or the PMPI::XXX class based on the value of the macro MPI
|
||||
// which is set in mpi2cxx_config.h.
|
||||
// If prototyping is enabled, there is a top layer that calls these
|
||||
// PMPI functions, and this top layer is in the XXX.cc files.
|
||||
//
|
||||
|
||||
#include "mpi/cxx/datatype_inln.h"
|
||||
#include "mpi/cxx/functions_inln.h"
|
||||
#include "mpi/cxx/request_inln.h"
|
||||
#include "mpi/cxx/comm_inln.h"
|
||||
#include "mpi/cxx/intracomm_inln.h"
|
||||
#include "mpi/cxx/topology_inln.h"
|
||||
#include "mpi/cxx/intercomm_inln.h"
|
||||
#include "mpi/cxx/group_inln.h"
|
||||
#include "mpi/cxx/op_inln.h"
|
||||
#include "mpi/cxx/errhandler_inln.h"
|
||||
#include "mpi/cxx/status_inln.h"
|
||||
#include "mpi/cxx/info_inln.h"
|
||||
#include "mpi/cxx/win_inln.h"
|
||||
#include "mpi/cxx/file_inln.h"
|
||||
|
||||
#endif // #if defined(__cplusplus) || defined(c_plusplus)
|
||||
#endif // #ifndef MPIPP_H_
|
47
src/mpi/cxx/op.h
Обычный файл
47
src/mpi/cxx/op.h
Обычный файл
@ -0,0 +1,47 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
class Op {
|
||||
public:
|
||||
|
||||
// construction
|
||||
Op();
|
||||
Op(const MPI_Op &i);
|
||||
Op(const Op& op);
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
Op(const PMPI::Op& op) : pmpi_op(op) { }
|
||||
#endif
|
||||
// destruction
|
||||
virtual ~Op();
|
||||
// assignment
|
||||
Op& operator=(const Op& op);
|
||||
Op& operator= (const MPI_Op &i);
|
||||
// comparison
|
||||
inline bool operator== (const Op &a);
|
||||
inline bool operator!= (const Op &a);
|
||||
// conversion functions for inter-language operability
|
||||
inline operator MPI_Op () const;
|
||||
// inline operator MPI_Op* (); //JGS const
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
inline operator const PMPI::Op&() const { return pmpi_op; }
|
||||
#endif
|
||||
// Collective Communication
|
||||
//JGS took const out
|
||||
virtual void Init(User_function *func, bool commute);
|
||||
virtual void Free();
|
||||
|
||||
#if ! 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
User_function *op_user_function; //JGS move to private
|
||||
protected:
|
||||
MPI_Op mpi_op;
|
||||
#endif
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
private:
|
||||
PMPI::Op pmpi_op;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
107
src/mpi/cxx/op_inln.h
Обычный файл
107
src/mpi/cxx/op_inln.h
Обычный файл
@ -0,0 +1,107 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
inline
|
||||
MPI::Op::Op() { }
|
||||
|
||||
inline
|
||||
MPI::Op::Op(const MPI::Op& o) : pmpi_op(o.pmpi_op) { }
|
||||
|
||||
inline
|
||||
MPI::Op::Op(const MPI_Op& o) : pmpi_op(o) { }
|
||||
|
||||
inline
|
||||
MPI::Op::~Op() { }
|
||||
|
||||
inline
|
||||
MPI::Op& MPI::Op::operator=(const MPI::Op& op) {
|
||||
pmpi_op = op.pmpi_op; return *this;
|
||||
}
|
||||
|
||||
// comparison
|
||||
inline bool
|
||||
MPI::Op::operator== (const MPI::Op &a) {
|
||||
return (bool)(pmpi_op == a.pmpi_op);
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Op::operator!= (const MPI::Op &a) {
|
||||
return (bool)!(*this == a);
|
||||
}
|
||||
|
||||
// inter-language operability
|
||||
inline MPI::Op&
|
||||
MPI::Op::operator= (const MPI_Op &i) { pmpi_op = i; return *this; }
|
||||
|
||||
inline
|
||||
MPI::Op::operator MPI_Op () const { return pmpi_op; }
|
||||
|
||||
//inline
|
||||
//MPI::Op::operator MPI_Op* () { return pmpi_op; }
|
||||
|
||||
|
||||
#else // ============= NO PROFILING ===================================
|
||||
|
||||
// construction
|
||||
inline
|
||||
MPI::Op::Op() : mpi_op(MPI_OP_NULL) { }
|
||||
|
||||
inline
|
||||
MPI::Op::Op(const MPI_Op &i) : mpi_op(i) { }
|
||||
|
||||
inline
|
||||
MPI::Op::Op(const MPI::Op& op)
|
||||
: op_user_function(op.op_user_function), mpi_op(op.mpi_op) { }
|
||||
|
||||
inline
|
||||
MPI::Op::~Op()
|
||||
{
|
||||
#if 0
|
||||
mpi_op = MPI_OP_NULL;
|
||||
op_user_function = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline MPI::Op&
|
||||
MPI::Op::operator=(const MPI::Op& op) {
|
||||
mpi_op = op.mpi_op;
|
||||
op_user_function = op.op_user_function;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// comparison
|
||||
inline bool
|
||||
MPI::Op::operator== (const MPI::Op &a) { return (bool)(mpi_op == a.mpi_op); }
|
||||
|
||||
inline bool
|
||||
MPI::Op::operator!= (const MPI::Op &a) { return (bool)!(*this == a); }
|
||||
|
||||
// inter-language operability
|
||||
inline MPI::Op&
|
||||
MPI::Op::operator= (const MPI_Op &i) { mpi_op = i; return *this; }
|
||||
|
||||
inline
|
||||
MPI::Op::operator MPI_Op () const { return mpi_op; }
|
||||
|
||||
//inline
|
||||
//MPI::Op::operator MPI_Op* () { return &mpi_op; }
|
||||
|
||||
#endif
|
||||
|
||||
inline void
|
||||
MPI::Op::Init(MPI::User_function *func, bool commute)
|
||||
{
|
||||
(void)MPI_Op_create(op_intercept , (int) commute, &mpi_op);
|
||||
op_user_function = (User_function*)func;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Op::Free()
|
||||
{
|
||||
(void)MPI_Op_free(&mpi_op);
|
||||
}
|
176
src/mpi/cxx/request.h
Обычный файл
176
src/mpi/cxx/request.h
Обычный файл
@ -0,0 +1,176 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
class Request {
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// friend class PMPI::Request;
|
||||
#endif
|
||||
public:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
// construction
|
||||
Request() { }
|
||||
Request(const MPI_Request &i) : pmpi_request(i) { }
|
||||
|
||||
// copy / assignment
|
||||
Request(const Request& r) : pmpi_request(r.pmpi_request) { }
|
||||
|
||||
Request(const PMPI::Request& r) : pmpi_request(r) { }
|
||||
|
||||
virtual ~Request() {}
|
||||
|
||||
Request& operator=(const Request& r) {
|
||||
pmpi_request = r.pmpi_request; return *this; }
|
||||
|
||||
// comparison
|
||||
bool operator== (const Request &a)
|
||||
{ return (bool)(pmpi_request == a.pmpi_request); }
|
||||
bool operator!= (const Request &a)
|
||||
{ return (bool)!(*this == a); }
|
||||
|
||||
// inter-language operability
|
||||
Request& operator= (const MPI_Request &i) {
|
||||
pmpi_request = i; return *this; }
|
||||
|
||||
operator MPI_Request () const { return pmpi_request; }
|
||||
// operator MPI_Request* () const { return pmpi_request; }
|
||||
operator const PMPI::Request&() const { return pmpi_request; }
|
||||
|
||||
#else
|
||||
|
||||
// construction / destruction
|
||||
Request() { mpi_request = MPI_REQUEST_NULL; }
|
||||
virtual ~Request() {}
|
||||
Request(const MPI_Request &i) : mpi_request(i) { }
|
||||
|
||||
// copy / assignment
|
||||
Request(const Request& r) : mpi_request(r.mpi_request) { }
|
||||
|
||||
Request& operator=(const Request& r) {
|
||||
mpi_request = r.mpi_request; return *this; }
|
||||
|
||||
// comparison
|
||||
bool operator== (const Request &a)
|
||||
{ return (bool)(mpi_request == a.mpi_request); }
|
||||
bool operator!= (const Request &a)
|
||||
{ return (bool)!(*this == a); }
|
||||
|
||||
// inter-language operability
|
||||
Request& operator= (const MPI_Request &i) {
|
||||
mpi_request = i; return *this; }
|
||||
operator MPI_Request () const { return mpi_request; }
|
||||
// operator MPI_Request* () const { return (MPI_Request*)&mpi_request; }
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Point-to-Point Communication
|
||||
//
|
||||
|
||||
virtual void Wait(Status &status);
|
||||
|
||||
virtual void Wait();
|
||||
|
||||
virtual bool Test(Status &status);
|
||||
|
||||
virtual bool Test();
|
||||
|
||||
virtual void Free(void);
|
||||
|
||||
static int Waitany(int count, Request array[], Status& status);
|
||||
|
||||
static int Waitany(int count, Request array[]);
|
||||
|
||||
static bool Testany(int count, Request array[], int& index, Status& status);
|
||||
|
||||
static bool Testany(int count, Request array[], int& index);
|
||||
|
||||
static void Waitall(int count, Request req_array[], Status stat_array[]);
|
||||
|
||||
static void Waitall(int count, Request req_array[]);
|
||||
|
||||
static bool Testall(int count, Request req_array[], Status stat_array[]);
|
||||
|
||||
static bool Testall(int count, Request req_array[]);
|
||||
|
||||
static int Waitsome(int incount, Request req_array[],
|
||||
int array_of_indices[], Status stat_array[]) ;
|
||||
|
||||
static int Waitsome(int incount, Request req_array[],
|
||||
int array_of_indices[]);
|
||||
|
||||
static int Testsome(int incount, Request req_array[],
|
||||
int array_of_indices[], Status stat_array[]);
|
||||
|
||||
static int Testsome(int incount, Request req_array[],
|
||||
int array_of_indices[]);
|
||||
|
||||
virtual void Cancel(void) const;
|
||||
|
||||
|
||||
protected:
|
||||
#if ! 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
MPI_Request mpi_request;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
PMPI::Request pmpi_request;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
class Prequest : public Request {
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// friend class PMPI::Prequest;
|
||||
#endif
|
||||
public:
|
||||
|
||||
Prequest() { }
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
Prequest(const Request& p) : Request(p), pmpi_request(p) { }
|
||||
|
||||
Prequest(const PMPI::Prequest& r) :
|
||||
Request((const PMPI::Request&)r),
|
||||
pmpi_request(r) { }
|
||||
|
||||
Prequest(const MPI_Request &i) : Request(i), pmpi_request(i) { }
|
||||
|
||||
virtual ~Prequest() { }
|
||||
|
||||
Prequest& operator=(const Request& r) {
|
||||
Request::operator=(r);
|
||||
pmpi_request = (PMPI::Prequest)r; return *this; }
|
||||
|
||||
Prequest& operator=(const Prequest& r) {
|
||||
Request::operator=(r);
|
||||
pmpi_request = r.pmpi_request; return *this; }
|
||||
#else
|
||||
Prequest(const Request& p) : Request(p) { }
|
||||
|
||||
Prequest(const MPI_Request &i) : Request(i) { }
|
||||
|
||||
virtual ~Prequest() { }
|
||||
|
||||
Prequest& operator=(const Request& r) {
|
||||
mpi_request = r; return *this; }
|
||||
|
||||
Prequest& operator=(const Prequest& r) {
|
||||
mpi_request = r.mpi_request; return *this; }
|
||||
#endif
|
||||
|
||||
virtual void Start();
|
||||
|
||||
static void Startall(int count, Prequest array_of_requests[]);
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
private:
|
||||
PMPI::Prequest pmpi_request;
|
||||
#endif
|
||||
};
|
277
src/mpi/cxx/request_inln.h
Обычный файл
277
src/mpi/cxx/request_inln.h
Обычный файл
@ -0,0 +1,277 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
//
|
||||
// Point-to-Point Communication
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Request::Wait(MPI::Status &status)
|
||||
{
|
||||
(void)MPI_Wait(&mpi_request, &status.mpi_status);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Request::Wait()
|
||||
{
|
||||
(void)MPI_Wait(&mpi_request, MPI_STATUS_IGNORE);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Request::Free()
|
||||
{
|
||||
(void)MPI_Request_free(&mpi_request);
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Request::Test(MPI::Status &status)
|
||||
{
|
||||
int t;
|
||||
(void)MPI_Test(&mpi_request, &t, &status.mpi_status);
|
||||
return (bool) t;
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Request::Test()
|
||||
{
|
||||
int t;
|
||||
(void)MPI_Test(&mpi_request, &t, MPI_STATUS_IGNORE);
|
||||
return (bool) t;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Request::Waitany(int count, MPI::Request array[],
|
||||
MPI::Status& status)
|
||||
{
|
||||
int index, i;
|
||||
MPI_Request* array_of_requests = new MPI_Request[count];
|
||||
for (i=0; i < count; i++)
|
||||
array_of_requests[i] = array[i];
|
||||
(void)MPI_Waitany(count, array_of_requests, &index, &status.mpi_status);
|
||||
for (i=0; i < count; i++)
|
||||
array[i] = array_of_requests[i];
|
||||
delete [] array_of_requests;
|
||||
return index;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Request::Waitany(int count, MPI::Request array[])
|
||||
{
|
||||
int index, i;
|
||||
MPI_Request* array_of_requests = new MPI_Request[count];
|
||||
for (i=0; i < count; i++)
|
||||
array_of_requests[i] = array[i];
|
||||
(void)MPI_Waitany(count, array_of_requests, &index, MPI_STATUS_IGNORE);
|
||||
for (i=0; i < count; i++)
|
||||
array[i] = array_of_requests[i];
|
||||
delete [] array_of_requests;
|
||||
return index; //JGS, Waitany return value
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Request::Testany(int count, MPI::Request array[],
|
||||
int& index, MPI::Status& status)
|
||||
{
|
||||
int i, flag;
|
||||
MPI_Request* array_of_requests = new MPI_Request[count];
|
||||
for (i=0; i < count; i++)
|
||||
array_of_requests[i] = array[i];
|
||||
(void)MPI_Testany(count, array_of_requests, &index, &flag, &status.mpi_status);
|
||||
for (i=0; i < count; i++)
|
||||
array[i] = array_of_requests[i];
|
||||
delete [] array_of_requests;
|
||||
return (bool)flag;
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Request::Testany(int count, MPI::Request array[], int& index)
|
||||
{
|
||||
int i, flag;
|
||||
MPI_Request* array_of_requests = new MPI_Request[count];
|
||||
for (i=0; i < count; i++)
|
||||
array_of_requests[i] = array[i];
|
||||
(void)MPI_Testany(count, array_of_requests, &index, &flag,
|
||||
MPI_STATUS_IGNORE);
|
||||
for (i=0; i < count; i++)
|
||||
array[i] = array_of_requests[i];
|
||||
delete [] array_of_requests;
|
||||
return (bool)flag;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Request::Waitall(int count, MPI::Request req_array[],
|
||||
MPI::Status stat_array[])
|
||||
{
|
||||
int i;
|
||||
MPI_Request* array_of_requests = new MPI_Request[count];
|
||||
MPI_Status* array_of_statuses = new MPI_Status[count];
|
||||
for (i=0; i < count; i++)
|
||||
array_of_requests[i] = req_array[i];
|
||||
(void)MPI_Waitall(count, array_of_requests, array_of_statuses);
|
||||
for (i=0; i < count; i++)
|
||||
req_array[i] = array_of_requests[i];
|
||||
for (i=0; i < count; i++)
|
||||
stat_array[i] = array_of_statuses[i];
|
||||
delete [] array_of_requests;
|
||||
delete [] array_of_statuses;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Request::Waitall(int count, MPI::Request req_array[])
|
||||
{
|
||||
int i;
|
||||
MPI_Request* array_of_requests = new MPI_Request[count];
|
||||
|
||||
for (i=0; i < count; i++)
|
||||
array_of_requests[i] = req_array[i];
|
||||
(void)MPI_Waitall(count, array_of_requests, MPI_STATUSES_IGNORE);
|
||||
|
||||
for (i=0; i < count; i++)
|
||||
req_array[i] = array_of_requests[i];
|
||||
|
||||
delete [] array_of_requests;
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Request::Testall(int count, MPI::Request req_array[],
|
||||
MPI::Status stat_array[])
|
||||
{
|
||||
int i, flag;
|
||||
MPI_Request* array_of_requests = new MPI_Request[count];
|
||||
MPI_Status* array_of_statuses = new MPI_Status[count];
|
||||
for (i=0; i < count; i++)
|
||||
array_of_requests[i] = req_array[i];
|
||||
(void)MPI_Testall(count, array_of_requests, &flag, array_of_statuses);
|
||||
for (i=0; i < count; i++)
|
||||
req_array[i] = array_of_requests[i];
|
||||
for (i=0; i < count; i++)
|
||||
stat_array[i] = array_of_statuses[i];
|
||||
delete [] array_of_requests;
|
||||
delete [] array_of_statuses;
|
||||
return (bool) flag;
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Request::Testall(int count, MPI::Request req_array[])
|
||||
{
|
||||
int i, flag;
|
||||
MPI_Request* array_of_requests = new MPI_Request[count];
|
||||
|
||||
for (i=0; i < count; i++)
|
||||
array_of_requests[i] = req_array[i];
|
||||
(void)MPI_Testall(count, array_of_requests, &flag, MPI_STATUSES_IGNORE);
|
||||
|
||||
for (i=0; i < count; i++)
|
||||
req_array[i] = array_of_requests[i];
|
||||
delete [] array_of_requests;
|
||||
|
||||
return (bool) flag;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Request::Waitsome(int incount, MPI::Request req_array[],
|
||||
int array_of_indices[], MPI::Status stat_array[])
|
||||
{
|
||||
int i, outcount;
|
||||
MPI_Request* array_of_requests = new MPI_Request[incount];
|
||||
MPI_Status* array_of_statuses = new MPI_Status[incount];
|
||||
for (i=0; i < incount; i++)
|
||||
array_of_requests[i] = req_array[i];
|
||||
(void)MPI_Waitsome(incount, array_of_requests, &outcount,
|
||||
array_of_indices, array_of_statuses);
|
||||
for (i=0; i < incount; i++)
|
||||
req_array[i] = array_of_requests[i];
|
||||
for (i=0; i < incount; i++)
|
||||
stat_array[i] = array_of_statuses[i];
|
||||
delete [] array_of_requests;
|
||||
delete [] array_of_statuses;
|
||||
return outcount;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Request::Waitsome(int incount, MPI::Request req_array[],
|
||||
int array_of_indices[])
|
||||
{
|
||||
int i, outcount;
|
||||
MPI_Request* array_of_requests = new MPI_Request[incount];
|
||||
|
||||
for (i=0; i < incount; i++)
|
||||
array_of_requests[i] = req_array[i];
|
||||
(void)MPI_Waitsome(incount, array_of_requests, &outcount,
|
||||
array_of_indices, MPI_STATUSES_IGNORE);
|
||||
|
||||
for (i=0; i < incount; i++)
|
||||
req_array[i] = array_of_requests[i];
|
||||
delete [] array_of_requests;
|
||||
|
||||
return outcount;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Request::Testsome(int incount, MPI::Request req_array[],
|
||||
int array_of_indices[], MPI::Status stat_array[])
|
||||
{
|
||||
int i, outcount;
|
||||
MPI_Request* array_of_requests = new MPI_Request[incount];
|
||||
MPI_Status* array_of_statuses = new MPI_Status[incount];
|
||||
for (i=0; i < incount; i++)
|
||||
array_of_requests[i] = req_array[i];
|
||||
(void)MPI_Testsome(incount, array_of_requests, &outcount,
|
||||
array_of_indices, array_of_statuses);
|
||||
for (i=0; i < incount; i++)
|
||||
req_array[i] = array_of_requests[i];
|
||||
for (i=0; i < incount; i++)
|
||||
stat_array[i] = array_of_statuses[i];
|
||||
delete [] array_of_requests;
|
||||
delete [] array_of_statuses;
|
||||
return outcount;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Request::Testsome(int incount, MPI::Request req_array[],
|
||||
int array_of_indices[])
|
||||
{
|
||||
int i, outcount;
|
||||
MPI_Request* array_of_requests = new MPI_Request[incount];
|
||||
|
||||
for (i=0; i < incount; i++)
|
||||
array_of_requests[i] = req_array[i];
|
||||
(void)MPI_Testsome(incount, array_of_requests, &outcount,
|
||||
array_of_indices, MPI_STATUSES_IGNORE);
|
||||
|
||||
for (i=0; i < incount; i++)
|
||||
req_array[i] = array_of_requests[i];
|
||||
delete [] array_of_requests;
|
||||
|
||||
return outcount;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Request::Cancel(void) const
|
||||
{
|
||||
(void)MPI_Cancel((MPI_Request*)&mpi_request);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Prequest::Start()
|
||||
{
|
||||
(void)MPI_Start(&mpi_request);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Prequest::Startall(int count, MPI:: Prequest array_of_requests[])
|
||||
{
|
||||
//convert the array of Prequests to an array of MPI_requests
|
||||
MPI_Request* mpi_requests = new MPI_Request[count];
|
||||
int i;
|
||||
for (i=0; i < count; i++) {
|
||||
mpi_requests[i] = array_of_requests[i];
|
||||
}
|
||||
(void)MPI_Startall(count, mpi_requests);
|
||||
for (i=0; i < count; i++)
|
||||
array_of_requests[i].mpi_request = mpi_requests[i] ;
|
||||
delete [] mpi_requests;
|
||||
}
|
||||
|
94
src/mpi/cxx/status.h
Обычный файл
94
src/mpi/cxx/status.h
Обычный файл
@ -0,0 +1,94 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
class Status {
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// friend class PMPI::Status;
|
||||
#endif
|
||||
friend class MPI::Comm; //so I can access pmpi_status data member in comm.cc
|
||||
friend class MPI::Request; //and also from request.cc
|
||||
friend class MPI::File;
|
||||
|
||||
public:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
// construction / destruction
|
||||
Status() { }
|
||||
virtual ~Status() {}
|
||||
|
||||
// copy / assignment
|
||||
Status(const Status& data) : pmpi_status(data.pmpi_status) { }
|
||||
|
||||
Status(const MPI_Status &i) : pmpi_status(i) { }
|
||||
|
||||
Status& operator=(const Status& data) {
|
||||
pmpi_status = data.pmpi_status; return *this; }
|
||||
|
||||
// comparison, don't need for status
|
||||
|
||||
// inter-language operability
|
||||
Status& operator= (const MPI_Status &i) {
|
||||
pmpi_status = i; return *this; }
|
||||
operator MPI_Status () const { return pmpi_status; }
|
||||
// operator MPI_Status* () const { return pmpi_status; }
|
||||
operator const PMPI::Status&() const { return pmpi_status; }
|
||||
|
||||
#else
|
||||
|
||||
Status() { }
|
||||
// copy
|
||||
Status(const Status& data) : mpi_status(data.mpi_status) { }
|
||||
|
||||
Status(const MPI_Status &i) : mpi_status(i) { }
|
||||
|
||||
virtual ~Status() {}
|
||||
|
||||
Status& operator=(const Status& data) {
|
||||
mpi_status = data.mpi_status; return *this; }
|
||||
|
||||
// comparison, don't need for status
|
||||
|
||||
// inter-language operability
|
||||
Status& operator= (const MPI_Status &i) {
|
||||
mpi_status = i; return *this; }
|
||||
operator MPI_Status () const { return mpi_status; }
|
||||
// operator MPI_Status* () const { return (MPI_Status*)&mpi_status; }
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Point-to-Point Communication
|
||||
//
|
||||
|
||||
virtual int Get_count(const Datatype& datatype) const;
|
||||
|
||||
virtual bool Is_cancelled() const;
|
||||
|
||||
virtual int Get_elements(const Datatype& datatype) const;
|
||||
|
||||
//
|
||||
// Status Access
|
||||
//
|
||||
virtual int Get_source() const;
|
||||
|
||||
virtual void Set_source(int source);
|
||||
|
||||
virtual int Get_tag() const;
|
||||
|
||||
virtual void Set_tag(int tag);
|
||||
|
||||
virtual int Get_error() const;
|
||||
|
||||
virtual void Set_error(int error);
|
||||
|
||||
protected:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
PMPI::Status pmpi_status;
|
||||
#else
|
||||
MPI_Status mpi_status;
|
||||
#endif
|
||||
|
||||
};
|
78
src/mpi/cxx/status_inln.h
Обычный файл
78
src/mpi/cxx/status_inln.h
Обычный файл
@ -0,0 +1,78 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
//
|
||||
// Point-to-Point Communication
|
||||
//
|
||||
|
||||
inline int
|
||||
MPI::Status::Get_count(const MPI::Datatype& datatype) const
|
||||
{
|
||||
int count;
|
||||
//(MPI_Status*) is to cast away the const
|
||||
(void)MPI_Get_count((MPI_Status*)&mpi_status, datatype, &count);
|
||||
return count;
|
||||
}
|
||||
|
||||
inline bool
|
||||
MPI::Status::Is_cancelled() const
|
||||
{
|
||||
int t;
|
||||
(void)MPI_Test_cancelled((MPI_Status*)&mpi_status, &t);
|
||||
return (bool) t;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Status::Get_elements(const MPI::Datatype& datatype) const
|
||||
{
|
||||
int count;
|
||||
(void)MPI_Get_elements((MPI_Status*)&mpi_status, datatype, &count);
|
||||
return count;
|
||||
}
|
||||
|
||||
//
|
||||
// Status Access
|
||||
//
|
||||
inline int
|
||||
MPI::Status::Get_source() const
|
||||
{
|
||||
int source;
|
||||
source = mpi_status.MPI_SOURCE;
|
||||
return source;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Status::Set_source(int source)
|
||||
{
|
||||
mpi_status.MPI_SOURCE = source;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Status::Get_tag() const
|
||||
{
|
||||
int tag;
|
||||
tag = mpi_status.MPI_TAG;
|
||||
return tag;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Status::Set_tag(int tag)
|
||||
{
|
||||
mpi_status.MPI_TAG = tag;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Status::Get_error() const
|
||||
{
|
||||
int error;
|
||||
error = mpi_status.MPI_ERROR;
|
||||
return error;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Status::Set_error(int error)
|
||||
{
|
||||
mpi_status.MPI_ERROR = error;
|
||||
}
|
152
src/mpi/cxx/topology.h
Обычный файл
152
src/mpi/cxx/topology.h
Обычный файл
@ -0,0 +1,152 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
class Cartcomm : public Intracomm {
|
||||
public:
|
||||
|
||||
// construction
|
||||
Cartcomm() { }
|
||||
// copy
|
||||
Cartcomm(const Comm_Null& data) : Intracomm(data) { }
|
||||
// inter-language operability
|
||||
inline Cartcomm(const MPI_Comm& data);
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
Cartcomm(const Cartcomm& data) : Intracomm(data), pmpi_comm(data) { }
|
||||
Cartcomm(const PMPI::Cartcomm& d) :
|
||||
Intracomm((const PMPI::Intracomm&)d),
|
||||
pmpi_comm(d) { }
|
||||
|
||||
// assignment
|
||||
Cartcomm& operator=(const Cartcomm& data) {
|
||||
Intracomm::operator=(data);
|
||||
pmpi_comm = data.pmpi_comm; return *this; }
|
||||
Cartcomm& operator=(const Comm_Null& data) {
|
||||
Intracomm::operator=(data);
|
||||
pmpi_comm = (PMPI::Cartcomm)data; return *this; }
|
||||
// inter-language operability
|
||||
Cartcomm& operator=(const MPI_Comm& data) {
|
||||
Intracomm::operator=(data);
|
||||
pmpi_comm = data; return *this; }
|
||||
#else
|
||||
Cartcomm(const Cartcomm& data) : Intracomm(data.mpi_comm) { }
|
||||
// assignment
|
||||
Cartcomm& operator=(const Cartcomm& data) {
|
||||
mpi_comm = data.mpi_comm; return *this; }
|
||||
Cartcomm& operator=(const Comm_Null& data) {
|
||||
mpi_comm = data; return *this; }
|
||||
// inter-language operability
|
||||
Cartcomm& operator=(const MPI_Comm& data) {
|
||||
mpi_comm = data; return *this; }
|
||||
#endif
|
||||
//
|
||||
// Groups, Contexts, and Communicators
|
||||
//
|
||||
|
||||
Cartcomm Dup() const;
|
||||
|
||||
virtual Cartcomm& Clone() const;
|
||||
|
||||
|
||||
//
|
||||
// Groups, Contexts, and Communicators
|
||||
//
|
||||
|
||||
virtual int Get_dim() const;
|
||||
|
||||
virtual void Get_topo(int maxdims, int dims[], bool periods[],
|
||||
int coords[]) const;
|
||||
|
||||
virtual int Get_cart_rank(const int coords[]) const;
|
||||
|
||||
virtual void Get_coords(int rank, int maxdims, int coords[]) const;
|
||||
|
||||
virtual void Shift(int direction, int disp,
|
||||
int &rank_source, int &rank_dest) const;
|
||||
|
||||
virtual Cartcomm Sub(const bool remain_dims[]);
|
||||
|
||||
virtual int Map(int ndims, const int dims[], const bool periods[]) const;
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
private:
|
||||
PMPI::Cartcomm pmpi_comm;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
//===================================================================
|
||||
// Class Graphcomm
|
||||
//===================================================================
|
||||
|
||||
class Graphcomm : public Intracomm {
|
||||
public:
|
||||
|
||||
// construction
|
||||
Graphcomm() { }
|
||||
// copy
|
||||
Graphcomm(const Comm_Null& data) : Intracomm(data) { }
|
||||
// inter-language operability
|
||||
inline Graphcomm(const MPI_Comm& data);
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
Graphcomm(const Graphcomm& data) : Intracomm(data), pmpi_comm(data) { }
|
||||
Graphcomm(const PMPI::Graphcomm& d) :
|
||||
Intracomm((const PMPI::Intracomm&)d), pmpi_comm(d) { }
|
||||
|
||||
// assignment
|
||||
Graphcomm& operator=(const Graphcomm& data) {
|
||||
Intracomm::operator=(data);
|
||||
pmpi_comm = data.pmpi_comm; return *this; }
|
||||
Graphcomm& operator=(const Comm_Null& data) {
|
||||
Intracomm::operator=(data);
|
||||
pmpi_comm = (PMPI::Graphcomm)data; return *this; }
|
||||
// inter-language operability
|
||||
Graphcomm& operator=(const MPI_Comm& data) {
|
||||
Intracomm::operator=(data);
|
||||
pmpi_comm = data; return *this; }
|
||||
|
||||
#else
|
||||
Graphcomm(const Graphcomm& data) : Intracomm(data.mpi_comm) { }
|
||||
// assignment
|
||||
Graphcomm& operator=(const Graphcomm& data) {
|
||||
mpi_comm = data.mpi_comm; return *this; }
|
||||
Graphcomm& operator=(const Comm_Null& data) {
|
||||
mpi_comm = data; return *this; }
|
||||
// inter-language operability
|
||||
Graphcomm& operator=(const MPI_Comm& data) {
|
||||
mpi_comm = data; return *this; }
|
||||
#endif
|
||||
|
||||
//
|
||||
// Groups, Contexts, and Communicators
|
||||
//
|
||||
|
||||
Graphcomm Dup() const;
|
||||
|
||||
virtual Graphcomm& Clone() const;
|
||||
|
||||
//
|
||||
// Process Topologies
|
||||
//
|
||||
|
||||
virtual void Get_dims(int nnodes[], int nedges[]) const;
|
||||
|
||||
virtual void Get_topo(int maxindex, int maxedges, int index[],
|
||||
int edges[]) const;
|
||||
|
||||
virtual int Get_neighbors_count(int rank) const;
|
||||
|
||||
virtual void Get_neighbors(int rank, int maxneighbors,
|
||||
int neighbors[]) const;
|
||||
|
||||
virtual int Map(int nnodes, const int index[],
|
||||
const int edges[]) const;
|
||||
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
private:
|
||||
PMPI::Graphcomm pmpi_comm;
|
||||
#endif
|
||||
};
|
||||
|
203
src/mpi/cxx/topology_inln.h
Обычный файл
203
src/mpi/cxx/topology_inln.h
Обычный файл
@ -0,0 +1,203 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
//
|
||||
// ======== Cartcomm member functions ========
|
||||
//
|
||||
|
||||
inline
|
||||
MPI::Cartcomm::Cartcomm(const MPI_Comm& data) {
|
||||
int status;
|
||||
if (MPI::Is_initialized() && (data != MPI_COMM_NULL)) {
|
||||
(void)MPI_Topo_test(data, &status) ;
|
||||
if (status == MPI_CART)
|
||||
mpi_comm = data;
|
||||
else
|
||||
mpi_comm = MPI_COMM_NULL;
|
||||
}
|
||||
else {
|
||||
mpi_comm = data;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Groups, Contexts, and Communicators
|
||||
//
|
||||
|
||||
inline MPI::Cartcomm
|
||||
MPI::Cartcomm::Dup() const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Comm_dup(mpi_comm, &newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
//
|
||||
// Process Topologies
|
||||
//
|
||||
|
||||
inline int
|
||||
MPI::Cartcomm::Get_dim() const
|
||||
{
|
||||
int ndims;
|
||||
(void)MPI_Cartdim_get(mpi_comm, &ndims);
|
||||
return ndims;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Cartcomm::Get_topo(int maxdims, int dims[], bool periods[],
|
||||
int coords[]) const
|
||||
{
|
||||
int *int_periods = new int [maxdims];
|
||||
int i;
|
||||
for (i=0; i<maxdims; i++) {
|
||||
int_periods[i] = (int)periods[i];
|
||||
}
|
||||
(void)MPI_Cart_get(mpi_comm, maxdims, dims, int_periods, coords);
|
||||
for (i=0; i<maxdims; i++) {
|
||||
periods[i] = (bool)int_periods[i];
|
||||
}
|
||||
delete [] int_periods;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Cartcomm::Get_cart_rank(const int coords[]) const
|
||||
{
|
||||
int rank;
|
||||
(void)MPI_Cart_rank(mpi_comm, (int*)coords, &rank);
|
||||
return rank;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Cartcomm::Get_coords(int rank, int maxdims, int coords[]) const
|
||||
{
|
||||
(void)MPI_Cart_coords(mpi_comm, rank, maxdims, coords);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Cartcomm::Shift(int direction, int disp,
|
||||
int &rank_source, int &rank_dest) const
|
||||
{
|
||||
(void)MPI_Cart_shift(mpi_comm, direction, disp, &rank_source, &rank_dest);
|
||||
}
|
||||
|
||||
inline MPI::Cartcomm
|
||||
MPI::Cartcomm::Sub(const bool remain_dims[])
|
||||
{
|
||||
int ndims;
|
||||
MPI_Cartdim_get(mpi_comm, &ndims);
|
||||
int* int_remain_dims = new int[ndims];
|
||||
for (int i=0; i<ndims; i++) {
|
||||
int_remain_dims[i] = (int)remain_dims[i];
|
||||
}
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Cart_sub(mpi_comm, int_remain_dims, &newcomm);
|
||||
delete [] int_remain_dims;
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Cartcomm::Map(int ndims, const int dims[], const bool periods[]) const
|
||||
{
|
||||
int *int_periods = new int [ndims];
|
||||
for (int i=0; i<ndims; i++) {
|
||||
int_periods[i] = (int) periods[i];
|
||||
}
|
||||
int newrank;
|
||||
(void)MPI_Cart_map(mpi_comm, ndims, (int*)dims, int_periods, &newrank);
|
||||
delete [] int_periods;
|
||||
return newrank;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Cartcomm&
|
||||
MPI::Cartcomm::Clone() const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Comm_dup(mpi_comm, &newcomm);
|
||||
MPI::Cartcomm* dup = new MPI::Cartcomm(newcomm);
|
||||
return *dup;
|
||||
}
|
||||
|
||||
//
|
||||
// ======== Graphcomm member functions ========
|
||||
//
|
||||
|
||||
inline
|
||||
MPI::Graphcomm::Graphcomm(const MPI_Comm& data) {
|
||||
int status;
|
||||
if (MPI::Is_initialized() && (data != MPI_COMM_NULL)) {
|
||||
(void)MPI_Topo_test(data, &status) ;
|
||||
if (status == MPI_GRAPH)
|
||||
mpi_comm = data;
|
||||
else
|
||||
mpi_comm = MPI_COMM_NULL;
|
||||
}
|
||||
else {
|
||||
mpi_comm = data;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Groups, Contexts, and Communicators
|
||||
//
|
||||
|
||||
inline MPI::Graphcomm
|
||||
MPI::Graphcomm::Dup() const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Comm_dup(mpi_comm, &newcomm);
|
||||
return newcomm;
|
||||
}
|
||||
|
||||
//
|
||||
// Process Topologies
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Graphcomm::Get_dims(int nnodes[], int nedges[]) const
|
||||
{
|
||||
(void)MPI_Graphdims_get(mpi_comm, nnodes, nedges);
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Graphcomm::Get_topo(int maxindex, int maxedges, int index[],
|
||||
int edges[]) const
|
||||
{
|
||||
(void)MPI_Graph_get(mpi_comm, maxindex, maxedges, index, edges);
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Graphcomm::Get_neighbors_count(int rank) const
|
||||
{
|
||||
int nneighbors;
|
||||
(void)MPI_Graph_neighbors_count(mpi_comm, rank, &nneighbors);
|
||||
return nneighbors;
|
||||
}
|
||||
|
||||
inline void
|
||||
MPI::Graphcomm::Get_neighbors(int rank, int maxneighbors,
|
||||
int neighbors[]) const
|
||||
{
|
||||
(void)MPI_Graph_neighbors(mpi_comm, rank, maxneighbors, neighbors);
|
||||
}
|
||||
|
||||
inline int
|
||||
MPI::Graphcomm::Map(int nnodes, const int index[],
|
||||
const int edges[]) const
|
||||
{
|
||||
int newrank;
|
||||
(void)MPI_Graph_map(mpi_comm, nnodes, (int*)index, (int*)edges, &newrank);
|
||||
return newrank;
|
||||
}
|
||||
|
||||
inline MPI::Graphcomm&
|
||||
MPI::Graphcomm::Clone() const
|
||||
{
|
||||
MPI_Comm newcomm;
|
||||
(void)MPI_Comm_dup(mpi_comm, &newcomm);
|
||||
MPI::Graphcomm* dup = new MPI::Graphcomm(newcomm);
|
||||
return *dup;
|
||||
}
|
153
src/mpi/cxx/win.h
Обычный файл
153
src/mpi/cxx/win.h
Обычный файл
@ -0,0 +1,153 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
class Win {
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
// friend class P;
|
||||
#endif
|
||||
friend class MPI::Comm; //so I can access pmpi_win data member in comm.cc
|
||||
friend class MPI::Request; //and also from request.cc
|
||||
|
||||
public:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
|
||||
// construction / destruction
|
||||
Win() { }
|
||||
virtual ~Win() { }
|
||||
|
||||
|
||||
// copy / assignment
|
||||
Win(const Win& data) : pmpi_win(data.pmpi_win) { }
|
||||
|
||||
Win(const MPI_Win &i) : pmpi_win(i) { }
|
||||
|
||||
Win& operator=(const Win& data) {
|
||||
pmpi_win = data.pmpi_win; return *this; }
|
||||
|
||||
// comparison, don't need for win
|
||||
|
||||
// inter-language operability
|
||||
Win& operator= (const MPI_Win &i) {
|
||||
pmpi_win = i; return *this; }
|
||||
operator MPI_Win () const { return pmpi_win; }
|
||||
// operator MPI_Win* () const { return pmpi_win; }
|
||||
operator const PMPI::Win&() const { return pmpi_win; }
|
||||
|
||||
#else
|
||||
|
||||
Win() { }
|
||||
// copy
|
||||
Win(const Win& data) : mpi_win(data.mpi_win) { }
|
||||
|
||||
Win(const MPI_Win &i) : mpi_win(i) { }
|
||||
|
||||
virtual ~Win() { }
|
||||
|
||||
Win& operator=(const Win& data) {
|
||||
mpi_win = data.mpi_win; return *this; }
|
||||
|
||||
// comparison, don't need for win
|
||||
|
||||
// inter-language operability
|
||||
Win& operator= (const MPI_Win &i) {
|
||||
mpi_win = i; return *this; }
|
||||
operator MPI_Win () const { return mpi_win; }
|
||||
// operator MPI_Win* () const { return (MPI_Win*)&mpi_win; }
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// User defined functions
|
||||
//
|
||||
typedef int Copy_attr_function(const Win& oldwin, int win_keyval,
|
||||
void* extra_state, void* attribute_val_in,
|
||||
void* attribute_val_out, bool& flag);
|
||||
|
||||
typedef int Delete_attr_function(Win& win, int win_keyval,
|
||||
void* attribute_val, void* extra_state);
|
||||
|
||||
typedef void Errhandler_fn(Win &, int *, ... );
|
||||
|
||||
//
|
||||
// Miscellany
|
||||
//
|
||||
static MPI::Errhandler Create_errhandler(Errhandler_fn* function);
|
||||
virtual MPI::Errhandler Get_errhandler() const;
|
||||
virtual void Set_errhandler(const MPI::Errhandler& errhandler);
|
||||
|
||||
//
|
||||
// One sided communication
|
||||
//
|
||||
virtual void Accumulate(const void* origin_addr, int origin_count,
|
||||
const MPI::Datatype& origin_datatype,
|
||||
int target_rank, MPI::Aint target_disp,
|
||||
int target_count,
|
||||
const MPI::Datatype& target_datatype,
|
||||
const MPI::Op& op) const;
|
||||
|
||||
virtual void Complete() const;
|
||||
|
||||
static Win Create(const void* base, MPI::Aint size, int disp_unit,
|
||||
const MPI::Info& info, const MPI::Intracomm& comm);
|
||||
|
||||
virtual void Fence(int assert) const;
|
||||
|
||||
virtual void Free();
|
||||
|
||||
virtual void Get(const void *origin_addr, int origin_count,
|
||||
const MPI::Datatype& origin_datatype, int target_rank,
|
||||
MPI::Aint target_disp, int target_count,
|
||||
const MPI::Datatype& target_datatype) const;
|
||||
|
||||
virtual MPI::Group Get_group() const;
|
||||
|
||||
virtual void Lock(int lock_type, int rank, int assert) const;
|
||||
|
||||
virtual void Post(const MPI::Group& group, int assert) const;
|
||||
|
||||
virtual void Put(const void* origin_addr, int origin_count,
|
||||
const MPI::Datatype& origin_datatype, int target_rank,
|
||||
MPI::Aint target_disp, int target_count,
|
||||
const MPI::Datatype& target_datatype) const;
|
||||
|
||||
virtual void Start(const MPI::Group& group, int assert) const;
|
||||
|
||||
virtual bool Test() const;
|
||||
|
||||
virtual void Unlock(int rank) const;
|
||||
|
||||
virtual void Wait() const;
|
||||
|
||||
|
||||
//
|
||||
// External Interfaces
|
||||
//
|
||||
virtual void Call_errhandler(int errorcode) const;
|
||||
|
||||
static int Create_keyval(Copy_attr_function* win_copy_attr_fn,
|
||||
Delete_attr_function* win_delete_attr_fn,
|
||||
void* extra_state);
|
||||
|
||||
virtual void Delete_attr(int win_keyval);
|
||||
|
||||
static void Free_keyval(int& win_keyval);
|
||||
|
||||
bool Get_attr(const Win& win, int win_keyval,
|
||||
void* attribute_val) const;
|
||||
|
||||
virtual void Get_name(char* win_name, int& resultlen) const;
|
||||
|
||||
virtual void Set_attr(int win_keyval, const void* attribute_val);
|
||||
|
||||
virtual void Set_name(const char* win_name);
|
||||
|
||||
protected:
|
||||
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
||||
PMPI::Win pmpi_win;
|
||||
#else
|
||||
MPI_Win mpi_win;
|
||||
#endif
|
||||
};
|
260
src/mpi/cxx/win_inln.h
Обычный файл
260
src/mpi/cxx/win_inln.h
Обычный файл
@ -0,0 +1,260 @@
|
||||
// -*- c++ -*-
|
||||
//
|
||||
// $HEADER$
|
||||
//
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Miscellany
|
||||
//
|
||||
|
||||
|
||||
inline MPI::Errhandler
|
||||
MPI::Win::Create_errhandler(MPI::Win::Errhandler_fn* function)
|
||||
{
|
||||
MPI_Errhandler errhandler;
|
||||
(void) MPI_Win_create_errhandler((MPI_Win_errhandler_fn *)function,
|
||||
&errhandler);
|
||||
return errhandler;
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Errhandler
|
||||
MPI::Win:: Get_errhandler() const
|
||||
{
|
||||
MPI_Errhandler errhandler;
|
||||
(void) MPI_Win_get_errhandler(mpi_win, &errhandler);
|
||||
return errhandler;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Set_errhandler(const MPI::Errhandler& errhandler)
|
||||
{
|
||||
(void) MPI_Win_set_errhandler(mpi_win, errhandler);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// One sided communication
|
||||
//
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Accumulate(const void* origin_addr, int origin_count,
|
||||
const MPI::Datatype& origin_datatype, int target_rank,
|
||||
MPI::Aint target_disp, int target_count,
|
||||
const MPI::Datatype& target_datatype,
|
||||
const MPI::Op& op) const
|
||||
{
|
||||
(void) MPI_Accumulate((void*) origin_addr, origin_count, origin_datatype,
|
||||
target_rank, target_disp, target_count,
|
||||
target_datatype, op, mpi_win);
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Complete() const
|
||||
{
|
||||
(void) MPI_Win_complete(mpi_win);
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Win
|
||||
MPI::Win::Create(const void* base, MPI::Aint size,
|
||||
int disp_unit, const MPI::Info& info,
|
||||
const MPI::Intracomm& comm)
|
||||
{
|
||||
MPI_Win newwin;
|
||||
(void) MPI_Win_create((void *)base, size, disp_unit, info, comm, &newwin);
|
||||
return newwin;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Fence(int assert) const
|
||||
{
|
||||
(void) MPI_Win_fence(assert, mpi_win);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Free()
|
||||
{
|
||||
(void) MPI_Win_free(&mpi_win);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Get(const void *origin_addr, int origin_count,
|
||||
const MPI::Datatype& origin_datatype,
|
||||
int target_rank, MPI::Aint target_disp,
|
||||
int target_count,
|
||||
const MPI::Datatype& target_datatype) const
|
||||
{
|
||||
(void) MPI_Get((void*) origin_addr, origin_count, origin_datatype,
|
||||
target_rank, target_disp,
|
||||
target_count, target_datatype, mpi_win);
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline MPI::Group
|
||||
MPI::Win::Get_group() const
|
||||
{
|
||||
MPI_Group mpi_group;
|
||||
(void) MPI_Win_get_group(mpi_win, &mpi_group);
|
||||
return mpi_group;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Lock(int lock_type, int rank, int assert) const
|
||||
{
|
||||
(void) MPI_Win_lock(lock_type, rank, assert, mpi_win);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Post(const MPI::Group& group, int assert) const
|
||||
{
|
||||
(void) MPI_Win_post(group, assert, mpi_win);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Put(const void* origin_addr, int origin_count,
|
||||
const MPI::Datatype& origin_datatype,
|
||||
int target_rank, MPI::Aint target_disp,
|
||||
int target_count,
|
||||
const MPI::Datatype& target_datatype) const
|
||||
{
|
||||
(void) MPI_Put((void*) origin_addr, origin_count, origin_datatype,
|
||||
target_rank, target_disp, target_count,
|
||||
target_datatype, mpi_win);
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Start(const MPI::Group& group, int assert) const
|
||||
{
|
||||
(void) MPI_Win_start(group, assert, mpi_win);
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
MPI::Win::Test() const
|
||||
{
|
||||
int flag;
|
||||
MPI_Win_test(mpi_win, &flag);
|
||||
return (bool) flag;
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Unlock(int rank) const
|
||||
{
|
||||
(void) MPI_Win_unlock(rank, mpi_win);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Wait() const
|
||||
{
|
||||
(void) MPI_Win_wait(mpi_win);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// External Interfaces
|
||||
//
|
||||
|
||||
inline void
|
||||
MPI::Win::Call_errhandler(int errorcode) const
|
||||
{
|
||||
(void) MPI_Win_call_errhandler(mpi_win, errorcode);
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
MPI::Win::Create_keyval(MPI::Win::Copy_attr_function*
|
||||
win_copy_attr_fn,
|
||||
MPI::Win::Delete_attr_function*
|
||||
win_delete_attr_fn, void* extra_state)
|
||||
{
|
||||
int val;
|
||||
(void) MPI_Win_create_keyval((MPI_Win_copy_attr_function *)win_copy_attr_fn,
|
||||
(MPI_Win_delete_attr_function *)
|
||||
win_delete_attr_fn, &val,extra_state);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Delete_attr(int win_keyval)
|
||||
{
|
||||
(void) MPI_Win_delete_attr(mpi_win, win_keyval);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Free_keyval(int& win_keyval)
|
||||
{
|
||||
(void) MPI_Win_free_keyval(&win_keyval);
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
MPI::Win::Get_attr(const Win& win, int win_keyval,
|
||||
void* attribute_val) const
|
||||
{
|
||||
int ret;
|
||||
(void) MPI_Win_get_attr(win, win_keyval, attribute_val, &ret);
|
||||
return (bool) ret;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Get_name(char* win_name, int& resultlen) const
|
||||
{
|
||||
(void) MPI_Win_get_name(mpi_win, win_name, &resultlen);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Set_attr(int win_keyval, const void* attribute_val)
|
||||
{
|
||||
(void) MPI_Win_set_attr(mpi_win, win_keyval,(void *) attribute_val);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MPI::Win::Set_name(const char* win_name)
|
||||
{
|
||||
(void) MPI_Win_set_name(mpi_win, (char *)win_name);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//
|
||||
// User defined functions
|
||||
//
|
||||
|
||||
typedef int MPI::Win::Copy_attr_function(const Win& oldwin,
|
||||
int win_keyval,
|
||||
void* extra_state,
|
||||
void* attribute_val_in,
|
||||
void* attribute_val_out,
|
||||
bool& flag);
|
||||
|
||||
typedef int MPI::Win::Delete_attr_function(&win, int win_keyval,
|
||||
void* attribute_val,
|
||||
void* extra_state);
|
||||
|
||||
typedef void MPI::Win::Errhandler_fn(Win &, int *, ... );
|
||||
|
||||
#endif
|
@ -216,6 +216,14 @@ ompi_wrap_build_cflags(bool want_f77_includes, ompi_sv_t& cflags)
|
||||
|
||||
if (want_f77_includes || "/usr/include" != incdir)
|
||||
cflags.push_back("-I" + incdir);
|
||||
|
||||
#if OMPI_WANT_CXX_BINDINGS
|
||||
cflags.push_back("-I" + incdir + "/ompi");
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && WIN32
|
||||
#error "Anju needs to fix me. FIX ME FIX ME FIX ME."
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -352,18 +360,20 @@ ompi_wrap_build_libs(bool want_cxx_libs, ompi_sv_t& libs)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if OMPI_WANT_CXX_BINDINGS
|
||||
// The C++ bindings come next
|
||||
#if 0
|
||||
if (want_cxx_libs) {
|
||||
if (!ompi_wrap_check_file(libdir, "libompi_mpi++.a") &&
|
||||
!ompi_wrap_check_file(libdir, "libompi_mpi++.so"))
|
||||
if (!ompi_wrap_check_file(libdir, "libmpi_cxx.a") &&
|
||||
!ompi_wrap_check_file(libdir, "libmpi_cxx.so") &&
|
||||
!ompi_wrap_check_file(libdir, "libmpi_cxx.dylib"))
|
||||
cerr << "WARNING: " << cmd_name
|
||||
<< " expected to find libompi_mpi++.* in " << libdir << endl
|
||||
<< " expected to find libmpi_cxx.* in " << libdir << endl
|
||||
<< "WARNING: MPI C++ support will be disabled" << endl;
|
||||
else
|
||||
libs.push_back("-lompi_mpi++");
|
||||
libs.push_back("-lmpi_cxx");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Next comes the fortran MPI library
|
||||
#if 0
|
||||
#if BUILD_MPI_F77
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user