1
1
- Fix some typos from last commit
- Add collectives of intercommunicators
- Move the static current_op member from Intracomm to Comm
  --> this is still a remaining problem: the global variable
      current_op is not thread safe!

This commit was SVN r8520.
Этот коммит содержится в:
Jeff Squyres 2005-12-15 22:07:34 +00:00
родитель 8df345b66a
Коммит 83d34c8435
7 изменённых файлов: 243 добавлений и 20 удалений

Просмотреть файл

@ -365,6 +365,9 @@ public: // JGS hmmm, these used by errhandler_intercept
void init() {
my_errhandler = (Errhandler*)0;
}
static Op* current_op;
#endif
};

Просмотреть файл

@ -124,7 +124,7 @@ public:
#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*) &ompi_mpi_cxx_throw_excptn_fctn,
const_cast<MPI_Errhandler *> &mpi_errhandler);
const_cast<MPI_Errhandler *>(&mpi_errhandler));
#else
pmpi_errhandler.init();
#endif
@ -134,7 +134,7 @@ public:
//this is called from MPI::Finalize
inline void free() const {
#if ! 0 /* OMPI_ENABLE_MPI_PROFILING */
(void)MPI_Errhandler_free(const_cast<MPI_Errhandler *> &mpi_errhandler);
(void)MPI_Errhandler_free(const_cast<MPI_Errhandler *>(&mpi_errhandler));
#else
pmpi_errhandler.free();
#endif

Просмотреть файл

@ -61,13 +61,13 @@ void ompi_mpi_cxx_errhandler_intercept(MPI_Comm *mpi_comm, int *err, ...)
}
}
MPI::Op* MPI::Intracomm::current_op;
MPI::Op* MPI::Comm::current_op;
extern "C" void
ompi_mpi_cxx_op_intercept(void *invec, void *outvec, int *len,
MPI_Datatype *datatype)
{
MPI::Op* op = MPI::Intracomm::current_op;
MPI::Op* op = MPI::Comm::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:

Просмотреть файл

@ -83,17 +83,83 @@ public:
// Extended Collective Operations
//
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 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
};

Просмотреть файл

@ -17,6 +17,166 @@
// $HEADER$
//
inline void
MPI::Intercomm::Barrier() const
{
(void)MPI_Barrier(mpi_comm);
}
inline void
MPI::Intercomm::Bcast(void *buffer, int count,
const MPI::Datatype& datatype, int root) const
{
(void)MPI_Bcast(buffer, count, datatype, root, mpi_comm);
}
inline void
MPI::Intercomm::Gather(const void *sendbuf, int sendcount,
const MPI::Datatype & sendtype,
void *recvbuf, int recvcount,
const MPI::Datatype & recvtype, int root) const
{
(void)MPI_Gather(const_cast<void *>(sendbuf), sendcount, sendtype,
recvbuf, recvcount, recvtype, root, mpi_comm);
}
inline void
MPI::Intercomm::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(const_cast<void *>(sendbuf), sendcount, sendtype,
recvbuf, const_cast<int *>(recvcounts), const_cast<int *>(displs),
recvtype, root, mpi_comm);
}
inline void
MPI::Intercomm::Scatter(const void *sendbuf, int sendcount,
const MPI::Datatype & sendtype,
void *recvbuf, int recvcount,
const MPI::Datatype & recvtype, int root) const
{
(void)MPI_Scatter(const_cast<void *>(sendbuf), sendcount, sendtype,
recvbuf, recvcount, recvtype, root, mpi_comm);
}
inline void
MPI::Intercomm::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(const_cast<void *>(sendbuf), const_cast<int *>(sendcounts),
const_cast<int *>(displs), sendtype,
recvbuf, recvcount, recvtype,
root, mpi_comm);
}
inline void
MPI::Intercomm::Allgather(const void *sendbuf, int sendcount,
const MPI::Datatype & sendtype, void *recvbuf,
int recvcount, const MPI::Datatype & recvtype) const
{
(void)MPI_Allgather(const_cast<void *>(sendbuf), sendcount,
sendtype, recvbuf, recvcount,
recvtype, mpi_comm);
}
inline void
MPI::Intercomm::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(const_cast<void *>(sendbuf), sendcount,
sendtype, recvbuf,
const_cast<int *>(recvcounts), const_cast<int *>(displs),
recvtype, mpi_comm);
}
inline void
MPI::Intercomm::Alltoall(const void *sendbuf, int sendcount,
const MPI::Datatype & sendtype, void *recvbuf,
int recvcount, const MPI::Datatype & recvtype) const
{
(void)MPI_Alltoall(const_cast<void *>(sendbuf), sendcount,
sendtype, recvbuf, recvcount,
recvtype, mpi_comm);
}
inline void
MPI::Intercomm::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(const_cast<void *>(sendbuf),
const_cast<int *>(sendcounts),
const_cast<int *>(sdispls), sendtype, recvbuf,
const_cast<int *>(recvcounts),
const_cast<int *>(rdispls),
recvtype,mpi_comm);
}
inline void
MPI::Intercomm::Alltoallw(const void *sendbuf, const int sendcounts[],
const int sdispls[], const MPI::Datatype sendtypes[],
void *recvbuf, const int recvcounts[],
const int rdispls[], const MPI::Datatype recvtypes[]) const
{
const int comm_size = Get_size();
MPI_Datatype *const data_type_tbl = new MPI_Datatype [2*comm_size];
// This must be done because MPI::Datatype arrays cannot be
// converted directly into MPI_Datatype arrays.
for (int i_rank=0; i_rank < comm_size; i_rank++) {
data_type_tbl[i_rank] = sendtypes[i_rank];
data_type_tbl[i_rank + comm_size] = recvtypes[i_rank];
}
(void)MPI_Alltoallw(const_cast<void *>(sendbuf),
const_cast<int *>(sendcounts),
const_cast<int *>(sdispls),
data_type_tbl, recvbuf,
const_cast<int *>(recvcounts),
const_cast<int *>(rdispls),
&data_type_tbl[comm_size], mpi_comm);
delete[] data_type_tbl;
}
inline void
MPI::Intercomm::Reduce(const void *sendbuf, void *recvbuf, int count,
const MPI::Datatype & datatype, const MPI::Op& op,
int root) const
{
current_op = const_cast<MPI::Op*>(&op);
(void)MPI_Reduce(const_cast<void *>(sendbuf), recvbuf, count, datatype, op, root, mpi_comm);
current_op = (Op*)0;
}
inline void
MPI::Intercomm::Allreduce(const void *sendbuf, void *recvbuf, int count,
const MPI::Datatype & datatype, const MPI::Op& op) const
{
current_op = const_cast<MPI::Op*>(&op);
(void)MPI_Allreduce (const_cast<void *>(sendbuf), recvbuf, count, datatype, op, mpi_comm);
current_op = (Op*)0;
}
inline void
MPI::Intercomm::Reduce_scatter(const void *sendbuf, void *recvbuf,
int recvcounts[],
const MPI::Datatype & datatype,
const MPI::Op& op) const
{
current_op = const_cast<MPI::Op*>(&op);
(void)MPI_Reduce_scatter(const_cast<void *>(sendbuf), recvbuf, recvcounts,
datatype, op, mpi_comm);
current_op = (Op*)0;
}
inline MPI::Intercomm
MPI::Intercomm::Dup() const
{

Просмотреть файл

@ -233,10 +233,4 @@ protected:
// eventually deleted.
static inline MPI_Info *convert_info_to_mpi_info(int p_nbr,
const Info p_info_tbl[]);
public: // JGS see above about friend decls
#if ! 0 /* OMPI_ENABLE_MPI_PROFILING */
static Op* current_op;
#endif
};

Просмотреть файл

@ -161,7 +161,7 @@ MPI::Intracomm::Alltoallw(const void *sendbuf, const int sendcounts[],
data_type_tbl, recvbuf,
const_cast<int *>(recvcounts),
const_cast<int *>(rdispls),
data_type_tbl[comm_size], mpi_comm);
&data_type_tbl[comm_size], mpi_comm);
delete[] data_type_tbl;
}