int main(int argc, char** argv) { int nproc = 64; int npartners = 4; int niterations = 2; int nresults = nproc*npartners*niterations; int nparams = 2; int njobs = 4; const char* param_names[] = { "injection_bandwidth", "network_bandwidth", }; double** param_values = allocate_values(njobs, nparams); double** results = allocate_results(njobs, nresults); double inj_bws[] = { 1.0, 1.0 }; int nInj = sizeof(inj_bws) / sizeof(double); double net_bws[] = { 1.0, 1.0 }; int nNet = sizeof(net_bws) / sizeof(double); const char* units[] = { "GB/s", "GB/s" }; int job = 0; int i,j; for (i=0; i < nInj; ++i){ for (j=0; j < nNet; ++j, ++job){ param_values[job][0] = inj_bws[i]; param_values[job][1] = net_bws[j]; } } void* queue = sstmac_uq_init(argc, argv); int max_nthread = 1; sstmac_uq_run_units(queue, njobs, nparams, nresults, max_nthread, param_names, param_values, units, results); for (job=0; job < njobs; ++job){ debug_print("Job %d: {\n", job); for (i=0; i < nresults; ++i){ double bw = results[job][i]; debug_print(" %12.8fGB/s\n", bw); if (bw < 0.1 || bw > 1.0){ printf("UQ test failed: got invalid bandwidths\n"); return 1; } } debug_print("}\n"); } printf("UQ test passed: got all valid bandwidths\n"); return 0; }
int main (int argc, char *argv[]) { int N; int i; pthread_t *tids; struct args *args_array; if (argc != 3) { fprintf (stderr, "Wrong number of arguments\n"); printf ("Correct usage: %s <base> <final exponent>\n", argv[0]); exit(1); } N = atoi(argv[2]); // Read the upper limit of the sum N = N+1; // so that the sum actually runs from 0 to N instead of from 0 to N-1 if (N <=0) { fprintf (stderr, "The upper limit must be positive\n"); exit(1); } sscanf(argv[1], "%f", &base); results = allocate_results(N); args_array = allocate_args(N); tids = allocate_tids(N); // Assign values to the args of the runner function for (i = 0; i < N; i += 1) { args_array[i].tid = i; } for (i = 0; i < N; i += 1) { if (pthread_create(&tids[i], NULL, runner, (void *) &args_array[i])) { fprintf (stderr, "Error during creation of a thread\n"); exit(1); } } for (i = 0; i < N; i += 1) { pthread_join(tids[i], NULL); } // This is not required for (i = 0; i < N; i += 1) { printf("The result of %g to the %d is %g\n", base, i, results[i]); sum+=results[i]; } // Final result printf("The sum is %g\n", sum); return 0; }