Adding new functionality to Maffinity component to support NUMA awareness
This commit was SVN r18657.
Этот коммит содержится в:
родитель
8cff3131d6
Коммит
dee2f1d175
@ -105,6 +105,9 @@ OPAL_DECLSPEC int opal_maffinity_base_select(void);
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_maffinity_base_set(opal_maffinity_base_segment_t *segments, size_t num_segments);
|
||||
|
||||
OPAL_DECLSPEC int opal_maffinity_base_node_name_to_id(char *, int *);
|
||||
OPAL_DECLSPEC int opal_maffinity_base_bind(opal_maffinity_base_segment_t *, size_t, int);
|
||||
|
||||
/**
|
||||
* Shut down the maffinity MCA framework.
|
||||
*
|
||||
|
@ -31,3 +31,33 @@ int opal_maffinity_base_set(opal_maffinity_base_segment_t *segments,
|
||||
}
|
||||
return opal_maffinity_base_module->maff_module_set(segments, num_segments);
|
||||
}
|
||||
|
||||
int opal_maffinity_base_node_name_to_id(char *node_name, int *node_id)
|
||||
{
|
||||
if (!opal_maffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (!opal_maffinity_base_module->maff_module_name_to_id) {
|
||||
*node_id = 0;
|
||||
return OPAL_ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return opal_maffinity_base_module->maff_module_name_to_id(node_name,
|
||||
node_id);
|
||||
}
|
||||
|
||||
int opal_maffinity_base_bind(opal_maffinity_base_segment_t *segments,
|
||||
size_t num_segments, int node_id)
|
||||
{
|
||||
if (!opal_maffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (!opal_maffinity_base_module->maff_module_bind) {
|
||||
return OPAL_ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return opal_maffinity_base_module->maff_module_bind(segments, num_segments,
|
||||
node_id);
|
||||
}
|
||||
|
@ -41,7 +41,9 @@ static const opal_maffinity_base_module_1_0_0_t loc_module = {
|
||||
first_use_module_init,
|
||||
|
||||
/* Module function pointers */
|
||||
first_use_module_set
|
||||
first_use_module_set,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
int opal_maffinity_first_use_component_query(mca_base_module_t **module, int *priority)
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <numa.h>
|
||||
#include <numaif.h>
|
||||
|
||||
#include "opal/constants.h"
|
||||
#include "opal/mca/maffinity/maffinity.h"
|
||||
@ -33,6 +34,8 @@
|
||||
static int libnuma_module_init(void);
|
||||
static int libnuma_module_set(opal_maffinity_base_segment_t *segments,
|
||||
size_t num_segments);
|
||||
static int libnuma_module_node_name_to_id(char *, int *);
|
||||
static int libnuma_modules_bind(opal_maffinity_base_segment_t *, size_t, int);
|
||||
|
||||
/*
|
||||
* Libnuma maffinity module
|
||||
@ -42,7 +45,9 @@ static const opal_maffinity_base_module_1_0_0_t loc_module = {
|
||||
libnuma_module_init,
|
||||
|
||||
/* Module function pointers */
|
||||
libnuma_module_set
|
||||
libnuma_module_set,
|
||||
libnuma_module_node_name_to_id,
|
||||
libnuma_modules_bind
|
||||
};
|
||||
|
||||
int opal_maffinity_libnuma_component_query(mca_base_module_t **module, int *priority)
|
||||
@ -92,3 +97,28 @@ static int libnuma_module_set(opal_maffinity_base_segment_t *segments,
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int libnuma_module_node_name_to_id(char *node_name, int *id)
|
||||
{
|
||||
/* GLB: fix me */
|
||||
*id = atoi(node_name + 3);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int libnuma_modules_bind(opal_maffinity_base_segment_t *segs,
|
||||
size_t count, int node_id)
|
||||
{
|
||||
size_t i;
|
||||
int rc;
|
||||
unsigned long node_mask = (1 << node_id);
|
||||
|
||||
for(i = 0; i < count; i++) {
|
||||
rc = mbind(segs[i].mbs_start_addr, segs[i].mbs_len, MPOL_PREFERRED,
|
||||
&node_mask, sizeof(node_mask) * 8, MPOL_MF_MOVE);
|
||||
if(rc != 0)
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
@ -82,6 +82,17 @@ typedef int (*opal_maffinity_base_module_init_1_0_0_fn_t)(void);
|
||||
typedef int (*opal_maffinity_base_module_set_fn_t)
|
||||
(opal_maffinity_base_segment_t *segments, size_t num_segments);
|
||||
|
||||
/**
|
||||
* translate memory node name (such as "mem0") to memory node id
|
||||
*/
|
||||
typedef int (*opal_maffinity_base_module_node_name_to_id_fn_t)
|
||||
(char *node_name, int *node_id);
|
||||
|
||||
/**
|
||||
* bind memory to node
|
||||
*/
|
||||
typedef int (*opal_maffinity_base_module_bind_fn_t)
|
||||
(opal_maffinity_base_segment_t *segments, size_t num_segments, int node_id);
|
||||
|
||||
/**
|
||||
* Structure for maffinity v1.0.0 components.
|
||||
@ -108,6 +119,8 @@ struct opal_maffinity_base_module_1_0_0_t {
|
||||
|
||||
/** Set memory affinity */
|
||||
opal_maffinity_base_module_set_fn_t maff_module_set;
|
||||
opal_maffinity_base_module_node_name_to_id_fn_t maff_module_name_to_id;
|
||||
opal_maffinity_base_module_bind_fn_t maff_module_bind;
|
||||
};
|
||||
/**
|
||||
* Convenience typedef
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user