Skip to content

Commit 4453cf3

Browse files
authored
Merge pull request #13276 from edgargabriel/topic/comm-null-name
comm_get_name: allow MPI_COMM_NULL as argument
2 parents f67e216 + abd5c65 commit 4453cf3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

docs/man-openmpi/man3/MPI_Comm_get_name.3.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ occurs, :ref:`MPI_Comm_get_name` will return an empty string (all spaces in
3737
Fortran, "" in C). The three predefined communicators will have
3838
predefined names associated with them. Thus, the names of
3939
MPI_COMM_WORLD, MPI_COMM_SELF, and MPI_COMM_PARENT will have the default
40-
of MPI_COMM_WORLD, MPI_COMM_SELF, and MPI_COMM_PARENT. The fact that the
40+
of MPI_COMM_WORLD, MPI_COMM_SELF, and MPI_COMM_PARENT (if not MPI_COMM_NULL).
41+
Passing MPI_COMM_NULL as ``comm`` will return the string MPI_COMM_NULL. The fact that the
4142
system may have chosen to give a default name to a communicator does not
4243
prevent the user from setting a name on the same communicator; doing
4344
this removes the old name and assigns the new one.

ompi/mpi/c/comm_get_name.c.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2024 Triad National Security, LLC. All rights
1616
* reserved.
17+
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserverd.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -44,7 +45,9 @@ PROTOTYPE ERROR_CLASS comm_get_name(COMM comm, STRING_OUT name, INT_OUT length)
4445
if ( MPI_PARAM_CHECK ) {
4546
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
4647

47-
if ( ompi_comm_invalid ( comm ) )
48+
/* Note that MPI 4.1. explicitely allows to invoke comm_get_name
49+
on MPI_COMM_NULL */
50+
if (ompi_comm_invalid(comm) && MPI_COMM_NULL != comm)
4851
return OMPI_ERRHANDLER_INVOKE ( MPI_COMM_WORLD, MPI_ERR_COMM,
4952
FUNC_NAME);
5053

0 commit comments

Comments
 (0)