Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify these tests
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 25 Feb 2019 15:14:00 +0000 (16:14 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 25 Feb 2019 15:21:01 +0000 (16:21 +0100)
examples/deprecated/msg/platform-failures/platform-failures.c
teshsuite/msg/app-pingpong/app-pingpong.c

index 0520e7d..f575ea8 100644 (file)
@@ -24,8 +24,7 @@ static int master(int argc, char *argv[])
     char mailbox[256];
     snprintf(mailbox, 255, "worker-%ld", i % workers_count);
     XBT_INFO("Send a message to %s", mailbox);
     char mailbox[256];
     snprintf(mailbox, 255, "worker-%ld", i % workers_count);
     XBT_INFO("Send a message to %s", mailbox);
-    msg_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size, xbt_new0(double, 1));
-    *((double *) task->data) = MSG_get_clock();
+    msg_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size, NULL);
 
     switch ( MSG_task_send_with_timeout(task,mailbox,10.0) ) {
     case MSG_OK:
 
     switch ( MSG_task_send_with_timeout(task,mailbox,10.0) ) {
     case MSG_OK:
@@ -34,19 +33,16 @@ static int master(int argc, char *argv[])
 
     case MSG_HOST_FAILURE:
       XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
 
     case MSG_HOST_FAILURE:
       XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
-      free(task->data);
       MSG_task_destroy(task);
       return 0;
 
     case MSG_TRANSFER_FAILURE:
       XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox);
       MSG_task_destroy(task);
       return 0;
 
     case MSG_TRANSFER_FAILURE:
       XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox);
-      free(task->data);
       MSG_task_destroy(task);
       break;
 
     case MSG_TIMEOUT:
       XBT_INFO ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox);
       MSG_task_destroy(task);
       break;
 
     case MSG_TIMEOUT:
       XBT_INFO ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox);
-      free(task->data);
       MSG_task_destroy(task);
       break;
 
       MSG_task_destroy(task);
       break;
 
@@ -111,11 +107,9 @@ static int worker(int argc, char *argv[])
       retcode = MSG_task_execute(task);
       if (retcode == MSG_OK) {
         XBT_INFO("Execution complete.");
       retcode = MSG_task_execute(task);
       if (retcode == MSG_OK) {
         XBT_INFO("Execution complete.");
-        free(task->data);
         MSG_task_destroy(task);
       } else if (retcode == MSG_HOST_FAILURE) {
         XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
         MSG_task_destroy(task);
       } else if (retcode == MSG_HOST_FAILURE) {
         XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
-        free(task->data);
         MSG_task_destroy(task);
         return 0;
       } else {
         MSG_task_destroy(task);
         return 0;
       } else {
index 265c15f..bbc8dcf 100644 (file)
@@ -17,9 +17,7 @@ static int pinger(int argc, char* argv[])
 
   /* - Do the ping with a 1-Byte task (latency bound) ... */
   double now                = MSG_get_clock();
 
   /* - Do the ping with a 1-Byte task (latency bound) ... */
   double now                = MSG_get_clock();
-  msg_task_t ping_task      = MSG_task_create("small communication (latency bound)", 0.0, 1, NULL);
-  ping_task->data           = xbt_new(double, 1);
-  *(double*)ping_task->data = now;
+  msg_task_t ping_task      = MSG_task_create("small communication (latency bound)", 0.0, 1, &now);
   MSG_task_send(ping_task, argv[1]);
 
   /* - ... then wait for the (large) pong */
   MSG_task_send(ping_task, argv[1]);
 
   /* - ... then wait for the (large) pong */
@@ -27,10 +25,9 @@ static int pinger(int argc, char* argv[])
   int a                = MSG_task_receive(&pong_task, MSG_host_get_name(MSG_host_self()));
   xbt_assert(a == MSG_OK, "Unexpected behavior");
 
   int a                = MSG_task_receive(&pong_task, MSG_host_get_name(MSG_host_self()));
   xbt_assert(a == MSG_OK, "Unexpected behavior");
 
-  double sender_time        = *((double*)(pong_task->data));
+  double sender_time        = *((double*)(MSG_task_get_data(pong_task)));
   double communication_time = MSG_get_clock() - sender_time;
   XBT_INFO("Task received : %s", MSG_task_get_name(pong_task));
   double communication_time = MSG_get_clock() - sender_time;
   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);
 
   MSG_task_destroy(pong_task);
   XBT_INFO("Pong time (bandwidth bound): %.3f", communication_time);
 
@@ -48,19 +45,16 @@ static int ponger(int argc, char* argv[])
   int a                = MSG_task_receive(&ping_task, MSG_host_get_name(MSG_host_self()));
   xbt_assert(a == MSG_OK, "Unexpected behavior");
 
   int a                = MSG_task_receive(&ping_task, MSG_host_get_name(MSG_host_self()));
   xbt_assert(a == MSG_OK, "Unexpected behavior");
 
-  double sender_time        = *((double*)(ping_task->data));
+  double sender_time        = *((double*)(MSG_task_get_data(ping_task)));
   double communication_time = MSG_get_clock() - sender_time;
   XBT_INFO("Task received : %s", MSG_task_get_name(ping_task));
   double communication_time = MSG_get_clock() - sender_time;
   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);
 
   /*  - ... Then send a 1GB pong back (bandwidth bound) */
   double now                = MSG_get_clock();
   MSG_task_destroy(ping_task);
   XBT_INFO(" Ping time (latency bound) %f", communication_time);
 
   /*  - ... Then send a 1GB pong back (bandwidth bound) */
   double now                = MSG_get_clock();
-  msg_task_t pong_task      = MSG_task_create("large communication (bandwidth bound)", 0.0, 1e9, NULL);
-  pong_task->data           = xbt_new(double, 1);
-  *(double*)pong_task->data = now;
-  XBT_INFO("task_bw->data = %.3f", *((double*)pong_task->data));
+  msg_task_t pong_task      = MSG_task_create("large communication (bandwidth bound)", 0.0, 1e9, &now);
+  XBT_INFO("task_bw->data = %.3f", *((double*)MSG_task_get_data(pong_task)));
   MSG_task_send(pong_task, argv[1]);
 
   return 0;
   MSG_task_send(pong_task, argv[1]);
 
   return 0;