Nature Language: Main driver for mixed mode benchmark program:Reads benchmark input file. Initialises the parallel environment. Calls each benchmark.
  
CPP: int main(int argc, char *argv[]){\n    int supportFlag;\n    char name[MAXSTRING];\n\n    initParallelEnv();\n\n    if (myMPIRank == 0){\n        if (argc != 2){\n            printf(\"ERROR Reading input file from command line.\\n\");\n            printf(\"Usage: %s <filename>\", argv[0] );\n            finaliseParallelEnv();\n            exit(-1);\n        }\n        else{\n            printHeader(numMPIprocs,numThreads,threadSupport);\n            openFile(argv[1]);\n            setupBenchmarkList();\n        }\n    }\n\n    readBenchmarkParams();\n\n    while (findBenchmarkNumber() != FINISHED){\n        switch (benchmarkNumber){\n            case 0:\n                if (myMPIRank == 0){\n                    supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED);\n                    strcpy(name,\"Masteronly Pingpong\");\n                    setBenchName(name, benchmarkNumber, supportFlag);\n                }\n                pingPong(MASTERONLY);\n                break;\n\n            case 1:\n                if (myMPIRank == 0){\n                    supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED);\n                    strcpy(name,\"Funnelled Pingpong\");\n                    setBenchName(name, benchmarkNumber, supportFlag);\n                }\n                pingPong(FUNNELLED);\n                break;\n\n            case 2:\n                if (myMPIRank == 0){\n                    supportFlag = benchmarkSupport(MPI_THREAD_MULTIPLE);\n                    strcpy(name,\"Multiple Pingpong\");\n                    setBenchName(name, benchmarkNumber, supportFlag);\n                }\n                pingPong(MULTIPLE);\n                break;\n\n            case 3:\n                if (myMPIRank == 0){\n                    supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED);\n                    strcpy(name,\"Masteronly Pingping\");\n                    setBenchName(name, benchmarkNumber, supportFlag);\n                }\n                pingPing(MASTERONLY);\n                break;\n\n            case 4:\n                if (myMPIRank == 0){\n                    supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED);\n                    strcpy(name,\"Funnelled Pingping\");\n                    setBenchName(name, benchmarkNumber, supportFlag);\n                }\n                pingPing(FUNNELLED);\n                break;\n\n            case 5:\n                if (myMPIRank == 0){\n                    supportFlag = benchmarkSupport(MPI_THREAD_MULTIPLE);\n                    strcpy(name,\"Multiple Pingping\");\n                    setBenchName(name, benchmarkNumber, supportFlag);\n                }\n                pingPing(M",
  
Fortran: PROGRAM mixedModeBenchmark\n use pt_to_pt_pingpong\n use pt_to_pt_pingping\n use pt_to_pt_multiPingPong\n use pt_to_pt_multiPingPing\n use pt_to_pt_haloExchange\n use collective_barrier\n use collective_reduction\n use collective_broadcast\n use collective_scatterGather\n use collective_alltoall\n use parallelEnvironment\n use benchmarkSetup\n use output\n\n implicit none\n\n !String for setting benchmark name for output\n character (len = MAXSTRING) :: name\n\n !Flag to check if benchmark is supported \n logical :: supportFlag\n\n !Initialise the parallel execution environment\n CALL initParallelEnv()\n\n !Master MPI process.....\n IF (myMPIRank == 0) THEN\n !1) Ptints header and parallel environment info.\n CALL printHeader(numMPIprocs,numThreads,threadSupport)\n !2) Opens the input file\n CALL openFile()\n !3) Setup the list of all possible benchmarks\n CALL setupBenchmarkList()\n END IF\n \n !Master reads parameters from input file and\n !broadcasts them to the other processes.\n CALL readBenchmarkParams()\n \n !Execute bencmarks by reading list from\n !input file.\n CALL findBenchmarkNumber()\n DO WHILE(benchmarkNumber /= FINISHED)\n \n benchmarks : SELECT CASE (benchmarkNumber)\n !Masteronly Pingpong\n CASE(1) \n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Masteronly Pingpong"\n CALL setBenchName(name, benchmarkNumber, supportFlag) \n END IF\n !Execute benchmark\n CALL pingPong(MASTERONLY)\n \n !Funnelled Pingpong \n CASE(2)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Funnelled Pingpong"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n END IF\n !Execute benchmark\n CALL pingPong(FUNNELLED)\n\n !Multiple Pingpong\n CASE(3) \n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_MULTIPLE)\n name = "Multiple Pingpong"\n CALL setBenchName(name, benchmarkNumber, supportFlag) \n END IF\n !Execute benchmark \n CALL pingPong(MULTIPLE)\n\n !Masteronly Pingping\n CASE(4)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Masteronly Pingping"\n CALL setBenchName(name, benchmarkNumber, supportFlag) \n END IF\n !Execute benchmark\n CALL pingPing(MASTERONLY)\n\n !Funnelled Pingping\n CASE(5)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Funnelled Pingping"\n CALL setBenchName(name, benchmarkNumber, supportFlag) \n END IF\n !Execute benchmark\n CALL pingPing(FUNNELLED)\n\n !Multiple Pingping\n CASE(6)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_MULTIPLE)\n name = "Multiple Pingping"\n CALL setBenchName(name, benchmarkNumber, supportFlag) \n END IF\n !Execute benchmark\n CALL pingPing(MULTIPLE)\n\n !Masteronly Haloexchange\n CASE(7)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Masteronly Haloexchange"\n CALL setBenchName(name, benchmarkNumber, supportFlag) \n CALL printBenchHeader()\n END IF\n !Execute benchmark\n CALL haloExchange(MASTERONLY)\n\n !Funnelled Haloexchange \n CASE(8) \n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Funnelled Haloexchange"\n CALL setBenchName(name, benchmarkNumber, supportFlag) \n CALL printBenchHeader()\n END IF\n !Execute benchmark\n CALL haloExchange(FUNNELLED)\n\n !Multiple Haloexchange\n CASE(9) \n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_MULTIPLE)\n name = "Multiple Haloexchange"\n CALL setBenchName(name, benchmarkNumber, supportFlag) \n CALL printBenchHeader()\n END IF\n !Execute benchmark\n CALL haloExchange(MULTIPLE)\n\n !Masteronly Multipingpong\n CASE(10)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Masteronly MultiPingpong"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n END IF\n !Execute benchmark\n CALL multiPingPong(MASTERONLY)\n\n !Funnelled Multipingpong\n CASE(11)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Funnelled MultiPingpong"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n END IF\n !Execute benchmark\n CALL multiPingPong(FUNNELLED) \n\n !Multiple Multipingpong\n CASE(12)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_MULTIPLE)\n name = "Multiple MultiPingpong"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n END IF\n !Execute benchmark\n CALL multiPingPong(MULTIPLE)\n\n !Masteronly Multipingping\n CASE(13)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Masteronly MultiPingping"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n END IF\n !Execute benchmark\n CALL multiPingPing(MASTERONLY)\n\n !Funnelled Multipingping\n CASE(14)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Funnelled MultiPingping"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n END IF\n !Execute benchmark\n CALL multiPingPing(FUNNELLED)\n\n !Multiple MultiPingping\n CASE(15)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_MULTIPLE)\n name = "Multiple MultiPingping"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n END IF\n !Execute benchmark\n CALL multiPingPing(MULTIPLE)\n\n !Barrier \n CASE(16) \n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Barrier"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n CALL printBenchHeader()\n END IF\n !Execute benchmark\n CALL barrierDriver()\n\n !Reduce \n CASE(17)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Reduce"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n CALL printBenchHeader()\n END IF\n !Execute benchmark\n CALL reduction(REDUCE)\n\n !All-reduce \n CASE(18)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "All Reduce"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n CALL printBenchHeader()\n END IF\n !Execute benchmark\n CALL reduction(ALLREDUCE)\n\n !Broadcast \n CASE(19) \n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Broadcast"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n CALL printBenchHeader()\n END IF\n !Execute benchmark\n CALL broadcast()\n \n !Scatter \n CASE(20)\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Scatter"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n CALL printBenchHeader()\n END IF\n !Execute banehmark\n CALL scatterGather(SCATTER)\n\n !Gather \n CASE(21)\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "Gather"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n CALL printBenchHeader()\n END IF\n !Execute benchmark\n CALL scatterGather(GATHER)\n\n !All to all\n CASE(22)\n !Set name\n IF (myMPIRank == 0) THEN\n supportFlag = benchmarkSupport(MPI_THREAD_FUNNELED)\n name = "All to all"\n CALL setBenchName(name, benchmarkNumber, supportFlag)\n CALL printBenchHeader()\n END IF\n !Execute benchmark\n CALL alltoall()\n \n !Default..file read error\n CASE default\n !..error message will already be printed out.\n\n END SELECT benchmarks\n \n !Read next benchmark from file\n CALL findBenchmarkNumber()\n END DO\n\n !Finalise programming environment\n CALL finaliseParallelEnv()\n !Master process closes file\n IF (myMPIRank == 0) THEN\n CALL closeFile()\n END IF\nEND PROGRAM mixedModeBenchmark
  