Nature Language: gatherKernel:Implements the gather benchmark. Each thread writes part of its buffer then all data is gathered to the master process.
  
CPP: int gatherKernel(int totalReps, int dataSize){\n    int repIter, i;\n    int totalRecvBufElems, sendCount, recvCount;\n    int startVal;\n\n    totalRecvBufElems = dataSize * numThreads * numMPIprocs;\n    sendCount = dataSize * numThreads;\n    recvCount = sendCount;\n    startVal = (myMPIRank * sendCount) + GATHERSTARTVAL;\n\n    for (repIter=0; repIter<totalReps; repIter++){\n        #pragma omp parallel for default(none)         \\ \n        private(i)                          \\ \n        shared(gatherSendBuf,startVal,dataSize,sendCount)    \\\n        schedule(static,dataSize)\n        for (i=0; i<sendCount; i++){\n            gatherSendBuf[i] = startVal + i;\n        }\n\n        MPI_Gather(gatherSendBuf, sendCount, MPI_INT,\\\n                   gatherRecvBuf, recvCount, MPI_INT,\\\n                   GATHERROOT, comm);\n\n        if (myMPIRank == GATHERROOT){\n            for (i=0; i<totalRecvBufElems; i++){\n                finalBuf[i] = gatherRecvBuf[i];\n            }\n        }\n    }\n\n    return 0;\n}",
  
Fortran: SUBROUTINE gatherKernel(totalReps, dataSize)\ninteger, intent(in) :: totalReps, dataSize\ninteger :: repIter, i\ninteger :: totalRecvBufElems\ninteger :: sendCount, recvCount\ninteger :: startVal\n\n!Calculate totalRecvBufElems\ntotalRecvBufElems = dataSize * numThreads * numMPIprocs\n!Each process calculates its send and recv count\nsendCount = dataSize * numThreads\nrecvCount = sendCount\n\n!Calculate startVal for each process\n!This is used to find the values to put in gatherSendBuf\nstartVal = (myMPIRank * sendCount) + GATHERSTARTVAL\n\nDO repIter = 1, totalReps\n\n!Each thread writes to its portion of gatherSendBuf\n!$OMP PARALLEL DO DEFAULT(NONE), &\n!$OMP PRIVATE(i), &\n!$OMP SHARED(gatherSendBuf,startVal,dataSize,sendCount),&\n!$OMP SCHEDULE(STATIC,dataSize)\nDO i = 1, sendCount\ngatherSendBuf(i) = startVal + i\nEND DO\n!$OMP END PARALLEL DO\n\n!Gather the data to GATHERROOT\nCALL MPI_Gather(gatherSendBuf, sendCount, MPI_INTEGER, &\ngatherRecvBuf, recvCount, MPI_INTEGER, &\nGATHERROOT, comm, ierr)\n\n!GATHERROOT process then copies its received data to\n!finalBuf\nIF (myMPIRank == GATHERROOT) THEN\nDO i = 1, totalRecvBufElems\nfinalBuf(i) = gatherRecvBuf(i)\nEND DO\nEND IF\n\nEND DO !End of repetitions loop\n\nEND SUBROUTINE gatherKernel
  