Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Huge import with Lucas tracing modifications.
[simgrid.git] / examples / msg / masterslave / masterslave_forwarder.c
index c1eb978..50807a0 100644 (file)
@@ -37,6 +37,7 @@ int master(int argc, char *argv[])
   double task_comp_size = 0;
   double task_comm_size = 0;
 
+  TRACE_host_variable_set ("is_master", 1);
 
   int i;
 
@@ -56,6 +57,8 @@ int master(int argc, char *argv[])
       sprintf(sprintf_buffer, "Task_%d", i);
       todo[i] =
         MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
+      TRACE_host_variable_set ("task_creation", i);
+      TRACE_msg_set_task_category (todo[i], "compute");
     }
   }
 
@@ -88,9 +91,11 @@ int master(int argc, char *argv[])
 
   INFO0
     ("All tasks have been dispatched. Let's tell everybody the computation is over.");
-  for (i = 0; i < slaves_count; i++)
-    MSG_task_put(MSG_task_create("finalize", 0, 0, FINALIZE),
-                 slaves[i], PORT_22);
+  for (i = 0; i < slaves_count; i++){
+    m_task_t finalize=MSG_task_create("finalize", 0, 0, FINALIZE);
+    TRACE_msg_set_task_category(finalize,"finalize");
+    MSG_task_put(finalize, slaves[i], PORT_22);
+  }
 
   INFO0("Goodbye now!");
   free(slaves);
@@ -102,6 +107,7 @@ int master(int argc, char *argv[])
 int slave(int argc, char *argv[])
 {
   m_task_t task = NULL;
+  TRACE_host_variable_set ("is_slave", 1);
   int res;
   while (1) {
     res = MSG_task_get(&(task), PORT_22);
@@ -114,6 +120,7 @@ int slave(int argc, char *argv[])
     }
 
     INFO1("Processing \"%s\"", MSG_task_get_name(task));
+    TRACE_host_variable_add ("task_computation", MSG_task_get_compute_duration(task));
     MSG_task_execute(task);
     INFO1("\"%s\" done", MSG_task_get_name(task));
     MSG_task_destroy(task);
@@ -202,6 +209,14 @@ int main(int argc, char *argv[])
 {
   MSG_error_t res = MSG_OK;
 
+  TRACE_start ("zmsg_test.trace");
+  TRACE_host_variable_declare ("is_slave");
+  TRACE_host_variable_declare ("is_master");
+  TRACE_host_variable_declare ("task_creation");
+  TRACE_host_variable_declare ("task_computation");
+  TRACE_category ("compute");
+  TRACE_category ("finalize");
+
   MSG_global_init(&argc, argv);
   if (argc < 3) {
     printf("Usage: %s platform_file deployment_file\n", argv[0]);
@@ -211,6 +226,8 @@ int main(int argc, char *argv[])
   res = test_all(argv[1], argv[2]);
   MSG_clean();
 
+  TRACE_end ();
+
   if (res == MSG_OK)
     return 0;
   else