Nature Language: masteronlyPingpong:One MPI process sends single fixed length message to another MPI process. This other process then sends it back to the first process.
  
CPP: int masteronlyPingpong(int totalReps, int dataSize){\n\tint repIter, i;\n\tfor (repIter = 0; repIter < totalReps; repIter++){\n\t\t/* All threads under MPI process with rank = pingRank\n\t\t * write to their part of the pingBuf array using a\n\t\t * parallel for directive.\n\t\t */\n\t\tif (myMPIRank == pingRank){\n#pragma omp parallel for default(none) \\\n\tprivate(i) \\\n\tshared(pingSendBuf,dataSize,sizeofBuffer,globalIDarray) \\\n\tschedule(static,dataSize)\n\t\t\tfor(i=0; i<sizeofBuffer; i++){\n\t\t\t\tpingSendBuf[i] = globalIDarray[myThreadID];\n\t\t\t}\n\t\t\t/* Ping process sends buffer to MPI process with rank equal to\n\t\t\t * pongRank.\n\t\t\t */\n\t\t\tMPI_Send(pingSendBuf, sizeofBuffer, MPI_INT, pongRank, TAG, comm);\n\t\t\t/* Process then waits for a message from pong process and\n\t\t\t * each thread reads its part of received buffer.\n\t\t\t */\n\t\t\tMPI_Recv(pongRecvBuf, sizeofBuffer, MPI_INT, pongRank, \\\n\t\t\t\t\tTAG, comm, &status);\n#pragma omp parallel for default(none) \\\n\tprivate(i) \\\n\tshared(pongRecvBuf,finalRecvBuf,dataSize,sizeofBuffer) \\\n\tschedule(static,dataSize)\n\t\t\tfor(i=0; i<sizeofBuffer; i++){\n\t\t\t\tfinalRecvBuf[i] = pongRecvBuf[i];\n\t\t\t}\n\t\t}\n\t\telse if (myMPIRank == pongRank){\n\t\t\t/* pongRank receives the message from the ping process */\n\t\t\tMPI_Recv(pingRecvBuf, sizeofBuffer, MPI_INT, pingRank, \\\n\t\t\t\t\tTAG, comm, &status);\n\t\t\t/* each thread under the pongRank MPI process now copies\n\t\t\t * its part of the received buffer to pongSendBuf.\n\t\t\t */\n#pragma omp parallel for default(none) \\\n\tprivate(i) \\\n    shared(pongSendBuf,pingRecvBuf,dataSize,sizeofBuffer) \\\n\tschedule(static,dataSize)\n\t\t\tfor(i=0; i< sizeofBuffer; i++){\n\t\t\t\tpongSendBuf[i] = pingRecvBuf[i];\n\t\t\t}\n\t\t\t/* pongRank process now sends pongSendBuf to ping process. */\n\t\t\tMPI_Send(pongSendBuf, sizeofBuffer, MPI_INTEGER, pingRank, \\\n\t\t\t\t\tTAG, comm);\n\t\t}\n\t}\n\treturn 0;\n}
  
Fortran: SUBROUTINE masteronlyPingpong(totalReps, dataSize)\n integer, intent(in) :: totalReps, dataSize\n integer :: repIter, i\n DO repIter = 1, totalReps !loop totalRep times\n\n !All threads under MPI process with rank = pingRank\n !write to its part of the pingBuf array using a \n !PARALLEL DO directive.\n IF (myMPIRank == pingRank) THEN\n \n!$OMP PARALLEL DO DEFAULT(NONE), &\n!$OMP PRIVATE(i), &\n!$OMP SHARED(pingSendBuf,dataSize,sizeofBuffer,globalIDarray), &\n!$OMP SCHEDULE(STATIC,dataSize)\n\n DO i = 1,sizeofBuffer\n pingSendBuf(i) = globalIDarray(myThreadID)\n ENDDO\n!$OMP END PARALLEL DO\n \n !Ping process sends buffer to MPI process with rank equal\n !to pongRank.\n CALL MPI_Send(pingSendBuf, sizeofBuffer, MPI_INTEGER,&\n pongRank, tag, comm, ierr)\n \n !Process then waits for a message from pong process and\n !each thread reads its part of received buffer.\n !This completes the pingpong operation.\n CALL MPI_Recv(pongRecvBuf, sizeofBuffer, MPI_INTEGER,&\n pongRank, tag, comm, status, ierr)\n\n!$OMP PARALLEL DO DEFAULT(NONE), &\n!$OMP PRIVATE(i), &\n!$OMP SHARED(pongRecvBuf,finalRecvBuf,dataSize,sizeofBuffer), &\n!$OMP SCHEDULE(STATIC,dataSize)\n DO i = 1,sizeofBuffer\n finalRecvBuf(i) = pongRecvBuf(i)\n ENDDO\n!$OMP END PARALLEL DO\n \n ELSEIF (myMPIRank == pongRank) THEN\n \n !pongRank receives the message from the ping process\n CALL MPI_Recv(pingRecvBuf, sizeofBuffer, MPI_INTEGER, &\n pingRank, tag, comm, status, ierr)\n\n !Each thread under the pongRank MPI process now copies \n !its part of the received buffer to pongSendBuf\n\n!$OMP PARALLEL DO DEFAULT(NONE), &\n!$OMP PRIVATE(i), &\n!$OMP SHARED(pongSendBuf,pingRecvBuf,dataSize,sizeofBuffer), &\n!$OMP SCHEDULE(STATIC,dataSize)\n DO i = 1,sizeofBuffer\n pongSendBuf(i) = pingRecvBuf(i)\n END DO\n!$OMP END PARALLEL DO\n \n !pongRank process now sends pongSendBuf to ping process.\n CALL MPI_Send(pongSendBuf, sizeofBuffer, MPI_INTEGER, &\n pingRank, tag, comm, ierr)\n END IF\n\n END DO !End repetitions loop\n \nEND SUBROUTINE masteronlyPingpong
  