/* * spawn.c - handle dynamic process spawning for MPI-2. * * $Id: spawn.c 388 2006-11-27 17:09:48Z pw $ * * Copyright (C) 2005-6 Pete Wyckoff * * Distributed under the GNU Public License Version 2 or later (See LICENSE) */ #include #include "mpiexec.h" /* * Called on parent (not stdio listener) after the arguments for the * spawn have been gathered. Deallocate them when done. * * Only mpich2/pmi is known to support MPI_Spawn. And only particular devices * of mpich2/pmi do. In mpich2-1.0.3, ch3:sock works, and perhaps others. * OSU's mvapich2 is based on old mpich2-1.0.1 and does not support spawning. */ int spawn(int nprocs, char *execname, int numarg, char **args, int numinfo, char **infokeys, char **infovals) { const char *target_host; int i, ret = 1; tasks_t *newtasks; growstr_t *g; config_spec_t *cfg; char *cfg_exe, *cfg_args; debug(2, "%s: spawn %d %s", __func__, nprocs, execname); /* * Look at the info args to figure out what to do. */ target_host = NULL; for (i=0; i 0) growstr_append(g, " "); growstr_append(g, args[i]); } cfg_args = strsave(g->s); growstr_free(g); /* * Command-line constraints are still in force here. Run on the specified * host or find free ones. */ if (target_host) { int target_node; for (i=0; i 0) break; allocate_cpu_to_task(j, &newtasks[i]); newtasks[i].conf = cfg; } } /* * Accept these tasks and try to start them. * For now, don't tasks_shmem_reduce: only for mpich/p4 that will not * ever support spawn. And don't bother with distribute_executable * yet either. */ cfg->exe = cfg_exe; cfg->args = cfg_args; free(tasks); /* * Build the next spawn group. */ { void *x = spawns; spawns = Malloc((numspawns + 1) * sizeof(*spawns)); memcpy(spawns, x, numspawns * sizeof(*spawns)); free(x); memset(&spawns[numspawns], 0, sizeof(*spawns)); spawns[numspawns].task_start = numtasks; spawns[numspawns].task_end = numtasks + nprocs; spawns[numspawns].obits = Malloc(nprocs * sizeof(*spawns[numspawns].obits)); spawns[numspawns].ranks2hosts_response = NULL; for (i=numtasks; ilist); free(cfg); free(newtasks); outfree: free(execname); for (i=0; i