Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
do not promote bad practices: use "accessor" to get task name
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 25 Feb 2019 14:16:32 +0000 (15:16 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 25 Feb 2019 14:16:32 +0000 (15:16 +0100)
examples/deprecated/msg/app-masterworker/app-masterworker.c
examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c
teshsuite/msg/app-pingpong/app-pingpong.c
teshsuite/msg/app-token-ring/app-token-ring.c
teshsuite/msg/host_on_off/host_on_off.c
teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp
teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp
teshsuite/msg/task_progress/task_progress.cpp

index e619089..6100fb3 100644 (file)
@@ -28,7 +28,7 @@ static int master(int argc, char *argv[])
     snprintf(task_name,79, "Task_%d", i);
     msg_task_t task = MSG_task_create(task_name, comp_size, comm_size, NULL);   /* - Create a task */
     if (number_of_tasks < 10000 || i % 10000 == 0)
-      XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox);
+      XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", MSG_task_get_name(task), number_of_tasks, mailbox);
 
     MSG_task_send(task, mailbox); /* - Send the task to the @ref worker */
   }
index c0562ea..1fe801a 100644 (file)
@@ -27,7 +27,7 @@ static int master(int argc, char *argv[])
     snprintf(sprintf_buffer,256, "Task_%d", i);
     msg_task_t task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
     if (number_of_tasks < 10000 || i % 10000 == 0)
-      XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox);
+      XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", MSG_task_get_name(task), number_of_tasks, mailbox);
 
     MSG_task_send(task, mailbox);
   }
index 49fe365..265c15f 100644 (file)
@@ -29,7 +29,7 @@ static int pinger(int argc, char* argv[])
 
   double sender_time        = *((double*)(pong_task->data));
   double communication_time = MSG_get_clock() - sender_time;
-  XBT_INFO("Task received : %s", pong_task->name);
+  XBT_INFO("Task received : %s", MSG_task_get_name(pong_task));
   xbt_free(pong_task->data);
   MSG_task_destroy(pong_task);
   XBT_INFO("Pong time (bandwidth bound): %.3f", communication_time);
@@ -50,7 +50,7 @@ static int ponger(int argc, char* argv[])
 
   double sender_time        = *((double*)(ping_task->data));
   double communication_time = MSG_get_clock() - sender_time;
-  XBT_INFO("Task received : %s", ping_task->name);
+  XBT_INFO("Task received : %s", MSG_task_get_name(ping_task));
   xbt_free(ping_task->data);
   MSG_task_destroy(ping_task);
   XBT_INFO(" Ping time (latency bound) %f", communication_time);
index d10112d..3c585b2 100644 (file)
@@ -22,7 +22,7 @@ static int relay_runner(int argc, char* argv[])
     snprintf(mailbox, 255, "%d", rank + 1);
     unsigned int task_comm_size = 1000000; /* The token is 1MB long*/
     msg_task_t task             = MSG_task_create("Token", 0, task_comm_size, NULL);
-    XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, task->name, mailbox);
+    XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, MSG_task_get_name(task), mailbox);
     MSG_task_send(task, mailbox);
     task    = NULL;
     int res = MSG_task_receive(&task, MSG_process_get_name(MSG_process_self()));
@@ -42,7 +42,7 @@ static int relay_runner(int argc, char* argv[])
       snprintf(mailbox, 255, "0");
     else
       snprintf(mailbox, 255, "%d", rank + 1);
-    XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, task->name, mailbox);
+    XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, MSG_task_get_name(task), mailbox);
     MSG_task_send(task, mailbox);
   }
   return 0;
index b91077b..db526a4 100644 (file)
@@ -47,7 +47,7 @@ static int master(int argc, char *argv[])
   msg_host_t jupiter = MSG_host_by_name("Jupiter");
 
   msg_task_t task = MSG_task_create("task on", task_comp_size, task_comm_size, NULL);
-  XBT_INFO("Sending \"%s\"", task->name);
+  XBT_INFO("Sending \"%s\"", MSG_task_get_name(task));
   if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK)
     MSG_task_destroy(task);
 
@@ -55,7 +55,7 @@ static int master(int argc, char *argv[])
   MSG_host_off(jupiter);
 
   task = MSG_task_create("task off", task_comp_size, task_comm_size, NULL);
-  XBT_INFO("Sending \"%s\"", task->name);
+  XBT_INFO("Sending \"%s\"", MSG_task_get_name(task));
   if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK)
     MSG_task_destroy(task);
 
@@ -71,7 +71,7 @@ static int master(int argc, char *argv[])
   xbt_dynar_free(&jupi_processes);
 
   task = MSG_task_create("task on without proc", task_comp_size, task_comm_size, NULL);
-  XBT_INFO("Sending \"%s\"", task->name);
+  XBT_INFO("Sending \"%s\"", MSG_task_get_name(task));
   if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK)
     MSG_task_destroy(task);
 
@@ -80,12 +80,12 @@ static int master(int argc, char *argv[])
   MSG_process_create_with_arguments("slave", slave, NULL, MSG_host_by_name("Jupiter"), 1, argvF);
 
   task = MSG_task_create("task on with proc", task_comp_size, task_comm_size, NULL);
-  XBT_INFO("Sending \"%s\"", task->name);
+  XBT_INFO("Sending \"%s\"", MSG_task_get_name(task));
   if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK)
     MSG_task_destroy(task);
 
   task = MSG_task_create("finalize", 0, 0, 0);
-  XBT_INFO("Sending \"%s\"", task->name);
+  XBT_INFO("Sending \"%s\"", MSG_task_get_name(task));
   if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK)
     MSG_task_destroy(task);
 
index fe7a2f2..eb6b463 100644 (file)
@@ -61,7 +61,7 @@ static int commRX(int /*argc*/, char** /*argv*/)
   XBT_INFO("  Start RX");
   msg_error_t error = MSG_task_receive(&(task), mailbox);
   if (error == MSG_OK) {
-    XBT_INFO("  Receive message: %s", task->name);
+    XBT_INFO("  Receive message: %s", MSG_task_get_name(task));
     MSG_task_destroy(task);
   } else if (error == MSG_HOST_FAILURE) {
     XBT_INFO("  Receive message: HOST_FAILURE");
index ed57228..e8e2aed 100644 (file)
@@ -15,21 +15,21 @@ static int master(int /*argc*/, char* /*argv*/ [])
   double timeout = 1;
 
   msg_task_t task = MSG_task_create("normal", task_comp_size, task_comm_size, NULL);
-  XBT_INFO("Sending task: \"%s\"", task->name);
+  XBT_INFO("Sending task: \"%s\"", MSG_task_get_name(task));
   MSG_task_send_with_timeout(task, "worker_mailbox", timeout);
 
   task = MSG_task_create("cancel directly", task_comp_size, task_comm_size, NULL);
-  XBT_INFO("Canceling task \"%s\" directly", task->name);
+  XBT_INFO("Canceling task \"%s\" directly", MSG_task_get_name(task));
   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);
+  XBT_INFO("Destroying task \"%s\" directly", MSG_task_get_name(task));
   MSG_task_destroy(task);
 
   task = MSG_task_create("cancel", task_comp_size, task_comm_size, NULL);
   msg_comm_t comm = MSG_task_isend(task, "worker_mailbox");
-  XBT_INFO("Canceling task \"%s\" during comm", task->name);
+  XBT_INFO("Canceling task \"%s\" during comm", MSG_task_get_name(task));
   MSG_task_cancel(task);
   if (MSG_comm_wait(comm, -1) != MSG_OK)
     MSG_comm_destroy(comm);
@@ -37,7 +37,7 @@ static int master(int /*argc*/, char* /*argv*/ [])
 
   task = MSG_task_create("finalize", task_comp_size, task_comm_size, NULL);
   comm = MSG_task_isend(task, "worker_mailbox");
-  XBT_INFO("Destroying task \"%s\" during comm", task->name);
+  XBT_INFO("Destroying task \"%s\" during comm", MSG_task_get_name(task));
   MSG_task_destroy(task);
   if (MSG_comm_wait(comm, -1) != MSG_OK)
     MSG_comm_destroy(comm);
@@ -56,7 +56,7 @@ static int worker_main(int /*argc*/, char* /*argv*/ [])
 {
   msg_task_t task = (msg_task_t) MSG_process_get_data(MSG_process_self());
   msg_error_t res;
-  XBT_INFO("Start %s", task->name);
+  XBT_INFO("Start %s", MSG_task_get_name(task));
   res = MSG_task_execute(task);
   XBT_INFO("Task %s", res == MSG_OK ? "done" : "failed");
   MSG_task_destroy(task);
@@ -72,7 +72,7 @@ static int worker(int /*argc*/, char* /*argv*/ [])
     XBT_INFO("Handling task \"%s\"", MSG_task_get_name(task));
 
     if (not strcmp(MSG_task_get_name(task), "finalize")) {
-      XBT_INFO("Destroying task \"%s\"", task->name);
+      XBT_INFO("Destroying task \"%s\"", MSG_task_get_name(task));
       MSG_task_destroy(task);
       break;
     }
@@ -80,7 +80,7 @@ static int worker(int /*argc*/, char* /*argv*/ [])
     if (not strcmp(MSG_task_get_name(task), "cancel")) {
       MSG_process_create("worker1", worker_main, task, MSG_host_self());
       MSG_process_sleep(0.1);
-      XBT_INFO("Canceling task \"%s\"", task->name);
+      XBT_INFO("Canceling task \"%s\"", MSG_task_get_name(task));
       MSG_task_cancel(task);
       continue;
     }
index dc467fe..65810c2 100644 (file)
@@ -19,14 +19,14 @@ static int seq_task(int /*argc*/, char* /*argv*/ [])
   msg_task_t task = MSG_task_create("simple", task_comp_size, task_comm_size, NULL);
   tasks.push_back(task);
 
-  XBT_INFO("get the progress of %s before the task starts", task->name);
+  XBT_INFO("get the progress of %s before the task starts", MSG_task_get_name(task));
   progress = MSG_task_get_remaining_work_ratio(task);
   xbt_assert(progress == 1.0, "Progress should be 1.0 not %f", progress);
 
-  XBT_INFO("Executing task: \"%s\"", task->name);
+  XBT_INFO("Executing task: \"%s\"", MSG_task_get_name(task));
   MSG_task_execute(task);
 
-  XBT_INFO("get the progress of %s after the task finishes", task->name);
+  XBT_INFO("get the progress of %s after the task finishes", MSG_task_get_name(task));
   progress = MSG_task_get_remaining_work_ratio(task);
   xbt_assert(progress == 0.0, "Progress should be equal to 0.0 not %f", progress);
 
@@ -48,14 +48,14 @@ static int par_task(int /*argc*/, char* /*argv*/ [])
   msg_task_t task = MSG_parallel_task_create("ptask", 2, hosts_to_use.data(), computation_amount, communication_amount, NULL);
   tasks.push_back(task);
 
-  XBT_INFO("get the progress of %s before the task starts", task->name);
+  XBT_INFO("get the progress of %s before the task starts", MSG_task_get_name(task));
   progress = MSG_task_get_remaining_work_ratio(task);
   xbt_assert(progress == 1.0, "Progress should be 1.0 not %f", progress);
 
-  XBT_INFO("Executing task: \"%s\"", task->name);
+  XBT_INFO("Executing task: \"%s\"", MSG_task_get_name(task));
   MSG_parallel_task_execute(task);
 
-  XBT_INFO("get the progress of %s after the task finishes", task->name);
+  XBT_INFO("get the progress of %s after the task finishes", MSG_task_get_name(task));
   progress = MSG_task_get_remaining_work_ratio(task);
   xbt_assert(progress == 0.0, "Progress should be equal to 0.0 not %f", progress);
 
@@ -80,7 +80,7 @@ static int get_progress(int /*argc*/, char* /*argv*/ [])
       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);
+      XBT_INFO("Progress of \"%s\": %f", MSG_task_get_name(task), progress);
       progress_prev = progress;
     }
   }