Nature Language: testPingping:Verifies that the PingPing benchmark worked correctly.
  
CPP: int testPingping(int sizeofBuffer,int dataSize){\n\tint otherPingRank, i, testFlag, reduceFlag;\n\tint *testBuf;\n\t/* initialise testFlag to true (test passed) */\n\ttestFlag = TRUE;\n\t/* Testing only needs to be done by pingRankA & pingRankB */\n\tif (myMPIRank == pingRankA || myMPIRank == pingRankB){\n\t\t/* allocate space for testBuf */\n\t\ttestBuf = (int *)malloc(sizeofBuffer * sizeof(int));\n\t\t/* set the ID of other pingRank */\n\t\tif (myMPIRank == pingRankA){\n\t\t\totherPingRank = pingRankB;\n\t\t}\n\t\telse if (myMPIRank == pingRankB){\n\t\t\totherPingRank = pingRankA;\n\t\t}\n\t\t/* construct testBuf array with correct values.\n\t\t * These are the values that should be in finalRecvBuf.\n\t\t */\n#pragma omp parallel for default(none) \\\n\t\tprivate(i) \\\n\t\tshared(otherPingRank,numThreads,testBuf,dataSize,sizeofBuffer) \\\n\t\tschedule(static,dataSize)\n\t\tfor (i=0; i<sizeofBuffer; i++){\n\t\t\t/* calculate globalID of thread expected in finalRecvBuf\n\t\t\t * This is done by using otherPingRank\n\t\t\t */\n\t\t\ttestBuf[i] = (otherPingRank * numThreads) + myThreadID;\n\t\t}\n\t\t/* compare each element of testBuf and finalRecvBuf */\n\t\tfor (i=0; i<sizeofBuffer; i++){\n\t\t\tif (testBuf[i] != finalRecvBuf[i]){\n\t\t\t\ttestFlag = FALSE;\n\t\t\t}\n\t\t}\n\t\t/* free space for testBuf */\n\t\tfree(testBuf);\n\t}\n\tMPI_Reduce(&testFlag, &reduceFlag, 1, MPI_INT, MPI_LAND, 0, comm);\n\t/* Master process sets the testOutcome using testFlag. */\n\t if (myMPIRank == 0){\n\t\t setTestOutcome(reduceFlag);\n\t }\n\t return 0;\n}
  
Fortran: SUBROUTINE testPingPing(sizeofBuffer, dataSize)\n integer, intent(in) :: sizeofBuffer, dataSize\n integer :: otherPingRank, i\n logical :: testFlag, reduceFlag\n \n !set testFlag to true\n testFlag = .true.\n \n !Testing only needs to be done by pingRankA & pingRankB\n IF (myMPIRank == pingRankA .or. myMPIRank == pingRankB) THEN\n !allocate space for testBuf\n allocate(testBuf(sizeofBuffer))\n \n !set the ID of other pingRank\n IF (myMPIRank == pingRankA) THEN\n otherPingRank = pingRankB\n ELSE IF (myMPIRank == pingRankB) THEN\n otherPingRank = pingRankA\n END IF\n \n !Construct testBuf with correct values\n!$OMP PARALLEL DO DEFAULT(NONE), &\n!$OMP PRIVATE(i), &\n!$OMP SHARED(otherPingRank,numThreads,dataSize), &\n!$OMP SHARED(sizeofBuffer,testBuf), &\n!$OMP SCHEDULE(STATIC,dataSize)\n DO i = 1, sizeofBuffer\n !calculate globalID of thread expected in finalRecvBuf\n !this is done by using otherPingRank\n testBuf(i) = (otherPingRank * numThreads) + myThreadID\n END DO\n!$OMP END PARALLEL DO\n\n !Compare each element of testBuf and finalRecvBuf\n DO i = 1, sizeofBuffer\n IF (testBuf(i) /= finalRecvBuf(i)) THEN\n testFlag = .false.\n END IF\n END DO\n\n !free space for testBuf\n deallocate(testBuf)\n \n END IF !End test loop\n \n !Reduce testFlag into master with logical AND\n CALL MPI_Reduce(testFlag, reduceFlag, 1, MPI_LOGICAL, &\n MPI_LAND, 0, comm, ierr)\n\n !master sets testOutcome flag\n IF (myMPIRank == 0) THEN\n CALL setTestOutcome(reduceFlag)\n END IF\n\n END SUBROUTINE testPingPing
  