Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix the prototype of s4u::Host::processes() to not return a swag of smx_actors
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 13 Mar 2017 23:22:32 +0000 (00:22 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 13 Mar 2017 23:22:32 +0000 (00:22 +0100)
include/simgrid/s4u/host.hpp
src/msg/msg_host.cpp
src/s4u/s4u_host.cpp
src/smpi/smpi_comm.cpp

index e2eb92c..7af3255 100644 (file)
@@ -87,7 +87,7 @@ public:
   xbt_dict_t properties();
   const char*property(const char*key);
   void setProperty(const char*key, const char *value);
-  xbt_swag_t processes();
+  void processes(std::vector<ActorPtr>* list);
   double getPstateSpeed(int pstate_index);
   int pstatesCount() const;
   void setPstate(int pstate_index);
index 7bef21b..51972e0 100644 (file)
@@ -8,6 +8,8 @@
 #include "simgrid/s4u/storage.hpp"
 #include "src/msg/msg_private.h"
 #include "src/simix/ActorImpl.hpp"
+#include "src/simix/smx_host_private.h"
+
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg);
 
@@ -146,7 +148,7 @@ void MSG_host_get_process_list(msg_host_t host, xbt_dynar_t whereto)
 {
   xbt_assert((host != nullptr), "Invalid parameters");
   smx_actor_t actor = NULL;
-  xbt_swag_foreach(actor, host->processes()) {
+  xbt_swag_foreach(actor, host->extension<simgrid::simix::Host>()->process_list) {
     msg_process_t p = actor->ciface();
     xbt_dynar_push(whereto, &p);
   }
index f792b9c..e3c3635 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2006-2017. 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. */
@@ -195,11 +194,12 @@ void Host::setProperty(const char*key, const char *value){
 }
 
 /** Get the processes attached to the host */
-xbt_swag_t Host::processes()
+void Host::processes(std::vector<ActorPtr>* list)
 {
-  return simgrid::simix::kernelImmediate([this] {
-    return this->extension<simgrid::simix::Host>()->process_list;
-  });
+  smx_actor_t actor = NULL;
+  xbt_swag_foreach(actor, this->extension<simgrid::simix::Host>()->process_list) {
+    list->push_back(actor->iface());
+  }
 }
 
 /** @brief Get the peak processor speed (in flops/s), at the specified pstate  */
index 973b24d..aa6c13e 100644 (file)
@@ -358,28 +358,26 @@ void Comm::init_smp(){
    }
   //identify neighbours in comm
   //get the indexes of all processes sharing the same simix host
-  xbt_swag_t process_list = SIMIX_host_self()->processes();
-  int intra_comm_size = 0;
-  int i =0;
-  int min_index=INT_MAX;//the minimum index will be the leader
-  smx_actor_t process = nullptr;
-  xbt_swag_foreach(process, process_list) {
-    int index = process->pid -1;
+  xbt_swag_t process_list = SIMIX_host_self()->extension<simgrid::simix::Host>()->process_list;
+  int intra_comm_size     = 0;
+  int min_index           = INT_MAX;//the minimum index will be the leader
+  smx_actor_t actor       = nullptr;
+  xbt_swag_foreach(actor, process_list) {
+    int index = actor->pid -1;
 
     if(this->group()->rank(index)!=MPI_UNDEFINED){
-        intra_comm_size++;
+      intra_comm_size++;
       //the process is in the comm
       if(index < min_index)
         min_index=index;
-      i++;
     }
   }
   XBT_DEBUG("number of processes deployed on my node : %d", intra_comm_size);
   MPI_Group group_intra = new  Group(intra_comm_size);
-  i=0;
-  process = nullptr;
-  xbt_swag_foreach(process, process_list) {
-    int index = process->pid -1;
+  int i = 0;
+  actor = nullptr;
+  xbt_swag_foreach(actor, process_list) {
+    int index = actor->pid -1;
     if(this->group()->rank(index)!=MPI_UNDEFINED){
       group_intra->set_mapping(index, i);
       i++;