Nature Language: reduceKernel:Implements the reduce mixed mode benchmark. Each thread under every MPI process combines its local buffer. This is then sent to the master MPI process to get the overall reduce value.
  
CPP: int reduceKernel(int totalReps, int dataSize){\n    int repIter, i, j;\n\n    for (repIter=1; repIter<totalReps; repIter++){\n        #pragma omp parallel default(none) \\\n        private(i,j) \\\n        shared(tempBuf,globalIDarray,dataSize,numThreads) \\\n        shared(localReduceBuf)\n        {\n            #pragma omp for schedule(static,dataSize)\n            for(i=0; i<(numThreads * dataSize); i++){\n                tempBuf[i] = globalIDarray[myThreadID];\n            }\n\n            #pragma omp for\n            for(i=0; i<dataSize; i++){\n                localReduceBuf[i] = 0;\n                for (j=0; j<numThreads; j++){\n                    localReduceBuf[i] += tempBuf[(j*dataSize)+i];\n                }\n            }\n        }\n\n        MPI_Reduce(localReduceBuf, globalReduceBuf, dataSize,\\\n        MPI_INT, MPI_SUM, 0, comm);\n\n        if (myMPIRank==0) {\n            for (i=0; i<dataSize; i++){\n                finalReduceBuf[i] = globalReduceBuf[i];\n            }\n        }\n    }\n\n    return 0;\n}",
  
Fortran: SUBROUTINE reduceKernel(totalReps, dataSize)\ninteger, intent(in) :: totalReps, dataSize\ninteger :: repIter,i\n!Decalre array which each thread reduces into\ninteger, dimension(dataSize) :: localReduceBuf\n\nDO repIter = 1, totalReps !loop for totalReps\n\n !initialise all reduce arrays to ensure correct results\n localReduceBuf = 0\n globalReduceBuf = 0\n finalReduceBuf = 0\n\n !Open the parallel region and declare localReduceBuf\n !as a reduction variable.\n!$OMP PARALLEL DEFAULT(NONE), &\n!$OMP PRIVATE(i),&\n!$OMP SHARED(dataSize,globalIDarray),&\n!$OMP REDUCTION(+:localReduceBuf)\n DO i = 1, dataSize\n localReduceBuf(i) = localReduceBuf(i) + globalIDarray(myThreadID)\n END DO\n!$OMP END PARALLEL\n\n !Perform a reduce of localReduceBuf across the\n !MPI processes.\n CALL MPI_Reduce(localReduceBuf, globalReduceBuf, &\n dataSize, MPI_INTEGER, MPI_SUM, 0, comm, ierr)\n \n !Copy globalReduceBuf into master Threads portion\n !of finalReduceBuf.\n ! FR this should only happen on rank==0 \n if (myMPIRank==0) then \n finalReduceBuf(1:dataSize) = globalReduceBuf\n end if\n\nEND DO !End repetitions loop\n\nEND SUBROUTINE reduceKernel
  