From e8f8350f07c1b13dd8628f56d5a5050da18264d3 Mon Sep 17 00:00:00 2001 From: Pierre-Nicolas Clauss Date: Thu, 31 Mar 2011 17:06:13 +0200 Subject: [PATCH] Added one more missing MPI call. --- include/smpi/smpi.h | 2 ++ src/smpi/private.h | 1 + src/smpi/smpi_comm.c | 10 ++++++++++ src/smpi/smpi_mpi.c | 5 +++++ src/smpi/smpi_pmpi.c | 17 +++++++++++++++++ 5 files changed, 35 insertions(+) diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index aac82f0384..4b5e72c858 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -23,6 +23,7 @@ SG_BEGIN_DECL() #define MPI_THREAD_MULTIPLE 3 //FIXME: check values #define MPI_MAX_PROCESSOR_NAME 100 +#define MPI_MAX_NAME_STRING 100 #define MPI_MAX_ERROR_STRING 100 #define MPI_MAX_DATAREP_STRIN 100 #define MPI_MAX_INFO_KEY 100 @@ -208,6 +209,7 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Group_range_excl, MPI_CALL(XBT_PUBLIC(int), MPI_Comm_rank, (MPI_Comm comm, int *rank)); MPI_CALL(XBT_PUBLIC(int), MPI_Comm_size, (MPI_Comm comm, int *size)); +MPI_CALL(XBT_PUBLIC(int), MPI_Comm_get_name, (MPI_Comm comm, char* name, int* len)); MPI_CALL(XBT_PUBLIC(int), MPI_Get_processor_name, (char *name, int *resultlen)); MPI_CALL(XBT_PUBLIC(int), MPI_Get_count, (MPI_Status * status, MPI_Datatype datatype, diff --git a/src/smpi/private.h b/src/smpi/private.h index 12bf309a46..d457c767b4 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -83,6 +83,7 @@ MPI_Comm smpi_comm_new(MPI_Group group); void smpi_comm_destroy(MPI_Comm comm); MPI_Group smpi_comm_group(MPI_Comm comm); int smpi_comm_size(MPI_Comm comm); +void smpi_comm_get_name(MPI_Comm comm, char* name, int* len); int smpi_comm_rank(MPI_Comm comm); MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key); diff --git a/src/smpi/smpi_comm.c b/src/smpi/smpi_comm.c index 70267cd79e..c189c4d569 100644 --- a/src/smpi/smpi_comm.c +++ b/src/smpi/smpi_comm.c @@ -67,6 +67,16 @@ int smpi_comm_rank(MPI_Comm comm) return smpi_group_rank(smpi_comm_group(comm), smpi_process_index()); } +void smpi_comm_get_name (MPI_Comm comm, char* name, int* len) +{ + if(comm == MPI_COMM_WORLD) { + strcpy(name, "WORLD"); + *len = 5; + } else { + *len = snprintf(name, MPI_MAX_NAME_STRING, "%p", comm); + } +} + MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key) { int system_tag = 666; diff --git a/src/smpi/smpi_mpi.c b/src/smpi/smpi_mpi.c index e8dfd05570..c709e0aaec 100644 --- a/src/smpi/smpi_mpi.c +++ b/src/smpi/smpi_mpi.c @@ -164,6 +164,11 @@ int MPI_Comm_size(MPI_Comm comm, int *size) return PMPI_Comm_size(comm, size); } +int MPI_Comm_get_name (MPI_Comm comm, char* name, int* len) +{ + return PMPI_Comm_get_name(comm, name, len); +} + int MPI_Comm_group(MPI_Comm comm, MPI_Group * group) { return PMPI_Comm_group(comm, group); diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.c index d229642b43..0422b98b76 100644 --- a/src/smpi/smpi_pmpi.c +++ b/src/smpi/smpi_pmpi.c @@ -649,6 +649,23 @@ int PMPI_Comm_size(MPI_Comm comm, int *size) return retval; } +int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len) +{ + int retval; + + smpi_bench_end(); + if (comm == MPI_COMM_NULL) { + retval = MPI_ERR_COMM; + } else if (name == NULL || len == NULL) { + retval = MPI_ERR_ARG; + } else { + smpi_comm_get_name(comm, name, len); + retval = MPI_SUCCESS; + } + smpi_bench_begin(); + return retval; +} + int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group) { int retval; -- 2.20.1