Reverted commit # r17443
This commit was SVN r17446. The following SVN revision numbers were found above: r17443 --> open-mpi/ompi@88ce5a2b73
Этот коммит содержится в:
родитель
bdc616837a
Коммит
5b2dab2439
@ -1175,10 +1175,10 @@ static int get_ib_dev_distance(struct ibv_device *dev)
|
||||
{
|
||||
opal_paffinity_base_cpu_set_t cpus;
|
||||
opal_carto_base_node_t *hca_node;
|
||||
int min_distance = -1, i, max_proc_id, num_processors;
|
||||
int min_distance = -1, i, max_proc_id;
|
||||
const char *hca = ibv_get_device_name(dev);
|
||||
|
||||
if(opal_paffinity_base_get_processor_info(&num_processors, &max_proc_id) != OMPI_SUCCESS)
|
||||
if(opal_paffinity_base_max_processor_id(&max_proc_id) != OMPI_SUCCESS)
|
||||
max_proc_id = 100; /* Choose something big enough */
|
||||
|
||||
hca_node = carto_base_find_node(host_topo, hca);
|
||||
|
@ -167,7 +167,7 @@ extern "C" {
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
OPAL_DECLSPEC int opal_paffinity_base_max_processor_id(int *max_processor_id);
|
||||
|
||||
/**
|
||||
* Return the max socket number
|
||||
@ -177,7 +177,7 @@ extern "C" {
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
OPAL_DECLSPEC int opal_paffinity_base_max_socket(int *max_socket);
|
||||
|
||||
/**
|
||||
* Return the max core number for a given socket
|
||||
@ -188,7 +188,7 @@ extern "C" {
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
OPAL_DECLSPEC int opal_paffinity_base_max_core(int socket, int *max_core);
|
||||
|
||||
/**
|
||||
* Indication of whether a component was successfully selected or
|
||||
|
@ -63,28 +63,27 @@ int opal_paffinity_base_map_to_socket_core(int processor_id, int *socket, int *c
|
||||
return opal_paffinity_base_module->paff_map_to_socket_core(processor_id, socket, core);
|
||||
}
|
||||
|
||||
|
||||
int opal_paffinity_base_get_processor_info(int *num_processors, int *max_processor_id)
|
||||
int opal_paffinity_base_max_processor_id(int *max_processor_id)
|
||||
{
|
||||
if (!opal_paffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
return opal_paffinity_base_module->paff_get_processor_info(num_processors, max_processor_id);
|
||||
return opal_paffinity_base_module->paff_max_processor_id(max_processor_id);
|
||||
}
|
||||
|
||||
int opal_paffinity_base_get_socket_info(int *num_sockets, int *max_socket_num)
|
||||
int opal_paffinity_base_max_socket(int *max_socket)
|
||||
{
|
||||
if (!opal_paffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
return opal_paffinity_base_module->paff_get_socket_info(num_sockets, max_socket_num);
|
||||
return opal_paffinity_base_module->paff_max_socket(max_socket);
|
||||
}
|
||||
|
||||
int opal_paffinity_base_get_core_info(int socket, int *num_cores, int *max_core_num)
|
||||
int opal_paffinity_base_max_core(int socket, int *max_core)
|
||||
{
|
||||
if (!opal_paffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
return opal_paffinity_base_module->paff_get_core_info(socket, num_cores, max_core_num);
|
||||
return opal_paffinity_base_module->paff_max_core(socket, max_core);
|
||||
}
|
||||
|
||||
|
@ -45,9 +45,9 @@ static int linux_module_set(opal_paffinity_base_cpu_set_t cpumask);
|
||||
static int linux_module_get(opal_paffinity_base_cpu_set_t *cpumask);
|
||||
static int linux_module_map_to_processor_id(int socket, int core, int *processor_id);
|
||||
static int linux_module_map_to_socket_core(int processor_id, int *socket, int *core);
|
||||
static int linux_module_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
static int linux_module_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
static int linux_module_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
static int linux_module_max_processor_id(int *max_processor_id);
|
||||
static int linux_module_max_socket(int *max_socket);
|
||||
static int linux_module_max_core(int socket, int *max_core);
|
||||
|
||||
/*
|
||||
* Linux paffinity module
|
||||
@ -64,9 +64,9 @@ static const opal_paffinity_base_module_1_1_0_t module = {
|
||||
linux_module_get,
|
||||
linux_module_map_to_processor_id,
|
||||
linux_module_map_to_socket_core,
|
||||
linux_module_get_processor_info,
|
||||
linux_module_get_socket_info,
|
||||
linux_module_get_core_info,
|
||||
linux_module_max_processor_id,
|
||||
linux_module_max_socket,
|
||||
linux_module_max_core,
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -168,18 +168,18 @@ static int linux_module_map_to_socket_core(int processor_id, int *socket, int *c
|
||||
return opal_paffinity_linux_plpa_map_to_socket_core(processor_id, socket, core);
|
||||
}
|
||||
|
||||
static int linux_module_get_processor_info(int *num_processors, int *max_processor_id)
|
||||
static int linux_module_max_processor_id(int *max_processor_id)
|
||||
{
|
||||
return opal_paffinity_linux_plpa_get_processor_info(num_processors, max_processor_id);
|
||||
return opal_paffinity_linux_plpa_max_processor_id(max_processor_id);
|
||||
}
|
||||
|
||||
static int linux_module_get_socket_info(int *num_sockets, int *max_socket_num)
|
||||
static int linux_module_max_socket(int *max_socket)
|
||||
{
|
||||
return opal_paffinity_linux_plpa_get_socket_info(num_sockets, max_socket_num);
|
||||
return opal_paffinity_linux_plpa_max_socket(max_socket);
|
||||
}
|
||||
|
||||
static int linux_module_get_core_info(int socket, int *num_cores, int *max_core_num)
|
||||
static int linux_module_max_core(int socket, int *max_core)
|
||||
{
|
||||
return opal_paffinity_linux_plpa_get_core_info(socket, num_cores, max_core_num);
|
||||
return opal_paffinity_linux_plpa_max_core(socket, max_core);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006-2007 Cisco, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -27,7 +26,7 @@
|
||||
|
||||
/* Internal macro to munge names */
|
||||
|
||||
/* Preprocessors are fun -- the double inderection is necessary.
|
||||
/* Preprocessors are fun -- the double indirection is necessary.
|
||||
Extra bonus points if you can figure out why! :p */
|
||||
#define PLPA_MUNGE_NAME(a, b) PLPA_MUNGE_NAME2(a, b)
|
||||
#define PLPA_MUNGE_NAME2(a, b) a ## b
|
||||
@ -120,13 +119,13 @@ int PLPA_NAME(map_to_processor_id)(int socket, int core, int *processor_id);
|
||||
int PLPA_NAME(map_to_socket_core)(int processor_id, int *socket, int *core);
|
||||
|
||||
/* Return the max processor ID */
|
||||
int PLPA_NAME(get_processor_info)(int *num_processors, int *max_processor_id);
|
||||
int PLPA_NAME(max_processor_id)(int *max_processor_id);
|
||||
|
||||
/* Return the max socket number */
|
||||
int PLPA_NAME(get_socket_info)(int *num_sockets, int *max_socket_num);
|
||||
int PLPA_NAME(max_socket)(int *max_socket);
|
||||
|
||||
/* Return the max core number for a given socket */
|
||||
int PLPA_NAME(get_core_info)(int socket, int *num_cores, int *max_core_num);
|
||||
int PLPA_NAME(max_core)(int socket, int *max_core);
|
||||
|
||||
/* Shut down PLPA */
|
||||
int PLPA_NAME(finalize)(void);
|
||||
|
@ -130,25 +130,18 @@ typedef struct tuple_t_ {
|
||||
} tuple_t;
|
||||
|
||||
static int supported = 0;
|
||||
static int num_processors = -1;
|
||||
static int max_processor_num = -1;
|
||||
static int num_sockets = -1;
|
||||
static int max_socket_num = -1;
|
||||
static int *max_core_num = NULL;
|
||||
static int *num_cores = NULL;
|
||||
static int max_core_num_overall = -1;
|
||||
static int max_processor = -1;
|
||||
static int max_socket = -1;
|
||||
static int *max_core = NULL;
|
||||
static int max_core_overall = -1;
|
||||
static tuple_t *map_processor_id_to_tuple = NULL;
|
||||
static tuple_t ***map_tuple_to_processor_id = NULL;
|
||||
|
||||
static void clear_cache(void)
|
||||
{
|
||||
if (NULL != max_core_num) {
|
||||
free(max_core_num);
|
||||
max_core_num = NULL;
|
||||
}
|
||||
if (NULL != num_cores) {
|
||||
free(num_cores);
|
||||
num_cores = NULL;
|
||||
if (NULL != max_core) {
|
||||
free(max_core);
|
||||
max_core = NULL;
|
||||
}
|
||||
if (NULL != map_processor_id_to_tuple) {
|
||||
free(map_processor_id_to_tuple);
|
||||
@ -163,17 +156,15 @@ static void clear_cache(void)
|
||||
map_tuple_to_processor_id = NULL;
|
||||
}
|
||||
|
||||
num_processors = max_processor_num = -1;
|
||||
num_sockets = max_socket_num = -1;
|
||||
max_core_num_overall = -1;
|
||||
max_processor = -1;
|
||||
max_socket = -1;
|
||||
max_core_overall = -1;
|
||||
}
|
||||
|
||||
static void load_cache(const char *sysfs_mount)
|
||||
{
|
||||
int i, j, k, invalid_entry, fd;
|
||||
char path[PATH_MAX], buf[8];
|
||||
PLPA_NAME(cpu_set_t) *cores_on_sockets;
|
||||
int found;
|
||||
|
||||
/* Check for the parent directory */
|
||||
sprintf(path, "%s/devices/system/cpu", sysfs_mount);
|
||||
@ -182,30 +173,23 @@ static void load_cache(const char *sysfs_mount)
|
||||
}
|
||||
|
||||
/* Go through and find the max processor ID */
|
||||
for (num_processors = max_processor_num = i = 0;
|
||||
i < PLPA_BITMASK_CPU_MAX; ++i) {
|
||||
sprintf(path, "%s/devices/system/cpu/cpu%d", sysfs_mount, i);
|
||||
if (0 != access(path, (R_OK | X_OK))) {
|
||||
max_processor_num = i - 1;
|
||||
for (max_processor = 0; max_processor < PLPA_BITMASK_CPU_MAX;
|
||||
++max_processor) {
|
||||
sprintf(path, "%s/devices/system/cpu/cpu%d", sysfs_mount,
|
||||
max_processor);
|
||||
if ( access(path, R_OK|X_OK) ) {
|
||||
break;
|
||||
}
|
||||
++num_processors;
|
||||
}
|
||||
|
||||
/* If we found no processors, then we have no topology info */
|
||||
if (0 == num_processors) {
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
--max_processor;
|
||||
|
||||
/* Malloc space for the first map (processor ID -> tuple).
|
||||
Include enough space for one invalid entry. */
|
||||
map_processor_id_to_tuple = malloc(sizeof(tuple_t) *
|
||||
(max_processor_num + 2));
|
||||
map_processor_id_to_tuple = malloc(sizeof(tuple_t) * (max_processor + 2));
|
||||
if (NULL == map_processor_id_to_tuple) {
|
||||
return;
|
||||
}
|
||||
for (i = 0; i <= max_processor_num; ++i) {
|
||||
for (i = 0; i <= max_processor; ++i) {
|
||||
map_processor_id_to_tuple[i].processor_id = i;
|
||||
map_processor_id_to_tuple[i].socket = -1;
|
||||
map_processor_id_to_tuple[i].core = -1;
|
||||
@ -216,119 +200,57 @@ static void load_cache(const char *sysfs_mount)
|
||||
map_processor_id_to_tuple[invalid_entry].socket = -1;
|
||||
map_processor_id_to_tuple[invalid_entry].core = -1;
|
||||
|
||||
/* Malloc space for the max number of cores on each socket */
|
||||
max_core = malloc(sizeof(int) * (max_processor + 1));
|
||||
if (NULL == max_core) {
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
for (i = 0; i <= max_processor; ++i) {
|
||||
max_core[i] = -1;
|
||||
}
|
||||
|
||||
/* Build a cached map of (socket,core) tuples */
|
||||
for (found = 0, i = 0; i <= max_processor_num; ++i) {
|
||||
for ( i = 0; i <= max_processor; i++ ) {
|
||||
sprintf(path, "%s/devices/system/cpu/cpu%d/topology/core_id",
|
||||
sysfs_mount, i);
|
||||
fd = open(path, O_RDONLY);
|
||||
if ( fd < 0 ) {
|
||||
continue;
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
if ( read(fd, buf, 7) <= 0 ) {
|
||||
continue;
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
sscanf(buf, "%d", &(map_processor_id_to_tuple[i].core));
|
||||
close(fd);
|
||||
|
||||
sprintf(path,
|
||||
"%s/devices/system/cpu/cpu%d/topology/physical_package_id",
|
||||
sprintf(path, "%s/devices/system/cpu/cpu%d/topology/physical_package_id",
|
||||
sysfs_mount, i);
|
||||
fd = open(path, O_RDONLY);
|
||||
if ( fd < 0 ) {
|
||||
continue;
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
if ( read(fd, buf, 7) <= 0 ) {
|
||||
continue;
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
sscanf(buf, "%d", &(map_processor_id_to_tuple[i].socket));
|
||||
close(fd);
|
||||
found = 1;
|
||||
|
||||
/* Keep a running tab on the max socket number */
|
||||
if (map_processor_id_to_tuple[i].socket > max_socket_num) {
|
||||
max_socket_num = map_processor_id_to_tuple[i].socket;
|
||||
/* Compute some globals */
|
||||
if (map_processor_id_to_tuple[i].socket > max_socket) {
|
||||
max_socket = map_processor_id_to_tuple[i].socket;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now that we know the max number of sockets, allocate some
|
||||
arrays */
|
||||
max_core_num = malloc(sizeof(int) * (max_socket_num + 1));
|
||||
if (NULL == max_core_num) {
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
num_cores = malloc(sizeof(int) * (max_socket_num + 1));
|
||||
if (NULL == num_cores) {
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
for (i = 0; i <= max_socket_num; ++i) {
|
||||
num_cores[i] = -1;
|
||||
max_core_num[i] = -1;
|
||||
}
|
||||
|
||||
/* Find the max core number on each socket */
|
||||
for (i = 0; i <= max_processor_num; ++i) {
|
||||
if (map_processor_id_to_tuple[i].core >
|
||||
max_core_num[map_processor_id_to_tuple[i].socket]) {
|
||||
max_core_num[map_processor_id_to_tuple[i].socket] =
|
||||
max_core[map_processor_id_to_tuple[i].socket]) {
|
||||
max_core[map_processor_id_to_tuple[i].socket] =
|
||||
map_processor_id_to_tuple[i].core;
|
||||
}
|
||||
if (max_core_num[map_processor_id_to_tuple[i].socket] >
|
||||
max_core_num_overall) {
|
||||
max_core_num_overall =
|
||||
max_core_num[map_processor_id_to_tuple[i].socket];
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't find any core_id/physical_package_id's, then we
|
||||
don't have the topology info */
|
||||
if (!found) {
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Go through and count the number of unique sockets found. It
|
||||
may not be the same as max_socket_num because there may be
|
||||
"holes" -- e.g., sockets 0 and 3 are used, but sockets 1 and 2
|
||||
are empty. */
|
||||
for (j = i = 0; i <= max_socket_num; ++i) {
|
||||
if (max_core_num[i] >= 0) {
|
||||
++j;
|
||||
}
|
||||
}
|
||||
if (j > 0) {
|
||||
num_sockets = j;
|
||||
}
|
||||
|
||||
/* Count how many cores are available on each socket. This may
|
||||
not be the same as max_core_num[socket_num] if there are
|
||||
"holes". I don't know if holes can happen (i.e., if specific
|
||||
cores can be taken offline), but what the heck... */
|
||||
cores_on_sockets = malloc(sizeof(PLPA_NAME(cpu_set_t)) *
|
||||
(max_socket_num + 1));
|
||||
if (NULL == cores_on_sockets) {
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
for (i = 0; i <= max_socket_num; ++i) {
|
||||
PLPA_CPU_ZERO(&(cores_on_sockets[i]));
|
||||
}
|
||||
for (i = 0; i <= max_processor_num; ++i) {
|
||||
if (map_processor_id_to_tuple[i].socket >= 0) {
|
||||
PLPA_CPU_SET(map_processor_id_to_tuple[i].core,
|
||||
&(cores_on_sockets[map_processor_id_to_tuple[i].socket]));
|
||||
}
|
||||
}
|
||||
for (i = 0; i <= max_socket_num; ++i) {
|
||||
int count = 0;
|
||||
for (j = 0; j < PLPA_BITMASK_CPU_MAX; ++j) {
|
||||
if (PLPA_CPU_ISSET(j, &(cores_on_sockets[i]))) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
num_cores[i] = count;
|
||||
if (max_core[map_processor_id_to_tuple[i].socket] > max_core_overall) {
|
||||
max_core_overall = max_core[map_processor_id_to_tuple[i].socket];
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,27 +258,26 @@ static void load_cache(const char *sysfs_mount)
|
||||
(socket,core) => processor_id. This map simply points to
|
||||
entries in the other map (i.e., it's by reference instead of by
|
||||
value). */
|
||||
map_tuple_to_processor_id = malloc(sizeof(tuple_t **) *
|
||||
(max_socket_num + 1));
|
||||
map_tuple_to_processor_id = malloc(sizeof(tuple_t **) * (max_socket + 1));
|
||||
if (NULL == map_tuple_to_processor_id) {
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
map_tuple_to_processor_id[0] = malloc(sizeof(tuple_t *) *
|
||||
((max_socket_num + 1) *
|
||||
(max_core_num_overall + 1)));
|
||||
((max_socket + 1) *
|
||||
(max_core_overall + 1)));
|
||||
if (NULL == map_tuple_to_processor_id[0]) {
|
||||
clear_cache();
|
||||
return;
|
||||
}
|
||||
/* Set pointers for 2nd dimension */
|
||||
for (i = 1; i <= max_socket_num; ++i) {
|
||||
for (i = 1; i <= max_socket; ++i) {
|
||||
map_tuple_to_processor_id[i] =
|
||||
map_tuple_to_processor_id[i - 1] + max_core_num_overall;
|
||||
map_tuple_to_processor_id[i - 1] + max_core_overall;
|
||||
}
|
||||
/* Compute map */
|
||||
for (i = 0; i <= max_socket_num; ++i) {
|
||||
for (j = 0; j <= max_core_num_overall; ++j) {
|
||||
for (i = 0; i <= max_socket; ++i) {
|
||||
for (j = 0; j <= max_core_overall; ++j) {
|
||||
/* Default to the invalid entry in the other map, meaning
|
||||
that this (socket,core) combination doesn't exist
|
||||
(e.g., the core number does not exist in this socket,
|
||||
@ -367,7 +288,7 @@ static void load_cache(const char *sysfs_mount)
|
||||
/* See if this (socket,core) tuple exists in the other
|
||||
map. If so, set this entry to point to it (overriding
|
||||
the invalid entry default). */
|
||||
for (k = 0; k <= max_processor_num; ++k) {
|
||||
for (k = 0; k <= max_processor; ++k) {
|
||||
if (map_processor_id_to_tuple[k].socket == i &&
|
||||
map_processor_id_to_tuple[k].core == j) {
|
||||
map_tuple_to_processor_id[i][j] =
|
||||
@ -449,8 +370,8 @@ int PLPA_NAME(map_to_processor_id)(int socket, int core, int *processor_id)
|
||||
}
|
||||
|
||||
/* Check for some invalid entries */
|
||||
if (socket < 0 || socket > max_socket_num ||
|
||||
core < 0 || core > max_core_num_overall ||
|
||||
if (socket < 0 || socket > max_socket ||
|
||||
core < 0 || core > max_core_overall ||
|
||||
NULL == processor_id) {
|
||||
return EINVAL;
|
||||
}
|
||||
@ -482,7 +403,7 @@ int PLPA_NAME(map_to_socket_core)(int processor_id, int *socket, int *core)
|
||||
}
|
||||
|
||||
/* Check for some invalid entries */
|
||||
if (processor_id < 0 || processor_id > max_processor_num ||
|
||||
if (processor_id < 0 || processor_id > max_processor ||
|
||||
NULL == socket ||
|
||||
NULL == core) {
|
||||
return EINVAL;
|
||||
@ -494,8 +415,7 @@ int PLPA_NAME(map_to_socket_core)(int processor_id, int *socket, int *core)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PLPA_NAME(get_processor_info)(int *num_processors_arg,
|
||||
int *max_processor_num_arg)
|
||||
int PLPA_NAME(max_processor_id)(int *max_processor_id_arg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -507,7 +427,7 @@ int PLPA_NAME(get_processor_info)(int *num_processors_arg,
|
||||
}
|
||||
|
||||
/* Check for bozo arguments */
|
||||
if (NULL == max_processor_num_arg || NULL == num_processors_arg) {
|
||||
if (NULL == max_processor_id_arg) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@ -517,13 +437,12 @@ int PLPA_NAME(get_processor_info)(int *num_processors_arg,
|
||||
}
|
||||
|
||||
/* All done */
|
||||
*num_processors_arg = num_processors;
|
||||
*max_processor_num_arg = max_processor_num;
|
||||
*max_processor_id_arg = max_processor;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return the max socket number */
|
||||
int PLPA_NAME(get_socket_info)(int *num_sockets_arg, int *max_socket_num_arg)
|
||||
int PLPA_NAME(max_socket)(int *max_socket_arg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -535,7 +454,7 @@ int PLPA_NAME(get_socket_info)(int *num_sockets_arg, int *max_socket_num_arg)
|
||||
}
|
||||
|
||||
/* Check for bozo arguments */
|
||||
if (NULL == max_socket_num_arg || NULL == num_sockets_arg) {
|
||||
if (NULL == max_socket_arg) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@ -545,14 +464,12 @@ int PLPA_NAME(get_socket_info)(int *num_sockets_arg, int *max_socket_num_arg)
|
||||
}
|
||||
|
||||
/* All done */
|
||||
*num_sockets_arg = num_sockets;
|
||||
*max_socket_num_arg = max_socket_num;
|
||||
*max_socket_arg = max_socket;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return the number of cores in a socket and the max core ID number */
|
||||
int PLPA_NAME(get_core_info)(int socket, int *num_cores_arg,
|
||||
int *max_core_num_arg)
|
||||
/* Return the max core number for a given socket */
|
||||
int PLPA_NAME(max_core)(int socket, int *max_core_arg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -564,7 +481,7 @@ int PLPA_NAME(get_core_info)(int socket, int *num_cores_arg,
|
||||
}
|
||||
|
||||
/* Check for bozo arguments */
|
||||
if (NULL == max_core_num_arg || NULL == num_cores_arg) {
|
||||
if (NULL == max_core_arg) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@ -574,12 +491,11 @@ int PLPA_NAME(get_core_info)(int socket, int *num_cores_arg,
|
||||
}
|
||||
|
||||
/* Check for some invalid entries */
|
||||
if (socket < 0 || socket > max_socket_num || -1 == max_core_num[socket]) {
|
||||
if (socket < 0 || socket > max_socket) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* All done */
|
||||
*num_cores_arg = num_cores[socket];
|
||||
*max_core_num_arg = max_core_num[socket];
|
||||
*max_core_arg = max_core[socket];
|
||||
return 0;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ int main(int argc, char *argv[])
|
||||
int ret = 0;
|
||||
int need_help = 0;
|
||||
int show_topo = 0;
|
||||
int have_topo, num_sockets, max_socket_num, num_cores, max_core_num;
|
||||
int have_topo, max_socket, max_core;
|
||||
PLPA_NAME(api_type_t) api_probe;
|
||||
|
||||
for (i = 1; i < argc; ++i) {
|
||||
@ -73,15 +73,10 @@ int main(int argc, char *argv[])
|
||||
have_topo = 0;
|
||||
}
|
||||
printf("Kernel topology support: %s\n", have_topo ? "yes" : "no");
|
||||
if (0 != PLPA_NAME(get_socket_info)(&num_sockets, &max_socket_num)) {
|
||||
num_sockets = max_socket_num = -1;
|
||||
}
|
||||
printf("Number of processor sockets: ");
|
||||
if (have_topo && num_sockets >= 0) {
|
||||
printf("%d\n", num_sockets);
|
||||
} else {
|
||||
printf("unknown\n");
|
||||
if (0 != PLPA_NAME(max_socket)(&max_socket)) {
|
||||
max_socket = -1;
|
||||
}
|
||||
printf("Number of processor sockets: %d\n", have_topo ? max_socket : -1);
|
||||
|
||||
/* If asked, print the map */
|
||||
|
||||
@ -89,11 +84,13 @@ int main(int argc, char *argv[])
|
||||
if (have_topo) {
|
||||
/* Remember that max_socket and max_core values are
|
||||
0-indexed */
|
||||
for (i = 0; i <= max_socket_num; ++i) {
|
||||
ret = PLPA_NAME(get_core_info)(i, &num_cores, &max_core_num);
|
||||
for (i = 0; i <= max_socket; ++i) {
|
||||
ret = PLPA_NAME(max_core)(i, &max_core);
|
||||
if (0 == ret) {
|
||||
printf("Socket %d: %d core%s\n", i, num_cores,
|
||||
(1 == num_cores) ? "" : "s");
|
||||
printf("Socket %d: %d core%s\n", i, max_core + 1,
|
||||
(0 == max_core) ? "" : "s");
|
||||
} else {
|
||||
printf("Socket %d: unknown cores\n", i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -87,11 +87,11 @@ static void append(char *str, int val)
|
||||
|
||||
static char *cpu_set_to_list(const PLPA_NAME(cpu_set_t) *cpu_set)
|
||||
{
|
||||
size_t i, j, last_bit, size = PLPA_BITMASK_CPU_MAX;
|
||||
size_t i, j, last_bit, size = PLPA_BITMASK_NUM_ELEMENTS;
|
||||
unsigned long long mask_value = 0;
|
||||
/* Upper bound on string length: 4 digits per
|
||||
PLPA_BITMASK_CPU_MAX + 1 comma for each */
|
||||
static char str[PLPA_BITMASK_CPU_MAX * 5];
|
||||
PLPA_BITMASK_NUM_ELEMENTS + 1 comma for each */
|
||||
static char str[PLPA_BITMASK_NUM_ELEMENTS * 5];
|
||||
char temp[8];
|
||||
|
||||
if (sizeof(mask_value) * 8 < size) {
|
||||
@ -156,7 +156,7 @@ static char *cpu_set_to_list(const PLPA_NAME(cpu_set_t) *cpu_set)
|
||||
|
||||
static unsigned long long cpu_set_to_ll(const PLPA_NAME(cpu_set_t) *cpu_set)
|
||||
{
|
||||
size_t i, size = PLPA_BITMASK_CPU_MAX;
|
||||
size_t i, size = PLPA_BITMASK_NUM_ELEMENTS;
|
||||
unsigned long long mask_value = 0;
|
||||
|
||||
if (sizeof(mask_value) * 8 < size) {
|
||||
@ -164,7 +164,7 @@ static unsigned long long cpu_set_to_ll(const PLPA_NAME(cpu_set_t) *cpu_set)
|
||||
}
|
||||
for (i = 0; i < size; ++i) {
|
||||
if (PLPA_CPU_ISSET(i, cpu_set)) {
|
||||
mask_value |= 1llu << i;
|
||||
mask_value += 1 << i;
|
||||
}
|
||||
}
|
||||
return mask_value;
|
||||
@ -184,7 +184,7 @@ static int cpu_list_to_cpu_set(char *str, PLPA_NAME(cpu_set_t) *cpu_set)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mask_to_cpu_set(const char *mask_string, PLPA_NAME(cpu_set_t) *cpu_set)
|
||||
static int mask_to_cpu_set(char *mask_string, PLPA_NAME(cpu_set_t) *cpu_set)
|
||||
{
|
||||
size_t i;
|
||||
unsigned int mask_value;
|
||||
@ -192,7 +192,7 @@ static int mask_to_cpu_set(const char *mask_string, PLPA_NAME(cpu_set_t) *cpu_se
|
||||
PLPA_CPU_ZERO(cpu_set);
|
||||
sscanf(mask_string, "%x", &mask_value);
|
||||
for (i = 0; i < sizeof(mask_value) * 8; ++i) {
|
||||
if (0 != (mask_value & (1u << i))) {
|
||||
if (0 != (mask_value & (1 << i))) {
|
||||
PLPA_CPU_SET(i, cpu_set);
|
||||
}
|
||||
}
|
||||
@ -371,6 +371,7 @@ int main(int argc, char *argv[])
|
||||
{ "cpu-list", 0, NULL, 'c' },
|
||||
{ "help", 0, NULL, 'h' },
|
||||
{ "version", 0, NULL, 'V' },
|
||||
{ "testing", 0, NULL, 't' },
|
||||
/* Undocumented testing function */
|
||||
{ "testing", 0, NULL, 't' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
|
@ -194,7 +194,7 @@ typedef int (*opal_paffinity_base_module_map_to_socket_core_fn_t)(int processor_
|
||||
* return OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supporeted (solaris, windows, etc...)
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_get_processor_info_fn_t)(int *num_processors, int *max_processor_id);
|
||||
typedef int (*opal_paffinity_base_module_max_processor_id_fn_t)(int *max_processor_id);
|
||||
|
||||
/**
|
||||
* Provides the number of sockets in a host. currently supported
|
||||
@ -203,7 +203,7 @@ typedef int (*opal_paffinity_base_module_get_processor_info_fn_t)(int *num_proce
|
||||
* return OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supporeted (solaris, windows, etc...)
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_get_socket_info_fn_t)(int *num_sockets, int *max_socket_num);
|
||||
typedef int (*opal_paffinity_base_module_max_socket_fn_t)(int *max_socket);
|
||||
|
||||
/**
|
||||
* Provides the number of cores in a socket. currently supported
|
||||
@ -212,7 +212,7 @@ typedef int (*opal_paffinity_base_module_get_socket_info_fn_t)(int *num_sockets,
|
||||
* return OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supporeted (solaris, windows, etc...)
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_get_core_info_fn_t)(int socket, int *num_cores, int *max_core_num);
|
||||
typedef int (*opal_paffinity_base_module_max_core)(int socket, int *max_core);
|
||||
|
||||
|
||||
/**
|
||||
@ -262,13 +262,13 @@ struct opal_paffinity_base_module_1_1_0_t {
|
||||
opal_paffinity_base_module_map_to_socket_core_fn_t paff_map_to_socket_core;
|
||||
|
||||
/** Return the max processor ID */
|
||||
opal_paffinity_base_module_get_processor_info_fn_t paff_get_processor_info;
|
||||
opal_paffinity_base_module_max_processor_id_fn_t paff_max_processor_id;
|
||||
|
||||
/** Return the max socket number */
|
||||
opal_paffinity_base_module_get_socket_info_fn_t paff_get_socket_info;
|
||||
opal_paffinity_base_module_max_socket_fn_t paff_max_socket;
|
||||
|
||||
/** Return the max core number */
|
||||
opal_paffinity_base_module_get_core_info_fn_t paff_get_core_info;
|
||||
opal_paffinity_base_module_max_core paff_max_core;
|
||||
|
||||
/** Shut down this module */
|
||||
opal_paffinity_base_module_finalize_fn_t paff_module_finalize;
|
||||
|
@ -45,9 +45,9 @@ static int solaris_module_finalize(void);
|
||||
static int cpumask_to_id(opal_paffinity_base_cpu_set_t cpumask);
|
||||
static int solaris_module_map_to_processor_id(int socket, int core, int *processor_id);
|
||||
static int solaris_module_map_to_socket_core(int processor_id, int *socket, int *core);
|
||||
static int solaris_module_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
static int solaris_module_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
static int solaris_module_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
static int solaris_module_max_processor_id(int *max_processor_id);
|
||||
static int solaris_module_max_socket(int *max_socket);
|
||||
static int solaris_module_max_core(int socket, int *max_core);
|
||||
|
||||
/*
|
||||
* Solaris paffinity module
|
||||
@ -64,9 +64,9 @@ static const opal_paffinity_base_module_1_1_0_t module = {
|
||||
solaris_module_get,
|
||||
solaris_module_map_to_processor_id,
|
||||
solaris_module_map_to_socket_core,
|
||||
solaris_module_get_processor_info,
|
||||
solaris_module_get_socket_info,
|
||||
solaris_module_get_core_info,
|
||||
solaris_module_max_processor_id,
|
||||
solaris_module_max_socket,
|
||||
solaris_module_max_core,
|
||||
solaris_module_finalize
|
||||
};
|
||||
|
||||
@ -173,17 +173,17 @@ static int solaris_module_map_to_socket_core(int processor_id, int *socket, int
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int solaris_module_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
static int solaris_module_max_processor_id(int *max_processor_id)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int solaris_module_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
static int solaris_module_max_socket(int *max_socket)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int solaris_module_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
static int solaris_module_max_core(int socket, int *max_core)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ static int windows_module_set(opal_paffinity_base_cpu_set_t cpumask);
|
||||
static int windows_module_get(opal_paffinity_base_cpu_set_t *cpumask);
|
||||
static int windows_module_map_to_processor_id(int socket, int core, int *processor_id);
|
||||
static int windows_module_map_to_socket_core(int processor_id, int *socket, int *core);
|
||||
static int windows_module_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
static int windows_module_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
static int windows_module_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
static int windows_module_max_processor_id(int *max_processor_id);
|
||||
static int windows_module_max_socket(int *max_socket);
|
||||
static int windows_module_max_core(int socket, int *max_core);
|
||||
|
||||
static SYSTEM_INFO sys_info;
|
||||
|
||||
@ -54,9 +54,9 @@ static const opal_paffinity_base_module_1_1_0_t module = {
|
||||
windows_module_get,
|
||||
windows_module_map_to_processor_id,
|
||||
windows_module_map_to_socket_core,
|
||||
windows_module_get_processor_info,
|
||||
windows_module_get_socket_info,
|
||||
windows_module_get_core_info,
|
||||
windows_module_max_processor_id,
|
||||
windows_module_max_socket,
|
||||
windows_module_max_core,
|
||||
windows_module_finalize
|
||||
};
|
||||
|
||||
@ -134,17 +134,17 @@ static int windows_module_map_to_socket_core(int processor_id, int *socket, int
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int windows_module_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
static int windows_module_max_processor_id(int *max_processor_id)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int windows_module_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
static int windows_module_max_socket(int *max_socket)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int windows_module_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
static int windows_module_max_core(int socket, int *max_core)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user