Skip to content

comm_get_name: allow MPI_COMM_NULL as argument #13276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/man-openmpi/man3/MPI_Comm_get_name.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ occurs, :ref:`MPI_Comm_get_name` will return an empty string (all spaces in
Fortran, "" in C). The three predefined communicators will have
predefined names associated with them. Thus, the names of
MPI_COMM_WORLD, MPI_COMM_SELF, and MPI_COMM_PARENT will have the default
of MPI_COMM_WORLD, MPI_COMM_SELF, and MPI_COMM_PARENT. The fact that the
of MPI_COMM_WORLD, MPI_COMM_SELF, and MPI_COMM_PARENT (if not MPI_COMM_NULL).
Passing MPI_COMM_NULL as ``comm`` will return the string MPI_COMM_NULL. The fact that the
system may have chosen to give a default name to a communicator does not
prevent the user from setting a name on the same communicator; doing
this removes the old name and assigns the new one.
Expand Down
5 changes: 4 additions & 1 deletion ompi/mpi/c/comm_get_name.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2024 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserverd.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -44,7 +45,9 @@ PROTOTYPE ERROR_CLASS comm_get_name(COMM comm, STRING_OUT name, INT_OUT length)
if ( MPI_PARAM_CHECK ) {
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);

if ( ompi_comm_invalid ( comm ) )
/* Note that MPI 4.1. explicitely allows to invoke comm_get_name
on MPI_COMM_NULL */
if (ompi_comm_invalid(comm) && MPI_COMM_NULL != comm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assumedly the rest of this function will work properly if MPI_COMM_NULL is passed (e.g., return the string MPI_COMM_NULL)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I tested it :-)

return OMPI_ERRHANDLER_INVOKE ( MPI_COMM_WORLD, MPI_ERR_COMM,
FUNC_NAME);

Expand Down