From 16b100219d4a26dfd3f9796b82d8172d5892f9ec Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 4 Dec 2009 00:51:15 +0000 Subject: [PATCH] A patch from UTK to allow orte_init(), opal_init(), and associated friends also receive &argc and &argv (George asked Jeff to Ralph to review before committing). The thought is that passing argv and argc to opal/orte_init be useful to other projects outside of OMPI that are using OPAL and/or ORTE (especially in conjunction with some other bootstrapping code where it is helpful to modify argv). It's such a small thing that it's easy to apply here to make others' lives a little easier. Ask George for more details; I'm just the messenger. :-) Judging by the copyrights on this patch, it's been around for a while. :-) This commit was SVN r22260. --- ompi/runtime/ompi_mpi_init.c | 4 ++-- ompi/tools/ompi-probe/ompi-probe.c | 2 +- ompi/tools/ompi-profiler/ompi-profiler.c | 2 +- ompi/tools/ompi-server/ompi-server.c | 4 ++-- ompi/tools/ompi_info/ompi_info.c | 2 +- opal/runtime/opal.h | 6 +++--- opal/runtime/opal_init.c | 6 +++--- opal/tools/opal-checkpoint/opal-checkpoint.c | 6 +++--- opal/tools/opal-restart/opal-restart.c | 6 +++--- opal/tools/wrappers/opal_wrapper.c | 2 +- orte/orted/orted_main.c | 7 +++---- orte/runtime/orte_init.c | 4 ++-- orte/runtime/runtime.h | 6 ++++-- orte/tools/orte-checkpoint/orte-checkpoint.c | 6 +++--- orte/tools/orte-clean/orte-clean.c | 4 ++-- orte/tools/orte-iof/orte-iof.c | 4 ++-- orte/tools/orte-ps/orte-ps.c | 6 +++--- orte/tools/orte-restart/orte-restart.c | 6 +++--- orte/tools/orte-top/orte-top.c | 4 ++-- orte/tools/orterun/orterun.c | 4 ++-- 20 files changed, 46 insertions(+), 45 deletions(-) diff --git a/ompi/runtime/ompi_mpi_init.c b/ompi/runtime/ompi_mpi_init.c index ccd3f34795..9688949461 100644 --- a/ompi/runtime/ompi_mpi_init.c +++ b/ompi/runtime/ompi_mpi_init.c @@ -299,7 +299,7 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) /* Setup enough to check get/set MCA params */ - if (ORTE_SUCCESS != (ret = opal_init_util())) { + if (ORTE_SUCCESS != (ret = opal_init_util(&argc, &argv))) { error = "ompi_mpi_init: opal_init_util failed"; goto error; } @@ -347,7 +347,7 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) } /* Setup ORTE - note that we are an MPI process */ - if (ORTE_SUCCESS != (ret = orte_init(ORTE_PROC_MPI))) { + if (ORTE_SUCCESS != (ret = orte_init(NULL, NULL, ORTE_PROC_MPI))) { error = "ompi_mpi_init: orte_init failed"; goto error; } diff --git a/ompi/tools/ompi-probe/ompi-probe.c b/ompi/tools/ompi-probe/ompi-probe.c index f399f2746e..af297232c0 100644 --- a/ompi/tools/ompi-probe/ompi-probe.c +++ b/ompi/tools/ompi-probe/ompi-probe.c @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) char * tmp_env_var = NULL; /* init enough of opal to use a few utilities */ - if (OPAL_SUCCESS != opal_init_util()) { + if (OPAL_SUCCESS != opal_init_util(&argc, &argv)) { fprintf(stderr, "OPAL failed to initialize -- ompi-probe aborting\n"); exit(1); } diff --git a/ompi/tools/ompi-profiler/ompi-profiler.c b/ompi/tools/ompi-profiler/ompi-profiler.c index 03f91c76b3..8a91183dae 100644 --- a/ompi/tools/ompi-profiler/ompi-profiler.c +++ b/ompi/tools/ompi-profiler/ompi-profiler.c @@ -166,7 +166,7 @@ int main(int argc, char *argv[]) } /* init enough of opal to use a few utilities */ - if (OPAL_SUCCESS != opal_init_util()) { + if (OPAL_SUCCESS != opal_init_util(&argc, &argv)) { fprintf(stderr, "OPAL failed to initialize -- ompi-profiler aborting\n"); exit(1); } diff --git a/ompi/tools/ompi-server/ompi-server.c b/ompi/tools/ompi-server/ompi-server.c index ba6f207a90..5f874828fa 100644 --- a/ompi/tools/ompi-server/ompi-server.c +++ b/ompi/tools/ompi-server/ompi-server.c @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) char * tmp_env_var = NULL; /* init enough of opal to process cmd lines */ - if (OPAL_SUCCESS != opal_init_util()) { + if (OPAL_SUCCESS != opal_init_util(&argc, &argv)) { fprintf(stderr, "OPAL failed to initialize -- orted aborting\n"); exit(1); } @@ -188,7 +188,7 @@ int main(int argc, char *argv[]) * so that we only open up the communications infrastructure. No * session directories will be created. */ - if (ORTE_SUCCESS != (ret = orte_init(ORTE_PROC_TOOL))) { + if (ORTE_SUCCESS != (ret = orte_init(&argc, &argv, ORTE_PROC_TOOL))) { fprintf(stderr, "ompi-server: failed to initialize -- aborting\n"); exit(1); } diff --git a/ompi/tools/ompi_info/ompi_info.c b/ompi/tools/ompi_info/ompi_info.c index b7a10032ad..f568040a79 100644 --- a/ompi/tools/ompi_info/ompi_info.c +++ b/ompi/tools/ompi_info/ompi_info.c @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) char *str; /* Initialize the argv parsing handle */ - if (OMPI_SUCCESS != opal_init_util()) { + if (OMPI_SUCCESS != opal_init_util(&argc, &argv)) { orte_show_help("help-ompi_info.txt", "lib-call-fail", true, "opal_init_util", __FILE__, __LINE__, NULL); exit(ret); diff --git a/opal/runtime/opal.h b/opal/runtime/opal.h index cd042d5d11..0e3b8c5a8e 100644 --- a/opal/runtime/opal.h +++ b/opal/runtime/opal.h @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2005 The University of Tennessee and The University + * Copyright (c) 2004-2007 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -42,7 +42,7 @@ OPAL_DECLSPEC extern char *opal_profile_file; * \note If this function is called, opal_init_util() should *not* be * called. */ -OPAL_DECLSPEC int opal_init(void); +OPAL_DECLSPEC int opal_init(int* pargc, char*** pargv); /** * Finalize the OPAL layer, including the MCA system. @@ -64,7 +64,7 @@ OPAL_DECLSPEC int opal_finalize(void); * \note If this function is called, opal_init() should *not* * be called. */ -OPAL_DECLSPEC int opal_init_util(void); +OPAL_DECLSPEC int opal_init_util(int* pargc, char*** pargv); /** * Finalize the OPAL layer, excluding the MCA system. diff --git a/opal/runtime/opal_init.c b/opal/runtime/opal_init.c index cebf51af83..8ef9c2ca69 100644 --- a/opal/runtime/opal_init.c +++ b/opal/runtime/opal_init.c @@ -177,7 +177,7 @@ opal_err2str(int errnum) int -opal_init_util(void) +opal_init_util(int* pargc, char*** pargv) { int ret; char *error = NULL; @@ -273,7 +273,7 @@ opal_init_util(void) int -opal_init(void) +opal_init(int* pargc, char*** pargv) { int ret; char *error = NULL; @@ -286,7 +286,7 @@ opal_init(void) } /* initialize util code */ - if (OPAL_SUCCESS != (ret = opal_init_util())) { + if (OPAL_SUCCESS != (ret = opal_init_util(pargc, pargv))) { return ret; } diff --git a/opal/tools/opal-checkpoint/opal-checkpoint.c b/opal/tools/opal-checkpoint/opal-checkpoint.c index 7e0a600697..8bd3cd26c3 100644 --- a/opal/tools/opal-checkpoint/opal-checkpoint.c +++ b/opal/tools/opal-checkpoint/opal-checkpoint.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2005 The University of Tennessee and The University + * Copyright (c) 2004-2007 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -208,7 +208,7 @@ static int initialize(int argc, char *argv[]) { * to ensure installdirs is setup properly * before calling mca_base_open(); */ - if( OPAL_SUCCESS != (ret = opal_init_util()) ) { + if( OPAL_SUCCESS != (ret = opal_init_util(&argc, &argv)) ) { return ret; } @@ -252,7 +252,7 @@ static int initialize(int argc, char *argv[]) { /* * Initialize OPAL */ - if (OPAL_SUCCESS != (ret = opal_init())) { + if (OPAL_SUCCESS != (ret = opal_init(&argc, &argv))) { exit_status = ret; goto cleanup; } diff --git a/opal/tools/opal-restart/opal-restart.c b/opal/tools/opal-restart/opal-restart.c index 5a01c74c8d..1e2809f125 100644 --- a/opal/tools/opal-restart/opal-restart.c +++ b/opal/tools/opal-restart/opal-restart.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2005 The University of Tennessee and The University + * Copyright (c) 2004-2007 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -305,7 +305,7 @@ static int initialize(int argc, char *argv[]) * to ensure installdirs is setup properly * before calling mca_base_open(); */ - if( OPAL_SUCCESS != (ret = opal_init_util()) ) { + if( OPAL_SUCCESS != (ret = opal_init_util(&argc, &argv)) ) { return ret; } @@ -341,7 +341,7 @@ static int initialize(int argc, char *argv[]) /* * Initialize the OPAL layer */ - if (OPAL_SUCCESS != (ret = opal_init())) { + if (OPAL_SUCCESS != (ret = opal_init(&argc, &argv))) { exit_status = ret; goto cleanup; } diff --git a/opal/tools/wrappers/opal_wrapper.c b/opal/tools/wrappers/opal_wrapper.c index cfe2a36f1f..4afc65e638 100644 --- a/opal/tools/wrappers/opal_wrapper.c +++ b/opal/tools/wrappers/opal_wrapper.c @@ -477,7 +477,7 @@ main(int argc, char *argv[]) bool disable_flags = true; bool real_flag = false; - if (OPAL_SUCCESS != (ret = opal_init_util())) { + if (OPAL_SUCCESS != (ret = opal_init_util(&argc, &argv))) { return ret; } diff --git a/orte/orted/orted_main.c b/orte/orted/orted_main.c index 4aabc990ce..bc56e0ed2e 100644 --- a/orte/orted/orted_main.c +++ b/orte/orted/orted_main.c @@ -283,7 +283,7 @@ int orte_daemon(int argc, char *argv[]) * opal_init_util() since mca_base_cmd_line_process_args() does *not* * depend upon opal_init_util() functionality. */ - if (OPAL_SUCCESS != opal_init_util()) { + if (OPAL_SUCCESS != opal_init_util(&argc, &argv)) { fprintf(stderr, "OPAL failed to initialize -- orted aborting\n"); exit(1); } @@ -325,7 +325,6 @@ int orte_daemon(int argc, char *argv[]) #endif /* !defined(__WINDOWS__) */ /* see if they want us to spin until they can connect a debugger to us */ i=0; - /*orted_globals.spin = 1;*/ while (orted_spin_flag) { i++; if (1000 < i) i=0; @@ -347,12 +346,12 @@ int orte_daemon(int argc, char *argv[]) * require. */ if (orted_globals.hnp) { - if (ORTE_SUCCESS != (ret = orte_init(ORTE_PROC_HNP))) { + if (ORTE_SUCCESS != (ret = orte_init(&argc, &argv, ORTE_PROC_HNP))) { ORTE_ERROR_LOG(ret); return ret; } } else { - if (ORTE_SUCCESS != (ret = orte_init(ORTE_PROC_DAEMON))) { + if (ORTE_SUCCESS != (ret = orte_init(&argc, &argv, ORTE_PROC_DAEMON))) { ORTE_ERROR_LOG(ret); return ret; } diff --git a/orte/runtime/orte_init.c b/orte/runtime/orte_init.c index b9b6a9833b..f9447d9525 100644 --- a/orte/runtime/orte_init.c +++ b/orte/runtime/orte_init.c @@ -65,7 +65,7 @@ orte_process_name_t orte_name_invalid = {ORTE_JOBID_INVALID, ORTE_VPID_INVALID}; #endif const char orte_version_string[] = ORTE_IDENT_STRING; -int orte_init(orte_proc_type_t flags) +int orte_init(int* pargc, char*** pargv, orte_proc_type_t flags) { int ret; char *error = NULL; @@ -75,7 +75,7 @@ int orte_init(orte_proc_type_t flags) } /* initialize the opal layer */ - if (ORTE_SUCCESS != (ret = opal_init())) { + if (ORTE_SUCCESS != (ret = opal_init(pargc, pargv))) { ORTE_ERROR_LOG(ret); return ret; } diff --git a/orte/runtime/runtime.h b/orte/runtime/runtime.h index c3c02ae115..60578d71d0 100644 --- a/orte/runtime/runtime.h +++ b/orte/runtime/runtime.h @@ -55,9 +55,11 @@ ORTE_DECLSPEC extern bool orte_debug_flag; * be called by every application using the RTE interface, including * MPI applications and mpirun. * - * @param tool Whether we are ORTE tool or not + * @param pargc Pointer to the number of arguments in the pargv array + * @param pargv The list of arguments. + * @param flags Whether we are ORTE tool or not */ -ORTE_DECLSPEC int orte_init(orte_proc_type_t flags); +ORTE_DECLSPEC int orte_init(int*pargc, char*** pargv, orte_proc_type_t flags); /** * Initialize parameters for ORTE. diff --git a/orte/tools/orte-checkpoint/orte-checkpoint.c b/orte/tools/orte-checkpoint/orte-checkpoint.c index 037be5de04..d24d2be55d 100644 --- a/orte/tools/orte-checkpoint/orte-checkpoint.c +++ b/orte/tools/orte-checkpoint/orte-checkpoint.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2005 The University of Tennessee and The University + * Copyright (c) 2004-2007 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -508,7 +508,7 @@ static int ckpt_init(int argc, char *argv[]) { * to ensure installdirs is setup properly * before calling mca_base_open(); */ - if( ORTE_SUCCESS != (ret = opal_init_util()) ) { + if( ORTE_SUCCESS != (ret = opal_init_util(&argc, &argv)) ) { ORTE_ERROR_LOG(ret); return ret; } @@ -539,7 +539,7 @@ static int ckpt_init(int argc, char *argv[]) { * We need all of OPAL and the TOOLS portion of ORTE - this * sets us up so we can talk to any HNP over the wire ***************************/ - if (ORTE_SUCCESS != (ret = orte_init(ORTE_PROC_TOOL))) { + if (ORTE_SUCCESS != (ret = orte_init(&argc, &argv, ORTE_PROC_TOOL))) { ORTE_ERROR_LOG(ret); exit_status = ret; goto cleanup; diff --git a/orte/tools/orte-clean/orte-clean.c b/orte/tools/orte-clean/orte-clean.c index 8b6aac9344..d1eee60fcb 100644 --- a/orte/tools/orte-clean/orte-clean.c +++ b/orte/tools/orte-clean/orte-clean.c @@ -127,7 +127,7 @@ main(int argc, char *argv[]) char *tmp_env_var; /* This is needed so we can print the help message */ - if (ORTE_SUCCESS != (ret = opal_init_util())) { + if (ORTE_SUCCESS != (ret = opal_init_util(&argc, &argv))) { return ret; } @@ -157,7 +157,7 @@ main(int argc, char *argv[]) #endif tmp_env_var = NULL; /* Silence compiler warning */ - if (ORTE_SUCCESS != (ret = orte_init(ORTE_PROC_TOOL))) { + if (ORTE_SUCCESS != (ret = orte_init(&argc, &argv, ORTE_PROC_TOOL))) { return ret; } diff --git a/orte/tools/orte-iof/orte-iof.c b/orte/tools/orte-iof/orte-iof.c index 80cf6f4bb8..b76c772836 100644 --- a/orte/tools/orte-iof/orte-iof.c +++ b/orte/tools/orte-iof/orte-iof.c @@ -171,7 +171,7 @@ main(int argc, char *argv[]) * to ensure installdirs is setup properly * before calling mca_base_open(); */ - if( ORTE_SUCCESS != (ret = opal_init_util()) ) { + if( ORTE_SUCCESS != (ret = opal_init_util(&argc, &argv)) ) { return ret; } @@ -212,7 +212,7 @@ main(int argc, char *argv[]) /*************************** * We need all of OPAL and the TOOL portion of ORTE ***************************/ - if (ORTE_SUCCESS != orte_init(ORTE_PROC_TOOL)) { + if (ORTE_SUCCESS != orte_init(&argc, &argv, ORTE_PROC_TOOL)) { orte_finalize(); return 1; } diff --git a/orte/tools/orte-ps/orte-ps.c b/orte/tools/orte-ps/orte-ps.c index 6aa7925b9d..de6da23948 100644 --- a/orte/tools/orte-ps/orte-ps.c +++ b/orte/tools/orte-ps/orte-ps.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2005 The University of Tennessee and The University + * Copyright (c) 2004-2007 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -337,7 +337,7 @@ static int orte_ps_init(int argc, char *argv[]) { * to ensure installdirs is setup properly * before calling mca_base_open(); */ - if( ORTE_SUCCESS != (ret = opal_init_util()) ) { + if( ORTE_SUCCESS != (ret = opal_init_util(&argc, &argv)) ) { return ret; } @@ -384,7 +384,7 @@ static int orte_ps_init(int argc, char *argv[]) { /*************************** * We need all of OPAL and the TOOL portion of ORTE ***************************/ - ret = orte_init(ORTE_PROC_TOOL); + ret = orte_init(&argc, &argv, ORTE_PROC_TOOL); return ret; } diff --git a/orte/tools/orte-restart/orte-restart.c b/orte/tools/orte-restart/orte-restart.c index e1eabe4c9b..fd286d532e 100644 --- a/orte/tools/orte-restart/orte-restart.c +++ b/orte/tools/orte-restart/orte-restart.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2005 The University of Tennessee and The University + * Copyright (c) 2004-2007 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -271,7 +271,7 @@ static int initialize(int argc, char *argv[]) { * to ensure installdirs is setup properly * before calling mca_base_open(); */ - if( ORTE_SUCCESS != (ret = opal_init_util()) ) { + if( ORTE_SUCCESS != (ret = opal_init_util(&argc, &argv)) ) { return ret; } @@ -310,7 +310,7 @@ static int initialize(int argc, char *argv[]) { /* * Setup any ORTE stuff we might need */ - if (OPAL_SUCCESS != (ret = orte_init(ORTE_PROC_TOOL))) { + if (OPAL_SUCCESS != (ret = orte_init(&argc, &argv, ORTE_PROC_TOOL))) { exit_status = ret; goto cleanup; } diff --git a/orte/tools/orte-top/orte-top.c b/orte/tools/orte-top/orte-top.c index 8d7e75f778..b51eeeddb1 100644 --- a/orte/tools/orte-top/orte-top.c +++ b/orte/tools/orte-top/orte-top.c @@ -223,7 +223,7 @@ main(int argc, char *argv[]) * to ensure installdirs is setup properly * before calling mca_base_open(); */ - if( ORTE_SUCCESS != (ret = opal_init_util()) ) { + if( ORTE_SUCCESS != (ret = opal_init_util(&argc, &argv)) ) { return ret; } @@ -257,7 +257,7 @@ main(int argc, char *argv[]) /*************************** * We need all of OPAL and the TOOL portion of ORTE ***************************/ - if (ORTE_SUCCESS != orte_init(ORTE_PROC_TOOL)) { + if (ORTE_SUCCESS != orte_init(&argc, &argv, ORTE_PROC_TOOL)) { orte_finalize(); return 1; } diff --git a/orte/tools/orterun/orterun.c b/orte/tools/orterun/orterun.c index c851fa09d1..0e6f058e58 100644 --- a/orte/tools/orterun/orterun.c +++ b/orte/tools/orterun/orterun.c @@ -491,7 +491,7 @@ int orterun(int argc, char *argv[]) * depend upon opal_init_util() functionality. */ /* Need to initialize OPAL so that install_dirs are filled in */ - if (OPAL_SUCCESS != opal_init_util()) { + if (OPAL_SUCCESS != opal_init_util(&argc, &argv)) { exit(1); } @@ -566,7 +566,7 @@ int orterun(int argc, char *argv[]) * up incorrect infrastructure that only a singleton would * require */ - if (ORTE_SUCCESS != (rc = orte_init(ORTE_PROC_HNP))) { + if (ORTE_SUCCESS != (rc = orte_init(&argc, &argv, ORTE_PROC_HNP))) { ORTE_ERROR_LOG(rc); return rc; }