Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
functioning MPI_Comm_get_name, MPI_Comm_set_name
authordegomme <adegomme@users.noreply.github.com>
Tue, 2 Apr 2019 13:55:27 +0000 (15:55 +0200)
committerdegomme <adegomme@users.noreply.github.com>
Tue, 2 Apr 2019 13:58:49 +0000 (15:58 +0200)
12 files changed:
src/smpi/bindings/smpi_f77_comm.cpp
src/smpi/bindings/smpi_mpi.cpp
src/smpi/bindings/smpi_pmpi_comm.cpp
src/smpi/include/private.hpp
src/smpi/include/smpi_comm.hpp
src/smpi/mpi/smpi_comm.cpp
teshsuite/smpi/mpich3-test/comm/CMakeLists.txt
teshsuite/smpi/mpich3-test/comm/testlist
teshsuite/smpi/mpich3-test/f77/comm/CMakeLists.txt
teshsuite/smpi/mpich3-test/f77/comm/testlist
teshsuite/smpi/mpich3-test/f77/testlist
teshsuite/smpi/mpich3-test/util/mtest.c

index 1332fdc..750ea02 100644 (file)
@@ -102,7 +102,8 @@ void mpi_comm_free_keyval_ (int* keyval, int* ierr) {
 void mpi_comm_get_name_ (int* comm, char* name, int* len, int* ierr){
  *ierr = MPI_Comm_get_name(simgrid::smpi::Comm::f2c(*comm), name, len);
   if(*len>0)
 void mpi_comm_get_name_ (int* comm, char* name, int* len, int* ierr){
  *ierr = MPI_Comm_get_name(simgrid::smpi::Comm::f2c(*comm), name, len);
   if(*len>0)
-    name[*len]=' ';
+    for(int i = *len; i<MPI_MAX_OBJECT_NAME+1; i++)
+      name[i]=' ';
 }
 
 void mpi_comm_compare_ (int* comm1, int* comm2, int *result, int* ierr){
 }
 
 void mpi_comm_compare_ (int* comm1, int* comm2, int *result, int* ierr){
@@ -142,10 +143,13 @@ void mpi_comm_remote_size_ (int* comm, int* size, int* ierr) {
  *ierr = MPI_Comm_remote_size(simgrid::smpi::Comm::f2c(*comm), size);
 }
 
  *ierr = MPI_Comm_remote_size(simgrid::smpi::Comm::f2c(*comm), size);
 }
 
-void mpi_comm_set_name_ (int* comm, char* name, int* ierr, int size){
- char* tname = xbt_new(char, size+1);
- strncpy(tname, name, size);
- tname[size]='\0';
+void mpi_comm_set_name_ (int* comm, char* name, int* ierr){
+ int count;
+ for(count=MPI_MAX_OBJECT_NAME-1; count>=0 && name[count]==' '; count--);
+ count+=1;
+ char* tname = xbt_new(char, count+1);
+ strncpy(tname, name, count);
+ tname[count]='\0';
  *ierr = MPI_Comm_set_name (simgrid::smpi::Comm::f2c(*comm), tname);
  xbt_free(tname);
 }
  *ierr = MPI_Comm_set_name (simgrid::smpi::Comm::f2c(*comm), tname);
  xbt_free(tname);
 }
index 96e2fd3..e398d05 100644 (file)
@@ -103,6 +103,7 @@ WRAPPED_PMPI_CALL(int,MPI_Comm_free_keyval,(int* keyval) ,( keyval))
 WRAPPED_PMPI_CALL(int,MPI_Comm_free,(MPI_Comm * comm),(comm))
 WRAPPED_PMPI_CALL(int,MPI_Comm_get_attr ,(MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag),(comm, comm_keyval, attribute_val, flag))
 WRAPPED_PMPI_CALL(int,MPI_Comm_get_name ,(MPI_Comm comm, char* name, int* len),(comm, name, len))
 WRAPPED_PMPI_CALL(int,MPI_Comm_free,(MPI_Comm * comm),(comm))
 WRAPPED_PMPI_CALL(int,MPI_Comm_get_attr ,(MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag),(comm, comm_keyval, attribute_val, flag))
 WRAPPED_PMPI_CALL(int,MPI_Comm_get_name ,(MPI_Comm comm, char* name, int* len),(comm, name, len))
+WRAPPED_PMPI_CALL(int,MPI_Comm_set_name ,(MPI_Comm comm, char* name),(comm, name))
 WRAPPED_PMPI_CALL(int,MPI_Comm_group,(MPI_Comm comm, MPI_Group * group),(comm, group))
 WRAPPED_PMPI_CALL(int,MPI_Comm_rank,(MPI_Comm comm, int *rank),(comm, rank))
 WRAPPED_PMPI_CALL(int,MPI_Comm_set_attr ,(MPI_Comm comm, int comm_keyval, void *attribute_val),( comm, comm_keyval, attribute_val))
 WRAPPED_PMPI_CALL(int,MPI_Comm_group,(MPI_Comm comm, MPI_Group * group),(comm, group))
 WRAPPED_PMPI_CALL(int,MPI_Comm_rank,(MPI_Comm comm, int *rank),(comm, rank))
 WRAPPED_PMPI_CALL(int,MPI_Comm_set_attr ,(MPI_Comm comm, int comm_keyval, void *attribute_val),( comm, comm_keyval, attribute_val))
@@ -331,7 +332,6 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_remote_group,(MPI_Comm comm, MPI_Gr
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_remote_size,(MPI_Comm comm, int* size) ,(comm, size))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_errhandler,(MPI_Comm comm, MPI_Errhandler errhandler) ,(comm, errhandler))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_info ,(MPI_Comm comm, MPI_Info info),(comm, info))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_remote_size,(MPI_Comm comm, int* size) ,(comm, size))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_errhandler,(MPI_Comm comm, MPI_Errhandler errhandler) ,(comm, errhandler))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_info ,(MPI_Comm comm, MPI_Info info),(comm, info))
-UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_name ,(MPI_Comm comm, char* name),(comm, name))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn,( char *command, char **argv, int maxprocs, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes),( command, argv, maxprocs, info, root, comm, intercomm, array_of_errcodes))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn_multiple,(int count, char **array_of_commands, char*** array_of_argv, int* array_of_maxprocs, MPI_Info* array_of_info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes), (count, array_of_commands, array_of_argv, array_of_maxprocs, array_of_info, root, comm, intercomm, array_of_errcodes))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_test_inter,(MPI_Comm comm, int* flag) ,(comm, flag))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn,( char *command, char **argv, int maxprocs, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes),( command, argv, maxprocs, info, root, comm, intercomm, array_of_errcodes))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn_multiple,(int count, char **array_of_commands, char*** array_of_argv, int* array_of_maxprocs, MPI_Info* array_of_info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes), (count, array_of_commands, array_of_argv, array_of_maxprocs, array_of_info, root, comm, intercomm, array_of_errcodes))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_test_inter,(MPI_Comm comm, int* flag) ,(comm, flag))
index 8916ec9..07a2904 100644 (file)
@@ -49,6 +49,18 @@ int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
   }
 }
 
   }
 }
 
+int PMPI_Comm_set_name (MPI_Comm comm, char* name)
+{
+  if (comm == MPI_COMM_NULL)  {
+    return MPI_ERR_COMM;
+  } else if (name == nullptr)  {
+    return MPI_ERR_ARG;
+  } else {
+    comm->set_name(name);
+    return MPI_SUCCESS;
+  }
+}
+
 int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
 {
   if (comm == MPI_COMM_NULL) {
 int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
 {
   if (comm == MPI_COMM_NULL) {
index 3cbfafa..de6dff6 100644 (file)
@@ -394,7 +394,7 @@ void mpi_type_create_resized_(int* oldtype, MPI_Aint* lb, MPI_Aint* extent, int*
 void mpi_type_create_subarray_(int* ndims, int* array_of_sizes, int* array_of_subsizes, int* array_of_starts,
                                int* order, int* oldtype, int* newtype, int* ierr);
 void mpi_type_match_size_(int* typeclass, int* size, int* datatype, int* ierr);
 void mpi_type_create_subarray_(int* ndims, int* array_of_sizes, int* array_of_subsizes, int* array_of_starts,
                                int* order, int* oldtype, int* newtype, int* ierr);
 void mpi_type_match_size_(int* typeclass, int* size, int* datatype, int* ierr);
-void mpi_comm_set_name_(int* comm, char* name, int* ierr, int size);
+void mpi_comm_set_name_(int* comm, char* name, int* ierr);
 void mpi_comm_dup_with_info_(int* comm, int* info, int* newcomm, int* ierr);
 void mpi_comm_split_type_(int* comm, int* split_type, int* key, int* info, int* newcomm, int* ierr);
 void mpi_comm_set_info_(int* comm, int* info, int* ierr);
 void mpi_comm_dup_with_info_(int* comm, int* info, int* newcomm, int* ierr);
 void mpi_comm_split_type_(int* comm, int* split_type, int* key, int* info, int* newcomm, int* ierr);
 void mpi_comm_set_info_(int* comm, int* info, int* ierr);
index e43c5b3..6d68c96 100644 (file)
@@ -28,6 +28,7 @@ class Comm : public F2C, public Keyval{
   int is_blocked_;              // are ranks allocated on the same smp node contiguous ?
   int is_smp_comm_;             // set to 0 in case this is already an intra-comm or a leader-comm to avoid recursivity
   std::list<MPI_Win> rma_wins_; // attached windows for synchronization.
   int is_blocked_;              // are ranks allocated on the same smp node contiguous ?
   int is_smp_comm_;             // set to 0 in case this is already an intra-comm or a leader-comm to avoid recursivity
   std::list<MPI_Win> rma_wins_; // attached windows for synchronization.
+  std::string name_;
 
 public:
   static std::unordered_map<int, smpi_key_elem> keyvals_;
 
 public:
   static std::unordered_map<int, smpi_key_elem> keyvals_;
@@ -41,6 +42,7 @@ public:
   int size();
   int rank();
   void get_name(char* name, int* len);
   int size();
   int rank();
   void get_name(char* name, int* len);
+  void set_name(char* name);
   void set_leaders_comm(MPI_Comm leaders);
   void set_intra_comm(MPI_Comm leaders) { intra_comm_ = leaders; };
   int* get_non_uniform_map();
   void set_leaders_comm(MPI_Comm leaders);
   void set_intra_comm(MPI_Comm leaders) { intra_comm_ = leaders; };
   int* get_non_uniform_map();
index b2ca92d..92d2f49 100644 (file)
@@ -118,14 +118,27 @@ void Comm::get_name (char* name, int* len)
     smpi_process()->comm_world()->get_name(name, len);
     return;
   }
     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 {
   } 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);
 void Comm::set_leaders_comm(MPI_Comm leaders){
   if (this == MPI_COMM_UNINITIALIZED){
     smpi_process()->comm_world()->set_leaders_comm(leaders);
index 712e5d5..062941a 100644 (file)
@@ -10,9 +10,9 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
   include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include/")
 
   foreach(file cmfree cmsplit2 cmsplit cmsplit_type commcreate1 comm_create_group comm_group_half comm_group_rand 
   include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include/")
 
   foreach(file cmfree cmsplit2 cmsplit cmsplit_type commcreate1 comm_create_group comm_group_half comm_group_rand 
-          comm_info ctxalloc ctxsplit dup dup_with_info) 
+          comm_info ctxalloc ctxsplit dup dup_with_info commname
     # not compiled files
     # not compiled files
-    # comm_idup comm_idup_mul comm_idup_overlap commname dupic ic1 ic2 iccreate icgroup icm icsplit probe-intercomm 
+    # comm_idup comm_idup_mul comm_idup_overlap  dupic ic1 ic2 iccreate icgroup icm icsplit probe-intercomm 
     add_executable(${file} EXCLUDE_FROM_ALL ${file}.c)
     add_dependencies(tests ${file})
     target_link_libraries(${file} simgrid mtest_c)
     add_executable(${file} EXCLUDE_FROM_ALL ${file}.c)
     add_dependencies(tests ${file})
     target_link_libraries(${file} simgrid mtest_c)
index f8b8296..694b941 100644 (file)
@@ -4,8 +4,7 @@ dup 2
 #works, but needs MPI_Comm_set_name
 commcreate1 8
 commcreate1 1
 #works, but needs MPI_Comm_set_name
 commcreate1 8
 commcreate1 1
-#needs MPI_Comm_set_name and MPI_Intercomm_create
-#commname 4
+commname 4
 #ic1 4
 # ic2 needs an unusually large number of processes (>= 33)
 #ic2 33
 #ic1 4
 # ic2 needs an unusually large number of processes (>= 33)
 #ic2 33
index 8867e04..44b8e3e 100644 (file)
@@ -9,12 +9,12 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite AND SMPI_FORTRAN)
   include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
 
  # add_executable(commerrf EXCLUDE_FROM_ALL commerrf.f)
   include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
 
  # add_executable(commerrf EXCLUDE_FROM_ALL commerrf.f)
- # add_executable(commnamef EXCLUDE_FROM_ALL commnamef.f)
-
- # add_dependencies(tests commerrf commnamef)
+  add_executable(commnamef EXCLUDE_FROM_ALL commnamef.f)
 
 
+  add_dependencies(tests commnamef)
+ # add_dependencies(tests commerrf)
  # target_link_libraries(commerrf simgrid mtest_f77)
  # target_link_libraries(commerrf simgrid mtest_f77)
# target_link_libraries(commnamef simgrid mtest_f77)
+  target_link_libraries(commnamef simgrid mtest_f77)
 endif()
 
 set(examples_src
 endif()
 
 set(examples_src
index 5118b48..daa68d6 100644 (file)
@@ -7,6 +7,6 @@ info
 #io
 rma
 init
 #io
 rma
 init
-#comm
+comm
 ext
 topo
 ext
 topo
index 98ed601..23af52b 100644 (file)
@@ -1033,9 +1033,9 @@ int MTestGetComm(MPI_Comm * comm, int min_size)
 
     if (!getinter) {
         idx = MTestGetIntracomm(comm, min_size);
 
     if (!getinter) {
         idx = MTestGetIntracomm(comm, min_size);
-        if (idx == 0) {
-            getinter = 1;
-        }
+/*        if (idx == 0) {*/
+/*            getinter = 1;*/
+/*        }*/
     }
     if (getinter) {
         int isLeft;
     }
     if (getinter) {
         int isLeft;