diff --git a/.gitignore b/.gitignore index 196eaa742c..76b43a7321 100644 --- a/.gitignore +++ b/.gitignore @@ -135,6 +135,7 @@ examples/colocate examples/pset examples/nodeid examples/client-threaded +examples/dynamic-dep src/sys/powerpc/atomic-32.s src/sys/powerpc/atomic-64.s diff --git a/examples/Makefile b/examples/Makefile index 6ca8603680..1c5cea655a 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -62,7 +62,8 @@ EXAMPLES = \ colocate \ pset \ nodeid \ - client-threaded + client-threaded \ + dynamic-dep all: $(EXAMPLES) diff --git a/examples/Makefile.include b/examples/Makefile.include index 330c9ecb91..48a22bea73 100644 --- a/examples/Makefile.include +++ b/examples/Makefile.include @@ -70,4 +70,5 @@ EXTRA_DIST += \ examples/colocate.c \ examples/pset.c \ examples/nodeid.c \ - examples/client-threaded.c + examples/client-threaded.c \ + examples/dynamic-dep.c diff --git a/examples/dynamic-dep.c b/examples/dynamic-dep.c new file mode 100644 index 0000000000..61ce60f354 --- /dev/null +++ b/examples/dynamic-dep.c @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2011 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2006-2013 Los Alamos National Security, LLC. + * All rights reserved. + * Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved. + * Copyright (c) 2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2021-2024 Nanook Consulting All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + */ + +#include + +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#include "examples.h" +#include + +static pmix_proc_t myproc; + +int main(int argc, char **argv) +{ + int rc, exitcode; + char nsp2[PMIX_MAX_NSLEN + 1]; + pmix_proc_t proc; + pmix_app_t *app; + bool test_dep = true; + pmix_info_t info; + + if (1 < argc) { + if (0 == strcmp(argv[1], "dep")) { + test_dep = false; + } + } + + /* init us */ + if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc, NULL, 0))) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Init failed: %d\n", myproc.nspace, myproc.rank, + rc); + exit(rc); + } + + /* rank=0 calls spawn */ + if (0 == myproc.rank) { + PMIX_APP_CREATE(app, 1); + app->cmd = strdup("sleep"); + app->maxprocs = 2; + PMIX_ARGV_APPEND(rc, app->argv, app->cmd); + PMIX_ARGV_APPEND(rc, app->argv, "5"); + + PMIX_INFO_LOAD(&info, PMIX_SPAWN_CHILD_SEP, &test_dep, PMIX_BOOL); + rc = PMIx_Spawn(&info, 1, app, 1, nsp2); + if (PMIX_SUCCESS != rc) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Spawn failed: %s(%d)\n", myproc.nspace, + myproc.rank, PMIx_Error_string(rc), rc); + exitcode = rc; + /* terminate our peers */ + PMIX_LOAD_PROCID(&proc, myproc.nspace, PMIX_RANK_WILDCARD); + PMIx_Abort(rc, "FAILED TO START CHILD JOB", &proc, 1); + goto done; + } else { + fprintf(stderr, "Spawn success.\n"); + } + PMIX_APP_FREE(app, 1); + + // now terminate + } + + +done: + if (PMIX_SUCCESS != (rc = PMIx_Finalize(NULL, 0))) { + fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize failed: %d\n", myproc.nspace, + myproc.rank, rc); + } + + fflush(stderr); + return (0); +} diff --git a/src/docs/show-help-files/help-state-base.txt b/src/docs/show-help-files/help-state-base.txt index 83a9969fe9..6b28ea1bde 100644 --- a/src/docs/show-help-files/help-state-base.txt +++ b/src/docs/show-help-files/help-state-base.txt @@ -48,7 +48,7 @@ its parent: Parent: %s Child: %s -This behavior is controlled by setting the PMIX_JOB_CHILD_SEP attribute +This behavior is controlled by setting the PMIX_SPAWN_CHILD_SEP attribute in the job info provided at time of spawn for the child job. When set to "true", the runtime will "separate" the child from its parent and allow it to continue execution after parent termination. Note that this is only diff --git a/src/mca/state/dvm/state_dvm.c b/src/mca/state/dvm/state_dvm.c index 600e24d1c6..1f316d7d32 100644 --- a/src/mca/state/dvm/state_dvm.c +++ b/src/mca/state/dvm/state_dvm.c @@ -835,6 +835,7 @@ static void check_complete(int fd, short args, void *cbdata) PMIX_LIST_FOREACH(jptr, &jdata->children, prte_job_t) { if (prte_get_attribute(&jptr->attributes, PRTE_JOB_CHILD_SEP, (void**)&sepptr, PMIX_BOOL) && !sep) { + pmix_output(0, "TERMINATING CHILD"); proc = PMIX_NEW(prte_proc_t); PMIX_LOAD_PROCID(&proc->name, jptr->nspace, PMIX_RANK_WILDCARD); pmix_pointer_array_add(&procs, proc); @@ -853,6 +854,8 @@ static void check_complete(int fd, short args, void *cbdata) PMIX_RELEASE(proc); } } + } else { + pmix_output(0, "NOT TERMINATING CHILD"); } PMIX_DESTRUCT(&procs); }