Nature Language: scatterGather:Driver routine for the scatter benchmark.
  
CPP: int scatterGather(int benchmarkType){\n    int dataSizeIter, bufferSize;\n    repsToDo = defaultReps;\n    dataSizeIter = minDataSize; /* initialise dataSizeIter */\n    \n    while (dataSizeIter <= maxDataSize){\n        bufferSize = dataSizeIter * numThreads;\n\n        if (benchmarkType == SCATTER){\n            allocateScatterGatherData(bufferSize, benchmarkType);\n            scatterKernel(warmUpIters, dataSizeIter);\n            testScatterGather(bufferSize, benchmarkType);\n        } else if (benchmarkType == GATHER){\n            allocateScatterGatherData(bufferSize, benchmarkType);\n            gatherKernel(warmUpIters, dataSizeIter);\n\n            if (myMPIRank == GATHERROOT){\n                testScatterGather(bufferSize*numMPIprocs, benchmarkType);\n            }\n        }\n\n        benchComplete = FALSE;\n\n        while (benchComplete != TRUE){\n            MPI_Barrier(comm);\n            startTime = MPI_Wtime();\n\n            if (benchmarkType == SCATTER){\n                scatterKernel(repsToDo, dataSizeIter);\n            } else if (benchmarkType == GATHER){\n                gatherKernel(repsToDo, dataSizeIter);\n            }\n\n            MPI_Barrier(comm);\n            finishTime = MPI_Wtime();\n            totalTime = finishTime - startTime;\n\n            if (myMPIRank==0) {\n                benchComplete = repTimeCheck(totalTime, repsToDo);\n            }\n\n            MPI_Bcast(&benchComplete, 1, MPI_INT, 0, comm);\n            MPI_Bcast(&repsToDo, 1, MPI_INT, 0, comm);\n        }\n\n        if (myMPIRank == 0){\n            setReportParams(dataSizeIter, repsToDo, totalTime);\n            printReport();\n        }\n\n        freeScatterGatherData(benchmarkType);\n        dataSizeIter = dataSizeIter * 2;\n    }\n\n    return 0;\n}",
  
Fortran: SUBROUTINE scatterGather(benchmarkType)\ninteger, intent(in) :: benchmarkType\ninteger :: dataSizeIter\ninteger :: bufferSize\n\n!Initialise repsToDo to defaultReps\nrepsToDo = defaultReps\n\n!Start loop over data sizes\ndataSizeIter = minDataSize !initialise dataSizeIter\nDO WHILE (dataSizeIter <= maxDataSize)\n!Calculate buffer size and allocate space for \n!scatter data arrays.\nbufferSize = dataSizeIter * numThreads\n\n\nIF (benchmarkType == SCATTER) THEN !Scatter\nCALL allocateData(bufferSize,benchmarkType)\n!Perform benchmark warm-up\nCALL scatterKernel(warmUpIters, dataSizeIter)\n!Test if scatter was successful\nCALL testScatterGather(bufferSize, benchmarkType)\n\nELSE IF (benchmarkType == GATHER) THEN !Gather\nCALL allocateData(bufferSize,benchmarkType)\n!Perform benchmark warm-up\nCALL gatherKernel(warmUpIters, dataSizeIter)\n!Test if gather was successful\nIF (myMPIRank == GATHERROOT) THEN\nCALL testScatterGather(bufferSize*numMPIprocs, benchmarkType)\nEND IF\nEND IF\n\n!Initialise the benchmark\nbenchComplete = .false.\n!Execute benchmark until target time is reached\nDO WHILE (benchComplete .NEQV. .true.)\n!Start timer\nCALL MPI_Barrier(comm, ierr)\nstartTime = MPI_Wtime()\n\nIF (benchmarkType == SCATTER) THEN !Scatter\n!Execute scatter for repsToDo repetitions\nCALL scatterKernel(repsToDo, dataSizeIter)\n\nELSE IF (benchmarkType == GATHER) THEN !Gather\n!Execute gather for repsToDo repetitions\nCALL gatherKernel(repsToDo, dataSizeIter)\nEND IF\n\n!Stop timer\nCALL MPI_Barrier(comm, ierr)\nfinishTime = MPI_Wtime()\ntotalTime = finishTime - startTime\n\n!Test if target time was reached\nif (myMPIRank==0) then \nbenchComplete = repTimeCheck(totalTime, repsToDo)\nend if\n!Ensure all procs have the same value of benchComplete\n!and repsToDo\ncall MPI_Bcast(benchComplete, 1, MPI_INTEGER, 0, comm, ierr)\ncall MPI_Bcast(repsToDo, 1, MPI_INTEGER, 0, comm, ierr)\n\nEND DO\n\n!Master process sets benchmark result for reporting\nIF (myMPIRank == 0) THEN\nCALL setReportParams(dataSizeIter,repsToDo,totalTime)\nCALL printReport()\nEND IF\n\n!Free allocated data\nCALL freeData(benchmarkType)\n\n!Double data size and loop again\ndataSizeIter = dataSizeIter * 2\n\nEND DO !End loop over data sizes\n\nEND SUBROUTINE scatterGather
  