Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
do not promote bad practices: use "accessor" to get task name
[simgrid.git] / examples / smpi / smpi_msg_masterslave / masterslave_mailbox_smpi.c
index 90091d7..1fe801a 100644 (file)
@@ -1,10 +1,13 @@
-/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2019. 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. */
 
 #include "simgrid/msg.h"
 #include "mpi.h"
+
+#include <stdio.h> /* snprintf */
+
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 static int master(int argc, char *argv[])
@@ -24,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);
   }
@@ -116,6 +119,7 @@ int main(int argc, char *argv[])
   msg_error_t res;
 
   MSG_init(&argc, argv);
+  SMPI_init();
 
   xbt_assert(argc > 2,"Usage: %s platform_file deployment_file\n"
              "\nexample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
@@ -129,7 +133,6 @@ int main(int argc, char *argv[])
   // the second performing an alltoall on 4 nodes
   SMPI_app_instance_register("alltoall_mpi", alltoall_mpi,4);
   MSG_launch_application(argv[2]);
-  SMPI_init();
 
   res = MSG_main();