/*-----------------------------------------------------------*/ int reduction(int benchmarkType){ int dataSizeIter, sizeofBuf; /* Initialise repsToDo to defaultReps */ repsToDo = defaultReps; /* Start loop over data sizes */ dataSizeIter = minDataSize; /* initialise dataSizeIter */ while (dataSizeIter <= maxDataSize){ /* allocate space for the main data arrays.. */ allocateReduceData(dataSizeIter); /* Perform benchmark warm-up */ if (benchmarkType == REDUCE){ reduceKernel(warmUpIters, dataSizeIter); /* Master process tests if reduce was a success */ if (myMPIRank == 0){ testReduce(dataSizeIter, benchmarkType); } } else if (benchmarkType == ALLREDUCE){ /* calculate sizeofBuf for test */ sizeofBuf = dataSizeIter * numThreads; allReduceKernel(warmUpIters, dataSizeIter); /* all processes need to perform unit test */ testReduce(sizeofBuf, benchmarkType); } /* Initialise the benchmark */ benchComplete = FALSE; /* Execute benchmark until target time is reached */ while (benchComplete != TRUE){ /* Start timer */ MPI_Barrier(comm); startTime = MPI_Wtime(); /* Execute reduce for repsToDo repetitions */ if (benchmarkType == REDUCE){ reduceKernel(repsToDo, dataSizeIter); } else if (benchmarkType == ALLREDUCE){ allReduceKernel(repsToDo, dataSizeIter); } /* Stop timer */ MPI_Barrier(comm); finishTime = MPI_Wtime(); totalTime = finishTime - startTime; /* Test if target time was reached with the number of reps */ if (myMPIRank==0){ benchComplete = repTimeCheck(totalTime, repsToDo); } /* Ensure all procs have the same value of benchComplete */ /* and repsToDo */ MPI_Bcast(&benchComplete, 1, MPI_INT, 0, comm); MPI_Bcast(&repsToDo, 1, MPI_INT, 0, comm); } /* Master process sets benchmark result for reporting */ if (myMPIRank == 0){ setReportParams(dataSizeIter, repsToDo, totalTime); printReport(); } /* Free allocated data */ freeReduceData(); /* Double dataSize and loop again */ dataSizeIter = dataSizeIter * 2; } return 0; }
int main(int argc, char **argv) { xmlRegexpPtr comp = NULL; #ifdef LIBXML_EXPR_ENABLED xmlExpNodePtr expr = NULL; int use_exp = 0; xmlExpCtxtPtr ctxt = NULL; #endif const char *pattern = NULL; char *filename = NULL; int i; xmlInitMemory(); if (argc <= 1) { usage(argv[0]); return(1); } for (i = 1; i < argc ; i++) { if (!strcmp(argv[i], "-")) break; if (argv[i][0] != '-') continue; if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) { debug++; } else if ((!strcmp(argv[i], "-repeat")) || (!strcmp(argv[i], "--repeat"))) { repeat++; #ifdef LIBXML_EXPR_ENABLED } else if ((!strcmp(argv[i], "-expr")) || (!strcmp(argv[i], "--expr"))) { use_exp++; #endif } else if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "-f")) || (!strcmp(argv[i], "--input"))) filename = argv[++i]; else { fprintf(stderr, "Unknown option %s\n", argv[i]); usage(argv[0]); } } #ifdef LIBXML_EXPR_ENABLED if (use_exp) ctxt = xmlExpNewCtxt(0, NULL); #endif if (filename != NULL) { #ifdef LIBXML_EXPR_ENABLED if (use_exp) runFileTest(ctxt, filename); else #endif testRegexpFile(filename); } else { #ifdef LIBXML_EXPR_ENABLED if (use_exp) { for (i = 1; i < argc ; i++) { if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) { if (pattern == NULL) { pattern = argv[i]; printf("Testing expr %s:\n", pattern); expr = xmlExpParse(ctxt, pattern); if (expr == NULL) { printf(" failed to compile\n"); break; } if (debug) { exprDebug(ctxt, expr); } } else { testReduce(ctxt, expr, argv[i]); } } } if (expr != NULL) xmlExpFree(ctxt, expr); } else #endif { for (i = 1; i < argc ; i++) { if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) { if (pattern == NULL) { pattern = argv[i]; printf("Testing %s:\n", pattern); comp = xmlRegexpCompile((const xmlChar *) pattern); if (comp == NULL) { printf(" failed to compile\n"); break; } if (debug) xmlRegexpPrint(stdout, comp); } else { testRegexp(comp, argv[i]); } } } if (comp != NULL) xmlRegFreeRegexp(comp); } } #ifdef LIBXML_EXPR_ENABLED if (ctxt != NULL) { printf("Ops: %d nodes, %d cons\n", xmlExpCtxtNbNodes(ctxt), xmlExpCtxtNbCons(ctxt)); xmlExpFreeCtxt(ctxt); } #endif xmlCleanupParser(); xmlMemoryDump(); return(0); }