1
1

Extend the paffinity test module to allow users to specify the number of sockets and cores - provides an extended ability to mimic archs.

This commit was SVN r21912.
Этот коммит содержится в:
Ralph Castain 2009-08-29 03:35:39 +00:00
родитель 433673c64f
Коммит 888f3c3afe
3 изменённых файлов: 69 добавлений и 62 удалений

Просмотреть файл

@ -30,14 +30,16 @@ BEGIN_C_DECLS
/*
* Globally exported variable
*/
typedef struct opal_paffinity_test_component_t {
opal_paffinity_base_component_t super;
bool bound;
int num_sockets;
int num_cores;
} opal_paffinity_test_component_t;
OPAL_DECLSPEC extern const opal_paffinity_base_component_2_0_0_t mca_paffinity_test_component;
OPAL_MODULE_DECLSPEC extern opal_paffinity_test_component_t mca_paffinity_test_component;
/* query function */
int opal_paffinity_test_component_query(mca_base_module_t **module, int *priority);
/* local value */
OPAL_DECLSPEC extern bool opal_paffinity_test_bound;
extern opal_paffinity_base_module_t opal_paffinity_test_module;
END_C_DECLS

Просмотреть файл

@ -39,42 +39,43 @@ const char *opal_paffinity_test_component_version_string =
* Local function
*/
static int test_open(void);
static int test_query(mca_base_module_t **module, int *priority);
/*
* Instantiate the public struct with all of our public information
* and pointers to our public functions in it
*/
bool opal_paffinity_test_bound;
const opal_paffinity_base_component_2_0_0_t mca_paffinity_test_component = {
/* First, the mca_component_t struct containing meta information
about the component itself */
opal_paffinity_test_component_t mca_paffinity_test_component = {
{
/* Indicate that we are a paffinity v1.1.0 component (which also
implies a specific MCA version) */
OPAL_PAFFINITY_BASE_VERSION_2_0_0,
/* First, the mca_component_t struct containing meta information
* about the component itself
*/
/* Component name and version */
{
/* Indicate that we are a paffinity v1.1.0 component (which also
implies a specific MCA version) */
"test",
OPAL_MAJOR_VERSION,
OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION,
OPAL_PAFFINITY_BASE_VERSION_2_0_0,
/* Component open and close functions */
/* Component name and version */
test_open,
NULL,
opal_paffinity_test_component_query
},
/* Next the MCA v1.0.0 component meta data */
{
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
"test",
OPAL_MAJOR_VERSION,
OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION,
/* Component open and close functions */
test_open,
NULL,
test_query
},
/* Next the MCA v1.0.0 component meta data */
{
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
}
}
};
@ -83,10 +84,26 @@ static int test_open(void)
{
int tmp;
mca_base_param_reg_int(&mca_paffinity_test_component.base_version, "bound",
mca_base_param_reg_int(&mca_paffinity_test_component.super.base_version, "bound",
"Whether or not to test as if externally bound (default=0: no)",
false, false, (int)false, &tmp);
opal_paffinity_test_bound = OPAL_INT_TO_BOOL(tmp);
mca_paffinity_test_component.bound = OPAL_INT_TO_BOOL(tmp);
mca_base_param_reg_int(&mca_paffinity_test_component.super.base_version, "num_sockets",
"Number of sockets on each node (default=4)",
false, false, 4, &mca_paffinity_test_component.num_sockets);
mca_base_param_reg_int(&mca_paffinity_test_component.super.base_version, "num_cores",
"Number of cores in each socket (default=4)",
false, false, 4, &mca_paffinity_test_component.num_cores);
return OPAL_SUCCESS;
}
static int test_query(mca_base_module_t **module, int *priority)
{
/* set this priority so I can only be selected if directed */
*priority = 00;
*module = (mca_base_module_t *)&opal_paffinity_test_module;
return OPAL_SUCCESS;
}

Просмотреть файл

@ -28,10 +28,6 @@
#include "paffinity_test.h"
/* Fake an arch */
#define NUM_SOCKETS 4
#define NUM_CORES 4
/*
* Local functions
*/
@ -51,7 +47,7 @@ static int get_physical_core_id(int physical_socket_id, int logical_core_id);
/*
* Test paffinity module
*/
static const opal_paffinity_base_module_1_1_0_t loc_module = {
opal_paffinity_base_module_t opal_paffinity_test_module = {
/* Initialization function */
init,
@ -69,17 +65,7 @@ static const opal_paffinity_base_module_1_1_0_t loc_module = {
finalize
};
int opal_paffinity_test_component_query(mca_base_module_t **module, int *priority)
{
/* set this priority so I can only be selected if directed */
*priority = 00;
*module = (mca_base_module_t *)&loc_module;
return OPAL_SUCCESS;
}
/* do nothing here. both mpirun and processes would run init(), but
* only processes would run the set function */
/* nothing to init here */
static int init(void)
{
return OPAL_SUCCESS;
@ -98,16 +84,18 @@ static int get(opal_paffinity_base_cpu_set_t *cpumask)
int i;
OPAL_PAFFINITY_CPU_ZERO(*cpumask);
if (opal_paffinity_test_bound) {
for (i=0; i < NUM_SOCKETS*NUM_CORES; i+=2) {
if (mca_paffinity_test_component.bound) {
for (i=0; i < mca_paffinity_test_component.num_sockets*mca_paffinity_test_component.num_cores; i+=2) {
OPAL_PAFFINITY_CPU_SET(i, *cpumask);
}
/* assign all cores in the 2nd socket */
for (i=NUM_CORES; i < 2*NUM_CORES; i++) {
OPAL_PAFFINITY_CPU_SET(i, *cpumask);
/* assign all cores in the 2nd socket, if it exists */
if (mca_paffinity_test_component.num_sockets >= 2) {
for (i=mca_paffinity_test_component.num_cores; i < 2*mca_paffinity_test_component.num_cores; i++) {
OPAL_PAFFINITY_CPU_SET(i, *cpumask);
}
}
} else {
for (i=0; i < NUM_SOCKETS*NUM_CORES; i++) {
for (i=0; i < mca_paffinity_test_component.num_sockets*mca_paffinity_test_component.num_cores; i++) {
OPAL_PAFFINITY_CPU_SET(i, *cpumask);
}
}
@ -116,32 +104,32 @@ static int get(opal_paffinity_base_cpu_set_t *cpumask)
static int map_to_processor_id(int socket, int core, int *processor_id)
{
*processor_id = socket*NUM_CORES + core;
*processor_id = socket*mca_paffinity_test_component.num_cores + core;
return OPAL_SUCCESS;
}
static int map_to_socket_core(int processor_id, int *socket, int *core)
{
*socket = processor_id / NUM_CORES;
*core = processor_id % NUM_CORES;
*socket = processor_id / mca_paffinity_test_component.num_cores;
*core = processor_id % mca_paffinity_test_component.num_cores;
return OPAL_SUCCESS;
}
static int get_processor_info(int *num_processors)
{
*num_processors = NUM_SOCKETS * NUM_CORES;
*num_processors = mca_paffinity_test_component.num_sockets * mca_paffinity_test_component.num_cores;
return OPAL_SUCCESS;
}
static int get_socket_info(int *num_sockets)
{
*num_sockets = NUM_SOCKETS;
*num_sockets = mca_paffinity_test_component.num_sockets;
return OPAL_SUCCESS;
}
static int get_core_info(int socket, int *num_cores)
{
*num_cores = NUM_CORES;
*num_cores = mca_paffinity_test_component.num_cores;
return OPAL_SUCCESS;
}
@ -157,7 +145,7 @@ static int get_physical_socket_id(int logical_socket_id)
static int get_physical_core_id(int physical_socket_id, int logical_core_id)
{
if (NUM_CORES < logical_core_id) {
if (mca_paffinity_test_component.num_cores < logical_core_id) {
return OPAL_ERROR;
}
return logical_core_id;