Commit 1c16acb0 authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r4129] Used some more detailed features of PLPA to check how many processing

elements are there on the system and wrap around once we reach the
maximum core. This requires us to make sure that we can read the
system topology information (also through PLPA); so for cases where we
cannot read this information, even if there is no over-provisioning,
we do not perform any binding. Though we are being more conservative
on the systems that we can function correctly, this should be more
robust.
parent 33055063
......@@ -156,8 +156,8 @@ AC_MSG_CHECKING(process binding)
AC_MSG_RESULT($PROC_BINDING)
if test "$PROC_BINDING" = "yes"; then
AC_DEFINE(PROC_BINDING,1,[Define if process binding is enabled])
plpa_makefile="utils/plpa/Makefile"
opt_utils="${opt_utils} plpa"
opt_utils_makefiles="${opt_utils_makefiles} utils/plpa/Makefile utils/bind/Makefile"
opt_utils="${opt_utils} plpa bind"
fi
AC_SUBST(opt_utils)
......@@ -307,7 +307,7 @@ AC_OUTPUT(Makefile \
utils/sock/Makefile \
utils/string/Makefile \
utils/timer/Makefile \
${plpa_makefile} \
${opt_utils_makefiles} \
launcher/Makefile \
launcher/utils/Makefile \
launcher/${hydra_launcher}/Makefile \
......
......@@ -72,12 +72,21 @@ HYD_Status HYDU_Create_process(char **client_arg, int *in, int *out, int *err, i
HYD_Status HYDU_Get_base_path(char *execname, char **path);
HYD_Status HYDU_Chdir(const char *dir);
/* Process binding */
#if defined PROC_BINDING
#include "plpa.h"
#include "plpa_internal.h"
#endif /* PROC_BINDING */
HYD_Status HYDU_bind_process(int core);
#else
#define HYDU_bind_process(...) HYD_SUCCESS
#endif /* PROC_BINDING */
/* Memory utilities */
#define HYDU_NUM_JOIN_STR 100
......
......@@ -4,5 +4,5 @@
# See COPYRIGHT in top-level directory.
#
SUBDIRS_opt_utils = plpa .
SUBDIRS_opt_utils = plpa bind .
SUBDIRS = args dbg env launch signals sock string timer @opt_utils@
# -*- Mode: Makefile; -*-
#
# (C) 2008 by Argonne National Laboratory.
# See COPYRIGHT in top-level directory.
#
HYDRA_LIB_PATH = ../../lib
libhydra_a_DIR = ${HYDRA_LIB_PATH}
libhydra_a_SOURCES = bind.c
INCLUDES = -I${abs_srcdir}/../../include \
-I${abs_srcdir}/../../../../include \
-I../../include \
-I../../../../include
......@@ -7,20 +7,37 @@
#include "hydra_utils.h"
HYD_Status HYDU_bind_process(int core)
#if defined PROC_BINDING
{
plpa_api_type_t p;
plpa_cpu_set_t cpuset;
int ret;
int ret, supported;
int num_procs, max_proc_id;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
if (!((plpa_api_probe(&p) == 0) && (p == PLPA_PROBE_OK)))
HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "plpa probe failed\n");
if (!((plpa_api_probe(&p) == 0) && (p == PLPA_PROBE_OK))) {
/* If this failed, we just return without binding */
goto fn_exit;
}
/* We need topology information too */
ret = plpa_have_topology_information(&supported);
if ((ret == 0) && (supported == 1)) {
/* Find the maximum number of processing elements */
ret = plpa_get_processor_data(PLPA_COUNT_ALL, &num_procs, &max_proc_id);
if (ret) {
HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
"plpa get processor data failed\n");
}
}
else {
/* If this failed, we just return without binding */
goto fn_exit;
}
PLPA_CPU_ZERO(&cpuset);
PLPA_CPU_SET(core, &cpuset);
PLPA_CPU_SET(core % num_procs, &cpuset);
ret = plpa_sched_setaffinity(0, 1, &cpuset);
if (ret)
HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "plpa setaffinity failed\n");
......@@ -32,8 +49,3 @@ HYD_Status HYDU_bind_process(int core)
fn_fail:
goto fn_exit;
}
#else
{
return HYD_SUCCESS;
}
#endif /* PROC_BINDING */
......@@ -7,7 +7,7 @@
HYDRA_LIB_PATH = ../../lib
libhydra_a_DIR = ${HYDRA_LIB_PATH}
libhydra_a_SOURCES = allocate.c launch.c bind.c
libhydra_a_SOURCES = allocate.c launch.c
INCLUDES = -I${abs_srcdir}/../../include \
-I${abs_srcdir}/../../../../include \
-I../../include \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment