Nature Language: testHaloexchange:Verifies that the halo exchange benchmark worked correctly.
  
CPP: int testHaloexchange(int sizeofBuffer, int dataSize){\n    int i;\n    int testFlag, reduceFlag;\n    int *testLeftBuf, *testRightBuf;\n\n    testFlag = TRUE;\n\n    testLeftBuf = (int *)malloc(sizeofBuffer * sizeof(int));\n    testRightBuf = (int *)malloc(sizeofBuffer * sizeof(int));\n\n    #pragma omp parallel for default(none) \\\n        private(i) \\\n        shared(leftNeighbour,rightNeighbour,numThreads) \\\n        shared(dataSize,sizeofBuffer,testLeftBuf,testRightBuf) \\\n        schedule(static,dataSize)\n    for (i=0; i<sizeofBuffer; i++){\n        testLeftBuf[i] = (leftNeighbour * numThreads) + myThreadID;\n        testRightBuf[i] = (rightNeighbour * numThreads) + myThreadID;\n    }\n\n    for (i=0; i<sizeofBuffer; i++){\n        if (testLeftBuf[i] != finalLeftBuf[i]){\n            testFlag = FALSE;\n        }\n        if (testRightBuf[i] != finalRightBuf[i]){\n            testFlag = FALSE;\n        }\n    }\n\n    MPI_Reduce(&testFlag, &reduceFlag, 1, MPI_INT, MPI_LAND, 0, comm);\n\n    if (myMPIRank == 0){\n        setTestOutcome(reduceFlag);\n    }\n\n    free(testLeftBuf);\n    free(testRightBuf);\n\n    return 0;\n}",
  
Fortran: SUBROUTINE testHaloexchange(sizeofBuffer, dataSize)\n integer, intent(in) :: sizeofBuffer, dataSize\n integer :: i\n logical :: testFlag, reduceFlag\n\n !set testFlag to true\n testFlag = .true.\n\n !allocate space for testLeftBuf and testRightBuf\n allocate(testLeftBuf(sizeofBuffer),testRightBuf(sizeofBuffer))\n\n !Construct testLeftBuf and testRightBuf with correct values\n!$OMP PARALLEL DO DEFAULT(NONE), &\n!$OMP PRIVATE(i), &\n!$OMP SHARED(leftNeighbour,rightNeighbour,numThreads), &\n!$OMP SHARED(dataSize,sizeofBuffer,testLeftBuf,testRightBuf),&\n!$OMP SCHEDULE(STATIC,dataSize)\n DO i = 1, sizeofBuffer\n !Calculate globalID of thread expected in finalLeftBuf..\n testLeftBuf(i) = (leftNeighbour * numThreads) + myThreadID\n !...and in finalRightBuf.\n testRightBuf(i) = (rightNeighbour * numThreads) + myThreadID\n END DO\n!OMP END PARALLEL DO\n\n !Compare..\n DO i = 1, sizeofBuffer\n !1) values from left neighbour\n IF (testLeftBuf(i) /= finalLeftBuf(i)) THEN\n testFlag = .false.\n END IF\n !2) values from right neighbour\n IF (testRightBuf(i) /= finalRightBuf(i)) THEN\n testFlag = .false.\n END IF\n END DO\n\n !Reduce testFlag into master with logical AND operator\n CALL MPI_Reduce(testFlag, reduceFlag, 1, MPI_LOGICAL, &\n MPI_LAND, 0, comm, ierr)\n\n !Master then sets testOutcome flag\n IF (myMPIRank == 0) THEN\n CALL setTestOutcome(reduceFlag)\n END IF\n\n !free space for testLeftBuf and testRightBuf\n deallocate(testLeftBuf, testRightBuf)\n\n END SUBROUTINE testHaloexchange
  