Nature Language: haloExchange:Driver subroutine for the haloExchange benchmark.
  
CPP: int haloExchange(int benchmarkType){ \n    int dataSizeIter; \n    findNeighbours(); \n    repsToDo = defaultReps; \n    dataSizeIter = minDataSize; /* Initialise dataSizeIter */ \n    \n    while (dataSizeIter <= maxDataSize){ \n        sizeofBuffer = dataSizeIter * numThreads; \n        allocateHaloexchangeData(sizeofBuffer); \n        \n        if (benchmarkType == MASTERONLY){ \n            masteronlyHaloexchange(warmUpIters, dataSizeIter); \n        } else if (benchmarkType == FUNNELLED){ \n            funnelledHaloexchange(warmUpIters, dataSizeIter); \n        } else if (benchmarkType == MULTIPLE){ \n            multipleHaloexchange(warmUpIters, dataSizeIter); \n        } \n        \n        testHaloexchange(sizeofBuffer, dataSizeIter); \n        benchComplete = FALSE; \n        \n        while (benchComplete != TRUE){ \n            MPI_Barrier(comm); \n            startTime = MPI_Wtime(); \n            \n            if (benchmarkType == MASTERONLY){ \n                masteronlyHaloexchange(repsToDo, dataSizeIter); \n            } else if (benchmarkType == FUNNELLED){ \n                funnelledHaloexchange(repsToDo, dataSizeIter); \n            } else if (benchmarkType == MULTIPLE){ \n                multipleHaloexchange(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        freeHaloexchangeData(); \n        dataSizeIter = dataSizeIter * 2; \n    } \n    \n    return 0; \n}",
  
Fortran: SUBROUTINE haloExchange(benchmarkType)\ninteger, intent(in) :: benchmarkType\ninteger :: dataSizeIter\n\nCALL findNeighbourRanks()\n\nrepsToDo = defaultReps\n\ndataSizeIter = minDataSize\nDO WHILE (dataSizeIter <= maxDataSize)\nsizeofBuffer = dataSizeIter * numThreads\n\nCALL allocateData(sizeofBuffer)\n\nIF (benchmarkType == MASTERONLY) THEN\nCALL masteronlyHaloexchange(warmUpIters, dataSizeIter)\nELSE IF (benchmarkType == FUNNELLED) THEN\nCALL funnelledHaloexchange(warmUpIters, dataSizeIter)\nELSE IF (benchmarkType == MULTIPLE) THEN\nCALL multipleHaloexchange(warmUpIters, dataSizeIter)\nEND IF\n\nCALL testHaloexchange(sizeofBuffer, dataSizeIter)\n\nbenchComplete = .false.\nDO WHILE (benchComplete .NEQV. .true.)\nCALL MPI_Barrier(comm, ierr)\nstartTime = MPI_Wtime()\n\nIF (benchmarkType == MASTERONLY) THEN\nCALL masteronlyHaloexchange(repsToDo, dataSizeIter)\nELSE IF (benchmarkType == FUNNELLED) THEN\nCALL funnelledHaloexchange(repsToDo, dataSizeIter)\nELSE IF (benchmarkType == MULTIPLE) THEN\nCALL multipleHaloexchange(repsToDo, dataSizeIter)\nEND IF\n\nCALL MPI_Barrier(comm, ierr)\nfinishTime = MPI_Wtime()\ntotalTime = finishTime - startTime\n\nIF (myMPIRank==0) THEN\nbenchComplete = repTimeCheck(totalTime, repsToDo)\nEND IF\nCALL MPI_Bcast(benchComplete, 1, MPI_INTEGER, 0, comm, ierr)\nCALL MPI_Bcast(repsToDo, 1, MPI_INTEGER, 0, comm, ierr)\n\nEND DO\n\nIF (myMPIRank == 0) THEN\nCALL setReportParams(dataSizeIter,repsToDo,totalTime)\nCALL printReport()\nEND IF\n\nCALL freeData()\n\ndataSizeIter = dataSizeIter * 2\n\nEND DO\n\nEND SUBROUTINE haloExchange
  