From 4cd7f3b202e6f6922caf86de6c762035f21012ca Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Wed, 10 Jan 2018 20:28:21 -0800 Subject: [PATCH] Convert nidmap to regx framework Handle the need for different regex generator/parsers by moving the orte/util/nidmap and orte/util/regex code into a new "regx" framework. Use the original code to complete a "fwd" component, and create a scaffold for IBM's "reverse" component. Signed-off-by: Ralph Castain --- orte/mca/dfs/orted/dfs_orted.c | 3 +- .../errmgr/default_hnp/errmgr_default_hnp.c | 3 +- .../default_orted/errmgr_default_orted.c | 3 +- orte/mca/errmgr/dvm/errmgr_dvm.c | 3 +- orte/mca/ess/alps/ess_alps_module.c | 4 +- orte/mca/ess/alps/ess_alps_utils.c | 3 +- orte/mca/ess/base/ess_base_fns.c | 3 +- orte/mca/ess/base/ess_base_std_orted.c | 22 +- orte/mca/ess/env/ess_env_module.c | 3 +- orte/mca/ess/hnp/ess_hnp_module.c | 13 +- orte/mca/ess/lsf/ess_lsf_module.c | 3 +- orte/mca/ess/pmi/ess_pmi_module.c | 3 +- orte/mca/ess/slurm/ess_slurm_module.c | 3 +- orte/mca/ess/tm/ess_tm_module.c | 3 +- orte/mca/grpcomm/base/grpcomm_base_stubs.c | 3 +- orte/mca/grpcomm/direct/grpcomm_direct.c | 8 +- orte/mca/odls/base/odls_base_default_fns.c | 13 +- orte/mca/plm/base/plm_base_launch_support.c | 7 +- orte/mca/plm/rsh/plm_rsh_module.c | 1 - orte/mca/regx/Makefile.am | 30 + orte/mca/regx/base/Makefile.am | 15 + orte/mca/regx/base/base.h | 40 + orte/mca/regx/base/owner.txt | 7 + orte/mca/regx/base/regx_base_frame.c | 77 + orte/mca/regx/base/regx_base_select.c | 61 + orte/mca/regx/fwd/Makefile.am | 37 + orte/mca/regx/fwd/owner.txt | 7 + .../nidmap.c => mca/regx/fwd/regx_fwd.c} | 1692 +++++++++-------- orte/mca/regx/fwd/regx_fwd.h | 29 + orte/mca/regx/fwd/regx_fwd_component.c | 45 + orte/mca/regx/regx.h | 123 ++ orte/mca/regx/reverse/Makefile.am | 37 + orte/mca/regx/reverse/owner.txt | 7 + orte/mca/regx/reverse/regx_reverse.c | 74 + orte/mca/regx/reverse/regx_reverse.h | 29 + .../mca/regx/reverse/regx_reverse_component.c | 45 + orte/mca/routed/binomial/routed_binomial.c | 3 +- orte/mca/state/dvm/state_dvm.c | 8 +- orte/orted/orted_comm.c | 3 +- orte/orted/orted_main.c | 6 +- orte/runtime/orte_init.c | 4 +- orte/util/Makefile.am | 6 +- orte/util/nidmap.h | 70 - orte/util/regex.c | 404 ---- orte/util/regex.h | 59 - 45 files changed, 1663 insertions(+), 1359 deletions(-) create mode 100644 orte/mca/regx/Makefile.am create mode 100644 orte/mca/regx/base/Makefile.am create mode 100644 orte/mca/regx/base/base.h create mode 100644 orte/mca/regx/base/owner.txt create mode 100644 orte/mca/regx/base/regx_base_frame.c create mode 100644 orte/mca/regx/base/regx_base_select.c create mode 100644 orte/mca/regx/fwd/Makefile.am create mode 100644 orte/mca/regx/fwd/owner.txt rename orte/{util/nidmap.c => mca/regx/fwd/regx_fwd.c} (60%) create mode 100644 orte/mca/regx/fwd/regx_fwd.h create mode 100644 orte/mca/regx/fwd/regx_fwd_component.c create mode 100644 orte/mca/regx/regx.h create mode 100644 orte/mca/regx/reverse/Makefile.am create mode 100644 orte/mca/regx/reverse/owner.txt create mode 100644 orte/mca/regx/reverse/regx_reverse.c create mode 100644 orte/mca/regx/reverse/regx_reverse.h create mode 100644 orte/mca/regx/reverse/regx_reverse_component.c delete mode 100644 orte/util/nidmap.h delete mode 100644 orte/util/regex.c delete mode 100644 orte/util/regex.h diff --git a/orte/mca/dfs/orted/dfs_orted.c b/orte/mca/dfs/orted/dfs_orted.c index ac72ce3a41..ee3c9d5a33 100644 --- a/orte/mca/dfs/orted/dfs_orted.c +++ b/orte/mca/dfs/orted/dfs_orted.c @@ -2,7 +2,7 @@ * Copyright (c) 2012-2013 Los Alamos National Security, LLC. * All rights reserved. * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -34,7 +34,6 @@ #include "orte/util/proc_info.h" #include "orte/util/session_dir.h" #include "orte/util/show_help.h" -#include "orte/util/nidmap.h" #include "orte/util/threads.h" #include "orte/mca/errmgr/errmgr.h" diff --git a/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c b/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c index 16a99cdbd9..9c807dd54b 100644 --- a/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c +++ b/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c @@ -9,7 +9,7 @@ * Copyright (c) 2011 Oracle and/or all its affiliates. All rights reserved. * Copyright (c) 2011-2013 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * $COPYRIGHT$ * @@ -49,7 +49,6 @@ #include "orte/util/name_fns.h" #include "orte/util/proc_info.h" #include "orte/util/show_help.h" -#include "orte/util/nidmap.h" #include "orte/util/threads.h" #include "orte/runtime/orte_globals.h" diff --git a/orte/mca/errmgr/default_orted/errmgr_default_orted.c b/orte/mca/errmgr/default_orted/errmgr_default_orted.c index 7583836712..bce5163866 100644 --- a/orte/mca/errmgr/default_orted/errmgr_default_orted.c +++ b/orte/mca/errmgr/default_orted/errmgr_default_orted.c @@ -8,7 +8,7 @@ * reserved. * Copyright (c) 2011-2013 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * $COPYRIGHT$ * @@ -33,7 +33,6 @@ #include "orte/util/proc_info.h" #include "orte/util/session_dir.h" #include "orte/util/show_help.h" -#include "orte/util/nidmap.h" #include "orte/util/threads.h" #include "orte/mca/iof/base/base.h" diff --git a/orte/mca/errmgr/dvm/errmgr_dvm.c b/orte/mca/errmgr/dvm/errmgr_dvm.c index 60604e1534..7773bcfa8a 100644 --- a/orte/mca/errmgr/dvm/errmgr_dvm.c +++ b/orte/mca/errmgr/dvm/errmgr_dvm.c @@ -9,7 +9,7 @@ * Copyright (c) 2011 Oracle and/or all its affiliates. All rights reserved. * Copyright (c) 2011-2013 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * $COPYRIGHT$ * @@ -49,7 +49,6 @@ #include "orte/util/name_fns.h" #include "orte/util/proc_info.h" #include "orte/util/show_help.h" -#include "orte/util/nidmap.h" #include "orte/util/threads.h" #include "orte/runtime/orte_globals.h" diff --git a/orte/mca/ess/alps/ess_alps_module.c b/orte/mca/ess/alps/ess_alps_module.c index 349f781f69..533a054e8b 100644 --- a/orte/mca/ess/alps/ess_alps_module.c +++ b/orte/mca/ess/alps/ess_alps_module.c @@ -12,7 +12,7 @@ * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011-2013 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2017 Intel, Inc. All rights reserved. + * Copyright (c) 2017-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -30,8 +30,6 @@ #include "orte/util/proc_info.h" #include "orte/mca/errmgr/base/base.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" -#include "orte/util/regex.h" #include "orte/runtime/orte_globals.h" #include "orte/mca/ess/ess.h" diff --git a/orte/mca/ess/alps/ess_alps_utils.c b/orte/mca/ess/alps/ess_alps_utils.c index 3e59e9fdc2..c6c59dee7c 100644 --- a/orte/mca/ess/alps/ess_alps_utils.c +++ b/orte/mca/ess/alps/ess_alps_utils.c @@ -12,6 +12,7 @@ * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011-2013 Los Alamos National Security, LLC. * All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,8 +30,6 @@ #include "orte/util/proc_info.h" #include "orte/mca/errmgr/base/base.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" -#include "orte/util/regex.h" #include "orte/runtime/orte_globals.h" #include "orte/mca/ess/ess.h" diff --git a/orte/mca/ess/base/ess_base_fns.c b/orte/mca/ess/base/ess_base_fns.c index 1c86ef8d4a..9b57519e80 100644 --- a/orte/mca/ess/base/ess_base_fns.c +++ b/orte/mca/ess/base/ess_base_fns.c @@ -12,7 +12,7 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011-2012 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -37,7 +37,6 @@ #include "orte/mca/errmgr/errmgr.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" #include "orte/util/proc_info.h" #include "orte/util/show_help.h" #include "orte/runtime/orte_globals.h" diff --git a/orte/mca/ess/base/ess_base_std_orted.c b/orte/mca/ess/base/ess_base_std_orted.c index 67d5e188b7..b848f78745 100644 --- a/orte/mca/ess/base/ess_base_std_orted.c +++ b/orte/mca/ess/base/ess_base_std_orted.c @@ -14,7 +14,7 @@ * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * $COPYRIGHT$ * @@ -58,6 +58,7 @@ #include "orte/mca/iof/base/base.h" #include "orte/mca/plm/base/base.h" #include "orte/mca/odls/base/base.h" +#include "orte/mca/regx/base/base.h" #include "orte/mca/errmgr/errmgr.h" #include "orte/mca/rmaps/base/base.h" #if OPAL_ENABLE_FT_CR == 1 @@ -68,8 +69,6 @@ #include "orte/util/proc_info.h" #include "orte/util/session_dir.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" -#include "orte/util/regex.h" #include "orte/util/show_help.h" #include "orte/mca/errmgr/base/base.h" #include "orte/mca/state/base/base.h" @@ -519,9 +518,20 @@ int orte_ess_base_orted_setup(void) } if (ORTE_SUCCESS != (ret = orte_rmaps_base_select())) { ORTE_ERROR_LOG(ret); - error = "orte_rmaps_base_find_available"; + error = "orte_rmaps_base_select"; goto error; } + if (ORTE_SUCCESS != (ret = mca_base_framework_open(&orte_regx_base_framework, 0))) { + ORTE_ERROR_LOG(ret); + error = "orte_regx_base_open"; + goto error; + } + if (ORTE_SUCCESS != (ret = orte_regx_base_select())) { + ORTE_ERROR_LOG(ret); + error = "orte_regx_base_select"; + goto error; + } + /* if a topology file was given, then the rmaps framework open * will have reset our topology. Ensure we always get the right @@ -545,7 +555,7 @@ int orte_ess_base_orted_setup(void) * own port, which we need in order to construct the nidmap */ if (NULL != orte_node_regex) { - if (ORTE_SUCCESS != (ret = orte_util_nidmap_parse(orte_node_regex))) { + if (ORTE_SUCCESS != (ret = orte_regx.nidmap_parse(orte_node_regex))) { ORTE_ERROR_LOG(ret); error = "construct nidmap"; goto error; @@ -565,7 +575,7 @@ int orte_ess_base_orted_setup(void) * build a nidmap from it - this will update the * routing plan as well */ - if (ORTE_SUCCESS != (ret = orte_util_build_daemon_nidmap())) { + if (ORTE_SUCCESS != (ret = orte_regx.build_daemon_nidmap())) { ORTE_ERROR_LOG(ret); error = "construct daemon map from static ports"; goto error; diff --git a/orte/mca/ess/env/ess_env_module.c b/orte/mca/ess/env/ess_env_module.c index bc4152e23e..ae793fd848 100644 --- a/orte/mca/ess/env/ess_env_module.c +++ b/orte/mca/ess/env/ess_env_module.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -63,7 +63,6 @@ #include "orte/util/proc_info.h" #include "orte/util/session_dir.h" #include "orte/util/name_fns.h" -#include "orte/util/regex.h" #include "orte/runtime/runtime.h" #include "orte/runtime/orte_wait.h" diff --git a/orte/mca/ess/hnp/ess_hnp_module.c b/orte/mca/ess/hnp/ess_hnp_module.c index c1e501eef9..11e3eb6457 100644 --- a/orte/mca/ess/hnp/ess_hnp_module.c +++ b/orte/mca/ess/hnp/ess_hnp_module.c @@ -14,7 +14,7 @@ * Copyright (c) 2011-2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011-2017 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -67,6 +67,7 @@ #include "orte/mca/grpcomm/base/base.h" #include "orte/mca/iof/base/base.h" #include "orte/mca/ras/base/base.h" +#include "orte/mca/regx/base/base.h" #include "orte/mca/plm/base/base.h" #include "orte/mca/plm/plm.h" #include "orte/mca/odls/base/base.h" @@ -541,6 +542,16 @@ static int rte_init(void) error = "orte_rmaps_base_find_available"; goto error; } + if (ORTE_SUCCESS != (ret = mca_base_framework_open(&orte_regx_base_framework, 0))) { + ORTE_ERROR_LOG(ret); + error = "orte_regx_base_open"; + goto error; + } + if (ORTE_SUCCESS != (ret = orte_regx_base_select())) { + ORTE_ERROR_LOG(ret); + error = "orte_regx_base_select"; + goto error; + } /* if a topology file was given, then the rmaps framework open * will have reset our topology. Ensure we always get the right diff --git a/orte/mca/ess/lsf/ess_lsf_module.c b/orte/mca/ess/lsf/ess_lsf_module.c index 190b1718d1..18d3ddc554 100644 --- a/orte/mca/ess/lsf/ess_lsf_module.c +++ b/orte/mca/ess/lsf/ess_lsf_module.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007-2011 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -40,7 +40,6 @@ #include "orte/util/proc_info.h" #include "orte/runtime/orte_globals.h" #include "orte/mca/errmgr/errmgr.h" -#include "orte/util/regex.h" #include "orte/mca/ess/ess.h" #include "orte/mca/ess/base/base.h" diff --git a/orte/mca/ess/pmi/ess_pmi_module.c b/orte/mca/ess/pmi/ess_pmi_module.c index e53ff60876..0420218e26 100644 --- a/orte/mca/ess/pmi/ess_pmi_module.c +++ b/orte/mca/ess/pmi/ess_pmi_module.c @@ -12,7 +12,7 @@ * Copyright (c) 2008-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012-2013 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2016-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -60,7 +60,6 @@ #include "orte/util/show_help.h" #include "orte/util/name_fns.h" #include "orte/util/pre_condition_transports.h" -#include "orte/util/regex.h" #include "orte/runtime/orte_globals.h" #include "orte/runtime/orte_wait.h" diff --git a/orte/mca/ess/slurm/ess_slurm_module.c b/orte/mca/ess/slurm/ess_slurm_module.c index a0abcbce34..47dddbed49 100644 --- a/orte/mca/ess/slurm/ess_slurm_module.c +++ b/orte/mca/ess/slurm/ess_slurm_module.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -36,7 +36,6 @@ #include "opal/dss/dss.h" #include "orte/util/proc_info.h" -#include "orte/util/regex.h" #include "orte/util/show_help.h" #include "orte/mca/errmgr/errmgr.h" #include "orte/mca/rml/rml.h" diff --git a/orte/mca/ess/tm/ess_tm_module.c b/orte/mca/ess/tm/ess_tm_module.c index 62da4acc3c..20373798c4 100644 --- a/orte/mca/ess/tm/ess_tm_module.c +++ b/orte/mca/ess/tm/ess_tm_module.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2017 Intel, Inc. All rights reserved. + * Copyright (c) 2017-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -36,7 +36,6 @@ #include "opal/dss/dss.h" #include "orte/util/proc_info.h" -#include "orte/util/regex.h" #include "orte/util/show_help.h" #include "orte/mca/errmgr/errmgr.h" #include "orte/util/name_fns.h" diff --git a/orte/mca/grpcomm/base/grpcomm_base_stubs.c b/orte/mca/grpcomm/base/grpcomm_base_stubs.c index cc805185e2..d0d9757036 100644 --- a/orte/mca/grpcomm/base/grpcomm_base_stubs.c +++ b/orte/mca/grpcomm/base/grpcomm_base_stubs.c @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2011-2016 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -43,7 +43,6 @@ #include "orte/mca/routed/routed.h" #include "orte/mca/state/state.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" #include "orte/util/threads.h" #include "orte/runtime/orte_globals.h" diff --git a/orte/mca/grpcomm/direct/grpcomm_direct.c b/orte/mca/grpcomm/direct/grpcomm_direct.c index 0eaf9b80cc..8711d2c254 100644 --- a/orte/mca/grpcomm/direct/grpcomm_direct.c +++ b/orte/mca/grpcomm/direct/grpcomm_direct.c @@ -5,7 +5,7 @@ * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All * rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -26,13 +26,13 @@ #include "opal/mca/pmix/pmix.h" #include "orte/mca/errmgr/errmgr.h" +#include "orte/mca/regx/regx.h" #include "orte/mca/rml/base/base.h" #include "orte/mca/rml/base/rml_contact.h" #include "orte/mca/routed/base/base.h" #include "orte/mca/state/state.h" #include "orte/util/compress.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" #include "orte/util/proc_info.h" #include "orte/mca/grpcomm/base/base.h" @@ -416,7 +416,7 @@ static void xcast_recv(int status, orte_process_name_t* sender, goto relay; } if (NULL != nidmap) { - if (ORTE_SUCCESS != (ret = orte_util_nidmap_parse(nidmap))) { + if (ORTE_SUCCESS != (ret = orte_regx.nidmap_parse(nidmap))) { ORTE_ERROR_LOG(ret); goto relay; } @@ -436,7 +436,7 @@ static void xcast_recv(int status, orte_process_name_t* sender, "%s grpcomm:direct:xcast updating daemon nidmap", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME))); - if (ORTE_SUCCESS != (ret = orte_util_decode_daemon_nodemap(data))) { + if (ORTE_SUCCESS != (ret = orte_regx.decode_daemon_nodemap(data))) { ORTE_ERROR_LOG(ret); goto relay; } diff --git a/orte/mca/odls/base/odls_base_default_fns.c b/orte/mca/odls/base/odls_base_default_fns.c index aaab218e8d..ea97f4cd1a 100644 --- a/orte/mca/odls/base/odls_base_default_fns.c +++ b/orte/mca/odls/base/odls_base_default_fns.c @@ -14,7 +14,7 @@ * Copyright (c) 2011-2013 Los Alamos National Security, LLC. * All rights reserved. * Copyright (c) 2011-2017 Cisco Systems, Inc. All rights reserved - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 Mellanox Technologies Ltd. All rights reserved. @@ -66,6 +66,7 @@ #include "orte/mca/ess/base/base.h" #include "orte/mca/grpcomm/base/base.h" #include "orte/mca/plm/base/base.h" +#include "orte/mca/regx/regx.h" #include "orte/mca/rml/base/rml_contact.h" #include "orte/mca/rmaps/rmaps_types.h" #include "orte/mca/rmaps/base/base.h" @@ -78,10 +79,8 @@ #include "orte/util/context_fns.h" #include "orte/util/name_fns.h" -#include "orte/util/regex.h" #include "orte/util/session_dir.h" #include "orte/util/proc_info.h" -#include "orte/util/nidmap.h" #include "orte/util/show_help.h" #include "orte/util/threads.h" #include "orte/runtime/orte_globals.h" @@ -138,7 +137,7 @@ int orte_odls_base_default_get_add_procs_data(opal_buffer_t *buffer, /* if we couldn't provide the allocation regex on the orted * cmd line, then we need to provide all the info here */ if (!orte_nidmap_communicated) { - if (ORTE_SUCCESS != (rc = orte_util_nidmap_create(orte_node_pool, &nidmap))) { + if (ORTE_SUCCESS != (rc = orte_regx.nidmap_create(orte_node_pool, &nidmap))) { ORTE_ERROR_LOG(rc); return rc; } @@ -157,7 +156,7 @@ int orte_odls_base_default_get_add_procs_data(opal_buffer_t *buffer, orte_get_attribute(&jdata->attributes, ORTE_JOB_LAUNCHED_DAEMONS, NULL, OPAL_BOOL)) { flag = 1; opal_dss.pack(buffer, &flag, 1, OPAL_INT8); - if (ORTE_SUCCESS != (rc = orte_util_encode_nodemap(buffer))) { + if (ORTE_SUCCESS != (rc = orte_regx.encode_nodemap(buffer))) { ORTE_ERROR_LOG(rc); return rc; } @@ -336,7 +335,7 @@ int orte_odls_base_default_get_add_procs_data(opal_buffer_t *buffer, if (!orte_get_attribute(&jdata->attributes, ORTE_JOB_FULLY_DESCRIBED, NULL, OPAL_BOOL)) { /* compute and pack the ppn regex */ - if (ORTE_SUCCESS != (rc = orte_util_nidmap_generate_ppn(jdata, &nidmap))) { + if (ORTE_SUCCESS != (rc = orte_regx.generate_ppn(jdata, &nidmap))) { ORTE_ERROR_LOG(rc); return rc; } @@ -514,7 +513,7 @@ int orte_odls_base_default_construct_child_list(opal_buffer_t *buffer, } /* populate the node array of the job map and the proc array of * the job object so we know how many procs are on each node */ - if (ORTE_SUCCESS != (rc = orte_util_nidmap_parse_ppn(jdata, ppn))) { + if (ORTE_SUCCESS != (rc = orte_regx.parse_ppn(jdata, ppn))) { ORTE_ERROR_LOG(rc); free(ppn); goto REPORT_ERROR; diff --git a/orte/mca/plm/base/plm_base_launch_support.c b/orte/mca/plm/base/plm_base_launch_support.c index 7eaaca6d4c..bfd9adedde 100644 --- a/orte/mca/plm/base/plm_base_launch_support.c +++ b/orte/mca/plm/base/plm_base_launch_support.c @@ -13,7 +13,7 @@ * Copyright (c) 2009 Institut National de Recherche en Informatique * et Automatique. All rights reserved. * Copyright (c) 2011-2012 Los Alamos National Security, LLC. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. @@ -51,6 +51,7 @@ #include "orte/mca/iof/base/base.h" #include "orte/mca/odls/base/base.h" #include "orte/mca/ras/base/base.h" +#include "orte/mca/regx/regx.h" #include "orte/mca/rmaps/rmaps.h" #include "orte/mca/rmaps/base/base.h" #include "orte/mca/rml/rml.h" @@ -71,10 +72,8 @@ #include "orte/runtime/orte_quit.h" #include "orte/util/compress.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" #include "orte/util/pre_condition_transports.h" #include "orte/util/proc_info.h" -#include "orte/util/regex.h" #include "orte/util/threads.h" #include "orte/mca/state/state.h" #include "orte/mca/state/base/base.h" @@ -1561,7 +1560,7 @@ int orte_plm_base_orted_append_basic_args(int *argc, char ***argv, /* convert the nodes with daemons to a regex */ param = NULL; - if (ORTE_SUCCESS != (rc = orte_util_nidmap_create(orte_node_pool, ¶m))) { + if (ORTE_SUCCESS != (rc = orte_regx.nidmap_create(orte_node_pool, ¶m))) { ORTE_ERROR_LOG(rc); return rc; } diff --git a/orte/mca/plm/rsh/plm_rsh_module.c b/orte/mca/plm/rsh/plm_rsh_module.c index 0881b13e5a..01c51020ce 100644 --- a/orte/mca/plm/rsh/plm_rsh_module.c +++ b/orte/mca/plm/rsh/plm_rsh_module.c @@ -78,7 +78,6 @@ #include "orte/runtime/orte_wait.h" #include "orte/runtime/orte_globals.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" #include "orte/util/proc_info.h" #include "orte/util/threads.h" diff --git a/orte/mca/regx/Makefile.am b/orte/mca/regx/Makefile.am new file mode 100644 index 0000000000..8248d9f464 --- /dev/null +++ b/orte/mca/regx/Makefile.am @@ -0,0 +1,30 @@ +# +# Copyright (c) 2015-2018 Intel, Inc. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# main library setup +noinst_LTLIBRARIES = libmca_regx.la +libmca_regx_la_SOURCES = + +# pkgdata setup +dist_ortedata_DATA = + +# local files +headers = regx.h +libmca_regx_la_SOURCES += $(headers) + +# Conditionally install the header files +if WANT_INSTALL_HEADERS +ortedir = $(orteincludedir)/$(subdir) +nobase_orte_HEADERS = $(headers) +endif + +include base/Makefile.am + +distclean-local: + rm -f base/static-components.h diff --git a/orte/mca/regx/base/Makefile.am b/orte/mca/regx/base/Makefile.am new file mode 100644 index 0000000000..e0237653f4 --- /dev/null +++ b/orte/mca/regx/base/Makefile.am @@ -0,0 +1,15 @@ +# +# Copyright (c) 2015-2018 Intel, Inc. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +headers += \ + base/base.h + +libmca_regx_la_SOURCES += \ + base/regx_base_frame.c \ + base/regx_base_select.c diff --git a/orte/mca/regx/base/base.h b/orte/mca/regx/base/base.h new file mode 100644 index 0000000000..29c9a286b0 --- /dev/null +++ b/orte/mca/regx/base/base.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +/** @file: + * regx framework base functionality. + */ + +#ifndef ORTE_MCA_REGX_BASE_H +#define ORTE_MCA_REGX_BASE_H + +/* + * includes + */ +#include "orte_config.h" +#include "orte/types.h" + +#include "opal/class/opal_list.h" +#include "orte/mca/mca.h" + +#include "orte/runtime/orte_globals.h" + +#include "orte/mca/regx/regx.h" + +BEGIN_C_DECLS + +/* + * MCA Framework + */ +ORTE_DECLSPEC extern mca_base_framework_t orte_regx_base_framework; +/* select all components */ +ORTE_DECLSPEC int orte_regx_base_select(void); + +END_C_DECLS + +#endif diff --git a/orte/mca/regx/base/owner.txt b/orte/mca/regx/base/owner.txt new file mode 100644 index 0000000000..85b4416d20 --- /dev/null +++ b/orte/mca/regx/base/owner.txt @@ -0,0 +1,7 @@ +# +# owner/status file +# owner: institution that is responsible for this package +# status: e.g. active, maintenance, unmaintained +# +owner: INTEL +status: active diff --git a/orte/mca/regx/base/regx_base_frame.c b/orte/mca/regx/base/regx_base_frame.c new file mode 100644 index 0000000000..61a8f0bf61 --- /dev/null +++ b/orte/mca/regx/base/regx_base_frame.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "orte_config.h" +#include "orte/constants.h" + +#include + +#include "orte/mca/mca.h" +#include "opal/util/argv.h" +#include "opal/util/output.h" +#include "opal/mca/base/base.h" + +#include "orte/runtime/orte_globals.h" +#include "orte/util/show_help.h" +#include "orte/mca/errmgr/errmgr.h" + +#include "orte/mca/regx/base/base.h" +/* + * The following file was created by configure. It contains extern + * statements and the definition of an array of pointers to each + * component's public mca_base_component_t struct. + */ + +#include "orte/mca/regx/base/static-components.h" + +/* + * Global variables + */ +orte_regx_base_module_t orte_regx = {0}; + +static int orte_regx_base_close(void) +{ + /* give the selected module a chance to finalize */ + if (NULL != orte_regx.finalize) { + orte_regx.finalize(); + } + return mca_base_framework_components_close(&orte_regx_base_framework, NULL); +} + +/** + * Function for finding and opening either all MCA components, or the one + * that was specifically requested via a MCA parameter. + */ +static int orte_regx_base_open(mca_base_open_flag_t flags) +{ + int rc; + + /* Open up all available components */ + rc = mca_base_framework_components_open(&orte_regx_base_framework, flags); + + /* All done */ + return rc; +} + +MCA_BASE_FRAMEWORK_DECLARE(orte, regx, "ORTE Regx Subsystem", NULL, + orte_regx_base_open, orte_regx_base_close, + mca_regx_base_static_components, 0); + +/* OBJECT INSTANTIATIONS */ +static void nrcon(orte_nidmap_regex_t *p) +{ + p->ctx = 0; + p->nprocs = -1; + p->cnt = 0; +} +OBJ_CLASS_INSTANCE(orte_nidmap_regex_t, + opal_list_item_t, + nrcon, NULL); diff --git a/orte/mca/regx/base/regx_base_select.c b/orte/mca/regx/base/regx_base_select.c new file mode 100644 index 0000000000..35cd36dc2a --- /dev/null +++ b/orte/mca/regx/base/regx_base_select.c @@ -0,0 +1,61 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2008 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 + * 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) 2015 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "orte_config.h" +#include "orte/constants.h" + +#include "orte/mca/mca.h" +#include "opal/mca/base/base.h" + +#include "orte/mca/regx/base/base.h" + + +/** + * Function for selecting one component from all those that are + * available. + */ +int orte_regx_base_select(void) +{ + orte_regx_base_component_t *best_component = NULL; + orte_regx_base_module_t *best_module = NULL; + int rc = ORTE_SUCCESS; + + /* + * Select the best component + */ + if (OPAL_SUCCESS != mca_base_select("regx", orte_regx_base_framework.framework_output, + &orte_regx_base_framework.framework_components, + (mca_base_module_t **) &best_module, + (mca_base_component_t **) &best_component, NULL)) { + /* This will only happen if no component was selected */ + return ORTE_ERR_NOT_FOUND; + } + + /* Save the winner */ + orte_regx = *best_module; + /* give it a chance to init */ + if (NULL != orte_regx.init) { + rc = orte_regx.init(); + } + return rc; +} diff --git a/orte/mca/regx/fwd/Makefile.am b/orte/mca/regx/fwd/Makefile.am new file mode 100644 index 0000000000..6adc516bb6 --- /dev/null +++ b/orte/mca/regx/fwd/Makefile.am @@ -0,0 +1,37 @@ +# +# Copyright (c) 2016-2018 Intel, Inc. All rights reserved. +# Copyright (c) 2017 IBM Corporation. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +sources = \ + regx_fwd_component.c \ + regx_fwd.h \ + regx_fwd.c + +# Make the output library in this directory, and name it either +# mca__.la (for DSO builds) or libmca__.la +# (for static builds). + +if MCA_BUILD_orte_regx_fwd_DSO +component_noinst = +component_install = mca_regx_fwd.la +else +component_noinst = libmca_regx_fwd.la +component_install = +endif + +mcacomponentdir = $(ortelibdir) +mcacomponent_LTLIBRARIES = $(component_install) +mca_regx_fwd_la_SOURCES = $(sources) +mca_regx_fwd_la_LDFLAGS = -module -avoid-version +mca_regx_fwd_la_LIBADD = $(top_builddir)/orte/lib@ORTE_LIB_PREFIX@open-rte.la + +noinst_LTLIBRARIES = $(component_noinst) +libmca_regx_fwd_la_SOURCES = $(sources) +libmca_regx_fwd_la_LDFLAGS = -module -avoid-version + diff --git a/orte/mca/regx/fwd/owner.txt b/orte/mca/regx/fwd/owner.txt new file mode 100644 index 0000000000..85b4416d20 --- /dev/null +++ b/orte/mca/regx/fwd/owner.txt @@ -0,0 +1,7 @@ +# +# owner/status file +# owner: institution that is responsible for this package +# status: e.g. active, maintenance, unmaintained +# +owner: INTEL +status: active diff --git a/orte/util/nidmap.c b/orte/mca/regx/fwd/regx_fwd.c similarity index 60% rename from orte/util/nidmap.c rename to orte/mca/regx/fwd/regx_fwd.c index fa05f681bf..87250172a1 100644 --- a/orte/util/nidmap.c +++ b/orte/mca/regx/fwd/regx_fwd.c @@ -1,210 +1,106 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2004-2005 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) 2012-2014 Los Alamos National Security, LLC. - * All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2017 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ + * */ + #include "orte_config.h" #include "orte/types.h" -#include "orte/constants.h" +#include "opal/types.h" -#include -#include -#include -#include -#include #ifdef HAVE_UNISTD_H #include #endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_IFADDRS_H -#include -#endif +#include -#include "opal/dss/dss.h" -#include "opal/runtime/opal.h" -#include "opal/class/opal_pointer_array.h" -#include "opal/mca/pmix/pmix.h" -#include "opal/mca/hwloc/base/base.h" -#include "opal/util/net.h" -#include "opal/util/output.h" #include "opal/util/argv.h" -#include "opal/datatype/opal_datatype.h" +#include "opal/util/basename.h" +#include "opal/util/opal_environ.h" -#include "orte/mca/dfs/dfs.h" +#include "orte/runtime/orte_globals.h" +#include "orte/util/name_fns.h" +#include "orte/util/show_help.h" #include "orte/mca/errmgr/errmgr.h" -#include "orte/mca/odls/base/odls_private.h" #include "orte/mca/rmaps/base/base.h" #include "orte/mca/routed/routed.h" -#include "orte/util/show_help.h" -#include "orte/util/proc_info.h" -#include "orte/util/name_fns.h" -#include "orte/util/regex.h" -#include "orte/runtime/orte_globals.h" -#include "orte/mca/rml/base/rml_contact.h" -#include "orte/mca/state/state.h" +#include "orte/mca/regx/base/base.h" -#include "orte/util/nidmap.h" +#include "regx_fwd.h" -static int orte_nidmap_verbosity = -1; -static int orte_nidmap_output = -1; +static int nidmap_create(opal_pointer_array_t *pool, char **regex); +static int nidmap_parse(char *regex); +static int encode_nodemap(opal_buffer_t *buffer); +static int decode_daemon_nodemap(opal_buffer_t *buffer); +static int generate_ppn(orte_job_t *jdata, char **ppn); +static int parse_ppn(orte_job_t *jdata, char *ppn); -void orte_util_nidmap_init(void) +orte_regx_base_module_t orte_regx_fwd_module = { + .nidmap_create = nidmap_create, + .nidmap_parse = nidmap_parse, + .encode_nodemap = encode_nodemap, + .decode_daemon_nodemap = decode_daemon_nodemap, + .generate_ppn = generate_ppn, + .parse_ppn = parse_ppn +}; + +typedef struct { + opal_list_item_t super; + int vpid; + int cnt; + int slots; + orte_topology_t *t; +} orte_regex_range_t; +static void range_construct(orte_regex_range_t *ptr) { - orte_nidmap_verbosity = -1; - (void) mca_base_var_register ("orte", "orte", NULL, "nidmap_verbose", - "Verbosity level for ORTE debug messages in the nidmap utilities", - MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, - OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_ALL, - &orte_nidmap_verbosity); - - /* set default output */ - orte_nidmap_output = opal_output_open(NULL); - - /* open up the verbose output for debugging */ - if (0 < orte_nidmap_verbosity) { - opal_output_set_verbosity(orte_nidmap_output, orte_nidmap_verbosity); - } + ptr->vpid = 0; + ptr->cnt = 0; } +OBJ_CLASS_INSTANCE(orte_regex_range_t, + opal_list_item_t, + range_construct, NULL); -int orte_util_build_daemon_nidmap(void) +typedef struct { + /* list object */ + opal_list_item_t super; + char *prefix; + char *suffix; + int num_digits; + opal_list_t ranges; +} orte_regex_node_t; +static void orte_regex_node_construct(orte_regex_node_t *ptr) { - int i; - int rc; - struct hostent *h; - orte_node_t *node; - opal_process_name_t proc; - char *uri, *addr; - char *proc_name; - opal_value_t kv, val; - - /* install the entry for the HNP */ - proc.jobid = ORTE_PROC_MY_NAME->jobid; - proc.vpid = 0; - OBJ_CONSTRUCT(&kv, opal_value_t); - kv.key = strdup(ORTE_DB_DAEMON_VPID); - kv.data.uint32 = proc.vpid; - kv.type = OPAL_UINT32; - if (OPAL_SUCCESS != (rc = opal_pmix.store_local(&proc, &kv))) { - ORTE_ERROR_LOG(rc); - OBJ_DESTRUCT(&kv); - return rc; - } - OBJ_DESTRUCT(&kv); - - /* we must have already built the node pool, so cycle across it */ - OBJ_CONSTRUCT(&val, opal_value_t); - val.key = OPAL_PMIX_PROC_URI; - val.type = OPAL_STRING; - for (i=0; i < orte_node_pool->size; i++) { - if (NULL == (node = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, i))) { - continue; - } - if (NULL == node->daemon) { - /* this node isn't occupied */ - continue; - } - /* define the vpid for this daemon */ - proc.vpid = node->daemon->name.vpid; - /* store the hostname for the proc */ - OBJ_CONSTRUCT(&kv, opal_value_t); - kv.key = strdup(OPAL_PMIX_HOSTNAME); - kv.data.string = strdup(node->name); - kv.type = OPAL_STRING; - if (OPAL_SUCCESS != (rc = opal_pmix.store_local(&proc, &kv))) { - ORTE_ERROR_LOG(rc); - OBJ_DESTRUCT(&kv); - return rc; - } - OBJ_DESTRUCT(&kv); - - /* the arch defaults to our arch so that non-hetero - * case will yield correct behavior - */ - OBJ_CONSTRUCT(&kv, opal_value_t); - kv.key = strdup(OPAL_PMIX_ARCH); - kv.data.uint32 = opal_local_arch; - kv.type = OPAL_UINT32; - if (OPAL_SUCCESS != (rc = opal_pmix.store_local(&proc, &kv))) { - ORTE_ERROR_LOG(rc); - OBJ_DESTRUCT(&kv); - return rc; - } - OBJ_DESTRUCT(&kv); - - /* lookup the address of this node */ - if (NULL == (h = gethostbyname(node->name))) { - ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND); - return ORTE_ERR_NOT_FOUND; - } - addr = inet_ntoa(*(struct in_addr*)h->h_addr_list[0]); - - /* since we are using static ports, all my fellow daemons will be on my - * port. Setup the contact info for each daemon in my hash tables. Note - * that this will -not- open a port to those daemons, but will only - * define the info necessary for opening such a port if/when I communicate - * to them - */ - - /* construct the URI */ - orte_util_convert_process_name_to_string(&proc_name, &proc); - asprintf(&uri, "%s;tcp://%s:%d", proc_name, addr, (int)orte_process_info.my_port); - OPAL_OUTPUT_VERBOSE((2, orte_debug_verbosity, - "%s orte:util:build:daemon:nidmap node %s daemon %d addr %s uri %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), - node->name, i+1, addr, uri)); - /* if this is the HNP, then save it */ - if (!ORTE_PROC_IS_HNP && 0 == i) { - orte_process_info.my_hnp_uri = strdup(uri); - } - val.data.string = uri; - if (OPAL_SUCCESS != (rc = opal_pmix.store_local(&proc, &val))) { - ORTE_ERROR_LOG(rc); - val.key = NULL; - val.data.string = NULL; - OBJ_DESTRUCT(&val); - return rc; - } - - free(proc_name); - free(uri); - } - val.key = NULL; - val.data.string = NULL; - OBJ_DESTRUCT(&val); - - return rc; + ptr->prefix = NULL; + ptr->suffix = NULL; + ptr->num_digits = 0; + OBJ_CONSTRUCT(&ptr->ranges, opal_list_t); } +static void orte_regex_node_destruct(orte_regex_node_t *ptr) +{ + opal_list_item_t *item; -int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex) + if (NULL != ptr->prefix) { + free(ptr->prefix); + } + if (NULL != ptr->suffix) { + free(ptr->suffix); + } + + while (NULL != (item = opal_list_remove_first(&ptr->ranges))) { + OBJ_RELEASE(item); + } + OBJ_DESTRUCT(&ptr->ranges); +} +OBJ_CLASS_INSTANCE(orte_regex_node_t, + opal_list_item_t, + orte_regex_node_construct, + orte_regex_node_destruct); +static int extract_node_names(char *regexp, char ***names); + +static int nidmap_create(opal_pointer_array_t *pool, char **regex) { char *node; char prefix[ORTE_MAX_NODE_PREFIX]; @@ -475,327 +371,7 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex) return ORTE_SUCCESS; } -int orte_util_encode_nodemap(opal_buffer_t *buffer) -{ - int n; - bool test; - orte_regex_range_t *rng, *slt, *tp, *flg; - opal_list_t slots, topos, flags; - opal_list_item_t *item; - char *tmp, *tmp2; - orte_node_t *nptr; - int rc; - uint8_t ui8; - orte_topology_t *ortetopo; - - /* setup the list of results */ - OBJ_CONSTRUCT(&slots, opal_list_t); - OBJ_CONSTRUCT(&topos, opal_list_t); - OBJ_CONSTRUCT(&flags, opal_list_t); - - slt = NULL; - tp = NULL; - flg = NULL; - - /* pack a flag indicating if the HNP was included in the allocation */ - if (orte_hnp_is_allocated) { - ui8 = 1; - } else { - ui8 = 0; - } - if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &ui8, 1, OPAL_UINT8))) { - ORTE_ERROR_LOG(rc); - return rc; - } - - /* pack a flag indicating if we are in a managed allocation */ - if (orte_managed_allocation) { - ui8 = 1; - } else { - ui8 = 0; - } - if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &ui8, 1, OPAL_UINT8))) { - ORTE_ERROR_LOG(rc); - return rc; - } - - /* handle the topologies - as the most common case by far - * is to have homogeneous topologies, we only send them - * if something is different. We know that the HNP is - * the first topology, and that any differing topology - * on the compute nodes must follow. So send the topologies - * if and only if: - * - * (a) the HNP is being used to house application procs and - * there is more than one topology on our list; or - * - * (b) the HNP is not being used, but there are more than - * two topologies on our list, thus indicating that - * there are multiple topologies on the compute nodes - */ - nptr = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, 0); - if (!orte_hnp_is_allocated || (ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping) & ORTE_MAPPING_NO_USE_LOCAL)) { - /* assign a NULL topology so we still account for our presence, - * but don't cause us to send topology info when not needed */ - tp = OBJ_NEW(orte_regex_range_t); - tp->t = NULL; - tp->cnt = 1; - } else { - /* there is always one topology - our own - so start with it */ - tp = OBJ_NEW(orte_regex_range_t); - tp->t = nptr->topology; - tp->cnt = 1; - } - opal_list_append(&topos, &tp->super); - - opal_output_verbose(5, orte_nidmap_output, - "%s STARTING WITH TOPOLOGY FOR NODE %s: %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), - nptr->name, (NULL == tp->t) ? "NULL" : tp->t->sig); - - /* likewise, we have slots */ - slt = OBJ_NEW(orte_regex_range_t); - slt->slots = nptr->slots; - slt->cnt = 1; - opal_list_append(&slots, &slt->super); - - /* and flags */ - flg = OBJ_NEW(orte_regex_range_t); - if (ORTE_FLAG_TEST(nptr, ORTE_NODE_FLAG_SLOTS_GIVEN)) { - flg->slots = 1; - } else { - flg->slots = 0; - } - flg->cnt = 1; - opal_list_append(&flags, &flg->super); - - for (n=1; n < orte_node_pool->size; n++) { - if (NULL == (nptr = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, n))) { - continue; - } - /* check the #slots */ - /* is this the next in line */ - if (nptr->slots == slt->slots) { - slt->cnt++; - } else { - /* need to start another range */ - slt = OBJ_NEW(orte_regex_range_t); - slt->slots = nptr->slots; - slt->cnt = 1; - opal_list_append(&slots, &slt->super); - } - /* check the topologies */ - if (NULL != tp->t && NULL == nptr->topology) { - /* we don't know this topology, likely because - * we don't have a daemon on the node */ - tp = OBJ_NEW(orte_regex_range_t); - tp->t = NULL; - tp->cnt = 1; - opal_output_verbose(5, orte_nidmap_output, - "%s ADD TOPOLOGY FOR NODE %s: NULL", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), nptr->name); - opal_list_append(&topos, &tp->super); - } else { - /* is this the next in line */ - if (tp->t == nptr->topology) { - tp->cnt++; - opal_output_verbose(5, orte_nidmap_output, - "%s CONTINUE TOPOLOGY RANGE (%d) WITH NODE %s: %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), - tp->cnt, nptr->name, - (NULL == tp->t) ? "N/A" : tp->t->sig); - } else { - /* need to start another range */ - tp = OBJ_NEW(orte_regex_range_t); - tp->t = nptr->topology; - tp->cnt = 1; - opal_output_verbose(5, orte_nidmap_output, - "%s STARTING NEW TOPOLOGY RANGE WITH NODE %s: %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), - nptr->name, tp->t->sig); - opal_list_append(&topos, &tp->super); - } - } - /* check the flags */ - test = ORTE_FLAG_TEST(nptr, ORTE_NODE_FLAG_SLOTS_GIVEN); - /* is this the next in line */ - if ((test && 1 == flg->slots) || - (!test && 0 == flg->slots)) { - flg->cnt++; - } else { - /* need to start another range */ - flg = OBJ_NEW(orte_regex_range_t); - if (test) { - flg->slots = 1; - } else { - flg->slots = 0; - } - flg->cnt = 1; - opal_list_append(&flags, &flg->super); - } - } - - /* pass #slots on each node */ - tmp = NULL; - while (NULL != (item = opal_list_remove_first(&slots))) { - rng = (orte_regex_range_t*)item; - if (NULL == tmp) { - asprintf(&tmp, "%d[%d]", rng->cnt, rng->slots); - } else { - asprintf(&tmp2, "%s,%d[%d]", tmp, rng->cnt, rng->slots); - free(tmp); - tmp = tmp2; - } - OBJ_RELEASE(rng); - } - OPAL_LIST_DESTRUCT(&slots); - opal_output_verbose(1, orte_nidmap_output, - "%s SLOT ASSIGNMENTS: %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), tmp); - /* pack the string */ - if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &tmp, 1, OPAL_STRING))) { - ORTE_ERROR_LOG(rc); - return rc; - } - if (NULL != tmp) { - free(tmp); - } - - /* do the same to pass the flags for each node */ - tmp = NULL; - while (NULL != (item = opal_list_remove_first(&flags))) { - rng = (orte_regex_range_t*)item; - if (NULL == tmp) { - asprintf(&tmp, "%d[%d]", rng->cnt, rng->slots); - } else { - asprintf(&tmp2, "%s,%d[%d]", tmp, rng->cnt, rng->slots); - free(tmp); - tmp = tmp2; - } - OBJ_RELEASE(rng); - } - OPAL_LIST_DESTRUCT(&flags); - - /* pack the string */ - opal_output_verbose(1, orte_nidmap_output, - "%s FLAG ASSIGNMENTS: %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), tmp); - if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &tmp, 1, OPAL_STRING))) { - ORTE_ERROR_LOG(rc); - return rc; - } - if (NULL != tmp) { - free(tmp); - } - - /* don't try to be cute - there aren't going to be that many - * topologies, so just scan the list and see if they are the - * same, excluding any NULL values */ - ortetopo = NULL; - test = false; - OPAL_LIST_FOREACH(rng, &topos, orte_regex_range_t) { - if (NULL == rng->t) { - continue; - } - if (NULL == ortetopo) { - ortetopo = rng->t; - } else if (0 != strcmp(ortetopo->sig, rng->t->sig)) { - /* we have a difference, so send them */ - test = true; - } - } - tmp = NULL; - if (test) { - opal_buffer_t bucket, *bptr; - OBJ_CONSTRUCT(&bucket, opal_buffer_t); - while (NULL != (item = opal_list_remove_first(&topos))) { - rng = (orte_regex_range_t*)item; - opal_output_verbose(5, orte_nidmap_output, - "%s PASSING TOPOLOGY %s RANGE %d", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), - (NULL == rng->t) ? "NULL" : rng->t->sig, rng->cnt); - if (NULL == tmp) { - asprintf(&tmp, "%d", rng->cnt); - } else { - asprintf(&tmp2, "%s,%d", tmp, rng->cnt); - free(tmp); - tmp = tmp2; - } - if (NULL == rng->t) { - /* need to account for NULL topology */ - opal_output_verbose(1, orte_nidmap_output, - "%s PACKING NULL TOPOLOGY", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)); - tmp2 = NULL; - if (ORTE_SUCCESS != (rc = opal_dss.pack(&bucket, &tmp2, 1, OPAL_STRING))) { - ORTE_ERROR_LOG(rc); - OBJ_RELEASE(rng); - OPAL_LIST_DESTRUCT(&topos); - OBJ_DESTRUCT(&bucket); - free(tmp); - return rc; - } - } else { - opal_output_verbose(1, orte_nidmap_output, - "%s PACKING TOPOLOGY: %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), rng->t->sig); - /* pack this topology string */ - if (ORTE_SUCCESS != (rc = opal_dss.pack(&bucket, &rng->t->sig, 1, OPAL_STRING))) { - ORTE_ERROR_LOG(rc); - OBJ_RELEASE(rng); - OPAL_LIST_DESTRUCT(&topos); - OBJ_DESTRUCT(&bucket); - free(tmp); - return rc; - } - /* pack the topology itself */ - if (ORTE_SUCCESS != (rc = opal_dss.pack(&bucket, &rng->t->topo, 1, OPAL_HWLOC_TOPO))) { - ORTE_ERROR_LOG(rc); - OBJ_RELEASE(rng); - OPAL_LIST_DESTRUCT(&topos); - OBJ_DESTRUCT(&bucket); - free(tmp); - return rc; - } - } - OBJ_RELEASE(rng); - } - OPAL_LIST_DESTRUCT(&topos); - /* pack the string */ - opal_output_verbose(1, orte_nidmap_output, - "%s TOPOLOGY ASSIGNMENTS: %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), tmp); - if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &tmp, 1, OPAL_STRING))) { - ORTE_ERROR_LOG(rc); - OBJ_DESTRUCT(&bucket); - free(tmp); - return rc; - } - free(tmp); - - /* now pack the topologies */ - bptr = &bucket; - if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &bptr, 1, OPAL_BUFFER))) { - ORTE_ERROR_LOG(rc); - OBJ_DESTRUCT(&bucket); - return rc; - } - OBJ_DESTRUCT(&bucket); - } else { - opal_output_verbose(1, orte_nidmap_output, - "%s NOT PASSING TOPOLOGIES", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)); - /* need to pack the NULL just to terminate the region */ - if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &tmp, 1, OPAL_STRING))) { - ORTE_ERROR_LOG(rc); - return rc; - } - } - - return ORTE_SUCCESS; -} - -int orte_util_nidmap_parse(char *regex) +static int nidmap_parse(char *regex) { char *nodelist, *vpids, *ptr; char **nodes, **dvpids; @@ -827,7 +403,7 @@ int orte_util_nidmap_parse(char *regex) /* decompress the nodes regex */ nodes = NULL; - if (ORTE_SUCCESS != (rc = orte_regex_extract_node_names(nodelist, &nodes))) { + if (ORTE_SUCCESS != (rc = extract_node_names(nodelist, &nodes))) { ORTE_ERROR_LOG(rc); return rc; } @@ -909,7 +485,7 @@ int orte_util_nidmap_parse(char *regex) orte_process_info.max_procs = orte_process_info.num_procs; } - if (0 < opal_output_get_verbosity(orte_debug_verbosity)) { + if (0 < opal_output_get_verbosity(orte_regx_base_framework.framework_output)) { int i; for (i=0; i < orte_node_pool->size; i++) { if (NULL == (nd = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, i))) { @@ -925,288 +501,585 @@ int orte_util_nidmap_parse(char *regex) return ORTE_SUCCESS; } -/* decode a nodemap for a daemon */ -int orte_util_decode_daemon_nodemap(opal_buffer_t *buffer) +static int encode_nodemap(opal_buffer_t *buffer) { - int n, nn, rc, cnt, offset; - orte_node_t *node; - char *slots=NULL, *topos=NULL, *flags=NULL; - char *rmndr, **tmp; - opal_list_t slts, flgs;; - opal_buffer_t *bptr=NULL; - orte_topology_t *t2; - orte_regex_range_t *rng, *srng, *frng; + int n; + bool test; + orte_regex_range_t *rng, *slt, *tp, *flg; + opal_list_t slots, topos, flags; + opal_list_item_t *item; + char *tmp, *tmp2; + orte_node_t *nptr; + int rc; uint8_t ui8; + orte_topology_t *ortetopo; - OBJ_CONSTRUCT(&slts, opal_list_t); - OBJ_CONSTRUCT(&flgs, opal_list_t); + /* setup the list of results */ + OBJ_CONSTRUCT(&slots, opal_list_t); + OBJ_CONSTRUCT(&topos, opal_list_t); + OBJ_CONSTRUCT(&flags, opal_list_t); - /* unpack the flag indicating if the HNP was allocated */ - n = 1; - if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &ui8, &n, OPAL_UINT8))) { - ORTE_ERROR_LOG(rc); - goto cleanup; - } - if (0 == ui8) { - orte_hnp_is_allocated = false; + slt = NULL; + tp = NULL; + flg = NULL; + + /* pack a flag indicating if the HNP was included in the allocation */ + if (orte_hnp_is_allocated) { + ui8 = 1; } else { - orte_hnp_is_allocated = true; + ui8 = 0; + } + if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &ui8, 1, OPAL_UINT8))) { + ORTE_ERROR_LOG(rc); + return rc; } - /* unpack the flag indicating we are in a managed allocation */ - n = 1; - if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &ui8, &n, OPAL_UINT8))) { - ORTE_ERROR_LOG(rc); - goto cleanup; - } - if (0 == ui8) { - orte_managed_allocation = false; + /* pack a flag indicating if we are in a managed allocation */ + if (orte_managed_allocation) { + ui8 = 1; } else { - orte_managed_allocation = true; + ui8 = 0; } - - /* unpack the slots regex */ - n = 1; - if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &slots, &n, OPAL_STRING))) { + if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &ui8, 1, OPAL_UINT8))) { ORTE_ERROR_LOG(rc); - goto cleanup; - } - /* this is not allowed to be NULL */ - if (NULL == slots) { - ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); - rc = ORTE_ERR_BAD_PARAM; - goto cleanup; + return rc; } - /* unpack the flags regex */ - n = 1; - if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &flags, &n, OPAL_STRING))) { - ORTE_ERROR_LOG(rc); - goto cleanup; - } - /* this is not allowed to be NULL */ - if (NULL == flags) { - ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); - rc = ORTE_ERR_BAD_PARAM; - goto cleanup; + /* handle the topologies - as the most common case by far + * is to have homogeneous topologies, we only send them + * if something is different. We know that the HNP is + * the first topology, and that any differing topology + * on the compute nodes must follow. So send the topologies + * if and only if: + * + * (a) the HNP is being used to house application procs and + * there is more than one topology on our list; or + * + * (b) the HNP is not being used, but there are more than + * two topologies on our list, thus indicating that + * there are multiple topologies on the compute nodes + */ + nptr = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, 0); + if (!orte_hnp_is_allocated || (ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping) & ORTE_MAPPING_NO_USE_LOCAL)) { + /* assign a NULL topology so we still account for our presence, + * but don't cause us to send topology info when not needed */ + tp = OBJ_NEW(orte_regex_range_t); + tp->t = NULL; + tp->cnt = 1; + } else { + /* there is always one topology - our own - so start with it */ + tp = OBJ_NEW(orte_regex_range_t); + tp->t = nptr->topology; + tp->cnt = 1; } + opal_list_append(&topos, &tp->super); - /* unpack the topos regex - this may not have been - * provided (e.g., for a homogeneous machine) */ - n = 1; - if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &topos, &n, OPAL_STRING))) { - ORTE_ERROR_LOG(rc); - goto cleanup; - } - if (NULL != topos) { - /* need to unpack the topologies */ - n = 1; - if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &bptr, &n, OPAL_BUFFER))) { - ORTE_ERROR_LOG(rc); - goto cleanup; - } - } + opal_output_verbose(5, orte_regx_base_framework.framework_output, + "%s STARTING WITH TOPOLOGY FOR NODE %s: %s", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), + nptr->name, (NULL == tp->t) ? "NULL" : tp->t->sig); - /* if we are the HNP, then we just discard these strings as we already - * have a complete picture - but we needed to unpack them in order to - * maintain sync in the unpacking order */ - if (ORTE_PROC_IS_HNP) { - rc = ORTE_SUCCESS; - goto cleanup; - } + /* likewise, we have slots */ + slt = OBJ_NEW(orte_regex_range_t); + slt->slots = nptr->slots; + slt->cnt = 1; + opal_list_append(&slots, &slt->super); - /* decompress the slots */ - tmp = opal_argv_split(slots, ','); - for (n=0; NULL != tmp[n]; n++) { - rng = OBJ_NEW(orte_regex_range_t); - opal_list_append(&slts, &rng->super); - /* find the '[' as that delimits the value */ - rmndr = strchr(tmp[n], '['); - if (NULL == rmndr) { - ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); - rc = ORTE_ERR_BAD_PARAM; - opal_argv_free(tmp); - goto cleanup; - } - *rmndr = '\0'; - ++rmndr; - /* convert that number as this is the number of - * slots for this range */ - rng->slots = strtoul(rmndr, NULL, 10); - /* convert the initial number as that is the cnt */ - rng->cnt = strtoul(tmp[n], NULL, 10); + /* and flags */ + flg = OBJ_NEW(orte_regex_range_t); + if (ORTE_FLAG_TEST(nptr, ORTE_NODE_FLAG_SLOTS_GIVEN)) { + flg->slots = 1; + } else { + flg->slots = 0; } - opal_argv_free(tmp); + flg->cnt = 1; + opal_list_append(&flags, &flg->super); - /* decompress the flags */ - tmp = opal_argv_split(flags, ','); - for (n=0; NULL != tmp[n]; n++) { - rng = OBJ_NEW(orte_regex_range_t); - opal_list_append(&flgs, &rng->super); - /* find the '[' as that delimits the value */ - rmndr = strchr(tmp[n], '['); - if (NULL == rmndr) { - ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); - opal_argv_free(tmp); - rc = ORTE_ERR_BAD_PARAM; - goto cleanup; - } - *rmndr = '\0'; - ++rmndr; - /* check the value - it is just one character */ - if ('1' == *rmndr) { - rng->slots = 1; - } else { - rng->slots = 0; - } - /* convert the initial number as that is the cnt */ - rng->cnt = strtoul(tmp[n], NULL, 10); - } - opal_argv_free(tmp); - free(flags); - - /* update the node array */ - srng = (orte_regex_range_t*)opal_list_get_first(&slts); - frng = (orte_regex_range_t*)opal_list_get_first(&flgs); - for (n=0; n < orte_node_pool->size; n++) { - if (NULL == (node = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, n))) { + for (n=1; n < orte_node_pool->size; n++) { + if (NULL == (nptr = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, n))) { continue; } - /* set the number of slots */ - node->slots = srng->slots; - srng->cnt--; - if (0 == srng->cnt) { - srng = (orte_regex_range_t*)opal_list_get_next(&srng->super); - } - /* set the flags */ - if (0 == frng->slots) { - ORTE_FLAG_UNSET(node, ORTE_NODE_FLAG_SLOTS_GIVEN); + /* check the #slots */ + /* is this the next in line */ + if (nptr->slots == slt->slots) { + slt->cnt++; } else { - ORTE_FLAG_SET(node, ORTE_NODE_FLAG_SLOTS_GIVEN); + /* need to start another range */ + slt = OBJ_NEW(orte_regex_range_t); + slt->slots = nptr->slots; + slt->cnt = 1; + opal_list_append(&slots, &slt->super); } - frng->cnt--; - if (0 == frng->cnt) { - frng = (orte_regex_range_t*)opal_list_get_next(&frng->super); + /* check the topologies */ + if (NULL != tp->t && NULL == nptr->topology) { + /* we don't know this topology, likely because + * we don't have a daemon on the node */ + tp = OBJ_NEW(orte_regex_range_t); + tp->t = NULL; + tp->cnt = 1; + opal_output_verbose(5, orte_regx_base_framework.framework_output, + "%s ADD TOPOLOGY FOR NODE %s: NULL", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), nptr->name); + opal_list_append(&topos, &tp->super); + } else { + /* is this the next in line */ + if (tp->t == nptr->topology) { + tp->cnt++; + opal_output_verbose(5, orte_regx_base_framework.framework_output, + "%s CONTINUE TOPOLOGY RANGE (%d) WITH NODE %s: %s", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), + tp->cnt, nptr->name, + (NULL == tp->t) ? "N/A" : tp->t->sig); + } else { + /* need to start another range */ + tp = OBJ_NEW(orte_regex_range_t); + tp->t = nptr->topology; + tp->cnt = 1; + opal_output_verbose(5, orte_regx_base_framework.framework_output, + "%s STARTING NEW TOPOLOGY RANGE WITH NODE %s: %s", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), + nptr->name, tp->t->sig); + opal_list_append(&topos, &tp->super); + } + } + /* check the flags */ + test = ORTE_FLAG_TEST(nptr, ORTE_NODE_FLAG_SLOTS_GIVEN); + /* is this the next in line */ + if ((test && 1 == flg->slots) || + (!test && 0 == flg->slots)) { + flg->cnt++; + } else { + /* need to start another range */ + flg = OBJ_NEW(orte_regex_range_t); + if (test) { + flg->slots = 1; + } else { + flg->slots = 0; + } + flg->cnt = 1; + opal_list_append(&flags, &flg->super); } } - /* if no topology info was passed, then everyone shares our topology */ - if (NULL == bptr) { - /* our topology is first in the array */ - t2 = (orte_topology_t*)opal_pointer_array_get_item(orte_node_topologies, 0); - opal_output_verbose(1, orte_nidmap_output, - "%s ASSIGNING ALL TOPOLOGIES TO: %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), t2->sig); - for (n=0; n < orte_node_pool->size; n++) { - if (NULL != (node = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, n))) { - if (NULL == node->topology) { - OBJ_RETAIN(t2); - node->topology = t2; - } - } + /* pass #slots on each node */ + tmp = NULL; + while (NULL != (item = opal_list_remove_first(&slots))) { + rng = (orte_regex_range_t*)item; + if (NULL == tmp) { + asprintf(&tmp, "%d[%d]", rng->cnt, rng->slots); + } else { + asprintf(&tmp2, "%s,%d[%d]", tmp, rng->cnt, rng->slots); + free(tmp); + tmp = tmp2; } - } else { - char *sig; - hwloc_topology_t topo; - /* decompress the topology regex */ - tmp = opal_argv_split(topos, ','); - /* there must be a topology definition for each range */ - offset = 0; - for (nn=0; NULL != tmp[nn]; nn++) { - cnt = strtoul(tmp[nn], NULL, 10); - /* unpack the signature */ - n = 1; - if (ORTE_SUCCESS != (rc = opal_dss.unpack(bptr, &sig, &n, OPAL_STRING))) { - ORTE_ERROR_LOG(rc); - opal_argv_free(tmp); - OBJ_RELEASE(bptr); - goto cleanup; - } - if (NULL == sig) { - /* the nodes in this range have not reported a topology, - * so skip them */ - offset += cnt; - continue; - } - n = 1; - if (ORTE_SUCCESS != (rc = opal_dss.unpack(bptr, &topo, &n, OPAL_HWLOC_TOPO))) { - ORTE_ERROR_LOG(rc); - opal_argv_free(tmp); - OBJ_RELEASE(bptr); - free(sig); - goto cleanup; - } - /* see if we already have this topology - could be an update */ - t2 = NULL; - for (n=0; n < orte_node_topologies->size; n++) { - if (NULL == (t2 = (orte_topology_t*)opal_pointer_array_get_item(orte_node_topologies, n))) { - continue; - } - if (0 == strcmp(t2->sig, sig)) { - /* found a match */ - free(sig); - opal_hwloc_base_free_topology(topo); - sig = NULL; - break; - } - } - if (NULL != sig || NULL == t2) { - /* new topology - record it */ - t2 = OBJ_NEW(orte_topology_t); - t2->sig = sig; - t2->topo = topo; - opal_pointer_array_add(orte_node_topologies, t2); - } - /* point each of the nodes in this range to this topology */ - n=0; - while (n < cnt && (n+offset) < orte_node_pool->size) { - if (NULL == (node = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, n+offset))) { - continue; - } - opal_output_verbose(1, orte_nidmap_output, - "%s ASSIGNING NODE %s WITH TOPO: %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), - node->name, t2->sig); - if (NULL == node->topology) { - OBJ_RETAIN(t2); - node->topology = t2; - } - ++n; - } - offset += cnt; - } - OBJ_RELEASE(bptr); - opal_argv_free(tmp); + OBJ_RELEASE(rng); } + OPAL_LIST_DESTRUCT(&slots); + opal_output_verbose(1, orte_regx_base_framework.framework_output, + "%s SLOT ASSIGNMENTS: %s", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), tmp); + /* pack the string */ + if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &tmp, 1, OPAL_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + if (NULL != tmp) { + free(tmp); + } + + /* do the same to pass the flags for each node */ + tmp = NULL; + while (NULL != (item = opal_list_remove_first(&flags))) { + rng = (orte_regex_range_t*)item; + if (NULL == tmp) { + asprintf(&tmp, "%d[%d]", rng->cnt, rng->slots); + } else { + asprintf(&tmp2, "%s,%d[%d]", tmp, rng->cnt, rng->slots); + free(tmp); + tmp = tmp2; + } + OBJ_RELEASE(rng); + } + OPAL_LIST_DESTRUCT(&flags); + + /* pack the string */ + opal_output_verbose(1, orte_regx_base_framework.framework_output, + "%s FLAG ASSIGNMENTS: %s", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), tmp); + if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &tmp, 1, OPAL_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + if (NULL != tmp) { + free(tmp); + } + + /* don't try to be cute - there aren't going to be that many + * topologies, so just scan the list and see if they are the + * same, excluding any NULL values */ + ortetopo = NULL; + test = false; + OPAL_LIST_FOREACH(rng, &topos, orte_regex_range_t) { + if (NULL == rng->t) { + continue; + } + if (NULL == ortetopo) { + ortetopo = rng->t; + } else if (0 != strcmp(ortetopo->sig, rng->t->sig)) { + /* we have a difference, so send them */ + test = true; + } + } + tmp = NULL; + if (test) { + opal_buffer_t bucket, *bptr; + OBJ_CONSTRUCT(&bucket, opal_buffer_t); + while (NULL != (item = opal_list_remove_first(&topos))) { + rng = (orte_regex_range_t*)item; + opal_output_verbose(5, orte_regx_base_framework.framework_output, + "%s PASSING TOPOLOGY %s RANGE %d", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), + (NULL == rng->t) ? "NULL" : rng->t->sig, rng->cnt); + if (NULL == tmp) { + asprintf(&tmp, "%d", rng->cnt); + } else { + asprintf(&tmp2, "%s,%d", tmp, rng->cnt); + free(tmp); + tmp = tmp2; + } + if (NULL == rng->t) { + /* need to account for NULL topology */ + opal_output_verbose(1, orte_regx_base_framework.framework_output, + "%s PACKING NULL TOPOLOGY", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)); + tmp2 = NULL; + if (ORTE_SUCCESS != (rc = opal_dss.pack(&bucket, &tmp2, 1, OPAL_STRING))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(rng); + OPAL_LIST_DESTRUCT(&topos); + OBJ_DESTRUCT(&bucket); + free(tmp); + return rc; + } + } else { + opal_output_verbose(1, orte_regx_base_framework.framework_output, + "%s PACKING TOPOLOGY: %s", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), rng->t->sig); + /* pack this topology string */ + if (ORTE_SUCCESS != (rc = opal_dss.pack(&bucket, &rng->t->sig, 1, OPAL_STRING))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(rng); + OPAL_LIST_DESTRUCT(&topos); + OBJ_DESTRUCT(&bucket); + free(tmp); + return rc; + } + /* pack the topology itself */ + if (ORTE_SUCCESS != (rc = opal_dss.pack(&bucket, &rng->t->topo, 1, OPAL_HWLOC_TOPO))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(rng); + OPAL_LIST_DESTRUCT(&topos); + OBJ_DESTRUCT(&bucket); + free(tmp); + return rc; + } + } + OBJ_RELEASE(rng); + } + OPAL_LIST_DESTRUCT(&topos); + /* pack the string */ + opal_output_verbose(1, orte_regx_base_framework.framework_output, + "%s TOPOLOGY ASSIGNMENTS: %s", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), tmp); + if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &tmp, 1, OPAL_STRING))) { + ORTE_ERROR_LOG(rc); + OBJ_DESTRUCT(&bucket); + free(tmp); + return rc; + } + free(tmp); + + /* now pack the topologies */ + bptr = &bucket; + if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &bptr, 1, OPAL_BUFFER))) { + ORTE_ERROR_LOG(rc); + OBJ_DESTRUCT(&bucket); + return rc; + } + OBJ_DESTRUCT(&bucket); + } else { + opal_output_verbose(1, orte_regx_base_framework.framework_output, + "%s NOT PASSING TOPOLOGIES", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)); + /* need to pack the NULL just to terminate the region */ + if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, &tmp, 1, OPAL_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + return ORTE_SUCCESS; +} + +static int decode_daemon_nodemap(opal_buffer_t *buffer) +{ + int n, nn, rc, cnt, offset; + orte_node_t *node; + char *slots=NULL, *topos=NULL, *flags=NULL; + char *rmndr, **tmp; + opal_list_t slts, flgs;; + opal_buffer_t *bptr=NULL; + orte_topology_t *t2; + orte_regex_range_t *rng, *srng, *frng; + uint8_t ui8; + + OBJ_CONSTRUCT(&slts, opal_list_t); + OBJ_CONSTRUCT(&flgs, opal_list_t); + + /* unpack the flag indicating if the HNP was allocated */ + n = 1; + if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &ui8, &n, OPAL_UINT8))) { + ORTE_ERROR_LOG(rc); + goto cleanup; + } + if (0 == ui8) { + orte_hnp_is_allocated = false; + } else { + orte_hnp_is_allocated = true; + } + + /* unpack the flag indicating we are in a managed allocation */ + n = 1; + if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &ui8, &n, OPAL_UINT8))) { + ORTE_ERROR_LOG(rc); + goto cleanup; + } + if (0 == ui8) { + orte_managed_allocation = false; + } else { + orte_managed_allocation = true; + } + + /* unpack the slots regex */ + n = 1; + if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &slots, &n, OPAL_STRING))) { + ORTE_ERROR_LOG(rc); + goto cleanup; + } + /* this is not allowed to be NULL */ + if (NULL == slots) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + rc = ORTE_ERR_BAD_PARAM; + goto cleanup; + } + + /* unpack the flags regex */ + n = 1; + if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &flags, &n, OPAL_STRING))) { + ORTE_ERROR_LOG(rc); + goto cleanup; + } + /* this is not allowed to be NULL */ + if (NULL == flags) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + rc = ORTE_ERR_BAD_PARAM; + goto cleanup; + } + + /* unpack the topos regex - this may not have been + * provided (e.g., for a homogeneous machine) */ + n = 1; + if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &topos, &n, OPAL_STRING))) { + ORTE_ERROR_LOG(rc); + goto cleanup; + } + if (NULL != topos) { + /* need to unpack the topologies */ + n = 1; + if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &bptr, &n, OPAL_BUFFER))) { + ORTE_ERROR_LOG(rc); + goto cleanup; + } + } + + /* if we are the HNP, then we just discard these strings as we already + * have a complete picture - but we needed to unpack them in order to + * maintain sync in the unpacking order */ + if (ORTE_PROC_IS_HNP) { + rc = ORTE_SUCCESS; + goto cleanup; + } + + /* decompress the slots */ + tmp = opal_argv_split(slots, ','); + for (n=0; NULL != tmp[n]; n++) { + rng = OBJ_NEW(orte_regex_range_t); + opal_list_append(&slts, &rng->super); + /* find the '[' as that delimits the value */ + rmndr = strchr(tmp[n], '['); + if (NULL == rmndr) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + rc = ORTE_ERR_BAD_PARAM; + opal_argv_free(tmp); + goto cleanup; + } + *rmndr = '\0'; + ++rmndr; + /* convert that number as this is the number of + * slots for this range */ + rng->slots = strtoul(rmndr, NULL, 10); + /* convert the initial number as that is the cnt */ + rng->cnt = strtoul(tmp[n], NULL, 10); + } + opal_argv_free(tmp); + + /* decompress the flags */ + tmp = opal_argv_split(flags, ','); + for (n=0; NULL != tmp[n]; n++) { + rng = OBJ_NEW(orte_regex_range_t); + opal_list_append(&flgs, &rng->super); + /* find the '[' as that delimits the value */ + rmndr = strchr(tmp[n], '['); + if (NULL == rmndr) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + opal_argv_free(tmp); + rc = ORTE_ERR_BAD_PARAM; + goto cleanup; + } + *rmndr = '\0'; + ++rmndr; + /* check the value - it is just one character */ + if ('1' == *rmndr) { + rng->slots = 1; + } else { + rng->slots = 0; + } + /* convert the initial number as that is the cnt */ + rng->cnt = strtoul(tmp[n], NULL, 10); + } + opal_argv_free(tmp); + free(flags); + + /* update the node array */ + srng = (orte_regex_range_t*)opal_list_get_first(&slts); + frng = (orte_regex_range_t*)opal_list_get_first(&flgs); + for (n=0; n < orte_node_pool->size; n++) { + if (NULL == (node = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, n))) { + continue; + } + /* set the number of slots */ + node->slots = srng->slots; + srng->cnt--; + if (0 == srng->cnt) { + srng = (orte_regex_range_t*)opal_list_get_next(&srng->super); + } + /* set the flags */ + if (0 == frng->slots) { + ORTE_FLAG_UNSET(node, ORTE_NODE_FLAG_SLOTS_GIVEN); + } else { + ORTE_FLAG_SET(node, ORTE_NODE_FLAG_SLOTS_GIVEN); + } + frng->cnt--; + if (0 == frng->cnt) { + frng = (orte_regex_range_t*)opal_list_get_next(&frng->super); + } + } + + /* if no topology info was passed, then everyone shares our topology */ + if (NULL == bptr) { + /* our topology is first in the array */ + t2 = (orte_topology_t*)opal_pointer_array_get_item(orte_node_topologies, 0); + opal_output_verbose(1, orte_regx_base_framework.framework_output, + "%s ASSIGNING ALL TOPOLOGIES TO: %s", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), t2->sig); + for (n=0; n < orte_node_pool->size; n++) { + if (NULL != (node = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, n))) { + if (NULL == node->topology) { + OBJ_RETAIN(t2); + node->topology = t2; + } + } + } + } else { + char *sig; + hwloc_topology_t topo; + /* decompress the topology regex */ + tmp = opal_argv_split(topos, ','); + /* there must be a topology definition for each range */ + offset = 0; + for (nn=0; NULL != tmp[nn]; nn++) { + cnt = strtoul(tmp[nn], NULL, 10); + /* unpack the signature */ + n = 1; + if (ORTE_SUCCESS != (rc = opal_dss.unpack(bptr, &sig, &n, OPAL_STRING))) { + ORTE_ERROR_LOG(rc); + opal_argv_free(tmp); + OBJ_RELEASE(bptr); + goto cleanup; + } + if (NULL == sig) { + /* the nodes in this range have not reported a topology, + * so skip them */ + offset += cnt; + continue; + } + n = 1; + if (ORTE_SUCCESS != (rc = opal_dss.unpack(bptr, &topo, &n, OPAL_HWLOC_TOPO))) { + ORTE_ERROR_LOG(rc); + opal_argv_free(tmp); + OBJ_RELEASE(bptr); + free(sig); + goto cleanup; + } + /* see if we already have this topology - could be an update */ + t2 = NULL; + for (n=0; n < orte_node_topologies->size; n++) { + if (NULL == (t2 = (orte_topology_t*)opal_pointer_array_get_item(orte_node_topologies, n))) { + continue; + } + if (0 == strcmp(t2->sig, sig)) { + /* found a match */ + free(sig); + opal_hwloc_base_free_topology(topo); + sig = NULL; + break; + } + } + if (NULL != sig || NULL == t2) { + /* new topology - record it */ + t2 = OBJ_NEW(orte_topology_t); + t2->sig = sig; + t2->topo = topo; + opal_pointer_array_add(orte_node_topologies, t2); + } + /* point each of the nodes in this range to this topology */ + n=0; + while (n < cnt && (n+offset) < orte_node_pool->size) { + if (NULL == (node = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, n+offset))) { + continue; + } + opal_output_verbose(1, orte_regx_base_framework.framework_output, + "%s ASSIGNING NODE %s WITH TOPO: %s", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), + node->name, t2->sig); + if (NULL == node->topology) { + OBJ_RETAIN(t2); + node->topology = t2; + } + ++n; + } + offset += cnt; + } + OBJ_RELEASE(bptr); + opal_argv_free(tmp); + } cleanup: OPAL_LIST_DESTRUCT(&slts); OPAL_LIST_DESTRUCT(&flgs); return rc; } - -typedef struct { - opal_list_item_t super; - int ctx; - int nprocs; - int cnt; -} orte_nidmap_regex_t; -static void nrcon(orte_nidmap_regex_t *p) -{ - p->ctx = 0; - p->nprocs = -1; - p->cnt = 0; -} -static OBJ_CLASS_INSTANCE(orte_nidmap_regex_t, - opal_list_item_t, - nrcon, NULL); - -/* since not every node is involved in a job, we have to create a - * regex that indicates the ppn for every node, marking those that - * are not involved. Since each daemon knows the entire - * node pool, we simply provide a ppn for every daemon, with a -1 - * to indicate that the node is empty for that job */ -int orte_util_nidmap_generate_ppn(orte_job_t *jdata, char **ppn) +static int generate_ppn(orte_job_t *jdata, char **ppn) { orte_nidmap_regex_t *prng, **actives; opal_list_t *prk; @@ -1305,7 +1178,7 @@ int orte_util_nidmap_generate_ppn(orte_job_t *jdata, char **ppn) return ORTE_SUCCESS; } -int orte_util_nidmap_parse_ppn(orte_job_t *jdata, char *regex) +static int parse_ppn(orte_job_t *jdata, char *regex) { orte_node_t *node; orte_proc_t *proc; @@ -1392,11 +1265,316 @@ int orte_util_nidmap_parse_ppn(orte_job_t *jdata, char *regex) complete: /* reset any node map flags we used so the next job will start clean */ - for (n=0; n < jdata->map->nodes->size; n++) { - if (NULL != (node = (orte_node_t*)opal_pointer_array_get_item(jdata->map->nodes, n))) { - ORTE_FLAG_UNSET(node, ORTE_NODE_FLAG_MAPPED); - } - } + for (n=0; n < jdata->map->nodes->size; n++) { + if (NULL != (node = (orte_node_t*)opal_pointer_array_get_item(jdata->map->nodes, n))) { + ORTE_FLAG_UNSET(node, ORTE_NODE_FLAG_MAPPED); + } + } return rc; } + + +static int regex_parse_node_ranges(char *base, char *ranges, int num_digits, char *suffix, char ***names); +static int regex_parse_node_range(char *base, char *range, int num_digits, char *suffix, char ***names); + +static int extract_node_names(char *regexp, char ***names) +{ + int i, j, k, len, ret; + char *base; + char *orig, *suffix; + bool found_range = false; + bool more_to_come = false; + int num_digits; + + if (NULL == regexp) { + *names = NULL; + return ORTE_SUCCESS; + } + + orig = base = strdup(regexp); + if (NULL == base) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + OPAL_OUTPUT_VERBOSE((1, orte_debug_output, + "%s regex:extract:nodenames: checking nodelist: %s", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), + regexp)); + + do { + /* Find the base */ + len = strlen(base); + for (i = 0; i <= len; ++i) { + if (base[i] == '[') { + /* we found a range. this gets dealt with below */ + base[i] = '\0'; + found_range = true; + break; + } + if (base[i] == ',') { + /* we found a singleton node, and there are more to come */ + base[i] = '\0'; + found_range = false; + more_to_come = true; + break; + } + if (base[i] == '\0') { + /* we found a singleton node */ + found_range = false; + more_to_come = false; + break; + } + } + if (i == 0 && !found_range) { + /* we found a special character at the beginning of the string */ + orte_show_help("help-regex.txt", "regex:special-char", true, regexp); + free(orig); + return ORTE_ERR_BAD_PARAM; + } + + if (found_range) { + /* If we found a range, get the number of digits in the numbers */ + i++; /* step over the [ */ + for (j=i; j < len; j++) { + if (base[j] == ':') { + base[j] = '\0'; + break; + } + } + if (j >= len) { + /* we didn't find the number of digits */ + orte_show_help("help-regex.txt", "regex:num-digits-missing", true, regexp); + free(orig); + return ORTE_ERR_BAD_PARAM; + } + num_digits = strtol(&base[i], NULL, 10); + i = j + 1; /* step over the : */ + /* now find the end of the range */ + for (j = i; j < len; ++j) { + if (base[j] == ']') { + base[j] = '\0'; + break; + } + } + if (j >= len) { + /* we didn't find the end of the range */ + orte_show_help("help-regex.txt", "regex:end-range-missing", true, regexp); + free(orig); + return ORTE_ERR_BAD_PARAM; + } + /* check for a suffix */ + if (j+1 < len && base[j+1] != ',') { + /* find the next comma, if present */ + for (k=j+1; k < len && base[k] != ','; k++); + if (k < len) { + base[k] = '\0'; + } + suffix = strdup(&base[j+1]); + if (k < len) { + base[k] = ','; + } + j = k-1; + } else { + suffix = NULL; + } + OPAL_OUTPUT_VERBOSE((1, orte_debug_output, + "%s regex:extract:nodenames: parsing range %s %s %s", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), + base, base + i, suffix)); + + ret = regex_parse_node_ranges(base, base + i, num_digits, suffix, names); + if (NULL != suffix) { + free(suffix); + } + if (ORTE_SUCCESS != ret) { + orte_show_help("help-regex.txt", "regex:bad-value", true, regexp); + free(orig); + return ret; + } + if (j+1 < len && base[j + 1] == ',') { + more_to_come = true; + base = &base[j + 2]; + } else { + more_to_come = false; + } + } else { + /* If we didn't find a range, just add the node */ + if(ORTE_SUCCESS != (ret = opal_argv_append_nosize(names, base))) { + ORTE_ERROR_LOG(ret); + free(orig); + return ret; + } + /* step over the comma */ + i++; + /* set base equal to the (possible) next base to look at */ + base = &base[i]; + } + } while(more_to_come); + + free(orig); + + /* All done */ + return ret; +} + +/* + * Parse one or more ranges in a set + * + * @param base The base text of the node name + * @param *ranges A pointer to a range. This can contain multiple ranges + * (i.e. "1-3,10" or "5" or "9,0100-0130,250") + * @param ***names An argv array to add the newly discovered nodes to + */ +static int regex_parse_node_ranges(char *base, char *ranges, int num_digits, char *suffix, char ***names) +{ + int i, len, ret; + char *start, *orig; + + /* Look for commas, the separator between ranges */ + + len = strlen(ranges); + for (orig = start = ranges, i = 0; i < len; ++i) { + if (',' == ranges[i]) { + ranges[i] = '\0'; + ret = regex_parse_node_range(base, start, num_digits, suffix, names); + if (ORTE_SUCCESS != ret) { + ORTE_ERROR_LOG(ret); + return ret; + } + start = ranges + i + 1; + } + } + + /* Pick up the last range, if it exists */ + + if (start < orig + len) { + + OPAL_OUTPUT_VERBOSE((1, orte_debug_output, + "%s regex:parse:ranges: parse range %s (2)", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), start)); + + ret = regex_parse_node_range(base, start, num_digits, suffix, names); + if (ORTE_SUCCESS != ret) { + ORTE_ERROR_LOG(ret); + return ret; + } + } + + /* All done */ + return ORTE_SUCCESS; +} + + +/* + * Parse a single range in a set and add the full names of the nodes + * found to the names argv + * + * @param base The base text of the node name + * @param *ranges A pointer to a single range. (i.e. "1-3" or "5") + * @param ***names An argv array to add the newly discovered nodes to + */ +static int regex_parse_node_range(char *base, char *range, int num_digits, char *suffix, char ***names) +{ + char *str, tmp[132]; + size_t i, k, start, end; + size_t base_len, len; + bool found; + int ret; + + if (NULL == base || NULL == range) { + return ORTE_ERROR; + } + + len = strlen(range); + base_len = strlen(base); + /* Silence compiler warnings; start and end are always assigned + properly, below */ + start = end = 0; + + /* Look for the beginning of the first number */ + + for (found = false, i = 0; i < len; ++i) { + if (isdigit((int) range[i])) { + if (!found) { + start = atoi(range + i); + found = true; + break; + } + } + } + if (!found) { + ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND); + return ORTE_ERR_NOT_FOUND; + } + + /* Look for the end of the first number */ + + for (found = false; i < len; ++i) { + if (!isdigit(range[i])) { + break; + } + } + + /* Was there no range, just a single number? */ + + if (i >= len) { + end = start; + found = true; + } else { + /* Nope, there was a range. Look for the beginning of the second + * number + */ + for (; i < len; ++i) { + if (isdigit(range[i])) { + end = strtol(range + i, NULL, 10); + found = true; + break; + } + } + } + if (!found) { + ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND); + return ORTE_ERR_NOT_FOUND; + } + + /* Make strings for all values in the range */ + + len = base_len + num_digits + 32; + if (NULL != suffix) { + len += strlen(suffix); + } + str = (char *) malloc(len); + if (NULL == str) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + for (i = start; i <= end; ++i) { + memset(str, 0, len); + strcpy(str, base); + /* we need to zero-pad the digits */ + for (k=0; k < (size_t)num_digits; k++) { + str[k+base_len] = '0'; + } + memset(tmp, 0, 132); + snprintf(tmp, 132, "%lu", (unsigned long)i); + for (k=0; k < strlen(tmp); k++) { + str[base_len + num_digits - k - 1] = tmp[strlen(tmp)-k-1]; + } + /* if there is a suffix, add it */ + if (NULL != suffix) { + strcat(str, suffix); + } + ret = opal_argv_append_nosize(names, str); + if(ORTE_SUCCESS != ret) { + ORTE_ERROR_LOG(ret); + free(str); + return ret; + } + } + free(str); + + /* All done */ + return ORTE_SUCCESS; +} diff --git a/orte/mca/regx/fwd/regx_fwd.h b/orte/mca/regx/fwd/regx_fwd.h new file mode 100644 index 0000000000..d67fbfbf34 --- /dev/null +++ b/orte/mca/regx/fwd/regx_fwd.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#ifndef _MCA_REGX_FwD_H_ +#define _MCA_REGX_FwD_H_ + +#include "orte_config.h" + +#include "orte/types.h" + +#include "opal/mca/base/base.h" +#include "orte/mca/regx/regx.h" + + +BEGIN_C_DECLS + +ORTE_MODULE_DECLSPEC extern orte_regx_base_component_t mca_regx_fwd_component; +extern orte_regx_base_module_t orte_regx_fwd_module; + +END_C_DECLS + +#endif /* MCA_REGX_FwD_H_ */ + diff --git a/orte/mca/regx/fwd/regx_fwd_component.c b/orte/mca/regx/fwd/regx_fwd_component.c new file mode 100644 index 0000000000..50ad2ed32c --- /dev/null +++ b/orte/mca/regx/fwd/regx_fwd_component.c @@ -0,0 +1,45 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "orte_config.h" +#include "orte/types.h" +#include "opal/types.h" + +#include "opal/util/show_help.h" + +#include "orte/mca/regx/regx.h" +#include "regx_fwd.h" + +static int component_query(mca_base_module_t **module, int *priority); + +/* + * Struct of function pointers and all that to let us be initialized + */ +orte_regx_base_component_t mca_regx_fwd_component = { + .base_version = { + MCA_REGX_BASE_VERSION_1_0_0, + .mca_component_name = "fwd", + MCA_BASE_MAKE_VERSION(component, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION, + ORTE_RELEASE_VERSION), + .mca_query_component = component_query, + }, + .base_data = { + /* The component is checkpoint ready */ + MCA_BASE_METADATA_PARAM_CHECKPOINT + }, +}; + +static int component_query(mca_base_module_t **module, int *priority) +{ + *module = (mca_base_module_t*)&orte_regx_fwd_module; + *priority = 10; + return ORTE_SUCCESS; +} + diff --git a/orte/mca/regx/regx.h b/orte/mca/regx/regx.h new file mode 100644 index 0000000000..592ea6a6ea --- /dev/null +++ b/orte/mca/regx/regx.h @@ -0,0 +1,123 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +/** @file: + * + * The Open RTE Personality Framework (regx) + * + * Multi-select framework so that multiple personalities can be + * simultaneously supported + * + */ + +#ifndef ORTE_MCA_REGX_H +#define ORTE_MCA_REGX_H + +#include "orte_config.h" +#include "orte/types.h" + +#include "opal/class/opal_pointer_array.h" +#include "opal/dss/dss_types.h" +#include "orte/mca/mca.h" + +#include "orte/runtime/orte_globals.h" + + +BEGIN_C_DECLS + +/* + * regx module functions + */ + +#define ORTE_MAX_NODE_PREFIX 50 +#define ORTE_CONTIG_NODE_CMD 0x01 +#define ORTE_NON_CONTIG_NODE_CMD 0x02 + +/** +* REGX module functions - the modules are accessed via +* the base stub functions +*/ +typedef struct { + opal_list_item_t super; + int ctx; + int nprocs; + int cnt; +} orte_nidmap_regex_t; +ORTE_DECLSPEC OBJ_CLASS_DECLARATION(orte_nidmap_regex_t); + +/* initialize the module - allow it to do whatever one-time + * things it requires */ +typedef int (*orte_regx_base_module_init_fn_t)(void); + +typedef int (*orte_regx_base_module_nidmap_create_fn_t)(opal_pointer_array_t *pool, char **regex); +typedef int (*orte_regx_base_module_nidmap_parse_fn_t)(char *regex); + +/* create a regular expression describing the nodes in the + * allocation */ +typedef int (*orte_regx_base_module_encode_nodemap_fn_t)(opal_buffer_t *buffer); + +/* decode a regular expression created by the encode function + * into the orte_node_pool array */ +typedef int (*orte_regx_base_module_decode_daemon_nodemap_fn_t)(opal_buffer_t *buffer); + +typedef int (*orte_regx_base_module_build_daemon_nidmap_fn_t)(void); + +/* create a regular expression describing the ppn for a job */ +typedef int (*orte_regx_base_module_generate_ppn_fn_t)(orte_job_t *jdata, char **ppn); + +/* decode the ppn */ +typedef int (*orte_regx_base_module_parse_ppn_fn_t)(orte_job_t *jdata, char *ppn); + + +/* give the component a chance to cleanup */ +typedef void (*orte_regx_base_module_finalize_fn_t)(void); + +/* + * regx module version 1.0.0 + */ +typedef struct { + orte_regx_base_module_init_fn_t init; + orte_regx_base_module_nidmap_create_fn_t nidmap_create; + orte_regx_base_module_nidmap_parse_fn_t nidmap_parse; + orte_regx_base_module_encode_nodemap_fn_t encode_nodemap; + orte_regx_base_module_decode_daemon_nodemap_fn_t decode_daemon_nodemap; + orte_regx_base_module_build_daemon_nidmap_fn_t build_daemon_nidmap; + orte_regx_base_module_generate_ppn_fn_t generate_ppn; + orte_regx_base_module_parse_ppn_fn_t parse_ppn; + orte_regx_base_module_finalize_fn_t finalize; +} orte_regx_base_module_t; + +ORTE_DECLSPEC extern orte_regx_base_module_t orte_regx; + +/* + * regx component + */ + +/** + * regx component version 1.0.0 + */ +typedef struct { + /** Base MCA structure */ + mca_base_component_t base_version; + /** Base MCA data */ + mca_base_component_data_t base_data; +} orte_regx_base_component_t; + +/** + * Macro for use in components that are of type regx + */ +#define MCA_REGX_BASE_VERSION_1_0_0 \ + ORTE_MCA_BASE_VERSION_2_1_0("regx", 1, 0, 0) + + +END_C_DECLS + +#endif diff --git a/orte/mca/regx/reverse/Makefile.am b/orte/mca/regx/reverse/Makefile.am new file mode 100644 index 0000000000..b09394a357 --- /dev/null +++ b/orte/mca/regx/reverse/Makefile.am @@ -0,0 +1,37 @@ +# +# Copyright (c) 2016-2018 Intel, Inc. All rights reserved. +# Copyright (c) 2017 IBM Corporation. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +sources = \ + regx_reverse_component.c \ + regx_reverse.h \ + regx_reverse.c + +# Make the output library in this directory, and name it either +# mca__.la (for DSO builds) or libmca__.la +# (for static builds). + +if MCA_BUILD_orte_regx_reverse_DSO +component_noinst = +component_install = mca_regx_reverse.la +else +component_noinst = libmca_regx_reverse.la +component_install = +endif + +mcacomponentdir = $(ortelibdir) +mcacomponent_LTLIBRARIES = $(component_install) +mca_regx_reverse_la_SOURCES = $(sources) +mca_regx_reverse_la_LDFLAGS = -module -avoid-version +mca_regx_reverse_la_LIBADD = $(top_builddir)/orte/lib@ORTE_LIB_PREFIX@open-rte.la + +noinst_LTLIBRARIES = $(component_noinst) +libmca_regx_reverse_la_SOURCES = $(sources) +libmca_regx_reverse_la_LDFLAGS = -module -avoid-version + diff --git a/orte/mca/regx/reverse/owner.txt b/orte/mca/regx/reverse/owner.txt new file mode 100644 index 0000000000..2fd247dddb --- /dev/null +++ b/orte/mca/regx/reverse/owner.txt @@ -0,0 +1,7 @@ +# +# owner/status file +# owner: institution that is responsible for this package +# status: e.g. active, maintenance, unmaintained +# +owner: IBM +status: active diff --git a/orte/mca/regx/reverse/regx_reverse.c b/orte/mca/regx/reverse/regx_reverse.c new file mode 100644 index 0000000000..1a8b5f2199 --- /dev/null +++ b/orte/mca/regx/reverse/regx_reverse.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + */ + +#include "orte_config.h" +#include "orte/types.h" +#include "opal/types.h" + +#ifdef HAVE_UNISTD_H +#include +#endif +#include + +#include "opal/util/argv.h" +#include "opal/util/basename.h" +#include "opal/util/opal_environ.h" + +#include "orte/runtime/orte_globals.h" +#include "orte/util/name_fns.h" +#include "orte/mca/regx/base/base.h" + +#include "regx_reverse.h" + +static int nidmap_create(opal_pointer_array_t *pool, char **regex); +static int nidmap_parse(char *regex); +static int encode_nodemap(opal_buffer_t *buffer); +static int decode_daemon_nodemap(opal_buffer_t *buffer); +static int generate_ppn(orte_job_t *jdata, char **ppn); +static int parse_ppn(orte_job_t *jdata, char *ppn); + +orte_regx_base_module_t orte_regx_reverse_module = { + .nidmap_create = nidmap_create, + .nidmap_parse = nidmap_parse, + .encode_nodemap = encode_nodemap, + .decode_daemon_nodemap = decode_daemon_nodemap, + .generate_ppn = generate_ppn, + .parse_ppn = parse_ppn +}; + +static int nidmap_create(opal_pointer_array_t *pool, char **regex) +{ + return ORTE_ERR_NOT_IMPLEMENTED; +} + +static int nidmap_parse(char *regex) +{ + return ORTE_ERR_NOT_IMPLEMENTED; +} + +static int encode_nodemap(opal_buffer_t *buffer) +{ + return ORTE_ERR_NOT_IMPLEMENTED; +} + +static int decode_daemon_nodemap(opal_buffer_t *buffer) +{ + return ORTE_ERR_NOT_IMPLEMENTED; +} + +static int generate_ppn(orte_job_t *jdata, char **ppn) +{ + return ORTE_ERR_NOT_IMPLEMENTED; +} + +static int parse_ppn(orte_job_t *jdata, char *ppn) +{ + return ORTE_ERR_NOT_IMPLEMENTED; +} diff --git a/orte/mca/regx/reverse/regx_reverse.h b/orte/mca/regx/reverse/regx_reverse.h new file mode 100644 index 0000000000..de86c90474 --- /dev/null +++ b/orte/mca/regx/reverse/regx_reverse.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#ifndef _MCA_REGX_REVERSE_H_ +#define _MCA_REGX_REVERSE_H_ + +#include "orte_config.h" + +#include "orte/types.h" + +#include "opal/mca/base/base.h" +#include "orte/mca/regx/regx.h" + + +BEGIN_C_DECLS + +ORTE_MODULE_DECLSPEC extern orte_regx_base_component_t mca_regx_reverse_component; +extern orte_regx_base_module_t orte_regx_reverse_module; + +END_C_DECLS + +#endif /* MCA_REGX_ORTE_H_ */ + diff --git a/orte/mca/regx/reverse/regx_reverse_component.c b/orte/mca/regx/reverse/regx_reverse_component.c new file mode 100644 index 0000000000..aee446211d --- /dev/null +++ b/orte/mca/regx/reverse/regx_reverse_component.c @@ -0,0 +1,45 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "orte_config.h" +#include "orte/types.h" +#include "opal/types.h" + +#include "opal/util/show_help.h" + +#include "orte/mca/regx/regx.h" +#include "regx_reverse.h" + +static int component_query(mca_base_module_t **module, int *priority); + +/* + * Struct of function pointers and all that to let us be initialized + */ +orte_regx_base_component_t mca_regx_reverse_component = { + .base_version = { + MCA_REGX_BASE_VERSION_1_0_0, + .mca_component_name = "reverse", + MCA_BASE_MAKE_VERSION(component, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION, + ORTE_RELEASE_VERSION), + .mca_query_component = component_query, + }, + .base_data = { + /* The component is checkpoint ready */ + MCA_BASE_METADATA_PARAM_CHECKPOINT + }, +}; + +static int component_query(mca_base_module_t **module, int *priority) +{ + *module = (mca_base_module_t*)&orte_regx_reverse_module; + *priority = 1; + return ORTE_SUCCESS; +} + diff --git a/orte/mca/routed/binomial/routed_binomial.c b/orte/mca/routed/binomial/routed_binomial.c index 7762d01f2a..7f4514a27a 100644 --- a/orte/mca/routed/binomial/routed_binomial.c +++ b/orte/mca/routed/binomial/routed_binomial.c @@ -5,7 +5,7 @@ * Copyright (c) 2007-2012 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2013-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,7 +29,6 @@ #include "orte/mca/rml/rml.h" #include "orte/mca/rml/rml_types.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" #include "orte/runtime/orte_globals.h" #include "orte/runtime/orte_wait.h" #include "orte/runtime/runtime.h" diff --git a/orte/mca/state/dvm/state_dvm.c b/orte/mca/state/dvm/state_dvm.c index 06dfe88470..98ef551d3c 100644 --- a/orte/mca/state/dvm/state_dvm.c +++ b/orte/mca/state/dvm/state_dvm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -25,11 +25,11 @@ #include "orte/mca/odls/odls_types.h" #include "orte/mca/plm/base/base.h" #include "orte/mca/ras/base/base.h" +#include "orte/mca/regx/regx.h" #include "orte/mca/rmaps/base/base.h" #include "orte/mca/rml/rml.h" #include "orte/mca/rml/base/rml_contact.h" #include "orte/mca/routed/routed.h" -#include "orte/util/nidmap.h" #include "orte/util/session_dir.h" #include "orte/util/threads.h" #include "orte/runtime/orte_quit.h" @@ -265,7 +265,7 @@ static void vm_ready(int fd, short args, void *cbdata) /* if we couldn't provide the allocation regex on the orted * cmd line, then we need to provide all the info here */ if (!orte_nidmap_communicated) { - if (ORTE_SUCCESS != (rc = orte_util_nidmap_create(orte_node_pool, &nidmap))) { + if (ORTE_SUCCESS != (rc = orte_regx.nidmap_create(orte_node_pool, &nidmap))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(buf); return; @@ -282,7 +282,7 @@ static void vm_ready(int fd, short args, void *cbdata) if (!orte_node_info_communicated) { flag = 1; opal_dss.pack(buf, &flag, 1, OPAL_INT8); - if (ORTE_SUCCESS != (rc = orte_util_encode_nodemap(buf))) { + if (ORTE_SUCCESS != (rc = orte_regx.encode_nodemap(buf))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(buf); return; diff --git a/orte/orted/orted_comm.c b/orte/orted/orted_comm.c index 7d18e1ad92..ad8f85cb76 100644 --- a/orte/orted/orted_comm.c +++ b/orte/orted/orted_comm.c @@ -14,7 +14,7 @@ * reserved. * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2016-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -58,7 +58,6 @@ #include "orte/util/proc_info.h" #include "orte/util/session_dir.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" #include "orte/util/compress.h" #include "orte/mca/errmgr/errmgr.h" diff --git a/orte/orted/orted_main.c b/orte/orted/orted_main.c index c465f327cc..167006e4ff 100644 --- a/orte/orted/orted_main.c +++ b/orte/orted/orted_main.c @@ -16,7 +16,7 @@ * Copyright (c) 2009 Institut National de Recherche en Informatique * et Automatique. All rights reserved. * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -72,7 +72,6 @@ #include "orte/util/proc_info.h" #include "orte/util/session_dir.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" #include "orte/util/parse_options.h" #include "orte/mca/rml/base/rml_contact.h" #include "orte/util/pre_condition_transports.h" @@ -83,6 +82,7 @@ #include "orte/mca/ess/ess.h" #include "orte/mca/grpcomm/grpcomm.h" #include "orte/mca/grpcomm/base/base.h" +#include "orte/mca/regx/regx.h" #include "orte/mca/rml/rml.h" #include "orte/mca/rml/rml_types.h" #include "orte/mca/odls/odls.h" @@ -1147,7 +1147,7 @@ static void node_regex_report(int status, orte_process_name_t* sender, } orte_node_regex = regex; - if (ORTE_SUCCESS != (rc = orte_util_nidmap_parse(orte_node_regex))) { + if (ORTE_SUCCESS != (rc = orte_regx.nidmap_parse(orte_node_regex))) { ORTE_ERROR_LOG(rc); return; } diff --git a/orte/runtime/orte_init.c b/orte/runtime/orte_init.c index 827c268230..04dec8c418 100644 --- a/orte/runtime/orte_init.c +++ b/orte/runtime/orte_init.c @@ -13,7 +13,7 @@ * reserved. * Copyright (c) 2007-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007-2008 Sun Microsystems, Inc. All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014-2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. * @@ -48,7 +48,6 @@ #include "orte/mca/schizo/base/base.h" #include "orte/util/listener.h" #include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" #include "orte/util/proc_info.h" #include "orte/util/error_strings.h" #include "orte/orted/pmix/pmix_server.h" @@ -217,7 +216,6 @@ int orte_init(int* pargc, char*** pargv, orte_proc_type_t flags) if (ORTE_PROC_IS_DAEMON || ORTE_PROC_IS_HNP) { /* let the pmix server register params */ pmix_server_register_params(); - orte_util_nidmap_init(); OPAL_TIMING_ENV_NEXT(tmng, "pmix_server_register_params"); } diff --git a/orte/util/Makefile.am b/orte/util/Makefile.am index 9ef926a6ce..d54503b3bb 100644 --- a/orte/util/Makefile.am +++ b/orte/util/Makefile.am @@ -11,7 +11,7 @@ # All rights reserved. # Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved. # Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. -# Copyright (c) 2014-2017 Intel, Inc. All rights reserved. +# Copyright (c) 2014-2018 Intel, Inc. All rights reserved. # Copyright (c) 2016 Research Organization for Information Science # and Technology (RIST). All rights reserved. # $COPYRIGHT$ @@ -56,8 +56,6 @@ headers += \ util/hostfile/hostfile_lex.h \ util/dash_host/dash_host.h \ util/comm/comm.h \ - util/nidmap.h \ - util/regex.h \ util/attr.h \ util/listener.h \ util/compress.h \ @@ -77,8 +75,6 @@ lib@ORTE_LIB_PREFIX@open_rte_la_SOURCES += \ util/hostfile/hostfile.c \ util/dash_host/dash_host.c \ util/comm/comm.c \ - util/nidmap.c \ - util/regex.c \ util/attr.c \ util/listener.c \ util/compress.c diff --git a/orte/util/nidmap.h b/orte/util/nidmap.h deleted file mode 100644 index 3be3f71dbf..0000000000 --- a/orte/util/nidmap.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2004-2008 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) 2014-2017 Intel, Inc. All rights reserved. - * Copyright (c) 2017 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -/** @file: - * - * Populates global structure with system-specific information. - * - * Notes: add limits.h, compute size of integer and other types via sizeof(type)*CHAR_BIT - * - */ - -#ifndef _ORTE_NIDMAP_H_ -#define _ORTE_NIDMAP_H_ - -#include "orte_config.h" -#include "orte/types.h" - -#include "opal/dss/dss_types.h" - -#include "orte/runtime/orte_globals.h" - -BEGIN_C_DECLS - -#define ORTE_MAX_NODE_PREFIX 50 -#define ORTE_CONTIG_NODE_CMD 0x01 -#define ORTE_NON_CONTIG_NODE_CMD 0x02 - - -ORTE_DECLSPEC void orte_util_nidmap_init(void); - -ORTE_DECLSPEC int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex); -ORTE_DECLSPEC int orte_util_nidmap_parse(char *regex); - -/* create a regular expression describing the nodes in the - * allocation */ -ORTE_DECLSPEC int orte_util_encode_nodemap(opal_buffer_t *buffer); - -/* decode a regular expression created by the encode function - * into the orte_node_pool array */ -ORTE_DECLSPEC int orte_util_decode_daemon_nodemap(opal_buffer_t *buffer); - -ORTE_DECLSPEC int orte_util_build_daemon_nidmap(void); - -/* create a regular expression describing the ppn for a job */ -ORTE_DECLSPEC int orte_util_nidmap_generate_ppn(orte_job_t *jdata, char **ppn); - -/* decode the ppn */ -ORTE_DECLSPEC int orte_util_nidmap_parse_ppn(orte_job_t *jdata, char *ppn); - -END_C_DECLS - -#endif diff --git a/orte/util/regex.c b/orte/util/regex.c deleted file mode 100644 index f59ed0000f..0000000000 --- a/orte/util/regex.c +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright (c) 2004-2005 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) 2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2017 Intel, Inc. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ -#include "orte_config.h" -#include "orte/types.h" -#include "orte/constants.h" - -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_IFADDRS_H -#include -#endif - -#include "opal/util/argv.h" - -#include "orte/mca/errmgr/errmgr.h" -#include "orte/mca/odls/odls_types.h" -#include "orte/mca/rml/base/rml_contact.h" -#include "orte/mca/rmaps/rmaps_types.h" -#include "orte/util/show_help.h" -#include "orte/util/name_fns.h" -#include "orte/util/nidmap.h" -#include "orte/runtime/orte_globals.h" -#include "orte/mca/ess/ess.h" - -#include "orte/util/regex.h" - -#define ORTE_MAX_NODE_PREFIX 50 - -static int regex_parse_node_ranges(char *base, char *ranges, int num_digits, char *suffix, char ***names); -static int regex_parse_node_range(char *base, char *range, int num_digits, char *suffix, char ***names); - -int orte_regex_extract_node_names(char *regexp, char ***names) -{ - int i, j, k, len, ret; - char *base; - char *orig, *suffix; - bool found_range = false; - bool more_to_come = false; - int num_digits; - - if (NULL == regexp) { - *names = NULL; - return ORTE_SUCCESS; - } - - orig = base = strdup(regexp); - if (NULL == base) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - - OPAL_OUTPUT_VERBOSE((1, orte_debug_output, - "%s regex:extract:nodenames: checking nodelist: %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), - regexp)); - - do { - /* Find the base */ - len = strlen(base); - for (i = 0; i <= len; ++i) { - if (base[i] == '[') { - /* we found a range. this gets dealt with below */ - base[i] = '\0'; - found_range = true; - break; - } - if (base[i] == ',') { - /* we found a singleton node, and there are more to come */ - base[i] = '\0'; - found_range = false; - more_to_come = true; - break; - } - if (base[i] == '\0') { - /* we found a singleton node */ - found_range = false; - more_to_come = false; - break; - } - } - if (i == 0 && !found_range) { - /* we found a special character at the beginning of the string */ - orte_show_help("help-regex.txt", "regex:special-char", true, regexp); - free(orig); - return ORTE_ERR_BAD_PARAM; - } - - if (found_range) { - /* If we found a range, get the number of digits in the numbers */ - i++; /* step over the [ */ - for (j=i; j < len; j++) { - if (base[j] == ':') { - base[j] = '\0'; - break; - } - } - if (j >= len) { - /* we didn't find the number of digits */ - orte_show_help("help-regex.txt", "regex:num-digits-missing", true, regexp); - free(orig); - return ORTE_ERR_BAD_PARAM; - } - num_digits = strtol(&base[i], NULL, 10); - i = j + 1; /* step over the : */ - /* now find the end of the range */ - for (j = i; j < len; ++j) { - if (base[j] == ']') { - base[j] = '\0'; - break; - } - } - if (j >= len) { - /* we didn't find the end of the range */ - orte_show_help("help-regex.txt", "regex:end-range-missing", true, regexp); - free(orig); - return ORTE_ERR_BAD_PARAM; - } - /* check for a suffix */ - if (j+1 < len && base[j+1] != ',') { - /* find the next comma, if present */ - for (k=j+1; k < len && base[k] != ','; k++); - if (k < len) { - base[k] = '\0'; - } - suffix = strdup(&base[j+1]); - if (k < len) { - base[k] = ','; - } - j = k-1; - } else { - suffix = NULL; - } - OPAL_OUTPUT_VERBOSE((1, orte_debug_output, - "%s regex:extract:nodenames: parsing range %s %s %s", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), - base, base + i, suffix)); - - ret = regex_parse_node_ranges(base, base + i, num_digits, suffix, names); - if (NULL != suffix) { - free(suffix); - } - if (ORTE_SUCCESS != ret) { - orte_show_help("help-regex.txt", "regex:bad-value", true, regexp); - free(orig); - return ret; - } - if (j+1 < len && base[j + 1] == ',') { - more_to_come = true; - base = &base[j + 2]; - } else { - more_to_come = false; - } - } else { - /* If we didn't find a range, just add the node */ - if(ORTE_SUCCESS != (ret = opal_argv_append_nosize(names, base))) { - ORTE_ERROR_LOG(ret); - free(orig); - return ret; - } - /* step over the comma */ - i++; - /* set base equal to the (possible) next base to look at */ - base = &base[i]; - } - } while(more_to_come); - - free(orig); - - /* All done */ - return ret; -} - -/* - * Parse one or more ranges in a set - * - * @param base The base text of the node name - * @param *ranges A pointer to a range. This can contain multiple ranges - * (i.e. "1-3,10" or "5" or "9,0100-0130,250") - * @param ***names An argv array to add the newly discovered nodes to - */ -static int regex_parse_node_ranges(char *base, char *ranges, int num_digits, char *suffix, char ***names) -{ - int i, len, ret; - char *start, *orig; - - /* Look for commas, the separator between ranges */ - - len = strlen(ranges); - for (orig = start = ranges, i = 0; i < len; ++i) { - if (',' == ranges[i]) { - ranges[i] = '\0'; - ret = regex_parse_node_range(base, start, num_digits, suffix, names); - if (ORTE_SUCCESS != ret) { - ORTE_ERROR_LOG(ret); - return ret; - } - start = ranges + i + 1; - } - } - - /* Pick up the last range, if it exists */ - - if (start < orig + len) { - - OPAL_OUTPUT_VERBOSE((1, orte_debug_output, - "%s regex:parse:ranges: parse range %s (2)", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), start)); - - ret = regex_parse_node_range(base, start, num_digits, suffix, names); - if (ORTE_SUCCESS != ret) { - ORTE_ERROR_LOG(ret); - return ret; - } - } - - /* All done */ - return ORTE_SUCCESS; -} - - -/* - * Parse a single range in a set and add the full names of the nodes - * found to the names argv - * - * @param base The base text of the node name - * @param *ranges A pointer to a single range. (i.e. "1-3" or "5") - * @param ***names An argv array to add the newly discovered nodes to - */ -static int regex_parse_node_range(char *base, char *range, int num_digits, char *suffix, char ***names) -{ - char *str, tmp[132]; - size_t i, k, start, end; - size_t base_len, len; - bool found; - int ret; - - if (NULL == base || NULL == range) { - return ORTE_ERROR; - } - - len = strlen(range); - base_len = strlen(base); - /* Silence compiler warnings; start and end are always assigned - properly, below */ - start = end = 0; - - /* Look for the beginning of the first number */ - - for (found = false, i = 0; i < len; ++i) { - if (isdigit((int) range[i])) { - if (!found) { - start = atoi(range + i); - found = true; - break; - } - } - } - if (!found) { - ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND); - return ORTE_ERR_NOT_FOUND; - } - - /* Look for the end of the first number */ - - for (found = false; i < len; ++i) { - if (!isdigit(range[i])) { - break; - } - } - - /* Was there no range, just a single number? */ - - if (i >= len) { - end = start; - found = true; - } else { - /* Nope, there was a range. Look for the beginning of the second - * number - */ - for (; i < len; ++i) { - if (isdigit(range[i])) { - end = strtol(range + i, NULL, 10); - found = true; - break; - } - } - } - if (!found) { - ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND); - return ORTE_ERR_NOT_FOUND; - } - - /* Make strings for all values in the range */ - - len = base_len + num_digits + 32; - if (NULL != suffix) { - len += strlen(suffix); - } - str = (char *) malloc(len); - if (NULL == str) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - for (i = start; i <= end; ++i) { - memset(str, 0, len); - strcpy(str, base); - /* we need to zero-pad the digits */ - for (k=0; k < (size_t)num_digits; k++) { - str[k+base_len] = '0'; - } - memset(tmp, 0, 132); - snprintf(tmp, 132, "%lu", (unsigned long)i); - for (k=0; k < strlen(tmp); k++) { - str[base_len + num_digits - k - 1] = tmp[strlen(tmp)-k-1]; - } - /* if there is a suffix, add it */ - if (NULL != suffix) { - strcat(str, suffix); - } - ret = opal_argv_append_nosize(names, str); - if(ORTE_SUCCESS != ret) { - ORTE_ERROR_LOG(ret); - free(str); - return ret; - } - } - free(str); - - /* All done */ - return ORTE_SUCCESS; -} - -/***** CLASS INSTANTIATIONS ****/ - -static void range_construct(orte_regex_range_t *ptr) -{ - ptr->vpid = 0; - ptr->cnt = 0; -} -OBJ_CLASS_INSTANCE(orte_regex_range_t, - opal_list_item_t, - range_construct, NULL); - -static void orte_regex_node_construct(orte_regex_node_t *ptr) -{ - ptr->prefix = NULL; - ptr->suffix = NULL; - ptr->num_digits = 0; - OBJ_CONSTRUCT(&ptr->ranges, opal_list_t); -} -static void orte_regex_node_destruct(orte_regex_node_t *ptr) -{ - opal_list_item_t *item; - - if (NULL != ptr->prefix) { - free(ptr->prefix); - } - if (NULL != ptr->suffix) { - free(ptr->suffix); - } - - while (NULL != (item = opal_list_remove_first(&ptr->ranges))) { - OBJ_RELEASE(item); - } - OBJ_DESTRUCT(&ptr->ranges); -} -OBJ_CLASS_INSTANCE(orte_regex_node_t, - opal_list_item_t, - orte_regex_node_construct, - orte_regex_node_destruct); diff --git a/orte/util/regex.h b/orte/util/regex.h deleted file mode 100644 index b58cacb807..0000000000 --- a/orte/util/regex.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2006 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) 2017 Intel, Inc. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -/** @file: - * - */ - -#ifndef _ORTE_REGEX_H_ -#define _ORTE_REGEX_H_ - -#include "orte_config.h" - -#include "opal/class/opal_value_array.h" -#include "opal/class/opal_list.h" - -#include "orte/mca/odls/odls_types.h" -#include "orte/runtime/orte_globals.h" - -BEGIN_C_DECLS - -typedef struct { - opal_list_item_t super; - int vpid; - int cnt; - int slots; - orte_topology_t *t; -} orte_regex_range_t; -ORTE_DECLSPEC OBJ_CLASS_DECLARATION(orte_regex_range_t); - -typedef struct { - /* list object */ - opal_list_item_t super; - char *prefix; - char *suffix; - int num_digits; - opal_list_t ranges; -} orte_regex_node_t; -ORTE_DECLSPEC OBJ_CLASS_DECLARATION(orte_regex_node_t); - -ORTE_DECLSPEC int orte_regex_extract_node_names(char *regexp, char ***names); - -END_C_DECLS -#endif