@@ -545,8 +545,9 @@ CellElementReturn WriteElements(const CGNS &cgns, apf::Mesh *m, apf::GlobalNumbe
545
545
cgp_error_exit ();
546
546
547
547
std::vector<int > allNumbersForThisType (m->getPCU ()->Peers (), 0 );
548
- MPI_Allgather (&numbersByElementType[o], 1 , MPI_INT, allNumbersForThisType.data (), 1 ,
549
- MPI_INT, m->getPCU ()->GetMPIComm ());
548
+ m->getPCU ()->Allgather (
549
+ &numbersByElementType[o], allNumbersForThisType.data (), 1
550
+ );
550
551
551
552
cgsize_t num = 0 ;
552
553
for (int i = 0 ; i < m->getPCU ()->Self (); i++)
@@ -656,8 +657,7 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
656
657
}
657
658
658
659
std::vector<int > allNumbersForThisType (m->getPCU ()->Peers (), 0 );
659
- MPI_Allgather (&number, 1 , MPI_INT, allNumbersForThisType.data (), 1 ,
660
- MPI_INT, m->getPCU ()->GetMPIComm ());
660
+ m->getPCU ()->Allgather (&number, allNumbersForThisType.data (), 1 );
661
661
662
662
cgsize_t num = 0 ;
663
663
for (int i = 0 ; i < m->getPCU ()->Self (); i++)
@@ -684,19 +684,16 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
684
684
}
685
685
}
686
686
std::vector<int > cacheStarts (m->getPCU ()->Peers (), 0 );
687
- MPI_Allgather (&cacheStart, 1 , MPI_INT, cacheStarts.data (), 1 ,
688
- MPI_INT, m->getPCU ()->GetMPIComm ());
687
+ m->getPCU ()->Allgather (&cacheStart, cacheStarts.data (), 1 );
689
688
std::vector<int > cacheEnds (m->getPCU ()->Peers (), 0 );
690
- MPI_Allgather (&cacheEnd, 1 , MPI_INT, cacheEnds.data (), 1 ,
691
- MPI_INT, m->getPCU ()->GetMPIComm ());
689
+ m->getPCU ()->Allgather (&cacheEnd, cacheEnds.data (), 1 );
692
690
return std::make_pair (cacheStarts, cacheEnds);
693
691
};
694
692
695
693
const auto globalElementList = [&m](const std::vector<cgsize_t > &bcList, std::vector<cgsize_t > &allElements) {
696
694
std::vector<int > sizes (m->getPCU ()->Peers (), 0 ); // important initialiser
697
695
const int l = bcList.size ();
698
- MPI_Allgather (&l, 1 , MPI_INT, sizes.data (), 1 ,
699
- MPI_INT, m->getPCU ()->GetMPIComm ());
696
+ m->getPCU ()->Allgather (&l, sizes.data (), 1 );
700
697
701
698
int totalLength = 0 ;
702
699
for (const auto &i : sizes)
@@ -708,9 +705,15 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
708
705
displacement[i] = displacement[i - 1 ] + sizes[i - 1 ];
709
706
710
707
allElements.resize (totalLength);
708
+ #ifndef SCOREC_NO_MPI
709
+ PCU_Comm comm;
710
+ m->getPCU ()->DupComm (&comm);
711
711
MPI_Allgatherv (bcList.data (), bcList.size (), MPI_INT, allElements.data (),
712
- sizes.data (), displacement.data (), MPI_INT,
713
- m->getPCU ()->GetMPIComm ());
712
+ sizes.data (), displacement.data (), MPI_INT, comm);
713
+ MPI_Comm_free (&comm);
714
+ #else
715
+ std::copy (bcList.begin (), bcList.end (), allElements.begin ());
716
+ #endif
714
717
};
715
718
716
719
const auto doVertexBC = [&](const auto &iter) {
@@ -1046,7 +1049,8 @@ void WriteCGNS(const char *prefix, apf::Mesh *m, const apf::CGNSBCMap &cgnsBCMap
1046
1049
sizes[2 ] = 0 ; // nodes are unsorted, as defined by api
1047
1050
1048
1051
// Copy communicator
1049
- auto communicator = m->getPCU ()->GetMPIComm ();
1052
+ PCU_Comm communicator;
1053
+ m->getPCU ()->DupComm (&communicator);
1050
1054
cgp_mpi_comm (communicator);
1051
1055
//
1052
1056
cgp_pio_mode (CGP_INDEPENDENT);
@@ -1134,6 +1138,9 @@ void WriteCGNS(const char *prefix, apf::Mesh *m, const apf::CGNSBCMap &cgnsBCMap
1134
1138
destroyGlobalNumbering (gcn);
1135
1139
//
1136
1140
cgp_close (cgns.index );
1141
+ #ifndef SCOREC_NO_MPI
1142
+ MPI_Comm_free (&communicator);
1143
+ #endif
1137
1144
}
1138
1145
} // namespace
1139
1146
0 commit comments