Nature Language: multipleMultiPingping:All processes with crossCommRank of pingNodeA and pingNodeB in crossComm send a message to each other.Multiple threads take part in the communication.
  
CPP: int multipleMultiPingping(int totalReps, int dataSize){ \n    int repIter, i; \n    int destRank; \n    int lBound; \n    if (crossCommRank == pingNodeA){ \n        destRank = pingNodeB; \n    } else if (crossCommRank == pingNodeB){ \n        destRank = pingNodeA; \n    } \n    #pragma omp parallel default(none)                \\\n    private(i,repIter,lBound,requestID,status)            \\\n    shared(dataSize,sizeofBuffer,pingSendBuf,globalIDarray)    \\\n    shared(pingRecvBuf,finalRecvBuf,destRank,crossComm)        \\\n    shared(crossCommRank,pingNodeA,pingNodeB,totalReps) \n    { \n        for (repIter = 1; repIter <= totalReps; repIter++){ \n            if (crossCommRank == pingNodeA || crossCommRank == pingNodeB){ \n                lBound = (myThreadID * dataSize); \n                #pragma omp for nowait schedule(static,dataSize) \n                for (i=0; i<sizeofBuffer; i++){ \n                    pingSendBuf[i] = globalIDarray[myThreadID]; \n                } \n                MPI_Isend(&pingSendBuf[lBound], dataSize, MPI_INT, \\\n                destRank, myThreadID, crossComm, &requestID); \n                MPI_Recv(&pingRecvBuf[lBound], dataSize, MPI_INT, destRank, \\\n                myThreadID, crossComm, &status); \n                MPI_Wait(&requestID, &status); \n                #pragma omp for nowait schedule(static,dataSize) \n                for (i=0; i<sizeofBuffer; i++){ \n                    finalRecvBuf[i] = pingRecvBuf[i]; \n                } \n            } \n        } /* End repetitions loop */ \n    } \n    return 0; \n}",
  
Fortran: SUBROUTINE multipleMultiPingping(totalReps, dataSize)\n integer, intent(in) :: totalReps, dataSize\n integer :: repIter, i\n integer :: destRank\n integer :: lBound, uBound\n\n !set destRank to be ID of other process\n IF (crossCommRank == pingNodeA) THEN\n destRank = pingNodeB\n ELSE IF (crossCommRank == pingNodeB) THEN\n destRank = pingNodeA\n END IF\n\n !Open parallel region\n!$OMP PARALLEL DEFAULT(NONE), &\n!$OMP PRIVATE(i,repIter,lBound,uBound,requestID,status,ierr), &\n!$OMP SHARED(dataSize,sizeofBuffer,pingSendBuf,globalIDarray), &\n!$OMP SHARED(pingRecvBuf,finalRecvBuf,destRank,crossComm), &\n!$OMP SHARED(crossCommRank,pingNodeA,pingNodeB,totalReps)\n\n DO repIter = 1, totalReps !loop totalRep times\n\n IF (crossCommRank == pingNodeA .or. &\n crossCommRank == pingNodeB) THEN\n \n !Calculate lower and upper bound of each threads\n !portion of the data arrays\n lBound = ((myThreadID-1) * dataSize) + 1\n uBound = (myThreadID * dataSize)\n\n !Each thread writes to its part of pingSendBuf\n!$OMP DO SCHEDULE(STATIC,dataSize)\n DO i = 1, sizeofBuffer\n pingSendBuf(i) = globalIDarray(myThreadID)\n END DO\n!$OMP END DO NOWAIT\n\n !Each thread starts send of dataSize items from\n !pingSendBuf.\n CALL MPI_Isend(pingSendBuf(lBound:uBound), dataSize, &\n MPI_INTEGER, destRank, myThreadID, crossComm, &\n requestID, ierr)\n\n !Thread then waits for message from destRank\n !with tag equal to its threadID.\n CALL MPI_Recv(pingRecvBuf(lBound:uBound), dataSize, &\n MPI_INTEGER, destRank, myThreadID, crossComm, &\n status, ierr)\n\n !Thread completes send using MPI_Wait\n CALL MPI_Wait(requestID, status, ierr)\n\n !Each thread reads its part of received buffer.\n!$OMP DO SCHEDULE(STATIC,dataSize)\n DO i = 1, sizeofBuffer\n finalRecvBuf(i) = pingRecvBuf(i)\n END DO\n!$OMP END DO NOWAIT\n\n END IF\n\n END DO !End reps\n!$OMP END PARALLEL\n\n END SUBROUTINE multipleMultiPingping
  