Nature Language: broadcast:Driver subroutine for the broadcast benchmark.
  
CPP: int broadcast() {\n    int dataSizeIter, sizeofFinalBuf;\n    repsToDo = defaultReps;\n    dataSizeIter = minDataSize;\n    \n    while (dataSizeIter <= maxDataSize) {\n        allocateBroadcastData(dataSizeIter);\n        broadcastKernel(warmUpIters,dataSizeIter);\n        sizeofFinalBuf = dataSizeIter * numThreads;\n        testBroadcast(sizeofFinalBuf);\n        benchComplete = FALSE;\n        \n        while (benchComplete != TRUE) {\n            MPI_Barrier(comm);\n            startTime = MPI_Wtime();\n            broadcastKernel(repsToDo, dataSizeIter);\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        freeBroadcastData();\n        dataSizeIter = dataSizeIter * 2;\n    }\n    \n    return 0;\n}",
  
Fortran: SUBROUTINE broadcast()\n\tinteger :: dataSizeIter\n\tinteger :: sizeofFinalBuf !needed for test\n\n\t!initialise repsToDo to defaultReps\n\trepsToDo = defaultReps\n\n\t!Start loop over data sizes\n\tdataSizeIter = minDataSize \n\tDO WHILE (dataSizeIter <= maxDataSize) \n\t\t!allocate space for main data arrays\n\t\tCALL allocateData(dataSizeIter)\n\n\t\t!Perform benchmark warm-up\n\t\tCALL broadcastKernel(warmUpIters,dataSizeIter)\n\t\t\n\t\t!Set sizeofFinalBuf and test if broadcast was a success\n\t\tsizeofFinalBuf = dataSizeIter * numThreads\n\t\tCALL testBroadcast(sizeofFinalBuf)\n\n\t\t!Initialise the benchmark \n\t\tbenchComplete = .false.\n\t\t!Execute benchmark until target time is reached\n\t\tDO WHILE (benchComplete .NEQV. .true.)\n\t\t\t!Start timer\n\t\t\tCALL MPI_Barrier(comm, ierr)\n\t\t\tstartTime = MPI_WTime()\n\n\t\t\t!Execute broadcast for repsToDo repetitions\n\t\t\tCALL broadcastKernel(repsToDo, dataSizeIter)\n\n\t\t\t!Stop timer \n\t\t\tCALL MPI_Barrier(comm, ierr)\n\t\t\tfinishTime = MPI_Wtime()\n\t\t\ttotalTime = finishTime - startTime\n\t\t\t\n\t\t\t!Test if target time was reached \n\t\t\tif (myMPIRank==0) then \n\t\t\t\tbenchComplete = repTimeCheck(totalTime, repsToDo)\n\t\t\tend if\n\t\t\t!Ensure all procs have the same value of benchComplete\n\t\t\t!and repsToDo\n\t\t\tcall MPI_Bcast(benchComplete, 1, MPI_INTEGER, 0, comm, ierr)\n\t\t\tcall MPI_Bcast(repsToDo, 1, MPI_INTEGER, 0, comm, ierr)\n\n\t\tEND DO\n\n\t\t!Master process sets benchmark result for reporting\n\t\tIF (myMPIRank == 0) THEN\n\t\t\tCALL setReportParams(dataSizeIter,repsToDo,totalTime)\n\t\t\tCALL printReport()\n\t\tEND IF\n\n\t\t!Free allocated data\n\t\tCALL freeData()\n\n\t\t!Double dataSize and loop again\n\t\tdataSizeIter = dataSizeIter * 2\n\t \n\tEND DO !End loop over data sizes\n\nEND SUBROUTINE broadcast
  