Nature Language: multiPingPing:Driver subroutine for the multi-pingping benchmark.
  
CPP: int multiPingping(int benchmarkType){\n\\n    int dataSizeIter;\n\\n    char otherProcName[MPI_MAX_PROCESSOR_NAME];\n\\n    int balance;\n\\n    pingNodeA = 0;\n\\n    pingNodeB = 1;\n\\n    balance = crossCommBalance(pingNodeA, pingNodeB);\n\n\\n    if (balance == FALSE){\n\\n        if (myMPIRank == 0){\n\\n            printBalanceError();\n\\n        }\n\\n        return 1;\n\\n    }\n\n\\n    exchangeWorldRanks(pingNodeA, pingNodeB, &otherPingRank);\n\\n    sendProcName(pingNodeA, pingNodeB, otherProcName);\n\\n    printMultiProcInfo(pingNodeA, otherPingRank, otherProcName);\n\\n    MPI_Barrier(comm);\n\n\\n    if (myMPIRank == 0){\n\\n        printBenchHeader();\n\\n    }\n\n\\n    repsToDo = defaultReps;\n\\n    dataSizeIter = minDataSize;\n\n\\n    while (dataSizeIter <= maxDataSize){\n\\n        sizeofBuffer = dataSizeIter * numThreads;\n\\n        allocateMultiPingpingData(sizeofBuffer);\n\n\\n        if (benchmarkType == MASTERONLY){\n\\n            masteronlyMultiPingping(warmUpIters, dataSizeIter);\n\\n        } else if (benchmarkType == FUNNELLED){\n\\n            funnelledMultiPingping(warmUpIters, dataSizeIter);\n\\n        } else if (benchmarkType == MULTIPLE){\n\\n            multipleMultiPingping(warmUpIters, dataSizeIter);\n\\n        }\n\n\\n        testMultiPingping(sizeofBuffer, dataSizeIter);\n\\n        benchComplete = FALSE;\n\n\\n        while (benchComplete != TRUE){\n\\n            MPI_Barrier(comm);\n\\n            startTime = MPI_Wtime();\n\n\\n            if (benchmarkType == MASTERONLY){\n\\n                masteronlyMultiPingping(repsToDo, dataSizeIter);\n\\n            } else if (benchmarkType == FUNNELLED){\n\\n                funnelledMultiPingping(repsToDo, dataSizeIter);\n\\n            } else if (benchmarkType == MULTIPLE){\n\\n                multipleMultiPingping(repsToDo, dataSizeIter);\n\\n            }\n\n\\n            MPI_Barrier(comm);\n\\n            finishTime = MPI_Wtime();\n\\n            totalTime = finishTime - startTime;\n\n\\n            if (myMPIRank==0){\n\\n                benchComplete = repTimeCheck(totalTime, repsToDo);\n\\n            }\n\n\\n           ",
  
Fortran: SUBROUTINE multiPingPing(benchmarkType)\n integer, intent(in) :: benchmarkType\n integer :: dataSizeIter\n character (len = MPI_MAX_PROCESSOR_NAME) :: otherProcName\n logical :: balance\n\n pingNodeA = 0\n pingNodeB = 1\n\n !Check if there's a balance in num of MPI processes \n !in pingNodeA and pingNodeB.\n balance = crossCommBalance(pingNodeA, pingNodeB)\n !If not balanced..\n IF (balance .EQV. .false.) THEN\n !..Master prints error\n IF (myMPIRank == 0) THEN\n CALL printBalanceError()\n END IF\n !..and all processes return from subroutine.\n RETURN\n END IF\n\n !Exchange MPI_COMM_WORLD ranks for processes in same crossComm\n CALL exchangeWorldRanks(pingNodeA, pingNodeB, otherPingRank)\n\n !Processes on pingNodeB send processor name to pingNodeA procs\n CALL sendProcName(pingNodeA, pingNodeB, otherProcName)\n\n !Print comm world ranks & processor names of \n !processes taking part in multi-pingping benchmark.\n CALL printMultiProcInfo(pingNodeA, otherPingRank, otherProcName)\n\n !Barrier to ensure that all procs have completed\n !printMultiProcInfo before printing column headings\n CALL MPI_Barrier(comm, ierr)\n !Master process then prints report column headings\n IF(myMPIRank == 0) THEN\n CALL printBenchHeader()\n END IF\n\n !initialise repsToDo to defaultReps at start of benchmark\n repsToDo = defaultReps\n\n !Start loop over data sizes\n dataSizeIter = minDataSize !initialise dataSizeIter\n DO WHILE (dataSizeIter <= maxDataSize)\n\n !set size of buffer\n sizeofBuffer = dataSizeIter * numThreads\n\n !Allocate space for the main data arrays\n CALL allocateData(sizeofBuffer)\n\n !Warm-up for benchmarkType\n IF (benchmarkType == MASTERONLY) THEN\n !Masteronly warm-up sweep\n CALL masteronlyMultiPingping(warmUpIters, dataSizeIter)\n ELSE IF (benchmarkType == FUNNELLED) THEN\n !Funnelled warm-up sweep\n CALL funnelledMultiPingping(warmUpIters, dataSizeIter)\n ELSE IF (benchmarkType == MULTIPLE) THEN\n !Multiple warm-up\n CALL multipleMultiPingping(warmUpIters, dataSizeIter)\n END IF\n \n !Verification test for multi-pingping\n CALL testMultiPingping(sizeofBuffer, dataSizeIter)\n\n !Initialise benchmark\n benchComplete = .false.\n !Keep executing benchmark until target time is reached\n DO WHILE (benchComplete .NEQV. .true.)\n\n !Start the timer..MPI_Barrier to synchronise\n !processes for more accurate timing.\n CALL MPI_Barrier(comm, ierr)\n startTime = MPI_Wtime()\n\n IF (benchmarkType == MASTERONLY) THEN\n !Execute masteronly multipingping repsToDo times\n CALL masteronlyMultiPingping(repsToDo, dataSizeIter)\n ELSE IF (benchmarkType == FUNNELLED) THEN\n !Execute funnelled multipingping\n CALL funnelledMultiPingping(repsToDo, dataSizeIter)\n ELSE IF (benchmarkType == MULTIPLE) THEN\n !Execute multiple multipingping\n CALL multipleMultiPingping(repsToDo, dataSizeIter)\n END IF\n\n !Stop the timer..MPI_Barrier to synchronise processes\n !for more accurate timing.\n CALL MPI_Barrier(comm, ierr)\n finishTime = MPI_Wtime()\n totalTime = finishTime - startTime\n\n !Call repTimeCheck function to test if target time\n !is reached.\n if (myMPIRank==0) then \n benchComplete = repTimeCheck(totalTime, repsToDo)\n end if\n !Ensure all procs have the same value of benchComplete\n !and repsToDo\n call MPI_Bcast(benchComplete, 1, MPI_INTEGER, 0, comm, ierr)\n call MPI_Bcast(repsToDo, 1, MPI_INTEGER, 0, comm, ierr)\n\n END DO !end of loop to check if benchComplete is true\n\n !Master process sets benchmark results\n IF (myMPIRank == 0) THEN\n CALL setReportParams(dataSizeIter, repsToDo, totalTime)\n CALL printReport()\n END IF\n\n !Free the allocated space for the main data arrays\n CALL freeData()\n\n !Update dataSize before next iteration\n dataSizeIter = dataSizeIter * 2 !double data size\n\n END DO !end of loop over data sizes.\n\n END SUBROUTINE multiPingPing
  