Nature Language: alltoall:Driver routine for the alltoall benchmark.
  
CPP: int alltoall(){ int dataSizeIter; int bufferSize; repsToDo = defaultReps; dataSizeIter = minDataSize; while (dataSizeIter <= maxDataSize){ bufferSize = dataSizeIter * numThreads * numMPIprocs * numThreads; allocateAlltoallData(bufferSize); alltoallKernel(warmUpIters, dataSizeIter); testAlltoall(dataSizeIter); benchComplete = FALSE; while (benchComplete != TRUE){ MPI_Barrier(comm); startTime = MPI_Wtime(); alltoallKernel(repsToDo, dataSizeIter); MPI_Barrier(comm); finishTime = MPI_Wtime(); totalTime = finishTime - startTime; if (myMPIRank==0){ benchComplete = repTimeCheck(totalTime, repsToDo); } MPI_Bcast(&benchComplete, 1, MPI_INT, 0, comm); MPI_Bcast(&repsToDo, 1, MPI_INT, 0, comm); } if (myMPIRank == 0){ setReportParams(dataSizeIter, repsToDo, totalTime); printReport(); } freeAlltoallData(); dataSizeIter = dataSizeIter * 2; } return 0; }
  
Fortran: SUBROUTINE alltoall()\n\tinteger :: dataSizeIter\n\tinteger :: bufferSize\n\n\t!Initialise repsToDo to defaultReps\n\trepsToDo = defaultReps\n\n\t!Start loop over data sizes\n\tdataSizeIter = minDataSize !initialise dataSizeIter\n\tDO WHILE (dataSizeIter <= maxDataSize)\n\t\t!Calculate buffer size and allocate space for\n\t\t!the data arrays.\n\t\tbufferSize = dataSizeIter * (numThreads * numMPIprocs) &\n\t\t\t* numThreads\n\t\t\n\t\tCALL allocateData(bufferSize)\n\t\t\n\t\t!Perform warm-up of benchmark\n\t\tCALL alltoallKernel(warmUpIters,dataSizeIter)\n\t\t\n\t\t!Test if alltoall was successful\n\t\tCALL testAlltoall(dataSizeIter)\n\n\t\t!Initialise the benchmark\n\t\tbenchComplete = .false.\n\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 alltoall for repsToDo repetitions\n\t\t\tCALL alltoallKernel(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\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\t\t\n\t\t!Double data size and loop again\n\t\tdataSizeIter = dataSizeIter * 2\n\n\tEND DO !End loop over data sizes\n\nEND SUBROUTINE alltoall
  