[mpich-devel] proper way to detect if program launched by mpiexec?
Balaji, Pavan
balaji at anl.gov
Mon Oct 20 11:44:33 CDT 2014
This is a known issue with MPICH. There’s no portable way to detect this, but for MPICH you can look for PMI variables in the environment.
— Pavan
> On Oct 20, 2014, at 11:34 AM, Jeff Hammond <jeff.science at gmail.com> wrote:
>
> I wrote a trivial program that uses MPI_Comm_spawn. It works when I
> launch with mpiexec but not if I run directly.
>
> 1) Is this a bug in MPICH?
> 2) What is the proper way for the program to detect how the program
> was launched? I would like to provide a helpful warning message...
>
> Thanks!
>
> Jeff
>
> jrhammon-mac01:comm_spawn jrhammon$ ./parent
> I am 0 of 1 for the parent program.
> [mpiexec at jrhammon-mac01.local] match_arg
> (../../../../src/pm/hydra/utils/args/args.c:159): unrecognized
> argument pmi_args
> [mpiexec at jrhammon-mac01.local] HYDU_parse_array
> (../../../../src/pm/hydra/utils/args/args.c:174): argument matching
> returned error
> [mpiexec at jrhammon-mac01.local] parse_args
> (../../../../src/pm/hydra/ui/mpich/utils.c:1596): error parsing input
> array
> [mpiexec at jrhammon-mac01.local] HYD_uii_mpx_get_parameters
> (../../../../src/pm/hydra/ui/mpich/utils.c:1648): unable to parse user
> arguments
> [mpiexec at jrhammon-mac01.local] main
> (../../../../src/pm/hydra/ui/mpich/mpiexec.c:153): error parsing
> parameters
> ^C
>
> jrhammon-mac01:comm_spawn jrhammon$ mpiexec -n 1 ./parent
> I am 0 of 1 for the parent program.
> I am 0 of 1 for the child program.
>
> ==> parent.c <==
> #include <stdio.h>
> #include <mpi.h>
>
> int main(int argc, char * argv[])
> {
> MPI_Init(&argc,&argv);
>
> int size, rank;
> MPI_Comm_size(MPI_COMM_WORLD, &size);
> MPI_Comm_rank(MPI_COMM_WORLD, &rank);
>
> printf("I am %d of %d for the parent program.\n", rank, size);
>
> MPI_Comm intercomm;
> int errors[size];
> MPI_Comm_spawn( (char*)"./child", MPI_ARGV_NULL, 1, MPI_INFO_NULL,
> 0 /* root */, MPI_COMM_WORLD, &intercomm, errors);
>
> MPI_Finalize();
> return 0;
> }
>
> ==> child.c <==
> #include <stdio.h>
> #include <mpi.h>
>
> int main(int argc, char * argv[])
> {
> MPI_Init(&argc,&argv);
>
> int size, rank;
> MPI_Comm_size(MPI_COMM_WORLD, &size);
> MPI_Comm_rank(MPI_COMM_WORLD, &rank);
>
> printf("I am %d of %d for the child program.\n", rank, size);
>
> MPI_Finalize();
> return 0;
> }
>
> ==> Makefile <==
> CC = mpicc
> CFLAGS = -g -O2 -Wall -std=c99
>
> LD = $(CC)
> LDFLAGS = $(COPT)
>
> LIBS =
>
> TESTS= parent child
>
> all: $(TESTS)
>
> %: %.o
> $(CC) $(CFLAGS) $< $(LIBS) -o $@
>
> clean:
> -rm -f *.o
> -rm -f $(TESTS)
>
> --
> Jeff Hammond
> jeff.science at gmail.com
> http://jeffhammond.github.io/
> _______________________________________________
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/devel
--
Pavan Balaji ✉️
http://www.mcs.anl.gov/~balaji
More information about the devel
mailing list