Nature Language: testReduce:Verifies that the reduction benchmarks worked correctly.
  
CPP: int testReduce(int bufferSize, int benchmarkType){ \n    int i, testFlag, reduceFlag; \n    int correctReduce, lastGlobalID; \n    correctReduce = 0; \n    testFlag = TRUE; \n    lastGlobalID = (numMPIprocs * numThreads); \n\n    for (i=0; i<lastGlobalID; i++){ \n        correctReduce = correctReduce + i; \n    } \n\n    for (i=0; i<bufferSize; i++){ \n        if (finalReduceBuf[i] != correctReduce){ \n            testFlag = FALSE; \n        } \n    } \n\n    if (benchmarkType == ALLREDUCE){ \n        MPI_Reduce(&testFlag, &reduceFlag, 1, MPI_INT, MPI_LAND, 0, comm); \n\n        if (myMPIRank == 0){ \n            setTestOutcome(reduceFlag); \n        } \n    } else{ \n        setTestOutcome(testFlag); \n    } \n\n    return 0; \n}",
  
Fortran: SUBROUTINE testReduce(bufferSize,benchmarkType)\ninteger, intent(in) :: bufferSize, benchmarkType\ninteger :: i\ninteger :: correctReduce, lastGlobalID\nlogical :: testFlag, reduceFlag\n\n!Initialise correctReduce to 0..\ncorrectReduce = 0\n!..and testFlag to true\ntestFlag = .true.\n\n!set lastGlobalID\nlastGlobalID = (numMPIprocs * numThreads)\n\n!Now find correctReduce value by summing to lastGlobalID\nDO i = 1, lastGlobalID\ncorrectReduce = correctReduce + i\nEND DO\n\n!Compare each element of finalRecvBuf to correctReduce \nDO i = 1, bufferSize\nIF (finalReduceBuf(i) /= correctReduce) THEN\ntestFlag = .false.\nEND IF\nEND DO\n\n!For allReduce, combine testFlag into master with logical AND\nIF (benchmarkType == ALLREDUCE) THEN\nCALL MPI_Reduce(testFlag, reduceFlag, 1, MPI_LOGICAL, &\nMPI_LAND, 0, comm, ierr)\n!then master sets testOutcome using reduceFlag\nIF (myMPIRank == 0) THEN\nCALL setTestOutcome(reduceFlag)\nEND IF\nELSE\n!For reduce master process just sets testOutcome using testFlag\nCALL setTestOutcome(testFlag)\nEND IF\n\nEND SUBROUTINE testReduce
  