diff --git a/opal/mca/maffinity/libnuma/.ompi_ignore b/opal/mca/maffinity/libnuma/.ompi_ignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/opal/mca/maffinity/libnuma/.ompi_unignore b/opal/mca/maffinity/libnuma/.ompi_unignore new file mode 100644 index 0000000000..814285c7e5 --- /dev/null +++ b/opal/mca/maffinity/libnuma/.ompi_unignore @@ -0,0 +1 @@ +jsquyres diff --git a/opal/mca/maffinity/libnuma/Makefile.am b/opal/mca/maffinity/libnuma/Makefile.am new file mode 100644 index 0000000000..4af6ad536a --- /dev/null +++ b/opal/mca/maffinity/libnuma/Makefile.am @@ -0,0 +1,45 @@ +# +# Copyright (c) 2004-2005 The Trustees of Indiana University. +# All rights reserved. +# Copyright (c) 2004-2005 The Trustees of the University of Tennessee. +# All rights reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +AM_CPPFLAGS = $(maffinity_libnuma_CPPFLAGS) + +sources = \ + maffinity_libnuma.h \ + maffinity_libnuma_component.c \ + maffinity_libnuma_module.c + +# Make the output library in this directory, and name it either +# mca__.la (for DSO builds) or libmca__.la +# (for static builds). + +if OMPI_BUILD_maffinity_libnuma_DSO +component_noinst = +component_install = mca_maffinity_libnuma.la +else +component_noinst = libmca_maffinity_libnuma.la +component_install = +endif + +mcacomponentdir = $(libdir)/openmpi +mcacomponent_LTLIBRARIES = $(component_install) +mca_maffinity_libnuma_la_SOURCES = $(sources) +mca_maffinity_libnuma_la_LIBADD = $(maffinity_libnuma_LIBS) +mca_maffinity_libnuma_la_LDFLAGS = -module -avoid-version $(maffinity_libnuma_LDFLAGS) + +noinst_LTLIBRARIES = $(component_noinst) +libmca_maffinity_libnuma_la_SOURCES =$(sources) +libmca_maffinity_libnuma_la_LIBADD = $(maffinity_libnuma_LIBS) +libmca_maffinity_libnuma_la_LDFLAGS = -module -avoid-version $(maffinity_libnuma_LDFLAGS) diff --git a/opal/mca/maffinity/libnuma/configure.m4 b/opal/mca/maffinity/libnuma/configure.m4 new file mode 100644 index 0000000000..20dc478757 --- /dev/null +++ b/opal/mca/maffinity/libnuma/configure.m4 @@ -0,0 +1,61 @@ +# -*- shell-script -*- +# +# Copyright (c) 2004-2005 The Trustees of Indiana University. +# All rights reserved. +# Copyright (c) 2004-2005 The Trustees of the University of Tennessee. +# All rights reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + + +# MCA___CONFIG([action-if-can-compile], +# [action-if-cant-compile]) +# ------------------------------------------------ +AC_DEFUN([MCA_maffinity_libnuma_CONFIG],[ + AC_ARG_WITH([libnuma], + [AC_HELP_STRING([--with-libnuma], + [Directory where the libnuma software is installed])]) + + ompi_check_maffinity_libnuma_save_CPPFLAGS="$CPPFLAGS" + ompi_check_maffinity_libnuma_save_LDFLAGS="$LDFLAGS" + ompi_check_maffinity_libnuma_save_LIBS="$LIBS" + + # libnuma, by default, installs into lib64/. So we're going to + # assume that's the common case. If this needs to be augmented + # someday to look in lib/ as well, then so be it. + AS_IF([test ! -z "$with_libnuma"], + [CPPFLAGS="$CPPFLAGS -I$with_libnuma/include" + LDFLAGS="$LDFLAGS -L$with_libnuma/lib64"]) + AC_CHECK_HEADERS([numa.h], + [AC_CHECK_LIB([numa], + [numa_available], + [ompi_check_maffinity_libnuma_happy="yes"], + [ompi_check_maffinity_libnuma_happy="no"])], + [ompi_check_maffinity_libnuma_happy="no"]) + + CPPFLAGS="$ompi_check_maffinity_libnuma_save_CPPFLAGS" + LDFLAGS="$ompi_check_maffinity_libnuma_save_LDFLAGS" + LIBS="$ompi_check_maffinity_libnuma_save_LIBS" + + AS_IF([test "$ompi_check_maffinity_libnuma_happy" = "yes"], + [AS_IF([test ! -z "$with_libnuma"], + [maffinity_libnuma_CPPFLAGS="$maffinity_libnuma_CPPFLAGS -I$with_libnuma/include" + maffinity_libnuma_LDFLAGS="$maffinity_libnuma_LDFLAGS -L$with_libnuma/lib64" + maffinity_libnuma_LIBS="$maffinity_libnuma_LIBS -lnuma"]) + $1], + [$2]) + + # substitute in the things needed to build gm + AC_SUBST([maffinity_libnuma_CFLAGS]) + AC_SUBST([maffinity_libnuma_CPPFLAGS]) + AC_SUBST([maffinity_libnuma_LDFLAGS]) + AC_SUBST([maffinity_libnuma_LIBS]) +])dnl diff --git a/opal/mca/maffinity/libnuma/configure.params b/opal/mca/maffinity/libnuma/configure.params new file mode 100644 index 0000000000..8f850f039a --- /dev/null +++ b/opal/mca/maffinity/libnuma/configure.params @@ -0,0 +1,19 @@ +# -*- shell-script -*- +# +# Copyright (c) 2004-2005 The Trustees of Indiana University. +# All rights reserved. +# Copyright (c) 2004-2005 The Trustees of the University of Tennessee. +# All rights reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +PARAM_INIT_FILE=maffinity_libnuma_component.c +PARAM_CONFIG_FILES="Makefile" diff --git a/opal/mca/maffinity/libnuma/maffinity_libnuma.h b/opal/mca/maffinity/libnuma/maffinity_libnuma.h new file mode 100644 index 0000000000..98811da71d --- /dev/null +++ b/opal/mca/maffinity/libnuma/maffinity_libnuma.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. + * All rights reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +/** + * @file + * + * Processor affinity for libnuma. + */ + + +#ifndef MCA_MAFFINITY_LIBNUMA_EXPORT_H +#define MCA_MAFFINITY_LIBNUMA_EXPORT_H + +#include "ompi_config.h" + +#include "opal/mca/mca.h" +#include "opal/mca/maffinity/maffinity.h" + + +#if defined(c_plusplus) || defined(__cplusplus) +extern "C" { +#endif + + /** + * Globally exported variable + */ + OMPI_COMP_EXPORT extern const opal_maffinity_base_component_1_0_0_t + mca_maffinity_libnuma_component; + + + /** + * maffinity query API function + */ + const opal_maffinity_base_module_1_0_0_t * + opal_maffinity_libnuma_component_query(int *query); + +#if defined(c_plusplus) || defined(__cplusplus) +} +#endif +#endif /* MCA_MAFFINITY_LIBNUMA_EXPORT_H */ diff --git a/opal/mca/maffinity/libnuma/maffinity_libnuma_component.c b/opal/mca/maffinity/libnuma/maffinity_libnuma_component.c new file mode 100644 index 0000000000..830a1bd417 --- /dev/null +++ b/opal/mca/maffinity/libnuma/maffinity_libnuma_component.c @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. + * All rights reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" + +#include "opal/include/constants.h" +#include "opal/mca/maffinity/maffinity.h" +#include "maffinity_libnuma.h" + +/* + * Public string showing the maffinity ompi_libnuma component version number + */ +const char *opal_maffinity_libnuma_component_version_string = + "OPAL libnuma maffinity MCA component version " OMPI_VERSION; + +/* + * Local function + */ +static int libnuma_open(void); + +/* + * Instantiate the public struct with all of our public information + * and pointers to our public functions in it + */ + +const opal_maffinity_base_component_1_0_0_t mca_maffinity_libnuma_component = { + + /* First, the mca_component_t struct containing meta information + about the component itself */ + + { + /* Indicate that we are a maffinity v1.0.0 component (which also + implies a specific MCA version) */ + + OPAL_MAFFINITY_BASE_VERSION_1_0_0, + + /* Component name and version */ + + "libnuma", + OMPI_MAJOR_VERSION, + OMPI_MINOR_VERSION, + OMPI_RELEASE_VERSION, + + /* Component open and close functions */ + + libnuma_open, + NULL + }, + + /* Next the MCA v1.0.0 component meta data */ + + { + /* Whether the component is checkpointable or not */ + + true + }, + + /* Query function */ + + opal_maffinity_libnuma_component_query +}; + + +static int libnuma_open(void) +{ + mca_base_param_reg_int(&mca_maffinity_libnuma_component.maffinityc_version, + "priority", + "Priority of the libnuma maffinity component", + false, false, 25, NULL); + + return OPAL_SUCCESS; +} diff --git a/opal/mca/maffinity/libnuma/maffinity_libnuma_module.c b/opal/mca/maffinity/libnuma/maffinity_libnuma_module.c new file mode 100644 index 0000000000..4158e71649 --- /dev/null +++ b/opal/mca/maffinity/libnuma/maffinity_libnuma_module.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. + * All rights reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" + +#include +#include +#include +#include + +#include "opal/include/constants.h" +#include "opal/mca/maffinity/maffinity.h" +#include "opal/mca/maffinity/base/base.h" +#include "maffinity_libnuma.h" + + +/* + * Local functions + */ +static int libnuma_module_init(void); +static int libnuma_module_set(opal_maffinity_base_segment_t *segments, + size_t num_segments, bool am_allocator); + +/* + * Libnuma maffinity module + */ +static const opal_maffinity_base_module_1_0_0_t module = { + + /* Initialization function */ + + libnuma_module_init, + + /* Module function pointers */ + + libnuma_module_set +}; + + +const opal_maffinity_base_module_1_0_0_t * +opal_maffinity_libnuma_component_query(int *query) +{ + int param; + + if (-1 == numa_available()) { + return NULL; + } + param = mca_base_param_find("maffinity", "libnuma", "priority"); + mca_base_param_lookup_int(param, query); + + return &module; +} + + +static int libnuma_module_init(void) +{ + /* Tell libnuma that we want all memory affinity to be local. */ + + numa_set_localalloc(); + + return OPAL_SUCCESS; +} + + +static int libnuma_module_set(opal_maffinity_base_segment_t *segments, + size_t num_segments, bool am_allocator) +{ + size_t i; + + /* Only the allocator does anything */ + + if (!am_allocator) { + return OPAL_SUCCESS; + } + + for (i = 0; i < num_segments; ++i) { + /* JMS do something */ + } + + return OPAL_SUCCESS; +}