#include "xbt.h" /* calloc, printf */
#include "simgrid_config.h" /* getline */
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+XBT_LOG_NEW_DEFAULT_CATEGORY(actions,
"Messages specific for this msg example");
int communicator_size=0;
/* My actions */
static void send(xbt_dynar_t action)
{
- char *name = xbt_str_join(action, " ");
+ char *name = NULL;
char to[250];
char *size = xbt_dynar_get_as(action, 3, char *);
double clock = MSG_get_clock();
sprintf (to,"%s_%s", MSG_process_get_name(MSG_process_self()),
xbt_dynar_get_as(action, 2, char *));
// char *to = xbt_dynar_get_as(action, 2, char *);
+
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ name = xbt_str_join(action, " ");
+
DEBUG2("Entering Send: %s (size: %lg)", name, parse_double(size));
MSG_task_send(MSG_task_create(name, 0, parse_double(size), NULL), to);
DEBUG2("%s %f", name, MSG_get_clock()-clock);
- free(name);
+
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ free(name);
}
static void recv(xbt_dynar_t action)
{
- char *name = xbt_str_join(action, " ");
+ char *name = NULL;
char mailbox_name[250];
m_task_t task = NULL;
double clock = MSG_get_clock();
//char *from=xbt_dynar_get_as(action,2,char*);
sprintf (mailbox_name,"%s_%s", xbt_dynar_get_as(action, 2, char *),
MSG_process_get_name(MSG_process_self()));
+
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ name = xbt_str_join(action, " ");
+
DEBUG1("Receiving: %s", name);
MSG_task_receive(&task, mailbox_name);
// MSG_task_receive(&task, MSG_process_get_name(MSG_process_self()));
DEBUG2("%s %f", name, MSG_get_clock()-clock);
MSG_task_destroy(task);
- free(name);
+
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ free(name);
}
static int spawned_recv(int argc, char *argv[])
static void Irecv(xbt_dynar_t action)
{
- char *name = xbt_str_join(action, " ");
+ char *name;
m_process_t comm_helper;
char mailbox_name[250];
char **myargv;
sprintf (mailbox_name,"%s_%s", xbt_dynar_get_as(action, 2, char *),
MSG_process_get_name(MSG_process_self()));
- sprintf(name,"%s_wait",MSG_process_get_name(MSG_process_self()));
+ name = bprintf("%s_wait",MSG_process_get_name(MSG_process_self()));
myargv = (char**) calloc (2, sizeof (char*));
myargv[0] = xbt_strdup(mailbox_name);
1, myargv);
DEBUG2("%s %f", xbt_str_join(action, " "),
- MSG_get_clock()-clock);
+ MSG_get_clock()-clock);
free(name);
}
static void wait_action(xbt_dynar_t action)
{
- char *name = xbt_str_join(action, " ");
+ char *name = NULL;
char task_name[80];
m_task_t task = NULL;
double clock = MSG_get_clock();
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ name = xbt_str_join(action, " ");
+
DEBUG1("Entering %s", name);
sprintf(task_name,"%s_wait",MSG_process_get_name(MSG_process_self()));
DEBUG1("wait: %s", task_name);
MSG_task_receive(&task,task_name);
MSG_task_destroy(task);
DEBUG2("%s %f", name, MSG_get_clock()-clock);
- free(name);
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ free(name);
}
static void barrier (xbt_dynar_t action)
{
- char *name = xbt_str_join(action, " ");
+ char *name = NULL;
+
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ name = xbt_str_join(action, " ");
+
DEBUG1("barrier: %s", name);
-
- free(name);
+ THROW_UNIMPLEMENTED;
+
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ free(name);
}
static void sleep(xbt_dynar_t action)
{
- char *name = xbt_str_join(action, " ");
+ char *name = NULL;
char *duration = xbt_dynar_get_as(action, 2, char *);
double clock = MSG_get_clock();
+
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ name = xbt_str_join(action, " ");
+
DEBUG1("Entering %s", name);
MSG_process_sleep(parse_double(duration));
DEBUG2("%s %f ", name, MSG_get_clock()-clock);
- free(name);
+
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ free(name);
}
static void allReduce(xbt_dynar_t action)
static void compute(xbt_dynar_t action)
{
- char *name = xbt_str_join(action, " ");
+ char *name=NULL;
char *amout = xbt_dynar_get_as(action, 2, char *);
m_task_t task = MSG_task_create(name, parse_double(amout), 0, NULL);
double clock = MSG_get_clock();
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ name = xbt_str_join(action, " ");
DEBUG1("Entering %s", name);
MSG_task_execute(task);
MSG_task_destroy(task);
DEBUG2("%s %f", name, MSG_get_clock()-clock);
- free(name);
+ if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+ free(name);
}
/** Main function */