Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
constify MPI_Group*
[simgrid.git] / src / smpi / mpi / smpi_comm.cpp
index b2ca92d..f3cec23 100644 (file)
@@ -8,6 +8,7 @@
 #include "smpi_datatype.hpp"
 #include "smpi_request.hpp"
 #include "smpi_win.hpp"
+#include "smpi_info.hpp"
 #include "src/smpi/include/smpi_actor.hpp"
 #include "src/surf/HostImpl.hpp"
 
@@ -118,14 +119,27 @@ void Comm::get_name (char* name, int* len)
     smpi_process()->comm_world()->get_name(name, len);
     return;
   }
-  if(this == MPI_COMM_WORLD) {
-    strncpy(name, "WORLD", 6);
-    *len = 5;
+  if(this == MPI_COMM_WORLD && name_.empty()) {
+    strncpy(name, "MPI_COMM_WORLD", 15);
+    *len = 14;
+  } else if(this == MPI_COMM_SELF && name_.empty()) {
+    strncpy(name, "MPI_COMM_SELF", 14);
+    *len = 13;
   } else {
-    *len = snprintf(name, MPI_MAX_NAME_STRING, "%p", this);
+    *len = snprintf(name, MPI_MAX_NAME_STRING+1, "%s", name_.c_str());
   }
 }
 
+void Comm::set_name (char* name)
+{
+  if (this == MPI_COMM_UNINITIALIZED){
+    smpi_process()->comm_world()->set_name(name);
+    return;
+  }
+  name_.replace (0, MPI_MAX_NAME_STRING+1, name);
+}
+
+
 void Comm::set_leaders_comm(MPI_Comm leaders){
   if (this == MPI_COMM_UNINITIALIZED){
     smpi_process()->comm_world()->set_leaders_comm(leaders);
@@ -490,7 +504,20 @@ void Comm::finish_rma_calls(){
   }
 }
 
-MPI_Comm Comm::split_type(int type, int key, MPI_Info info)
+MPI_Info Comm::info(){
+  if(info_== MPI_INFO_NULL)
+    info_ = new Info();
+  info_->ref();
+  return info_;
+}
+
+void Comm::set_info(MPI_Info info){
+  if(info_!= MPI_INFO_NULL)
+    info->ref();
+  info_=info;
+}
+
+MPI_Comm Comm::split_type(int type, int /*key*/, MPI_Info)
 {
   if(type != MPI_COMM_TYPE_SHARED){
     return MPI_COMM_NULL;