static void bench_parmap_full(int nthreads, e_xbt_parmap_mode_t mode) { unsigned *a; xbt_dynar_t data; xbt_parmap_t parmap; int i; double start_time, elapsed_time; printf("** mode = %-15s ", parmap_mode_name(mode)); fflush(stdout); if (parmap_skip_mode(mode)) return; array_new(&a, &data); i = 0; start_time = xbt_os_time(); do { parmap = xbt_parmap_new(nthreads, mode); xbt_parmap_apply(parmap, fun_to_apply, data); xbt_parmap_destroy(parmap); elapsed_time = xbt_os_time() - start_time; i++; } while (elapsed_time < TIMEOUT); printf("ran %d times in %g seconds (%g/s)\n", i, elapsed_time, i / elapsed_time); xbt_dynar_free(&data); xbt_free(a); }
static void test_heap_mean_operation(int size) { xbt_heap_t heap = xbt_heap_new(size, NULL); double date = xbt_os_time() * 1000000; for (int i = 0; i < size; i++) xbt_heap_push(heap, NULL, (10.0 * rand() / (RAND_MAX + 1.0))); date = xbt_os_time() * 1000000 - date; printf("Creation time %d size heap : %g\n", size, date); date = xbt_os_time() * 1000000; for (int j = 0; j < MAX_TEST; j++) { if (!(j % size) && j) test_reset_heap(&heap, size); double val = xbt_heap_maxkey(heap); xbt_heap_pop(heap); xbt_heap_push(heap, NULL, 3.0 * val); } date = xbt_os_time() * 1000000 - date; printf("Mean access time for a %d size heap : %g\n", size, date * 1.0 / (MAX_TEST + 0.0)); xbt_heap_free(heap); }
/** * \brief A platform constructor. * * Creates a new platform, including hosts, links and the * routing_table. * \param file a filename of a xml description of a platform. This file * follows this DTD : * * \include surfxml.dtd * * Here is a small example of such a platform * * \include small_platform.xml * */ void SIMIX_create_environment(const char *file) { double start, end; start = xbt_os_time(); parse_platform_file(file); end = xbt_os_time(); XBT_DEBUG("PARSE TIME: %lg", (end - start)); }
/** * @brief A platform loader. * * Creates a new platform, including hosts, links, and the routing_table. * @param platf a filename of the XML description of a platform. This file follows this DTD : * * @include src/surf/xml/simgrid.dtd * * Here is a small example of such a platform * * @include examples/platforms/small_platform.xml */ void Engine::load_platform(const std::string& platf) { double start = xbt_os_time(); try { parse_platform_file(platf); } catch (xbt_ex& e) { xbt_die("Error while loading %s: %s", platf.c_str(), e.what()); } double end = xbt_os_time(); XBT_DEBUG("PARSE TIME: %g", (end - start)); }
void print_TICreateContainer(paje_event_t event) { //if we are in the mode with only one file static FILE *temp = nullptr; if (tracing_files == nullptr) { tracing_files = xbt_dict_new_homogeneous(nullptr); //generate unique run id with time prefix = xbt_os_time(); } if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || temp == nullptr) { char *folder_name = bprintf("%s_files", TRACE_get_filename()); char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, ((createContainer_t) event->data)->container->name); #ifdef WIN32 _mkdir(folder_name); #else mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO); #endif temp = fopen(filename, "w"); xbt_assert(temp, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno)); fprintf(tracing_file, "%s\n", filename); xbt_free(folder_name); xbt_free(filename); } xbt_dict_set(tracing_files, ((createContainer_t) event->data)->container->name, (void *) temp, nullptr); }
int main(int argc, char **argv) { int i, j; xbt_os_timer_t timer = xbt_os_timer_new(); SD_init(&argc, argv); SD_create_environment(argv[1]); sg_host_t *hosts = sg_host_list(); int host_count = sg_host_count(); /* Random number initialization */ srand( (int) (xbt_os_time()*1000) ); do { i = rand()%host_count; j = rand()%host_count; } while(i==j); sg_host_t h1 = hosts[i]; sg_host_t h2 = hosts[j]; printf("%d\tand\t%d\t\t",i,j); xbt_os_cputimer_start(timer); SD_route_get_list(h1, h2); xbt_os_cputimer_stop(timer); printf("%f\n", xbt_os_timer_elapsed(timer) ); xbt_free(hosts); SD_exit(); return 0; }
void test(int nb_cnst, int nb_var, int nb_elem) { lmm_system_t Sys = NULL; lmm_constraint_t *cnst = xbt_new0(lmm_constraint_t, nb_cnst); lmm_variable_t *var = xbt_new0(lmm_variable_t, nb_var); int *used = xbt_new0(int, nb_cnst); int i, j, k; Sys = lmm_system_new(1); for (i = 0; i < nb_cnst; i++) { cnst[i] = lmm_constraint_new(Sys, NULL, float_random(10.0)); } for (i = 0; i < nb_var; i++) { var[i] = lmm_variable_new(Sys, NULL, 1.0, -1.0, nb_elem); for (j = 0; j < nb_cnst; j++) used[j] = 0; for (j = 0; j < nb_elem; j++) { k = int_random(nb_cnst); if (used[k]) { j--; continue; } lmm_expand(Sys, cnst[k], var[i], float_random(1.0)); used[k] = 1; } } printf("Starting to solve\n"); date = xbt_os_time() * 1000000; lmm_solve(Sys); date = xbt_os_time() * 1000000 - date; for (i = 0; i < nb_var; i++) lmm_variable_free(Sys, var[i]); lmm_system_free(Sys); free(cnst); free(var); free(used); }
int main(int argc, char **argv) { int nb_cnst = 2000; int nb_var = 2000; int nb_elem = 80; xbt_init(&argc, argv); date = xbt_os_time() * 1000000; test(nb_cnst, nb_var, nb_elem); printf("One shot execution time for a total of %d constraints, " "%d variables with %d active constraint each : %g microsecondes \n", nb_cnst, nb_var, nb_elem, date); return 0; }
double xbt_time(void) { return xbt_os_time(); }
static void test(int nb_cnst, int nb_var, int nb_elem, unsigned int pw_base_limit, unsigned int pw_max_limit, float rate_no_limit, int max_share, int mode) { lmm_system_t Sys = NULL; lmm_constraint_t *cnst = xbt_new0(lmm_constraint_t, nb_cnst); lmm_variable_t *var = xbt_new0(lmm_variable_t, nb_var); int *used = xbt_new0(int, nb_cnst); int i; int j; int k; int l; int concurrency_share; Sys = lmm_system_new(1); for (i = 0; i < nb_cnst; i++) { cnst[i] = lmm_constraint_new(Sys, NULL, float_random(10.0)); if(rate_no_limit>float_random(1.0)) //Look at what happens when there is no concurrency limit l=-1; else //Badly logarithmically random concurrency limit in [2^pw_base_limit+1,2^pw_base_limit+2^pw_max_limit] l=(1<<pw_base_limit)+(1<<int_random(pw_max_limit)); lmm_constraint_concurrency_limit_set(cnst[i],l ); } for (i = 0; i < nb_var; i++) { var[i] = lmm_variable_new(Sys, NULL, 1.0, -1.0, nb_elem); //Have a few variables with a concurrency share of two (e.g. cross-traffic in some cases) concurrency_share=1+int_random(max_share); lmm_variable_concurrency_share_set(var[i],concurrency_share); for (j = 0; j < nb_cnst; j++) used[j] = 0; for (j = 0; j < nb_elem; j++) { k = int_random(nb_cnst); if (used[k]>=concurrency_share) { j--; continue; } lmm_expand(Sys, cnst[k], var[i], float_random(1.5)); lmm_expand_add(Sys, cnst[k], var[i], float_random(1.5)); used[k]++; } } fprintf(stderr,"Starting to solve(%i)\n",myrand()%1000); date = xbt_os_time() * 1000000; lmm_solve(Sys); date = xbt_os_time() * 1000000 - date; if(mode==2){ fprintf(stderr,"Max concurrency:\n"); l=0; for (i = 0; i < nb_cnst; i++) { j=lmm_constraint_concurrency_maximum_get(cnst[i]); k=lmm_constraint_concurrency_limit_get(cnst[i]); xbt_assert(k<0 || j<=k); if(j>l) l=j; fprintf(stderr,"(%i):%i/%i ",i,j,k); lmm_constraint_concurrency_maximum_reset(cnst[i]); xbt_assert(!lmm_constraint_concurrency_maximum_get(cnst[i])); if(i%10==9) fprintf(stderr,"\n"); } fprintf(stderr,"\nTotal maximum concurrency is %i\n",l); lmm_print(Sys); } for (i = 0; i < nb_var; i++) lmm_variable_free(Sys, var[i]); lmm_system_free(Sys); free(cnst); free(var); free(used); }