static void simopen(const char *const *action) {
  const char *processid = action[0];
  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 */
  //Because the action open is too fast ,to catch up with the clock of the simulator, we let it to sleep for a while.
  sleeptime = atof(worktime);
  MSG_process_sleep(sleeptime);
  //open slow filename
  const char *file_name = action[2];
  char fn[200];
   strcpy(fn,file_name);
  ReplaceStr(fn,"/home","/slow");
  sprintf(full_name, "%s:%s:%s:%s","slow",file_name,MSG_process_get_name(MSG_process_self()),index);
  ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name);
  file = MSG_file_open(fn, NULL);
  xbt_dict_set(opened_files, full_name, file, NULL);
  //open fast filename
   strcpy(fn,file_name);
  ReplaceStr(fn,"/home","/fast");
  sprintf(full_name, "%s:%s:%s:%s","fast",file_name,MSG_process_get_name(MSG_process_self()),index);
  ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name);
  file = MSG_file_open(fn, 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);
}
static void simcreat(const char *const *action) {
  const char *processid = action[0];
  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);
  //open slow file
  const char *file_name = action[2];
  char fn[200];
   strcpy(fn,file_name);
  ReplaceStr(fn,"/home","/slow");
  sprintf(full_name, "%s:%s:%s:%s","slow",file_name,MSG_process_get_name(MSG_process_self()), index);
  ACT_DEBUG("Entering Creat: %s (filename: %s)", NAME, file_name);
  file = MSG_file_open(fn, NULL);
  xbt_dict_set(opened_files, full_name, file, NULL);
  //open fast version of file
  strcpy(fn,file_name);
  ReplaceStr(fn,"/home","/fast");
  sprintf(full_name, "%s:%s:%s:%s","fast",file_name,MSG_process_get_name(MSG_process_self()), index);
  ACT_DEBUG("Entering Creat: %s (filename: %s)", NAME, file_name);
  file = MSG_file_open(fn, NULL);
  xbt_dict_set(opened_files, full_name, file, NULL);
  
  log_action(action, MSG_get_clock() - clock);
  XBT_INFO("creat worker %s %s is done",processid,index);
}
Exemple #3
0
/* FIXME: that's a poor man's implementation: we should take the message exchanges into account */
static void action_barrier(const char *const *action)
{
  static smx_mutex_t mutex = NULL;
  static smx_cond_t cond = NULL;
  static int processes_arrived_sofar = 0;

  if (mutex == NULL) {          // first arriving on the barrier
    mutex = simcall_mutex_init();
    cond = simcall_cond_init();
    processes_arrived_sofar = 0;
  }
  ACT_DEBUG("Entering barrier: %s (%d already there)", NAME,
            processes_arrived_sofar);

  simcall_mutex_lock(mutex);
  if (++processes_arrived_sofar == communicator_size) {
    simcall_cond_broadcast(cond);
    simcall_mutex_unlock(mutex);
  } else {
    simcall_cond_wait(cond, mutex);
    simcall_mutex_unlock(mutex);
  }

  ACT_DEBUG("Exiting barrier: %s", NAME);

  processes_arrived_sofar--;
  if (!processes_arrived_sofar) {
    simcall_cond_destroy(cond);
    simcall_mutex_destroy(mutex);
    mutex = NULL;
  }
}
Exemple #4
0
 /* My actions */
 static void compute(simgrid::xbt::ReplayAction& action)
 {
   double amount = std::stod(action[2]);
   double clock  = simgrid::s4u::Engine::get_clock();
   ACT_DEBUG("Entering %s", NAME.c_str());
   simgrid::s4u::this_actor::execute(amount);
   log_action(action, simgrid::s4u::Engine::get_clock() - clock);
 }
Exemple #5
0
static void action_sleep(const char *const *action)
{
  const char *duration = action[2];
  double clock = MSG_get_clock();

  ACT_DEBUG("Entering %s", NAME);
  MSG_process_sleep(parse_double(duration));
  log_action(action, MSG_get_clock() - clock);
}
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 */
  
  if(position<2880 && (position+size)<2880)
  {
  file = get_file_descriptor("fast",file_name,index);
  ACT_DEBUG("Entering Read: %s (size: %llu)", NAME, size);
  MSG_file_seek(file,position,SEEK_SET);
  MSG_file_read(file, size);
  }
  else if(position<2880 && (position+size)>2880)
  {
  //read the Head part
  file = get_file_descriptor("fast",file_name,index);
  ACT_DEBUG("Entering Read: %s (size: %llu)", NAME, size);
  MSG_file_seek(file,position,SEEK_SET);
  MSG_file_read(file, (2880-position));
  //read the data part
  file = get_file_descriptor("slow",file_name,index);
  ACT_DEBUG("Entering Read: %s (size: %llu)", NAME, size);
  MSG_file_seek(file,2880,SEEK_SET);
  MSG_file_read(file, size-(2880-position));
  }
  else
  {
  XBT_INFO("3 position is  %llu ,size is %llu",position,size);
  file = get_file_descriptor("slow",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);
}
Exemple #7
0
static void action_compute(const char *const *action)
{
  const char *amount = action[2];
  msg_task_t task = MSG_task_create("task", parse_double(amount), 0, NULL);
  double clock = MSG_get_clock();

  ACT_DEBUG("Entering %s", NAME);
  MSG_task_execute(task);
  MSG_task_destroy(task);
  log_action(action, MSG_get_clock() - clock);
}
Exemple #8
0
  static void recv(simgrid::xbt::ReplayAction& action)
  {
    double clock = simgrid::s4u::Engine::get_clock();
    simgrid::s4u::Mailbox* from =
        simgrid::s4u::Mailbox::by_name(std::string(action[2]) + "_" + simgrid::s4u::this_actor::get_name());

    ACT_DEBUG("Receiving: %s -- Actor %s on mailbox %s", NAME.c_str(), simgrid::s4u::this_actor::get_cname(),
              from->get_cname());
    from->get();
    log_action(action, simgrid::s4u::Engine::get_clock() - clock);
  }
Exemple #9
0
static void simrelease(const char *const *action) {
  const char *processid = action[0];
  const char *file_name = action[2];
  const char *index = action[4];
  msg_file_t file;
  double clock = MSG_get_clock();       /* this "call" is free thanks to inlining */
  file = get_file_descriptor(file_name,index);
  ACT_DEBUG("Entering Close: %s (filename: %s)", NAME, file_name);
  MSG_file_close(file);
  log_action(action, MSG_get_clock() - clock);
  XBT_INFO("release worker %s%s is done",processid,index);
}
static void action_close(const char *const *action) {
  const char *file_name = action[2];
  msg_file_t file;
  double clock = MSG_get_clock();

  file = get_file_descriptor(file_name);

  ACT_DEBUG("Entering Close: %s (filename: %s)", NAME, file_name);
  MSG_file_close(file);

  log_action(action, MSG_get_clock() - clock);
}
Exemple #11
0
  static void send(simgrid::xbt::ReplayAction& action)
  {
    double size                 = std::stod(action[3]);
    std::string* payload        = new std::string(action[3]);
    double clock                = simgrid::s4u::Engine::get_clock();
    simgrid::s4u::Mailbox* to = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_name() + "_" + action[2]);
    ACT_DEBUG("Entering Send: %s (size: %g) -- Actor %s on mailbox %s", NAME.c_str(), size,
              simgrid::s4u::this_actor::get_cname(), to->get_cname());
    to->put(payload, size);
    delete payload;

    log_action(action, simgrid::s4u::Engine::get_clock() - clock);
  }
Exemple #12
0
static void simopen(const char *const *action) {
  const char *processid = action[0];
  const char *file_name = action[2];
  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 */
  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(full_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);
}
static void simrelease(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];
  msg_file_t file;
  double clock = MSG_get_clock();       /* this "call" is free thanks to inlining */
  //Because the action release is too fast ,to catch up with the clock of the simulator, we let it to sleep for a while.
  sleeptime = atof(worktime);
  MSG_process_sleep(sleeptime);
  //close slow file
  file = get_file_descriptor("slow",file_name,index);
  ACT_DEBUG("Entering Close: %s (filename: %s)", NAME, file_name);
  MSG_file_close(file);
  //close fast file
  file = get_file_descriptor("fast",file_name,index);
  ACT_DEBUG("Entering Close: %s (filename: %s)", NAME, file_name);
  MSG_file_close(file);
 
  log_action(action, MSG_get_clock() - clock);
  XBT_INFO("release worker %s%s is done",processid,index);
}
static void action_read(const char *const *action) {
  const char *file_name = action[2];
  const char *size_str = action[3];
  msg_file_t file = NULL;
  sg_size_t size = parse_size(size_str);

  double clock = MSG_get_clock();

  file = get_file_descriptor(file_name);

  ACT_DEBUG("Entering Read: %s (size: %llu)", NAME, size);
  MSG_file_read(file, size);

  log_action(action, MSG_get_clock() - clock);
}
static void action_open(const char *const *action) {
  const char *file_name = action[2];
  char full_name[1024];
  msg_file_t file = NULL;
  double clock = MSG_get_clock();

  snprintf(full_name,1023, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name);

  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);
}
Exemple #16
0
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);
}
Exemple #17
0
static void action_recv(const char *const *action)
{
  char mailbox_name[250];
  msg_task_t task = NULL;
  double clock = MSG_get_clock();

  sprintf(mailbox_name, "%s_%s", action[2],
          MSG_process_get_name(MSG_process_self()));

  ACT_DEBUG("Receiving: %s", NAME);
  msg_error_t res = MSG_task_receive(&task, mailbox_name);
  log_action(action, MSG_get_clock() - clock);

  if (res == MSG_OK) {
    MSG_task_destroy(task);
  }
  asynchronous_cleanup();
}
Exemple #18
0
/* My actions */
static void action_send(const char *const *action)
{
  char to[250];
  const char *size_str = action[3];
  double size = parse_double(size_str);
  double clock = MSG_get_clock();       /* this "call" is free thanks to inlining */

  sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]);

  ACT_DEBUG("Entering Send: %s (size: %g)", NAME, size);
  if (size < 65536) {
    action_Isend(action);
  } else {
    MSG_task_send(MSG_task_create(to, 0, size, NULL), to);
  }

  log_action(action, MSG_get_clock() - clock);
  asynchronous_cleanup();
}
Exemple #19
0
static void action_wait(const char *const *action)
{
  msg_task_t task = NULL;
  msg_comm_t comm;
  double clock = MSG_get_clock();
  process_globals_t globals =
      (process_globals_t) MSG_process_get_data(MSG_process_self());

  xbt_assert(xbt_dynar_length(globals->irecvs),
             "action wait not preceded by any irecv: %s",
             xbt_str_join_array(action, " "));

  ACT_DEBUG("Entering %s", NAME);
  comm = xbt_dynar_pop_as(globals->irecvs, msg_comm_t);
  MSG_comm_wait(comm, -1);
  task = xbt_dynar_pop_as(globals->tasks, msg_task_t);
  MSG_comm_destroy(comm);
  MSG_task_destroy(task);

  log_action(action, MSG_get_clock() - clock);
}