From 11d44cec1b96d10c0d58ea7c800d940e168331e1 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 19 Aug 2009 13:24:12 +0000 Subject: [PATCH] Fix MPI_COMM_SPAWN[_MULTIPLE] to only check the info handles for errors on the root. Thanks to Federico Golfre Andreasi for reporting the problem. This commit was SVN r21838. --- ompi/mpi/c/comm_spawn.c | 12 +++--- ompi/mpi/c/comm_spawn_multiple.c | 72 ++++++++++++++++---------------- 2 files changed, 43 insertions(+), 41 deletions(-) diff --git a/ompi/mpi/c/comm_spawn.c b/ompi/mpi/c/comm_spawn.c index 8e7383b10a..f36f8c8727 100644 --- a/ompi/mpi/c/comm_spawn.c +++ b/ompi/mpi/c/comm_spawn.c @@ -71,10 +71,6 @@ int MPI_Comm_spawn(char *command, char **argv, int maxprocs, MPI_Info info, return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } - if (NULL == info || ompi_info_is_freed(info)) { - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO, - FUNC_NAME); - } } rank = ompi_comm_rank ( comm ); @@ -88,6 +84,10 @@ int MPI_Comm_spawn(char *command, char **argv, int maxprocs, MPI_Info info, return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } + if (NULL == info || ompi_info_is_freed(info)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO, + FUNC_NAME); + } } } @@ -95,7 +95,9 @@ int MPI_Comm_spawn(char *command, char **argv, int maxprocs, MPI_Info info, memset(port_name, 0, MPI_MAX_PORT_NAME); /* See if the info key "ompi_non_mpi" was set to true */ - ompi_info_get_bool(info, "ompi_non_mpi", &non_mpi, &flag); + if (rank == root) { + ompi_info_get_bool(info, "ompi_non_mpi", &non_mpi, &flag); + } OPAL_CR_ENTER_LIBRARY(); diff --git a/ompi/mpi/c/comm_spawn_multiple.c b/ompi/mpi/c/comm_spawn_multiple.c index fff8c9e2cf..21e3d505e2 100644 --- a/ompi/mpi/c/comm_spawn_multiple.c +++ b/ompi/mpi/c/comm_spawn_multiple.c @@ -69,35 +69,6 @@ int MPI_Comm_spawn_multiple(int count, char **array_of_commands, char ***array_o if ( NULL == intercomm ) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } - if (NULL == array_of_info) { - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO, - FUNC_NAME); - } - for (i = 0; i < count; ++i) { - if (NULL == array_of_info[i] || - ompi_info_is_freed(array_of_info[i])) { - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO, - FUNC_NAME); - } - /* If ompi_non_mpi is set to true on any info, it must be - set to true on all of them. Note that not setting - ompi_non_mpi is the same as setting it to false. */ - ompi_info_get_bool(array_of_info[i], "ompi_non_mpi", &non_mpi, - &flag); - if (flag && 0 == i) { - /* If this is the first info, save its ompi_non_mpi value */ - cumulative = non_mpi; - } else if (!flag) { - non_mpi = false; - } - /* If this info's effective value doesn't agree with the - rest of them, error */ - if (cumulative != non_mpi) { - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, - MPI_ERR_INFO, - FUNC_NAME); - } - } } rank = ompi_comm_rank ( comm ); @@ -113,7 +84,34 @@ int MPI_Comm_spawn_multiple(int count, char **array_of_commands, char ***array_o return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } if ( NULL == array_of_info ) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); + return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_INFO, FUNC_NAME); + } + for (i = 0; i < count; ++i) { + if (NULL == array_of_info[i] || + ompi_info_is_freed(array_of_info[i])) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO, + FUNC_NAME); + } + /* If ompi_non_mpi is set to true on any info, it must + be set to true on all of them. Note that not + setting ompi_non_mpi is the same as setting it to + false. */ + ompi_info_get_bool(array_of_info[i], "ompi_non_mpi", &non_mpi, + &flag); + if (flag && 0 == i) { + /* If this is the first info, save its + ompi_non_mpi value */ + cumulative = non_mpi; + } else if (!flag) { + non_mpi = false; + } + /* If this info's effective value doesn't agree with + the rest of them, error */ + if (cumulative != non_mpi) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, + MPI_ERR_INFO, + FUNC_NAME); + } } for ( i=0; i