int main(int argc, char *argv[]) { int nthreads, size, numiter; char *argNames[2] = { "size", "numiter" }; char *defaultValues[2] = { "1000", "10" }; char *timerNames[1] = { "EXE_TIME" }; //SETUP_ISR; nthreads = omp_get_max_threads(); OSCR_init( nthreads, "Sinthetic loops experiment.", NULL, 2, argNames, defaultValues, 1, 1, timerNames, argc, argv ); /* 1. GET PARAMETERS */ size = OSCR_getarg_int(1); numiter = OSCR_getarg_int(2); /* 2. CALL COMPUTATION */ loop(nthreads, size, numiter); /* 3. REPORT */ OSCR_report(); exit(0); return 0; }
/* ----------------------------------------------------------------------- */ int main(int argc, char *argv[]) { int STEP, NUMTHREADS; double total_time; char *PARAM_NAMES[NUM_ARGS] = {"Size (in K)"}; char *TIMERS_NAMES[NUM_TIMERS] = {"Total_time" }; char *DEFAULT_VALUES[NUM_ARGS] = {"2048 K"}; NUMTHREADS = omp_get_max_threads(); OSCR_init (NUMTHREADS, "Quicksort", "Use 'qsort' <size (in K)>", NUM_ARGS, PARAM_NAMES, DEFAULT_VALUES , NUM_TIMERS, NUM_TIMERS, TIMERS_NAMES, argc, argv); SIZE = OSCR_getarg_int(1); if (SIZE > MAXSIZE) { printf("Size: %d Maximum size: %d\n", SIZE, MAXSIZE); exit(-1); } /* Default: DEFAULT_SIZE */ for (STEP = 0; STEP < NUM_STEPS; STEP++) { initialize(array, STEP); OSCR_timer_start(0); qs(array, 0, SIZE-1); OSCR_timer_stop(0); testit(array); } total_time = OSCR_timer_read(0); OSCR_report(1, TIMERS_NAMES); printf("\n \t# THREADS \tSIZE \tSTEPS \tTIME (secs.) \n"); printf("\t%d \t\t%d \t%d \t%14.6lf \n", NUMTHREADS, SIZE, NUM_STEPS, total_time); } /* main */
int main(int argc, char **argv){ double *u, *f, dx, dy; double dt, mflops; int NUMTHREADS; char *PARAM_NAMES[NUM_ARGS] = {"Grid dimension: X dir =", "Grid dimension: Y dir =", "Helmhotlz constant =", "Successive over-relaxation parameter =", "error tolerance for iterative solver =", "Maximum iterations for solver ="}; char *TIMERS_NAMES[NUM_TIMERS] = {"Total_time"}; char *DEFAULT_VALUES[NUM_ARGS] = {"5000", "5000", "0.8", "1.0", "1e-7", "1000"}; NUMTHREADS = omp_get_max_threads(); OSCR_init (NUMTHREADS, "Jacobi Solver v1", "Use 'jacobi01' <n> <m> <alpha> <relax> <tol> <mits>", NUM_ARGS, PARAM_NAMES, DEFAULT_VALUES , NUM_TIMERS, NUM_TIMERS, TIMERS_NAMES, argc, argv); n = OSCR_getarg_int(1); m = OSCR_getarg_int(2); alpha = OSCR_getarg_double(3); relax = OSCR_getarg_double(4); tol = OSCR_getarg_double(5); mits = OSCR_getarg_int(6); printf("-> %d, %d, %g, %g, %g, %d\n", n, m, alpha, relax, tol, mits); u = (double *) OSCR_malloc(n*m*sizeof(double)); f = (double *) OSCR_malloc(n*m*sizeof(double)); /* arrays are allocated and initialzed */ initialize(n, m, alpha, &dx, &dy, u, f); /* Solve Helmholtz eqiation */ OSCR_timer_start(0); jacobi(n, m, dx, dy, alpha, relax, u,f, tol, mits); OSCR_timer_stop(0); dt = OSCR_timer_read(0); // printf(" elapsed time : %12.6f\n", dt); mflops = (0.000001*mits*(m-2)*(n-2)*13) / dt; // printf(" MFlops : %12.6g (%d, %d, %d, %g)\n",mflops, mits, m, n, dt); error_check(n, m, alpha, dx, dy, u, f); OSCR_report(1, TIMERS_NAMES); return 0; }
//#include <interrupt_tasks.h> int main(int argc, char *argv[]) { int nthreads, source, target; char *graphFileName; FILE *graphFile; tg graph; char *argNames[3] = { "source_node_num", "target_node_num", "graph_file" }; char *defaultValues[3] = { "1", "29", "software/benchmarks/data/exampleGraph_01.gph" }; char *timerNames[1] = { "EXE_TIME" }; //SETUP_ISR; nthreads = omp_get_max_threads(); OSCR_init( nthreads, "Check if there is a path on a directed graph.", NULL, 3, argNames, defaultValues, 1, 1, timerNames, argc, argv ); /* 1. GET PARAMETERS */ source = OSCR_getarg_int(1); target = OSCR_getarg_int(2); graphFileName = OSCR_getarg_string(3); /* 2. READ GRAPH */ graphFile = fopen(graphFileName,"r"); if (graphFile==NULL) { fprintf(stderr,"Imposible to open graph file: %s\n",graphFileName); exit(-1); } graph = tg_read(graphFile); fclose(graphFile); /* 3. CALL COMPUTATION */ testPath(nthreads, source, target, graph); /* 4. REPORT */ OSCR_report(); exit(0); return 0; }
/* ----------------------------------------------------------------------- IMPLEMENTATION * ----------------------------------------------------------------------- */ int main(int argc, char **argv) { int i, j, NUMTHREADS; long inside, /* no. of points inside the Mandelbrot set */ outside; /* no. of points outside the Mandelbrot set */ double area, error, ztemp, total_time; complex z; char *PARAM_NAMES[NUM_ARGS] = {"Number of points"}; char *TIMERS_NAMES[NUM_TIMERS] = {"Total_time"}; char *DEFAULT_VALUES[NUM_ARGS] = {"4092"}; NUMTHREADS = omp_get_max_threads(); OSCR_init (NUMTHREADS, "Mandelbrot set area", "Use 'mandel' <Number of points>", NUM_ARGS, PARAM_NAMES, DEFAULT_VALUES , NUM_TIMERS, NUM_TIMERS, TIMERS_NAMES, argc, argv); NPOINTS = OSCR_getarg_int(1); /* Default: DEFAULT_NPOINTS */ points = (complex *)OSCR_calloc(NPOINTS, sizeof(complex)); NUMTHREADS = omp_get_max_threads(); /*1. Generate NPOINTS random points in the complex plane */ srandom(31416); for (i = 0; i < NPOINTS; i++) { points[i].re = -2.0 + 2.5 * random() / OSCR_RAND_MAX; points[i].im = 1.125 * random() / OSCR_RAND_MAX; } /* * 2. Monte Carlo sampling * 2a. Outer loop runs over NPOINTS, initialise z=c * 2b. Inner loop has the iteration z=z*z+c, and threshold test */ OSCR_timer_start(0); outside = 0; #pragma omp parallel for default(none) reduction(+:outside) \ private(i, j, ztemp, z) shared(NPOINTS, points) for(i = 0; i < NPOINTS; i++) { z.re = points[i].re; z.im = points[i].im; for (j = 0; j < MAXITER; j++) { ztemp = (z.re * z.re) - (z.im * z.im) + points[i].re; z.im = z.re * z.im * 2 + points[i].im; z.re = ztemp; if (z.re * z.re + z.im * z.im > THRESOLD) { outside++; break; } } /* for j */ } /* for i */ inside = (long)NPOINTS - outside; /*3. Calculate area and error */ /* The area is proportional to 2 * the area of the rectangle * no. of points inside it */ /* The error is inversely proportional to the square root of the number of test cases */ area = 2.0 * (2.5 * 1.125) * inside / NPOINTS; error = area / sqrt(NPOINTS); OSCR_timer_stop(0); total_time = OSCR_timer_read(0); /* 4. Output the Results */ OSCR_report(1, TIMERS_NAMES); printf("\n \t# THREADS NPOINTS AREA \t\t\tERROR \t\tTIME (secs.)\n"); // printf("\t%d \t%d \t%16.12f %16.12f \t%lf\n", NUMTHREADS, NPOINTS, area, error, total_time); printf("\t%d \t%d \t%16.12f %16.12f \t\n", NUMTHREADS, NPOINTS, area, error); return 0; }
/** main function with initialization, command line argument parsing, * memory allocation, OpenMP setup, wall--clock time measurement. */ int main(int argc, char *argv[]) { std::vector < int >myVec; int numThreads; int numEntries; int switchThresh; char *PARAM_NAMES[NUM_ARGS] = {"Number of integer to sort:", "Number of threads:", "SwitchThresh:"}; char *TIMERS_NAMES[NUM_TIMERS] = {"Total_time" }; char *DEFAULT_VALUES[NUM_ARGS] = {"10000000", "1", "1000"}; /* used for time measurements */ double accTime; numThreads = omp_get_max_threads(); OSCR_init (numThreads, "QuickSort", "", NUM_ARGS, PARAM_NAMES, DEFAULT_VALUES , NUM_TIMERS, NUM_TIMERS, TIMERS_NAMES, argc, argv); numEntries = OSCR_getarg_int(1); numThreads = OSCR_getarg_int(2); switchThresh = OSCR_getarg_int(3); /* and run with the specified number of threads */ omp_set_num_threads(numThreads); /* initialize random number generator to fixed seed. this is done, so * that every run of the algorithm is sorting the exact same vector. * this way, we can compare runs easily */ //std::srand( std::time(0) ); std::srand(123); /* Reserve sufficient capacity for vector once and for all */ myVec.reserve(myVec.size() + numEntries); /* fill the vector with random numbers */ for (int i = 0; i < numEntries; ++i) { myVec.push_back(std::rand()); } /* Start measuring the time */ OSCR_timer_start(0); /* sort vector in parallel */ # pragma omp parallel shared (myVec, switchThresh, numThreads) { # pragma intel omp taskq { # pragma intel omp task { myQuickSort(myVec, 0, myVec.size() - 1, switchThresh); } } } /* Finish time measurement */ OSCR_timer_stop(0); /* calculate elapsed time */ accTime = OSCR_timer_read(0); /* determine and print out, whether or not the vector was sorted ok */ if (vectorValidate(myVec)) std::cout << "\nSuccess, wall-clock time: " << accTime << "\n\n"; else std::cout << "\nSorting FAILED!" << "\n\n"; OSCR_report(); return 0; }
/** main function with initialization, command line argument parsing, * memory allocation, OpenMP setup, wall--clock time measurement. */ int main(int argc, char *argv[]) { std::vector < int >myVec; std::stack < std::pair < int, int > >globalTodoStack; int numThreads; int numEntries; int switchThresh; char *PARAM_NAMES[NUM_ARGS] = {(char *)"Number of integer to sort:", (char *)"Number of threads:", (char *)"SwitchThresh:"}; char *TIMERS_NAMES[NUM_TIMERS] = {(char *)"Total_time" }; char *DEFAULT_VALUES[NUM_ARGS] = {(char *)"100", (char *)"2", (char *)"10"}; /* this number indicates, how many threads are doing useful work atm. */ int numBusyThreads = 1; /* used for time measurements */ double accTime; /* used for performance measurements */ std::vector < int >globalStackWrite; numThreads = omp_get_max_threads(); OSCR_init (numThreads, (char *)"QuickSort", (char *)"", NUM_ARGS, PARAM_NAMES, DEFAULT_VALUES , NUM_TIMERS, NUM_TIMERS, TIMERS_NAMES, argc, argv); numEntries = OSCR_getarg_int(1); numThreads = OSCR_getarg_int(2); switchThresh = OSCR_getarg_int(3); /* initialize the performance measures */ for (int i = 0; i < numThreads; ++i) { globalStackWrite.push_back(0); } /* and run with the specified number of threads */ omp_set_num_threads(numThreads); /* initialize random number generator to fixed seed. this is done, so * that every run of the algorithm is sorting the exact same vector. * this way, we can compare runs easily */ //std::srand( std::time(0) ); std::srand(123); /* Reserve sufficient capacity for vector once and for all */ myVec.reserve(myVec.size() + numEntries); /* fill the vector with random numbers */ for (int i = 0; i < numEntries; ++i) { myVec.push_back(std::rand()); } /* Start measuring the time */ OSCR_timer_start(0); /* sort vector in parallel */ # pragma omp parallel shared(myVec, globalTodoStack, numThreads, \ switchThresh, numBusyThreads, globalStackWrite) { /* start sorting with only one thread, the others wait for the stack * to fill up */ if (0 == omp_get_thread_num()) { myQuickSort(myVec, 0, myVec.size() - 1, switchThresh, globalTodoStack, numBusyThreads, numThreads, globalStackWrite); } else { myQuickSort(myVec, 0, 0, switchThresh, globalTodoStack, numBusyThreads, numThreads, globalStackWrite); } } /* Finish time measurement */ OSCR_timer_stop(0); /* calculate elapsed time */ accTime = OSCR_timer_read(0); /* determine and print out, whether or not the vector was sorted ok */ if (vectorValidate(myVec)) std::cout << "\nSuccess, wall-clock time: " << accTime << "\n\n"; else std::cout << "\nSorting FAILED!" << "\n\n"; int globalStackWriteSum = 0; /* sum up and print out all performance measures */ for (int i = 0; i < numThreads; ++i) { globalStackWriteSum += globalStackWrite[i]; std::cout << i << ".: gSW: " << globalStackWrite[i] << "\n"; } std::cout << std:: endl << "Total: gSW: " << globalStackWriteSum << "\n\n"; OSCR_report(); return 0; }