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..9f6abc8eecd --- /dev/null +++ b/src/pm/hydra/libhydra/bstrap/ll/ll_launch.c @@ -0,0 +1,62 @@ +/* -*- 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(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); + } + + 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;