@@ -633,6 +633,13 @@ int YogiManager::rootToMPI(int root) {
633633 return root;
634634}
635635
636+ template <typename T>
637+ int YogiManager::findInPool (std::vector<T> &pool, T item, int counter) {
638+ typename std::vector<T>::iterator it = pool.begin ();
639+ it = std::find (pool.begin (), pool.begin () + counter, item);
640+ return it - pool.begin ();
641+ }
642+
636643template <typename T, typename V>
637644int YogiManager::insertIntoPool (std::vector<T> &pool, T newItem, V marker_in,
638645 int offset, int &counter) {
@@ -670,42 +677,6 @@ int YogiManager::insertIntoPool(std::vector<T> &pool, T newItem, V marker_in,
670677 return delta;
671678}
672679
673- template <typename T, typename V>
674- int YogiManager::insertIntoPoolIfNotFound (std::vector<T> &pool, T newItem, V marker_in, int &counter) {
675-
676- /* Cast the marker to the type in the pool */
677- T marker = std::move (static_cast <T>(marker_in));
678-
679- /* First see if this already exists as a constant. If it does, just
680- return the equivalent Yogi constant value.
681- */
682- typename std::vector<T>::iterator it = pool.begin ();
683- it = std::find (pool.begin (), pool.begin () + counter, newItem);
684- if (it != pool.begin () + counter) {
685- return it - pool.begin ();
686- }
687- int delta;
688-
689- /* Then see if the current counter exceeds the size of the vector.
690- If it does, double it. */
691- if (counter >= pool.capacity () - 1 ) {
692- pool.resize (pool.capacity () * 2 , marker);
693- }
694- // After the counter, find first instance of marker, replace with newItem.
695- it = pool.begin ();
696- std::advance (it, counter);
697- if (std::find (it, pool.end (), marker) != pool.end ()) {
698- delta = std::distance (pool.begin (), std::find (it, pool.end (), marker));
699- pool.at (delta) = newItem;
700- }
701- else {
702- return -1 ;
703- }
704- // Bump up the counter and return the index.
705- counter++;
706- return delta;
707- }
708-
709680template <typename T, typename V>
710681void YogiManager::removeFromPool (std::vector<T> &pool, int index, V marker_in,
711682 int offset, int &counter) {
@@ -877,7 +848,7 @@ YogiMPI_Message YogiManager::messageToYogi(MPI_Message in_message) {
877848#endif
878849
879850YogiMPI_Datatype YogiManager::datatypeToYogi (MPI_Datatype in_data) {
880- return insertIntoPoolIfNotFound (datatypePool, in_data, MPI_DATATYPE_NULL, numDatatypes);
851+ return insertIntoPool (datatypePool, in_data, MPI_DATATYPE_NULL, datatypeOffset , numDatatypes);
881852}
882853
883854YogiMPI_Errhandler YogiManager::errhandlerToYogi (MPI_Errhandler in_errhandler) {
@@ -996,6 +967,10 @@ void YogiManager::statusToYogi(MPI_Status * &in_mpi, YogiMPI_Status *& out_yogi,
996967 if (free_mpi) freeStatus (in_mpi);
997968}
998969
970+ YogiMPI_Datatype YogiManager::datatypeToYogiFindOnly (MPI_Datatype in_data) {
971+ return findInPool (datatypePool, in_data, numDatatypes);
972+ }
973+
999974// Removing Yogi handles
1000975
1001976YogiMPI_Comm YogiManager::unmapComm (YogiMPI_Comm to_free) {
0 commit comments