2005-08-26 19:51:02 +00:00
/*
2008-05-06 18:08:45 +00:00
* Copyright ( c ) 2004 - 2008 The Trustees of Indiana University and Indiana
2005-11-05 19:57:48 +00:00
* University Research and Technology
* Corporation . All rights reserved .
* Copyright ( c ) 2004 - 2005 The University of Tennessee and The University
* of Tennessee Research Foundation . All rights
* reserved .
2005-08-26 19:51:02 +00:00
* 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 .
2011-01-24 14:39:16 +00:00
* Copyright ( c ) 2011 Cisco Systems , Inc . All rights reserved .
2005-08-26 19:51:02 +00:00
* $ COPYRIGHT $
*
* Additional copyrights may follow
*
* $ HEADER $
*/
2006-02-12 01:33:29 +00:00
# include "opal_config.h"
2005-08-26 19:51:02 +00:00
2011-01-24 14:39:16 +00:00
# include <numa.h>
# include <numaif.h>
# include <unistd.h>
2006-02-12 01:33:29 +00:00
# include "opal/constants.h"
2011-01-24 14:39:16 +00:00
# include "opal/util/show_help.h"
2005-08-26 19:51:02 +00:00
# include "opal/mca/maffinity/maffinity.h"
2011-01-24 14:39:16 +00:00
2005-08-26 19:51:02 +00:00
# include "maffinity_libnuma.h"
/*
* Public string showing the maffinity ompi_libnuma component version number
*/
const char * opal_maffinity_libnuma_component_version_string =
2007-01-02 16:17:47 +00:00
" OPAL libnuma maffinity MCA component version " OPAL_VERSION ;
2005-08-26 19:51:02 +00:00
/*
2011-01-24 14:39:16 +00:00
* Local functions
*/
static int libnuma_register ( void ) ;
/*
* Local variable
2005-08-26 19:51:02 +00:00
*/
2011-01-24 14:39:16 +00:00
static char * mca_policy = NULL ;
2005-08-26 19:51:02 +00:00
/*
* Instantiate the public struct with all of our public information
* and pointers to our public functions in it
*/
2011-01-24 14:39:16 +00:00
opal_maffinity_libnuma_component_2_0_0_t mca_maffinity_libnuma_component = {
2005-08-26 19:51:02 +00:00
{
2011-01-24 14:39:16 +00:00
/* First, the mca_component_t struct containing meta information
about the component itself */
2007-02-21 14:32:41 +00:00
2011-01-24 14:39:16 +00:00
{
OPAL_MAFFINITY_BASE_VERSION_2_0_0 ,
/* Component name and version */
" libnuma " ,
OPAL_MAJOR_VERSION ,
OPAL_MINOR_VERSION ,
OPAL_RELEASE_VERSION ,
/* Component open and close functions */
NULL ,
NULL ,
opal_maffinity_libnuma_component_query ,
libnuma_register ,
} ,
{
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
}
2005-08-26 19:51:02 +00:00
} ,
2011-01-24 14:39:16 +00:00
/* Default libnuma memory binding policy */
MPOL_PREFERRED ,
2005-08-26 19:51:02 +00:00
} ;
2011-01-24 14:39:16 +00:00
static int libnuma_register ( void )
2005-08-26 19:51:02 +00:00
{
2011-01-24 14:39:16 +00:00
char * val ;
mca_base_param_reg_int ( & mca_maffinity_libnuma_component . base . base_version ,
2005-08-26 19:51:02 +00:00
" priority " ,
" Priority of the libnuma maffinity component " ,
false , false , 25 , NULL ) ;
2011-01-24 14:39:16 +00:00
val = ( MPOL_PREFERRED = = mca_maffinity_libnuma_component . libnuma_policy ?
" loose " : " strict " ) ;
mca_base_param_reg_string ( & mca_maffinity_libnuma_component . base . base_version ,
" policy " ,
" Binding policy that determines what happens if memory is unavailable on the local NUMA node. A value of \" strict \" means that the memory allocation will fail; a value of \" loose \" means that the memory allocation will spill over to another NUMA node. " ,
false , false , val , & mca_policy ) ;
if ( strcasecmp ( mca_policy , " loose " ) = = 0 ) {
mca_maffinity_libnuma_component . libnuma_policy = MPOL_PREFERRED ;
} else if ( strcasecmp ( mca_policy , " strict " ) = = 0 ) {
mca_maffinity_libnuma_component . libnuma_policy = MPOL_BIND ;
} else {
opal_show_help ( " help-opal-maffinity-libnuma.txt " , " invalid policy " ,
true , mca_policy , getpid ( ) ) ;
mca_maffinity_libnuma_component . libnuma_policy = MPOL_PREFERRED ;
return OPAL_ERR_BAD_PARAM ;
}
2005-08-26 19:51:02 +00:00
return OPAL_SUCCESS ;
}