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 smpi_sample_3(int global, const char *file, int line) { char *loc = sample_location(global, file, line); local_data_t *data; xbt_assert(samples, "Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!"); data = xbt_dict_get(samples, loc); XBT_DEBUG("sample3 %s",loc); if (data->benching==0) { THROW_IMPOSSIBLE; } // ok, benchmarking this loop is over xbt_os_timer_stop(smpi_process_timer()); // update the stats double sample, n; data->count++; sample = xbt_os_timer_elapsed(smpi_process_timer()); data->sum += sample; data->sum_pow2 += sample * sample; n = (double)data->count; data->mean = data->sum / n; data->relstderr = sqrt((data->sum_pow2 / n - data->mean * data->mean) / n) / data->mean; if (!sample_enough_benchs(data)) { data->mean = sample; // Still in benching process; We want sample_2 to simulate the exact time of this loop occurrence before leaving, not the mean over the history } XBT_DEBUG("Average mean after %d steps is %f, relative standard error is %f (sample was %f)", data->count, data->mean, data->relstderr, sample); // That's enough for now, prevent sample_2 to run the same code over and over data->benching = 0; }
void smpi_bench_end(void) { xbt_os_timer_t timer = smpi_process_timer(); xbt_os_timer_stop(timer); smpi_execute(xbt_os_timer_elapsed(timer)); }
int main(int argc, char **argv) { char *platformFile = NULL; unsigned int totalHosts, totalLinks; int timings=0; int version = 4; const char *link_ctn = "link_ctn"; unsigned int i; xbt_dict_t props = NULL; xbt_dict_cursor_t cursor = NULL; xbt_lib_cursor_t cursor_src = NULL; xbt_lib_cursor_t cursor_dst = NULL; char *src,*dst,*key,*data; sg_netcard_t value1; sg_netcard_t value2; const sg_host_t *hosts; const SD_link_t *links; xbt_os_timer_t parse_time = xbt_os_timer_new(); SD_init(&argc, argv); if (parse_cmdline(&timings, &platformFile, argc, argv) || !platformFile) { xbt_die("Invalid command line arguments: expected [--timings] platformFile"); } XBT_DEBUG("%d,%s", timings, platformFile); create_environment(parse_time, platformFile); if (timings) { XBT_INFO("Parsing time: %fs (%zu hosts, %d links)", xbt_os_timer_elapsed(parse_time), sg_host_count(), sg_link_count()); } else { printf("<?xml version='1.0'?>\n"); printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n"); printf("<platform version=\"%d\">\n", version); printf("<AS id=\"AS0\" routing=\"Full\">\n"); // Hosts totalHosts = sg_host_count(); hosts = sg_host_list(); qsort((void *) hosts, totalHosts, sizeof(sg_host_t), name_compare_hosts); for (i = 0; i < totalHosts; i++) { printf(" <host id=\"%s\" speed=\"%.0f\"", sg_host_get_name(hosts[i]), sg_host_speed(hosts[i])); props = sg_host_get_properties(hosts[i]); if (sg_host_core_count(hosts[i])>1) { printf(" core=\"%d\"", sg_host_core_count(hosts[i])); } if (props && !xbt_dict_is_empty(props)) { printf(">\n"); xbt_dict_foreach(props, cursor, key, data) { printf(" <prop id=\"%s\" value=\"%s\"/>\n", key, data); } printf(" </host>\n"); } else {
void kernel(simgrid::xbt::ReplayAction&) { static std::map<simgrid::s4u::ActorPtr, int> migration_call_counter; static simgrid::s4u::Barrier smpilb_bar(smpi_process_count()); simgrid::s4u::Host* cur_host = simgrid::s4u::this_actor::get_host(); simgrid::s4u::Host* migrate_to_host; TRACE_migration_call(my_proc_id, nullptr); // We only migrate every "cfg_migration_frequency"-times, not at every call migration_call_counter[simgrid::s4u::Actor::self()]++; if ((migration_call_counter[simgrid::s4u::Actor::self()] % simgrid::config::get_value<int>(cfg_migration_frequency.get_name())) != 0) { return; } // TODO cheinrich: Why do we need this barrier? smpilb_bar.wait(); static bool was_executed = false; if (not was_executed) { was_executed = true; XBT_DEBUG("Process %li runs the load balancer", my_proc_id); smpi_bench_begin(); lb.run(); smpi_bench_end(); } // This barrier is required to ensure that the mapping has been computed and is available smpilb_bar.wait(); was_executed = false; // Must stay behind this barrier so that all processes have passed the if clause migrate_to_host = lb.get_mapping(simgrid::s4u::Actor::self()); if (cur_host != migrate_to_host) { // Origin and dest are not the same -> migrate std::vector<simgrid::s4u::Host*> migration_hosts = {cur_host, migrate_to_host}; std::vector<double> comp_amount = {0, 0}; std::vector<double> comm_amount = {0, /*must not be 0*/ std::max(args.memory_consumption, 1.0), 0, 0}; xbt_os_timer_t timer = smpi_process()->timer(); xbt_os_threadtimer_start(timer); simgrid::s4u::this_actor::parallel_execute(migration_hosts, comp_amount, comm_amount, -1.0); xbt_os_threadtimer_stop(timer); smpi_execute(xbt_os_timer_elapsed(timer)); // Update the process and host mapping in SimGrid. XBT_DEBUG("Migrating process %li from %s to %s", my_proc_id, cur_host->get_cname(), migrate_to_host->get_cname()); TRACE_smpi_process_change_host(my_proc_id, migrate_to_host); simgrid::s4u::this_actor::migrate(migrate_to_host); } smpilb_bar.wait(); smpi_bench_begin(); }
int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *argv[]) { srand(SMPI_RAND_SEED); if (getenv("SMPI_PRETEND_CC") != NULL) { /* Hack to ensure that smpicc can pretend to be a simple compiler. Particularly handy to pass it to the * configuration tools */ return 0; } smpi_init_logs(); TRACE_global_init(&argc, argv); TRACE_add_start_function(TRACE_smpi_alloc); TRACE_add_end_function(TRACE_smpi_release); SIMIX_global_init(&argc, argv); MSG_init(&argc,argv); SMPI_switch_data_segment = smpi_switch_data_segment; smpi_init_options(); // parse the platform file: get the host list SIMIX_create_environment(argv[1]); SIMIX_comm_set_copy_data_callback(&smpi_comm_copy_buffer_callback); SIMIX_function_register_default(realmain); SIMIX_launch_application(argv[2]); smpi_global_init(); smpi_check_options(); if(smpi_privatize_global_variables) smpi_initialize_global_memory_segments(); /* Clean IO before the run */ fflush(stdout); fflush(stderr); if (MC_is_active()) { MC_run(); } else { SIMIX_run(); xbt_os_walltimer_stop(global_timer); if (xbt_cfg_get_boolean("smpi/display-timing")){ double global_time = xbt_os_timer_elapsed(global_timer); XBT_INFO("Simulated time: %g seconds. \n\n" "The simulation took %g seconds (after parsing and platform setup)\n" "%g seconds were actual computation of the application", SIMIX_get_clock(), global_time , smpi_total_benched_time); if (smpi_total_benched_time/global_time>=0.75) XBT_INFO("More than 75%% of the time was spent inside the application code.\n" "You may want to use sampling functions or trace replay to reduce this."); } } int count = smpi_process_count(); int i, ret=0; for (i = 0; i < count; i++) { if(process_data[i]->return_value!=0){ ret=process_data[i]->return_value;//return first non 0 value break; } } smpi_global_destroy(); TRACE_end(); return ret; }
void RawContectFactory::run_all_adaptative() { unsigned long nb_processes = xbt_dynar_length(simix_global->process_to_run); unsigned long threshold = SIMIX_context_get_parallel_threshold(); reached_seq_limit = (seq_sched_round % SCHED_ROUND_LIMIT == 0); reached_par_limit = (par_sched_round % SCHED_ROUND_LIMIT == 0); if(reached_seq_limit && reached_par_limit){ par_ratio = (par_proc_that_ran != 0) ? (par_time / (double)par_proc_that_ran) : 0; seq_ratio = (seq_proc_that_ran != 0) ? (seq_time / (double)seq_proc_that_ran) : 0; if(seq_ratio > par_ratio){ if(nb_processes < avg_par_proc) { threshold = (threshold>2) ? threshold - 1 : threshold ; SIMIX_context_set_parallel_threshold(threshold); } } else { if(nb_processes > avg_seq_proc){ SIMIX_context_set_parallel_threshold(threshold+1); } } } if (nb_processes >= SIMIX_context_get_parallel_threshold()) { simix_global->context_factory->suspend = smx_ctx_raw_suspend_parallel; if (nb_processes < par_window){ par_sched_round++; xbt_os_walltimer_start(round_time); smx_ctx_raw_runall_parallel(); xbt_os_walltimer_stop(round_time); par_time += xbt_os_timer_elapsed(round_time); prev_avg_par_proc = avg_par_proc; delta = nb_processes - avg_par_proc; avg_par_proc = (par_sched_round==1) ? nb_processes : avg_par_proc + delta / (double) par_sched_round; if(par_sched_round>=2){ s_par_proc = s_par_proc + (nb_processes - prev_avg_par_proc) * delta; sd_par_proc = sqrt(s_par_proc / (par_sched_round-1)); par_window = (int) (avg_par_proc + sd_par_proc); }else{ sd_par_proc = 0; } par_proc_that_ran += nb_processes; } else{ smx_ctx_raw_runall_parallel(); } } else { simix_global->context_factory->suspend = smx_ctx_raw_suspend_serial; if(nb_processes > seq_window){ seq_sched_round++; xbt_os_walltimer_start(round_time); smx_ctx_raw_runall_serial(); xbt_os_walltimer_stop(round_time); seq_time += xbt_os_timer_elapsed(round_time); prev_avg_seq_proc = avg_seq_proc; delta = (nb_processes-avg_seq_proc); avg_seq_proc = (seq_sched_round==1) ? nb_processes : avg_seq_proc + delta / (double) seq_sched_round; if(seq_sched_round>=2){ s_seq_proc = s_seq_proc + (nb_processes - prev_avg_seq_proc)*delta; sd_seq_proc = sqrt(s_seq_proc / (seq_sched_round-1)); seq_window = (int) (avg_seq_proc - sd_seq_proc); } else { sd_seq_proc = 0; } seq_proc_that_ran += nb_processes; } else { smx_ctx_raw_runall_serial(); } } }
int main(int argc, char **argv) { char *platformFile = NULL; int totalHosts, totalLinks; int timings=0; int downgrade = 0; int version = 3; const char *link_ctn = link_ctn_v3; unsigned int i; xbt_dict_t props = NULL; xbt_dict_cursor_t cursor = NULL; xbt_lib_cursor_t cursor_src = NULL; xbt_lib_cursor_t cursor_dst = NULL; char *src,*dst,*key,*data; sg_routing_edge_t value1; sg_routing_edge_t value2; const SD_workstation_t *hosts; const SD_link_t *links; xbt_os_timer_t parse_time = xbt_os_timer_new(); setvbuf(stdout, NULL, _IOLBF, 0); SD_init(&argc, argv); if (parse_cmdline(&timings, &downgrade, &platformFile, argc, argv) || !platformFile) { xbt_die("Invalid command line arguments: expected [--timings|--downgrade] platformFile"); } XBT_DEBUG("%d,%d,%s", timings, downgrade, platformFile); if (downgrade) { version = 2; link_ctn = link_ctn_v2; } create_environment(parse_time, platformFile); if (timings) { XBT_INFO("Parsing time: %fs (%d hosts, %d links)", xbt_os_timer_elapsed(parse_time),SD_workstation_get_number(),SD_link_get_number()); } else { printf("<?xml version='1.0'?>\n"); printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n"); printf("<platform version=\"%d\">\n", version); if (!downgrade) printf("<AS id=\"AS0\" routing=\"Full\">\n"); // Hosts totalHosts = SD_workstation_get_number(); hosts = SD_workstation_get_list(); qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t), name_compare_hosts); for (i = 0; i < totalHosts; i++) { printf(" <host id=\"%s\" power=\"%.0f\"", SD_workstation_get_name(hosts[i]), SD_workstation_get_power(hosts[i])); props = SD_workstation_get_properties(hosts[i]); if (props && !xbt_dict_is_empty(props)) { printf(">\n"); xbt_dict_foreach(props, cursor, key, data) { printf(" <prop id=\"%s\" value=\"%s\"/>\n", key, data); } printf(" </host>\n"); } else {