Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
properly deprecate MSG_task_get_flops_amount() and stop using it ourselves
[simgrid.git] / examples / msg / trace-masterworker / trace-masterworker.c
index 335dd09..56cb7a3 100644 (file)
@@ -1,25 +1,11 @@
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-2016. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-/** @addtogroup MSG_examples
- * 
- * - <b>tracing/ms.c</b> This is a master/worker program where the master creates tasks, send them to the workers. For
- * each task received, the worker executes it and then destroys it. This program uses several tracing functions that
- * enable the tracing of categorized resource utilization, the use of trace marks, and user variables associated to the
- * hosts of the platform file. You might want to run this program with the following parameters:
- * --cfg=tracing/categorized:yes
- * --cfg=tracing/uncategorized:yes
- * --cfg=viva/categorized:viva_cat.plist
- * --cfg=viva/uncategorized:viva_uncat.plist
- * (See \ref tracing_tracing_options for details)
- */
-
 #include "simgrid/msg.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_trace_masterworker, "Messages specific for this msg example");
 
 static int master(int argc, char *argv[])
 {
@@ -32,10 +18,8 @@ static int master(int argc, char *argv[])
   TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "is_master", 1);
 
   TRACE_mark("msmark", "start_send_tasks");
-  int i;
-  for (i = 0; i < number_of_tasks; i++) {
-    msg_task_t task = NULL;
-    task = MSG_task_create("task", task_comp_size, task_comm_size, NULL);
+  for (int i = 0; i < number_of_tasks; i++) {
+    msg_task_t task = MSG_task_create("task", task_comp_size, task_comm_size, NULL);
 
     //setting the variable "task_creation" to value i
     TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "task_creation", i);
@@ -47,7 +31,7 @@ static int master(int argc, char *argv[])
   }
   TRACE_mark("msmark", "finish_send_tasks");
 
-  for (i = 0; i < workers_count; i++) {
+  for (int i = 0; i < workers_count; i++) {
     msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
     MSG_task_set_category(finalize, "finalize");
     MSG_task_send(finalize, "master_mailbox");
@@ -65,13 +49,13 @@ static int worker(int argc, char *argv[])
   while (1) {
     MSG_task_receive(&(task), "master_mailbox");
 
-    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+    if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
       MSG_task_destroy(task);
       break;
     }
-    //adding the value returned by MSG_task_get_compute_duration(task)
-    //to the variable "task_computation"
-    TRACE_host_variable_add(MSG_host_get_name(MSG_host_self()), "task_computation", MSG_task_get_flops_amount(task));
+    // adding the value returned by MSG_task_get_compute_duration(task) to the variable "task_computation"
+    TRACE_host_variable_add(MSG_host_get_name(MSG_host_self()), "task_computation",
+                            MSG_task_get_initial_flops_amount(task));
     MSG_task_execute(task);
     MSG_task_destroy(task);
     task = NULL;