From 124ca9c2ff7969f3d18a9f5ac8b6708a191010e0 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Sat, 19 Feb 2022 14:15:35 -0500 Subject: [PATCH] Allow name query for all predefined NULL MPI objects. This applies to MPI_DATATYPE_NULL, MPI_COMM_NULL and MPI_WIN_NULL. MPI 4.0 states that "The predefined constant MPI_COMM_NULL is the value used for invalid communicator handles." Hence, we might assume that MPI_COMM_NULL is an invalid communicator, but that is only partially true because in 4.12.4 it is clearly stated that the translation function, MPI_*_C2F and MPI_*_F2C, should treat MPI_COMM_NULL as a valiid communicator. So, the real role of these MPI_*_NULL objects might be to point to valid MPI objects used as bounds, but they represent valid MPI objects that cannot be used for communications. In any case, as predefined handles they have an associated name, and the user _must_ be able to get this name. Signed-off-by: George Bosilca --- ompi/mpi/c/comm_get_name.c | 8 ++++++-- ompi/mpi/c/type_get_name.c | 2 +- ompi/mpi/c/win_get_name.c | 9 +++++++-- ompi/win/win.c | 3 +-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ompi/mpi/c/comm_get_name.c b/ompi/mpi/c/comm_get_name.c index e635b768505..ddb4875819f 100644 --- a/ompi/mpi/c/comm_get_name.c +++ b/ompi/mpi/c/comm_get_name.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2005 The University of Tennessee and The University + * Copyright (c) 2004-2022 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -52,7 +52,11 @@ int MPI_Comm_get_name(MPI_Comm comm, char *name, int *length) if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if ( ompi_comm_invalid ( comm ) ) + /* Do not use ompi_comm_invalid, it prevent returning + * the name for the predefined MPI_COMM_NULL. + */ + if ((NULL == comm) || + (OMPI_COMM_IS_FREED(comm)) || (OMPI_COMM_IS_INVALID(comm)) ) return OMPI_ERRHANDLER_INVOKE ( MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); diff --git a/ompi/mpi/c/type_get_name.c b/ompi/mpi/c/type_get_name.c index b38697a1bc1..e6b8d8a97d5 100644 --- a/ompi/mpi/c/type_get_name.c +++ b/ompi/mpi/c/type_get_name.c @@ -51,7 +51,7 @@ int MPI_Type_get_name(MPI_Datatype type, char *type_name, int *resultlen) if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (NULL == type || MPI_DATATYPE_NULL == type) { + if (NULL == type) { return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_TYPE, FUNC_NAME ); } else if (NULL == type_name || NULL == resultlen) { diff --git a/ompi/mpi/c/win_get_name.c b/ompi/mpi/c/win_get_name.c index 6d745c05a5f..375a31641b7 100644 --- a/ompi/mpi/c/win_get_name.c +++ b/ompi/mpi/c/win_get_name.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2020 The University of Tennessee and The University + * Copyright (c) 2004-2022 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -44,7 +44,12 @@ int MPI_Win_get_name(MPI_Win win, char *win_name, int *resultlen) if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (ompi_win_invalid(win)) { + /* Do not use ompi_comm_invalid, it prevent returning + * the name for the predefined MPI_COMM_NULL. + */ + if (NULL == win || + (OMPI_WIN_INVALID & win->w_flags) || + (OMPI_WIN_FREED & win->w_flags)) { return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_WIN, FUNC_NAME); } else if (NULL == win_name || NULL == resultlen) { return OMPI_ERRHANDLER_INVOKE(win, MPI_ERR_ARG, FUNC_NAME); diff --git a/ompi/win/win.c b/ompi/win/win.c index 70e70c978e8..4113165d1f0 100644 --- a/ompi/win/win.c +++ b/ompi/win/win.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2022 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -124,7 +124,6 @@ int ompi_win_init (void) /* Setup MPI_WIN_NULL */ OBJ_CONSTRUCT(&ompi_mpi_win_null.win, ompi_win_t); - ompi_mpi_win_null.win.w_flags = OMPI_WIN_INVALID; ompi_mpi_win_null.win.w_group = &ompi_mpi_group_null.group; OBJ_RETAIN(&ompi_mpi_group_null); ompi_win_set_name(&ompi_mpi_win_null.win, "MPI_WIN_NULL");