[mpich2-commits] r5466 - in mpich2/trunk/src/pm/hydra: . bootstrap bootstrap/fork bootstrap/include bootstrap/rsh bootstrap/slurm bootstrap/src bootstrap/ssh bootstrap/utils demux include pm/pmiserv tools tools/bind tools/bind/plpa tools/bind/plpa/plpa tools/bootstrap tools/bootstrap/fork tools/bootstrap/include tools/bootstrap/rsh tools/bootstrap/slurm tools/bootstrap/src tools/bootstrap/ssh tools/bootstrap/utils tools/ckpoint tools/ckpoint/blcr tools/demux utils utils/bind utils/bind/plpa utils/bind/plpa/plpa utils/ckpoint utils/ckpoint/blcr utils/launch
balaji at mcs.anl.gov
balaji at mcs.anl.gov
Thu Oct 15 12:10:32 CDT 2009
Author: balaji
Date: 2009-10-15 12:10:32 -0500 (Thu, 15 Oct 2009)
New Revision: 5466
Added:
mpich2/trunk/src/pm/hydra/include/hydra_tools.h
mpich2/trunk/src/pm/hydra/tools/
mpich2/trunk/src/pm/hydra/tools/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/bind/
mpich2/trunk/src/pm/hydra/tools/bind/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/bind/bind.c
mpich2/trunk/src/pm/hydra/tools/bind/bind.h
mpich2/trunk/src/pm/hydra/tools/bind/plpa/
mpich2/trunk/src/pm/hydra/tools/bind/plpa/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/bind/plpa/bind_plpa.c
mpich2/trunk/src/pm/hydra/tools/bind/plpa/bind_plpa.h
mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/
mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/LICENSE
mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa.h
mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_api_probe.c
mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_dispatch.c
mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_internal.h
mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_map.c
mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_runtime.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/
mpich2/trunk/src/pm/hydra/tools/bootstrap/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/
mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork.h
mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork_init.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork_launch.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/include/
mpich2/trunk/src/pm/hydra/tools/bootstrap/include/bsci.h.in
mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/
mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh.h
mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh_init.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh_launch.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/
mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm.h
mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_init.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_launch.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_query_node_list.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_query_proxy_id.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/src/
mpich2/trunk/src/pm/hydra/tools/bootstrap/src/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_finalize.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_init.c.in
mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_launch.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_query_node_list.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_query_proxy_id.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_usize.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_wait.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/
mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh.h
mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh_init.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh_launch.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/
mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu.h
mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_finalize.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_query_node_list.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_query_proxy_id.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_usize.c
mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_wait.c
mpich2/trunk/src/pm/hydra/tools/ckpoint/
mpich2/trunk/src/pm/hydra/tools/ckpoint/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/
mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/ckpoint_blcr.c
mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/ckpoint_blcr.h
mpich2/trunk/src/pm/hydra/tools/ckpoint/ckpoint.c
mpich2/trunk/src/pm/hydra/tools/ckpoint/ckpoint.h
mpich2/trunk/src/pm/hydra/tools/demux/
mpich2/trunk/src/pm/hydra/tools/demux/Makefile.mk
mpich2/trunk/src/pm/hydra/tools/demux/demux.c
mpich2/trunk/src/pm/hydra/tools/demux/demux.h
Removed:
mpich2/trunk/src/pm/hydra/bootstrap/Makefile.mk
mpich2/trunk/src/pm/hydra/bootstrap/fork/Makefile.mk
mpich2/trunk/src/pm/hydra/bootstrap/fork/fork.h
mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_init.c
mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_launch.c
mpich2/trunk/src/pm/hydra/bootstrap/include/bsci.h.in
mpich2/trunk/src/pm/hydra/bootstrap/rsh/Makefile.mk
mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh.h
mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh_init.c
mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh_launch.c
mpich2/trunk/src/pm/hydra/bootstrap/slurm/Makefile.mk
mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm.h
mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_init.c
mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_launch.c
mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_query_node_list.c
mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_query_proxy_id.c
mpich2/trunk/src/pm/hydra/bootstrap/src/Makefile.mk
mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_finalize.c
mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_init.c.in
mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_launch.c
mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_query_node_list.c
mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_query_proxy_id.c
mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_usize.c
mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_wait.c
mpich2/trunk/src/pm/hydra/bootstrap/ssh/Makefile.mk
mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh.h
mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_init.c
mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c
mpich2/trunk/src/pm/hydra/bootstrap/utils/Makefile.mk
mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu.h
mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_finalize.c
mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_query_node_list.c
mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_query_proxy_id.c
mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_usize.c
mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_wait.c
mpich2/trunk/src/pm/hydra/demux/Makefile.mk
mpich2/trunk/src/pm/hydra/demux/demux.c
mpich2/trunk/src/pm/hydra/demux/demux.h
mpich2/trunk/src/pm/hydra/utils/bind/Makefile.mk
mpich2/trunk/src/pm/hydra/utils/bind/bind.c
mpich2/trunk/src/pm/hydra/utils/bind/bind.h
mpich2/trunk/src/pm/hydra/utils/bind/plpa/Makefile.mk
mpich2/trunk/src/pm/hydra/utils/bind/plpa/bind_plpa.c
mpich2/trunk/src/pm/hydra/utils/bind/plpa/bind_plpa.h
mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/LICENSE
mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/Makefile.mk
mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa.h
mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_api_probe.c
mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_dispatch.c
mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_internal.h
mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_map.c
mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_runtime.c
mpich2/trunk/src/pm/hydra/utils/ckpoint/Makefile.mk
mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/Makefile.mk
mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/ckpoint_blcr.c
mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/ckpoint_blcr.h
mpich2/trunk/src/pm/hydra/utils/ckpoint/ckpoint.c
mpich2/trunk/src/pm/hydra/utils/ckpoint/ckpoint.h
Modified:
mpich2/trunk/src/pm/hydra/Makefile.am
mpich2/trunk/src/pm/hydra/configure.in
mpich2/trunk/src/pm/hydra/include/hydra_utils.h
mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy_cb.c
mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy_utils.c
mpich2/trunk/src/pm/hydra/utils/Makefile.mk
mpich2/trunk/src/pm/hydra/utils/launch/launch.c
Log:
We now separate out the basic utility functions with tools. This makes
it clearer with respect to what structures are shared by what parts of
the stack.
Modified: mpich2/trunk/src/pm/hydra/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/Makefile.am 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/Makefile.am 2009-10-15 17:10:32 UTC (rev 5466)
@@ -19,9 +19,8 @@
# The below directories contribute to libhydra.a
include utils/Makefile.mk
include rmk/Makefile.mk
-include bootstrap/Makefile.mk
include css/Makefile.mk
-include demux/Makefile.mk
+include tools/Makefile.mk
# Build the PM
include pm/Makefile.mk
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,26 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-AM_CPPFLAGS += -I$(top_srcdir)/bootstrap/include -I$(top_builddir)/bootstrap/include
-
-include bootstrap/src/Makefile.mk
-include bootstrap/utils/Makefile.mk
-
-if hydra_bss_ssh
-include bootstrap/ssh/Makefile.mk
-endif
-
-if hydra_bss_rsh
-include bootstrap/rsh/Makefile.mk
-endif
-
-if hydra_bss_fork
-include bootstrap/fork/Makefile.mk
-endif
-
-if hydra_bss_slurm
-include bootstrap/slurm/Makefile.mk
-endif
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/fork/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/fork/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/fork/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,8 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-libhydra_a_SOURCES += $(top_srcdir)/bootstrap/fork/fork_init.c \
- $(top_srcdir)/bootstrap/fork/fork_launch.c
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/fork/fork.h
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/fork/fork.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/fork/fork.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,15 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#ifndef FORK_H_INCLUDED
-#define FORK_H_INCLUDED
-
-#include "hydra_base.h"
-
-HYD_Status HYD_BSCD_fork_launch_procs(char **global_args, const char *proxy_id_str,
- struct HYD_Proxy *proxy_list);
-
-#endif /* FORK_H_INCLUDED */
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_init.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_init.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_init.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,22 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "fork.h"
-
-HYD_Status HYD_BSCI_fork_init(void)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- HYD_BSCI_fns.launch_procs = HYD_BSCD_fork_launch_procs;
-
- HYDU_FUNC_EXIT();
-
- return status;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_launch.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_launch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,60 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-#include "fork.h"
-
-HYD_Status HYD_BSCD_fork_launch_procs(char **global_args, const char *proxy_id_str,
- struct HYD_Proxy *proxy_list)
-{
- struct HYD_Proxy *proxy;
- char *client_arg[HYD_NUM_TMP_STRINGS];
- int i, arg, process_id;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- process_id = 0;
- FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
- /* Setup the executable arguments */
- arg = 0;
-
- for (i = 0; global_args[i]; i++)
- client_arg[arg++] = HYDU_strdup(global_args[i]);
-
- if (proxy_id_str) {
- client_arg[arg++] = HYDU_strdup(proxy_id_str);
- client_arg[arg++] = HYDU_int_to_str(proxy->proxy_id);
- }
-
- client_arg[arg++] = NULL;
-
- if (HYD_BSCI_info.debug) {
- HYDU_dump(stdout, "Launching process: ");
- HYDU_print_strlist(client_arg);
- }
-
- /* The stdin pointer will be some value for process_id 0; for
- * everyone else, it's NULL. */
- status = HYDU_create_process(client_arg, NULL,
- (process_id == 0 ? &proxy->in : NULL),
- &proxy->out, &proxy->err, &proxy->pid, -1);
- HYDU_ERR_POP(status, "create process returned error\n");
-
- HYDU_free_strlist(client_arg);
-
- process_id++;
- }
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/include/bsci.h.in
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/include/bsci.h.in 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/include/bsci.h.in 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,42 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#ifndef BSCI_H_INCLUDED
-#define BSCI_H_INCLUDED
-
-struct HYD_BSCI_info {
- char *bootstrap_exec;
- int enablex;
- int debug;
-};
-
-struct HYD_BSCI_fns {
- HYD_Status(*launch_procs) (char **global_args, const char *proxy_id_str,
- struct HYD_Proxy *proxy_list);
- HYD_Status(*finalize) (void);
- HYD_Status(*wait_for_completion) (struct HYD_Proxy *proxy_list);
- HYD_Status(*query_node_list) (int *num_nodes, struct HYD_Proxy **proxy_list);
- HYD_Status(*query_usize) (int *size);
- HYD_Status(*query_proxy_id) (int *proxy_id);
-};
-
-extern struct HYD_BSCI_fns HYD_BSCI_fns;
-
-HYD_Status HYD_BSCI_init(char *bootstrap, char *bootstrap_exec, int enablex, int debug);
-HYD_Status HYD_BSCI_launch_procs(char **global_args, const char *proxy_id_str,
- struct HYD_Proxy *proxy_list);
-HYD_Status HYD_BSCI_finalize(void);
-HYD_Status HYD_BSCI_wait_for_completion(struct HYD_Proxy *proxy_list);
-HYD_Status HYD_BSCI_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list);
-HYD_Status HYD_BSCI_query_usize(int *size);
-HYD_Status HYD_BSCI_query_proxy_id(int *proxy_id);
-
-/* Each bootstrap server has to expose an initialization function */
- at hydra_bss_init_decl@
-
-extern struct HYD_BSCI_info HYD_BSCI_info;
-
-#endif /* BSCI_H_INCLUDED */
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/rsh/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/rsh/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/rsh/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,8 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-libhydra_a_SOURCES += $(top_srcdir)/bootstrap/rsh/rsh_init.c \
- $(top_srcdir)/bootstrap/rsh/rsh_launch.c
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh.h
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,15 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#ifndef RSH_H_INCLUDED
-#define RSH_H_INCLUDED
-
-#include "hydra_base.h"
-
-HYD_Status HYD_BSCD_rsh_launch_procs(char **global_args, const char *proxy_id_str,
- struct HYD_Proxy *proxy_list);
-
-#endif /* RSH_H_INCLUDED */
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh_init.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh_init.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh_init.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,22 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "rsh.h"
-
-HYD_Status HYD_BSCI_rsh_init(void)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- HYD_BSCI_fns.launch_procs = HYD_BSCD_rsh_launch_procs;
-
- HYDU_FUNC_EXIT();
-
- return status;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh_launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh_launch.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh_launch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,97 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-#include "rsh.h"
-
-/*
- * HYD_BSCD_rsh_launch_procs: For each process, we create an
- * executable which reads like "rsh exec args" and the list of
- * environment variables. We fork a worker process that sets the
- * environment and execvp's this executable.
- */
-HYD_Status HYD_BSCD_rsh_launch_procs(char **global_args, const char *proxy_id_str,
- struct HYD_Proxy *proxy_list)
-{
- struct HYD_Proxy *proxy;
- char *client_arg[HYD_NUM_TMP_STRINGS];
- char *tmp[HYD_NUM_TMP_STRINGS], *path = NULL, *test_path = NULL;
- int i, arg, process_id;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- /*
- * We use the following priority order for the executable path:
- * 1. User-specified
- * 2. Search in path
- * 3. Hard-coded location
- */
- if (HYD_BSCI_info.bootstrap_exec) {
- path = HYDU_strdup(HYD_BSCI_info.bootstrap_exec);
- }
- else {
- status = HYDU_find_in_path("rsh", &test_path);
- HYDU_ERR_POP(status, "error while searching for executable in user path\n");
-
- if (test_path) {
- tmp[0] = HYDU_strdup(test_path);
- tmp[1] = HYDU_strdup("rsh");
- tmp[2] = NULL;
-
- status = HYDU_str_alloc_and_join(tmp, &path);
- HYDU_ERR_POP(status, "error joining strings\n");
-
- HYDU_free_strlist(tmp);
- }
- else
- path = HYDU_strdup("/usr/bin/rsh");
- }
-
- process_id = 0;
- FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
- /* Setup the executable arguments */
- arg = 0;
- client_arg[arg++] = HYDU_strdup(path);
-
- client_arg[arg++] = HYDU_strdup(proxy->hostname);
-
- for (i = 0; global_args[i]; i++)
- client_arg[arg++] = HYDU_strdup(global_args[i]);
-
- if (proxy_id_str) {
- client_arg[arg++] = HYDU_strdup(proxy_id_str);
- client_arg[arg++] = HYDU_int_to_str(proxy->proxy_id);
- }
-
- client_arg[arg++] = NULL;
-
- if (HYD_BSCI_info.debug) {
- HYDU_dump(stdout, "Launching process: ");
- HYDU_print_strlist(client_arg);
- }
-
- /* The stdin pointer will be some value for process_id 0; for
- * everyone else, it's NULL. */
- status = HYDU_create_process(client_arg, NULL,
- (process_id == 0 ? &proxy->in : NULL),
- &proxy->out, &proxy->err, &proxy->pid, -1);
- HYDU_ERR_POP(status, "create process returned error\n");
-
- HYDU_free_strlist(client_arg);
-
- process_id++;
- }
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/slurm/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/slurm/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/slurm/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,10 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-libhydra_a_SOURCES += $(top_srcdir)/bootstrap/slurm/slurm_init.c \
- $(top_srcdir)/bootstrap/slurm/slurm_launch.c \
- $(top_srcdir)/bootstrap/slurm/slurm_query_node_list.c \
- $(top_srcdir)/bootstrap/slurm/slurm_query_proxy_id.c
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm.h
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,17 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#ifndef SLURM_H_INCLUDED
-#define SLURM_H_INCLUDED
-
-#include "hydra_base.h"
-
-HYD_Status HYD_BSCD_slurm_launch_procs(char **global_args, const char *proxy_id_str,
- struct HYD_Proxy *proxy_list);
-HYD_Status HYD_BSCD_slurm_query_proxy_id(int *proxy_id);
-HYD_Status HYD_BSCD_slurm_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list);
-
-#endif /* SLURM_H_INCLUDED */
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_init.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_init.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_init.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,24 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "slurm.h"
-
-HYD_Status HYD_BSCI_slurm_init(void)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- HYD_BSCI_fns.launch_procs = HYD_BSCD_slurm_launch_procs;
- HYD_BSCI_fns.query_proxy_id = HYD_BSCD_slurm_query_proxy_id;
- HYD_BSCI_fns.query_node_list = HYD_BSCD_slurm_query_node_list;
-
- HYDU_FUNC_EXIT();
-
- return status;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_launch.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_launch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,110 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-#include "slurm.h"
-
-HYD_Status HYD_BSCD_slurm_launch_procs(char **global_args, const char *proxy_id_str,
- struct HYD_Proxy *proxy_list)
-{
- struct HYD_Proxy *proxy;
- char *client_arg[HYD_NUM_TMP_STRINGS];
- char *tmp[HYD_NUM_TMP_STRINGS], *path = NULL, *test_path = NULL;
- int i, arg, num_nodes;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- /*
- * We use the following priority order for the executable path:
- * 1. User-specified
- * 2. Search in path
- * 3. Hard-coded location
- */
- if (HYD_BSCI_info.bootstrap_exec) {
- path = HYDU_strdup(HYD_BSCI_info.bootstrap_exec);
- }
- else {
- status = HYDU_find_in_path("srun", &test_path);
- HYDU_ERR_POP(status, "error while searching for executable in user path\n");
-
- if (test_path) {
- tmp[0] = HYDU_strdup(test_path);
- tmp[1] = HYDU_strdup("srun");
- tmp[2] = NULL;
-
- status = HYDU_str_alloc_and_join(tmp, &path);
- HYDU_ERR_POP(status, "error joining strings\n");
-
- HYDU_free_strlist(tmp);
- }
- else
- path = HYDU_strdup("/usr/bin/srun");
- }
-
- arg = 0;
- client_arg[arg++] = HYDU_strdup(path);
- client_arg[arg++] = HYDU_strdup("--nodelist");
-
- i = 0;
- num_nodes = 0;
- FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
- tmp[i++] = HYDU_strdup(proxy->hostname);
- if (proxy->next && proxy->next->active)
- tmp[i++] = HYDU_strdup(",");
- num_nodes++;
-
- /* If we used up more than half of the array elements, merge
- * what we have so far */
- if (i > (HYD_NUM_TMP_STRINGS / 2)) {
- tmp[i++] = NULL;
- status = HYDU_str_alloc_and_join(tmp, &client_arg[arg]);
- HYDU_ERR_POP(status, "error joining strings\n");
-
- i = 0;
- tmp[i++] = client_arg[arg];
- }
- }
- tmp[i++] = NULL;
- status = HYDU_str_alloc_and_join(tmp, &client_arg[arg]);
- HYDU_ERR_POP(status, "error joining strings\n");
-
- HYDU_free_strlist(tmp);
-
- arg++;
-
- client_arg[arg++] = HYDU_strdup("-N");
- client_arg[arg++] = HYDU_int_to_str(num_nodes);
-
- client_arg[arg++] = HYDU_strdup("-n");
- client_arg[arg++] = HYDU_int_to_str(num_nodes);
-
- for (i = 0; global_args[i]; i++)
- client_arg[arg++] = HYDU_strdup(global_args[i]);
-
- client_arg[arg++] = NULL;
-
- if (HYD_BSCI_info.debug) {
- HYDU_dump(stdout, "Launching process: ");
- HYDU_print_strlist(client_arg);
- }
-
- status = HYDU_create_process(client_arg, NULL,
- &proxy_list->in,
- &proxy_list->out, &proxy_list->err, &proxy_list->pid, -1);
- HYDU_ERR_POP(status, "bootstrap spawn process returned error\n");
-
- HYDU_free_strlist(client_arg);
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_query_node_list.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_query_node_list.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_query_node_list.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,142 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-#include "slurm.h"
-
-static void full_str_to_groups(char *str, char **list)
-{
- char *tmp;
- char new[MAX_HOSTNAME_LEN];
- int nesting, i, arg;
-
- tmp = str;
- i = 0;
- nesting = 0;
- arg = 0;
-
- while (1) {
- new[i] = *tmp;
- if (*tmp == '[')
- nesting++;
- if (*tmp == ']')
- nesting--;
- if (*tmp == ',' && nesting == 0) {
- new[i] = 0;
- list[arg++] = HYDU_strdup(new);
- i = -1;
- }
- if (*tmp == 0) {
- new[++i] = 0;
- list[arg++] = HYDU_strdup(new);
- break;
- }
-
- i++;
- tmp++;
- }
- list[arg++] = NULL;
-}
-
-static HYD_Status group_to_individual_nodes(char *str, char **list)
-{
- char *pre = NULL, *nodes = NULL, *tmp;
- int start_node, end_node;
- char new[MAX_HOSTNAME_LEN], *node_str[MAX_HOSTNAME_LEN];
- int arg, i;
- HYD_Status status = HYD_SUCCESS;
-
- tmp = str;
- i = 0;
- while (1) {
- new[i] = *tmp;
-
- if (*tmp == '[') {
- new[i] = 0;
- pre = HYDU_strdup(new);
- i = -1;
- }
-
- if (*tmp == ']' || *tmp == 0) {
- new[i] = 0;
- nodes = HYDU_strdup(new);
- break;
- }
-
- i++;
- tmp++;
- }
-
- arg = 0;
- if (pre == NULL) {
- list[arg++] = nodes;
- }
- else {
- start_node = atoi(strtok(nodes, "-"));
- end_node = atoi(strtok(NULL, "-"));
- for (i = start_node; i <= end_node; i++) {
- node_str[0] = HYDU_strdup(pre);
- node_str[1] = HYDU_int_to_str(i);
- node_str[2] = NULL;
-
- status = HYDU_str_alloc_and_join(node_str, &list[arg++]);
- HYDU_ERR_POP(status, "unable to join strings\n");
-
- HYDU_free_strlist(node_str);
- }
- }
- list[arg++] = NULL;
-
- fn_exit:
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-HYD_Status HYD_BSCD_slurm_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list)
-{
- char *str, *num_procs;
- char *tmp1[HYD_NUM_TMP_STRINGS], *tmp2[HYD_NUM_TMP_STRINGS];
- int i, j;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- str = getenv("SLURM_NODELIST");
- num_procs = getenv("SLURM_JOB_CPUS_PER_NODE");
-
- if (str == NULL || num_procs == NULL) {
- *proxy_list = NULL;
- }
- else {
- full_str_to_groups(str, tmp1);
- num_procs = strtok(num_procs, "(");
-
- *num_nodes = 0;
- for (i = 0; tmp1[i]; i++) {
- status = group_to_individual_nodes(tmp1[i], tmp2);
- HYDU_ERR_POP(status, "unable to parse node list\n");
-
- for (j = 0; tmp2[j]; j++) {
- status = HYDU_merge_proxy_segment(tmp2[j], *num_nodes, atoi(num_procs),
- proxy_list);
- HYDU_ERR_POP(status, "merge proxy segment failed\n");
-
- *num_nodes += atoi(num_procs);
- }
- }
- }
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_query_proxy_id.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_query_proxy_id.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_query_proxy_id.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,32 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-#include "slurm.h"
-
-HYD_Status HYD_BSCD_slurm_query_proxy_id(int *proxy_id)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- if (getenv("SLURM_NODEID")) {
- *proxy_id = atoi(getenv("SLURM_NODEID"));
- }
- else {
- *proxy_id = -1;
- HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "cannot find slurm proxy ID\n");
- }
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/src/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/src/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/src/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,13 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-libhydra_a_SOURCES += $(top_builddir)/bootstrap/src/bsci_init.c \
- $(top_srcdir)/bootstrap/src/bsci_finalize.c \
- $(top_srcdir)/bootstrap/src/bsci_launch.c \
- $(top_srcdir)/bootstrap/src/bsci_query_node_list.c \
- $(top_srcdir)/bootstrap/src/bsci_query_proxy_id.c \
- $(top_srcdir)/bootstrap/src/bsci_usize.c \
- $(top_srcdir)/bootstrap/src/bsci_wait.c
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_finalize.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_finalize.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_finalize.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,26 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-
-HYD_Status HYD_BSCI_finalize(void)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- status = HYD_BSCI_fns.finalize();
- HYDU_ERR_POP(status, "bootstrap device returned error while finalizing\n");
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_init.c.in
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_init.c.in 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_init.c.in 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,62 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-
-struct HYD_BSCI_fns HYD_BSCI_fns = { 0 };
-const char *HYD_BSCI_comp_array[] = { @hydra_bss_name_array@ };
-HYD_Status(*HYD_BSCI_comp_init[])(void) = { @hydra_bss_init_array@ };
-struct HYD_BSCI_info HYD_BSCI_info = { 0 };
-
-HYD_Status HYD_BSCI_init(char *bootstrap, char *bootstrap_exec, int enablex, int debug)
-{
- int i;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- for (i = 0; HYD_BSCI_comp_array[i]; i++) {
- if (!strcmp(bootstrap, HYD_BSCI_comp_array[i])) {
- status = (*HYD_BSCI_comp_init[i])();
- HYDU_ERR_POP(status, "bootstrap device returned error initializing\n");
- break;
- }
- }
-
- /* Set the appropriate info */
- HYD_BSCI_info.bootstrap_exec = bootstrap_exec;
- HYD_BSCI_info.enablex = enablex;
- HYD_BSCI_info.debug = debug;
-
- if (HYD_BSCI_comp_array[i] == NULL)
- HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR,
- "unrecognized bootstrap server: %s\n", bootstrap);
-
- /* This function is mandatory */
- if (HYD_BSCI_fns.launch_procs == NULL)
- HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
- "mandatory bootstrap launch function undefined\n");
-
- if (HYD_BSCI_fns.finalize == NULL)
- HYD_BSCI_fns.finalize = HYD_BSCU_finalize;
- if (HYD_BSCI_fns.wait_for_completion == NULL)
- HYD_BSCI_fns.wait_for_completion = HYD_BSCU_wait_for_completion;
- if (HYD_BSCI_fns.query_node_list == NULL)
- HYD_BSCI_fns.query_node_list = HYD_BSCU_query_node_list;
- if (HYD_BSCI_fns.query_usize == NULL)
- HYD_BSCI_fns.query_usize = HYD_BSCU_query_usize;
- if (HYD_BSCI_fns.query_proxy_id == NULL)
- HYD_BSCI_fns.query_proxy_id = HYD_BSCU_query_proxy_id;
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_launch.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_launch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,26 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-
-HYD_Status HYD_BSCI_launch_procs(char **global_args, const char *proxy_id_str,
- struct HYD_Proxy *proxy_list)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- status = HYD_BSCI_fns.launch_procs(global_args, proxy_id_str, proxy_list);
- HYDU_ERR_POP(status, "bootstrap device returned error while launching processes\n");
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_query_node_list.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_query_node_list.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_query_node_list.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,26 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-
-HYD_Status HYD_BSCI_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- status = HYD_BSCI_fns.query_node_list(num_nodes, proxy_list);
- HYDU_ERR_POP(status, "bootstrap device returned error while querying node list\n");
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_query_proxy_id.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_query_proxy_id.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_query_proxy_id.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,26 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-
-HYD_Status HYD_BSCI_query_proxy_id(int *proxy_id)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- status = HYD_BSCI_fns.query_proxy_id(proxy_id);
- HYDU_ERR_POP(status, "bootstrap device returned error while querying proxy ID\n");
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_usize.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_usize.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_usize.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,26 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-
-HYD_Status HYD_BSCI_query_usize(int *size)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- status = HYD_BSCI_fns.query_usize(size);
- HYDU_ERR_POP(status, "bootstrap device returned error querying usize\n");
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_wait.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_wait.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_wait.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,26 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-
-HYD_Status HYD_BSCI_wait_for_completion(struct HYD_Proxy *proxy_list)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- status = HYD_BSCI_fns.wait_for_completion(proxy_list);
- HYDU_ERR_POP(status, "bootstrap device returned error waiting for completion\n");
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/ssh/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/ssh/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/ssh/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,8 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-libhydra_a_SOURCES += $(top_srcdir)/bootstrap/ssh/ssh_init.c \
- $(top_srcdir)/bootstrap/ssh/ssh_launch.c
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh.h
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,15 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#ifndef SSH_H_INCLUDED
-#define SSH_H_INCLUDED
-
-#include "hydra_base.h"
-
-HYD_Status HYD_BSCD_ssh_launch_procs(char **global_args, const char *proxy_id_str,
- struct HYD_Proxy *proxy_list);
-
-#endif /* SSH_H_INCLUDED */
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_init.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_init.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_init.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,22 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "ssh.h"
-
-HYD_Status HYD_BSCI_ssh_init(void)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- HYD_BSCI_fns.launch_procs = HYD_BSCD_ssh_launch_procs;
-
- HYDU_FUNC_EXIT();
-
- return status;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,109 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bsci.h"
-#include "bscu.h"
-#include "ssh.h"
-
-/*
- * HYD_BSCD_ssh_launch_procs: For each process, we create an
- * executable which reads like "ssh exec args" and the list of
- * environment variables. We fork a worker process that sets the
- * environment and execvp's this executable.
- */
-HYD_Status HYD_BSCD_ssh_launch_procs(char **global_args, const char *proxy_id_str,
- struct HYD_Proxy *proxy_list)
-{
- struct HYD_Proxy *proxy;
- char *client_arg[HYD_NUM_TMP_STRINGS];
- char *tmp[HYD_NUM_TMP_STRINGS], *path = NULL, *test_path = NULL;
- int i, arg, process_id;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- /*
- * We use the following priority order for the executable path:
- * 1. User-specified
- * 2. Search in path
- * 3. Hard-coded location
- */
- if (HYD_BSCI_info.bootstrap_exec) {
- path = HYDU_strdup(HYD_BSCI_info.bootstrap_exec);
- }
- else {
- status = HYDU_find_in_path("ssh", &test_path);
- HYDU_ERR_POP(status, "error while searching for executable in user path\n");
-
- if (test_path) {
- tmp[0] = HYDU_strdup(test_path);
- tmp[1] = HYDU_strdup("ssh");
- tmp[2] = NULL;
-
- status = HYDU_str_alloc_and_join(tmp, &path);
- HYDU_ERR_POP(status, "error joining strings\n");
-
- HYDU_free_strlist(tmp);
- }
- else
- path = HYDU_strdup("/usr/bin/ssh");
- }
-
- process_id = 0;
- FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
- /* Setup the executable arguments */
- arg = 0;
- client_arg[arg++] = HYDU_strdup(path);
-
- /* Allow X forwarding only if explicitly requested */
- if (HYD_BSCI_info.enablex == 1)
- client_arg[arg++] = HYDU_strdup("-X");
- else if (HYD_BSCI_info.enablex == 0)
- client_arg[arg++] = HYDU_strdup("-x");
- else /* default mode is disable X */
- client_arg[arg++] = HYDU_strdup("-x");
-
- client_arg[arg++] = HYDU_strdup(proxy->hostname);
-
- for (i = 0; global_args[i]; i++)
- client_arg[arg++] = HYDU_strdup(global_args[i]);
-
- if (proxy_id_str) {
- client_arg[arg++] = HYDU_strdup(proxy_id_str);
- client_arg[arg++] = HYDU_int_to_str(proxy->proxy_id);
- }
-
- client_arg[arg++] = NULL;
-
- if (HYD_BSCI_info.debug) {
- HYDU_dump(stdout, "Launching process: ");
- HYDU_print_strlist(client_arg);
- }
-
- /* The stdin pointer will be some value for process_id 0; for
- * everyone else, it's NULL. */
- status = HYDU_create_process(client_arg, NULL,
- (process_id == 0 ? &proxy->in : NULL),
- &proxy->out, &proxy->err, &proxy->pid, -1);
- HYDU_ERR_POP(status, "create process returned error\n");
-
- HYDU_free_strlist(client_arg);
-
- process_id++;
- }
-
- fn_exit:
- if (test_path)
- HYDU_FREE(test_path);
- if (path)
- HYDU_FREE(path);
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/utils/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/utils/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/utils/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,13 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-AM_CPPFLAGS += -I$(top_srcdir)/bootstrap/utils
-
-libhydra_a_SOURCES += $(top_srcdir)/bootstrap/utils/bscu_finalize.c \
- $(top_srcdir)/bootstrap/utils/bscu_query_node_list.c \
- $(top_srcdir)/bootstrap/utils/bscu_query_proxy_id.c \
- $(top_srcdir)/bootstrap/utils/bscu_usize.c \
- $(top_srcdir)/bootstrap/utils/bscu_wait.c
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu.h
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,18 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#ifndef BSCU_H_INCLUDED
-#define BSCU_H_INCLUDED
-
-#include "hydra_base.h"
-
-HYD_Status HYD_BSCU_finalize(void);
-HYD_Status HYD_BSCU_wait_for_completion(struct HYD_Proxy *proxy_list);
-HYD_Status HYD_BSCU_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list);
-HYD_Status HYD_BSCU_query_usize(int *size);
-HYD_Status HYD_BSCU_query_proxy_id(int *proxy_id);
-
-#endif /* BSCU_H_INCLUDED */
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_finalize.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_finalize.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_finalize.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,20 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_base.h"
-#include "hydra_utils.h"
-#include "bscu.h"
-
-HYD_Status HYD_BSCU_finalize(void)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- HYDU_FUNC_EXIT();
-
- return status;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_query_node_list.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_query_node_list.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_query_node_list.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,25 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_base.h"
-#include "hydra_utils.h"
-#include "bscu.h"
-
-HYD_Status HYD_BSCU_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- /* We don't know anything about nodes or resources. Just return
- * NULL. */
- *num_nodes = 0;
- *proxy_list = NULL;
-
- HYDU_FUNC_EXIT();
-
- return status;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_query_proxy_id.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_query_proxy_id.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_query_proxy_id.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,23 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_base.h"
-#include "hydra_utils.h"
-#include "bscu.h"
-
-HYD_Status HYD_BSCU_query_proxy_id(int *proxy_id)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- /* We don't know anything about proxy IDs by default. */
- *proxy_id = -1;
-
- HYDU_FUNC_EXIT();
-
- return status;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_usize.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_usize.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_usize.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,22 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_base.h"
-#include "hydra_utils.h"
-#include "bscu.h"
-
-HYD_Status HYD_BSCU_query_usize(int *size)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- *size = -1;
-
- HYDU_FUNC_EXIT();
-
- return status;
-}
Deleted: mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_wait.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_wait.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_wait.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,48 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bscu.h"
-
-HYD_Status HYD_BSCU_wait_for_completion(struct HYD_Proxy *proxy_list)
-{
- int pid, ret_status, not_completed;
- struct HYD_Proxy *proxy;
- struct HYD_Proxy_exec *exec;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- not_completed = 0;
- FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
- if (proxy->exit_status == NULL) {
- for (exec = proxy->exec_list; exec; exec = exec->next)
- not_completed += exec->proc_count;
- }
- }
-
- /* We get here only after the I/O sockets have been closed. If the
- * application did not manually close its stdout and stderr
- * sockets, this means that the processes have terminated. In that
- * case the below loop will return almost immediately. If not, we
- * poll for some time, burning CPU. */
- while (not_completed > 0) {
- pid = waitpid(-1, &ret_status, WNOHANG);
- if (pid > 0) {
- /* Find the pid and mark it as complete. */
- FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
- if (proxy->pid == pid)
- not_completed--;
- }
- }
- }
-
- if (not_completed)
- status = HYD_INTERNAL_ERROR;
-
- HYDU_FUNC_EXIT();
- return status;
-}
Modified: mpich2/trunk/src/pm/hydra/configure.in
===================================================================
--- mpich2/trunk/src/pm/hydra/configure.in 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/configure.in 2009-10-15 17:10:32 UTC (rev 5466)
@@ -321,10 +321,10 @@
AC_MSG_CHECKING(if plpa works correctly)
old_CFLAGS=$CFLAGS
old_LDFLAGS=$LDFLAGS
- CFLAGS="$CFLAGS -I${srcdir}/utils/bind/plpa/plpa"
- LDFLAGS="$LDFLAGS ${srcdir}/utils/bind/plpa/plpa/plpa_api_probe.c"
- LDFLAGS="$LDFLAGS ${srcdir}/utils/bind/plpa/plpa/plpa_runtime.c"
- LDFLAGS="$LDFLAGS ${srcdir}/utils/bind/plpa/plpa/plpa_map.c"
+ CFLAGS="$CFLAGS -I${srcdir}/tools/bind/plpa/plpa"
+ LDFLAGS="$LDFLAGS ${srcdir}/tools/bind/plpa/plpa/plpa_api_probe.c"
+ LDFLAGS="$LDFLAGS ${srcdir}/tools/bind/plpa/plpa/plpa_runtime.c"
+ LDFLAGS="$LDFLAGS ${srcdir}/tools/bind/plpa/plpa/plpa_map.c"
AC_TRY_LINK([#include <plpa_internal.h>],[
PLPA_NAME(api_type_t) p;
PLPA_NAME(api_probe)(&p);
@@ -485,8 +485,8 @@
# Final output
AC_OUTPUT(Makefile
- bootstrap/src/bsci_init.c
- bootstrap/include/bsci.h
+ tools/bootstrap/src/bsci_init.c
+ tools/bootstrap/include/bsci.h
rmk/src/rmki_init.c
rmk/include/rmki.h
css/src/cssi_init.c
Deleted: mpich2/trunk/src/pm/hydra/demux/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/demux/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/demux/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,9 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-AM_CPPFLAGS += -I$(top_srcdir)/demux
-
-libhydra_a_SOURCES += $(top_srcdir)/demux/demux.c
Deleted: mpich2/trunk/src/pm/hydra/demux/demux.c
===================================================================
--- mpich2/trunk/src/pm/hydra/demux/demux.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/demux/demux.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,210 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra.h"
-#include "hydra_utils.h"
-#include "demux.h"
-
-static int num_cb_fds = 0;
-
-typedef struct HYD_DMXI_callback {
- int num_fds;
- int *fd;
- HYD_Event_t events;
- void *userp;
- HYD_Status(*callback) (int fd, HYD_Event_t events, void *userp);
-
- struct HYD_DMXI_callback *next;
-} HYD_DMXI_callback_t;
-
-static HYD_DMXI_callback_t *cb_list = NULL;
-
-HYD_Status HYD_DMX_register_fd(int num_fds, int *fd, HYD_Event_t events, void *userp,
- HYD_Status(*callback) (int fd, HYD_Event_t events, void *userp))
-{
- HYD_DMXI_callback_t *cb_element, *run;
- int i;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- for (i = 0; i < num_fds; i++)
- if (fd[i] < 0)
- HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR, "registering bad fd %d\n", fd[i]);
-
- HYDU_MALLOC(cb_element, HYD_DMXI_callback_t *, sizeof(HYD_DMXI_callback_t), status);
- cb_element->num_fds = num_fds;
- HYDU_MALLOC(cb_element->fd, int *, num_fds * sizeof(int), status);
- memcpy(cb_element->fd, fd, num_fds * sizeof(int));
- cb_element->events = events;
- cb_element->userp = userp;
- cb_element->callback = callback;
- cb_element->next = NULL;
-
- if (cb_list == NULL) {
- cb_list = cb_element;
- }
- else {
- run = cb_list;
- while (run->next)
- run = run->next;
- run->next = cb_element;
- }
-
- num_cb_fds += num_fds;
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-
-HYD_Status HYD_DMX_deregister_fd(int fd)
-{
- int i;
- HYD_DMXI_callback_t *cb_element;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- cb_element = cb_list;
- while (cb_element) {
- for (i = 0; i < cb_element->num_fds; i++) {
- if (cb_element->fd[i] == fd) {
- cb_element->fd[i] = -1;
- num_cb_fds--;
- goto fn_exit;
- }
- }
- cb_element = cb_element->next;
- }
-
- /* FD is not found */
- HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR,
- "could not find fd to deregister: %d\n", fd);
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-
-HYD_Status HYD_DMX_wait_for_event(int wtime)
-{
- int total_fds, i, j, events, ret;
- HYD_DMXI_callback_t *run;
- struct pollfd *pollfds = NULL;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- HYDU_MALLOC(pollfds, struct pollfd *, num_cb_fds * sizeof(struct pollfd), status);
-
- run = cb_list;
- i = 0;
- while (run) {
- for (j = 0; j < run->num_fds; j++) {
- if (run->fd[j] == -1)
- continue;
-
- pollfds[i].fd = run->fd[j];
-
- pollfds[i].events = 0;
- if (run->events & HYD_STDOUT)
- pollfds[i].events |= POLLIN;
- if (run->events & HYD_STDIN)
- pollfds[i].events |= POLLOUT;
-
- i++;
- }
- run = run->next;
- }
- total_fds = i;
-
- while (1) {
- ret = poll(pollfds, total_fds, wtime);
- if (ret < 0) {
- if (errno == EINTR) {
- /* We were interrupted by a system call; this is not
- * an error case in the regular sense; but the upper
- * layer needs to gracefully cleanup the processes. */
- status = HYD_SUCCESS;
- goto fn_exit;
- }
- HYDU_ERR_SETANDJUMP1(status, HYD_SOCK_ERROR, "poll error (%s)\n",
- HYDU_strerror(errno));
- }
- break;
- }
-
- run = cb_list;
- i = 0;
- while (run) {
- for (j = 0; j < run->num_fds; j++) {
- if (run->fd[j] == -1)
- continue;
-
- if (pollfds[i].revents) {
- events = 0;
- if (pollfds[i].revents & POLLOUT)
- events |= HYD_STDIN;
- if (pollfds[i].revents & POLLIN)
- events |= HYD_STDOUT;
-
- if (run->callback == NULL)
- HYDU_ERR_POP(status, "no registered callback found for socket\n");
-
- status = run->callback(pollfds[i].fd, events, run->userp);
- HYDU_ERR_POP(status, "callback returned error status\n");
- }
-
- i++;
- if (i == total_fds)
- break;
- }
- run = run->next;
-
- if (i == total_fds)
- break;
- }
-
- fn_exit:
- if (pollfds)
- HYDU_FREE(pollfds);
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-
-HYD_Status HYD_DMX_finalize(void)
-{
- HYD_DMXI_callback_t *run1, *run2;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- run1 = cb_list;
- while (run1) {
- run2 = run1->next;
- if (run1->fd)
- HYDU_FREE(run1->fd);
- HYDU_FREE(run1);
- run1 = run2;
- }
- cb_list = NULL;
-
- HYDU_FUNC_EXIT();
- return status;
-}
Deleted: mpich2/trunk/src/pm/hydra/demux/demux.h
===================================================================
--- mpich2/trunk/src/pm/hydra/demux/demux.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/demux/demux.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,19 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#ifndef DEMUX_H_INCLUDED
-#define DEMUX_H_INCLUDED
-
-#include "hydra.h"
-
-HYD_Status HYD_DMX_register_fd(int num_fds, int *fd, HYD_Event_t events, void *userp,
- HYD_Status(*callback) (int fd, HYD_Event_t events,
- void *userp));
-HYD_Status HYD_DMX_deregister_fd(int fd);
-HYD_Status HYD_DMX_wait_for_event(int time);
-HYD_Status HYD_DMX_finalize(void);
-
-#endif /* DEMUX_H_INCLUDED */
Added: mpich2/trunk/src/pm/hydra/include/hydra_tools.h
===================================================================
--- mpich2/trunk/src/pm/hydra/include/hydra_tools.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/include/hydra_tools.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,24 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef HYDRA_TOOLS_H_INCLUDED
+#define HYDRA_TOOLS_H_INCLUDED
+
+#include "hydra_base.h"
+
+/* bind */
+HYD_Status HYDU_bind_init(char *binding, char *bindlib);
+void HYDU_bind_finalize(void);
+HYD_Status HYDU_bind_process(int core);
+int HYDU_bind_get_core_id(int id);
+
+/* checkpointing */
+HYD_Status HYDU_ckpoint_init(char *ckpointlib, char *ckpoint_prefix);
+HYD_Status HYDU_ckpoint_suspend(void);
+HYD_Status HYDU_ckpoint_restart(HYD_Env_t * envlist, int num_ranks, int ranks[], int *in,
+ int *out, int *err);
+
+#endif /* HYDRA_TOOLS_H_INCLUDED */
Modified: mpich2/trunk/src/pm/hydra/include/hydra_utils.h
===================================================================
--- mpich2/trunk/src/pm/hydra/include/hydra_utils.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/include/hydra_utils.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -137,12 +137,6 @@
HYD_Status HYDU_parse_hostfile(char *hostfile,
HYD_Status(*process_token) (char *token, int newline));
-/* bind */
-HYD_Status HYDU_bind_init(char *binding, char *bindlib);
-void HYDU_bind_finalize(void);
-HYD_Status HYDU_bind_process(int core);
-int HYDU_bind_get_core_id(int id);
-
/* debug */
HYD_Status HYDU_dbg_init(const char *str);
void HYDU_dump_prefix(FILE * fp);
@@ -290,10 +284,4 @@
void HYDU_time_set(HYD_Time * time, int *val);
int HYDU_time_left(HYD_Time start, HYD_Time timeout);
-/* checkpointing */
-HYD_Status HYDU_ckpoint_init(char *ckpointlib, char *ckpoint_prefix);
-HYD_Status HYDU_ckpoint_suspend(void);
-HYD_Status HYDU_ckpoint_restart(HYD_Env_t * envlist, int num_ranks, int ranks[], int *in,
- int *out, int *err);
-
#endif /* HYDRA_UTILS_H_INCLUDED */
Modified: mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy_cb.c
===================================================================
--- mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy_cb.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy_cb.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -6,6 +6,7 @@
#include "hydra.h"
#include "hydra_utils.h"
+#include "hydra_tools.h"
#include "pmi_proxy.h"
#include "demux.h"
Modified: mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy_utils.c
===================================================================
--- mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy_utils.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy_utils.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -8,6 +8,7 @@
#include "bsci.h"
#include "demux.h"
#include "hydra_utils.h"
+#include "hydra_tools.h"
struct HYD_PMCD_pmi_proxy_params HYD_PMCD_pmi_proxy_params;
Added: mpich2/trunk/src/pm/hydra/tools/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,12 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+tools_libs =
+
+include tools/bind/Makefile.mk
+include tools/bootstrap/Makefile.mk
+include tools/ckpoint/Makefile.mk
+include tools/demux/Makefile.mk
Copied: mpich2/trunk/src/pm/hydra/tools/bind/Makefile.mk (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/Makefile.mk)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,13 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+AM_CPPFLAGS += -I$(top_srcdir)/tools/bind
+
+libhydra_a_SOURCES += $(top_srcdir)/tools/bind/bind.c
+
+if hydra_have_plpa
+include tools/bind/plpa/Makefile.mk
+endif
Copied: mpich2/trunk/src/pm/hydra/tools/bind/bind.c (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/bind.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/bind.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/bind.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,173 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "hydra_tools.h"
+#include "bind.h"
+
+#if defined HAVE_PLPA
+#include "plpa/bind_plpa.h"
+#endif /* HAVE_PLPA */
+
+struct HYDU_bind_info HYDU_bind_info;
+
+HYD_Status HYDU_bind_init(char *binding, char *bindlib)
+{
+ char *bindstr, *bindentry;
+ int sock, core, thread, i, j;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ HYDU_bind_info.support_level = HYDU_BIND_NONE;
+ HYDU_bind_info.topology = NULL;
+ HYDU_bind_info.bindlib = HYDU_strdup(bindlib);
+
+ if (!binding || !strcmp(binding, "none")) {
+ /* If no binding is given, we just set all mappings to -1 */
+ HYDU_MALLOC(HYDU_bind_info.bindmap, int *, sizeof(int), status);
+ HYDU_bind_info.num_procs = 1;
+ HYDU_bind_info.bindmap[0] = -1;
+
+ goto fn_exit;
+ }
+
+ if (!strncmp(binding, "user:", strlen("user:"))) {
+ /* If the user specified the binding, we don't need to
+ * initialize anything */
+ bindstr = HYDU_strdup(binding + strlen("user:"));
+
+ /* Find the number of processing elements */
+ HYDU_bind_info.num_procs = 0;
+ bindentry = strtok(bindstr, ",");
+ while (bindentry) {
+ HYDU_bind_info.num_procs++;
+ bindentry = strtok(NULL, ",");
+ }
+
+ /* Find the actual processing elements */
+ HYDU_MALLOC(HYDU_bind_info.bindmap, int *, HYDU_bind_info.num_procs * sizeof(int),
+ status);
+ i = 0;
+ bindentry = strtok(bindstr, ",");
+ while (bindentry) {
+ HYDU_bind_info.bindmap[i++] = atoi(bindentry);
+ bindentry = strtok(NULL, ",");
+ }
+
+ goto fn_exit;
+ }
+
+ /* If a real binding is required, we initialize the binding
+ * library requested by the user */
+#if defined HAVE_PLPA
+ if (!strcmp(HYDU_bind_info.bindlib, "plpa")) {
+ status = HYDU_bind_plpa_init(&HYDU_bind_info.support_level);
+ HYDU_ERR_POP(status, "unable to initialize plpa\n");
+ }
+#endif /* HAVE_PLPA */
+
+ if (HYDU_bind_info.support_level != HYDU_BIND_NONE) {
+ HYDU_MALLOC(HYDU_bind_info.bindmap, int *, HYDU_bind_info.num_procs * sizeof(int),
+ status);
+
+ for (i = 0; i < HYDU_bind_info.num_procs; i++) {
+
+ /* RR is supported at the basic binding level */
+ if (!strcmp(binding, "rr")) {
+ HYDU_bind_info.bindmap[i] = i;
+ continue;
+ }
+
+ /* If we reached here, the user requested for topology
+ * aware binding. */
+ if (HYDU_bind_info.support_level != HYDU_BIND_TOPO)
+ HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
+ "topology binding not supported on this platform\n");
+
+ if (!strcmp(binding, "buddy")) {
+ thread = i / (HYDU_bind_info.num_sockets * HYDU_bind_info.num_cores);
+
+ core = i % (HYDU_bind_info.num_sockets * HYDU_bind_info.num_cores);
+ core /= HYDU_bind_info.num_sockets;
+
+ sock = i % HYDU_bind_info.num_sockets;
+ }
+ else if (!strcmp(binding, "pack")) {
+ sock = i / (HYDU_bind_info.num_cores * HYDU_bind_info.num_threads);
+
+ core = i % (HYDU_bind_info.num_cores * HYDU_bind_info.num_threads);
+ core /= HYDU_bind_info.num_threads;
+
+ thread = i % HYDU_bind_info.num_threads;
+ }
+ else {
+ HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "unknown binding option\n");
+ }
+
+ for (j = 0; j < HYDU_bind_info.num_procs; j++) {
+ if (HYDU_bind_info.topology[j].socket_rank == sock &&
+ HYDU_bind_info.topology[j].core_rank == core &&
+ HYDU_bind_info.topology[j].thread_rank == thread) {
+ HYDU_bind_info.bindmap[i] = HYDU_bind_info.topology[j].processor_id;
+ break;
+ }
+ }
+ }
+ }
+ else {
+ /* If no binding is supported, we just set all mappings to -1 */
+ HYDU_MALLOC(HYDU_bind_info.bindmap, int *, sizeof(int), status);
+ HYDU_bind_info.num_procs = 1;
+ HYDU_bind_info.bindmap[0] = -1;
+ }
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+void HYDU_bind_finalize(void)
+{
+ if (HYDU_bind_info.bindmap)
+ HYDU_FREE(HYDU_bind_info.bindmap);
+
+ if (HYDU_bind_info.bindlib)
+ HYDU_FREE(HYDU_bind_info.bindlib);
+
+ if (HYDU_bind_info.topology)
+ HYDU_FREE(HYDU_bind_info.topology);
+}
+
+HYD_Status HYDU_bind_process(int core)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+#if defined HAVE_PLPA
+ if (!strcmp(HYDU_bind_info.bindlib, "plpa")) {
+ status = HYDU_bind_plpa_process(core);
+ HYDU_ERR_POP(status, "PLPA failure binding process to core\n");
+ }
+#endif /* HAVE_PLPA */
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+
+int HYDU_bind_get_core_id(int id)
+{
+ return HYDU_bind_info.bindmap[id % HYDU_bind_info.num_procs];
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bind/bind.h (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/bind.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/bind.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/bind.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,45 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef BIND_H_INCLUDED
+#define BIND_H_INCLUDED
+
+#include "hydra_utils.h"
+
+typedef enum {
+ HYDU_BIND_NONE = 0,
+ HYDU_BIND_BASIC,
+ HYDU_BIND_TOPO
+} HYDU_bind_support_level_t;
+
+struct HYDU_bind_info {
+ HYDU_bind_support_level_t support_level;
+
+ int num_procs;
+ int num_sockets;
+ int num_cores;
+ int num_threads;
+
+ int *bindmap;
+ char *bindlib;
+
+ struct HYDU_topology {
+ int processor_id;
+
+ int socket_rank;
+ int socket_id;
+
+ int core_rank;
+ int core_id;
+
+ int thread_rank;
+ int thread_id;
+ } *topology;
+};
+
+extern struct HYDU_bind_info HYDU_bind_info;
+
+#endif /* BIND_H_INCLUDED */
Copied: mpich2/trunk/src/pm/hydra/tools/bind/plpa/Makefile.mk (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/plpa/Makefile.mk)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/plpa/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/plpa/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,9 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+libhydra_a_SOURCES += $(top_srcdir)/tools/bind/plpa/bind_plpa.c
+
+include $(top_srcdir)/tools/bind/plpa/plpa/Makefile.mk
Copied: mpich2/trunk/src/pm/hydra/tools/bind/plpa/bind_plpa.c (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/plpa/bind_plpa.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/plpa/bind_plpa.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/plpa/bind_plpa.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,170 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bind.h"
+#include "bind_plpa.h"
+
+struct HYDU_bind_info HYDU_bind_info;
+
+#include "plpa.h"
+#include "plpa_internal.h"
+
+HYD_Status HYDU_bind_plpa_init(HYDU_bind_support_level_t * support_level)
+{
+ PLPA_NAME(api_type_t) p;
+ int ret, i, j, max, id;
+ int processor, sock, core, thread;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ if (!((PLPA_NAME(api_probe) (&p) == 0) && (p == PLPA_NAME_CAPS(PROBE_OK)))) {
+ /* If this failed, we just return without binding */
+ HYDU_Warn_printf("plpa api runtime probe failed\n");
+ goto fn_fail;
+ }
+
+ /* Find the maximum number of processing elements */
+ ret = PLPA_NAME(get_processor_data) (PLPA_NAME_CAPS(COUNT_ONLINE),
+ &HYDU_bind_info.num_procs, &max);
+ if (ret) {
+ /* Unable to get number of processors */
+ HYDU_Warn_printf("plpa get processor data failed\n");
+ goto fn_fail;
+ }
+
+ HYDU_MALLOC(HYDU_bind_info.topology, struct HYDU_topology *,
+ HYDU_bind_info.num_procs * sizeof(struct HYDU_topology), status);
+ for (i = 0; i < HYDU_bind_info.num_procs; i++) {
+ HYDU_bind_info.topology[i].processor_id = -1;
+ HYDU_bind_info.topology[i].socket_rank = -1;
+ HYDU_bind_info.topology[i].socket_id = -1;
+ HYDU_bind_info.topology[i].core_rank = -1;
+ HYDU_bind_info.topology[i].core_id = -1;
+ HYDU_bind_info.topology[i].thread_rank = -1;
+ HYDU_bind_info.topology[i].thread_id = -1;
+ }
+
+ for (i = 0; i < HYDU_bind_info.num_procs; i++) {
+ ret = PLPA_NAME(get_processor_id) (i, PLPA_NAME_CAPS(COUNT_ALL), &processor);
+ if (ret) {
+ /* Unable to get processor ID */
+ HYDU_Warn_printf("plpa get processor id failed\n");
+ if (HYDU_bind_info.topology)
+ HYDU_FREE(HYDU_bind_info.topology);
+ goto fn_fail;
+ }
+ HYDU_bind_info.topology[i].processor_id = processor;
+ }
+
+ /* We have qualified for basic binding support level */
+ *support_level = HYDU_BIND_BASIC;
+
+ /* PLPA only gives information about sockets and cores */
+ ret = PLPA_NAME(get_socket_info) (&HYDU_bind_info.num_sockets, &max);
+ if (ret) {
+ /* Unable to get number of sockets */
+ HYDU_Warn_printf("plpa get socket info failed\n");
+ goto fn_fail;
+ }
+
+ ret = PLPA_NAME(get_core_info) (0, &HYDU_bind_info.num_cores, &max);
+ if (ret) {
+ /* Unable to get number of cores */
+ HYDU_Warn_printf("plpa get core info failed\n");
+ goto fn_fail;
+ }
+
+ HYDU_bind_info.num_threads = HYDU_bind_info.num_procs /
+ (HYDU_bind_info.num_sockets * HYDU_bind_info.num_cores);
+
+ /* Find the socket and core IDs for all processor IDs */
+ for (i = 0; i < HYDU_bind_info.num_procs; i++) {
+ ret = PLPA_NAME(map_to_socket_core) (HYDU_bind_info.topology[i].processor_id,
+ &sock, &core);
+ if (ret) {
+ /* Unable to get number of cores */
+ HYDU_Warn_printf("plpa unable to map socket to core\n");
+ goto fn_fail;
+ }
+
+ HYDU_bind_info.topology[i].socket_id = sock;
+ HYDU_bind_info.topology[i].core_id = core;
+
+ thread = -1;
+ for (j = 0; j < i; j++)
+ if (HYDU_bind_info.topology[j].socket_id == sock &&
+ HYDU_bind_info.topology[j].core_id == core)
+ thread = HYDU_bind_info.topology[j].thread_id;
+ thread++;
+
+ HYDU_bind_info.topology[i].thread_id = thread;
+ HYDU_bind_info.topology[i].thread_rank = thread;
+ }
+
+ /* Find the rank of each socket ID */
+ for (i = 0; i < HYDU_bind_info.num_sockets; i++) {
+ ret = PLPA_NAME(get_socket_id) (i, &id);
+ if (ret) {
+ /* Unable to get socket id */
+ HYDU_Warn_printf("plpa unable to get socket id\n");
+ goto fn_fail;
+ }
+ for (j = 0; j < HYDU_bind_info.num_procs; j++)
+ if (HYDU_bind_info.topology[j].socket_id == id)
+ HYDU_bind_info.topology[j].socket_rank = i;
+ }
+
+ /* Find the rank of each core ID */
+ for (i = 0; i < HYDU_bind_info.num_cores; i++) {
+ ret = PLPA_NAME(get_core_id) (HYDU_bind_info.topology[0].socket_id, i, &id);
+ if (ret) {
+ /* Unable to get socket id */
+ HYDU_Warn_printf("plpa unable to get socket id\n");
+ goto fn_fail;
+ }
+ for (j = 0; j < HYDU_bind_info.num_procs; j++)
+ if (HYDU_bind_info.topology[j].core_id == id)
+ HYDU_bind_info.topology[j].core_rank = i;
+ }
+
+ /* We have qualified for topology-aware binding support level */
+ *support_level = HYDU_BIND_TOPO;
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+HYD_Status HYDU_bind_plpa_process(int core)
+{
+ int ret;
+ PLPA_NAME(cpu_set_t) cpuset;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ /* If the specified core is negative, we just ignore it */
+ if (core < 0)
+ goto fn_exit;
+
+ PLPA_NAME_CAPS(CPU_ZERO) (&cpuset);
+ PLPA_NAME_CAPS(CPU_SET) (core % HYDU_bind_info.num_procs, &cpuset);
+ ret = PLPA_NAME(sched_setaffinity) (0, 1, &cpuset);
+ if (ret)
+ HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "plpa setaffinity failed\n");
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bind/plpa/bind_plpa.h (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/plpa/bind_plpa.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/plpa/bind_plpa.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/plpa/bind_plpa.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,13 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef BIND_PLPA_H_INCLUDED
+#define BIND_PLPA_H_INCLUDED
+
+HYD_Status HYDU_bind_plpa_init(HYDU_bind_support_level_t * support_level);
+HYD_Status HYDU_bind_plpa_process(int core);
+
+#endif /* BIND_PLPA_H_INCLUDED */
Copied: mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/LICENSE (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/LICENSE)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/LICENSE (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/LICENSE 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,57 @@
+Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
+ University Research and Technology
+ Corporation. All rights reserved.
+Copyright (c) 2004-2005 The Regents of the University of California.
+ All rights reserved.
+Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
+
+Portions copyright:
+
+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) 2006, 2007 Advanced Micro Devices, Inc.
+ All rights reserved.
+
+$COPYRIGHT$
+
+Additional copyrights may follow
+
+$HEADER$
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+- Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+- Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer listed
+ in this license in the documentation and/or other materials
+ provided with the distribution.
+
+- Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+The copyright holders provide no reassurances that the source code
+provided does not infringe any patent, copyright, or any other
+intellectual property rights of third parties. The copyright holders
+disclaim any liability to any recipient for claims brought against
+recipient by any third party for infringement of that parties
+intellectual property rights.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Added: mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,12 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+AM_CPPFLAGS += -I$(top_srcdir)/tools/bind/plpa/plpa
+
+libhydra_a_SOURCES += $(top_srcdir)/tools/bind/plpa/plpa/plpa_api_probe.c \
+ $(top_srcdir)/tools/bind/plpa/plpa/plpa_dispatch.c \
+ $(top_srcdir)/tools/bind/plpa/plpa/plpa_map.c \
+ $(top_srcdir)/tools/bind/plpa/plpa/plpa_runtime.c
Copied: mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa.h (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,298 @@
+/* -*- c -*-
+ *
+ * Copyright (c) 2004-2005 The Trustees of Indiana University.
+ * All rights reserved.
+ * Copyright (c) 2004-2005 The Regents of the University of California.
+ * All rights reserved.
+ * Copyright (c) 2006-2008 Cisco, Inc. All rights reserved.
+ * $COPYRIGHT$
+ *
+ * Additional copyrights may follow
+ *
+ * $HEADER$
+ */
+
+/*
+ * Some notes about the declarations and definitions in this file:
+ *
+ * This file is a mix of internal and public declarations.
+ * Applications are warned against using the internal types; they are
+ * subject to change with no warning.
+ *
+ * The PLPA_NAME() and PLPA_NAME_CAPS() macros are used for prefixing
+ * the PLPA type names, enum names, and symbol names when embedding
+ * PLPA. When not embedding, the default prefix is "plpa_" (or
+ * "PLPA_" when using PLPA_NAME_CAPS()). Hence, if you see a
+ * declaration like this:
+ *
+ * int PLPA_NAME(foo)(void);
+ *
+ * It's a function named plpa_foo() that returns an int and takes no
+ * arguments when building PLPA as a standalone library. It's a
+ * function with a different prefix than "plpa_" when the
+ * --enable-included-mode and --with-plpa-symbol-prefix options are
+ * supplied to PLPA's configure script.
+ *
+ * Note that this header file differentiates between a
+ * processor/socket/core ID and a processor/socket/core number. The
+ * "ID" is the integer that is used by Linux to identify that entity.
+ * These integers may or may not be contiguous. The "number" is a
+ * contiguous set of integers starting with 0 and going to (count-1),
+ * where (count) is the number of processors, sockets, and cores
+ * (where the count of cores is dependent upon the socket). Hence,
+ * "number" is a human convenience, and "ID" is the actual Linux
+ * identifier.
+ */
+
+#ifndef PLPA_H
+#define PLPA_H
+
+/* Absolutely must not include <sched.h> here or it will generate
+ conflicts. */
+
+/* For memset() */
+#include <string.h>
+/* For pid_t and size_t */
+#include <sys/types.h>
+
+/***************************************************************************
+ * Internal types
+ ***************************************************************************/
+
+/* If we're building PLPA itself, <plpa_config.h> will have already
+ been included. But <plpa_config.h> is a private header file; it is
+ not installed into $includedir. Hence, applications including
+ <plpa.h> will not have included <plpa_config.h> (this is by
+ design). So include just enough information here to allow us to
+ continue. */
+#ifndef PLPA_CONFIG_H
+/* The PLPA symbol prefix */
+#define PLPA_SYM_PREFIX plpa_
+
+/* The PLPA symbol prefix in all caps */
+#define PLPA_SYM_PREFIX_CAPS PLPA_
+#endif
+
+/* Preprocessors are fun -- the double inderection is unfortunately
+ necessary. */
+#define PLPA_MUNGE_NAME(a, b) PLPA_MUNGE_NAME2(a, b)
+#define PLPA_MUNGE_NAME2(a, b) a ## b
+#define PLPA_NAME(name) PLPA_MUNGE_NAME(PLPA_SYM_PREFIX, name)
+#define PLPA_NAME_CAPS(name) PLPA_MUNGE_NAME(PLPA_SYM_PREFIX_CAPS, name)
+
+/***************************************************************************
+ * Public type
+ ***************************************************************************/
+
+/* Values that can be returned from plpa_api_probe() */
+typedef enum {
+ /* Sentinel value */
+ PLPA_NAME_CAPS(PROBE_UNSET),
+ /* sched_setaffinity syscall available */
+ PLPA_NAME_CAPS(PROBE_OK),
+ /* syscall unavailable/unimplemented */
+ PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED),
+ /* we experienced some strange failure that the user should report */
+ PLPA_NAME_CAPS(PROBE_UNKNOWN)
+} PLPA_NAME(api_type_t);
+
+/***************************************************************************
+ * Internal types
+ ***************************************************************************/
+
+/* Internal PLPA bitmask type. This type should not be used by
+ external applications! */
+typedef unsigned long int PLPA_NAME(bitmask_t);
+#define PLPA_BITMASK_T_NUM_BITS (sizeof(PLPA_NAME(bitmask_t)) * 8)
+#define PLPA_BITMASK_CPU_MAX 1024
+#define PLPA_BITMASK_NUM_ELEMENTS (PLPA_BITMASK_CPU_MAX / PLPA_BITMASK_T_NUM_BITS)
+
+/***************************************************************************
+ * Public type
+ ***************************************************************************/
+
+/* Public type for the PLPA cpu set. */
+typedef struct { PLPA_NAME(bitmask_t) bitmask[PLPA_BITMASK_NUM_ELEMENTS]; } PLPA_NAME(cpu_set_t);
+
+/***************************************************************************
+ * Internal macros
+ ***************************************************************************/
+
+/* Internal macro for identifying the byte in a bitmask array. This
+ macro should not be used by external applications! */
+#define PLPA_CPU_BYTE(num) ((num) / PLPA_BITMASK_T_NUM_BITS)
+
+/* Internal macro for identifying the bit in a bitmask array. This
+ macro should not be used by external applications! */
+#define PLPA_CPU_BIT(num) ((num) % PLPA_BITMASK_T_NUM_BITS)
+
+/***************************************************************************
+ * Public macros
+ ***************************************************************************/
+
+/* Public macro to zero out a PLPA cpu set (analogous to the FD_ZERO()
+ macro; see select(2)). */
+#define PLPA_CPU_ZERO(cpuset) \
+ memset((cpuset), 0, sizeof(PLPA_NAME(cpu_set_t)))
+
+/* Public macro to set a bit in a PLPA cpu set (analogous to the
+ FD_SET() macro; see select(2)). */
+#define PLPA_CPU_SET(num, cpuset) \
+ (cpuset)->bitmask[PLPA_CPU_BYTE(num)] |= ((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))
+
+/* Public macro to clear a bit in a PLPA cpu set (analogous to the
+ FD_CLR() macro; see select(2)). */
+#define PLPA_CPU_CLR(num, cpuset) \
+ (cpuset)->bitmask[PLPA_CPU_BYTE(num)] &= ~((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))
+
+/* Public macro to test if a bit is set in a PLPA cpu set (analogous
+ to the FD_ISSET() macro; see select(2)). */
+#define PLPA_CPU_ISSET(num, cpuset) \
+ (0 != (((cpuset)->bitmask[PLPA_CPU_BYTE(num)]) & ((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))))
+
+/***************************************************************************
+ * Public functions
+ ***************************************************************************/
+
+/* Setup PLPA internals. This function is optional; it will be
+ automatically invoked by all the other API functions if you do not
+ invoke it explicitly. Returns 0 upon success. */
+int PLPA_NAME(init)(void);
+
+/* Check what API is on this machine. If api_type returns
+ PLPA_PROBE_OK, then PLPA can function properly on this machine.
+ Returns 0 upon success. */
+int PLPA_NAME(api_probe)(PLPA_NAME(api_type_t) *api_type);
+
+/* Set processor affinity. Use the PLPA_CPU_* macros to set the
+ cpuset value. The same rules and restrictions about pid apply as
+ they do for the sched_setaffinity(2) system call. Bits set in the
+ CPU mask correspond to Linux processor IDs. Returns 0 upon
+ success. */
+int PLPA_NAME(sched_setaffinity)(pid_t pid, size_t cpusetsize,
+ const PLPA_NAME(cpu_set_t) *cpuset);
+
+/* Get processor affinity. Use the PLPA_CPU_* macros to analyze the
+ returned value of cpuset. The same rules and restrictions about
+ pid apply as they do for the sched_getaffinity(2) system call.
+ Bits set in the CPU mask corresopnd to Linux processor IDs.
+ Returns 0 upon success. */
+int PLPA_NAME(sched_getaffinity)(pid_t pid, size_t cpusetsize,
+ PLPA_NAME(cpu_set_t) *cpuset);
+
+/* Return whether topology information is available (i.e.,
+ plpa_map_to_*, plpa_max_*). The topology functions will be
+ available if supported == 1 and the function returns 0. */
+int PLPA_NAME(have_topology_information)(int *supported);
+
+/* Map (socket_id,core_id) tuple to virtual processor ID. processor_id is
+ then suitable for use with the PLPA_CPU_* macros, probably leading
+ to a call to plpa_sched_setaffinity(). Returns 0 upon success. */
+int PLPA_NAME(map_to_processor_id)(int socket_id, int core_id,
+ int *processor_id);
+
+/* Map processor_id to (socket_id,core_id) tuple. The processor_id input is
+ usually obtained from the return from the plpa_sched_getaffinity()
+ call, using PLPA_CPU_ISSET to find individual bits in the map that
+ were set/unset. plpa_map_to_socket_core() can map the bit indexes
+ to a socket/core tuple. Returns 0 upon success. */
+int PLPA_NAME(map_to_socket_core)(int processor_id,
+ int *socket_id, int *core_id);
+
+/* This function is deprecated and will disappear in a future release.
+ It is exactly equivalent to calling
+ plpa_get_processor_data(PLPA_COUNT_ALL, num_processors,
+ max_processor_id). */
+int PLPA_NAME(get_processor_info)(int *num_processors, int *max_processor_id);
+
+/* Typedefs for specifying which processors / sockets / cores to count
+ in get_processor_data() and get_processor_id() */
+typedef enum {
+ /* Only count online processors */
+ PLPA_NAME_CAPS(COUNT_ONLINE),
+ /* Only count offline processors */
+ PLPA_NAME_CAPS(COUNT_OFFLINE),
+ /* Count all processors (online and offline) */
+ PLPA_NAME_CAPS(COUNT_ALL)
+} PLPA_NAME(count_specification_t);
+
+/* Returns both the number of processors in a system and the maximum
+ Linux virtual processor ID (because it may be higher than the
+ number of processors if there are "holes" in the available Linux
+ virtual processor IDs). The count_spec argument specifies whether
+ to count all processors, only online processors, or only offline
+ processors. Returns 0 upon success. */
+int PLPA_NAME(get_processor_data)(PLPA_NAME(count_specification_t) count_spec,
+ int *num_processors, int *max_processor_id);
+
+/* Returns the Linux processor ID for the Nth processor. For example,
+ if the Linux processor IDs have "holes", use this function to say
+ "give me the Linux processor ID of the 4th processor." count_spec
+ specifies whether to count online, offline, or all processors when
+ looking for the processor_num'th processor. Returns 0 upon
+ success. */
+int PLPA_NAME(get_processor_id)(int processor_num,
+ PLPA_NAME(count_specification_t) count_spec,
+ int *processor_id);
+
+/* Check to see if a given Linux processor ID exists / is online.
+ Returns 0 on success. */
+int PLPA_NAME(get_processor_flags)(int processor_id, int *exists, int *online);
+
+/* Returns both the number of sockets in the system and the maximum
+ socket ID number (in case there are "holes" in the list of available
+ socket IDs). Returns 0 upon sucess. */
+int PLPA_NAME(get_socket_info)(int *num_sockets, int *max_socket_id);
+
+/* Returns the Linux socket ID for the Nth socket. For example, if
+ the socket IDs have "holes", use this function to say "give me the
+ Linux socket ID of the 2nd socket." Linux does not specify the
+ socket/core tuple information for offline processors, so a
+ plpa_count_specification_t parameter is not used here. Returns 0
+ upon success. */
+int PLPA_NAME(get_socket_id)(int socket_num, int *socket_id);
+
+/* Return both the number of cores and the max code ID for a given
+ socket (in case there are "holes" in the list of available core
+ IDs). Returns 0 upon success. */
+int PLPA_NAME(get_core_info)(int socket_id, int *num_cores, int *max_core_id);
+
+/* Given a specific socket, returns the Linux core ID for the Nth
+ core. For example, if the core IDs have "holes", use this function
+ to say "give me the Linux core ID of the 4th core on socket ID 7."
+ Linux does not specify the socket/core tuple information for
+ offline processors, so a plpa_count_specification_t parameter is
+ not used here. Returns 0 upon success. Returns 0 upon success. */
+int PLPA_NAME(get_core_id)(int socket_id, int core_num, int *core_id);
+
+/* Check to see if a given Linux (socket_id,core_id) tuple exists / is
+ online. Returns 0 on success. */
+int PLPA_NAME(get_core_flags)(int socket_id, int core_id,
+ int *exists, int *online);
+
+/* Typedefs for specifying the cache behavior via
+ plpa_set_cache_behavior() */
+typedef enum {
+ /* Use the cache (default behavior); fills the cache right now if
+ it's not already full */
+ PLPA_NAME_CAPS(CACHE_USE),
+ /* Never use the cache; always look up the information in
+ the kernel */
+ PLPA_NAME_CAPS(CACHE_IGNORE),
+ /* Refresh the cache right now */
+ PLPA_NAME_CAPS(CACHE_REFRESH)
+} PLPA_NAME(cache_behavior_t);
+
+/* Set PLPA's cache behavior. Returns 0 upon success. */
+int PLPA_NAME(set_cache_behavior)(PLPA_NAME(cache_behavior_t));
+
+/* Shut down PLPA. This function releases resources used by the PLPA.
+ It should be the last PLPA function invoked, or can be used to
+ forcibly cause PLPA to dump its topology cache and re-analyze the
+ underlying system the next time another PLPA function is called.
+ Specifically: it is safe to call plpa_init() (or any other PLPA
+ function) again after plpa_finalized(). Returns 0 upon success. */
+int PLPA_NAME(finalize)(void);
+
+#endif /* PLPA_H */
+
Copied: mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_api_probe.c (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_api_probe.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_api_probe.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_api_probe.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,89 @@
+/* -*- c -*-
+ *
+ * Copyright (c) 2004-2005 The Trustees of Indiana University.
+ * All rights reserved.
+ * Copyright (c) 2004-2005 The Regents of the University of California.
+ * All rights reserved.
+ * Copyright (c) 2007-2008 Cisco, Inc. All rights reserved.
+ * $COPYRIGHT$
+ *
+ * Additional copyrights may follow
+ *
+ * $HEADER$
+ */
+
+#include "plpa.h"
+#include "plpa_internal.h"
+
+#include <errno.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+/* Cache, just to make things a little more efficient */
+static PLPA_NAME(api_type_t) cache = PLPA_NAME_CAPS(PROBE_UNSET);
+
+/* The len value we find - not in public header, but used by the lib */
+size_t PLPA_NAME(len) = 0;
+
+int PLPA_NAME(api_probe_init)(void)
+{
+ PLPA_NAME(cpu_set_t) mask;
+ int rc;
+ size_t len;
+
+ for (len = sizeof(mask); len != 0; len >>= 1) {
+ rc = syscall(__NR_sched_getaffinity, 0, len, &mask);
+ if (rc >= 0) {
+ /* OK, kernel is happy with a get(). Validate w/ a set(). */
+ /* Note that kernel may have told us the "proper" size */
+ size_t tmp = (0 != rc) ? ((size_t) rc) : len;
+ /* Pass mask=NULL, expect errno==EFAULT if tmp was OK
+ as a length */
+ rc = syscall(__NR_sched_setaffinity, 0, tmp, NULL);
+ if ((rc < 0) && (errno == EFAULT)) {
+ cache = PLPA_NAME_CAPS(PROBE_OK);
+ PLPA_NAME(len) = tmp;
+ rc = 0;
+ break;
+ }
+ }
+ if (errno == ENOSYS) {
+ break; /* No point in looping */
+ }
+ }
+
+ if (rc >= 0) {
+ /* OK */
+ } else if (errno == ENOSYS) {
+ /* Kernel returns ENOSYS because there is no support for
+ processor affinity */
+ cache = PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED);
+ } else {
+ /* Unknown! */
+ cache = PLPA_NAME_CAPS(PROBE_UNKNOWN);
+ }
+
+ return 0;
+}
+
+
+int PLPA_NAME(api_probe)(PLPA_NAME(api_type_t) *api_type)
+{
+ int ret;
+
+ /* Check to see that we're initialized */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == api_type) {
+ return EINVAL;
+ }
+
+ /* All done */
+ *api_type = cache;
+ return 0;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_dispatch.c (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_dispatch.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_dispatch.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_dispatch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,192 @@
+/* -*- c -*-
+ *
+ * Copyright (c) 2004-2006 The Trustees of Indiana University.
+ * All rights reserved.
+ * Copyright (c) 2004-2005 The Regents of the University of California.
+ * All rights reserved.
+ * Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
+ * $COPYRIGHT$
+ *
+ * Additional copyrights may follow
+ *
+ * $HEADER$
+ */
+
+#include "plpa.h"
+#include "plpa_internal.h"
+
+#include <errno.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+/**
+ * Call the kernel's setaffinity, massaging the user's input
+ * parameters as necessary
+ */
+int PLPA_NAME(sched_setaffinity)(pid_t pid, size_t cpusetsize,
+ const PLPA_NAME(cpu_set_t) *cpuset)
+{
+ int ret;
+ size_t i;
+ PLPA_NAME(cpu_set_t) tmp;
+ PLPA_NAME(api_type_t) api;
+
+ /* Check to see that we're initialized */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == cpuset) {
+ return EINVAL;
+ }
+
+ /* Probe the API type */
+ if (0 != (ret = PLPA_NAME(api_probe)(&api))) {
+ return ret;
+ }
+ switch (api) {
+ case PLPA_NAME_CAPS(PROBE_OK):
+ /* This shouldn't happen, but check anyway */
+ if (cpusetsize > sizeof(*cpuset)) {
+ return EINVAL;
+ }
+
+ /* If the user-supplied bitmask is smaller than what the
+ kernel wants, zero out a temporary buffer of the size that
+ the kernel wants and copy the user-supplied bitmask to the
+ lower part of the temporary buffer. This could be done
+ more efficiently, but we're looking for clarity/simplicity
+ of code here -- this is not intended to be
+ performance-critical. */
+ if (cpusetsize < PLPA_NAME(len)) {
+ memset(&tmp, 0, sizeof(tmp));
+ for (i = 0; i < cpusetsize * 8; ++i) {
+ if (PLPA_CPU_ISSET(i, cpuset)) {
+ PLPA_CPU_SET(i, &tmp);
+ }
+ }
+ }
+
+ /* If the user-supplied bitmask is larger than what the kernel
+ will accept, scan it and see if there are any set bits in
+ the part larger than what the kernel will accept. If so,
+ return EINVAL. Otherwise, copy the part that the kernel
+ will accept into a temporary and use that. Again,
+ efficinency is not the issue of this code -- clarity is. */
+ else if (cpusetsize > PLPA_NAME(len)) {
+ for (i = PLPA_NAME(len) * 8; i < cpusetsize * 8; ++i) {
+ if (PLPA_CPU_ISSET(i, cpuset)) {
+ return EINVAL;
+ }
+ }
+ /* No upper-level bits are set, so now copy over the bits
+ that the kernel will look at */
+ memset(&tmp, 0, sizeof(tmp));
+ for (i = 0; i < PLPA_NAME(len) * 8; ++i) {
+ if (PLPA_CPU_ISSET(i, cpuset)) {
+ PLPA_CPU_SET(i, &tmp);
+ }
+ }
+ }
+
+ /* Otherwise, the user supplied a buffer that is exactly the
+ right size. Just for clarity of code, copy the user's
+ buffer into the temporary and use that. */
+ else {
+ memcpy(&tmp, cpuset, cpusetsize);
+ }
+
+ /* Now do the syscall */
+ ret = syscall(__NR_sched_setaffinity, pid, PLPA_NAME(len), &tmp);
+
+ /* Return 0 upon success. According to
+ http://www.open-mpi.org/community/lists/plpa-users/2006/02/0016.php,
+ all the kernel implementations return >= 0 upon success. */
+ return (ret >= 0) ? 0 : ret;
+ break;
+
+ case PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED):
+ /* Process affinity not supported here */
+ return ENOSYS;
+ break;
+
+ default:
+ /* Something went wrong */
+ /* JMS: would be good to have something other than EINVAL here
+ -- suggestions? */
+ return EINVAL;
+ break;
+ }
+}
+
+
+/**
+ * Call the kernel's getaffinity, massaging the user's input
+ * parameters as necessary
+ */
+int PLPA_NAME(sched_getaffinity)(pid_t pid, size_t cpusetsize,
+ PLPA_NAME(cpu_set_t) *cpuset)
+{
+ int ret;
+ PLPA_NAME(api_type_t) api;
+
+ /* Check to see that we're initialized */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == cpuset) {
+ return EINVAL;
+ }
+ /* Probe the API type */
+ if (0 != (ret = PLPA_NAME(api_probe)(&api))) {
+ return ret;
+ }
+ switch (api) {
+ case PLPA_NAME_CAPS(PROBE_OK):
+ /* This shouldn't happen, but check anyway */
+ if (PLPA_NAME(len) > sizeof(*cpuset)) {
+ return EINVAL;
+ }
+
+ /* If the user supplied a buffer that is too small, then don't
+ even bother */
+ if (cpusetsize < PLPA_NAME(len)) {
+ return EINVAL;
+ }
+
+ /* Now we know that the user's buffer is >= the size required
+ by the kernel. If it's >, then zero it out so that the
+ bits at the top are cleared (since they won't be set by the
+ kernel) */
+ if (cpusetsize > PLPA_NAME(len)) {
+ memset(cpuset, 0, cpusetsize);
+ }
+
+ /* Now do the syscall */
+ ret = syscall(__NR_sched_getaffinity, pid, PLPA_NAME(len), cpuset);
+
+ /* Return 0 upon success. According to
+ http://www.open-mpi.org/community/lists/plpa-users/2006/02/0016.php,
+ all the kernel implementations return >= 0 upon success. */
+ return (ret >= 0) ? 0 : ret;
+ break;
+
+ case PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED):
+ /* Process affinity not supported here */
+ return ENOSYS;
+ break;
+
+ default:
+ /* Something went wrong */
+ return EINVAL;
+ break;
+ }
+}
+
Copied: mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_internal.h (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_internal.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_internal.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_internal.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,30 @@
+/* -*- c -*-
+ *
+ * Copyright (c) 2004-2005 The Trustees of Indiana University.
+ * All rights reserved.
+ * Copyright (c) 2004-2005 The Regents of the University of California.
+ * All rights reserved.
+ * Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
+ * $COPYRIGHT$
+ *
+ * Additional copyrights may follow
+ *
+ * $HEADER$
+ */
+
+#ifndef PLPA_INTERNAL_H
+#define PLPA_INTERNAL_H
+
+#include <plpa.h>
+
+/* Have we initialized yet? */
+extern int PLPA_NAME(initialized);
+
+/* Cached size of the affinity buffers that the kernel expects */
+extern size_t PLPA_NAME(len);
+
+/* Setup API type */
+int PLPA_NAME(api_probe_init)(void);
+
+#endif /* PLPA_INTERNAL_H */
+
Copied: mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_map.c (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_map.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_map.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_map.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,1066 @@
+/*
+ * Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
+ *
+ * Portions of this file originally contributed by Advanced Micro
+ * Devices, Inc. See notice below.
+ */
+/* ============================================================
+ License Agreement
+
+ Copyright (c) 2006, 2007 Advanced Micro Devices, Inc.
+ All rights reserved.
+
+ Redistribution and use in any form of this material and any product
+ thereof including software in source or binary forms, along with any
+ related documentation, with or without modification ("this material"),
+ is permitted provided that the following conditions are met:
+
+ + Redistributions of source code of any software must retain the above
+ copyright notice and all terms of this license as part of the code.
+
+ + Redistributions in binary form of any software must reproduce the
+ above copyright notice and all terms of this license in any related
+ documentation and/or other materials.
+
+ + Neither the names nor trademarks of Advanced Micro Devices, Inc. or
+ any copyright holders or contributors may be used to endorse or
+ promote products derived from this material without specific prior
+ written permission.
+
+ + Notice about U.S. Government restricted rights: This material is
+ provided with "RESTRICTED RIGHTS." Use, duplication or disclosure by
+ the U.S. Government is subject to the full extent of restrictions set
+ forth in FAR52.227 and DFARS252.227 et seq., or any successor or
+ applicable regulations. Use of this material by the U.S. Government
+ constitutes acknowledgment of the proprietary rights of Advanced Micro
+ Devices, Inc.
+ and any copyright holders and contributors.
+
+ + In no event shall anyone redistributing or accessing or using this
+ material commence or participate in any arbitration or legal action
+ relating to this material against Advanced Micro Devices, Inc. or any
+ copyright holders or contributors. The foregoing shall survive any
+ expiration or termination of this license or any agreement or access
+ or use related to this material.
+
+ + ANY BREACH OF ANY TERM OF THIS LICENSE SHALL RESULT IN THE IMMEDIATE
+ REVOCATION OF ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE THIS MATERIAL.
+
+ THIS MATERIAL IS PROVIDED BY ADVANCED MICRO DEVICES, INC. AND ANY
+ COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" IN ITS CURRENT CONDITION
+ AND WITHOUT ANY REPRESENTATIONS, GUARANTEE, OR WARRANTY OF ANY KIND OR
+ IN ANY WAY RELATED TO SUPPORT, INDEMNITY, ERROR FREE OR UNINTERRUPTED
+ OPERATION, OR THAT IT IS FREE FROM DEFECTS OR VIRUSES. ALL
+ OBLIGATIONS ARE HEREBY DISCLAIMED - WHETHER EXPRESS, IMPLIED, OR
+ STATUTORY - INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+ TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, ACCURACY,
+ COMPLETENESS, OPERABILITY, QUALITY OF SERVICE, OR NON-INFRINGEMENT. IN
+ NO EVENT SHALL ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS
+ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, PUNITIVE, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, REVENUE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED OR BASED ON ANY THEORY OF LIABILITY ARISING IN ANY WAY RELATED
+ TO THIS MATERIAL, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ THE ENTIRE AND AGGREGATE LIABILITY OF ADVANCED MICRO DEVICES, INC. AND
+ ANY COPYRIGHT HOLDERS AND CONTRIBUTORS SHALL NOT EXCEED TEN DOLLARS
+ (US $10.00). ANYONE REDISTRIBUTING OR ACCESSING OR USING THIS MATERIAL
+ ACCEPTS THIS ALLOCATION OF RISK AND AGREES TO RELEASE ADVANCED MICRO
+ DEVICES, INC. AND ANY COPYRIGHT HOLDERS AND CONTRIBUTORS FROM ANY AND
+ ALL LIABILITIES, OBLIGATIONS, CLAIMS, OR DEMANDS IN EXCESS OF TEN
+ DOLLARS (US $10.00). THE FOREGOING ARE ESSENTIAL TERMS OF THIS LICENSE
+ AND, IF ANY OF THESE TERMS ARE CONSTRUED AS UNENFORCEABLE, FAIL IN
+ ESSENTIAL PURPOSE, OR BECOME VOID OR DETRIMENTAL TO ADVANCED MICRO
+ DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR CONTRIBUTORS FOR ANY REASON,
+ THEN ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE THIS MATERIAL SHALL
+ TERMINATE IMMEDIATELY. MOREOVER, THE FOREGOING SHALL SURVIVE ANY
+ EXPIRATION OR TERMINATION OF THIS LICENSE OR ANY AGREEMENT OR ACCESS
+ OR USE RELATED TO THIS MATERIAL.
+
+ NOTICE IS HEREBY PROVIDED, AND BY REDISTRIBUTING OR ACCESSING OR USING
+ THIS MATERIAL SUCH NOTICE IS ACKNOWLEDGED, THAT THIS MATERIAL MAY BE
+ SUBJECT TO RESTRICTIONS UNDER THE LAWS AND REGULATIONS OF THE UNITED
+ STATES OR OTHER COUNTRIES, WHICH INCLUDE BUT ARE NOT LIMITED TO, U.S.
+ EXPORT CONTROL LAWS SUCH AS THE EXPORT ADMINISTRATION REGULATIONS AND
+ NATIONAL SECURITY CONTROLS AS DEFINED THEREUNDER, AS WELL AS STATE
+ DEPARTMENT CONTROLS UNDER THE U.S. MUNITIONS LIST. THIS MATERIAL MAY
+ NOT BE USED, RELEASED, TRANSFERRED, IMPORTED, EXPORTED AND/OR RE-
+ EXPORTED IN ANY MANNER PROHIBITED UNDER ANY APPLICABLE LAWS, INCLUDING
+ U.S. EXPORT CONTROL LAWS REGARDING SPECIFICALLY DESIGNATED PERSONS,
+ COUNTRIES AND NATIONALS OF COUNTRIES SUBJECT TO NATIONAL SECURITY
+ CONTROLS.
+ MOREOVER,
+ THE FOREGOING SHALL SURVIVE ANY EXPIRATION OR TERMINATION OF ANY
+ LICENSE OR AGREEMENT OR ACCESS OR USE RELATED TO THIS MATERIAL.
+
+ This license forms the entire agreement regarding the subject matter
+ hereof and supersedes all proposals and prior discussions and writings
+ between the parties with respect thereto. This license does not affect
+ any ownership, rights, title, or interest in, or relating to, this
+ material. No terms of this license can be modified or waived, and no
+ breach of this license can be excused, unless done so in a writing
+ signed by all affected parties. Each term of this license is
+ separately enforceable. If any term of this license is determined to
+ be or becomes unenforceable or illegal, such term shall be reformed to
+ the minimum extent necessary in order for this license to remain in
+ effect in accordance with its terms as modified by such reformation.
+ This license shall be governed by and construed in accordance with the
+ laws of the State of Texas without regard to rules on conflicts of law
+ of any state or jurisdiction or the United Nations Convention on the
+ International Sale of Goods. All disputes arising out of this license
+ shall be subject to the jurisdiction of the federal and state courts
+ in Austin, Texas, and all defenses are hereby waived concerning
+ personal jurisdiction and venue of these courts.
+ ============================================================ */
+
+#include "plpa.h"
+#include "plpa_internal.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <limits.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+typedef struct tuple_t_ {
+ int processor_id, socket_id, core_id, online;
+} tuple_t;
+
+static const char *sysfs_mount = "/sys";
+static int supported = 0;
+static int num_processors = -1;
+static int max_processor_id = -1;
+static int num_sockets = -1;
+static int max_socket_id = -1;
+static int *max_core_id = NULL;
+static int *num_cores = NULL;
+static int max_core_id_overall = -1;
+static tuple_t *map_processor_id_to_tuple = NULL;
+static tuple_t **map_tuple_to_processor_id = NULL;
+static PLPA_NAME(cache_behavior_t) cache_behavior = PLPA_NAME_CAPS(CACHE_IGNORE);
+
+static void clear_cache(void)
+{
+ if (NULL != max_core_id) {
+ free(max_core_id);
+ max_core_id = NULL;
+ }
+ if (NULL != num_cores) {
+ free(num_cores);
+ num_cores = NULL;
+ }
+ if (NULL != map_processor_id_to_tuple) {
+ free(map_processor_id_to_tuple);
+ map_processor_id_to_tuple = NULL;
+ }
+ if (NULL != map_tuple_to_processor_id) {
+ free(map_tuple_to_processor_id);
+ map_tuple_to_processor_id = NULL;
+ }
+
+ num_processors = max_processor_id = -1;
+ num_sockets = max_socket_id = -1;
+ max_core_id_overall = -1;
+}
+
+static void load_cache(void)
+{
+ int i, j, k, invalid_entry, fd, found_online;
+ char path[PATH_MAX], buf[8];
+ PLPA_NAME(cpu_set_t) valid_processors;
+ PLPA_NAME(cpu_set_t) *cores_on_sockets;
+ int found;
+ DIR *dir;
+ struct dirent dentry, *dentryp = NULL;
+
+#if PLPA_DEBUG
+ char *temp = getenv("PLPA_SYSFS_MOUNT");
+ if (temp) {
+ sysfs_mount = temp;
+ }
+#endif
+
+ /* Check for the parent directory */
+ sprintf(path, "%s/devices/system/cpu", sysfs_mount);
+ if (access(path, R_OK|X_OK)) {
+ return;
+ }
+
+ dir = opendir(path);
+ if (NULL == dir) {
+ return;
+ }
+
+ /* Catch all entries of format "cpu%d", count them and maintain
+ max_processor_id */
+ num_processors = 0;
+ PLPA_CPU_ZERO(&valid_processors);
+ do {
+ int ret = readdir_r(dir, &dentry, &dentryp);
+ if (0 != ret) {
+ closedir(dir);
+ clear_cache();
+ return;
+ }
+
+ if (dentryp) {
+ int cpuid;
+
+ ret = sscanf(dentryp->d_name, "cpu%d", &cpuid);
+ if (1 == ret) {
+ ++num_processors;
+ if (cpuid >= PLPA_BITMASK_CPU_MAX) {
+ closedir(dir);
+ clear_cache();
+ return;
+ } else if (cpuid > max_processor_id) {
+ max_processor_id = cpuid;
+ }
+ PLPA_CPU_SET(cpuid, &valid_processors);
+ }
+ }
+ } while (NULL != dentryp);
+ closedir(dir);
+
+ /* If we found no processors, then we have no topology info */
+ if (0 == num_processors) {
+ clear_cache();
+ return;
+ }
+
+ /* Malloc space for the first map (processor ID -> tuple).
+ Include enough space for one invalid entry. */
+ map_processor_id_to_tuple = malloc(sizeof(tuple_t) *
+ (max_processor_id + 2));
+ if (NULL == map_processor_id_to_tuple) {
+ clear_cache();
+ return;
+ }
+ for (i = 0; i <= max_processor_id; ++i) {
+ if (PLPA_CPU_ISSET(i, &valid_processors)) {
+ map_processor_id_to_tuple[i].processor_id = i;
+ } else {
+ map_processor_id_to_tuple[i].processor_id = -1;
+ }
+ map_processor_id_to_tuple[i].socket_id = -1;
+ map_processor_id_to_tuple[i].core_id = -1;
+ }
+ /* Set the invalid entry */
+ invalid_entry = i;
+ map_processor_id_to_tuple[invalid_entry].processor_id = -1;
+ map_processor_id_to_tuple[invalid_entry].socket_id = -1;
+ map_processor_id_to_tuple[invalid_entry].core_id = -1;
+
+ /* Build a cached map of (socket,core) tuples */
+ for (found = 0, i = 0; i <= max_processor_id; ++i) {
+
+ /* Check for invalid processor ID */
+ if (map_processor_id_to_tuple[i].processor_id < 0) {
+ continue;
+ }
+
+ /* Read the "online" state for this processor. If the online
+ file is not there, then the kernel likely doesn't have
+ hotplug support so just assume that it's online. Some notes:
+
+ - the perms on the "online" file are root/600, so only root
+ will see this info
+ - if online is 0, then all the topology files disappear (!)
+ -- so PLPA needs to compensate for that
+ */
+ found_online = 0;
+ sprintf(path, "%s/devices/system/cpu/cpu%d/online",
+ sysfs_mount, i);
+ fd = open(path, O_RDONLY);
+ memset(buf, 0, sizeof(buf));
+ if (fd >= 0 && read(fd, buf, sizeof(buf) - 1) > 0) {
+ found_online = 1;
+ sscanf(buf, "%d", &(map_processor_id_to_tuple[i].online));
+ } else {
+ map_processor_id_to_tuple[i].online = 1;
+ }
+ if (fd >= 0) {
+ close(fd);
+ }
+
+ /* Core ID */
+ sprintf(path, "%s/devices/system/cpu/cpu%d/topology/core_id",
+ sysfs_mount, i);
+ fd = open(path, O_RDONLY);
+ if (fd >= 0) {
+ memset(buf, 0, sizeof(buf));
+ if (read(fd, buf, sizeof(buf) - 1) > 0) {
+ sscanf(buf, "%d", &(map_processor_id_to_tuple[i].core_id));
+ } else {
+ map_processor_id_to_tuple[i].core_id = -1;
+ }
+ close(fd);
+ }
+ /* Special case: we didn't find the core_id file, but we *did*
+ find the online file and the processor is offline -- then
+ just mark the core ID as "unknown" and keep going (because
+ if a processor is offline, the core_id file won't exist --
+ grumble) */
+ else if (found_online && 0 == map_processor_id_to_tuple[i].online) {
+ map_processor_id_to_tuple[i].core_id = -1;
+ }
+
+ /* Socket ID */
+ sprintf(path,
+ "%s/devices/system/cpu/cpu%d/topology/physical_package_id",
+ sysfs_mount, i);
+ fd = open(path, O_RDONLY);
+ if (fd >= 0) {
+ memset(buf, 0, sizeof(buf));
+ if (read(fd, buf, sizeof(buf) - 1) > 0) {
+ sscanf(buf, "%d", &(map_processor_id_to_tuple[i].socket_id));
+ }
+ close(fd);
+ found = 1;
+ }
+ /* Special case: we didn't find the socket_id file, but we
+ *did* find the online file and the processor is offline --
+ then just mark the socket ID as "unknown" and keep going
+ (because if a processor is offline, the socket_id file won't
+ exist -- grumble) */
+ else if (found_online && 0 == map_processor_id_to_tuple[i].online) {
+ map_processor_id_to_tuple[i].socket_id = -1;
+ }
+
+ /* Keep a running tab on the max socket number */
+ if (map_processor_id_to_tuple[i].socket_id > max_socket_id) {
+ max_socket_id = map_processor_id_to_tuple[i].socket_id;
+ }
+ }
+
+ /* If we didn't find any core_id/physical_package_id's, then we
+ don't have the topology info */
+ if (!found) {
+ clear_cache();
+ return;
+ }
+
+ /* Now that we know the max number of sockets, allocate some
+ arrays */
+ max_core_id = malloc(sizeof(int) * (max_socket_id + 1));
+ if (NULL == max_core_id) {
+ clear_cache();
+ return;
+ }
+ num_cores = malloc(sizeof(int) * (max_socket_id + 1));
+ if (NULL == num_cores) {
+ clear_cache();
+ return;
+ }
+ for (i = 0; i <= max_socket_id; ++i) {
+ num_cores[i] = -1;
+ max_core_id[i] = -1;
+ }
+
+ /* Find the max core number on each socket */
+ for (i = 0; i <= max_processor_id; ++i) {
+ if (map_processor_id_to_tuple[i].processor_id < 0 ||
+ map_processor_id_to_tuple[i].socket_id < 0) {
+ continue;
+ }
+ if (map_processor_id_to_tuple[i].core_id >
+ max_core_id[map_processor_id_to_tuple[i].socket_id]) {
+ max_core_id[map_processor_id_to_tuple[i].socket_id] =
+ map_processor_id_to_tuple[i].core_id;
+ }
+ if (max_core_id[map_processor_id_to_tuple[i].socket_id] >
+ max_core_id_overall) {
+ max_core_id_overall =
+ max_core_id[map_processor_id_to_tuple[i].socket_id];
+ }
+ }
+
+ /* Go through and count the number of unique sockets found. It
+ may not be the same as max_socket_id because there may be
+ "holes" -- e.g., sockets 0 and 3 are used, but sockets 1 and 2
+ are empty. */
+ for (j = i = 0; i <= max_socket_id; ++i) {
+ if (max_core_id[i] >= 0) {
+ ++j;
+ }
+ }
+ if (j > 0) {
+ num_sockets = j;
+ }
+
+ /* Count how many cores are available on each socket. This may
+ not be the same as max_core_id[socket_num] if there are
+ "holes". I don't know if holes can happen (i.e., if specific
+ cores can be taken offline), but what the heck... */
+ cores_on_sockets = malloc(sizeof(PLPA_NAME(cpu_set_t)) *
+ (max_socket_id + 1));
+ if (NULL == cores_on_sockets) {
+ clear_cache();
+ return;
+ }
+ for (i = 0; i <= max_socket_id; ++i) {
+ PLPA_CPU_ZERO(&(cores_on_sockets[i]));
+ }
+ for (i = 0; i <= max_processor_id; ++i) {
+ if (map_processor_id_to_tuple[i].socket_id >= 0) {
+ PLPA_CPU_SET(map_processor_id_to_tuple[i].core_id,
+ &(cores_on_sockets[map_processor_id_to_tuple[i].socket_id]));
+ }
+ }
+ for (i = 0; i <= max_socket_id; ++i) {
+ int count = 0;
+ for (j = 0; j <= max_core_id[i]; ++j) {
+ if (PLPA_CPU_ISSET(j, &(cores_on_sockets[i]))) {
+ ++count;
+ }
+ }
+ if (count > 0) {
+ num_cores[i] = count;
+ }
+ }
+ free(cores_on_sockets);
+
+ /* Now go through and build the map in the other direction:
+ (socket,core) => processor_id. This map simply points to
+ entries in the other map (i.e., it's by reference instead of by
+ value). */
+ map_tuple_to_processor_id = malloc(sizeof(tuple_t *) *
+ ((max_socket_id + 1) *
+ (max_core_id_overall + 1)));
+ if (NULL == map_tuple_to_processor_id) {
+ clear_cache();
+ return;
+ }
+ /* Compute map */
+ for (i = 0; i <= max_socket_id; ++i) {
+ for (j = 0; j <= max_core_id_overall; ++j) {
+ tuple_t **tuple_ptr = &map_tuple_to_processor_id[
+ i * (max_core_id_overall + 1) + j];
+
+ /* Default to the invalid entry in the other map, meaning
+ that this (socket,core) combination doesn't exist
+ (e.g., the core number does not exist in this socket,
+ although it does exist in other sockets). */
+ *tuple_ptr = &map_processor_id_to_tuple[invalid_entry];
+
+ /* See if this (socket,core) tuple exists in the other
+ map. If so, set this entry to point to it (overriding
+ the invalid entry default). */
+ for (k = 0; k <= max_processor_id; ++k) {
+ if (map_processor_id_to_tuple[k].socket_id == i &&
+ map_processor_id_to_tuple[k].core_id == j) {
+ *tuple_ptr = &map_processor_id_to_tuple[k];
+#if defined(PLPA_DEBUG) && PLPA_DEBUG
+ printf("Creating map [%d]: (socket %d, core %d) -> ID %d\n",
+ i * (max_core_id_overall + 1) + j,
+ i, j, k);
+#endif
+ break;
+ }
+ }
+ }
+ }
+
+ supported = 1;
+}
+
+static int cache_action(void)
+{
+ switch (cache_behavior) {
+ case PLPA_NAME_CAPS(CACHE_USE):
+ if (NULL == map_processor_id_to_tuple) {
+ load_cache();
+ }
+ break;
+
+ case PLPA_NAME_CAPS(CACHE_IGNORE):
+ clear_cache();
+ load_cache();
+ break;
+
+ default:
+ return EINVAL;
+ }
+
+ return 0;
+}
+
+/* Return whether this kernel supports topology information or not */
+int PLPA_NAME(have_topology_information)(int *supported_arg)
+{
+ int ret;
+
+ /* Initialize if not already done so */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == supported_arg) {
+ return EINVAL;
+ }
+
+ *supported_arg = supported;
+ return 0;
+}
+
+int PLPA_NAME(map_to_processor_id)(int socket_id, int core_id,
+ int *processor_id)
+{
+ int ret;
+
+ /* Initialize if not already done so */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* If this system doesn't support mapping, sorry Charlie */
+ if (!supported) {
+ return ENOSYS;
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == processor_id) {
+ return EINVAL;
+ }
+
+ /* Check cache behavior */
+ if (0 != (ret = cache_action())) {
+ return ret;
+ }
+
+ /* Check for some invalid entries */
+ if (socket_id < 0 || socket_id > max_socket_id ||
+ core_id < 0 || core_id > max_core_id[socket_id]) {
+ return ENOENT;
+ }
+ /* If the mapping returns -1, then this is a non-existent
+ socket/core combo (even though they fall within the max socket
+ / max core overall values) */
+ ret = map_tuple_to_processor_id[socket_id * (max_core_id_overall + 1) +
+ core_id]->processor_id;
+ if (-1 == ret) {
+ return ENOENT;
+ }
+
+ /* Ok, all should be good -- return the mapping */
+ *processor_id = ret;
+ return 0;
+}
+
+int PLPA_NAME(map_to_socket_core)(int processor_id,
+ int *socket_id, int *core_id)
+{
+ int ret;
+
+ /* Initialize if not already done so */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* If this system doesn't support mapping, sorry Charlie */
+ if (!supported) {
+ return ENOSYS;
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == socket_id || NULL == core_id) {
+ return EINVAL;
+ }
+
+ /* Check cache behavior */
+ if (0 != (ret = cache_action())) {
+ return ret;
+ }
+
+ /* Check for some invalid entries */
+ if (processor_id < 0 || processor_id > max_processor_id ||
+ map_processor_id_to_tuple[processor_id].processor_id < 0) {
+ return ENOENT;
+ }
+ ret = map_processor_id_to_tuple[processor_id].socket_id;
+ if (-1 == ret) {
+ return ENOENT;
+ }
+
+ /* Ok, all should be good -- return the mapping */
+ *socket_id = ret;
+ *core_id = map_processor_id_to_tuple[processor_id].core_id;
+ return 0;
+}
+
+/* Deprecated function */
+int PLPA_NAME(get_processor_info)(int *num_processors_arg,
+ int *max_processor_id_arg)
+{
+ return PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_ALL),
+ num_processors_arg,
+ max_processor_id_arg);
+}
+
+int PLPA_NAME(get_processor_data)(PLPA_NAME(count_specification_t) count_spec,
+ int *num_processors_arg,
+ int *max_processor_id_arg)
+{
+ int i, ret;
+ bool match;
+
+ /* Initialize if not already done so */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* If this system doesn't support mapping, sorry Charlie */
+ if (!supported) {
+ return ENOSYS;
+ }
+
+ /* Check cache behavior */
+ if (0 != (ret = cache_action())) {
+ return ret;
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == max_processor_id_arg || NULL == num_processors_arg) {
+ return EINVAL;
+ }
+
+ /* If we wanted all processors, we're done */
+ if (PLPA_NAME_CAPS(COUNT_ALL) == count_spec) {
+ *num_processors_arg = num_processors;
+ *max_processor_id_arg = max_processor_id;
+ } else {
+ /* Otherwise, count the appropriate type */
+ *num_processors_arg = 0;
+ *max_processor_id_arg = 0;
+ for (i = 0; i <= max_processor_id; ++i) {
+ if (map_processor_id_to_tuple[i].processor_id >= 0) {
+ match = false;
+ switch (count_spec) {
+ case PLPA_NAME_CAPS(COUNT_ONLINE):
+ if (map_processor_id_to_tuple[i].online) {
+ match = true;
+ }
+ break;
+
+ case PLPA_NAME_CAPS(COUNT_OFFLINE):
+ if (!map_processor_id_to_tuple[i].online) {
+ match = true;
+ }
+ break;
+ default:
+ /* Just so that compilers don't complain */
+ break;
+ }
+ if (match) {
+ ++(*num_processors_arg);
+ if (*max_processor_id_arg <
+ map_processor_id_to_tuple[i].processor_id) {
+ *max_processor_id_arg =
+ map_processor_id_to_tuple[i].processor_id;
+ }
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+/* Returns the Linux processor ID for the Nth processor (starting with
+ 0). */
+int PLPA_NAME(get_processor_id)(int processor_num,
+ PLPA_NAME(count_specification_t) count_spec,
+ int *processor_id)
+{
+ int ret, i, count;
+ bool match;
+
+ /* Initialize if not already done so */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* If this system doesn't support mapping, sorry Charlie */
+ if (!supported) {
+ return ENOSYS;
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == processor_id) {
+ return EINVAL;
+ }
+
+ /* Check cache behavior */
+ if (0 != (ret = cache_action())) {
+ return ret;
+ }
+
+ /* Check for out of range params */
+ if (processor_num < 0 || processor_num > num_processors) {
+ return EINVAL;
+ }
+
+ /* Find the processor_num'th processor */
+ for (count = i = 0; i <= max_processor_id; ++i) {
+ if (map_processor_id_to_tuple[i].processor_id >= 0) {
+ match = false;
+ switch (count_spec) {
+ case PLPA_NAME_CAPS(COUNT_ONLINE):
+ if (map_processor_id_to_tuple[i].online) {
+ match = true;
+ }
+ break;
+
+ case PLPA_NAME_CAPS(COUNT_OFFLINE):
+ if (!map_processor_id_to_tuple[i].online) {
+ match = true;
+ }
+ break;
+
+ case PLPA_NAME_CAPS(COUNT_ALL):
+ match = true;
+ break;
+ }
+ if (match) {
+ if (count++ == processor_num) {
+ *processor_id = map_processor_id_to_tuple[i].processor_id;
+ return 0;
+ }
+ }
+ }
+ }
+
+ /* Didn't find it */
+ return ENODEV;
+}
+
+/* Check to see if a given Linux processor ID exists / is online.
+ Returns 0 on success. */
+int PLPA_NAME(get_processor_flags)(int processor_id,
+ int *exists_arg, int *online_arg)
+{
+ int ret, exists, online;
+
+ /* Initialize if not already done so */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* If this system doesn't support mapping, sorry Charlie */
+ if (!supported) {
+ return ENOSYS;
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == exists_arg && NULL == online_arg) {
+ return EINVAL;
+ }
+
+ /* Check cache behavior */
+ if (0 != (ret = cache_action())) {
+ return ret;
+ }
+
+ /* Check for out of range params */
+ if (processor_id < 0 || processor_id > max_processor_id) {
+ return EINVAL;
+ }
+
+ exists = online = 0;
+ if (processor_id == map_processor_id_to_tuple[processor_id].processor_id) {
+ exists = 1;
+ if (map_processor_id_to_tuple[processor_id].online) {
+ online = 1;
+ }
+ }
+ if (NULL != exists_arg) {
+ *exists_arg = exists;
+ }
+ if (NULL != online_arg) {
+ *online_arg = online;
+ }
+
+ return 0;
+}
+
+/* Return the max socket number */
+int PLPA_NAME(get_socket_info)(int *num_sockets_arg, int *max_socket_id_arg)
+{
+ int ret;
+
+ /* Initialize if not already done so */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* If this system doesn't support mapping, sorry Charlie */
+ if (!supported) {
+ return ENOSYS;
+ }
+
+ /* Check cache behavior */
+ if (0 != (ret = cache_action())) {
+ return ret;
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == max_socket_id_arg || NULL == num_sockets_arg) {
+ return EINVAL;
+ }
+
+ /* All done */
+ *num_sockets_arg = num_sockets;
+ *max_socket_id_arg = max_socket_id;
+ return 0;
+}
+
+/* Returns the Linux socket ID for the Nth socket (starting with 0). */
+int PLPA_NAME(get_socket_id)(int socket_num, int *socket_id)
+{
+ int ret, i, j, k, count;
+
+ /* Initialize if not already done so */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* If this system doesn't support mapping, sorry Charlie */
+ if (!supported) {
+ return ENOSYS;
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == socket_id) {
+ return EINVAL;
+ }
+
+ /* Check cache behavior */
+ if (0 != (ret = cache_action())) {
+ return ret;
+ }
+
+ /* Check for out of range params */
+ if (socket_num < 0 || socket_num > num_sockets) {
+ return EINVAL;
+ }
+
+ /* Find the socket_num'th socket */
+ for (count = i = 0; i <= max_socket_id; ++i) {
+ /* See if any core in this socket is active. If so, count
+ this socket */
+ for (j = 0; j <= max_core_id_overall; ++j) {
+ k = i * (max_core_id_overall + 1) + j;
+ if (map_tuple_to_processor_id[k]->processor_id >= 0) {
+ if (count++ == socket_num) {
+ *socket_id = map_tuple_to_processor_id[k]->socket_id;
+ return 0;
+ }
+ /* Ok, we found one -- skip to the end of this socket */
+ j = max_core_id_overall + 1;
+ }
+ }
+ }
+
+ /* Didn't find it */
+ return ENODEV;
+}
+
+/* Return the number of cores in a socket and the max core ID number */
+int PLPA_NAME(get_core_info)(int socket_id, int *num_cores_arg,
+ int *max_core_id_arg)
+{
+ int ret;
+
+ /* Initialize if not already done so */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* If this system doesn't support mapping, sorry Charlie */
+ if (!supported) {
+ return ENOSYS;
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == max_core_id_arg || NULL == num_cores_arg) {
+ return EINVAL;
+ }
+
+ /* Check cache behavior */
+ if (0 != (ret = cache_action())) {
+ return ret;
+ }
+
+ /* Check for some invalid entries */
+ if (socket_id < 0 || socket_id > max_socket_id ||
+ -1 == max_core_id[socket_id]) {
+ return ENOENT;
+ }
+ ret = num_cores[socket_id];
+ if (-1 == ret) {
+ return ENOENT;
+ }
+
+ /* All done */
+ *num_cores_arg = ret;
+ *max_core_id_arg = max_core_id[socket_id];
+ return 0;
+}
+
+/* Given a specific socket, returns the Linux core ID for the Nth core
+ (starting with 0) */
+int PLPA_NAME(get_core_id)(int socket_id, int core_num, int *core_id)
+{
+ int ret, i, j, count;
+
+ /* Initialize if not already done so */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* If this system doesn't support mapping, sorry Charlie */
+ if (!supported) {
+ return ENOSYS;
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == core_id) {
+ return EINVAL;
+ }
+
+ /* Check cache behavior */
+ if (0 != (ret = cache_action())) {
+ return ret;
+ }
+
+ /* Check for out of range params */
+ if (socket_id < 0 || socket_id > max_socket_id ||
+ core_num < 0 || core_num > max_core_id_overall) {
+ return EINVAL;
+ }
+
+ /* Find the core_num'th core */
+ for (count = i = 0, j = socket_id * (max_core_id_overall + 1);
+ i <= max_core_id_overall; ++i) {
+ if (map_tuple_to_processor_id[j + i]->processor_id >= 0) {
+ if (count++ == core_num) {
+ *core_id = map_tuple_to_processor_id[j + i]->core_id;
+ return 0;
+ }
+ }
+ }
+
+ /* Didn't find it */
+ return ENODEV;
+}
+
+/* Check to see if a given Linux (socket_id,core_id) tuple exists / is
+ online. Returns 0 on success. */
+int PLPA_NAME(get_core_flags)(int socket_id, int core_id,
+ int *exists_arg, int *online_arg)
+{
+ int ret, i, exists, online;
+
+ /* Initialize if not already done so */
+ if (!PLPA_NAME(initialized)) {
+ if (0 != (ret = PLPA_NAME(init)())) {
+ return ret;
+ }
+ }
+
+ /* If this system doesn't support mapping, sorry Charlie */
+ if (!supported) {
+ return ENOSYS;
+ }
+
+ /* Check for bozo arguments */
+ if (NULL == exists_arg && NULL == online_arg) {
+ return EINVAL;
+ }
+
+ /* Check cache behavior */
+ if (0 != (ret = cache_action())) {
+ return ret;
+ }
+
+ /* Check for out of range params */
+ if (socket_id < 0 || socket_id > max_socket_id ||
+ core_id < 0 || core_id > max_core_id_overall) {
+ return EINVAL;
+ }
+
+ exists = online = 0;
+ i = socket_id * (max_core_id_overall + 1) + core_id;
+ if (map_tuple_to_processor_id[i]->processor_id >= 0) {
+ exists = 1;
+ if (map_tuple_to_processor_id[i]->online) {
+ online = 1;
+ }
+ }
+
+ if (NULL != exists_arg) {
+ *exists_arg = exists;
+ }
+ if (NULL != online_arg) {
+ *online_arg = online;
+ }
+ return 0;
+}
+
+/* Set PLPA's caching behavior */
+int PLPA_NAME(set_cache_behavior)(PLPA_NAME(cache_behavior_t) behavior)
+{
+ switch (behavior) {
+ case PLPA_NAME_CAPS(CACHE_USE):
+ if (PLPA_NAME_CAPS(CACHE_USE) != cache_behavior) {
+ load_cache();
+ cache_behavior = PLPA_NAME_CAPS(CACHE_USE);
+ }
+ break;
+
+ case PLPA_NAME_CAPS(CACHE_IGNORE):
+ if (PLPA_NAME_CAPS(CACHE_IGNORE) != cache_behavior) {
+ clear_cache();
+ cache_behavior = PLPA_NAME_CAPS(CACHE_IGNORE);
+ }
+ break;
+
+ case PLPA_NAME_CAPS(CACHE_REFRESH):
+ if (PLPA_NAME_CAPS(CACHE_USE) != cache_behavior) {
+ return EINVAL;
+ }
+ clear_cache();
+ load_cache();
+ break;
+
+ default:
+ return EINVAL;
+ }
+
+ return 0;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_runtime.c (from rev 5465, mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_runtime.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_runtime.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bind/plpa/plpa/plpa_runtime.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
+ */
+
+#include "plpa.h"
+#include "plpa_internal.h"
+
+#include <errno.h>
+#include <pthread.h>
+
+/* Global variables */
+int PLPA_NAME(initialized) = 0;
+
+/* Local variables */
+static int refcount = 0;
+static pthread_mutex_t mutex;
+
+
+/* Central clearing point for all parts of PLPA that need to be
+ initialized. It is erroneous to call this function by more than
+ one thread simultaneously. */
+int PLPA_NAME(init)(void)
+{
+ int ret;
+
+ /* If we're already initialized, simply increase the refcount */
+ if (PLPA_NAME(initialized)) {
+ pthread_mutex_lock(&mutex);
+ ++refcount;
+ pthread_mutex_unlock(&mutex);
+ return 0;
+ }
+
+ /* Otherwise, initialize all the sybsystems */
+ if (0 != (ret = pthread_mutex_init(&mutex, NULL)) ||
+ 0 != (ret = PLPA_NAME(api_probe_init)()) ||
+ 0 != (ret = PLPA_NAME(set_cache_behavior)(PLPA_NAME_CAPS(CACHE_USE)))) {
+ return ret;
+ }
+
+ PLPA_NAME(initialized) = 1;
+ refcount = 1;
+ return 0;
+}
+
+
+/* Central clearing point for all parts of PLPA that need to be
+ shutdown. */
+int PLPA_NAME(finalize)(void)
+{
+ int val;
+
+ /* If we're not initialized, return an error */
+ if (!PLPA_NAME(initialized)) {
+ return ENOENT;
+ }
+
+ /* Decrement and check the refcount. If it's nonzero, then simply
+ return success. */
+ pthread_mutex_lock(&mutex);
+ val = --refcount;
+ pthread_mutex_unlock(&mutex);
+ if (0 != val) {
+ return 0;
+ }
+
+ /* Ok, we're the last one. Cleanup. */
+ PLPA_NAME(set_cache_behavior)(PLPA_NAME_CAPS(CACHE_IGNORE));
+ pthread_mutex_destroy(&mutex);
+ PLPA_NAME(initialized) = 0;
+ return 0;
+}
Added: mpich2/trunk/src/pm/hydra/tools/bootstrap/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,26 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+AM_CPPFLAGS += -I$(top_srcdir)/tools/bootstrap/include -I$(top_builddir)/tools/bootstrap/include
+
+include tools/bootstrap/src/Makefile.mk
+include tools/bootstrap/utils/Makefile.mk
+
+if hydra_bss_ssh
+include tools/bootstrap/ssh/Makefile.mk
+endif
+
+if hydra_bss_rsh
+include tools/bootstrap/rsh/Makefile.mk
+endif
+
+if hydra_bss_fork
+include tools/bootstrap/fork/Makefile.mk
+endif
+
+if hydra_bss_slurm
+include tools/bootstrap/slurm/Makefile.mk
+endif
Added: mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,8 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+libhydra_a_SOURCES += $(top_srcdir)/tools/bootstrap/fork/fork_init.c \
+ $(top_srcdir)/tools/bootstrap/fork/fork_launch.c
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork.h (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/fork/fork.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,15 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef FORK_H_INCLUDED
+#define FORK_H_INCLUDED
+
+#include "hydra_base.h"
+
+HYD_Status HYD_BSCD_fork_launch_procs(char **global_args, const char *proxy_id_str,
+ struct HYD_Proxy *proxy_list);
+
+#endif /* FORK_H_INCLUDED */
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork_init.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_init.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork_init.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork_init.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,22 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "fork.h"
+
+HYD_Status HYD_BSCI_fork_init(void)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ HYD_BSCI_fns.launch_procs = HYD_BSCD_fork_launch_procs;
+
+ HYDU_FUNC_EXIT();
+
+ return status;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork_launch.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_launch.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork_launch.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/fork/fork_launch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,60 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+#include "fork.h"
+
+HYD_Status HYD_BSCD_fork_launch_procs(char **global_args, const char *proxy_id_str,
+ struct HYD_Proxy *proxy_list)
+{
+ struct HYD_Proxy *proxy;
+ char *client_arg[HYD_NUM_TMP_STRINGS];
+ int i, arg, process_id;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ process_id = 0;
+ FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
+ /* Setup the executable arguments */
+ arg = 0;
+
+ for (i = 0; global_args[i]; i++)
+ client_arg[arg++] = HYDU_strdup(global_args[i]);
+
+ if (proxy_id_str) {
+ client_arg[arg++] = HYDU_strdup(proxy_id_str);
+ client_arg[arg++] = HYDU_int_to_str(proxy->proxy_id);
+ }
+
+ client_arg[arg++] = NULL;
+
+ if (HYD_BSCI_info.debug) {
+ HYDU_dump(stdout, "Launching process: ");
+ HYDU_print_strlist(client_arg);
+ }
+
+ /* The stdin pointer will be some value for process_id 0; for
+ * everyone else, it's NULL. */
+ status = HYDU_create_process(client_arg, NULL,
+ (process_id == 0 ? &proxy->in : NULL),
+ &proxy->out, &proxy->err, &proxy->pid, -1);
+ HYDU_ERR_POP(status, "create process returned error\n");
+
+ HYDU_free_strlist(client_arg);
+
+ process_id++;
+ }
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/include/bsci.h.in (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/include/bsci.h.in)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/include/bsci.h.in (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/include/bsci.h.in 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,42 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef BSCI_H_INCLUDED
+#define BSCI_H_INCLUDED
+
+struct HYD_BSCI_info {
+ char *bootstrap_exec;
+ int enablex;
+ int debug;
+};
+
+struct HYD_BSCI_fns {
+ HYD_Status(*launch_procs) (char **global_args, const char *proxy_id_str,
+ struct HYD_Proxy *proxy_list);
+ HYD_Status(*finalize) (void);
+ HYD_Status(*wait_for_completion) (struct HYD_Proxy *proxy_list);
+ HYD_Status(*query_node_list) (int *num_nodes, struct HYD_Proxy **proxy_list);
+ HYD_Status(*query_usize) (int *size);
+ HYD_Status(*query_proxy_id) (int *proxy_id);
+};
+
+extern struct HYD_BSCI_fns HYD_BSCI_fns;
+
+HYD_Status HYD_BSCI_init(char *bootstrap, char *bootstrap_exec, int enablex, int debug);
+HYD_Status HYD_BSCI_launch_procs(char **global_args, const char *proxy_id_str,
+ struct HYD_Proxy *proxy_list);
+HYD_Status HYD_BSCI_finalize(void);
+HYD_Status HYD_BSCI_wait_for_completion(struct HYD_Proxy *proxy_list);
+HYD_Status HYD_BSCI_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list);
+HYD_Status HYD_BSCI_query_usize(int *size);
+HYD_Status HYD_BSCI_query_proxy_id(int *proxy_id);
+
+/* Each bootstrap server has to expose an initialization function */
+ at hydra_bss_init_decl@
+
+extern struct HYD_BSCI_info HYD_BSCI_info;
+
+#endif /* BSCI_H_INCLUDED */
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/Makefile.mk (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/ssh/Makefile.mk)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,8 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+libhydra_a_SOURCES += $(top_srcdir)/tools/bootstrap/rsh/rsh_init.c \
+ $(top_srcdir)/tools/bootstrap/rsh/rsh_launch.c
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh.h (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,15 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef RSH_H_INCLUDED
+#define RSH_H_INCLUDED
+
+#include "hydra_base.h"
+
+HYD_Status HYD_BSCD_rsh_launch_procs(char **global_args, const char *proxy_id_str,
+ struct HYD_Proxy *proxy_list);
+
+#endif /* RSH_H_INCLUDED */
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh_init.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh_init.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh_init.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh_init.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,22 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "rsh.h"
+
+HYD_Status HYD_BSCI_rsh_init(void)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ HYD_BSCI_fns.launch_procs = HYD_BSCD_rsh_launch_procs;
+
+ HYDU_FUNC_EXIT();
+
+ return status;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh_launch.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/rsh/rsh_launch.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh_launch.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/rsh/rsh_launch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,97 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+#include "rsh.h"
+
+/*
+ * HYD_BSCD_rsh_launch_procs: For each process, we create an
+ * executable which reads like "rsh exec args" and the list of
+ * environment variables. We fork a worker process that sets the
+ * environment and execvp's this executable.
+ */
+HYD_Status HYD_BSCD_rsh_launch_procs(char **global_args, const char *proxy_id_str,
+ struct HYD_Proxy *proxy_list)
+{
+ struct HYD_Proxy *proxy;
+ char *client_arg[HYD_NUM_TMP_STRINGS];
+ char *tmp[HYD_NUM_TMP_STRINGS], *path = NULL, *test_path = NULL;
+ int i, arg, process_id;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ /*
+ * We use the following priority order for the executable path:
+ * 1. User-specified
+ * 2. Search in path
+ * 3. Hard-coded location
+ */
+ if (HYD_BSCI_info.bootstrap_exec) {
+ path = HYDU_strdup(HYD_BSCI_info.bootstrap_exec);
+ }
+ else {
+ status = HYDU_find_in_path("rsh", &test_path);
+ HYDU_ERR_POP(status, "error while searching for executable in user path\n");
+
+ if (test_path) {
+ tmp[0] = HYDU_strdup(test_path);
+ tmp[1] = HYDU_strdup("rsh");
+ tmp[2] = NULL;
+
+ status = HYDU_str_alloc_and_join(tmp, &path);
+ HYDU_ERR_POP(status, "error joining strings\n");
+
+ HYDU_free_strlist(tmp);
+ }
+ else
+ path = HYDU_strdup("/usr/bin/rsh");
+ }
+
+ process_id = 0;
+ FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
+ /* Setup the executable arguments */
+ arg = 0;
+ client_arg[arg++] = HYDU_strdup(path);
+
+ client_arg[arg++] = HYDU_strdup(proxy->hostname);
+
+ for (i = 0; global_args[i]; i++)
+ client_arg[arg++] = HYDU_strdup(global_args[i]);
+
+ if (proxy_id_str) {
+ client_arg[arg++] = HYDU_strdup(proxy_id_str);
+ client_arg[arg++] = HYDU_int_to_str(proxy->proxy_id);
+ }
+
+ client_arg[arg++] = NULL;
+
+ if (HYD_BSCI_info.debug) {
+ HYDU_dump(stdout, "Launching process: ");
+ HYDU_print_strlist(client_arg);
+ }
+
+ /* The stdin pointer will be some value for process_id 0; for
+ * everyone else, it's NULL. */
+ status = HYDU_create_process(client_arg, NULL,
+ (process_id == 0 ? &proxy->in : NULL),
+ &proxy->out, &proxy->err, &proxy->pid, -1);
+ HYDU_ERR_POP(status, "create process returned error\n");
+
+ HYDU_free_strlist(client_arg);
+
+ process_id++;
+ }
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Added: mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,10 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+libhydra_a_SOURCES += $(top_srcdir)/tools/bootstrap/slurm/slurm_init.c \
+ $(top_srcdir)/tools/bootstrap/slurm/slurm_launch.c \
+ $(top_srcdir)/tools/bootstrap/slurm/slurm_query_node_list.c \
+ $(top_srcdir)/tools/bootstrap/slurm/slurm_query_proxy_id.c
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm.h (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,17 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef SLURM_H_INCLUDED
+#define SLURM_H_INCLUDED
+
+#include "hydra_base.h"
+
+HYD_Status HYD_BSCD_slurm_launch_procs(char **global_args, const char *proxy_id_str,
+ struct HYD_Proxy *proxy_list);
+HYD_Status HYD_BSCD_slurm_query_proxy_id(int *proxy_id);
+HYD_Status HYD_BSCD_slurm_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list);
+
+#endif /* SLURM_H_INCLUDED */
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_init.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_init.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_init.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_init.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,24 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "slurm.h"
+
+HYD_Status HYD_BSCI_slurm_init(void)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ HYD_BSCI_fns.launch_procs = HYD_BSCD_slurm_launch_procs;
+ HYD_BSCI_fns.query_proxy_id = HYD_BSCD_slurm_query_proxy_id;
+ HYD_BSCI_fns.query_node_list = HYD_BSCD_slurm_query_node_list;
+
+ HYDU_FUNC_EXIT();
+
+ return status;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_launch.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_launch.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_launch.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_launch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,110 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+#include "slurm.h"
+
+HYD_Status HYD_BSCD_slurm_launch_procs(char **global_args, const char *proxy_id_str,
+ struct HYD_Proxy *proxy_list)
+{
+ struct HYD_Proxy *proxy;
+ char *client_arg[HYD_NUM_TMP_STRINGS];
+ char *tmp[HYD_NUM_TMP_STRINGS], *path = NULL, *test_path = NULL;
+ int i, arg, num_nodes;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ /*
+ * We use the following priority order for the executable path:
+ * 1. User-specified
+ * 2. Search in path
+ * 3. Hard-coded location
+ */
+ if (HYD_BSCI_info.bootstrap_exec) {
+ path = HYDU_strdup(HYD_BSCI_info.bootstrap_exec);
+ }
+ else {
+ status = HYDU_find_in_path("srun", &test_path);
+ HYDU_ERR_POP(status, "error while searching for executable in user path\n");
+
+ if (test_path) {
+ tmp[0] = HYDU_strdup(test_path);
+ tmp[1] = HYDU_strdup("srun");
+ tmp[2] = NULL;
+
+ status = HYDU_str_alloc_and_join(tmp, &path);
+ HYDU_ERR_POP(status, "error joining strings\n");
+
+ HYDU_free_strlist(tmp);
+ }
+ else
+ path = HYDU_strdup("/usr/bin/srun");
+ }
+
+ arg = 0;
+ client_arg[arg++] = HYDU_strdup(path);
+ client_arg[arg++] = HYDU_strdup("--nodelist");
+
+ i = 0;
+ num_nodes = 0;
+ FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
+ tmp[i++] = HYDU_strdup(proxy->hostname);
+ if (proxy->next && proxy->next->active)
+ tmp[i++] = HYDU_strdup(",");
+ num_nodes++;
+
+ /* If we used up more than half of the array elements, merge
+ * what we have so far */
+ if (i > (HYD_NUM_TMP_STRINGS / 2)) {
+ tmp[i++] = NULL;
+ status = HYDU_str_alloc_and_join(tmp, &client_arg[arg]);
+ HYDU_ERR_POP(status, "error joining strings\n");
+
+ i = 0;
+ tmp[i++] = client_arg[arg];
+ }
+ }
+ tmp[i++] = NULL;
+ status = HYDU_str_alloc_and_join(tmp, &client_arg[arg]);
+ HYDU_ERR_POP(status, "error joining strings\n");
+
+ HYDU_free_strlist(tmp);
+
+ arg++;
+
+ client_arg[arg++] = HYDU_strdup("-N");
+ client_arg[arg++] = HYDU_int_to_str(num_nodes);
+
+ client_arg[arg++] = HYDU_strdup("-n");
+ client_arg[arg++] = HYDU_int_to_str(num_nodes);
+
+ for (i = 0; global_args[i]; i++)
+ client_arg[arg++] = HYDU_strdup(global_args[i]);
+
+ client_arg[arg++] = NULL;
+
+ if (HYD_BSCI_info.debug) {
+ HYDU_dump(stdout, "Launching process: ");
+ HYDU_print_strlist(client_arg);
+ }
+
+ status = HYDU_create_process(client_arg, NULL,
+ &proxy_list->in,
+ &proxy_list->out, &proxy_list->err, &proxy_list->pid, -1);
+ HYDU_ERR_POP(status, "bootstrap spawn process returned error\n");
+
+ HYDU_free_strlist(client_arg);
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_query_node_list.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_query_node_list.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_query_node_list.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_query_node_list.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,142 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+#include "slurm.h"
+
+static void full_str_to_groups(char *str, char **list)
+{
+ char *tmp;
+ char new[MAX_HOSTNAME_LEN];
+ int nesting, i, arg;
+
+ tmp = str;
+ i = 0;
+ nesting = 0;
+ arg = 0;
+
+ while (1) {
+ new[i] = *tmp;
+ if (*tmp == '[')
+ nesting++;
+ if (*tmp == ']')
+ nesting--;
+ if (*tmp == ',' && nesting == 0) {
+ new[i] = 0;
+ list[arg++] = HYDU_strdup(new);
+ i = -1;
+ }
+ if (*tmp == 0) {
+ new[++i] = 0;
+ list[arg++] = HYDU_strdup(new);
+ break;
+ }
+
+ i++;
+ tmp++;
+ }
+ list[arg++] = NULL;
+}
+
+static HYD_Status group_to_individual_nodes(char *str, char **list)
+{
+ char *pre = NULL, *nodes = NULL, *tmp;
+ int start_node, end_node;
+ char new[MAX_HOSTNAME_LEN], *node_str[MAX_HOSTNAME_LEN];
+ int arg, i;
+ HYD_Status status = HYD_SUCCESS;
+
+ tmp = str;
+ i = 0;
+ while (1) {
+ new[i] = *tmp;
+
+ if (*tmp == '[') {
+ new[i] = 0;
+ pre = HYDU_strdup(new);
+ i = -1;
+ }
+
+ if (*tmp == ']' || *tmp == 0) {
+ new[i] = 0;
+ nodes = HYDU_strdup(new);
+ break;
+ }
+
+ i++;
+ tmp++;
+ }
+
+ arg = 0;
+ if (pre == NULL) {
+ list[arg++] = nodes;
+ }
+ else {
+ start_node = atoi(strtok(nodes, "-"));
+ end_node = atoi(strtok(NULL, "-"));
+ for (i = start_node; i <= end_node; i++) {
+ node_str[0] = HYDU_strdup(pre);
+ node_str[1] = HYDU_int_to_str(i);
+ node_str[2] = NULL;
+
+ status = HYDU_str_alloc_and_join(node_str, &list[arg++]);
+ HYDU_ERR_POP(status, "unable to join strings\n");
+
+ HYDU_free_strlist(node_str);
+ }
+ }
+ list[arg++] = NULL;
+
+ fn_exit:
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+HYD_Status HYD_BSCD_slurm_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list)
+{
+ char *str, *num_procs;
+ char *tmp1[HYD_NUM_TMP_STRINGS], *tmp2[HYD_NUM_TMP_STRINGS];
+ int i, j;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ str = getenv("SLURM_NODELIST");
+ num_procs = getenv("SLURM_JOB_CPUS_PER_NODE");
+
+ if (str == NULL || num_procs == NULL) {
+ *proxy_list = NULL;
+ }
+ else {
+ full_str_to_groups(str, tmp1);
+ num_procs = strtok(num_procs, "(");
+
+ *num_nodes = 0;
+ for (i = 0; tmp1[i]; i++) {
+ status = group_to_individual_nodes(tmp1[i], tmp2);
+ HYDU_ERR_POP(status, "unable to parse node list\n");
+
+ for (j = 0; tmp2[j]; j++) {
+ status = HYDU_merge_proxy_segment(tmp2[j], *num_nodes, atoi(num_procs),
+ proxy_list);
+ HYDU_ERR_POP(status, "merge proxy segment failed\n");
+
+ *num_nodes += atoi(num_procs);
+ }
+ }
+ }
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_query_proxy_id.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_query_proxy_id.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_query_proxy_id.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/slurm/slurm_query_proxy_id.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,32 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+#include "slurm.h"
+
+HYD_Status HYD_BSCD_slurm_query_proxy_id(int *proxy_id)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ if (getenv("SLURM_NODEID")) {
+ *proxy_id = atoi(getenv("SLURM_NODEID"));
+ }
+ else {
+ *proxy_id = -1;
+ HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "cannot find slurm proxy ID\n");
+ }
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Added: mpich2/trunk/src/pm/hydra/tools/bootstrap/src/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/src/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/src/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,13 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+libhydra_a_SOURCES += $(top_builddir)/tools/bootstrap/src/bsci_init.c \
+ $(top_srcdir)/tools/bootstrap/src/bsci_finalize.c \
+ $(top_srcdir)/tools/bootstrap/src/bsci_launch.c \
+ $(top_srcdir)/tools/bootstrap/src/bsci_query_node_list.c \
+ $(top_srcdir)/tools/bootstrap/src/bsci_query_proxy_id.c \
+ $(top_srcdir)/tools/bootstrap/src/bsci_usize.c \
+ $(top_srcdir)/tools/bootstrap/src/bsci_wait.c
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_finalize.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_finalize.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_finalize.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_finalize.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,26 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+
+HYD_Status HYD_BSCI_finalize(void)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ status = HYD_BSCI_fns.finalize();
+ HYDU_ERR_POP(status, "bootstrap device returned error while finalizing\n");
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_init.c.in (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_init.c.in)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_init.c.in (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_init.c.in 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,62 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+
+struct HYD_BSCI_fns HYD_BSCI_fns = { 0 };
+const char *HYD_BSCI_comp_array[] = { @hydra_bss_name_array@ };
+HYD_Status(*HYD_BSCI_comp_init[])(void) = { @hydra_bss_init_array@ };
+struct HYD_BSCI_info HYD_BSCI_info = { 0 };
+
+HYD_Status HYD_BSCI_init(char *bootstrap, char *bootstrap_exec, int enablex, int debug)
+{
+ int i;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ for (i = 0; HYD_BSCI_comp_array[i]; i++) {
+ if (!strcmp(bootstrap, HYD_BSCI_comp_array[i])) {
+ status = (*HYD_BSCI_comp_init[i])();
+ HYDU_ERR_POP(status, "bootstrap device returned error initializing\n");
+ break;
+ }
+ }
+
+ /* Set the appropriate info */
+ HYD_BSCI_info.bootstrap_exec = bootstrap_exec;
+ HYD_BSCI_info.enablex = enablex;
+ HYD_BSCI_info.debug = debug;
+
+ if (HYD_BSCI_comp_array[i] == NULL)
+ HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR,
+ "unrecognized bootstrap server: %s\n", bootstrap);
+
+ /* This function is mandatory */
+ if (HYD_BSCI_fns.launch_procs == NULL)
+ HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
+ "mandatory bootstrap launch function undefined\n");
+
+ if (HYD_BSCI_fns.finalize == NULL)
+ HYD_BSCI_fns.finalize = HYD_BSCU_finalize;
+ if (HYD_BSCI_fns.wait_for_completion == NULL)
+ HYD_BSCI_fns.wait_for_completion = HYD_BSCU_wait_for_completion;
+ if (HYD_BSCI_fns.query_node_list == NULL)
+ HYD_BSCI_fns.query_node_list = HYD_BSCU_query_node_list;
+ if (HYD_BSCI_fns.query_usize == NULL)
+ HYD_BSCI_fns.query_usize = HYD_BSCU_query_usize;
+ if (HYD_BSCI_fns.query_proxy_id == NULL)
+ HYD_BSCI_fns.query_proxy_id = HYD_BSCU_query_proxy_id;
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_launch.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_launch.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_launch.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_launch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,26 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+
+HYD_Status HYD_BSCI_launch_procs(char **global_args, const char *proxy_id_str,
+ struct HYD_Proxy *proxy_list)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ status = HYD_BSCI_fns.launch_procs(global_args, proxy_id_str, proxy_list);
+ HYDU_ERR_POP(status, "bootstrap device returned error while launching processes\n");
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_query_node_list.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_query_node_list.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_query_node_list.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_query_node_list.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,26 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+
+HYD_Status HYD_BSCI_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ status = HYD_BSCI_fns.query_node_list(num_nodes, proxy_list);
+ HYDU_ERR_POP(status, "bootstrap device returned error while querying node list\n");
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_query_proxy_id.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_query_proxy_id.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_query_proxy_id.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_query_proxy_id.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,26 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+
+HYD_Status HYD_BSCI_query_proxy_id(int *proxy_id)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ status = HYD_BSCI_fns.query_proxy_id(proxy_id);
+ HYDU_ERR_POP(status, "bootstrap device returned error while querying proxy ID\n");
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_usize.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_usize.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_usize.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_usize.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,26 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+
+HYD_Status HYD_BSCI_query_usize(int *size)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ status = HYD_BSCI_fns.query_usize(size);
+ HYDU_ERR_POP(status, "bootstrap device returned error querying usize\n");
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_wait.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/src/bsci_wait.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_wait.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/src/bsci_wait.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,26 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+
+HYD_Status HYD_BSCI_wait_for_completion(struct HYD_Proxy *proxy_list)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ status = HYD_BSCI_fns.wait_for_completion(proxy_list);
+ HYDU_ERR_POP(status, "bootstrap device returned error waiting for completion\n");
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/Makefile.mk (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/fork/Makefile.mk)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,8 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+libhydra_a_SOURCES += $(top_srcdir)/tools/bootstrap/ssh/ssh_init.c \
+ $(top_srcdir)/tools/bootstrap/ssh/ssh_launch.c
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh.h (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,15 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef SSH_H_INCLUDED
+#define SSH_H_INCLUDED
+
+#include "hydra_base.h"
+
+HYD_Status HYD_BSCD_ssh_launch_procs(char **global_args, const char *proxy_id_str,
+ struct HYD_Proxy *proxy_list);
+
+#endif /* SSH_H_INCLUDED */
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh_init.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_init.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh_init.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh_init.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,22 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "ssh.h"
+
+HYD_Status HYD_BSCI_ssh_init(void)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ HYD_BSCI_fns.launch_procs = HYD_BSCD_ssh_launch_procs;
+
+ HYDU_FUNC_EXIT();
+
+ return status;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh_launch.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh_launch.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/ssh/ssh_launch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,109 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bsci.h"
+#include "bscu.h"
+#include "ssh.h"
+
+/*
+ * HYD_BSCD_ssh_launch_procs: For each process, we create an
+ * executable which reads like "ssh exec args" and the list of
+ * environment variables. We fork a worker process that sets the
+ * environment and execvp's this executable.
+ */
+HYD_Status HYD_BSCD_ssh_launch_procs(char **global_args, const char *proxy_id_str,
+ struct HYD_Proxy *proxy_list)
+{
+ struct HYD_Proxy *proxy;
+ char *client_arg[HYD_NUM_TMP_STRINGS];
+ char *tmp[HYD_NUM_TMP_STRINGS], *path = NULL, *test_path = NULL;
+ int i, arg, process_id;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ /*
+ * We use the following priority order for the executable path:
+ * 1. User-specified
+ * 2. Search in path
+ * 3. Hard-coded location
+ */
+ if (HYD_BSCI_info.bootstrap_exec) {
+ path = HYDU_strdup(HYD_BSCI_info.bootstrap_exec);
+ }
+ else {
+ status = HYDU_find_in_path("ssh", &test_path);
+ HYDU_ERR_POP(status, "error while searching for executable in user path\n");
+
+ if (test_path) {
+ tmp[0] = HYDU_strdup(test_path);
+ tmp[1] = HYDU_strdup("ssh");
+ tmp[2] = NULL;
+
+ status = HYDU_str_alloc_and_join(tmp, &path);
+ HYDU_ERR_POP(status, "error joining strings\n");
+
+ HYDU_free_strlist(tmp);
+ }
+ else
+ path = HYDU_strdup("/usr/bin/ssh");
+ }
+
+ process_id = 0;
+ FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
+ /* Setup the executable arguments */
+ arg = 0;
+ client_arg[arg++] = HYDU_strdup(path);
+
+ /* Allow X forwarding only if explicitly requested */
+ if (HYD_BSCI_info.enablex == 1)
+ client_arg[arg++] = HYDU_strdup("-X");
+ else if (HYD_BSCI_info.enablex == 0)
+ client_arg[arg++] = HYDU_strdup("-x");
+ else /* default mode is disable X */
+ client_arg[arg++] = HYDU_strdup("-x");
+
+ client_arg[arg++] = HYDU_strdup(proxy->hostname);
+
+ for (i = 0; global_args[i]; i++)
+ client_arg[arg++] = HYDU_strdup(global_args[i]);
+
+ if (proxy_id_str) {
+ client_arg[arg++] = HYDU_strdup(proxy_id_str);
+ client_arg[arg++] = HYDU_int_to_str(proxy->proxy_id);
+ }
+
+ client_arg[arg++] = NULL;
+
+ if (HYD_BSCI_info.debug) {
+ HYDU_dump(stdout, "Launching process: ");
+ HYDU_print_strlist(client_arg);
+ }
+
+ /* The stdin pointer will be some value for process_id 0; for
+ * everyone else, it's NULL. */
+ status = HYDU_create_process(client_arg, NULL,
+ (process_id == 0 ? &proxy->in : NULL),
+ &proxy->out, &proxy->err, &proxy->pid, -1);
+ HYDU_ERR_POP(status, "create process returned error\n");
+
+ HYDU_free_strlist(client_arg);
+
+ process_id++;
+ }
+
+ fn_exit:
+ if (test_path)
+ HYDU_FREE(test_path);
+ if (path)
+ HYDU_FREE(path);
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Added: mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,13 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+AM_CPPFLAGS += -I$(top_srcdir)/tools/bootstrap/utils
+
+libhydra_a_SOURCES += $(top_srcdir)/tools/bootstrap/utils/bscu_finalize.c \
+ $(top_srcdir)/tools/bootstrap/utils/bscu_query_node_list.c \
+ $(top_srcdir)/tools/bootstrap/utils/bscu_query_proxy_id.c \
+ $(top_srcdir)/tools/bootstrap/utils/bscu_usize.c \
+ $(top_srcdir)/tools/bootstrap/utils/bscu_wait.c
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu.h (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,18 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef BSCU_H_INCLUDED
+#define BSCU_H_INCLUDED
+
+#include "hydra_base.h"
+
+HYD_Status HYD_BSCU_finalize(void);
+HYD_Status HYD_BSCU_wait_for_completion(struct HYD_Proxy *proxy_list);
+HYD_Status HYD_BSCU_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list);
+HYD_Status HYD_BSCU_query_usize(int *size);
+HYD_Status HYD_BSCU_query_proxy_id(int *proxy_id);
+
+#endif /* BSCU_H_INCLUDED */
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_finalize.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_finalize.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_finalize.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_finalize.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,20 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_base.h"
+#include "hydra_utils.h"
+#include "bscu.h"
+
+HYD_Status HYD_BSCU_finalize(void)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ HYDU_FUNC_EXIT();
+
+ return status;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_query_node_list.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_query_node_list.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_query_node_list.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_query_node_list.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,25 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_base.h"
+#include "hydra_utils.h"
+#include "bscu.h"
+
+HYD_Status HYD_BSCU_query_node_list(int *num_nodes, struct HYD_Proxy **proxy_list)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ /* We don't know anything about nodes or resources. Just return
+ * NULL. */
+ *num_nodes = 0;
+ *proxy_list = NULL;
+
+ HYDU_FUNC_EXIT();
+
+ return status;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_query_proxy_id.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_query_proxy_id.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_query_proxy_id.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_query_proxy_id.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,23 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_base.h"
+#include "hydra_utils.h"
+#include "bscu.h"
+
+HYD_Status HYD_BSCU_query_proxy_id(int *proxy_id)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ /* We don't know anything about proxy IDs by default. */
+ *proxy_id = -1;
+
+ HYDU_FUNC_EXIT();
+
+ return status;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_usize.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_usize.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_usize.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_usize.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,22 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_base.h"
+#include "hydra_utils.h"
+#include "bscu.h"
+
+HYD_Status HYD_BSCU_query_usize(int *size)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ *size = -1;
+
+ HYDU_FUNC_EXIT();
+
+ return status;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_wait.c (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_wait.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_wait.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_wait.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,48 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "bscu.h"
+
+HYD_Status HYD_BSCU_wait_for_completion(struct HYD_Proxy *proxy_list)
+{
+ int pid, ret_status, not_completed;
+ struct HYD_Proxy *proxy;
+ struct HYD_Proxy_exec *exec;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ not_completed = 0;
+ FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
+ if (proxy->exit_status == NULL) {
+ for (exec = proxy->exec_list; exec; exec = exec->next)
+ not_completed += exec->proc_count;
+ }
+ }
+
+ /* We get here only after the I/O sockets have been closed. If the
+ * application did not manually close its stdout and stderr
+ * sockets, this means that the processes have terminated. In that
+ * case the below loop will return almost immediately. If not, we
+ * poll for some time, burning CPU. */
+ while (not_completed > 0) {
+ pid = waitpid(-1, &ret_status, WNOHANG);
+ if (pid > 0) {
+ /* Find the pid and mark it as complete. */
+ FORALL_ACTIVE_PROXIES(proxy, proxy_list) {
+ if (proxy->pid == pid)
+ not_completed--;
+ }
+ }
+ }
+
+ if (not_completed)
+ status = HYD_INTERNAL_ERROR;
+
+ HYDU_FUNC_EXIT();
+ return status;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/ckpoint/Makefile.mk (from rev 5465, mpich2/trunk/src/pm/hydra/utils/ckpoint/Makefile.mk)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/ckpoint/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/ckpoint/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,13 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+AM_CPPFLAGS += -I$(top_srcdir)/tools/ckpoint
+
+libhydra_a_SOURCES += $(top_srcdir)/tools/ckpoint/ckpoint.c
+
+if hydra_have_blcr
+include tools/ckpoint/blcr/Makefile.mk
+endif
Copied: mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/Makefile.mk (from rev 5465, mpich2/trunk/src/pm/hydra/demux/Makefile.mk)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,7 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+libhydra_a_SOURCES += $(top_srcdir)/tools/ckpoint/blcr/ckpoint_blcr.c
Copied: mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/ckpoint_blcr.c (from rev 5465, mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/ckpoint_blcr.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/ckpoint_blcr.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/ckpoint_blcr.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,278 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "ckpoint.h"
+#include "ckpoint_blcr.h"
+#include <libcr.h>
+
+static int my_callback(void *arg)
+{
+ int rc;
+
+ rc = cr_checkpoint(CR_CHECKPOINT_OMIT);
+
+ switch (rc) {
+ case -CR_ETEMPFAIL:
+ /* One of the processes indicated that it couldn't take the checkpoint now. Try again later. */
+ return -1;
+ break;
+ case -CR_EPERMFAIL:
+ /* One of the processes indicated a permanent failure */
+ return -1;
+ break;
+ case -CR_EOMITTED:
+ /* This is the expected return */
+ break;
+ default:
+ /* Something bad happened */
+ return -1;
+ }
+
+
+ return 0;
+}
+
+static HYD_Status create_fifo(const char *fname_template, int rank, int *fd)
+{
+ HYD_Status status = HYD_SUCCESS;
+ char filename[256];
+ int ret;
+
+ snprintf(filename, sizeof(filename), fname_template, (int) getpid(), rank);
+
+ ret = mkfifo(filename, 0600);
+ HYDU_ERR_CHKANDJUMP1(status, ret, HYD_INTERNAL_ERROR, "mkfifo failed: %s\n",
+ strerror(errno));
+
+ *fd = open(filename, O_RDWR);
+ HYDU_ERR_CHKANDJUMP1(status, *fd < 0, HYD_INTERNAL_ERROR, "open failed: %s\n",
+ strerror(errno));
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+
+static HYD_Status create_stdinouterr_fifos(int num_ranks, int ranks[], int *in, int *out,
+ int *err)
+{
+ HYD_Status status = HYD_SUCCESS;
+ int r;
+
+ for (r = 0; r < num_ranks; ++r) {
+ if (in && ranks[r] == 0) {
+ status = create_fifo("/tmp/hydra-in-%d:%d", ranks[r], in);
+ if (status)
+ HYDU_ERR_POP(status, "create in fifo\n");
+ }
+ if (out) {
+ status = create_fifo("/tmp/hydra-out-%d:%d", ranks[r], &out[r]);
+ if (status)
+ HYDU_ERR_POP(status, "create out fifo\n");
+ }
+ if (err) {
+ status = create_fifo("/tmp/hydra-err-%d:%d", ranks[r], &err[r]);
+ if (status)
+ HYDU_ERR_POP(status, "create err fifo\n");
+ }
+ }
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+
+static HYD_Status create_env_file(const HYD_Env_t * envlist, int num_ranks, int *ranks)
+{
+ HYD_Status status = HYD_SUCCESS;
+ char filename[256];
+ FILE *f;
+ const HYD_Env_t *e;
+ int ret;
+ int r;
+
+ HYDU_FUNC_ENTER();
+
+ for (r = 0; r < num_ranks; ++r) {
+ snprintf(filename, sizeof(filename), "/tmp/hydra-env-file-%d:%d", (int) getpid(),
+ ranks[r]);
+
+ f = fopen(filename, "w");
+ HYDU_ERR_CHKANDJUMP1(status, f == NULL, HYD_INTERNAL_ERROR, "fopen failed: %s\n",
+ strerror(errno));
+
+ for (e = envlist; e; e = e->next) {
+ fprintf(f, "%s=%s\n", e->env_name, e->env_value);
+ }
+
+ ret = fclose(f);
+ HYDU_ERR_CHKANDJUMP1(status, ret, HYD_INTERNAL_ERROR, "fclose failed: %s\n",
+ strerror(errno));
+ }
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+HYD_Status HYDU_ckpoint_blcr_suspend(const char *prefix)
+{
+ HYD_Status status = HYD_SUCCESS;
+ int ret;
+ int fd;
+ cr_checkpoint_args_t my_args;
+ cr_checkpoint_handle_t my_handle;
+ char filename[256];
+
+ HYDU_FUNC_ENTER();
+
+ /* build the checkpoint filename */
+ snprintf(filename, sizeof(filename), "%s/context", prefix);
+
+ /* remove existing checkpoint file, if any */
+ (void) unlink(filename);
+
+ /* open the checkpoint file */
+ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC /* | O_LARGEFILE */ , 0600);
+ HYDU_ERR_CHKANDJUMP1(status, fd < 0, HYD_INTERNAL_ERROR, "open failed: %s\n",
+ strerror(errno));
+
+ cr_initialize_checkpoint_args_t(&my_args);
+ my_args.cr_fd = fd;
+ my_args.cr_scope = CR_SCOPE_TREE;
+
+ /* issue the request */
+ ret = cr_request_checkpoint(&my_args, &my_handle);
+ if (ret < 0) {
+ HYDU_ERR_CHKANDJUMP1(status, errno == CR_ENOSUPPORT, HYD_INTERNAL_ERROR,
+ "cr_request_checkpoint failed, %s\n", strerror(errno));
+ HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR, "cr_request_checkpoint failed, %s\n",
+ strerror(errno));
+ }
+ /* wait for the request to complete */
+ while (0) {
+ ret = cr_poll_checkpoint(&my_handle, NULL);
+ if (ret < 0) {
+ if ((ret == CR_POLL_CHKPT_ERR_POST) && (errno == CR_ERESTARTED)) {
+ HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
+ "trying to restart in a checkpoint\n");
+ }
+ else if (errno == EINTR) {
+ /* poll was interrupted by a signal -- retry */
+ }
+ else {
+ HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR,
+ "cr_poll_checkpoint failed: %s\n", strerror(errno));
+ }
+ }
+ else if (ret == 0) {
+ HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
+ "cr_poll_checkpoint returned 0 unexpectedly\n");
+ }
+ else {
+ break;
+ }
+ }
+
+ ret = close(my_args.cr_fd);
+ HYDU_ERR_CHKANDJUMP1(status, ret, HYD_INTERNAL_ERROR, "close failed, %s\n",
+ strerror(errno));
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+HYD_Status HYDU_ckpoint_blcr_restart(const char *prefix, HYD_Env_t * envlist, int num_ranks,
+ int ranks[], int *in, int *out, int *err)
+{
+ HYD_Status status = HYD_SUCCESS;
+ pid_t mypid;
+ int ret;
+ int context_fd;
+ cr_restart_handle_t cr_handle;
+ cr_restart_args_t args;
+ char filename[256];
+
+ HYDU_FUNC_ENTER();
+
+ mypid = getpid();
+
+ status = create_env_file(envlist, num_ranks, ranks);
+ if (status)
+ HYDU_ERR_POP(status, "blcr restart\n");
+
+ status = create_stdinouterr_fifos(num_ranks, ranks, in, out, err);
+ if (status)
+ HYDU_ERR_POP(status, "blcr restart\n");
+
+ snprintf(filename, sizeof(filename), "%s/context", prefix);
+
+ context_fd = open(filename, O_RDONLY /* | O_LARGEFILE */);
+ HYDU_ERR_CHKANDJUMP1(status, context_fd < 0, HYD_INTERNAL_ERROR, "open failed, %s\n",
+ strerror(errno));
+
+ /* ... initialize the request structure */
+ cr_initialize_restart_args_t(&args);
+ args.cr_fd = context_fd;
+ args.cr_flags = CR_RSTRT_RESTORE_PID;
+
+ /* ... issue the request */
+ ret = cr_request_restart(&args, &cr_handle);
+ HYDU_ERR_CHKANDJUMP1(status, ret, HYD_INTERNAL_ERROR, "cr_request_restart failed, %s\n",
+ strerror(errno));
+
+ ret = close(context_fd);
+ HYDU_ERR_CHKANDJUMP1(status, ret, HYD_INTERNAL_ERROR, "close failed, %s\n",
+ strerror(errno));
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+HYD_Status HYDU_ckpoint_blcr_init(void)
+{
+ HYD_Status status = HYD_SUCCESS;
+ int rc;
+ cr_client_id_t client_id;
+ cr_callback_id_t callback_id;
+
+ HYDU_FUNC_ENTER();
+
+ client_id = (int) cr_init();
+ if (client_id < 0)
+ goto fn_fail;
+
+ callback_id = cr_register_callback(my_callback, &rc, CR_SIGNAL_CONTEXT);
+ if (callback_id < 0)
+ goto fn_fail;
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/ckpoint_blcr.h (from rev 5465, mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/ckpoint_blcr.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/ckpoint_blcr.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/ckpoint/blcr/ckpoint_blcr.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,15 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef CKPOINT_BLCR_H_INCLUDED
+#define CKPOINT_BLCR_H_INCLUDED
+
+HYD_Status HYDU_ckpoint_blcr_init(void);
+HYD_Status HYDU_ckpoint_blcr_suspend(const char *prefix);
+HYD_Status HYDU_ckpoint_blcr_restart(const char *prefix, HYD_Env_t * envlist, int num_ranks,
+ int ranks[], int *in, int *out, int *err);
+
+#endif /* CKPOINT_BLCR_H_INCLUDED */
Copied: mpich2/trunk/src/pm/hydra/tools/ckpoint/ckpoint.c (from rev 5465, mpich2/trunk/src/pm/hydra/utils/ckpoint/ckpoint.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/ckpoint/ckpoint.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/ckpoint/ckpoint.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,93 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra_utils.h"
+#include "hydra_tools.h"
+#include "ckpoint.h"
+
+#if defined HAVE_BLCR
+#include "blcr/ckpoint_blcr.h"
+#endif /* HAVE_BLCR */
+
+struct HYDU_ckpoint_info HYDU_ckpoint_info;
+
+HYD_Status HYDU_ckpoint_init(char *ckpointlib, char *ckpoint_prefix)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ HYDU_ckpoint_info.ckpointlib = ckpointlib;
+ HYDU_ckpoint_info.ckpoint_prefix = ckpoint_prefix;
+
+ if (HYDU_ckpoint_info.ckpoint_prefix == NULL)
+ goto fn_exit;
+
+#if defined HAVE_BLCR
+ if (!strcmp(HYDU_ckpoint_info.ckpointlib, "blcr")) {
+ status = HYDU_ckpoint_blcr_init();
+ HYDU_ERR_POP(status, "blcr checkpoint returned error\n");
+ }
+#endif /* HAVE_BLCR */
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+HYD_Status HYDU_ckpoint_suspend(void)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ HYDU_ERR_CHKANDJUMP(status, HYDU_ckpoint_info.ckpoint_prefix == NULL, HYD_INTERNAL_ERROR,
+ "no checkpoint prefix defined\n");
+
+#if defined HAVE_BLCR
+ if (!strcmp(HYDU_ckpoint_info.ckpointlib, "blcr")) {
+ status = HYDU_ckpoint_blcr_suspend(HYDU_ckpoint_info.ckpoint_prefix);
+ HYDU_ERR_POP(status, "blcr checkpoint returned error\n");
+ }
+#endif /* HAVE_BLCR */
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+HYD_Status HYDU_ckpoint_restart(HYD_Env_t * envlist, int num_ranks, int ranks[], int *in,
+ int *out, int *err)
+{
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ HYDU_ERR_CHKANDJUMP(status, HYDU_ckpoint_info.ckpoint_prefix == NULL, HYD_INTERNAL_ERROR,
+ "no checkpoint prefix defined\n");
+
+#if defined HAVE_BLCR
+ if (!strcmp(HYDU_ckpoint_info.ckpointlib, "blcr")) {
+ status =
+ HYDU_ckpoint_blcr_restart(HYDU_ckpoint_info.ckpoint_prefix, envlist, num_ranks,
+ ranks, in, out, err);
+ HYDU_ERR_POP(status, "blcr checkpoint returned error\n");
+ }
+#endif /* HAVE_BLCR */
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/ckpoint/ckpoint.h (from rev 5465, mpich2/trunk/src/pm/hydra/utils/ckpoint/ckpoint.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/ckpoint/ckpoint.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/ckpoint/ckpoint.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,19 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef CKPOINT_H_INCLUDED
+#define CKPOINT_H_INCLUDED
+
+#include "hydra_utils.h"
+
+struct HYDU_ckpoint_info {
+ char *ckpointlib;
+ char *ckpoint_prefix;
+};
+
+extern struct HYDU_ckpoint_info HYDU_ckpoint_info;
+
+#endif /* CKPOINT_H_INCLUDED */
Copied: mpich2/trunk/src/pm/hydra/tools/demux/Makefile.mk (from rev 5465, mpich2/trunk/src/pm/hydra/bootstrap/rsh/Makefile.mk)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/demux/Makefile.mk (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/demux/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,9 @@
+# -*- Mode: Makefile; -*-
+#
+# (C) 2008 by Argonne National Laboratory.
+# See COPYRIGHT in top-level directory.
+#
+
+AM_CPPFLAGS += -I$(top_srcdir)/tools/demux
+
+libhydra_a_SOURCES += $(top_srcdir)/tools/demux/demux.c
Copied: mpich2/trunk/src/pm/hydra/tools/demux/demux.c (from rev 5465, mpich2/trunk/src/pm/hydra/demux/demux.c)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/demux/demux.c (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/demux/demux.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,210 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra.h"
+#include "hydra_utils.h"
+#include "demux.h"
+
+static int num_cb_fds = 0;
+
+typedef struct HYD_DMXI_callback {
+ int num_fds;
+ int *fd;
+ HYD_Event_t events;
+ void *userp;
+ HYD_Status(*callback) (int fd, HYD_Event_t events, void *userp);
+
+ struct HYD_DMXI_callback *next;
+} HYD_DMXI_callback_t;
+
+static HYD_DMXI_callback_t *cb_list = NULL;
+
+HYD_Status HYD_DMX_register_fd(int num_fds, int *fd, HYD_Event_t events, void *userp,
+ HYD_Status(*callback) (int fd, HYD_Event_t events, void *userp))
+{
+ HYD_DMXI_callback_t *cb_element, *run;
+ int i;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ for (i = 0; i < num_fds; i++)
+ if (fd[i] < 0)
+ HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR, "registering bad fd %d\n", fd[i]);
+
+ HYDU_MALLOC(cb_element, HYD_DMXI_callback_t *, sizeof(HYD_DMXI_callback_t), status);
+ cb_element->num_fds = num_fds;
+ HYDU_MALLOC(cb_element->fd, int *, num_fds * sizeof(int), status);
+ memcpy(cb_element->fd, fd, num_fds * sizeof(int));
+ cb_element->events = events;
+ cb_element->userp = userp;
+ cb_element->callback = callback;
+ cb_element->next = NULL;
+
+ if (cb_list == NULL) {
+ cb_list = cb_element;
+ }
+ else {
+ run = cb_list;
+ while (run->next)
+ run = run->next;
+ run->next = cb_element;
+ }
+
+ num_cb_fds += num_fds;
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+
+HYD_Status HYD_DMX_deregister_fd(int fd)
+{
+ int i;
+ HYD_DMXI_callback_t *cb_element;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ cb_element = cb_list;
+ while (cb_element) {
+ for (i = 0; i < cb_element->num_fds; i++) {
+ if (cb_element->fd[i] == fd) {
+ cb_element->fd[i] = -1;
+ num_cb_fds--;
+ goto fn_exit;
+ }
+ }
+ cb_element = cb_element->next;
+ }
+
+ /* FD is not found */
+ HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR,
+ "could not find fd to deregister: %d\n", fd);
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+
+HYD_Status HYD_DMX_wait_for_event(int wtime)
+{
+ int total_fds, i, j, events, ret;
+ HYD_DMXI_callback_t *run;
+ struct pollfd *pollfds = NULL;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ HYDU_MALLOC(pollfds, struct pollfd *, num_cb_fds * sizeof(struct pollfd), status);
+
+ run = cb_list;
+ i = 0;
+ while (run) {
+ for (j = 0; j < run->num_fds; j++) {
+ if (run->fd[j] == -1)
+ continue;
+
+ pollfds[i].fd = run->fd[j];
+
+ pollfds[i].events = 0;
+ if (run->events & HYD_STDOUT)
+ pollfds[i].events |= POLLIN;
+ if (run->events & HYD_STDIN)
+ pollfds[i].events |= POLLOUT;
+
+ i++;
+ }
+ run = run->next;
+ }
+ total_fds = i;
+
+ while (1) {
+ ret = poll(pollfds, total_fds, wtime);
+ if (ret < 0) {
+ if (errno == EINTR) {
+ /* We were interrupted by a system call; this is not
+ * an error case in the regular sense; but the upper
+ * layer needs to gracefully cleanup the processes. */
+ status = HYD_SUCCESS;
+ goto fn_exit;
+ }
+ HYDU_ERR_SETANDJUMP1(status, HYD_SOCK_ERROR, "poll error (%s)\n",
+ HYDU_strerror(errno));
+ }
+ break;
+ }
+
+ run = cb_list;
+ i = 0;
+ while (run) {
+ for (j = 0; j < run->num_fds; j++) {
+ if (run->fd[j] == -1)
+ continue;
+
+ if (pollfds[i].revents) {
+ events = 0;
+ if (pollfds[i].revents & POLLOUT)
+ events |= HYD_STDIN;
+ if (pollfds[i].revents & POLLIN)
+ events |= HYD_STDOUT;
+
+ if (run->callback == NULL)
+ HYDU_ERR_POP(status, "no registered callback found for socket\n");
+
+ status = run->callback(pollfds[i].fd, events, run->userp);
+ HYDU_ERR_POP(status, "callback returned error status\n");
+ }
+
+ i++;
+ if (i == total_fds)
+ break;
+ }
+ run = run->next;
+
+ if (i == total_fds)
+ break;
+ }
+
+ fn_exit:
+ if (pollfds)
+ HYDU_FREE(pollfds);
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+
+HYD_Status HYD_DMX_finalize(void)
+{
+ HYD_DMXI_callback_t *run1, *run2;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ run1 = cb_list;
+ while (run1) {
+ run2 = run1->next;
+ if (run1->fd)
+ HYDU_FREE(run1->fd);
+ HYDU_FREE(run1);
+ run1 = run2;
+ }
+ cb_list = NULL;
+
+ HYDU_FUNC_EXIT();
+ return status;
+}
Copied: mpich2/trunk/src/pm/hydra/tools/demux/demux.h (from rev 5465, mpich2/trunk/src/pm/hydra/demux/demux.h)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/demux/demux.h (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/demux/demux.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -0,0 +1,19 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef DEMUX_H_INCLUDED
+#define DEMUX_H_INCLUDED
+
+#include "hydra.h"
+
+HYD_Status HYD_DMX_register_fd(int num_fds, int *fd, HYD_Event_t events, void *userp,
+ HYD_Status(*callback) (int fd, HYD_Event_t events,
+ void *userp));
+HYD_Status HYD_DMX_deregister_fd(int fd);
+HYD_Status HYD_DMX_wait_for_event(int time);
+HYD_Status HYD_DMX_finalize(void);
+
+#endif /* DEMUX_H_INCLUDED */
Modified: mpich2/trunk/src/pm/hydra/utils/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -14,5 +14,3 @@
include utils/sock/Makefile.mk
include utils/string/Makefile.mk
include utils/timer/Makefile.mk
-include utils/bind/Makefile.mk
-include utils/ckpoint/Makefile.mk
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,13 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-AM_CPPFLAGS += -I$(top_srcdir)/utils/bind
-
-libhydra_a_SOURCES += $(top_srcdir)/utils/bind/bind.c
-
-if hydra_have_plpa
-include utils/bind/plpa/Makefile.mk
-endif
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/bind.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/bind.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/bind.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,172 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bind.h"
-
-#if defined HAVE_PLPA
-#include "plpa/bind_plpa.h"
-#endif /* HAVE_PLPA */
-
-struct HYDU_bind_info HYDU_bind_info;
-
-HYD_Status HYDU_bind_init(char *binding, char *bindlib)
-{
- char *bindstr, *bindentry;
- int sock, core, thread, i, j;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- HYDU_bind_info.support_level = HYDU_BIND_NONE;
- HYDU_bind_info.topology = NULL;
- HYDU_bind_info.bindlib = HYDU_strdup(bindlib);
-
- if (!binding || !strcmp(binding, "none")) {
- /* If no binding is given, we just set all mappings to -1 */
- HYDU_MALLOC(HYDU_bind_info.bindmap, int *, sizeof(int), status);
- HYDU_bind_info.num_procs = 1;
- HYDU_bind_info.bindmap[0] = -1;
-
- goto fn_exit;
- }
-
- if (!strncmp(binding, "user:", strlen("user:"))) {
- /* If the user specified the binding, we don't need to
- * initialize anything */
- bindstr = HYDU_strdup(binding + strlen("user:"));
-
- /* Find the number of processing elements */
- HYDU_bind_info.num_procs = 0;
- bindentry = strtok(bindstr, ",");
- while (bindentry) {
- HYDU_bind_info.num_procs++;
- bindentry = strtok(NULL, ",");
- }
-
- /* Find the actual processing elements */
- HYDU_MALLOC(HYDU_bind_info.bindmap, int *, HYDU_bind_info.num_procs * sizeof(int),
- status);
- i = 0;
- bindentry = strtok(bindstr, ",");
- while (bindentry) {
- HYDU_bind_info.bindmap[i++] = atoi(bindentry);
- bindentry = strtok(NULL, ",");
- }
-
- goto fn_exit;
- }
-
- /* If a real binding is required, we initialize the binding
- * library requested by the user */
-#if defined HAVE_PLPA
- if (!strcmp(HYDU_bind_info.bindlib, "plpa")) {
- status = HYDU_bind_plpa_init(&HYDU_bind_info.support_level);
- HYDU_ERR_POP(status, "unable to initialize plpa\n");
- }
-#endif /* HAVE_PLPA */
-
- if (HYDU_bind_info.support_level != HYDU_BIND_NONE) {
- HYDU_MALLOC(HYDU_bind_info.bindmap, int *, HYDU_bind_info.num_procs * sizeof(int),
- status);
-
- for (i = 0; i < HYDU_bind_info.num_procs; i++) {
-
- /* RR is supported at the basic binding level */
- if (!strcmp(binding, "rr")) {
- HYDU_bind_info.bindmap[i] = i;
- continue;
- }
-
- /* If we reached here, the user requested for topology
- * aware binding. */
- if (HYDU_bind_info.support_level != HYDU_BIND_TOPO)
- HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
- "topology binding not supported on this platform\n");
-
- if (!strcmp(binding, "buddy")) {
- thread = i / (HYDU_bind_info.num_sockets * HYDU_bind_info.num_cores);
-
- core = i % (HYDU_bind_info.num_sockets * HYDU_bind_info.num_cores);
- core /= HYDU_bind_info.num_sockets;
-
- sock = i % HYDU_bind_info.num_sockets;
- }
- else if (!strcmp(binding, "pack")) {
- sock = i / (HYDU_bind_info.num_cores * HYDU_bind_info.num_threads);
-
- core = i % (HYDU_bind_info.num_cores * HYDU_bind_info.num_threads);
- core /= HYDU_bind_info.num_threads;
-
- thread = i % HYDU_bind_info.num_threads;
- }
- else {
- HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "unknown binding option\n");
- }
-
- for (j = 0; j < HYDU_bind_info.num_procs; j++) {
- if (HYDU_bind_info.topology[j].socket_rank == sock &&
- HYDU_bind_info.topology[j].core_rank == core &&
- HYDU_bind_info.topology[j].thread_rank == thread) {
- HYDU_bind_info.bindmap[i] = HYDU_bind_info.topology[j].processor_id;
- break;
- }
- }
- }
- }
- else {
- /* If no binding is supported, we just set all mappings to -1 */
- HYDU_MALLOC(HYDU_bind_info.bindmap, int *, sizeof(int), status);
- HYDU_bind_info.num_procs = 1;
- HYDU_bind_info.bindmap[0] = -1;
- }
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-void HYDU_bind_finalize(void)
-{
- if (HYDU_bind_info.bindmap)
- HYDU_FREE(HYDU_bind_info.bindmap);
-
- if (HYDU_bind_info.bindlib)
- HYDU_FREE(HYDU_bind_info.bindlib);
-
- if (HYDU_bind_info.topology)
- HYDU_FREE(HYDU_bind_info.topology);
-}
-
-HYD_Status HYDU_bind_process(int core)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
-#if defined HAVE_PLPA
- if (!strcmp(HYDU_bind_info.bindlib, "plpa")) {
- status = HYDU_bind_plpa_process(core);
- HYDU_ERR_POP(status, "PLPA failure binding process to core\n");
- }
-#endif /* HAVE_PLPA */
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-
-int HYDU_bind_get_core_id(int id)
-{
- return HYDU_bind_info.bindmap[id % HYDU_bind_info.num_procs];
-}
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/bind.h
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/bind.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/bind.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,45 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#ifndef BIND_H_INCLUDED
-#define BIND_H_INCLUDED
-
-#include "hydra_utils.h"
-
-typedef enum {
- HYDU_BIND_NONE = 0,
- HYDU_BIND_BASIC,
- HYDU_BIND_TOPO
-} HYDU_bind_support_level_t;
-
-struct HYDU_bind_info {
- HYDU_bind_support_level_t support_level;
-
- int num_procs;
- int num_sockets;
- int num_cores;
- int num_threads;
-
- int *bindmap;
- char *bindlib;
-
- struct HYDU_topology {
- int processor_id;
-
- int socket_rank;
- int socket_id;
-
- int core_rank;
- int core_id;
-
- int thread_rank;
- int thread_id;
- } *topology;
-};
-
-extern struct HYDU_bind_info HYDU_bind_info;
-
-#endif /* BIND_H_INCLUDED */
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/plpa/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/plpa/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/plpa/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,9 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-libhydra_a_SOURCES += $(top_srcdir)/utils/bind/plpa/bind_plpa.c
-
-include $(top_srcdir)/utils/bind/plpa/plpa/Makefile.mk
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/plpa/bind_plpa.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/plpa/bind_plpa.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/plpa/bind_plpa.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,170 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "bind.h"
-#include "bind_plpa.h"
-
-struct HYDU_bind_info HYDU_bind_info;
-
-#include "plpa.h"
-#include "plpa_internal.h"
-
-HYD_Status HYDU_bind_plpa_init(HYDU_bind_support_level_t * support_level)
-{
- PLPA_NAME(api_type_t) p;
- int ret, i, j, max, id;
- int processor, sock, core, thread;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- if (!((PLPA_NAME(api_probe) (&p) == 0) && (p == PLPA_NAME_CAPS(PROBE_OK)))) {
- /* If this failed, we just return without binding */
- HYDU_Warn_printf("plpa api runtime probe failed\n");
- goto fn_fail;
- }
-
- /* Find the maximum number of processing elements */
- ret = PLPA_NAME(get_processor_data) (PLPA_NAME_CAPS(COUNT_ONLINE),
- &HYDU_bind_info.num_procs, &max);
- if (ret) {
- /* Unable to get number of processors */
- HYDU_Warn_printf("plpa get processor data failed\n");
- goto fn_fail;
- }
-
- HYDU_MALLOC(HYDU_bind_info.topology, struct HYDU_topology *,
- HYDU_bind_info.num_procs * sizeof(struct HYDU_topology), status);
- for (i = 0; i < HYDU_bind_info.num_procs; i++) {
- HYDU_bind_info.topology[i].processor_id = -1;
- HYDU_bind_info.topology[i].socket_rank = -1;
- HYDU_bind_info.topology[i].socket_id = -1;
- HYDU_bind_info.topology[i].core_rank = -1;
- HYDU_bind_info.topology[i].core_id = -1;
- HYDU_bind_info.topology[i].thread_rank = -1;
- HYDU_bind_info.topology[i].thread_id = -1;
- }
-
- for (i = 0; i < HYDU_bind_info.num_procs; i++) {
- ret = PLPA_NAME(get_processor_id) (i, PLPA_NAME_CAPS(COUNT_ALL), &processor);
- if (ret) {
- /* Unable to get processor ID */
- HYDU_Warn_printf("plpa get processor id failed\n");
- if (HYDU_bind_info.topology)
- HYDU_FREE(HYDU_bind_info.topology);
- goto fn_fail;
- }
- HYDU_bind_info.topology[i].processor_id = processor;
- }
-
- /* We have qualified for basic binding support level */
- *support_level = HYDU_BIND_BASIC;
-
- /* PLPA only gives information about sockets and cores */
- ret = PLPA_NAME(get_socket_info) (&HYDU_bind_info.num_sockets, &max);
- if (ret) {
- /* Unable to get number of sockets */
- HYDU_Warn_printf("plpa get socket info failed\n");
- goto fn_fail;
- }
-
- ret = PLPA_NAME(get_core_info) (0, &HYDU_bind_info.num_cores, &max);
- if (ret) {
- /* Unable to get number of cores */
- HYDU_Warn_printf("plpa get core info failed\n");
- goto fn_fail;
- }
-
- HYDU_bind_info.num_threads = HYDU_bind_info.num_procs /
- (HYDU_bind_info.num_sockets * HYDU_bind_info.num_cores);
-
- /* Find the socket and core IDs for all processor IDs */
- for (i = 0; i < HYDU_bind_info.num_procs; i++) {
- ret = PLPA_NAME(map_to_socket_core) (HYDU_bind_info.topology[i].processor_id,
- &sock, &core);
- if (ret) {
- /* Unable to get number of cores */
- HYDU_Warn_printf("plpa unable to map socket to core\n");
- goto fn_fail;
- }
-
- HYDU_bind_info.topology[i].socket_id = sock;
- HYDU_bind_info.topology[i].core_id = core;
-
- thread = -1;
- for (j = 0; j < i; j++)
- if (HYDU_bind_info.topology[j].socket_id == sock &&
- HYDU_bind_info.topology[j].core_id == core)
- thread = HYDU_bind_info.topology[j].thread_id;
- thread++;
-
- HYDU_bind_info.topology[i].thread_id = thread;
- HYDU_bind_info.topology[i].thread_rank = thread;
- }
-
- /* Find the rank of each socket ID */
- for (i = 0; i < HYDU_bind_info.num_sockets; i++) {
- ret = PLPA_NAME(get_socket_id) (i, &id);
- if (ret) {
- /* Unable to get socket id */
- HYDU_Warn_printf("plpa unable to get socket id\n");
- goto fn_fail;
- }
- for (j = 0; j < HYDU_bind_info.num_procs; j++)
- if (HYDU_bind_info.topology[j].socket_id == id)
- HYDU_bind_info.topology[j].socket_rank = i;
- }
-
- /* Find the rank of each core ID */
- for (i = 0; i < HYDU_bind_info.num_cores; i++) {
- ret = PLPA_NAME(get_core_id) (HYDU_bind_info.topology[0].socket_id, i, &id);
- if (ret) {
- /* Unable to get socket id */
- HYDU_Warn_printf("plpa unable to get socket id\n");
- goto fn_fail;
- }
- for (j = 0; j < HYDU_bind_info.num_procs; j++)
- if (HYDU_bind_info.topology[j].core_id == id)
- HYDU_bind_info.topology[j].core_rank = i;
- }
-
- /* We have qualified for topology-aware binding support level */
- *support_level = HYDU_BIND_TOPO;
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-HYD_Status HYDU_bind_plpa_process(int core)
-{
- int ret;
- PLPA_NAME(cpu_set_t) cpuset;
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- /* If the specified core is negative, we just ignore it */
- if (core < 0)
- goto fn_exit;
-
- PLPA_NAME_CAPS(CPU_ZERO) (&cpuset);
- PLPA_NAME_CAPS(CPU_SET) (core % HYDU_bind_info.num_procs, &cpuset);
- ret = PLPA_NAME(sched_setaffinity) (0, 1, &cpuset);
- if (ret)
- HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "plpa setaffinity failed\n");
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/plpa/bind_plpa.h
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/plpa/bind_plpa.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/plpa/bind_plpa.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,13 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#ifndef BIND_PLPA_H_INCLUDED
-#define BIND_PLPA_H_INCLUDED
-
-HYD_Status HYDU_bind_plpa_init(HYDU_bind_support_level_t * support_level);
-HYD_Status HYDU_bind_plpa_process(int core);
-
-#endif /* BIND_PLPA_H_INCLUDED */
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/LICENSE
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/LICENSE 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/LICENSE 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,57 +0,0 @@
-Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
- University Research and Technology
- Corporation. All rights reserved.
-Copyright (c) 2004-2005 The Regents of the University of California.
- All rights reserved.
-Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
-
-Portions copyright:
-
-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) 2006, 2007 Advanced Micro Devices, Inc.
- All rights reserved.
-
-$COPYRIGHT$
-
-Additional copyrights may follow
-
-$HEADER$
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
-- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer listed
- in this license in the documentation and/or other materials
- provided with the distribution.
-
-- Neither the name of the copyright holders nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-The copyright holders provide no reassurances that the source code
-provided does not infringe any patent, copyright, or any other
-intellectual property rights of third parties. The copyright holders
-disclaim any liability to any recipient for claims brought against
-recipient by any third party for infringement of that parties
-intellectual property rights.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,12 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-AM_CPPFLAGS += -I$(top_srcdir)/utils/bind/plpa/plpa
-
-libhydra_a_SOURCES += $(top_srcdir)/utils/bind/plpa/plpa/plpa_api_probe.c \
- $(top_srcdir)/utils/bind/plpa/plpa/plpa_dispatch.c \
- $(top_srcdir)/utils/bind/plpa/plpa/plpa_map.c \
- $(top_srcdir)/utils/bind/plpa/plpa/plpa_runtime.c
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa.h
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,298 +0,0 @@
-/* -*- c -*-
- *
- * Copyright (c) 2004-2005 The Trustees of Indiana University.
- * All rights reserved.
- * Copyright (c) 2004-2005 The Regents of the University of California.
- * All rights reserved.
- * Copyright (c) 2006-2008 Cisco, Inc. All rights reserved.
- * $COPYRIGHT$
- *
- * Additional copyrights may follow
- *
- * $HEADER$
- */
-
-/*
- * Some notes about the declarations and definitions in this file:
- *
- * This file is a mix of internal and public declarations.
- * Applications are warned against using the internal types; they are
- * subject to change with no warning.
- *
- * The PLPA_NAME() and PLPA_NAME_CAPS() macros are used for prefixing
- * the PLPA type names, enum names, and symbol names when embedding
- * PLPA. When not embedding, the default prefix is "plpa_" (or
- * "PLPA_" when using PLPA_NAME_CAPS()). Hence, if you see a
- * declaration like this:
- *
- * int PLPA_NAME(foo)(void);
- *
- * It's a function named plpa_foo() that returns an int and takes no
- * arguments when building PLPA as a standalone library. It's a
- * function with a different prefix than "plpa_" when the
- * --enable-included-mode and --with-plpa-symbol-prefix options are
- * supplied to PLPA's configure script.
- *
- * Note that this header file differentiates between a
- * processor/socket/core ID and a processor/socket/core number. The
- * "ID" is the integer that is used by Linux to identify that entity.
- * These integers may or may not be contiguous. The "number" is a
- * contiguous set of integers starting with 0 and going to (count-1),
- * where (count) is the number of processors, sockets, and cores
- * (where the count of cores is dependent upon the socket). Hence,
- * "number" is a human convenience, and "ID" is the actual Linux
- * identifier.
- */
-
-#ifndef PLPA_H
-#define PLPA_H
-
-/* Absolutely must not include <sched.h> here or it will generate
- conflicts. */
-
-/* For memset() */
-#include <string.h>
-/* For pid_t and size_t */
-#include <sys/types.h>
-
-/***************************************************************************
- * Internal types
- ***************************************************************************/
-
-/* If we're building PLPA itself, <plpa_config.h> will have already
- been included. But <plpa_config.h> is a private header file; it is
- not installed into $includedir. Hence, applications including
- <plpa.h> will not have included <plpa_config.h> (this is by
- design). So include just enough information here to allow us to
- continue. */
-#ifndef PLPA_CONFIG_H
-/* The PLPA symbol prefix */
-#define PLPA_SYM_PREFIX plpa_
-
-/* The PLPA symbol prefix in all caps */
-#define PLPA_SYM_PREFIX_CAPS PLPA_
-#endif
-
-/* Preprocessors are fun -- the double inderection is unfortunately
- necessary. */
-#define PLPA_MUNGE_NAME(a, b) PLPA_MUNGE_NAME2(a, b)
-#define PLPA_MUNGE_NAME2(a, b) a ## b
-#define PLPA_NAME(name) PLPA_MUNGE_NAME(PLPA_SYM_PREFIX, name)
-#define PLPA_NAME_CAPS(name) PLPA_MUNGE_NAME(PLPA_SYM_PREFIX_CAPS, name)
-
-/***************************************************************************
- * Public type
- ***************************************************************************/
-
-/* Values that can be returned from plpa_api_probe() */
-typedef enum {
- /* Sentinel value */
- PLPA_NAME_CAPS(PROBE_UNSET),
- /* sched_setaffinity syscall available */
- PLPA_NAME_CAPS(PROBE_OK),
- /* syscall unavailable/unimplemented */
- PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED),
- /* we experienced some strange failure that the user should report */
- PLPA_NAME_CAPS(PROBE_UNKNOWN)
-} PLPA_NAME(api_type_t);
-
-/***************************************************************************
- * Internal types
- ***************************************************************************/
-
-/* Internal PLPA bitmask type. This type should not be used by
- external applications! */
-typedef unsigned long int PLPA_NAME(bitmask_t);
-#define PLPA_BITMASK_T_NUM_BITS (sizeof(PLPA_NAME(bitmask_t)) * 8)
-#define PLPA_BITMASK_CPU_MAX 1024
-#define PLPA_BITMASK_NUM_ELEMENTS (PLPA_BITMASK_CPU_MAX / PLPA_BITMASK_T_NUM_BITS)
-
-/***************************************************************************
- * Public type
- ***************************************************************************/
-
-/* Public type for the PLPA cpu set. */
-typedef struct { PLPA_NAME(bitmask_t) bitmask[PLPA_BITMASK_NUM_ELEMENTS]; } PLPA_NAME(cpu_set_t);
-
-/***************************************************************************
- * Internal macros
- ***************************************************************************/
-
-/* Internal macro for identifying the byte in a bitmask array. This
- macro should not be used by external applications! */
-#define PLPA_CPU_BYTE(num) ((num) / PLPA_BITMASK_T_NUM_BITS)
-
-/* Internal macro for identifying the bit in a bitmask array. This
- macro should not be used by external applications! */
-#define PLPA_CPU_BIT(num) ((num) % PLPA_BITMASK_T_NUM_BITS)
-
-/***************************************************************************
- * Public macros
- ***************************************************************************/
-
-/* Public macro to zero out a PLPA cpu set (analogous to the FD_ZERO()
- macro; see select(2)). */
-#define PLPA_CPU_ZERO(cpuset) \
- memset((cpuset), 0, sizeof(PLPA_NAME(cpu_set_t)))
-
-/* Public macro to set a bit in a PLPA cpu set (analogous to the
- FD_SET() macro; see select(2)). */
-#define PLPA_CPU_SET(num, cpuset) \
- (cpuset)->bitmask[PLPA_CPU_BYTE(num)] |= ((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))
-
-/* Public macro to clear a bit in a PLPA cpu set (analogous to the
- FD_CLR() macro; see select(2)). */
-#define PLPA_CPU_CLR(num, cpuset) \
- (cpuset)->bitmask[PLPA_CPU_BYTE(num)] &= ~((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))
-
-/* Public macro to test if a bit is set in a PLPA cpu set (analogous
- to the FD_ISSET() macro; see select(2)). */
-#define PLPA_CPU_ISSET(num, cpuset) \
- (0 != (((cpuset)->bitmask[PLPA_CPU_BYTE(num)]) & ((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))))
-
-/***************************************************************************
- * Public functions
- ***************************************************************************/
-
-/* Setup PLPA internals. This function is optional; it will be
- automatically invoked by all the other API functions if you do not
- invoke it explicitly. Returns 0 upon success. */
-int PLPA_NAME(init)(void);
-
-/* Check what API is on this machine. If api_type returns
- PLPA_PROBE_OK, then PLPA can function properly on this machine.
- Returns 0 upon success. */
-int PLPA_NAME(api_probe)(PLPA_NAME(api_type_t) *api_type);
-
-/* Set processor affinity. Use the PLPA_CPU_* macros to set the
- cpuset value. The same rules and restrictions about pid apply as
- they do for the sched_setaffinity(2) system call. Bits set in the
- CPU mask correspond to Linux processor IDs. Returns 0 upon
- success. */
-int PLPA_NAME(sched_setaffinity)(pid_t pid, size_t cpusetsize,
- const PLPA_NAME(cpu_set_t) *cpuset);
-
-/* Get processor affinity. Use the PLPA_CPU_* macros to analyze the
- returned value of cpuset. The same rules and restrictions about
- pid apply as they do for the sched_getaffinity(2) system call.
- Bits set in the CPU mask corresopnd to Linux processor IDs.
- Returns 0 upon success. */
-int PLPA_NAME(sched_getaffinity)(pid_t pid, size_t cpusetsize,
- PLPA_NAME(cpu_set_t) *cpuset);
-
-/* Return whether topology information is available (i.e.,
- plpa_map_to_*, plpa_max_*). The topology functions will be
- available if supported == 1 and the function returns 0. */
-int PLPA_NAME(have_topology_information)(int *supported);
-
-/* Map (socket_id,core_id) tuple to virtual processor ID. processor_id is
- then suitable for use with the PLPA_CPU_* macros, probably leading
- to a call to plpa_sched_setaffinity(). Returns 0 upon success. */
-int PLPA_NAME(map_to_processor_id)(int socket_id, int core_id,
- int *processor_id);
-
-/* Map processor_id to (socket_id,core_id) tuple. The processor_id input is
- usually obtained from the return from the plpa_sched_getaffinity()
- call, using PLPA_CPU_ISSET to find individual bits in the map that
- were set/unset. plpa_map_to_socket_core() can map the bit indexes
- to a socket/core tuple. Returns 0 upon success. */
-int PLPA_NAME(map_to_socket_core)(int processor_id,
- int *socket_id, int *core_id);
-
-/* This function is deprecated and will disappear in a future release.
- It is exactly equivalent to calling
- plpa_get_processor_data(PLPA_COUNT_ALL, num_processors,
- max_processor_id). */
-int PLPA_NAME(get_processor_info)(int *num_processors, int *max_processor_id);
-
-/* Typedefs for specifying which processors / sockets / cores to count
- in get_processor_data() and get_processor_id() */
-typedef enum {
- /* Only count online processors */
- PLPA_NAME_CAPS(COUNT_ONLINE),
- /* Only count offline processors */
- PLPA_NAME_CAPS(COUNT_OFFLINE),
- /* Count all processors (online and offline) */
- PLPA_NAME_CAPS(COUNT_ALL)
-} PLPA_NAME(count_specification_t);
-
-/* Returns both the number of processors in a system and the maximum
- Linux virtual processor ID (because it may be higher than the
- number of processors if there are "holes" in the available Linux
- virtual processor IDs). The count_spec argument specifies whether
- to count all processors, only online processors, or only offline
- processors. Returns 0 upon success. */
-int PLPA_NAME(get_processor_data)(PLPA_NAME(count_specification_t) count_spec,
- int *num_processors, int *max_processor_id);
-
-/* Returns the Linux processor ID for the Nth processor. For example,
- if the Linux processor IDs have "holes", use this function to say
- "give me the Linux processor ID of the 4th processor." count_spec
- specifies whether to count online, offline, or all processors when
- looking for the processor_num'th processor. Returns 0 upon
- success. */
-int PLPA_NAME(get_processor_id)(int processor_num,
- PLPA_NAME(count_specification_t) count_spec,
- int *processor_id);
-
-/* Check to see if a given Linux processor ID exists / is online.
- Returns 0 on success. */
-int PLPA_NAME(get_processor_flags)(int processor_id, int *exists, int *online);
-
-/* Returns both the number of sockets in the system and the maximum
- socket ID number (in case there are "holes" in the list of available
- socket IDs). Returns 0 upon sucess. */
-int PLPA_NAME(get_socket_info)(int *num_sockets, int *max_socket_id);
-
-/* Returns the Linux socket ID for the Nth socket. For example, if
- the socket IDs have "holes", use this function to say "give me the
- Linux socket ID of the 2nd socket." Linux does not specify the
- socket/core tuple information for offline processors, so a
- plpa_count_specification_t parameter is not used here. Returns 0
- upon success. */
-int PLPA_NAME(get_socket_id)(int socket_num, int *socket_id);
-
-/* Return both the number of cores and the max code ID for a given
- socket (in case there are "holes" in the list of available core
- IDs). Returns 0 upon success. */
-int PLPA_NAME(get_core_info)(int socket_id, int *num_cores, int *max_core_id);
-
-/* Given a specific socket, returns the Linux core ID for the Nth
- core. For example, if the core IDs have "holes", use this function
- to say "give me the Linux core ID of the 4th core on socket ID 7."
- Linux does not specify the socket/core tuple information for
- offline processors, so a plpa_count_specification_t parameter is
- not used here. Returns 0 upon success. Returns 0 upon success. */
-int PLPA_NAME(get_core_id)(int socket_id, int core_num, int *core_id);
-
-/* Check to see if a given Linux (socket_id,core_id) tuple exists / is
- online. Returns 0 on success. */
-int PLPA_NAME(get_core_flags)(int socket_id, int core_id,
- int *exists, int *online);
-
-/* Typedefs for specifying the cache behavior via
- plpa_set_cache_behavior() */
-typedef enum {
- /* Use the cache (default behavior); fills the cache right now if
- it's not already full */
- PLPA_NAME_CAPS(CACHE_USE),
- /* Never use the cache; always look up the information in
- the kernel */
- PLPA_NAME_CAPS(CACHE_IGNORE),
- /* Refresh the cache right now */
- PLPA_NAME_CAPS(CACHE_REFRESH)
-} PLPA_NAME(cache_behavior_t);
-
-/* Set PLPA's cache behavior. Returns 0 upon success. */
-int PLPA_NAME(set_cache_behavior)(PLPA_NAME(cache_behavior_t));
-
-/* Shut down PLPA. This function releases resources used by the PLPA.
- It should be the last PLPA function invoked, or can be used to
- forcibly cause PLPA to dump its topology cache and re-analyze the
- underlying system the next time another PLPA function is called.
- Specifically: it is safe to call plpa_init() (or any other PLPA
- function) again after plpa_finalized(). Returns 0 upon success. */
-int PLPA_NAME(finalize)(void);
-
-#endif /* PLPA_H */
-
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_api_probe.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_api_probe.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_api_probe.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,89 +0,0 @@
-/* -*- c -*-
- *
- * Copyright (c) 2004-2005 The Trustees of Indiana University.
- * All rights reserved.
- * Copyright (c) 2004-2005 The Regents of the University of California.
- * All rights reserved.
- * Copyright (c) 2007-2008 Cisco, Inc. All rights reserved.
- * $COPYRIGHT$
- *
- * Additional copyrights may follow
- *
- * $HEADER$
- */
-
-#include "plpa.h"
-#include "plpa_internal.h"
-
-#include <errno.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-
-/* Cache, just to make things a little more efficient */
-static PLPA_NAME(api_type_t) cache = PLPA_NAME_CAPS(PROBE_UNSET);
-
-/* The len value we find - not in public header, but used by the lib */
-size_t PLPA_NAME(len) = 0;
-
-int PLPA_NAME(api_probe_init)(void)
-{
- PLPA_NAME(cpu_set_t) mask;
- int rc;
- size_t len;
-
- for (len = sizeof(mask); len != 0; len >>= 1) {
- rc = syscall(__NR_sched_getaffinity, 0, len, &mask);
- if (rc >= 0) {
- /* OK, kernel is happy with a get(). Validate w/ a set(). */
- /* Note that kernel may have told us the "proper" size */
- size_t tmp = (0 != rc) ? ((size_t) rc) : len;
- /* Pass mask=NULL, expect errno==EFAULT if tmp was OK
- as a length */
- rc = syscall(__NR_sched_setaffinity, 0, tmp, NULL);
- if ((rc < 0) && (errno == EFAULT)) {
- cache = PLPA_NAME_CAPS(PROBE_OK);
- PLPA_NAME(len) = tmp;
- rc = 0;
- break;
- }
- }
- if (errno == ENOSYS) {
- break; /* No point in looping */
- }
- }
-
- if (rc >= 0) {
- /* OK */
- } else if (errno == ENOSYS) {
- /* Kernel returns ENOSYS because there is no support for
- processor affinity */
- cache = PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED);
- } else {
- /* Unknown! */
- cache = PLPA_NAME_CAPS(PROBE_UNKNOWN);
- }
-
- return 0;
-}
-
-
-int PLPA_NAME(api_probe)(PLPA_NAME(api_type_t) *api_type)
-{
- int ret;
-
- /* Check to see that we're initialized */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* Check for bozo arguments */
- if (NULL == api_type) {
- return EINVAL;
- }
-
- /* All done */
- *api_type = cache;
- return 0;
-}
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_dispatch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_dispatch.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_dispatch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,192 +0,0 @@
-/* -*- c -*-
- *
- * Copyright (c) 2004-2006 The Trustees of Indiana University.
- * All rights reserved.
- * Copyright (c) 2004-2005 The Regents of the University of California.
- * All rights reserved.
- * Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
- * $COPYRIGHT$
- *
- * Additional copyrights may follow
- *
- * $HEADER$
- */
-
-#include "plpa.h"
-#include "plpa_internal.h"
-
-#include <errno.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-
-/**
- * Call the kernel's setaffinity, massaging the user's input
- * parameters as necessary
- */
-int PLPA_NAME(sched_setaffinity)(pid_t pid, size_t cpusetsize,
- const PLPA_NAME(cpu_set_t) *cpuset)
-{
- int ret;
- size_t i;
- PLPA_NAME(cpu_set_t) tmp;
- PLPA_NAME(api_type_t) api;
-
- /* Check to see that we're initialized */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* Check for bozo arguments */
- if (NULL == cpuset) {
- return EINVAL;
- }
-
- /* Probe the API type */
- if (0 != (ret = PLPA_NAME(api_probe)(&api))) {
- return ret;
- }
- switch (api) {
- case PLPA_NAME_CAPS(PROBE_OK):
- /* This shouldn't happen, but check anyway */
- if (cpusetsize > sizeof(*cpuset)) {
- return EINVAL;
- }
-
- /* If the user-supplied bitmask is smaller than what the
- kernel wants, zero out a temporary buffer of the size that
- the kernel wants and copy the user-supplied bitmask to the
- lower part of the temporary buffer. This could be done
- more efficiently, but we're looking for clarity/simplicity
- of code here -- this is not intended to be
- performance-critical. */
- if (cpusetsize < PLPA_NAME(len)) {
- memset(&tmp, 0, sizeof(tmp));
- for (i = 0; i < cpusetsize * 8; ++i) {
- if (PLPA_CPU_ISSET(i, cpuset)) {
- PLPA_CPU_SET(i, &tmp);
- }
- }
- }
-
- /* If the user-supplied bitmask is larger than what the kernel
- will accept, scan it and see if there are any set bits in
- the part larger than what the kernel will accept. If so,
- return EINVAL. Otherwise, copy the part that the kernel
- will accept into a temporary and use that. Again,
- efficinency is not the issue of this code -- clarity is. */
- else if (cpusetsize > PLPA_NAME(len)) {
- for (i = PLPA_NAME(len) * 8; i < cpusetsize * 8; ++i) {
- if (PLPA_CPU_ISSET(i, cpuset)) {
- return EINVAL;
- }
- }
- /* No upper-level bits are set, so now copy over the bits
- that the kernel will look at */
- memset(&tmp, 0, sizeof(tmp));
- for (i = 0; i < PLPA_NAME(len) * 8; ++i) {
- if (PLPA_CPU_ISSET(i, cpuset)) {
- PLPA_CPU_SET(i, &tmp);
- }
- }
- }
-
- /* Otherwise, the user supplied a buffer that is exactly the
- right size. Just for clarity of code, copy the user's
- buffer into the temporary and use that. */
- else {
- memcpy(&tmp, cpuset, cpusetsize);
- }
-
- /* Now do the syscall */
- ret = syscall(__NR_sched_setaffinity, pid, PLPA_NAME(len), &tmp);
-
- /* Return 0 upon success. According to
- http://www.open-mpi.org/community/lists/plpa-users/2006/02/0016.php,
- all the kernel implementations return >= 0 upon success. */
- return (ret >= 0) ? 0 : ret;
- break;
-
- case PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED):
- /* Process affinity not supported here */
- return ENOSYS;
- break;
-
- default:
- /* Something went wrong */
- /* JMS: would be good to have something other than EINVAL here
- -- suggestions? */
- return EINVAL;
- break;
- }
-}
-
-
-/**
- * Call the kernel's getaffinity, massaging the user's input
- * parameters as necessary
- */
-int PLPA_NAME(sched_getaffinity)(pid_t pid, size_t cpusetsize,
- PLPA_NAME(cpu_set_t) *cpuset)
-{
- int ret;
- PLPA_NAME(api_type_t) api;
-
- /* Check to see that we're initialized */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* Check for bozo arguments */
- if (NULL == cpuset) {
- return EINVAL;
- }
- /* Probe the API type */
- if (0 != (ret = PLPA_NAME(api_probe)(&api))) {
- return ret;
- }
- switch (api) {
- case PLPA_NAME_CAPS(PROBE_OK):
- /* This shouldn't happen, but check anyway */
- if (PLPA_NAME(len) > sizeof(*cpuset)) {
- return EINVAL;
- }
-
- /* If the user supplied a buffer that is too small, then don't
- even bother */
- if (cpusetsize < PLPA_NAME(len)) {
- return EINVAL;
- }
-
- /* Now we know that the user's buffer is >= the size required
- by the kernel. If it's >, then zero it out so that the
- bits at the top are cleared (since they won't be set by the
- kernel) */
- if (cpusetsize > PLPA_NAME(len)) {
- memset(cpuset, 0, cpusetsize);
- }
-
- /* Now do the syscall */
- ret = syscall(__NR_sched_getaffinity, pid, PLPA_NAME(len), cpuset);
-
- /* Return 0 upon success. According to
- http://www.open-mpi.org/community/lists/plpa-users/2006/02/0016.php,
- all the kernel implementations return >= 0 upon success. */
- return (ret >= 0) ? 0 : ret;
- break;
-
- case PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED):
- /* Process affinity not supported here */
- return ENOSYS;
- break;
-
- default:
- /* Something went wrong */
- return EINVAL;
- break;
- }
-}
-
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_internal.h
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_internal.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_internal.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,30 +0,0 @@
-/* -*- c -*-
- *
- * Copyright (c) 2004-2005 The Trustees of Indiana University.
- * All rights reserved.
- * Copyright (c) 2004-2005 The Regents of the University of California.
- * All rights reserved.
- * Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
- * $COPYRIGHT$
- *
- * Additional copyrights may follow
- *
- * $HEADER$
- */
-
-#ifndef PLPA_INTERNAL_H
-#define PLPA_INTERNAL_H
-
-#include <plpa.h>
-
-/* Have we initialized yet? */
-extern int PLPA_NAME(initialized);
-
-/* Cached size of the affinity buffers that the kernel expects */
-extern size_t PLPA_NAME(len);
-
-/* Setup API type */
-int PLPA_NAME(api_probe_init)(void);
-
-#endif /* PLPA_INTERNAL_H */
-
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_map.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_map.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_map.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,1066 +0,0 @@
-/*
- * Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
- *
- * Portions of this file originally contributed by Advanced Micro
- * Devices, Inc. See notice below.
- */
-/* ============================================================
- License Agreement
-
- Copyright (c) 2006, 2007 Advanced Micro Devices, Inc.
- All rights reserved.
-
- Redistribution and use in any form of this material and any product
- thereof including software in source or binary forms, along with any
- related documentation, with or without modification ("this material"),
- is permitted provided that the following conditions are met:
-
- + Redistributions of source code of any software must retain the above
- copyright notice and all terms of this license as part of the code.
-
- + Redistributions in binary form of any software must reproduce the
- above copyright notice and all terms of this license in any related
- documentation and/or other materials.
-
- + Neither the names nor trademarks of Advanced Micro Devices, Inc. or
- any copyright holders or contributors may be used to endorse or
- promote products derived from this material without specific prior
- written permission.
-
- + Notice about U.S. Government restricted rights: This material is
- provided with "RESTRICTED RIGHTS." Use, duplication or disclosure by
- the U.S. Government is subject to the full extent of restrictions set
- forth in FAR52.227 and DFARS252.227 et seq., or any successor or
- applicable regulations. Use of this material by the U.S. Government
- constitutes acknowledgment of the proprietary rights of Advanced Micro
- Devices, Inc.
- and any copyright holders and contributors.
-
- + In no event shall anyone redistributing or accessing or using this
- material commence or participate in any arbitration or legal action
- relating to this material against Advanced Micro Devices, Inc. or any
- copyright holders or contributors. The foregoing shall survive any
- expiration or termination of this license or any agreement or access
- or use related to this material.
-
- + ANY BREACH OF ANY TERM OF THIS LICENSE SHALL RESULT IN THE IMMEDIATE
- REVOCATION OF ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE THIS MATERIAL.
-
- THIS MATERIAL IS PROVIDED BY ADVANCED MICRO DEVICES, INC. AND ANY
- COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" IN ITS CURRENT CONDITION
- AND WITHOUT ANY REPRESENTATIONS, GUARANTEE, OR WARRANTY OF ANY KIND OR
- IN ANY WAY RELATED TO SUPPORT, INDEMNITY, ERROR FREE OR UNINTERRUPTED
- OPERATION, OR THAT IT IS FREE FROM DEFECTS OR VIRUSES. ALL
- OBLIGATIONS ARE HEREBY DISCLAIMED - WHETHER EXPRESS, IMPLIED, OR
- STATUTORY - INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
- TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, ACCURACY,
- COMPLETENESS, OPERABILITY, QUALITY OF SERVICE, OR NON-INFRINGEMENT. IN
- NO EVENT SHALL ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, PUNITIVE, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- USE, REVENUE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED OR BASED ON ANY THEORY OF LIABILITY ARISING IN ANY WAY RELATED
- TO THIS MATERIAL, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- THE ENTIRE AND AGGREGATE LIABILITY OF ADVANCED MICRO DEVICES, INC. AND
- ANY COPYRIGHT HOLDERS AND CONTRIBUTORS SHALL NOT EXCEED TEN DOLLARS
- (US $10.00). ANYONE REDISTRIBUTING OR ACCESSING OR USING THIS MATERIAL
- ACCEPTS THIS ALLOCATION OF RISK AND AGREES TO RELEASE ADVANCED MICRO
- DEVICES, INC. AND ANY COPYRIGHT HOLDERS AND CONTRIBUTORS FROM ANY AND
- ALL LIABILITIES, OBLIGATIONS, CLAIMS, OR DEMANDS IN EXCESS OF TEN
- DOLLARS (US $10.00). THE FOREGOING ARE ESSENTIAL TERMS OF THIS LICENSE
- AND, IF ANY OF THESE TERMS ARE CONSTRUED AS UNENFORCEABLE, FAIL IN
- ESSENTIAL PURPOSE, OR BECOME VOID OR DETRIMENTAL TO ADVANCED MICRO
- DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR CONTRIBUTORS FOR ANY REASON,
- THEN ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE THIS MATERIAL SHALL
- TERMINATE IMMEDIATELY. MOREOVER, THE FOREGOING SHALL SURVIVE ANY
- EXPIRATION OR TERMINATION OF THIS LICENSE OR ANY AGREEMENT OR ACCESS
- OR USE RELATED TO THIS MATERIAL.
-
- NOTICE IS HEREBY PROVIDED, AND BY REDISTRIBUTING OR ACCESSING OR USING
- THIS MATERIAL SUCH NOTICE IS ACKNOWLEDGED, THAT THIS MATERIAL MAY BE
- SUBJECT TO RESTRICTIONS UNDER THE LAWS AND REGULATIONS OF THE UNITED
- STATES OR OTHER COUNTRIES, WHICH INCLUDE BUT ARE NOT LIMITED TO, U.S.
- EXPORT CONTROL LAWS SUCH AS THE EXPORT ADMINISTRATION REGULATIONS AND
- NATIONAL SECURITY CONTROLS AS DEFINED THEREUNDER, AS WELL AS STATE
- DEPARTMENT CONTROLS UNDER THE U.S. MUNITIONS LIST. THIS MATERIAL MAY
- NOT BE USED, RELEASED, TRANSFERRED, IMPORTED, EXPORTED AND/OR RE-
- EXPORTED IN ANY MANNER PROHIBITED UNDER ANY APPLICABLE LAWS, INCLUDING
- U.S. EXPORT CONTROL LAWS REGARDING SPECIFICALLY DESIGNATED PERSONS,
- COUNTRIES AND NATIONALS OF COUNTRIES SUBJECT TO NATIONAL SECURITY
- CONTROLS.
- MOREOVER,
- THE FOREGOING SHALL SURVIVE ANY EXPIRATION OR TERMINATION OF ANY
- LICENSE OR AGREEMENT OR ACCESS OR USE RELATED TO THIS MATERIAL.
-
- This license forms the entire agreement regarding the subject matter
- hereof and supersedes all proposals and prior discussions and writings
- between the parties with respect thereto. This license does not affect
- any ownership, rights, title, or interest in, or relating to, this
- material. No terms of this license can be modified or waived, and no
- breach of this license can be excused, unless done so in a writing
- signed by all affected parties. Each term of this license is
- separately enforceable. If any term of this license is determined to
- be or becomes unenforceable or illegal, such term shall be reformed to
- the minimum extent necessary in order for this license to remain in
- effect in accordance with its terms as modified by such reformation.
- This license shall be governed by and construed in accordance with the
- laws of the State of Texas without regard to rules on conflicts of law
- of any state or jurisdiction or the United Nations Convention on the
- International Sale of Goods. All disputes arising out of this license
- shall be subject to the jurisdiction of the federal and state courts
- in Austin, Texas, and all defenses are hereby waived concerning
- personal jurisdiction and venue of these courts.
- ============================================================ */
-
-#include "plpa.h"
-#include "plpa_internal.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <dirent.h>
-#include <limits.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdbool.h>
-
-typedef struct tuple_t_ {
- int processor_id, socket_id, core_id, online;
-} tuple_t;
-
-static const char *sysfs_mount = "/sys";
-static int supported = 0;
-static int num_processors = -1;
-static int max_processor_id = -1;
-static int num_sockets = -1;
-static int max_socket_id = -1;
-static int *max_core_id = NULL;
-static int *num_cores = NULL;
-static int max_core_id_overall = -1;
-static tuple_t *map_processor_id_to_tuple = NULL;
-static tuple_t **map_tuple_to_processor_id = NULL;
-static PLPA_NAME(cache_behavior_t) cache_behavior = PLPA_NAME_CAPS(CACHE_IGNORE);
-
-static void clear_cache(void)
-{
- if (NULL != max_core_id) {
- free(max_core_id);
- max_core_id = NULL;
- }
- if (NULL != num_cores) {
- free(num_cores);
- num_cores = NULL;
- }
- if (NULL != map_processor_id_to_tuple) {
- free(map_processor_id_to_tuple);
- map_processor_id_to_tuple = NULL;
- }
- if (NULL != map_tuple_to_processor_id) {
- free(map_tuple_to_processor_id);
- map_tuple_to_processor_id = NULL;
- }
-
- num_processors = max_processor_id = -1;
- num_sockets = max_socket_id = -1;
- max_core_id_overall = -1;
-}
-
-static void load_cache(void)
-{
- int i, j, k, invalid_entry, fd, found_online;
- char path[PATH_MAX], buf[8];
- PLPA_NAME(cpu_set_t) valid_processors;
- PLPA_NAME(cpu_set_t) *cores_on_sockets;
- int found;
- DIR *dir;
- struct dirent dentry, *dentryp = NULL;
-
-#if PLPA_DEBUG
- char *temp = getenv("PLPA_SYSFS_MOUNT");
- if (temp) {
- sysfs_mount = temp;
- }
-#endif
-
- /* Check for the parent directory */
- sprintf(path, "%s/devices/system/cpu", sysfs_mount);
- if (access(path, R_OK|X_OK)) {
- return;
- }
-
- dir = opendir(path);
- if (NULL == dir) {
- return;
- }
-
- /* Catch all entries of format "cpu%d", count them and maintain
- max_processor_id */
- num_processors = 0;
- PLPA_CPU_ZERO(&valid_processors);
- do {
- int ret = readdir_r(dir, &dentry, &dentryp);
- if (0 != ret) {
- closedir(dir);
- clear_cache();
- return;
- }
-
- if (dentryp) {
- int cpuid;
-
- ret = sscanf(dentryp->d_name, "cpu%d", &cpuid);
- if (1 == ret) {
- ++num_processors;
- if (cpuid >= PLPA_BITMASK_CPU_MAX) {
- closedir(dir);
- clear_cache();
- return;
- } else if (cpuid > max_processor_id) {
- max_processor_id = cpuid;
- }
- PLPA_CPU_SET(cpuid, &valid_processors);
- }
- }
- } while (NULL != dentryp);
- closedir(dir);
-
- /* If we found no processors, then we have no topology info */
- if (0 == num_processors) {
- clear_cache();
- return;
- }
-
- /* Malloc space for the first map (processor ID -> tuple).
- Include enough space for one invalid entry. */
- map_processor_id_to_tuple = malloc(sizeof(tuple_t) *
- (max_processor_id + 2));
- if (NULL == map_processor_id_to_tuple) {
- clear_cache();
- return;
- }
- for (i = 0; i <= max_processor_id; ++i) {
- if (PLPA_CPU_ISSET(i, &valid_processors)) {
- map_processor_id_to_tuple[i].processor_id = i;
- } else {
- map_processor_id_to_tuple[i].processor_id = -1;
- }
- map_processor_id_to_tuple[i].socket_id = -1;
- map_processor_id_to_tuple[i].core_id = -1;
- }
- /* Set the invalid entry */
- invalid_entry = i;
- map_processor_id_to_tuple[invalid_entry].processor_id = -1;
- map_processor_id_to_tuple[invalid_entry].socket_id = -1;
- map_processor_id_to_tuple[invalid_entry].core_id = -1;
-
- /* Build a cached map of (socket,core) tuples */
- for (found = 0, i = 0; i <= max_processor_id; ++i) {
-
- /* Check for invalid processor ID */
- if (map_processor_id_to_tuple[i].processor_id < 0) {
- continue;
- }
-
- /* Read the "online" state for this processor. If the online
- file is not there, then the kernel likely doesn't have
- hotplug support so just assume that it's online. Some notes:
-
- - the perms on the "online" file are root/600, so only root
- will see this info
- - if online is 0, then all the topology files disappear (!)
- -- so PLPA needs to compensate for that
- */
- found_online = 0;
- sprintf(path, "%s/devices/system/cpu/cpu%d/online",
- sysfs_mount, i);
- fd = open(path, O_RDONLY);
- memset(buf, 0, sizeof(buf));
- if (fd >= 0 && read(fd, buf, sizeof(buf) - 1) > 0) {
- found_online = 1;
- sscanf(buf, "%d", &(map_processor_id_to_tuple[i].online));
- } else {
- map_processor_id_to_tuple[i].online = 1;
- }
- if (fd >= 0) {
- close(fd);
- }
-
- /* Core ID */
- sprintf(path, "%s/devices/system/cpu/cpu%d/topology/core_id",
- sysfs_mount, i);
- fd = open(path, O_RDONLY);
- if (fd >= 0) {
- memset(buf, 0, sizeof(buf));
- if (read(fd, buf, sizeof(buf) - 1) > 0) {
- sscanf(buf, "%d", &(map_processor_id_to_tuple[i].core_id));
- } else {
- map_processor_id_to_tuple[i].core_id = -1;
- }
- close(fd);
- }
- /* Special case: we didn't find the core_id file, but we *did*
- find the online file and the processor is offline -- then
- just mark the core ID as "unknown" and keep going (because
- if a processor is offline, the core_id file won't exist --
- grumble) */
- else if (found_online && 0 == map_processor_id_to_tuple[i].online) {
- map_processor_id_to_tuple[i].core_id = -1;
- }
-
- /* Socket ID */
- sprintf(path,
- "%s/devices/system/cpu/cpu%d/topology/physical_package_id",
- sysfs_mount, i);
- fd = open(path, O_RDONLY);
- if (fd >= 0) {
- memset(buf, 0, sizeof(buf));
- if (read(fd, buf, sizeof(buf) - 1) > 0) {
- sscanf(buf, "%d", &(map_processor_id_to_tuple[i].socket_id));
- }
- close(fd);
- found = 1;
- }
- /* Special case: we didn't find the socket_id file, but we
- *did* find the online file and the processor is offline --
- then just mark the socket ID as "unknown" and keep going
- (because if a processor is offline, the socket_id file won't
- exist -- grumble) */
- else if (found_online && 0 == map_processor_id_to_tuple[i].online) {
- map_processor_id_to_tuple[i].socket_id = -1;
- }
-
- /* Keep a running tab on the max socket number */
- if (map_processor_id_to_tuple[i].socket_id > max_socket_id) {
- max_socket_id = map_processor_id_to_tuple[i].socket_id;
- }
- }
-
- /* If we didn't find any core_id/physical_package_id's, then we
- don't have the topology info */
- if (!found) {
- clear_cache();
- return;
- }
-
- /* Now that we know the max number of sockets, allocate some
- arrays */
- max_core_id = malloc(sizeof(int) * (max_socket_id + 1));
- if (NULL == max_core_id) {
- clear_cache();
- return;
- }
- num_cores = malloc(sizeof(int) * (max_socket_id + 1));
- if (NULL == num_cores) {
- clear_cache();
- return;
- }
- for (i = 0; i <= max_socket_id; ++i) {
- num_cores[i] = -1;
- max_core_id[i] = -1;
- }
-
- /* Find the max core number on each socket */
- for (i = 0; i <= max_processor_id; ++i) {
- if (map_processor_id_to_tuple[i].processor_id < 0 ||
- map_processor_id_to_tuple[i].socket_id < 0) {
- continue;
- }
- if (map_processor_id_to_tuple[i].core_id >
- max_core_id[map_processor_id_to_tuple[i].socket_id]) {
- max_core_id[map_processor_id_to_tuple[i].socket_id] =
- map_processor_id_to_tuple[i].core_id;
- }
- if (max_core_id[map_processor_id_to_tuple[i].socket_id] >
- max_core_id_overall) {
- max_core_id_overall =
- max_core_id[map_processor_id_to_tuple[i].socket_id];
- }
- }
-
- /* Go through and count the number of unique sockets found. It
- may not be the same as max_socket_id because there may be
- "holes" -- e.g., sockets 0 and 3 are used, but sockets 1 and 2
- are empty. */
- for (j = i = 0; i <= max_socket_id; ++i) {
- if (max_core_id[i] >= 0) {
- ++j;
- }
- }
- if (j > 0) {
- num_sockets = j;
- }
-
- /* Count how many cores are available on each socket. This may
- not be the same as max_core_id[socket_num] if there are
- "holes". I don't know if holes can happen (i.e., if specific
- cores can be taken offline), but what the heck... */
- cores_on_sockets = malloc(sizeof(PLPA_NAME(cpu_set_t)) *
- (max_socket_id + 1));
- if (NULL == cores_on_sockets) {
- clear_cache();
- return;
- }
- for (i = 0; i <= max_socket_id; ++i) {
- PLPA_CPU_ZERO(&(cores_on_sockets[i]));
- }
- for (i = 0; i <= max_processor_id; ++i) {
- if (map_processor_id_to_tuple[i].socket_id >= 0) {
- PLPA_CPU_SET(map_processor_id_to_tuple[i].core_id,
- &(cores_on_sockets[map_processor_id_to_tuple[i].socket_id]));
- }
- }
- for (i = 0; i <= max_socket_id; ++i) {
- int count = 0;
- for (j = 0; j <= max_core_id[i]; ++j) {
- if (PLPA_CPU_ISSET(j, &(cores_on_sockets[i]))) {
- ++count;
- }
- }
- if (count > 0) {
- num_cores[i] = count;
- }
- }
- free(cores_on_sockets);
-
- /* Now go through and build the map in the other direction:
- (socket,core) => processor_id. This map simply points to
- entries in the other map (i.e., it's by reference instead of by
- value). */
- map_tuple_to_processor_id = malloc(sizeof(tuple_t *) *
- ((max_socket_id + 1) *
- (max_core_id_overall + 1)));
- if (NULL == map_tuple_to_processor_id) {
- clear_cache();
- return;
- }
- /* Compute map */
- for (i = 0; i <= max_socket_id; ++i) {
- for (j = 0; j <= max_core_id_overall; ++j) {
- tuple_t **tuple_ptr = &map_tuple_to_processor_id[
- i * (max_core_id_overall + 1) + j];
-
- /* Default to the invalid entry in the other map, meaning
- that this (socket,core) combination doesn't exist
- (e.g., the core number does not exist in this socket,
- although it does exist in other sockets). */
- *tuple_ptr = &map_processor_id_to_tuple[invalid_entry];
-
- /* See if this (socket,core) tuple exists in the other
- map. If so, set this entry to point to it (overriding
- the invalid entry default). */
- for (k = 0; k <= max_processor_id; ++k) {
- if (map_processor_id_to_tuple[k].socket_id == i &&
- map_processor_id_to_tuple[k].core_id == j) {
- *tuple_ptr = &map_processor_id_to_tuple[k];
-#if defined(PLPA_DEBUG) && PLPA_DEBUG
- printf("Creating map [%d]: (socket %d, core %d) -> ID %d\n",
- i * (max_core_id_overall + 1) + j,
- i, j, k);
-#endif
- break;
- }
- }
- }
- }
-
- supported = 1;
-}
-
-static int cache_action(void)
-{
- switch (cache_behavior) {
- case PLPA_NAME_CAPS(CACHE_USE):
- if (NULL == map_processor_id_to_tuple) {
- load_cache();
- }
- break;
-
- case PLPA_NAME_CAPS(CACHE_IGNORE):
- clear_cache();
- load_cache();
- break;
-
- default:
- return EINVAL;
- }
-
- return 0;
-}
-
-/* Return whether this kernel supports topology information or not */
-int PLPA_NAME(have_topology_information)(int *supported_arg)
-{
- int ret;
-
- /* Initialize if not already done so */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* Check for bozo arguments */
- if (NULL == supported_arg) {
- return EINVAL;
- }
-
- *supported_arg = supported;
- return 0;
-}
-
-int PLPA_NAME(map_to_processor_id)(int socket_id, int core_id,
- int *processor_id)
-{
- int ret;
-
- /* Initialize if not already done so */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* If this system doesn't support mapping, sorry Charlie */
- if (!supported) {
- return ENOSYS;
- }
-
- /* Check for bozo arguments */
- if (NULL == processor_id) {
- return EINVAL;
- }
-
- /* Check cache behavior */
- if (0 != (ret = cache_action())) {
- return ret;
- }
-
- /* Check for some invalid entries */
- if (socket_id < 0 || socket_id > max_socket_id ||
- core_id < 0 || core_id > max_core_id[socket_id]) {
- return ENOENT;
- }
- /* If the mapping returns -1, then this is a non-existent
- socket/core combo (even though they fall within the max socket
- / max core overall values) */
- ret = map_tuple_to_processor_id[socket_id * (max_core_id_overall + 1) +
- core_id]->processor_id;
- if (-1 == ret) {
- return ENOENT;
- }
-
- /* Ok, all should be good -- return the mapping */
- *processor_id = ret;
- return 0;
-}
-
-int PLPA_NAME(map_to_socket_core)(int processor_id,
- int *socket_id, int *core_id)
-{
- int ret;
-
- /* Initialize if not already done so */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* If this system doesn't support mapping, sorry Charlie */
- if (!supported) {
- return ENOSYS;
- }
-
- /* Check for bozo arguments */
- if (NULL == socket_id || NULL == core_id) {
- return EINVAL;
- }
-
- /* Check cache behavior */
- if (0 != (ret = cache_action())) {
- return ret;
- }
-
- /* Check for some invalid entries */
- if (processor_id < 0 || processor_id > max_processor_id ||
- map_processor_id_to_tuple[processor_id].processor_id < 0) {
- return ENOENT;
- }
- ret = map_processor_id_to_tuple[processor_id].socket_id;
- if (-1 == ret) {
- return ENOENT;
- }
-
- /* Ok, all should be good -- return the mapping */
- *socket_id = ret;
- *core_id = map_processor_id_to_tuple[processor_id].core_id;
- return 0;
-}
-
-/* Deprecated function */
-int PLPA_NAME(get_processor_info)(int *num_processors_arg,
- int *max_processor_id_arg)
-{
- return PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_ALL),
- num_processors_arg,
- max_processor_id_arg);
-}
-
-int PLPA_NAME(get_processor_data)(PLPA_NAME(count_specification_t) count_spec,
- int *num_processors_arg,
- int *max_processor_id_arg)
-{
- int i, ret;
- bool match;
-
- /* Initialize if not already done so */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* If this system doesn't support mapping, sorry Charlie */
- if (!supported) {
- return ENOSYS;
- }
-
- /* Check cache behavior */
- if (0 != (ret = cache_action())) {
- return ret;
- }
-
- /* Check for bozo arguments */
- if (NULL == max_processor_id_arg || NULL == num_processors_arg) {
- return EINVAL;
- }
-
- /* If we wanted all processors, we're done */
- if (PLPA_NAME_CAPS(COUNT_ALL) == count_spec) {
- *num_processors_arg = num_processors;
- *max_processor_id_arg = max_processor_id;
- } else {
- /* Otherwise, count the appropriate type */
- *num_processors_arg = 0;
- *max_processor_id_arg = 0;
- for (i = 0; i <= max_processor_id; ++i) {
- if (map_processor_id_to_tuple[i].processor_id >= 0) {
- match = false;
- switch (count_spec) {
- case PLPA_NAME_CAPS(COUNT_ONLINE):
- if (map_processor_id_to_tuple[i].online) {
- match = true;
- }
- break;
-
- case PLPA_NAME_CAPS(COUNT_OFFLINE):
- if (!map_processor_id_to_tuple[i].online) {
- match = true;
- }
- break;
- default:
- /* Just so that compilers don't complain */
- break;
- }
- if (match) {
- ++(*num_processors_arg);
- if (*max_processor_id_arg <
- map_processor_id_to_tuple[i].processor_id) {
- *max_processor_id_arg =
- map_processor_id_to_tuple[i].processor_id;
- }
- }
- }
- }
- }
- return 0;
-}
-
-/* Returns the Linux processor ID for the Nth processor (starting with
- 0). */
-int PLPA_NAME(get_processor_id)(int processor_num,
- PLPA_NAME(count_specification_t) count_spec,
- int *processor_id)
-{
- int ret, i, count;
- bool match;
-
- /* Initialize if not already done so */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* If this system doesn't support mapping, sorry Charlie */
- if (!supported) {
- return ENOSYS;
- }
-
- /* Check for bozo arguments */
- if (NULL == processor_id) {
- return EINVAL;
- }
-
- /* Check cache behavior */
- if (0 != (ret = cache_action())) {
- return ret;
- }
-
- /* Check for out of range params */
- if (processor_num < 0 || processor_num > num_processors) {
- return EINVAL;
- }
-
- /* Find the processor_num'th processor */
- for (count = i = 0; i <= max_processor_id; ++i) {
- if (map_processor_id_to_tuple[i].processor_id >= 0) {
- match = false;
- switch (count_spec) {
- case PLPA_NAME_CAPS(COUNT_ONLINE):
- if (map_processor_id_to_tuple[i].online) {
- match = true;
- }
- break;
-
- case PLPA_NAME_CAPS(COUNT_OFFLINE):
- if (!map_processor_id_to_tuple[i].online) {
- match = true;
- }
- break;
-
- case PLPA_NAME_CAPS(COUNT_ALL):
- match = true;
- break;
- }
- if (match) {
- if (count++ == processor_num) {
- *processor_id = map_processor_id_to_tuple[i].processor_id;
- return 0;
- }
- }
- }
- }
-
- /* Didn't find it */
- return ENODEV;
-}
-
-/* Check to see if a given Linux processor ID exists / is online.
- Returns 0 on success. */
-int PLPA_NAME(get_processor_flags)(int processor_id,
- int *exists_arg, int *online_arg)
-{
- int ret, exists, online;
-
- /* Initialize if not already done so */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* If this system doesn't support mapping, sorry Charlie */
- if (!supported) {
- return ENOSYS;
- }
-
- /* Check for bozo arguments */
- if (NULL == exists_arg && NULL == online_arg) {
- return EINVAL;
- }
-
- /* Check cache behavior */
- if (0 != (ret = cache_action())) {
- return ret;
- }
-
- /* Check for out of range params */
- if (processor_id < 0 || processor_id > max_processor_id) {
- return EINVAL;
- }
-
- exists = online = 0;
- if (processor_id == map_processor_id_to_tuple[processor_id].processor_id) {
- exists = 1;
- if (map_processor_id_to_tuple[processor_id].online) {
- online = 1;
- }
- }
- if (NULL != exists_arg) {
- *exists_arg = exists;
- }
- if (NULL != online_arg) {
- *online_arg = online;
- }
-
- return 0;
-}
-
-/* Return the max socket number */
-int PLPA_NAME(get_socket_info)(int *num_sockets_arg, int *max_socket_id_arg)
-{
- int ret;
-
- /* Initialize if not already done so */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* If this system doesn't support mapping, sorry Charlie */
- if (!supported) {
- return ENOSYS;
- }
-
- /* Check cache behavior */
- if (0 != (ret = cache_action())) {
- return ret;
- }
-
- /* Check for bozo arguments */
- if (NULL == max_socket_id_arg || NULL == num_sockets_arg) {
- return EINVAL;
- }
-
- /* All done */
- *num_sockets_arg = num_sockets;
- *max_socket_id_arg = max_socket_id;
- return 0;
-}
-
-/* Returns the Linux socket ID for the Nth socket (starting with 0). */
-int PLPA_NAME(get_socket_id)(int socket_num, int *socket_id)
-{
- int ret, i, j, k, count;
-
- /* Initialize if not already done so */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* If this system doesn't support mapping, sorry Charlie */
- if (!supported) {
- return ENOSYS;
- }
-
- /* Check for bozo arguments */
- if (NULL == socket_id) {
- return EINVAL;
- }
-
- /* Check cache behavior */
- if (0 != (ret = cache_action())) {
- return ret;
- }
-
- /* Check for out of range params */
- if (socket_num < 0 || socket_num > num_sockets) {
- return EINVAL;
- }
-
- /* Find the socket_num'th socket */
- for (count = i = 0; i <= max_socket_id; ++i) {
- /* See if any core in this socket is active. If so, count
- this socket */
- for (j = 0; j <= max_core_id_overall; ++j) {
- k = i * (max_core_id_overall + 1) + j;
- if (map_tuple_to_processor_id[k]->processor_id >= 0) {
- if (count++ == socket_num) {
- *socket_id = map_tuple_to_processor_id[k]->socket_id;
- return 0;
- }
- /* Ok, we found one -- skip to the end of this socket */
- j = max_core_id_overall + 1;
- }
- }
- }
-
- /* Didn't find it */
- return ENODEV;
-}
-
-/* Return the number of cores in a socket and the max core ID number */
-int PLPA_NAME(get_core_info)(int socket_id, int *num_cores_arg,
- int *max_core_id_arg)
-{
- int ret;
-
- /* Initialize if not already done so */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* If this system doesn't support mapping, sorry Charlie */
- if (!supported) {
- return ENOSYS;
- }
-
- /* Check for bozo arguments */
- if (NULL == max_core_id_arg || NULL == num_cores_arg) {
- return EINVAL;
- }
-
- /* Check cache behavior */
- if (0 != (ret = cache_action())) {
- return ret;
- }
-
- /* Check for some invalid entries */
- if (socket_id < 0 || socket_id > max_socket_id ||
- -1 == max_core_id[socket_id]) {
- return ENOENT;
- }
- ret = num_cores[socket_id];
- if (-1 == ret) {
- return ENOENT;
- }
-
- /* All done */
- *num_cores_arg = ret;
- *max_core_id_arg = max_core_id[socket_id];
- return 0;
-}
-
-/* Given a specific socket, returns the Linux core ID for the Nth core
- (starting with 0) */
-int PLPA_NAME(get_core_id)(int socket_id, int core_num, int *core_id)
-{
- int ret, i, j, count;
-
- /* Initialize if not already done so */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* If this system doesn't support mapping, sorry Charlie */
- if (!supported) {
- return ENOSYS;
- }
-
- /* Check for bozo arguments */
- if (NULL == core_id) {
- return EINVAL;
- }
-
- /* Check cache behavior */
- if (0 != (ret = cache_action())) {
- return ret;
- }
-
- /* Check for out of range params */
- if (socket_id < 0 || socket_id > max_socket_id ||
- core_num < 0 || core_num > max_core_id_overall) {
- return EINVAL;
- }
-
- /* Find the core_num'th core */
- for (count = i = 0, j = socket_id * (max_core_id_overall + 1);
- i <= max_core_id_overall; ++i) {
- if (map_tuple_to_processor_id[j + i]->processor_id >= 0) {
- if (count++ == core_num) {
- *core_id = map_tuple_to_processor_id[j + i]->core_id;
- return 0;
- }
- }
- }
-
- /* Didn't find it */
- return ENODEV;
-}
-
-/* Check to see if a given Linux (socket_id,core_id) tuple exists / is
- online. Returns 0 on success. */
-int PLPA_NAME(get_core_flags)(int socket_id, int core_id,
- int *exists_arg, int *online_arg)
-{
- int ret, i, exists, online;
-
- /* Initialize if not already done so */
- if (!PLPA_NAME(initialized)) {
- if (0 != (ret = PLPA_NAME(init)())) {
- return ret;
- }
- }
-
- /* If this system doesn't support mapping, sorry Charlie */
- if (!supported) {
- return ENOSYS;
- }
-
- /* Check for bozo arguments */
- if (NULL == exists_arg && NULL == online_arg) {
- return EINVAL;
- }
-
- /* Check cache behavior */
- if (0 != (ret = cache_action())) {
- return ret;
- }
-
- /* Check for out of range params */
- if (socket_id < 0 || socket_id > max_socket_id ||
- core_id < 0 || core_id > max_core_id_overall) {
- return EINVAL;
- }
-
- exists = online = 0;
- i = socket_id * (max_core_id_overall + 1) + core_id;
- if (map_tuple_to_processor_id[i]->processor_id >= 0) {
- exists = 1;
- if (map_tuple_to_processor_id[i]->online) {
- online = 1;
- }
- }
-
- if (NULL != exists_arg) {
- *exists_arg = exists;
- }
- if (NULL != online_arg) {
- *online_arg = online;
- }
- return 0;
-}
-
-/* Set PLPA's caching behavior */
-int PLPA_NAME(set_cache_behavior)(PLPA_NAME(cache_behavior_t) behavior)
-{
- switch (behavior) {
- case PLPA_NAME_CAPS(CACHE_USE):
- if (PLPA_NAME_CAPS(CACHE_USE) != cache_behavior) {
- load_cache();
- cache_behavior = PLPA_NAME_CAPS(CACHE_USE);
- }
- break;
-
- case PLPA_NAME_CAPS(CACHE_IGNORE):
- if (PLPA_NAME_CAPS(CACHE_IGNORE) != cache_behavior) {
- clear_cache();
- cache_behavior = PLPA_NAME_CAPS(CACHE_IGNORE);
- }
- break;
-
- case PLPA_NAME_CAPS(CACHE_REFRESH):
- if (PLPA_NAME_CAPS(CACHE_USE) != cache_behavior) {
- return EINVAL;
- }
- clear_cache();
- load_cache();
- break;
-
- default:
- return EINVAL;
- }
-
- return 0;
-}
Deleted: mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_runtime.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_runtime.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/bind/plpa/plpa/plpa_runtime.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
- */
-
-#include "plpa.h"
-#include "plpa_internal.h"
-
-#include <errno.h>
-#include <pthread.h>
-
-/* Global variables */
-int PLPA_NAME(initialized) = 0;
-
-/* Local variables */
-static int refcount = 0;
-static pthread_mutex_t mutex;
-
-
-/* Central clearing point for all parts of PLPA that need to be
- initialized. It is erroneous to call this function by more than
- one thread simultaneously. */
-int PLPA_NAME(init)(void)
-{
- int ret;
-
- /* If we're already initialized, simply increase the refcount */
- if (PLPA_NAME(initialized)) {
- pthread_mutex_lock(&mutex);
- ++refcount;
- pthread_mutex_unlock(&mutex);
- return 0;
- }
-
- /* Otherwise, initialize all the sybsystems */
- if (0 != (ret = pthread_mutex_init(&mutex, NULL)) ||
- 0 != (ret = PLPA_NAME(api_probe_init)()) ||
- 0 != (ret = PLPA_NAME(set_cache_behavior)(PLPA_NAME_CAPS(CACHE_USE)))) {
- return ret;
- }
-
- PLPA_NAME(initialized) = 1;
- refcount = 1;
- return 0;
-}
-
-
-/* Central clearing point for all parts of PLPA that need to be
- shutdown. */
-int PLPA_NAME(finalize)(void)
-{
- int val;
-
- /* If we're not initialized, return an error */
- if (!PLPA_NAME(initialized)) {
- return ENOENT;
- }
-
- /* Decrement and check the refcount. If it's nonzero, then simply
- return success. */
- pthread_mutex_lock(&mutex);
- val = --refcount;
- pthread_mutex_unlock(&mutex);
- if (0 != val) {
- return 0;
- }
-
- /* Ok, we're the last one. Cleanup. */
- PLPA_NAME(set_cache_behavior)(PLPA_NAME_CAPS(CACHE_IGNORE));
- pthread_mutex_destroy(&mutex);
- PLPA_NAME(initialized) = 0;
- return 0;
-}
Deleted: mpich2/trunk/src/pm/hydra/utils/ckpoint/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/ckpoint/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/ckpoint/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,13 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-AM_CPPFLAGS += -I$(top_srcdir)/utils/ckpoint
-
-libhydra_a_SOURCES += $(top_srcdir)/utils/ckpoint/ckpoint.c
-
-if hydra_have_blcr
-include utils/ckpoint/blcr/Makefile.mk
-endif
Deleted: mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/Makefile.mk 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/Makefile.mk 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,9 +0,0 @@
-# -*- Mode: Makefile; -*-
-#
-# (C) 2008 by Argonne National Laboratory.
-# See COPYRIGHT in top-level directory.
-#
-
-libhydra_a_SOURCES += $(top_srcdir)/utils/ckpoint/blcr/ckpoint_blcr.c
-
-# include $(top_srcdir)/utils/ckpoint/blcr/blcr/Makefile.mk
Deleted: mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/ckpoint_blcr.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/ckpoint_blcr.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/ckpoint_blcr.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,278 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "ckpoint.h"
-#include "ckpoint_blcr.h"
-#include <libcr.h>
-
-static int my_callback(void *arg)
-{
- int rc;
-
- rc = cr_checkpoint(CR_CHECKPOINT_OMIT);
-
- switch (rc) {
- case -CR_ETEMPFAIL:
- /* One of the processes indicated that it couldn't take the checkpoint now. Try again later. */
- return -1;
- break;
- case -CR_EPERMFAIL:
- /* One of the processes indicated a permanent failure */
- return -1;
- break;
- case -CR_EOMITTED:
- /* This is the expected return */
- break;
- default:
- /* Something bad happened */
- return -1;
- }
-
-
- return 0;
-}
-
-static HYD_Status create_fifo(const char *fname_template, int rank, int *fd)
-{
- HYD_Status status = HYD_SUCCESS;
- char filename[256];
- int ret;
-
- snprintf(filename, sizeof(filename), fname_template, (int) getpid(), rank);
-
- ret = mkfifo(filename, 0600);
- HYDU_ERR_CHKANDJUMP1(status, ret, HYD_INTERNAL_ERROR, "mkfifo failed: %s\n",
- strerror(errno));
-
- *fd = open(filename, O_RDWR);
- HYDU_ERR_CHKANDJUMP1(status, *fd < 0, HYD_INTERNAL_ERROR, "open failed: %s\n",
- strerror(errno));
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-
-static HYD_Status create_stdinouterr_fifos(int num_ranks, int ranks[], int *in, int *out,
- int *err)
-{
- HYD_Status status = HYD_SUCCESS;
- int r;
-
- for (r = 0; r < num_ranks; ++r) {
- if (in && ranks[r] == 0) {
- status = create_fifo("/tmp/hydra-in-%d:%d", ranks[r], in);
- if (status)
- HYDU_ERR_POP(status, "create in fifo\n");
- }
- if (out) {
- status = create_fifo("/tmp/hydra-out-%d:%d", ranks[r], &out[r]);
- if (status)
- HYDU_ERR_POP(status, "create out fifo\n");
- }
- if (err) {
- status = create_fifo("/tmp/hydra-err-%d:%d", ranks[r], &err[r]);
- if (status)
- HYDU_ERR_POP(status, "create err fifo\n");
- }
- }
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-
-static HYD_Status create_env_file(const HYD_Env_t * envlist, int num_ranks, int *ranks)
-{
- HYD_Status status = HYD_SUCCESS;
- char filename[256];
- FILE *f;
- const HYD_Env_t *e;
- int ret;
- int r;
-
- HYDU_FUNC_ENTER();
-
- for (r = 0; r < num_ranks; ++r) {
- snprintf(filename, sizeof(filename), "/tmp/hydra-env-file-%d:%d", (int) getpid(),
- ranks[r]);
-
- f = fopen(filename, "w");
- HYDU_ERR_CHKANDJUMP1(status, f == NULL, HYD_INTERNAL_ERROR, "fopen failed: %s\n",
- strerror(errno));
-
- for (e = envlist; e; e = e->next) {
- fprintf(f, "%s=%s\n", e->env_name, e->env_value);
- }
-
- ret = fclose(f);
- HYDU_ERR_CHKANDJUMP1(status, ret, HYD_INTERNAL_ERROR, "fclose failed: %s\n",
- strerror(errno));
- }
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-HYD_Status HYDU_ckpoint_blcr_suspend(const char *prefix)
-{
- HYD_Status status = HYD_SUCCESS;
- int ret;
- int fd;
- cr_checkpoint_args_t my_args;
- cr_checkpoint_handle_t my_handle;
- char filename[256];
-
- HYDU_FUNC_ENTER();
-
- /* build the checkpoint filename */
- snprintf(filename, sizeof(filename), "%s/context", prefix);
-
- /* remove existing checkpoint file, if any */
- (void) unlink(filename);
-
- /* open the checkpoint file */
- fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC /* | O_LARGEFILE */ , 0600);
- HYDU_ERR_CHKANDJUMP1(status, fd < 0, HYD_INTERNAL_ERROR, "open failed: %s\n",
- strerror(errno));
-
- cr_initialize_checkpoint_args_t(&my_args);
- my_args.cr_fd = fd;
- my_args.cr_scope = CR_SCOPE_TREE;
-
- /* issue the request */
- ret = cr_request_checkpoint(&my_args, &my_handle);
- if (ret < 0) {
- HYDU_ERR_CHKANDJUMP1(status, errno == CR_ENOSUPPORT, HYD_INTERNAL_ERROR,
- "cr_request_checkpoint failed, %s\n", strerror(errno));
- HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR, "cr_request_checkpoint failed, %s\n",
- strerror(errno));
- }
- /* wait for the request to complete */
- while (0) {
- ret = cr_poll_checkpoint(&my_handle, NULL);
- if (ret < 0) {
- if ((ret == CR_POLL_CHKPT_ERR_POST) && (errno == CR_ERESTARTED)) {
- HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
- "trying to restart in a checkpoint\n");
- }
- else if (errno == EINTR) {
- /* poll was interrupted by a signal -- retry */
- }
- else {
- HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR,
- "cr_poll_checkpoint failed: %s\n", strerror(errno));
- }
- }
- else if (ret == 0) {
- HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
- "cr_poll_checkpoint returned 0 unexpectedly\n");
- }
- else {
- break;
- }
- }
-
- ret = close(my_args.cr_fd);
- HYDU_ERR_CHKANDJUMP1(status, ret, HYD_INTERNAL_ERROR, "close failed, %s\n",
- strerror(errno));
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-HYD_Status HYDU_ckpoint_blcr_restart(const char *prefix, HYD_Env_t * envlist, int num_ranks,
- int ranks[], int *in, int *out, int *err)
-{
- HYD_Status status = HYD_SUCCESS;
- pid_t mypid;
- int ret;
- int context_fd;
- cr_restart_handle_t cr_handle;
- cr_restart_args_t args;
- char filename[256];
-
- HYDU_FUNC_ENTER();
-
- mypid = getpid();
-
- status = create_env_file(envlist, num_ranks, ranks);
- if (status)
- HYDU_ERR_POP(status, "blcr restart\n");
-
- status = create_stdinouterr_fifos(num_ranks, ranks, in, out, err);
- if (status)
- HYDU_ERR_POP(status, "blcr restart\n");
-
- snprintf(filename, sizeof(filename), "%s/context", prefix);
-
- context_fd = open(filename, O_RDONLY /* | O_LARGEFILE */);
- HYDU_ERR_CHKANDJUMP1(status, context_fd < 0, HYD_INTERNAL_ERROR, "open failed, %s\n",
- strerror(errno));
-
- /* ... initialize the request structure */
- cr_initialize_restart_args_t(&args);
- args.cr_fd = context_fd;
- args.cr_flags = CR_RSTRT_RESTORE_PID;
-
- /* ... issue the request */
- ret = cr_request_restart(&args, &cr_handle);
- HYDU_ERR_CHKANDJUMP1(status, ret, HYD_INTERNAL_ERROR, "cr_request_restart failed, %s\n",
- strerror(errno));
-
- ret = close(context_fd);
- HYDU_ERR_CHKANDJUMP1(status, ret, HYD_INTERNAL_ERROR, "close failed, %s\n",
- strerror(errno));
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-HYD_Status HYDU_ckpoint_blcr_init(void)
-{
- HYD_Status status = HYD_SUCCESS;
- int rc;
- cr_client_id_t client_id;
- cr_callback_id_t callback_id;
-
- HYDU_FUNC_ENTER();
-
- client_id = (int) cr_init();
- if (client_id < 0)
- goto fn_fail;
-
- callback_id = cr_register_callback(my_callback, &rc, CR_SIGNAL_CONTEXT);
- if (callback_id < 0)
- goto fn_fail;
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/ckpoint_blcr.h
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/ckpoint_blcr.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/ckpoint/blcr/ckpoint_blcr.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,15 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#ifndef CKPOINT_BLCR_H_INCLUDED
-#define CKPOINT_BLCR_H_INCLUDED
-
-HYD_Status HYDU_ckpoint_blcr_init(void);
-HYD_Status HYDU_ckpoint_blcr_suspend(const char *prefix);
-HYD_Status HYDU_ckpoint_blcr_restart(const char *prefix, HYD_Env_t * envlist, int num_ranks,
- int ranks[], int *in, int *out, int *err);
-
-#endif /* CKPOINT_BLCR_H_INCLUDED */
Deleted: mpich2/trunk/src/pm/hydra/utils/ckpoint/ckpoint.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/ckpoint/ckpoint.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/ckpoint/ckpoint.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,92 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "hydra_utils.h"
-#include "ckpoint.h"
-
-#if defined HAVE_BLCR
-#include "blcr/ckpoint_blcr.h"
-#endif /* HAVE_BLCR */
-
-struct HYDU_ckpoint_info HYDU_ckpoint_info;
-
-HYD_Status HYDU_ckpoint_init(char *ckpointlib, char *ckpoint_prefix)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- HYDU_ckpoint_info.ckpointlib = ckpointlib;
- HYDU_ckpoint_info.ckpoint_prefix = ckpoint_prefix;
-
- if (HYDU_ckpoint_info.ckpoint_prefix == NULL)
- goto fn_exit;
-
-#if defined HAVE_BLCR
- if (!strcmp(HYDU_ckpoint_info.ckpointlib, "blcr")) {
- status = HYDU_ckpoint_blcr_init();
- HYDU_ERR_POP(status, "blcr checkpoint returned error\n");
- }
-#endif /* HAVE_BLCR */
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-HYD_Status HYDU_ckpoint_suspend(void)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- HYDU_ERR_CHKANDJUMP(status, HYDU_ckpoint_info.ckpoint_prefix == NULL, HYD_INTERNAL_ERROR,
- "no checkpoint prefix defined\n");
-
-#if defined HAVE_BLCR
- if (!strcmp(HYDU_ckpoint_info.ckpointlib, "blcr")) {
- status = HYDU_ckpoint_blcr_suspend(HYDU_ckpoint_info.ckpoint_prefix);
- HYDU_ERR_POP(status, "blcr checkpoint returned error\n");
- }
-#endif /* HAVE_BLCR */
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
-
-HYD_Status HYDU_ckpoint_restart(HYD_Env_t * envlist, int num_ranks, int ranks[], int *in,
- int *out, int *err)
-{
- HYD_Status status = HYD_SUCCESS;
-
- HYDU_FUNC_ENTER();
-
- HYDU_ERR_CHKANDJUMP(status, HYDU_ckpoint_info.ckpoint_prefix == NULL, HYD_INTERNAL_ERROR,
- "no checkpoint prefix defined\n");
-
-#if defined HAVE_BLCR
- if (!strcmp(HYDU_ckpoint_info.ckpointlib, "blcr")) {
- status =
- HYDU_ckpoint_blcr_restart(HYDU_ckpoint_info.ckpoint_prefix, envlist, num_ranks,
- ranks, in, out, err);
- HYDU_ERR_POP(status, "blcr checkpoint returned error\n");
- }
-#endif /* HAVE_BLCR */
-
- fn_exit:
- HYDU_FUNC_EXIT();
- return status;
-
- fn_fail:
- goto fn_exit;
-}
Deleted: mpich2/trunk/src/pm/hydra/utils/ckpoint/ckpoint.h
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/ckpoint/ckpoint.h 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/ckpoint/ckpoint.h 2009-10-15 17:10:32 UTC (rev 5466)
@@ -1,19 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- * (C) 2008 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#ifndef CKPOINT_H_INCLUDED
-#define CKPOINT_H_INCLUDED
-
-#include "hydra_utils.h"
-
-struct HYDU_ckpoint_info {
- char *ckpointlib;
- char *ckpoint_prefix;
-};
-
-extern struct HYDU_ckpoint_info HYDU_ckpoint_info;
-
-#endif /* CKPOINT_H_INCLUDED */
Modified: mpich2/trunk/src/pm/hydra/utils/launch/launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/launch/launch.c 2009-10-15 17:10:02 UTC (rev 5465)
+++ mpich2/trunk/src/pm/hydra/utils/launch/launch.c 2009-10-15 17:10:32 UTC (rev 5466)
@@ -5,6 +5,7 @@
*/
#include "hydra_utils.h"
+#include "hydra_tools.h"
HYD_Status HYDU_create_process(char **client_arg, HYD_Env_t * env_list,
int *in, int *out, int *err, int *pid, int core)
More information about the mpich2-commits
mailing list