From: degomme Date: Tue, 2 Apr 2019 13:55:27 +0000 (+0200) Subject: functioning MPI_Comm_get_name, MPI_Comm_set_name X-Git-Tag: v3.22.1~24 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b1f5b9489d84e72cc1c4a0b51fe3940526de890c functioning MPI_Comm_get_name, MPI_Comm_set_name --- diff --git a/src/smpi/bindings/smpi_f77_comm.cpp b/src/smpi/bindings/smpi_f77_comm.cpp index 1332fdc8e0..750ea02a62 100644 --- a/src/smpi/bindings/smpi_f77_comm.cpp +++ b/src/smpi/bindings/smpi_f77_comm.cpp @@ -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) - name[*len]=' '; + for(int i = *len; i=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); } diff --git a/src/smpi/bindings/smpi_mpi.cpp b/src/smpi/bindings/smpi_mpi.cpp index 96e2fd3270..e398d05931 100644 --- a/src/smpi/bindings/smpi_mpi.cpp +++ b/src/smpi/bindings/smpi_mpi.cpp @@ -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_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)) @@ -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_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)) diff --git a/src/smpi/bindings/smpi_pmpi_comm.cpp b/src/smpi/bindings/smpi_pmpi_comm.cpp index 8916ec972e..07a290470d 100644 --- a/src/smpi/bindings/smpi_pmpi_comm.cpp +++ b/src/smpi/bindings/smpi_pmpi_comm.cpp @@ -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) { diff --git a/src/smpi/include/private.hpp b/src/smpi/include/private.hpp index 3cbfafa529..de6dff608a 100644 --- a/src/smpi/include/private.hpp +++ b/src/smpi/include/private.hpp @@ -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_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); diff --git a/src/smpi/include/smpi_comm.hpp b/src/smpi/include/smpi_comm.hpp index e43c5b3e74..6d68c964e4 100644 --- a/src/smpi/include/smpi_comm.hpp +++ b/src/smpi/include/smpi_comm.hpp @@ -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 rma_wins_; // attached windows for synchronization. + std::string name_; public: static std::unordered_map keyvals_; @@ -41,6 +42,7 @@ public: 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(); diff --git a/src/smpi/mpi/smpi_comm.cpp b/src/smpi/mpi/smpi_comm.cpp index b2ca92de2d..92d2f499fe 100644 --- a/src/smpi/mpi/smpi_comm.cpp +++ b/src/smpi/mpi/smpi_comm.cpp @@ -118,14 +118,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); diff --git a/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt b/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt index 712e5d5f09..062941a4b3 100644 --- a/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt +++ b/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt @@ -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 - comm_info ctxalloc ctxsplit dup dup_with_info) + comm_info ctxalloc ctxsplit dup dup_with_info commname) # 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) diff --git a/teshsuite/smpi/mpich3-test/comm/testlist b/teshsuite/smpi/mpich3-test/comm/testlist index f8b8296ce8..694b941f0b 100644 --- a/teshsuite/smpi/mpich3-test/comm/testlist +++ b/teshsuite/smpi/mpich3-test/comm/testlist @@ -4,8 +4,7 @@ dup 2 #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 diff --git a/teshsuite/smpi/mpich3-test/f77/comm/CMakeLists.txt b/teshsuite/smpi/mpich3-test/f77/comm/CMakeLists.txt index 8867e046a2..44b8e3ed16 100644 --- a/teshsuite/smpi/mpich3-test/f77/comm/CMakeLists.txt +++ b/teshsuite/smpi/mpich3-test/f77/comm/CMakeLists.txt @@ -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) - # 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(commnamef simgrid mtest_f77) + target_link_libraries(commnamef simgrid mtest_f77) endif() set(examples_src diff --git a/teshsuite/smpi/mpich3-test/f77/comm/testlist b/teshsuite/smpi/mpich3-test/f77/comm/testlist index 6523065976..1d0063b565 100644 --- a/teshsuite/smpi/mpich3-test/f77/comm/testlist +++ b/teshsuite/smpi/mpich3-test/f77/comm/testlist @@ -1,2 +1,2 @@ -#commnamef 2 +commnamef 2 #commerrf 2 diff --git a/teshsuite/smpi/mpich3-test/f77/testlist b/teshsuite/smpi/mpich3-test/f77/testlist index 5118b48274..daa68d6990 100644 --- a/teshsuite/smpi/mpich3-test/f77/testlist +++ b/teshsuite/smpi/mpich3-test/f77/testlist @@ -7,6 +7,6 @@ info #io rma init -#comm +comm ext topo diff --git a/teshsuite/smpi/mpich3-test/util/mtest.c b/teshsuite/smpi/mpich3-test/util/mtest.c index 98ed601e97..23af52b661 100644 --- a/teshsuite/smpi/mpich3-test/util/mtest.c +++ b/teshsuite/smpi/mpich3-test/util/mtest.c @@ -1033,9 +1033,9 @@ int MTestGetComm(MPI_Comm * comm, int min_size) if (!getinter) { idx = MTestGetIntracomm(comm, min_size); - if (idx == 0) { - getinter = 1; - } +/* if (idx == 0) {*/ +/* getinter = 1;*/ +/* }*/ } if (getinter) { int isLeft;