示例#1
0
int smpi_sample_2(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("sample2 %s",loc);
  free(loc);

  if (data->benching==1) {
    // we need to run a new bench
    XBT_DEBUG("benchmarking: count:%d iter:%d stderr:%f thres:%f; mean:%f",
        data->count, data->iters, data->relstderr, data->threshold, data->mean);
    smpi_bench_begin();
    return 1;
  } else {
    // Enough data, no more bench (either we got enough data from previous visits to this benched nest, or we just ran one bench and need to bail out now that our job is done).
    // Just sleep instead
    XBT_DEBUG("No benchmark (either no need, or just ran one): count >= iter (%d >= %d) or stderr<thres (%f<=%f). apply the %fs delay instead",
        data->count, data->iters, data->relstderr, data->threshold, data->mean);
    smpi_execute(data->mean);

    smpi_bench_begin(); // prepare to capture future, unrelated computations
    return 0;
  }
}
示例#2
0
unsigned int smpi_sleep(unsigned int secs)
{
  smpi_bench_end();
  smpi_execute((double) secs);
  smpi_bench_begin();
  return secs;
}
示例#3
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));
}
示例#4
0
int smpi_sample_2(int global, const char *file, int line)
{
  char *loc = sample_location(global, file, line);
  local_data_t *data;

  xbt_assert(samples, "You did something very inconsistent, didn't you?");
  data = xbt_dict_get_or_null(samples, loc);
  if (!data) {
    xbt_assert(data, "Please, do thing in order");
  }
  if (!data->started) {
    if ((data->iters > 0 && data->count >= data->iters)
        || (data->count > 1 && data->threshold > 0.0 && data->relstderr <= data->threshold)) {
      XBT_DEBUG("Perform some wait of %f", data->mean);
      smpi_execute(data->mean);
    } else {
      data->started = 1;
      data->count++;
    }
  } else {
    data->started = 0;
  }
  free(loc);
  smpi_bench_begin();
  smpi_process_simulated_start();
  return data->started;
}
示例#5
0
  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();
  }
示例#6
0
void Timer::simulateComputeTime(bool doComm, compute_t *_exec) {
  int sleep_duration = 0;

  comp_time = sleep_duration = getCompTime();

#ifdef SMPI_SIMULATION_ACTIVATED
  #ifdef SMPI_SIMULATION_TIME_INDEPENDENT
  long long flops = getNumInst();
  if (flops < 0) {
	cerr << "PAPI num instruction overflow!" << endl;
	exit(1);
  }
  //cout << "Simulating " << flops*1000.0 << " flops" << endl;
  smpi_execute_flops(flops*1000.0);	// Re-multiplying by 1000 (we had divided to avoid overflows)
  #else
  smpi_execute((double)comp_time / 1000000.0);
  #endif
  leftover = 0;
#else
  if(doComm)
    sleep_duration += getCommTime();
  sleep_duration -= getTime ();
  sleep_duration += leftover;
  /*if(my_rank == doTestFor){
		cout << comp_time << "   " << sleep_duration << endl;
	}*/

  if(sleep_duration > 0 && _exec){
    ( *(_exec->func) )( _exec->param );
    sleep_duration = getCompTime();
    if(doComm)
      sleep_duration += getCommTime();
    sleep_duration -= getTime();
    sleep_duration += leftover;
  }
  leftover = 0;

  if (sleep_duration > 0){
    leftover = busyWait(sleep_duration);
  } else {
    leftover = sleep_duration;
  }
#endif
}
示例#7
0
unsigned int smpi_sleep(unsigned int secs)
{
  smpi_execute((double) secs);
  return secs;
}