コード例 #1
0
ファイル: priority.c プロジェクト: cemsbr/simgrid
static msg_error_t test_all(const char *platform_file,
                            const char *application_file)
{
  msg_error_t res = MSG_OK;

  {                             /*  Simulation setting */
    MSG_create_environment(platform_file);
  }
  {                             /*   Application deployment */
    MSG_function_register("test", test);
    MSG_launch_application(application_file);
  }
  res = MSG_main();

  XBT_INFO("Simulation time %g", MSG_get_clock());
  return res;
}
コード例 #2
0
ファイル: bugged1.c プロジェクト: Shurakai/SimGrid
int server(int argc, char *argv[])
{
  msg_task_t task = NULL;
  int count = 0;
  while (count < N) {
    if (task) {
      MSG_task_destroy(task);
      task = NULL;
    }
    MSG_task_receive(&task, "mymailbox");
    count++;
  }
  MC_assert(atoi(MSG_task_get_name(task)) == 3);

  XBT_INFO("OK");
  return 0;
}
コード例 #3
0
ファイル: bugged1.c プロジェクト: R7R8/simgrid
static int server(int argc, char *argv[])
{
  msg_task_t task = NULL;
  int count = 0;
  while (count < N) {
    if (task) {
      MSG_task_destroy(task);
      task = NULL;
    }
    MSG_task_receive(&task, "mymailbox");
    count++;
  }
  MC_assert(xbt_str_parse_int(MSG_task_get_name(task), "Task names must be integers, not '%s'") == 3);

  XBT_INFO("OK");
  return 0;
}
コード例 #4
0
ファイル: task-priority.c プロジェクト: mpoquet/simgrid
int main(int argc, char* argv[])
{
  MSG_init(&argc, argv);
  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
                       "\tExample: %s msg_platform.xml msg_deployment.xml\n",
             argv[0], argv[0]);

  MSG_create_environment(argv[1]);
  MSG_function_register("test", test);
  MSG_launch_application(argv[2]);

  msg_error_t res = MSG_main();

  XBT_INFO("Simulation time %g", MSG_get_clock());

  return res != MSG_OK;
}
コード例 #5
0
int main(int argc, char *argv[])
{
  msg_error_t res = MSG_OK;

  MSG_init(&argc, argv);
  xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);

  MSG_create_environment(argv[1]);  /* - Load the platform description */
  MSG_function_register("dream_master", dream_master); /* - Create and deploy the dream_master */
  xbt_dynar_t hosts = MSG_hosts_as_dynar();
  MSG_process_create("dream_master", dream_master, NULL, xbt_dynar_getfirst_as(hosts, msg_host_t));
  xbt_dynar_free(&hosts);
  res = MSG_main();                 /* - Run the simulation */

  XBT_INFO("Simulation time %g", MSG_get_clock());
  return res != MSG_OK;
}
コード例 #6
0
ファイル: s4u-synchro-mutex.cpp プロジェクト: simgrid/simgrid
static void master()
{
  int result = 0;
  simgrid::s4u::MutexPtr mutex = simgrid::s4u::Mutex::create();

  for (int i = 0; i < NB_ACTOR * 2 ; i++) {
    // To create a worker use the static method simgrid::s4u::Actor.
    if((i % 2) == 0 )
      simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Jupiter"), workerLockGuard, mutex,
                                  std::ref(result));
    else
      simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Tremblay"), worker, mutex, std::ref(result));
  }

  simgrid::s4u::this_actor::sleep_for(10);
  XBT_INFO("Results is -> %d", result);
}
コード例 #7
0
ファイル: extracttrace.c プロジェクト: congfairy/simulator
static void simread(const char *const *action) {
  const char *processid = action[0];
  const char *file_name = action[2];
  const char *index = action[4];
  const char *position_str =action[5];
  const char *size_str = action[6];
  msg_file_t file = NULL;
  sg_size_t size = parse_size(size_str);
  sg_offset_t position= parse_offset(position_str);
  double clock = MSG_get_clock();       /* this "call" is free thanks to inlining */
  file = get_file_descriptor(file_name,index);
  ACT_DEBUG("Entering Read: %s (size: %llu)", NAME, size);
  MSG_file_seek(file,position,SEEK_SET);
  MSG_file_read(file, size);
  log_action(action, MSG_get_clock() - clock);
  XBT_INFO("read  worker %s%s is done",processid,index);
}
コード例 #8
0
ファイル: 10-rpc.c プロジェクト: rosacris/simgrid
int server_convert_a2i_cb(gras_msg_cb_ctx_t ctx, void *payload)
{
  char *string = *(char **) payload;
  long result;
  char *p;

  XBT_INFO("Convert %s to long", string);
  result = strtol(string, &p, 10);

  if (*p != '\0')
    THROWF(arg_error, 0,
           "Error while converting %s: this does not seem to be a valid number (problem at '%s')",
           string, p);

  gras_msg_rpcreturn(60, ctx, &result);
  return 0;
}                               /* end_of_convert_callback */
コード例 #9
0
ファイル: energy-pstate.c プロジェクト: mpoquet/simgrid
int main(int argc, char* argv[])
{
  MSG_init(&argc, argv);

  xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);

  MSG_create_environment(argv[1]);

  MSG_process_create("dvfs_test", dvfs, NULL, MSG_get_host_by_name("MyHost1"));
  MSG_process_create("dvfs_test", dvfs, NULL, MSG_get_host_by_name("MyHost2"));

  msg_error_t res = MSG_main();

  XBT_INFO("Total simulation time: %e", MSG_get_clock());

  return res != MSG_OK;
}
コード例 #10
0
ファイル: LivenessChecker.cpp プロジェクト: R7R8/simgrid
void LivenessChecker::showAcceptanceCycle(std::size_t depth)
{
  XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
  XBT_INFO("|             ACCEPTANCE CYCLE            |");
  XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
  XBT_INFO("Counter-example that violates formula :");
  simgrid::mc::dumpRecordPath();
  for (auto& s : this->getTextualTrace())
    XBT_INFO("%s", s.c_str());
  simgrid::mc::session->logState();
  XBT_INFO("Counter-example depth : %zd", depth);
}
コード例 #11
0
static int master(int argc, char *argv[])
{
  double task_comp_size = 5E7;
  double task_comm_size = 1E6;
  double timeout = 1;

  const char * mailbox = "jupi";

  msg_task_t task = MSG_task_create("normal", task_comp_size, task_comm_size, NULL);
  XBT_INFO("Sending task: \"%s\"", task->name);
  MSG_task_send_with_timeout(task, mailbox, timeout);

  task = MSG_task_create("cancel directly", task_comp_size, task_comm_size, NULL);
  XBT_INFO("Canceling task \"%s\" directly", task->name);
  MSG_task_cancel(task);
  MSG_task_destroy(task);

  task = MSG_task_create("destroy directly", task_comp_size, task_comm_size, NULL);
  XBT_INFO("Destroying task \"%s\" directly", task->name);
  MSG_task_destroy(task);

  task = MSG_task_create("cancel", task_comp_size, task_comm_size, NULL);
  msg_comm_t comm = MSG_task_isend(task, mailbox);
  XBT_INFO("Canceling task \"%s\" during comm", task->name);
  MSG_task_cancel(task);
  try {
    MSG_comm_wait(comm, -1);
  }
  catch (xbt_ex& ex) {;
    MSG_comm_destroy(comm);
  }
  MSG_task_destroy(task);

  task = MSG_task_create("finalize", task_comp_size, task_comm_size, NULL);
  comm = MSG_task_isend(task, mailbox);
  XBT_INFO("Destroying task \"%s\" during comm", task->name);
  MSG_task_destroy(task);
  try {
    MSG_comm_wait(comm, -1);
  }
  catch (xbt_ex& ex) {;
    MSG_comm_destroy(comm);
  }

  task = MSG_task_create("cancel", task_comp_size, task_comm_size, NULL);
  MSG_task_send_with_timeout(task, mailbox, timeout);

  task = MSG_task_create("finalize", task_comp_size, task_comm_size, NULL);
  MSG_task_send_with_timeout(task, mailbox, timeout);

  XBT_INFO("Goodbye now!");
  return 0;
}
コード例 #12
0
ファイル: sendrecv.c プロジェクト: Shurakai/SimGrid
/** Receiver function  */
int receiver(int argc, char *argv[])
{
  double time, time1, sender_time;
  msg_task_t task_la = NULL;
  msg_task_t task_bw = NULL;
  int a;
  double communication_time = 0;

  XBT_INFO("receiver");

  time = MSG_get_clock();

  /* Get Latency */
  a = MSG_task_receive(&task_la,MSG_host_get_name(MSG_host_self()));
  if (a == MSG_OK) {
    time1 = MSG_get_clock();
    sender_time = *((double *) (task_la->data));
    time = sender_time;
    communication_time = time1 - time;
    XBT_INFO("Task received : %s", task_la->name);
    xbt_free(task_la->data);
    MSG_task_destroy(task_la);
    XBT_INFO("Communic. time %le", communication_time);
    XBT_INFO("--- la %f ----", communication_time);
  } else {
    xbt_die("Unexpected behavior");
  }


  /* Get Bandwidth */
  a = MSG_task_receive(&task_bw,MSG_host_get_name(MSG_host_self()));
  if (a == MSG_OK) {
    time1 = MSG_get_clock();
    sender_time = *((double *) (task_bw->data));
    time = sender_time;
    communication_time = time1 - time;
    XBT_INFO("Task received : %s", task_bw->name);
    xbt_free(task_bw->data);
    MSG_task_destroy(task_bw);
    XBT_INFO("Communic. time %le", communication_time);
    XBT_INFO("--- bw %f ----", task_comm_size_bw / communication_time);
  } else {
    xbt_die("Unexpected behavior");
  }


  return 0;
}                               /* end_of_receiver */
コード例 #13
0
ファイル: vm_hl13.cpp プロジェクト: congfairy/simgrid
VMHL13::VMHL13(VMModelPtr model, const char* name, xbt_dict_t props,
		                                   surf_resource_t host_PM)
 : VM(model, name, props, NULL, NULL)
{
  HostPtr sub_ws = static_cast<HostPtr>(surf_host_resource_priv(host_PM));

  /* Currently, we assume a VM has no storage. */
  p_storage = NULL;

  /* Currently, a VM uses the network resource of its physical host. In
   * host_lib, this network resource object is referred from two different keys.
   * When deregistering the reference that points the network resource object
   * from the VM name, we have to make sure that the system does not call the
   * free callback for the network resource object. The network resource object
   * is still used by the physical machine. */
  p_netElm = new RoutingEdgeWrapper(static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, sub_ws->getName(), ROUTING_HOST_LEVEL)));
  xbt_lib_set(host_lib, name, ROUTING_HOST_LEVEL, p_netElm);

  p_subWs = sub_ws;
  p_currentState = SURF_VM_STATE_CREATED;

  // //// CPU  RELATED STUFF ////
  // Roughly, create a vcpu resource by using the values of the sub_cpu one.
  CpuCas01Ptr sub_cpu = static_cast<CpuCas01Ptr>(surf_cpu_resource_priv(host_PM));

  /* We can assume one core and cas01 cpu for the first step.
   * Do xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu) if you get the resource. */

  p_cpu = surf_cpu_model_vm->createCpu(name, // name
      sub_cpu->getPowerPeakList(),        // host->power_peak,
      sub_cpu->getPState(),
      1,                          // host->power_scale,
      NULL,                       // host->power_trace,
      1,                          // host->core_amount,
      SURF_RESOURCE_ON,           // host->initial_state,
      NULL,                       // host->state_trace,
      NULL);                       // host->properties,

  /* We create cpu_action corresponding to a VM process on the host operating system. */
  /* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
  // vm_ws->cpu_action = surf_cpu_model_pm->extension.cpu.execute(host_PM, GUESTOS_NOISE);
  p_action = sub_cpu->execute(0);

  XBT_INFO("Create VM(%s)@PM(%s) with %ld mounted disks", name, sub_ws->getName(), xbt_dynar_length(p_storage));
}
コード例 #14
0
ファイル: run_context.c プロジェクト: Shurakai/SimGrid
static void rctx_armageddon_kill_one(rctx_t initiator, const char *filepos,
                                     rctx_t rctx)
{
  if (rctx != initiator) {
    XBT_INFO("Kill <%s> because <%s> failed", rctx->filepos, filepos);
    xbt_os_mutex_acquire(rctx->interruption);
    if (!rctx->reader_done) {
      rctx->interrupted = 1;
      kill(rctx->pid, SIGTERM);
      struct timespec ts;
      ts.tv_sec = 0;
      ts.tv_nsec = (100e-6 - floor(100e-6)) * 1e9;
      nanosleep (&ts, NULL);
      kill(rctx->pid, SIGKILL);
    }
    xbt_os_mutex_release(rctx->interruption);
  }
}
コード例 #15
0
ファイル: energy-vm.c プロジェクト: R7R8/simgrid
int main(int argc, char *argv[])
{
  msg_error_t res = MSG_OK;
  sg_energy_plugin_init();
  MSG_init(&argc, argv);

  xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);

  MSG_create_environment(argv[1]);

  MSG_process_create("dvfs",dvfs,NULL,MSG_host_by_name("MyHost1"));

  res = MSG_main();

  XBT_INFO("Total simulation time: %.2f; All hosts must have the exact same energy consumption.", MSG_get_clock());

  return res != MSG_OK;
}
コード例 #16
0
ファイル: host_on_off_wait.c プロジェクト: R7R8/simgrid
int main(int argc, char *argv[])
{
  msg_error_t res;

  MSG_init(&argc, argv);
  xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);

  MSG_create_environment(argv[1]);

  MSG_process_create("master", master, NULL, MSG_get_host_by_name("Tremblay"));
  MSG_process_create("slave", slave, NULL, MSG_get_host_by_name("Jupiter"));

  res = MSG_main();

  XBT_INFO("Simulation time %g", MSG_get_clock());

  return res != MSG_OK;
}
コード例 #17
0
ファイル: remote.c プロジェクト: Julio-Anjos/simgrid
int main(int argc, char **argv)
{
  int res;
  unsigned int cur;
  xbt_dynar_t storages;
  msg_storage_t st;

  MSG_init(&argc, argv);
  MSG_create_environment(argv[1]);
  MSG_function_register("host", host);
  MSG_launch_application(argv[2]);

  storages = MSG_storages_as_dynar();
  xbt_dynar_foreach(storages, cur, st){
    XBT_INFO("Init: %llu MiB used on '%s'",
        MSG_storage_get_used_size(st)/INMEGA,
        MSG_storage_get_name(st));
  }
コード例 #18
0
static void simopen(const char *const *action) {
  const char *processid = action[0];
  const char *file_name = action[2];
  const char *worktime = action[3];
  double sleeptime;
  const char *index = action[4];
  char full_name[1024];
  msg_file_t file = NULL;
  double clock = MSG_get_clock();       /* this "call" is free thanks to inlining */
  sleeptime = atof(worktime);
  MSG_process_sleep(sleeptime);
  sprintf(full_name, "%s:%s:%s", file_name,MSG_process_get_name(MSG_process_self()),index);
  ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name);
  file = MSG_file_open(file_name, NULL);
  xbt_dict_set(opened_files, full_name, file, NULL);
  log_action(action, MSG_get_clock() - clock);
  XBT_INFO("open worker %s%s is done",processid,index);
}
コード例 #19
0
ファイル: cloud-capping.c プロジェクト: fabienchaix/simgrid
int main(int argc, char *argv[])
{
  /* Get the arguments */
  MSG_init(&argc, argv);

  /* load the platform file */
  xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/small_platform.xml\n", argv[0], argv[0]);

  MSG_create_environment(argv[1]);

  msg_host_t pm0 = MSG_host_by_name("Fafard");
  launch_master(pm0);

  int res = MSG_main();
  XBT_INFO("Bye (simulation time %g)", MSG_get_clock());

  return !(res == MSG_OK);
}
コード例 #20
0
ファイル: parallel_task.c プロジェクト: congfairy/simgrid
/** Test function */
msg_error_t test_all(const char *platform_file)
{
  msg_error_t res = MSG_OK;
  xbt_dynar_t all_hosts;
  msg_host_t first_host;

  MSG_config("host/model", "ptask_L07");
  MSG_create_environment(platform_file);

  all_hosts = MSG_hosts_as_dynar();
  first_host = xbt_dynar_getfirst_as(all_hosts,msg_host_t);
  MSG_process_create("test", test, NULL, first_host);
  res = MSG_main();
  xbt_dynar_free(&all_hosts);

  XBT_INFO("Simulation time %g", MSG_get_clock());
  return res;
}
コード例 #21
0
ファイル: chor.c プロジェクト: choreos/ChoreographySimulator
void run_service_cordel(int list_methods_len,chor_method_data list_methods[],char mailbox[]){
    m_task_t received_task = NULL;
    MSG_error_t res = MSG_OK;
    msg_comm_t msg_recv = NULL;
    static int id_sender = 0;
    char sender_name[50];
    sprintf(sender_name,"%s_%d",mailbox,id_sender++);
    int waiting_count = 0;
    while(1){
	msg_recv = MSG_task_irecv(&(received_task),mailbox);
	res = MSG_comm_wait(msg_recv,-1);
	if(res == MSG_OK){
	    char task_name[100];
	    strcpy(task_name,MSG_task_get_name(received_task));
	    task_data *received_task_data = (task_data *) received_task->data;
	    XBT_INFO("received task %lf",received_task_data->id);
	   // double endtime = MSG_get_clock();
	   // write_log(received_task_data->starttime,endtime,"waiting time");
	   //received_task_data->starttime = endtime;
	   int index_method = find_method(list_methods_len,list_methods,task_name);
	    chor_method_data method_data = list_methods[index_method];
	    int i;
	    for(i = 0;i<method_data.instructions_len;i++){
		method_instruction instruction = method_data.instructions[i];
		if(instruction.type == INVOKE){
		    service_invoke(instruction.role,instruction.method_name,instruction.input_size,sender_name);
		    waiting_count++;
		}else if(instruction.type == INVOKE_A){
		    service_invoke_cordel(instruction.role,instruction.method_name,instruction.input_size,received_task_data);
		}else if(instruction.type == EXEC){
		    run_chor_task(task_name,method_data);
		    }
		else if(instruction.type == WAIT){
		    wait_task(sender_name,waiting_count);
		    waiting_count = 0;
		    }
		else if(instruction.type == RETURN){
		    return_task(task_name,received_task,method_data.output_size);
		}
	    }
	}
	received_task = NULL;
    }
}
コード例 #22
0
ファイル: pastry.c プロジェクト: RockyMeadow/simgrid
/**
 * \brief Main function.
 */
int main(int argc, char *argv[])
{
  MSG_init(&argc, argv);
  xbt_assert(argc > 2, 
       "Usage: %s [-nb_bits=n] [-timeout=t] platform_file deployment_file\n"
       "\tExample: %s ../msg_platform.xml pastry10.xml\n", 
       argv[0], argv[0]);
  
  char **options = &argv[1];
  while (!strncmp(options[0], "-", 1)) {

    int length = strlen("-nb_bits=");
    if (!strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) {
      nb_bits = xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter: %s");
      XBT_DEBUG("Set nb_bits to %d", nb_bits);
    }
    else {

      length = strlen("-timeout=");
      if (!strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) {
        timeout = xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s");
        XBT_DEBUG("Set timeout to %d", timeout);
      }
      else {
        xbt_die("Invalid chord option '%s'", options[0]);
      }
    }
    options++;
  }

  const char* platform_file = options[0];
  const char* application_file = options[1];

  MSG_create_environment(platform_file);
  
  MSG_function_register("node", node);
  MSG_launch_application(application_file);

  msg_error_t res = MSG_main();
  XBT_CRITICAL("Messages created: %ld", smx_total_comms);
  XBT_INFO("Simulated time: %g", MSG_get_clock());

  return res != MSG_OK;
}
コード例 #23
0
ファイル: process-suspend.c プロジェクト: R7R8/simgrid
/** The Lazy guy only wants to sleep, but can be awaken by the @ref dream_master. */
static int lazy_guy(int argc, char *argv[])
{
  XBT_INFO("Nobody's watching me ? Let's go to sleep.");
  MSG_process_suspend(MSG_process_self());       /** - Start by suspending itself */
  XBT_INFO("Uuuh ? Did somebody call me ?");

  XBT_INFO("Going to sleep...");                 /** - Then repetitively go to sleep, but got awaken */
  SLEEP(10.0);
  XBT_INFO("Mmm... waking up.");

  XBT_INFO("Going to sleep one more time...");
  SLEEP(10.0);
  XBT_INFO("Waking up once for all!");

  XBT_INFO("Mmmh, goodbye now.");
  return 0;
}
コード例 #24
0
ファイル: task_progress.cpp プロジェクト: mpoquet/simgrid
static int get_progress(int /*argc*/, char* /*argv*/ [])
{
  while (tasks.empty()) {
    MSG_process_sleep(0.5);
  }
  double progress;
  for(auto const& task: tasks) {
    double progress_prev = 1;
    for (int i = 0; i < 3; i++) {
      MSG_process_sleep(0.2);
      progress = MSG_task_get_remaining_work_ratio(task);
      xbt_assert(progress >= 0 and progress < 1, "Progress should be in [0, 1[, and not %f", progress);
      xbt_assert(progress < progress_prev, "Progress should decrease, not increase");
      XBT_INFO("Progress of \"%s\": %f", task->name, progress);
      progress_prev = progress;
    }
  }
  return 0;
}
コード例 #25
0
int main(int argc, char *argv[])
{
  MSG_init(&argc, argv);

  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
             "\tExample: %s ../../platform/small_platform.xml app-pingpong_d.xml\n", argv[0], argv[0]);

  MSG_create_environment(argv[1]);          /* - Load the platform description */

  MSG_function_register("pinger", pinger);  /* - Register the functions to be executed by the processes */
  MSG_function_register("ponger", ponger);

  MSG_launch_application(argv[2]);          /* - Deploy the application */

  msg_error_t res = MSG_main();             /* - Run the simulation */

  XBT_INFO("Total simulation time: %e", MSG_get_clock());
  return res!=MSG_OK;
}
コード例 #26
0
ファイル: sendrecv.c プロジェクト: Shurakai/SimGrid
/** Main function */
int main(int argc, char *argv[])
{
  msg_error_t res = MSG_OK;

#ifdef _MSC_VER
  unsigned int prev_exponent_format =
      _set_output_format(_TWO_DIGIT_EXPONENT);
#endif

  MSG_init(&argc, argv);


  if (argc != 3) {
    XBT_CRITICAL("Usage: %s platform_file deployment_file <model>\n",
              argv[0]);
    XBT_CRITICAL
        ("example: %s msg_platform.xml msg_deployment.xml KCCFLN05_Vegas\n",
         argv[0]);
    exit(1);
  }

  /* Options for the workstation/model:

     KCCFLN05              => for maxmin
     KCCFLN05_proportional => for proportional (Vegas)
     KCCFLN05_Vegas        => for TCP Vegas
     KCCFLN05_Reno         => for TCP Reno
   */
  //MSG_config("workstation/model", argv[3]);

  res = test_all(argv[1], argv[2]);

  XBT_INFO("Total simulation time: %le", MSG_get_clock());

#ifdef _MSC_VER
  _set_output_format(prev_exponent_format);
#endif

  if (res == MSG_OK)
    return 0;
  else
    return 1;
}                               /* end_of_main */
コード例 #27
0
ファイル: s4u-energy-vm.cpp プロジェクト: simgrid/simgrid
int main(int argc, char* argv[])
{
  sg_host_energy_plugin_init();
  simgrid::s4u::Engine e(&argc, argv);

  xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);

  e.load_platform(argv[1]);

  simgrid::s4u::Actor::create("dvfs", simgrid::s4u::Host::by_name("MyHost1"), dvfs);

  e.run();

  XBT_INFO("Total simulation time: %.2f; Host2 and Host3 must have the exact same energy consumption; Host1 is "
           "multi-core and will differ.",
           simgrid::s4u::Engine::get_clock());

  return 0;
}
コード例 #28
0
ファイル: incomplete.c プロジェクト: simgrid/simgrid
/* SimDag Incomplete Test
 * Scenario:
 *   - Create a bunch of tasks
 *   - schedule only a subset of them (init, A and D)
 *   - run the simulation
 *   - Verify that we detect which tasks are not scheduled and show their state.
 * The scheduled task A sends 1GB. Simulation time should be
 *          1e9/1.25e8 + 1e-4 = 8.0001 seconds
 * Task D is scheduled but depends on unscheduled task C.
 */
int main(int argc, char **argv)
{
  /* scheduling parameters */
  double communication_amount1 = 1e9;
  double no_cost = 0.0;

  /* initialization of SD */
  SD_init(&argc, argv);

  /* creation of the environment */
  SD_create_environment(argv[1]);

  /* creation of the tasks and their dependencies */
  SD_task_t taskInit = SD_task_create("Init", NULL, 1.0);
  SD_task_t taskA = SD_task_create("Task A", NULL, 1.0);
  SD_task_t taskB = SD_task_create("Task B", NULL, 1.0);
  SD_task_t taskC = SD_task_create("Task C", NULL, 1.0);
  SD_task_t taskD = SD_task_create("Task D", NULL, 1.0);

  SD_task_dependency_add(taskInit, taskA);
  SD_task_dependency_add(taskInit, taskB);
  SD_task_dependency_add(taskC, taskD);

  sg_host_t *hosts = sg_host_list();
  SD_task_schedule(taskInit, 1, hosts, &no_cost, &no_cost, -1.0);
  SD_task_schedule(taskA, 1, &hosts[0], &no_cost, &communication_amount1, -1.0);
  SD_task_schedule(taskD, 1, &hosts[0], &no_cost, &communication_amount1, -1.0);
  xbt_free(hosts);

  /* let's launch the simulation! */
  SD_simulate(-1.);

  SD_task_destroy(taskA);
  SD_task_destroy(taskB);
  SD_task_destroy(taskC);
  SD_task_destroy(taskD);
  SD_task_destroy(taskInit);

  XBT_INFO("Simulation time: %f", SD_get_clock());


  return 0;
}
コード例 #29
0
ファイル: peer3.c プロジェクト: FlorianPO/simgrid
/** Test function */
msg_error_t test_all(const char *platform_file,
                     const char *application_file)
{
  msg_error_t res = MSG_OK;

  /* MSG_config("workstation/model","KCCFLN05"); */
  {                             /*  Simulation setting */
    MSG_create_environment(platform_file);
  }
  {                             /*   Application deployment */
    MSG_function_register("sender", sender);
    MSG_function_register("receiver", receiver);
    MSG_launch_application(application_file);
  }
  res = MSG_main();

  XBT_INFO("Simulation time %g", MSG_get_clock());
  return res;
}                               /* end_of_test_all */
コード例 #30
0
ファイル: async-wait.c プロジェクト: luizabeltrame/simgrid
int main(int argc, char *argv[])
{
  msg_error_t res = MSG_OK;

  MSG_init(&argc, argv);
  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
             "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);

  MSG_create_environment(argv[1]);/* - Load the platform description */

  MSG_function_register("sender", sender);
  MSG_function_register("receiver", receiver);
  MSG_launch_application(argv[2]);/* - Deploy the sender and receiver processes */

  res = MSG_main();  /* - Run the simulation */

  XBT_INFO("Simulation time %g", MSG_get_clock());

  return res != MSG_OK;
}