Nature Language: pingPong:Driver subroutine for the pingpong benchmark.
  
CPP: int pingPong(int benchmarkType){\n\tint dataSizeIter;\n\tint sameNode;\n\tpingRank = PPRanks[0];\n\tpongRank = PPRanks[1];\n\t/* Check if pingRank and pongRank are on the same node */\n\tsameNode = compareProcNames(pingRank,pongRank);\n\t/* Master process then does some reporting */\n\tif (myMPIRank == 0){\n\t\t/* print message saying if benchmark is inter or intra node */\n\t\tprintNodeReport(sameNode,pingRank,pongRank);\n\t\t/* then print report column headings. */\n\t\tprintBenchHeader();\n\t}\n\t/* initialise repsToDo to defaultReps at start of benchmark */\n\trepsToDo = defaultReps;\n\t/* Loop over data sizes */\n\tdataSizeIter = minDataSize; /* initialise dataSizeIter to minDataSize */\n\twhile (dataSizeIter <= maxDataSize){\n\t\t/* set sizeofBuffer */\n\t\tsizeofBuffer = dataSizeIter * numThreads;\n\t\t/* allocate space for the main data arrays */\n\t\tallocatePingpongData(sizeofBuffer);\n\t\t/* warm-up for either masteronly, funnelled or multiple */\n\t\tif (benchmarkType == MASTERONLY){\n\t\t\t/* perform masteronly warm-up sweep */\n\t\t\tmasteronlyPingpong(warmUpIters, dataSizeIter);\n\t\t}\n\t\telse if (benchmarkType == FUNNELLED){\n\t\t\t/* perform funnelled warm-up sweep */\n\t\t\tfunnelledPingpong(warmUpIters, dataSizeIter);\n\t\t}\n\t\telse if (benchmarkType == MULTIPLE){\n\t\t\tmultiplePingpong(warmUpIters, dataSizeIter);\n\t\t}\n\t\t/* perform verification test for the pingpong */\n\t\ttestPingpong(sizeofBuffer, dataSizeIter);\n\t\t/* Initialise benchmark */\n\t\tbenchComplete = FALSE;\n\t\t/* keep executing benchmark until target time is reached */\n\t\twhile (benchComplete != TRUE){\n\t\t\t/* Start the timer...MPI_Barrier to synchronise */\n\t\t\tMPI_Barrier(comm);\n\t\t\tstartTime = MPI_Wtime();\n\t\t\tif (benchmarkType == MASTERONLY){\n\t\t\t\t/* execute for repsToDo repetitions */\n\t\t\t\tmasteronlyPingpong(repsToDo, dataSizeIter);\n\t\t\t}\n\t\t\telse if (benchmarkType == FUNNELLED){\n\t\t\t\tfunnelledPingpong(repsToDo, dataSizeIter);\n\t\t\t}\n\t\t\telse if (benchmarkType == MULTIPLE){\n\t\t\t\tmultiplePingpong(repsToDo, dataSizeIter);\n\t\t\t}\n\t\t\t/* Stop the timer...MPI_Barrier to synchronise processes */\n\t\t\tMPI_Barrier(comm);\n\t\t\tfinishTime = MPI_Wtime();\n\t\t\ttotalTime = finishTime - startTime;\n\t\t\t/* Call repTimeCheck function to test if target time is reached */\n\t\t\tif (myMPIRank==0){\n\t\t\t  benchComplete = repTimeCheck(totalTime, repsToDo);\n\t\t\t}\n\t\t\t/* Ensure all procs have the same value of benchComplete */\n\t\t\t/* and repsToDo */\n\t\t\tMPI_Bcast(&benchComplete, 1, MPI_INT, 0, comm);\n\t\t\tMPI_Bcast(&repsToDo, 1, MPI_INT, 0, comm);\n\t\t}\n\t\t/* Master process sets benchmark results */\n\t\tif (myMPIRank == 0){\n\t\t\tsetReportParams(dataSizeIter, repsToDo, totalTime);\n\t\t\tprintReport();\n\t\t}\n\t\t/* Free the allocated space for the main data arrays */\n\t\tfreePingpongData();\n\t\t/* Update dataSize before the next iteration */\n\t\tdataSizeIter = dataSizeIter * 2; /* double data size */\n\t}\n\treturn 0;\n}
  
Fortran: SUBROUTINE pingPong(benchmarkType)\n integer, intent(in) :: benchmarkType\n integer :: dataSizeIter\n logical :: sameNode\n\n pingRank = PPRanks(1) \n pongRank = PPRanks(2)\n \n !Check if pingRank and pongRank are on the same node\n sameNode = compareProcNames(pingRank,pongRank)\n \n !Master process then does reporting...\n IF (myMPIRank == 0) THEN\n !print message saying if benchmark is inter or intra node\n CALL printNodeReport(sameNode,pingRank,pongRank)\n !..then print report column headings.\n CALL printBenchHeader()\n END IF\n\n !initialise repsToDo to defaultReps at start of benchmark\n repsToDo = defaultReps\n\n !Loop over data sizes\n dataSizeIter = minDataSize !initialise dataSizeIter to minDataSize\n DO WHILE (dataSizeIter <= maxDataSize)\n \n !set sizeofBuffer \n sizeofBuffer = dataSizeIter*numThreads\n\n !Allocate space for the main data arrays\n CALL allocateData(sizeofBuffer)\n\n !warm-up for either masteronly, funnelled or multiple\n IF (benchmarkType == MASTERONLY) THEN\n !Perform masteronly warm-up sweep\n CALL masteronlyPingpong(warmUpIters, dataSizeIter)\n ELSE IF (benchmarkType == FUNNELLED) THEN\n !Perform funnelled warm-up sweep\n CALL funnelledPingpong(warmUpIters, dataSizeIter)\n ELSE IF (benchmarkType == MULTIPLE) THEN\n !Perform multiple pingpong warmup\n CALL multiplePingpong(warmUpIters, dataSizeIter)\n END IF\n\n !Perform verification test for the pingpong\n CALL testPingpong(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 for repsToDo repetitions\n CALL masteronlyPingpong(repsToDo, dataSizeIter)\n ELSE IF (benchmarkType == FUNNELLED) THEN\n CALL funnelledPingpong(repsToDo, dataSizeIter)\n ELSE IF (benchmarkType == MULTIPLE) THEN\n CALL multiplePingpong(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 \nEND SUBROUTINE pingPong
  