int main (int argc, char **argv) { if (argc != 1) { nthreads = atoi(argv[1]); degree = nthreads; // flat phaser by default if (argc > 2) degree = atoi(argv[2]); delaylength = 0; innerreps = 1000000; if (argc > 3) delaylength = atoi(argv[3]); } else { // TODO should get number of workers here int nthreads = 3; degree = nthreads; // flat phaser by default delaylength = 0; innerreps = 1000000; } printf(" Running phaser barrier benchmark on %d thread(s) and phaser tree degree %d\n", nthreads, degree); /* GENERATE REFERENCE TIME */ refer(); /* TEST BARRIER */ hclib_init(&argc, argv); testbar(); hclib_finalize(); return 0; }
int main (int argc, char ** argv) { printf("Call Init\n"); hclib_init(&argc, argv); int i = 0; int *ran=(int *)malloc(H1*H2*sizeof(int)); // This is ok to have these on stack because this // code is alive until the end of the program. init_ran(ran, H1*H2); loop_domain_t loop0 = {0,H1,1,T1}; loop_domain_t loop1 = {0,H2,1,T2}; loop_domain_t loop[2] = {loop0, loop1}; forasync(forasync_fct2,(void*)(ran),NULL, NULL,NULL,2,loop, FORASYNC_MODE_FLAT); printf("Call Finalize\n"); hclib_finalize(); printf("Check results: "); i=0; while(i < H1*H2) { assert(ran[i] == i); i++; } printf("OK\n"); return 0; }
int main (int argc, char ** argv) { printf("Call Init\n"); hclib_init(&argc, argv); int i = 0; // This is ok to have these on stack because this // code is alive until the end of the program. int indices [NB_ASYNC]; init_ran(ran, NB_ASYNC); while(i < NB_ASYNC) { indices[i] = i; //Note: Forcefully pass the address we want to write to as a void ** async(async_fct, (void*) (indices+i), NULL, NULL, NO_PROP); i++; } printf("Call Finalize\n"); hclib_finalize(); printf("Check results: "); i=0; while(i < NB_ASYNC) { assert(ran[i] == i); i++; } printf("OK\n"); return 0; }
int main (int argc, char ** argv) { hclib_init(&argc, argv); phaser_t ph; phaser_create(&ph, SIGNAL_WAIT, 2); phaser_mode_t mode = SIGNAL_WAIT; phased_t phased; phased.count = 1; phased.phasers = &ph; phased.phasers_mode = &mode; async(&barrier_test, NULL, NULL, &phased, 0); phaser_drop(ph); // current worker enters in helper mode // and will pick up one of the tasks hclib_finalize(); return 0; }
void hclib_launch(generic_frame_ptr fct_ptr, void *arg, const char **deps, int ndeps) { unsigned long long start_time = 0; unsigned long long end_time; const int instrument = (getenv("HCLIB_INSTRUMENT") != NULL); hclib_init(deps, ndeps, instrument); if (profile_launch_body) { start_time = current_time_ns(); } hclib_async(fct_ptr, arg, NULL, 0, hclib_get_closest_locale()); hclib_finalize(instrument); if (profile_launch_body) { end_time = current_time_ns(); printf("\nHCLIB TIME %llu ns\n", end_time - start_time); } }
int main (int argc, char ** argv) { hclib_init(); // TODO should get number of workers here int nthreads = 3; int degree = nthreads; int i; phaser_t ph; phaser_create(&ph, SIGNAL_WAIT, degree); for(i = 1; i < nthreads; ++i) { printf("Create async %d\n", i); async(&barrier_test, NULL, NULL, NULL, PHASER_TRANSMIT_ALL); } // Participate in the barrier barrier_test(NULL); // current worker enters in helper mode // and will pick up one of the tasks hclib_finalize(); return 0; }
int main (int argc, char ** argv) { hclib_init(&argc, argv); // TODO should get number of workers here int nthreads = 3; int degree = nthreads; int i; phaser_t ph; phaser_create(&ph, SIGNAL_WAIT, degree); for(i = 0; i < nthreads; ++i) { printf("Create async %d\n", i); async(&barrier_test, NULL, NULL, NULL, PHASER_TRANSMIT_ALL); } printf("Dropping\n"); // Dropping here unlocks child activities next phaser_drop(ph); // current worker enters in helper mode // and will pick up one of the tasks hclib_finalize(); return 0; }
void shmem_workers_finalize() { hclib_end_finish(); hclib_finalize(); }