From 12fc2347cba38b86bbc63dda89b0f86d4c45622f Mon Sep 17 00:00:00 2001 From: Vladimir Kolodiev Date: Fri, 14 Apr 2017 14:29:46 +0300 Subject: [PATCH 1/5] Added SLURM bootstrap support --- src/pm/hydra/configure.ac | 2 +- src/pm/hydra/libhydra/bstrap/Makefile.mk | 1 + .../hydra/libhydra/bstrap/slurm/Makefile.mk | 14 ++++ .../bstrap/slurm/hydra_bstrap_slurm.h | 11 +++ .../libhydra/bstrap/slurm/slurm_finalize.c | 19 +++++ .../libhydra/bstrap/slurm/slurm_launch.c | 73 +++++++++++++++++++ 6 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 src/pm/hydra/libhydra/bstrap/slurm/Makefile.mk create mode 100644 src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h create mode 100644 src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c create mode 100644 src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c diff --git a/src/pm/hydra/configure.ac b/src/pm/hydra/configure.ac index f0a65c8c16e..489e9a75ba1 100644 --- a/src/pm/hydra/configure.ac +++ b/src/pm/hydra/configure.ac @@ -291,7 +291,7 @@ AC_ARG_WITH(hydra-bstrap, [AC_HELP_STRING([--with-hydra-bstrap=name], [Bstrap Server (ssh,rsh,slurm,ll,lsf,sge,pbs)])], [ hydra_bstrap=$withval ], - [ hydra_bstrap="ssh" ]) + [ hydra_bstrap="ssh,slurm" ]) AC_MSG_CHECKING(bstrap server) AC_MSG_RESULT($hydra_bstrap) hydra_bstrap_list="`echo $hydra_bstrap | sed -e 's/:/ /g' -e 's/,/ /g'`" diff --git a/src/pm/hydra/libhydra/bstrap/Makefile.mk b/src/pm/hydra/libhydra/bstrap/Makefile.mk index 7a2a8187e2d..1a500b98178 100644 --- a/src/pm/hydra/libhydra/bstrap/Makefile.mk +++ b/src/pm/hydra/libhydra/bstrap/Makefile.mk @@ -6,3 +6,4 @@ include libhydra/bstrap/src/Makefile.mk include libhydra/bstrap/ssh/Makefile.mk +include libhydra/bstrap/slurm/Makefile.mk diff --git a/src/pm/hydra/libhydra/bstrap/slurm/Makefile.mk b/src/pm/hydra/libhydra/bstrap/slurm/Makefile.mk new file mode 100644 index 00000000000..68b8265e058 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/slurm/Makefile.mk @@ -0,0 +1,14 @@ +## -*- Mode: Makefile; -*- +## +## (C) 2017 by Argonne National Laboratory. +## See COPYRIGHT in top-level directory. +## + +AM_CPPFLAGS += -I$(top_srcdir)/libhydra/bstrap/slurm + +noinst_HEADERS += \ + libhydra/bstrap/slurm/hydra_bstrap_slurm.h + +libhydra_la_SOURCES += \ + libhydra/bstrap/slurm/slurm_launch.c \ + libhydra/bstrap/slurm/slurm_finalize.c diff --git a/src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h b/src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h new file mode 100644 index 00000000000..d005082e6ed --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h @@ -0,0 +1,11 @@ +#ifndef HYDRA_BSTRAP_SLURM_H_INCLUDED +#define HYDRA_BSTRAP_SKURM_H_INCLUDED + +#include "hydra_base.h" + +HYD_status HYDI_bstrap_slurm_launch(const char *hostname, const char *launch_exec, char **args, + int *fd_stdin, int *fd_stdout, int *fd_stderr, int *pid, + int debug); +HYD_status HYDI_bstrap_slurm_finalize(void); + +#endif /* HYDRA_BSTRAP_SSH_H_INCLUDED */ diff --git a/src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c b/src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c new file mode 100644 index 00000000000..7a7dd5cbf5a --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c @@ -0,0 +1,19 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ + +#include "hydra_bstrap_slurm.h" +#include "hydra_err.h" + +HYD_status HYDI_bstrap_slurm_finalize(void) +{ + HYD_status status = HYD_SUCCESS; + + fn_exit: + return status; + + fn_fail: + goto fn_exit; +} diff --git a/src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c b/src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c new file mode 100644 index 00000000000..d1c90c7f616 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c @@ -0,0 +1,73 @@ +#include "hydra_bstrap_slurm.h" +#include "hydra_str.h" +#include "hydra_err.h" +#include "hydra_fs.h" +#include "hydra_spawn.h" + + +HYD_status HYDI_bstrap_slurm_launch(const char *hostname, const char *launch_exec, char **args, + int *fd_stdin, int *fd_stdout, int *fd_stderr, int *pid, + int debug) +{ + char *targs[HYD_NUM_TMP_STRINGS] = { NULL }; + int idx, i; + char *lexec = NULL; + HYD_status status = HYD_SUCCESS; + + HYD_FUNC_ENTER(); + + /* We use the following priority order for the executable path: + * (1) user-specified; (2) search in path; (3) Hard-coded + * location */ + if (launch_exec) + lexec = MPL_strdup(launch_exec); + if (lexec == NULL) + lexec = HYD_find_full_path("srun"); + if (lexec == NULL) + lexec = MPL_strdup("/usr/bin/srun"); + HYD_ASSERT(lexec, status); + + idx = 0; + targs[idx++] = MPL_strdup(lexec); + + targs[idx++] = MPL_strdup("-N"); + targs[idx++] = MPL_strdup("1"); + + targs[idx++] = MPL_strdup("-n"); + targs[idx++] = MPL_strdup("1"); + + targs[idx++] = MPL_strdup("--nodelist"); + targs[idx++] = MPL_strdup(hostname); + + /* Force srun to ignore stdin to avoid issues with + * unexpected files open on fd 0 */ + targs[idx++] = MPL_strdup("--input"); + targs[idx++] = MPL_strdup("none"); + + /* Fill in the remaining arguments */ + /* We do not need to create a quoted version of the string for + * SLURM. It seems to be internally quoting it anyway. */ + for (i = 0; args[i]; i++) + targs[idx++] = MPL_strdup(args[i]); + + if (debug) { + HYD_PRINT(stdout, "Launch arguments: "); + HYD_str_print_list(targs); + } + + + status = HYD_spawn(targs, NULL, fd_stdin, fd_stdout, fd_stderr, pid, -1); + HYD_ERR_POP(status, "create process returned error\n"); + + fn_exit: + HYD_str_free_list(targs); + if (lexec) + MPL_free(lexec); + HYD_FUNC_EXIT(); + return status; + +fn_fail: + goto fn_exit; +} + + From e0629b3cd4c0eacc1180d8c8696876f348f27401 Mon Sep 17 00:00:00 2001 From: Vladimir Kolodiev Date: Fri, 14 Apr 2017 17:06:18 +0300 Subject: [PATCH 2/5] Fixed typoes --- src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h | 4 ++-- src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h b/src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h index d005082e6ed..18c1f592b7d 100644 --- a/src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h +++ b/src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h @@ -1,5 +1,5 @@ #ifndef HYDRA_BSTRAP_SLURM_H_INCLUDED -#define HYDRA_BSTRAP_SKURM_H_INCLUDED +#define HYDRA_BSTRAP_SLURM_H_INCLUDED #include "hydra_base.h" @@ -8,4 +8,4 @@ HYD_status HYDI_bstrap_slurm_launch(const char *hostname, const char *launch_exe int debug); HYD_status HYDI_bstrap_slurm_finalize(void); -#endif /* HYDRA_BSTRAP_SSH_H_INCLUDED */ +#endif /* HYDRA_BSTRAP_SLURM_H_INCLUDED */ diff --git a/src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c b/src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c index 7a7dd5cbf5a..e08e42dd82c 100644 --- a/src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c +++ b/src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c @@ -1,9 +1,3 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ -/* - * (C) 2010 by Argonne National Laboratory. - * See COPYRIGHT in top-level directory. - */ - #include "hydra_bstrap_slurm.h" #include "hydra_err.h" From e869b47bf38c6534cd2f0fc4b4c27bc1a85db73b Mon Sep 17 00:00:00 2001 From: Vladimir Kolodiev Date: Fri, 14 Apr 2017 17:30:15 +0300 Subject: [PATCH 3/5] Added copyright --- src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h | 5 +++++ src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c | 5 +++++ src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h b/src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h index 18c1f592b7d..25a48af4e4c 100644 --- a/src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h +++ b/src/pm/hydra/libhydra/bstrap/slurm/hydra_bstrap_slurm.h @@ -1,3 +1,8 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ #ifndef HYDRA_BSTRAP_SLURM_H_INCLUDED #define HYDRA_BSTRAP_SLURM_H_INCLUDED diff --git a/src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c b/src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c index e08e42dd82c..af98fa40601 100644 --- a/src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c +++ b/src/pm/hydra/libhydra/bstrap/slurm/slurm_finalize.c @@ -1,3 +1,8 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ #include "hydra_bstrap_slurm.h" #include "hydra_err.h" diff --git a/src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c b/src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c index d1c90c7f616..f7d2c4e43a1 100644 --- a/src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c +++ b/src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c @@ -1,3 +1,8 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ #include "hydra_bstrap_slurm.h" #include "hydra_str.h" #include "hydra_err.h" From 9430e31362b50cfd7f8e7bda4a17aea2452b85e2 Mon Sep 17 00:00:00 2001 From: Vladimir Kolodiev Date: Mon, 15 May 2017 15:06:55 +0300 Subject: [PATCH 4/5] rsh and ll launchers --- src/pm/hydra/configure.ac | 2 +- src/pm/hydra/libhydra/bstrap/Makefile.mk | 2 + src/pm/hydra/libhydra/bstrap/ll/Makefile.mk | 14 +++ .../libhydra/bstrap/ll/hydra_bstrap_ll.h | 16 ++++ src/pm/hydra/libhydra/bstrap/ll/ll_finalize.c | 18 ++++ src/pm/hydra/libhydra/bstrap/ll/ll_launch.c | 82 ++++++++++++++++ src/pm/hydra/libhydra/bstrap/rsh/Makefile.mk | 14 +++ .../libhydra/bstrap/rsh/hydra_bstrap_rsh.h | 16 ++++ .../hydra/libhydra/bstrap/rsh/rsh_finalize.c | 18 ++++ src/pm/hydra/libhydra/bstrap/rsh/rsh_launch.c | 66 +++++++++++++ src/pm/hydra/libhydra/bstrap/sge/Makefile.mk | 14 +++ .../libhydra/bstrap/sge/hydra_bstrap_sge.h | 17 ++++ .../hydra/libhydra/bstrap/sge/sge_finalize.c | 18 ++++ src/pm/hydra/libhydra/bstrap/sge/sge_launch.c | 94 +++++++++++++++++++ .../libhydra/bstrap/slurm/slurm_launch.c | 2 +- .../libhydra/rmk/ll/ll_query_node_list.c | 20 ++++ 16 files changed, 411 insertions(+), 2 deletions(-) create mode 100644 src/pm/hydra/libhydra/bstrap/ll/Makefile.mk create mode 100644 src/pm/hydra/libhydra/bstrap/ll/hydra_bstrap_ll.h create mode 100644 src/pm/hydra/libhydra/bstrap/ll/ll_finalize.c create mode 100644 src/pm/hydra/libhydra/bstrap/ll/ll_launch.c create mode 100644 src/pm/hydra/libhydra/bstrap/rsh/Makefile.mk create mode 100644 src/pm/hydra/libhydra/bstrap/rsh/hydra_bstrap_rsh.h create mode 100644 src/pm/hydra/libhydra/bstrap/rsh/rsh_finalize.c create mode 100644 src/pm/hydra/libhydra/bstrap/rsh/rsh_launch.c create mode 100644 src/pm/hydra/libhydra/bstrap/sge/Makefile.mk create mode 100644 src/pm/hydra/libhydra/bstrap/sge/hydra_bstrap_sge.h create mode 100644 src/pm/hydra/libhydra/bstrap/sge/sge_finalize.c create mode 100644 src/pm/hydra/libhydra/bstrap/sge/sge_launch.c diff --git a/src/pm/hydra/configure.ac b/src/pm/hydra/configure.ac index 489e9a75ba1..af885a864e8 100644 --- a/src/pm/hydra/configure.ac +++ b/src/pm/hydra/configure.ac @@ -291,7 +291,7 @@ AC_ARG_WITH(hydra-bstrap, [AC_HELP_STRING([--with-hydra-bstrap=name], [Bstrap Server (ssh,rsh,slurm,ll,lsf,sge,pbs)])], [ hydra_bstrap=$withval ], - [ hydra_bstrap="ssh,slurm" ]) + [ hydra_bstrap="ssh,slurm,rsh,ll" ]) AC_MSG_CHECKING(bstrap server) AC_MSG_RESULT($hydra_bstrap) hydra_bstrap_list="`echo $hydra_bstrap | sed -e 's/:/ /g' -e 's/,/ /g'`" diff --git a/src/pm/hydra/libhydra/bstrap/Makefile.mk b/src/pm/hydra/libhydra/bstrap/Makefile.mk index 1a500b98178..1374cb405d3 100644 --- a/src/pm/hydra/libhydra/bstrap/Makefile.mk +++ b/src/pm/hydra/libhydra/bstrap/Makefile.mk @@ -7,3 +7,5 @@ include libhydra/bstrap/src/Makefile.mk include libhydra/bstrap/ssh/Makefile.mk include libhydra/bstrap/slurm/Makefile.mk +include libhydra/bstrap/rsh/Makefile.mk +include libhydra/bstrap/ll/Makefile.mk diff --git a/src/pm/hydra/libhydra/bstrap/ll/Makefile.mk b/src/pm/hydra/libhydra/bstrap/ll/Makefile.mk new file mode 100644 index 00000000000..910a1019756 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/ll/Makefile.mk @@ -0,0 +1,14 @@ +## -*- Mode: Makefile; -*- +## +## (C) 2017 by Argonne National Laboratory. +## See COPYRIGHT in top-level directory. +## + +AM_CPPFLAGS += -I$(top_srcdir)/libhydra/bstrap/ll + +noinst_HEADERS += \ + libhydra/bstrap/ll/hydra_bstrap_ll.h + +libhydra_la_SOURCES += \ + libhydra/bstrap/ll/ll_launch.c \ + libhydra/bstrap/ll/ll_finalize.c diff --git a/src/pm/hydra/libhydra/bstrap/ll/hydra_bstrap_ll.h b/src/pm/hydra/libhydra/bstrap/ll/hydra_bstrap_ll.h new file mode 100644 index 00000000000..c99e7ea1e20 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/ll/hydra_bstrap_ll.h @@ -0,0 +1,16 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#ifndef HYDRA_BSTRAP_LL_H_INCLUDED +#define HYDRA_BSTRAP_LL_H_INCLUDED + +#include "hydra_base.h" + +HYD_status HYDI_bstrap_ll_launch(const char *hostname, const char *launch_exec, char **args, + int *fd_stdin, int *fd_stdout, int *fd_stderr, int *pid, + int debug); +HYD_status HYDI_bstrap_ll_finalize(void); + +#endif /* HYDRA_BSTRAP_LL_H_INCLUDED */ diff --git a/src/pm/hydra/libhydra/bstrap/ll/ll_finalize.c b/src/pm/hydra/libhydra/bstrap/ll/ll_finalize.c new file mode 100644 index 00000000000..e4c5ccb3e44 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/ll/ll_finalize.c @@ -0,0 +1,18 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#include "hydra_bstrap_ll.h" +#include "hydra_err.h" + +HYD_status HYDI_bstrap_ll_finalize(void) +{ + HYD_status status = HYD_SUCCESS; + + fn_exit: + return status; + + fn_fail: + goto fn_exit; +} diff --git a/src/pm/hydra/libhydra/bstrap/ll/ll_launch.c b/src/pm/hydra/libhydra/bstrap/ll/ll_launch.c new file mode 100644 index 00000000000..7d365d5f30d --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/ll/ll_launch.c @@ -0,0 +1,82 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#include "hydra_bstrap_ll.h" +#include "hydra_str.h" +#include "hydra_err.h" +#include "hydra_fs.h" +#include "hydra_spawn.h" + + +HYD_status HYDI_bstrap_ll_launch(const char *hostname, const char *launch_exec, char **args, + int *fd_stdin, int *fd_stdout, int *fd_stderr, int *pid, + int debug) +{ + char *targs[HYD_NUM_TMP_STRINGS] = { NULL }; + int idx, i; + char *lexec = NULL; + HYD_status status = HYD_SUCCESS; + + HYD_FUNC_ENTER(); + + /* We use the following priority order for the executable path: + * (1) user-specified; (2) search in path; (3) Hard-coded + * location */ + if (launch_exec) + lexec = MPL_strdup(launch_exec); + if (lexec == NULL) + lexec = HYD_find_full_path("llspawn.stdio"); + if (lexec == NULL) + lexec = MPL_strdup("/usr/bin/llspawn.stdio"); + HYD_ASSERT(lexec, status); + + idx = 0; + + targs[idx++] = MPL_strdup(lexec); +// targs[idx++] = MPL_strdup("-x"); + targs[idx++] = MPL_strdup(hostname); + for (i = 0; args[i]; i++) + targs[idx++] = MPL_strdup(args[i]); + targs[idx++] = NULL; + + if (debug) { + HYD_PRINT(stdout, "Launch arguments: "); + HYD_str_print_list(targs); + } + + + + +/* targs[idx++] = MPL_strdup(lexec); + + targs[idx++] = MPL_strdup(hostname); +*/ + /* Fill in the remaining arguments */ + /* We do not need to create a quoted version of the string for + * SLURM. It seems to be internally quoting it anyway. */ +/* for (i = 0; args[i]; i++) + targs[idx++] = MPL_strdup(args[i]); + + if (debug) { + HYD_PRINT(stdout, "Launch arguments: "); + HYD_str_print_list(targs); + } +*/ + + status = HYD_spawn(targs, 0, NULL, fd_stdin, fd_stdout, fd_stderr, pid, -1); + HYD_ERR_POP(status, "create process returned error\n"); + + fn_exit: + HYD_str_free_list(targs); + if (lexec) + MPL_free(lexec); + HYD_FUNC_EXIT(); + return status; + +fn_fail: + goto fn_exit; +} + + diff --git a/src/pm/hydra/libhydra/bstrap/rsh/Makefile.mk b/src/pm/hydra/libhydra/bstrap/rsh/Makefile.mk new file mode 100644 index 00000000000..50c482bd176 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/rsh/Makefile.mk @@ -0,0 +1,14 @@ +## -*- Mode: Makefile; -*- +## +## (C) 2017 by Argonne National Laboratory. +## See COPYRIGHT in top-level directory. +## + +AM_CPPFLAGS += -I$(top_srcdir)/libhydra/bstrap/rsh + +noinst_HEADERS += \ + libhydra/bstrap/rsh/hydra_bstrap_rsh.h + +libhydra_la_SOURCES += \ + libhydra/bstrap/rsh/rsh_launch.c \ + libhydra/bstrap/rsh/rsh_finalize.c diff --git a/src/pm/hydra/libhydra/bstrap/rsh/hydra_bstrap_rsh.h b/src/pm/hydra/libhydra/bstrap/rsh/hydra_bstrap_rsh.h new file mode 100644 index 00000000000..35951e48e21 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/rsh/hydra_bstrap_rsh.h @@ -0,0 +1,16 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#ifndef HYDRA_BSTRAP_RSH_H_INCLUDED +#define HYDRA_BSTRAP_RSH_H_INCLUDED + +#include "hydra_base.h" + +HYD_status HYDI_bstrap_rsh_launch(const char *hostname, const char *launch_exec, char **args, + int *fd_stdin, int *fd_stdout, int *fd_stderr, int *pid, + int debug); +HYD_status HYDI_bstrap_rsh_finalize(void); + +#endif /* HYDRA_BSTRAP_RSH_H_INCLUDED */ diff --git a/src/pm/hydra/libhydra/bstrap/rsh/rsh_finalize.c b/src/pm/hydra/libhydra/bstrap/rsh/rsh_finalize.c new file mode 100644 index 00000000000..e7337a47739 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/rsh/rsh_finalize.c @@ -0,0 +1,18 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#include "hydra_bstrap_rsh.h" +#include "hydra_err.h" + +HYD_status HYDI_bstrap_rsh_finalize(void) +{ + HYD_status status = HYD_SUCCESS; + + fn_exit: + return status; + + fn_fail: + goto fn_exit; +} diff --git a/src/pm/hydra/libhydra/bstrap/rsh/rsh_launch.c b/src/pm/hydra/libhydra/bstrap/rsh/rsh_launch.c new file mode 100644 index 00000000000..bb92e05e615 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/rsh/rsh_launch.c @@ -0,0 +1,66 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#include "hydra_bstrap_rsh.h" +#include "hydra_str.h" +#include "hydra_err.h" +#include "hydra_fs.h" +#include "hydra_spawn.h" + + +HYD_status HYDI_bstrap_rsh_launch(const char *hostname, const char *launch_exec, char **args, + int *fd_stdin, int *fd_stdout, int *fd_stderr, int *pid, + int debug) +{ + char *targs[HYD_NUM_TMP_STRINGS] = { NULL }; + int idx, i; + char *lexec = NULL; + HYD_status status = HYD_SUCCESS; + + HYD_FUNC_ENTER(); + + /* We use the following priority order for the executable path: + * (1) user-specified; (2) search in path; (3) Hard-coded + * location */ + if (launch_exec) + lexec = MPL_strdup(launch_exec); + if (lexec == NULL) + lexec = HYD_find_full_path("rsh"); + if (lexec == NULL) + lexec = MPL_strdup("/usr/bin/rsh"); + HYD_ASSERT(lexec, status); + + idx = 0; + targs[idx++] = MPL_strdup(lexec); + + targs[idx++] = MPL_strdup(hostname); + + /* Fill in the remaining arguments */ + /* We do not need to create a quoted version of the string for + * SLURM. It seems to be internally quoting it anyway. */ + for (i = 0; args[i]; i++) + targs[idx++] = MPL_strdup(args[i]); + + if (debug) { + HYD_PRINT(stdout, "Launch arguments: "); + HYD_str_print_list(targs); + } + + + status = HYD_spawn(targs, 0, NULL, fd_stdin, fd_stdout, fd_stderr, pid, -1); + HYD_ERR_POP(status, "create process returned error\n"); + + fn_exit: + HYD_str_free_list(targs); + if (lexec) + MPL_free(lexec); + HYD_FUNC_EXIT(); + return status; + +fn_fail: + goto fn_exit; +} + + diff --git a/src/pm/hydra/libhydra/bstrap/sge/Makefile.mk b/src/pm/hydra/libhydra/bstrap/sge/Makefile.mk new file mode 100644 index 00000000000..75704aedc29 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/sge/Makefile.mk @@ -0,0 +1,14 @@ +## -*- Mode: Makefile; -*- +## +## (C) 2017 by Argonne National Laboratory. +## See COPYRIGHT in top-level directory. +## + +AM_CPPFLAGS += -I$(top_srcdir)/libhydra/bstrap/sge + +noinst_HEADERS += \ + libhydra/bstrap/sge/hydra_bstrap_sge.h + +libhydra_la_SOURCES += \ + libhydra/bstrap/sge/sge_launch.c \ + libhydra/bstrap/sge/sge_finalize.c diff --git a/src/pm/hydra/libhydra/bstrap/sge/hydra_bstrap_sge.h b/src/pm/hydra/libhydra/bstrap/sge/hydra_bstrap_sge.h new file mode 100644 index 00000000000..16e144db745 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/sge/hydra_bstrap_sge.h @@ -0,0 +1,17 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#ifndef HYDRA_BSTRAP_SGE_H_INCLUDED +#define HYDRA_BSTRAP_SGE_H_INCLUDED + +#include "hydra_base.h" +#include "hydra_mem.h" + +HYD_status HYDI_bstrap_sge_launch(const char *hostname, const char *launch_exec, char **args, + int *fd_stdin, int *fd_stdout, int *fd_stderr, int *pid, + int debug); +HYD_status HYDI_bstrap_sge_finalize(void); + +#endif /* HYDRA_BSTRAP_SGE_H_INCLUDED */ diff --git a/src/pm/hydra/libhydra/bstrap/sge/sge_finalize.c b/src/pm/hydra/libhydra/bstrap/sge/sge_finalize.c new file mode 100644 index 00000000000..4169cc90a7b --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/sge/sge_finalize.c @@ -0,0 +1,18 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#include "hydra_bstrap_sge.h" +#include "hydra_err.h" + +HYD_status HYDI_bstrap_sge_finalize(void) +{ + HYD_status status = HYD_SUCCESS; + + fn_exit: + return status; + + fn_fail: + goto fn_exit; +} diff --git a/src/pm/hydra/libhydra/bstrap/sge/sge_launch.c b/src/pm/hydra/libhydra/bstrap/sge/sge_launch.c new file mode 100644 index 00000000000..b2b30812f15 --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/sge/sge_launch.c @@ -0,0 +1,94 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#include "hydra_bstrap_sge.h" +#include "hydra_str.h" +#include "hydra_err.h" +#include "hydra_fs.h" +#include "hydra_spawn.h" + +static HYD_status sge_get_path(char **path); + +HYD_status HYDI_bstrap_sge_launch(const char *hostname, const char *launch_exec, char **args, + int *fd_stdin, int *fd_stdout, int *fd_stderr, int *pid, + int debug) +{ + char *targs[HYD_NUM_TMP_STRINGS] = { NULL }; + int idx, i; + char *lexec = NULL; + HYD_status status = HYD_SUCCESS; + + HYD_FUNC_ENTER(); + + /* We use the following priority order for the executable path: + * (1) user-specified; (2) search in path; (3) Hard-coded + * location */ + if (launch_exec) + lexec = MPL_strdup(launch_exec); + + if (lexec == NULL) + status = sge_get_path(&lexec); + + HYD_ASSERT(lexec, status); + + idx = 0; + targs[idx++] = MPL_strdup(lexec); + + targs[idx++] = MPL_strdup(hostname); + + /* Fill in the remaining arguments */ + /* We do not need to create a quoted version of the string for + * SLURM. It seems to be internally quoting it anyway. */ + for (i = 0; args[i]; i++) + targs[idx++] = MPL_strdup(args[i]); + + if (debug) { + HYD_PRINT(stdout, "Launch arguments: "); + HYD_str_print_list(targs); + } + + + status = HYD_spawn(targs, 0, NULL, fd_stdin, fd_stdout, fd_stderr, pid, -1); + HYD_ERR_POP(status, "create process returned error\n"); + + fn_exit: + HYD_str_free_list(targs); + if (lexec) + MPL_free(lexec); + HYD_FUNC_EXIT(); + return status; + +fn_fail: + goto fn_exit; +} + + +HYD_status sge_get_path(char **path) +{ + char *sge_root = NULL, *arc = NULL; + int length; + HYD_status status = HYD_SUCCESS; + + if (*path == NULL) { + MPL_env2str("SGE_ROOT", (const char **) &sge_root); + MPL_env2str("ARC", (const char **) &arc); + if (sge_root && arc) { + length = strlen(sge_root) + strlen("/bin/") + strlen(arc) + 1 + strlen("qrsh") + 1; + HYD_MALLOC((*path), char *, length, status); + MPL_snprintf(*path, length, "%s/bin/%s/qrsh", sge_root, arc); + } + } + if (*path == NULL) + *path = HYD_find_full_path("qrsh"); + if (*path == NULL) + *path = MPL_strdup("/usr/bin/qrsh"); + + fn_exit: + return status; + + fn_fail: + goto fn_exit; +} + diff --git a/src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c b/src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c index f7d2c4e43a1..a26c0178381 100644 --- a/src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c +++ b/src/pm/hydra/libhydra/bstrap/slurm/slurm_launch.c @@ -61,7 +61,7 @@ HYD_status HYDI_bstrap_slurm_launch(const char *hostname, const char *launch_exe } - status = HYD_spawn(targs, NULL, fd_stdin, fd_stdout, fd_stderr, pid, -1); + status = HYD_spawn(targs, 0, NULL, fd_stdin, fd_stdout, fd_stderr, pid, -1); HYD_ERR_POP(status, "create process returned error\n"); fn_exit: diff --git a/src/pm/hydra/libhydra/rmk/ll/ll_query_node_list.c b/src/pm/hydra/libhydra/rmk/ll/ll_query_node_list.c index 1e7043aa6b3..d5f5858c5fb 100644 --- a/src/pm/hydra/libhydra/rmk/ll/ll_query_node_list.c +++ b/src/pm/hydra/libhydra/rmk/ll/ll_query_node_list.c @@ -11,10 +11,20 @@ HYD_status HYDI_rmk_ll_query_node_list(int *node_count, struct HYD_node **nodes) { char *hostfile; + char *dummy; + int nprocs; + int node_num = 0; + int i; HYD_status status = HYD_SUCCESS; HYD_FUNC_ENTER(); + if (MPL_env2str("LOADL_TOTAL_TASKS", (const char **) &dummy) == 0) { + *node_count = 0; + HYD_ERR_SETANDJUMP(status, HYD_ERR_INTERNAL, "No LL total tasks information\n"); + } + nprocs = atoi(dummy); + MPL_env2str("LOADL_HOSTFILE", (const char **) &hostfile); if (hostfile == NULL) { @@ -26,6 +36,16 @@ HYD_status HYDI_rmk_ll_query_node_list(int *node_count, struct HYD_node **nodes) HYD_ERR_POP(status, "error parsing hostfile\n"); } + + if (*node_count > 0) { + for (i = 0; i < *node_count; i++) { + (*nodes)[i].core_count = (nprocs > (*node_count)) ? (nprocs/(*node_count) + ( (node_num < nprocs%(*node_count)) ? 1 : 0 ) ) : 1; + node_num++; + } + } else { + (*nodes)[0].core_count = nprocs; + } + fn_exit: HYD_FUNC_EXIT(); return status; From ba2a486babfb9d917fec29bfba1b4b6c9bb6349b Mon Sep 17 00:00:00 2001 From: Vladimir Kolodiev Date: Mon, 15 May 2017 15:29:07 +0300 Subject: [PATCH 5/5] Dead code removed --- src/pm/hydra/libhydra/bstrap/ll/ll_launch.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/pm/hydra/libhydra/bstrap/ll/ll_launch.c b/src/pm/hydra/libhydra/bstrap/ll/ll_launch.c index 7d365d5f30d..9f6abc8eecd 100644 --- a/src/pm/hydra/libhydra/bstrap/ll/ll_launch.c +++ b/src/pm/hydra/libhydra/bstrap/ll/ll_launch.c @@ -35,7 +35,6 @@ HYD_status HYDI_bstrap_ll_launch(const char *hostname, const char *launch_exec, idx = 0; targs[idx++] = MPL_strdup(lexec); -// targs[idx++] = MPL_strdup("-x"); targs[idx++] = MPL_strdup(hostname); for (i = 0; args[i]; i++) targs[idx++] = MPL_strdup(args[i]); @@ -45,25 +44,6 @@ HYD_status HYDI_bstrap_ll_launch(const char *hostname, const char *launch_exec, HYD_PRINT(stdout, "Launch arguments: "); HYD_str_print_list(targs); } - - - - -/* targs[idx++] = MPL_strdup(lexec); - - targs[idx++] = MPL_strdup(hostname); -*/ - /* Fill in the remaining arguments */ - /* We do not need to create a quoted version of the string for - * SLURM. It seems to be internally quoting it anyway. */ -/* for (i = 0; args[i]; i++) - targs[idx++] = MPL_strdup(args[i]); - - if (debug) { - HYD_PRINT(stdout, "Launch arguments: "); - HYD_str_print_list(targs); - } -*/ status = HYD_spawn(targs, 0, NULL, fd_stdin, fd_stdout, fd_stderr, pid, -1); HYD_ERR_POP(status, "create process returned error\n");