[mpich-devel] proper way to detect if program launched by mpiexec?

Rob Latham robl at mcs.anl.gov
Mon Oct 20 12:48:01 CDT 2014



On 10/20/2014 11:34 AM, Jeff Hammond 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?

http://trac.mpich.org/projects/mpich/ticket/2175

==rob


> 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)
>

-- 
Rob Latham
Mathematics and Computer Science Division
Argonne National Lab, IL USA


More information about the devel mailing list