Nature Language: testAlltoall:Verifies that the all to all completed successfully.
  
CPP: int testAlltoall(int dataSize){\n    int sizeofBuffer, i, j;\n    int dataForEachThread, startElem;\n    int testFlag, reduceFlag;\n    int *testBuf;\n\n    testFlag = TRUE;\n    sizeofBuffer = dataSize * numThreads * numMPIprocs * numThreads;\n    testBuf = (int *) malloc(sizeofBuffer * sizeof(int));\n\n    dataForEachThread = dataSize * numThreads * numMPIprocs;\n\n    #pragma omp parallel default(none) \\\n    private(i,j,startElem) \\\n    shared(testBuf,globalIDarray,sizeofBuffer,dataSize) \\\n    shared(numThreads,numMPIprocs,dataForEachThread)\n    {\n        startElem = (myThreadID) * dataForEachThread;\n\n        for (i=0; i<(numThreads * numMPIprocs); i++){\n            for (j=0; j<dataSize; j++){\n                testBuf[startElem + (i * dataSize) + j] = i;\n            }\n        }\n    }\n\n    for (i=0; i<sizeofBuffer; i++){\n        if (alltoallFinalBuf[i] != testBuf[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(testBuf);\n\n    return 0;\n}",
  
Fortran: SUBROUTINE testAlltoall(dataSize)\n\n\tinteger, intent(in) :: dataSize\n\tinteger :: sizeofBuffer, i, j\n\tinteger :: dataForEachThread, startElem\n\tlogical :: testFlag, reduceFlag\n\n\t!Set testFlag to true\n\ttestFlag = .true.\n\n\t!calculate the size of buffer on each process and allocate\n\tsizeofBuffer = dataSize * numThreads * numMPIprocs * numThreads\n\tallocate(testBuf(sizeofBuffer))\n\n\t!Calculate how many elements each thread will work with\n\tdataForEachThread = dataSize * numThreads * numMPIProcs\n\n\t!Fill buffer with expected values.\n!$OMP PARALLEL DEFAULT(NONE), &\n!$OMP PRIVATE(i,j,startElem), &\n!$OMP SHARED(testBuf,globalIDarray,sizeofBuffer,dataSize),&\n!$OMP SHARED(numThreads,numMPIprocs,dataForEachThread)\n\n\t!Calculate start element for each thread\n\tstartElem = (myThreadID - 1)* dataForEachThread\n\n\tDO i = 1, (numThreads * numMPIprocs)\n\t\tDO j = 1, dataSize\n\t\t\ttestBuf(startElem + (i-1)*dataSize + j) = i\n\t\tEND DO\n\tEND DO\n\n!$OMP END PARALLEL\n\n\t!Compare\n\tDO i = 1, sizeofBuffer\n\t\tIF(alltoallFinalBuf(i) /= testBuf(i)) THEN\n\t\t\ttestFlag = .false.\n\t\tEND IF\n\tEND DO\n\n\t!Reduce testFlag with logical AND operator to \n\t!get overall test result.\n\tCALL MPI_Reduce(testFlag, reduceFlag, 1, MPI_LOGICAL, &\n\t\tMPI_LAND, 0, comm, ierr)\n\n\t!Master then sets testOutcome flag\n\tIF (myMPIRank == 0) THEN\n\t\tCALL setTestOutcome(reduceFlag)\n\tEND IF\n\n\t!free space for testBuf\n\tdeallocate(testBuf)\n\nEND SUBROUTINE testAlltoall
  