From 9e96a6c29de19de2c29e9536eb9a98ab9a653fb8 Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt <mikael@djurfeldt.com> Date: Tue, 19 Jul 2022 20:38:37 +0200 Subject: [PATCH] Convert C++ calls to C calls --- examples/waveproducer.cc | 2 +- src/application_map.cc | 4 +- src/application_mapper.cc | 4 +- src/connector.cc | 79 +++++++------- src/multibuffer.cc | 36 ++++--- src/music/subconnector.hh | 2 +- src/runtime.cc | 4 +- src/scheduler.cc | 9 +- src/scheduler_agent.cc | 16 +-- src/setup.cc | 13 +-- src/spatial.cc | 44 ++++---- src/subconnector.cc | 149 +++++++++++++++------------ src/temporal.cc | 39 +++---- testsuite/sanitytests/constsource.cc | 2 +- utils/eventlogger.cc | 2 +- utils/eventsink.cc | 2 +- 16 files changed, 220 insertions(+), 187 deletions(-) diff --git a/examples/waveproducer.cc b/examples/waveproducer.cc index 5ff5fc5..da57d39 100644 --- a/examples/waveproducer.cc +++ b/examples/waveproducer.cc @@ -55,7 +55,7 @@ main (int argc, char* argv[]) } // Broadcast these data out to all nodes - comm.Bcast (data, nLocalVars, MPI::DOUBLE, 0); + MPI_Bcast (data, nLocalVars, MPI::DOUBLE, 0, comm); } runtime->finalize (); diff --git a/src/application_map.cc b/src/application_map.cc index 8e6e87f..053f272 100644 --- a/src/application_map.cc +++ b/src/application_map.cc @@ -123,8 +123,8 @@ namespace MUSIC { int size = mpi_get_size (MPI_COMM_WORLD); int rank = mpi_get_rank (MPI_COMM_WORLD); int *colors = new int[size]; - colors[my_rank] = lookup (my_app_label)->color (); - MPI::COMM_WORLD.Allgather (MPI::IN_PLACE, 0, MPI::INT, colors, 1, MPI::INT); + colors[rank] = lookup (my_app_label)->color (); + MPI_Allgather (MPI_IN_PLACE, 0, MPI_INT, colors, 1, MPI_INT, MPI_COMM_WORLD); int prev_color = -1; for (int i = 0; i < size; ++i) diff --git a/src/application_mapper.cc b/src/application_mapper.cc index 5d39925..01f7c86 100644 --- a/src/application_mapper.cc +++ b/src/application_mapper.cc @@ -96,8 +96,8 @@ namespace MUSIC { // communicate st.st_ino long *inos = new long[nRanks]; inos[my_rank] = my_ino; - MPI::COMM_WORLD.Allgather (MPI::IN_PLACE, 0, MPI::LONG, inos, 1, - MPI::LONG); + MPI_Allgather (MPI_IN_PLACE, 0, MPI_LONG, inos, 1, + MPI_LONG, MPI_COMM_WORLD); int index = 0; int i = 0; diff --git a/src/connector.cc b/src/connector.cc index dd8a49b..45e93ea 100644 --- a/src/connector.cc +++ b/src/connector.cc @@ -78,17 +78,19 @@ namespace MUSIC { Connector::createIntercomm () { - intercomm = comm.Create_intercomm (0, - MPI::COMM_WORLD, - info.remoteLeader (), - CREATE_INTERCOMM_MSG); + MPI_Intercomm_create (comm, + 0, + MPI_COMM_WORLD, + info.remoteLeader (), + CREATE_INTERCOMM_MSG, + &intercomm); } void Connector::freeIntercomm () { - intercomm.Free (); + MPI_Comm_free (&intercomm); } @@ -217,7 +219,7 @@ namespace MUSIC { (*s)->maybeCommunicate(requests); } //The spec guarantees vectors store their elements contiguously: - MPI::Request::Waitall(requests.size(), (MPI::Request *)&requests[0]); + MPI_Waitall(requests.size(), (MPI_Request *)&requests[0], MPI_STATUSES_IGNORE); } #endif //MUSIC_ISENDWAITALL @@ -250,12 +252,14 @@ namespace MUSIC { { // exchange tickInterval with peer leader sRemoteTickInterval = tickInterval.serialize (); - intercomm.Sendrecv_replace (&sRemoteTickInterval, 2, MPI::UNSIGNED_LONG, - 0, TICKINTERVAL_MSG, - 0, TICKINTERVAL_MSG); + MPI_Sendrecv_replace (&sRemoteTickInterval, 2, MPI_UNSIGNED_LONG, + 0, TICKINTERVAL_MSG, + 0, TICKINTERVAL_MSG, + intercomm, + MPI_STATUS_IGNORE); } // broadcast to peers - comm.Bcast (&sRemoteTickInterval, 2, MPI::UNSIGNED_LONG, 0); + MPI_Bcast (&sRemoteTickInterval, 2, MPI_UNSIGNED_LONG, 0, comm); return sRemoteTickInterval.deserialize (); } @@ -747,16 +751,18 @@ error( "LOCAL Indices are not supported with MUSIC_ANYSOURCE"); char data[SPIKE_BUFFER_MAX]; MPI_Status status; while(size > 0 && flushes > 0){ - intercomm.Recv (data, - SPIKE_BUFFER_MAX, - MPI::BYTE, - MPI_ANY_SOURCE, - SPIKE_MSG, - status); - - int msize = status.Get_count(MPI::BYTE); - if (rRank2Subconnector[status.Get_source()]->receive(data, msize)) - flushes--; + MPI_Recv (data, + SPIKE_BUFFER_MAX, + MPI_BYTE, + MPI_ANY_SOURCE, + SPIKE_MSG, + intercomm, + &status); + + int msize; + MPI_Get_count (&status, MPI_BYTE, &msize); + if (rRank2Subconnector[status.MPI_SOURCE]->receive (data, msize)) + flushes--; if( msize < SPIKE_BUFFER_MAX) size--; } @@ -859,14 +865,14 @@ error( "LOCAL Indices are not supported with MUSIC_ANYSOURCE"); CollectiveConnector::createIntercomm () { Connector::createIntercomm (); - intracomm_ = intercomm.Merge (high_); + MPI_Intercomm_merge (intercomm, high_, &intracomm_); } void CollectiveConnector::freeIntercomm () { - intracomm_.Free (); + MPI_Comm_free (&intracomm_); Connector::freeIntercomm (); } @@ -1051,15 +1057,17 @@ error( "LOCAL Indices are not supported with MUSIC_ANYSOURCE"); ContInputCollectiveConnector::receiveRemoteCommRankID(std::map<int,int> &remoteToCollectiveRankMap) { int nProcesses, intra_rank; - nProcesses = intercomm.Get_remote_size(); + MPI_Comm_remote_size (intercomm, &nProcesses); for (int i =0; i < nProcesses; ++i) { - intercomm.Recv (&intra_rank, - 1, - MPI::INT, - i, - SPATIAL_NEGOTIATION_MSG); + MPI_Recv (&intra_rank, + 1, + MPI_INT, + i, + SPATIAL_NEGOTIATION_MSG, + intercomm, + MPI_STATUS_IGNORE); remoteToCollectiveRankMap.insert(std::make_pair(i,intra_rank)); MUSIC_LOG0( "Remote Communication Rank:" << i << "is mapped to Collective Communication Rank:" << intra_rank ); } @@ -1098,15 +1106,16 @@ error( "LOCAL Indices are not supported with MUSIC_ANYSOURCE"); ContOutputCollectiveConnector::sendLocalCommRankID() { int nProcesses, intra_rank; - nProcesses = intercomm.Get_remote_size(); - intra_rank = intracomm_.Get_rank(); + MPI_Comm_remote_size (intercomm, &nProcesses); + intra_rank = mpi_get_rank (intracomm_); std::map<int,int> rCommToCollCommRankMap; for (int i =0; i < nProcesses; ++i){ - intercomm.Ssend(&intra_rank, - 1, - MPI::INT, - i, - SPATIAL_NEGOTIATION_MSG); + MPI_Ssend (&intra_rank, + 1, + MPI_INT, + i, + SPATIAL_NEGOTIATION_MSG, + intercomm); } } } diff --git a/src/multibuffer.cc b/src/multibuffer.cc index bfaf921..2d4c274 100644 --- a/src/multibuffer.cc +++ b/src/multibuffer.cc @@ -594,7 +594,9 @@ namespace MUSIC { ostr << std::endl; std::cout << ostr.str () << std::flush; #endif - group_ = MPI::COMM_WORLD.Get_group ().Range_incl (nRanges, range); + MPI_Group worldGroup; + MPI_Comm_group (MPI_COMM_WORLD, &worldGroup); + MPI_Group_range_incl (worldGroup, nRanges, range, &group_); delete[] range; } @@ -607,18 +609,18 @@ namespace MUSIC { idstr_ << ':' << cid->first << cid->second; id_ = "mc" + idstr_.str (); - if (!isContiguous || group_.Get_size () < MPI::COMM_WORLD.Get_size ()) - comm_ = MPI::COMM_WORLD.Create (group_); + if (!isContiguous || mpi_get_size (group_) < mpi_get_size (MPI_COMM_WORLD)) + MPI_Comm_create (MPI_COMM_WORLD, group_, &comm_); else - comm_ = MPI::COMM_WORLD; - MPI::COMM_WORLD.Barrier (); + comm_ = MPI_COMM_WORLD; + MPI_Barrier (MPI_COMM_WORLD); std::vector<int> ranks (size ()); std::vector<int> indices (size ()); for (int rank = 0; rank < size (); ++rank) ranks[rank] = rank; - MPI::Group::Translate_ranks (group_, size (), &ranks[0], - MPI::COMM_WORLD.Get_group (), &indices[0]); + MPI_Group_translate_ranks (group_, size (), &ranks[0], + mpi_get_group (MPI_COMM_WORLD), &indices[0]); #ifdef MUSIC_TWOSTAGE_ALLGATHER twostage_ = true; #endif @@ -895,8 +897,9 @@ namespace MUSIC { if (block_[rank ()]->finalizeFlag (buffer_)) recvc |= TWOSTAGE_FINALIZE_FLAG; recvcounts_[rank ()] = recvc; - comm_.Allgather (MPI::IN_PLACE, 0, MPI::DATATYPE_NULL, - recvcounts_, 1, MPI::INT); + MPI_Allgather (MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, + recvcounts_, 1, MPI_INT, + comm_); checkRestructure (); // sets doAllgather_ if (doAllgather_) { @@ -904,8 +907,9 @@ namespace MUSIC { #ifdef MUSIC_DEBUG dumprecvc (id_, recvcounts_, displs_, comm_.Get_size ()); #endif - comm_.Allgatherv (MPI::IN_PLACE, 0, MPI::DATATYPE_NULL, - buffer_, recvcounts_, displs_, MPI::BYTE); + MPI_Allgatherv (MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, + buffer_, recvcounts_, displs_, MPI_BYTE, + comm_); processReceived (); } } @@ -918,8 +922,9 @@ namespace MUSIC { #ifdef MUSIC_DEBUG dumprecvc (id_, recvcounts_, displs_, comm_.Get_size ()); #endif - comm_.Allgatherv (MPI::IN_PLACE, 0, MPI::DATATYPE_NULL, - buffer_, recvcounts_, displs_, MPI::BYTE); + MPI_Allgatherv (MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, + buffer_, recvcounts_, displs_, MPI_BYTE, + comm_); for (BlockPtrs::iterator b = block_.begin (); b != block_.end (); ++b) @@ -933,8 +938,9 @@ namespace MUSIC { #ifdef MUSIC_DEBUG dumprecvc (id_, recvcounts_, displs_, comm_.Get_size ()); #endif - comm_.Allgatherv (MPI::IN_PLACE, 0, MPI::DATATYPE_NULL, - buffer_, recvcounts_, displs_, MPI::BYTE); + MPI_Allgatherv (MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, + buffer_, recvcounts_, displs_, MPI_BYTE, + comm_); break; } processInput (); diff --git a/src/music/subconnector.hh b/src/music/subconnector.hh index cd9db03..545ea4d 100644 --- a/src/music/subconnector.hh +++ b/src/music/subconnector.hh @@ -269,7 +269,7 @@ namespace MUSIC { /* remedius * CollectiveSubconnector class is used for collective communication - * based on MPI::ALLGATHER function. + * based on the MPI_Allgather function. */ class CollectiveSubconnector : public virtual Subconnector { diff --git a/src/runtime.cc b/src/runtime.cc index 8de2775..2cbc790 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -433,13 +433,13 @@ namespace MUSIC #if defined (OPEN_MPI) && MPI_VERSION <= 2 // This is needed in OpenMPI version <= 1.2 for the freeing of the // intercommunicators to go well - MPI::COMM_WORLD.Barrier (); + MPI_Barrier (MPI_COMM_WORLD); #endif for (std::vector<Connector*>::iterator connector = connectors.begin (); connector != connectors.end (); ++connector) (*connector)->freeIntercomm (); - MPI::Finalize (); + MPI_Finalize (); } diff --git a/src/scheduler.cc b/src/scheduler.cc index 1ff8d1d..375185d 100644 --- a/src/scheduler.cc +++ b/src/scheduler.cc @@ -383,10 +383,11 @@ namespace MUSIC { if (!multiProxies[multiProxyId]) { - std::cout << "Rank " << MPI::COMM_WORLD.Get_rank () - << ": *" << std::endl << std::flush; - MPI::COMM_WORLD.Create (MPI::GROUP_EMPTY); - MPI::COMM_WORLD.Barrier (); + std::cout << "Rank " << mpi_get_rank (MPI_COMM_WORLD) + << ": *" << std::endl << std::flush; + MPI_Comm comm; + MPI_Comm_create (MPI_COMM_WORLD, MPI_GROUP_EMPTY, &comm); + MPI_Barrier (MPI_COMM_WORLD); //*fixme* Impossible to delete the following object multiProxies[multiProxyId] = true; } diff --git a/src/scheduler_agent.cc b/src/scheduler_agent.cc index 036e458..5e44313 100644 --- a/src/scheduler_agent.cc +++ b/src/scheduler_agent.cc @@ -240,8 +240,9 @@ namespace MUSIC { // std::cout << "Rank " << mpi_get_rank (MPI_COMM_WORLD) // << ": Proxy " << proxyId << std::endl; - MPI::COMM_WORLD.Create (MPI::GROUP_EMPTY); - MPI::COMM_WORLD.Barrier (); + MPI_Comm newcomm; + MPI_Comm_create (MPI_COMM_WORLD, MPI_GROUP_EMPTY, &newcomm); + MPI_Barrier (MPI_COMM_WORLD); (*multiProxies)[proxyId] = true; } } @@ -278,8 +279,9 @@ namespace MUSIC }// if we do not participate in the multicommunication and the multiconnector was not yet created else if (multiId == 0 && !((*multiProxies)[proxyId])) { - MPI::COMM_WORLD.Create (MPI::GROUP_EMPTY); - MPI::COMM_WORLD.Barrier (); + MPI_Comm newcomm; + MPI_Comm_create (MPI_COMM_WORLD, MPI_GROUP_EMPTY, &newcomm); + MPI_Barrier (MPI_COMM_WORLD); (*multiProxies)[proxyId] = true; } @@ -422,9 +424,9 @@ namespace MUSIC } // if we do not participate in the multicommunication and the multiconnector was not yet created else if (multiId == 0 && ! ( (*multiProxies)[proxyId])) { - - MPI::COMM_WORLD.Create (MPI::GROUP_EMPTY); - MPI::COMM_WORLD.Barrier (); + MPI_Comm newcomm; + MPI_Comm_create (MPI_COMM_WORLD, MPI_GROUP_EMPTY, &newcomm); + MPI_Barrier (MPI_COMM_WORLD); (*multiProxies)[proxyId] = true; } diff --git a/src/setup.cc b/src/setup.cc index 363f994..f2d3821 100644 --- a/src/setup.cc +++ b/src/setup.cc @@ -41,7 +41,7 @@ namespace MUSIC { if (MPI::Is_initialized ()) errorRank (err_MPI_Init); maybeProcessMusicArgv (argc, argv); - MPI::Init (argc, argv); + MPI_Init (&argc, &argv); init (argc, argv); @@ -55,12 +55,7 @@ namespace MUSIC { if (MPI::Is_initialized ()) errorRank (err_MPI_Init); maybeProcessMusicArgv (argc, argv); -#ifdef HAVE_MPI_INIT_THREAD - *provided = MPI::Init_thread (argc, argv, required); -#else - // Only C version provided in libmpich MPI_Init_thread (&argc, &argv, required, provided); -#endif init (argc, argv); } @@ -151,7 +146,7 @@ namespace MUSIC { argc = argc_; argv = argv_; } - comm = MPI::COMM_WORLD.Split (postponeSetup_ ? color_ : config_->Color (), myRank); + MPI_Comm_split (MPI_COMM_WORLD, postponeSetup_ ? color_ : config_->Color (), myRank, &comm); } else { @@ -227,13 +222,13 @@ namespace MUSIC { config.seekg (0, std::ios_base::beg); } // first broadcast the size of the file - MPI::COMM_WORLD.Bcast (&size, 1, MPI::INT, 0); + MPI_Bcast (&size, 1, MPI_INT, 0, MPI_COMM_WORLD); buffer = new char[size]; if (myRank == 0) config.read (buffer, size); // then broadcast the file but itself - MPI::COMM_WORLD.Bcast (buffer, size, MPI::BYTE, 0); + MPI_Bcast (buffer, size, MPI_BYTE, 0, MPI_COMM_WORLD); // parseMapFile (app_name, std::string (buffer, size), result); if (myRank == 0) config.close (); diff --git a/src/spatial.cc b/src/spatial.cc index 49875b0..65037e5 100644 --- a/src/spatial.cc +++ b/src/spatial.cc @@ -167,12 +167,12 @@ namespace MUSIC { // Now take maximum over all processes std::vector<int> m (nProcesses); - comm.Allgather (&u, 1, MPI::INT, &m[0], 1, MPI::INT); + MPI_Allgather (&u, 1, MPI_INT, &m[0], 1, MPI_INT, comm); for (unsigned int i = 0; i < nProcesses; ++i) if (m[i] > u) u = m[i]; width = u; - comm.Allgather (&w, 1, MPI::INT, &m[0], 1, MPI::INT); + MPI_Allgather (&w, 1, MPI_INT, &m[0], 1, MPI_INT, comm); for (unsigned int i = 0; i < nProcesses; ++i) if (m[i] > w) w = m[i]; @@ -189,9 +189,9 @@ namespace MUSIC { if (localRank == 0) { // Receiver might need to know sender width - intercomm.Send (&width, 1, MPI::INT, 0, WIDTH_MSG); + MPI_Send (&width, 1, MPI_INT, 0, WIDTH_MSG, intercomm); int remoteWidth; - intercomm.Recv (&remoteWidth, 1, MPI::INT, 0, WIDTH_MSG); + MPI_Recv (&remoteWidth, 1, MPI_INT, 0, WIDTH_MSG, intercomm, MPI_STATUS_IGNORE); if (remoteWidth != width) { std::ostringstream msg; @@ -209,7 +209,7 @@ namespace MUSIC { if (localRank == 0) { int remoteWidth; - intercomm.Recv (&remoteWidth, 1, MPI::INT, 0, WIDTH_MSG); + MPI_Recv (&remoteWidth, 1, MPI_INT, 0, WIDTH_MSG, intercomm, MPI_STATUS_IGNORE); // NOTE: For now, the handling of Index::WILDCARD_MAX is a bit // incomplete since, if there is any index interval on the // receiver side with index larger than the sender side width, @@ -220,10 +220,10 @@ namespace MUSIC { */ if (width == Index::WILDCARD_MAX || width < remoteWidth ) width = remoteWidth; - intercomm.Send (&width, 1, MPI::INT, 0, WIDTH_MSG); + MPI_Send (&width, 1, MPI_INT, 0, WIDTH_MSG, intercomm); } // Broadcast result (if we used a wildcard) - comm.Bcast (&width, 1, MPI::INT, 0); + MPI_Bcast (&width, 1, MPI_INT, 0, comm); if (maxLocalWidth_ == Index::WILDCARD_MAX) maxLocalWidth_ = width; } @@ -463,12 +463,13 @@ namespace MUSIC { SpatialNegotiationData* data = &intervals[0]; int nIntervals = intervals.size (); // first send size - comm.Send (&nIntervals, 1, MPI::INT, destRank, SPATIAL_NEGOTIATION_MSG); - comm.Send (data, - sizeof (SpatialNegotiationData) / sizeof (int) * nIntervals, - MPI::INT, - destRank, - SPATIAL_NEGOTIATION_MSG); + MPI_Send (&nIntervals, 1, MPI_INT, destRank, SPATIAL_NEGOTIATION_MSG, comm); + MPI_Send (data, + sizeof (SpatialNegotiationData) / sizeof (int) * nIntervals, + MPI_INT, + destRank, + SPATIAL_NEGOTIATION_MSG, + comm); } @@ -478,14 +479,17 @@ namespace MUSIC { NegotiationIntervals& intervals) { int nIntervals; - comm.Recv (&nIntervals, 1, MPI::INT, sourceRank, SPATIAL_NEGOTIATION_MSG); + MPI_Recv (&nIntervals, 1, MPI_INT, sourceRank, SPATIAL_NEGOTIATION_MSG, comm, + MPI_STATUS_IGNORE); intervals.resize (nIntervals); - comm.Recv (&intervals[0], - sizeof (SpatialNegotiationData) / sizeof (int) - * nIntervals, - MPI::INT, - sourceRank, - SPATIAL_NEGOTIATION_MSG); + MPI_Recv (&intervals[0], + sizeof (SpatialNegotiationData) / sizeof (int) + * nIntervals, + MPI_INT, + sourceRank, + SPATIAL_NEGOTIATION_MSG, + comm, + MPI_STATUS_IGNORE); } diff --git a/src/subconnector.cc b/src/subconnector.cc index f2e206f..51b7e4f 100644 --- a/src/subconnector.cc +++ b/src/subconnector.cc @@ -115,20 +115,22 @@ namespace MUSIC { { MUSIC_LOGR ("Sending to rank " << remoteRank_); - intercomm.Ssend (buffer, - CONT_BUFFER_MAX / type_.Get_size (), - type_, - remoteRank_, - CONT_MSG); + MPI_Ssend (buffer, + CONT_BUFFER_MAX / mpi_get_size (type_), + type_, + remoteRank_, + CONT_MSG, + intercomm); buffer += CONT_BUFFER_MAX; size -= CONT_BUFFER_MAX; } MUSIC_LOGR ("Last send to rank " << remoteRank_); - intercomm.Ssend (buffer, - size / type_.Get_size (), - type_, - remoteRank_, - CONT_MSG); + MPI_Ssend (buffer, + size / mpi_get_size (type_), + type_, + remoteRank_, + CONT_MSG, + intercomm); } @@ -146,7 +148,7 @@ namespace MUSIC { else { char dummy; - intercomm.Ssend (&dummy, 0, type_, remoteRank_, FLUSH_MSG); + MPI_Ssend (&dummy, 0, type_, remoteRank_, FLUSH_MSG, intercomm); flushed = true; } } @@ -200,20 +202,21 @@ namespace MUSIC { data = static_cast<char*> (buffer_.insertBlock ()); MUSIC_LOGR ("Receiving from rank " << remoteRank_); - intercomm.Recv (data, - maxCount, - type_, - remoteRank_, - MPI::ANY_TAG, - status); - if (status.Get_tag () == FLUSH_MSG) + MPI_Recv (data, + maxCount, + type_, + remoteRank_, + MPI_ANY_TAG, + intercomm, + &status); + if (status.MPI_TAG == FLUSH_MSG) { flushed = true; MUSIC_LOGR ("received flush message"); return; } - size = status.Get_count (type_); - buffer_.trimBlock (type_.Get_size () * size); + MPI_Get_count (&status, type_, &size); + buffer_.trimBlock (mpi_get_size (type_) * size); } while (size == maxCount); } @@ -280,15 +283,21 @@ namespace MUSIC { char* buffer = static_cast <char*> (data); while (size >= SPIKE_BUFFER_MAX) { - requests.push_back(intercomm.Isend (buffer, - SPIKE_BUFFER_MAX, - type_, - remoteRank_, - SPIKE_MSG)); + MPI_Request request; + MPI_Isend (buffer, + SPIKE_BUFFER_MAX, + type_, + remoteRank_, + SPIKE_MSG, + intercomm, + &request); + requests.push_back (request); buffer += SPIKE_BUFFER_MAX; size -= SPIKE_BUFFER_MAX; } - requests.push_back( intercomm.Isend (buffer, size, type_, remoteRank_, SPIKE_MSG)); + MPI_Request request; + MPI_Isend (buffer, size, type_, remoteRank_, SPIKE_MSG, intercomm, &request); + requests.push_back (request); } @@ -302,15 +311,16 @@ namespace MUSIC { char* buffer = static_cast <char*> (data); while (size >= SPIKE_BUFFER_MAX) { - intercomm.Ssend (buffer, - SPIKE_BUFFER_MAX, - type_, - remoteRank_, - SPIKE_MSG); + MPI_Ssend (buffer, + SPIKE_BUFFER_MAX, + type_, + remoteRank_, + SPIKE_MSG, + intercomm); buffer += SPIKE_BUFFER_MAX; size -= SPIKE_BUFFER_MAX; } - intercomm.Ssend (buffer, size, type_, remoteRank_, SPIKE_MSG); + MPI_Ssend (buffer, size, type_, remoteRank_, SPIKE_MSG, intercomm); } @@ -459,14 +469,15 @@ namespace MUSIC { do { - intercomm.Recv (data, - SPIKE_BUFFER_MAX, - type_, - remoteRank_, - SPIKE_MSG, - status); - - size = status.Get_count (type_); + MPI_Recv (data, + SPIKE_BUFFER_MAX, + type_, + remoteRank_, + SPIKE_MSG, + intercomm, + &status); + + MPI_Get_count (&status, type_, &size); Event* ev = (Event*) data; /* remedius * since the message can be of size 0 and contains garbage=FLUSH_MARK, @@ -505,13 +516,14 @@ namespace MUSIC { int size; do { - intercomm.Recv (data, - SPIKE_BUFFER_MAX, - type_, - remoteRank_, - SPIKE_MSG, - status); - size = status.Get_count (type_); + MPI_Recv (data, + SPIKE_BUFFER_MAX, + type_, + remoteRank_, + SPIKE_MSG, + intercomm, + &status); + MPI_Get_count (&status, type_, &size); Event* ev = (Event*) data; /* remedius * since the message can be of size 0 and contains garbage=FLUSH_MARK, @@ -601,15 +613,16 @@ namespace MUSIC { char* buffer = static_cast <char*> (data); while (size >= MESSAGE_BUFFER_MAX) { - intercomm.Ssend (buffer, - MESSAGE_BUFFER_MAX, - type_, - remoteRank_, - MESSAGE_MSG); + MPI_Ssend (buffer, + MESSAGE_BUFFER_MAX, + type_, + remoteRank_, + MESSAGE_MSG, + intercomm); buffer += MESSAGE_BUFFER_MAX; size -= MESSAGE_BUFFER_MAX; } - intercomm.Ssend (buffer, size, type_, remoteRank_, MESSAGE_MSG); + MPI_Ssend (buffer, size, type_, remoteRank_, MESSAGE_MSG, intercomm); } @@ -627,7 +640,7 @@ namespace MUSIC { else { char dummy; - intercomm.Ssend (&dummy, 0, type_, remoteRank_, FLUSH_MSG); + MPI_Ssend (&dummy, 0, type_, remoteRank_, FLUSH_MSG, intercomm); } } } @@ -671,19 +684,20 @@ namespace MUSIC { int size; do { - intercomm.Recv (data, - MESSAGE_BUFFER_MAX, - type_, - remoteRank_, - MPI::ANY_TAG, - status); - if (status.Get_tag () == FLUSH_MSG) + MPI_Recv (data, + MESSAGE_BUFFER_MAX, + type_, + remoteRank_, + MPI_ANY_TAG, + intercomm, + &status); + if (status.MPI_TAG == FLUSH_MSG) { flushed = true; MUSIC_LOGRE ("received flush message"); return; } - size = status.Get_count (type_); + MPI_Get_count (&status, type_, &size); int current = 0; while (current < size) { @@ -760,7 +774,7 @@ namespace MUSIC { { int dsize; //distributing the size of the buffer - intracomm_.Allgather (&local_data_size, 1, MPI_INT, ppBytes, 1, MPI_INT); + MPI_Allgather (&local_data_size, 1, MPI_INT, ppBytes, 1, MPI_INT, intracomm_); //could it be that dsize is more then unsigned int? dsize = 0; for(int i=0; i < nProcesses; ++i){ @@ -785,15 +799,16 @@ namespace MUSIC { unsigned int dsize; char *recv_buff; std::vector<char> commData; - recv_buff=NULL; + recv_buff = NULL; - dsize = calcCommDataSize(size); + dsize = calcCommDataSize (size); if(dsize > 0){ //distributing the data recv_buff = new char[dsize]; - intracomm_.Allgatherv(cur_buff, size, MPI::BYTE, recv_buff, ppBytes, displ, MPI::BYTE ); - std::copy(recv_buff,recv_buff+dsize,std::back_inserter(commData)); + MPI_Allgatherv (cur_buff, size, MPI_BYTE, recv_buff, ppBytes, displ, MPI_BYTE, + intracomm_); + std::copy (recv_buff, recv_buff + dsize, std::back_inserter (commData)); delete[] recv_buff; } return commData; diff --git a/src/temporal.cc b/src/temporal.cc index 4fd13df..db2c67f 100644 --- a/src/temporal.cc +++ b/src/temporal.cc @@ -42,11 +42,11 @@ namespace MUSIC freeNegotiationData (negotiationBuffer); // Free negotiation communicator in application leaders - if (negotiationComm != MPI::COMM_NULL) - negotiationComm.Free (); + if (negotiationComm != MPI_COMM_NULL) + MPI_Comm_free (&negotiationComm); - applicationLeaders.Free (); - groupWorld.Free (); + MPI_Group_free (&applicationLeaders); + MPI_Group_free (&groupWorld); } @@ -95,10 +95,10 @@ namespace MUSIC for (int i = 0; i < nApplications_; ++i) ranks[i] = (*applicationMap)[i].leader (); - groupWorld = MPI::COMM_WORLD.Get_group (); - applicationLeaders = groupWorld.Incl (nApplications_, ranks); + MPI_Comm_group (MPI_COMM_WORLD, &groupWorld); + MPI_Group_incl (groupWorld, nApplications_, ranks, &applicationLeaders); delete[] ranks; - negotiationComm = MPI::COMM_WORLD.Create (applicationLeaders); + MPI_Comm_create (MPI_COMM_WORLD, applicationLeaders, &negotiationComm); } @@ -261,8 +261,8 @@ namespace MUSIC { // First talk to others about how many connections each node has int* nConnections = new int[nApplications_]; - negotiationComm.Allgather (&nLocalConnections, 1, MPI::INT, nConnections, 1, - MPI::INT); + MPI_Allgather (&nLocalConnections, 1, MPI_INT, nConnections, 1, + MPI_INT, negotiationComm); for (int i = 0; i < nApplications_; ++i) nAllConnections += nConnections[i]; negotiationBuffer = allocNegotiationData (nApplications_, nAllConnections); @@ -279,8 +279,9 @@ namespace MUSIC } delete[] nConnections; int sendSize = negotiationDataSize (nLocalConnections); - negotiationComm.Allgatherv (negotiationData, sendSize, MPI::BYTE, - negotiationBuffer, receiveSizes, displacements, MPI::BYTE); + MPI_Allgatherv (negotiationData, sendSize, MPI_BYTE, + negotiationBuffer, receiveSizes, displacements, MPI_BYTE, + negotiationComm); delete[] displacements; delete[] receiveSizes; freeNegotiationData (negotiationData); @@ -394,12 +395,11 @@ namespace MUSIC if (hasPeers ()) { - comm.Bcast (&nAllConnections, 1, MPI::INT, 0); + MPI_Bcast (&nAllConnections, 1, MPI_INT, 0, comm); char* memory = static_cast<char*> (static_cast<void*> (negotiationBuffer)); - comm.Bcast (memory, - negotiationDataSize (nApplications_, nAllConnections), MPI::BYTE, - 0); + MPI_Bcast (memory, negotiationDataSize (nApplications_, nAllConnections), MPI_BYTE, + 0, comm); } } @@ -407,12 +407,13 @@ namespace MUSIC void TemporalNegotiator::receiveNegotiationData () { - MPI::Intracomm comm = setup_->communicator (); - comm.Bcast (&nAllConnections, 1, MPI::INT, 0); + MPI_Comm comm = setup_->communicator (); + MPI_Bcast (&nAllConnections, 1, MPI_INT, 0, comm); negotiationBuffer = allocNegotiationData (nApplications_, nAllConnections); char* memory = static_cast<char*> (static_cast<void*> (negotiationBuffer)); - comm.Bcast (memory, negotiationDataSize (nApplications_, nAllConnections), - MPI::BYTE, 0); + MPI_Bcast (memory, negotiationDataSize (nApplications_, nAllConnections), + MPI_BYTE, 0, + comm); fillTemporalNegotiatorGraph (); } diff --git a/testsuite/sanitytests/constsource.cc b/testsuite/sanitytests/constsource.cc index e190565..0d86847 100644 --- a/testsuite/sanitytests/constsource.cc +++ b/testsuite/sanitytests/constsource.cc @@ -111,7 +111,7 @@ main (int argc, char *argv[]) { if (rank == 0) std::cerr << "constsource port is not connected" << std::endl; - comm.Abort (1); + MPI_Abort (comm, 1); } int totalWidth = out->width (); diff --git a/utils/eventlogger.cc b/utils/eventlogger.cc index 078621f..33ceed5 100644 --- a/utils/eventlogger.cc +++ b/utils/eventlogger.cc @@ -260,7 +260,7 @@ main (int argc, char* argv[]) setup->config ("stoptime", &stoptime); if (useBarrier) - MPI::COMM_WORLD.Barrier(); + MPI_Barrier (MPI_COMM_WORLD); // Run MUSIC::Runtime* runtime = new MUSIC::Runtime (setup, timestep); diff --git a/utils/eventsink.cc b/utils/eventsink.cc index 69a6ef4..04aa5c0 100644 --- a/utils/eventsink.cc +++ b/utils/eventsink.cc @@ -224,7 +224,7 @@ main (int argc, char *argv[]) setup->config ("stoptime", &stoptime); if (useBarrier) - MPI::COMM_WORLD.Barrier(); + MPI_Barrier (MPI_COMM_WORLD); MUSIC::Runtime* runtime = new MUSIC::Runtime (setup, timestep); -- GitLab