Bring in PLPA v1.2b4
This commit was SVN r19299.
Этот коммит содержится в:
родитель
a81dfa0aea
Коммит
80d11dba8f
@ -16,7 +16,7 @@ release=0
|
||||
# requirement is that it must be entirely printable ASCII characters
|
||||
# and have no white space.
|
||||
|
||||
greek=b3
|
||||
greek=b4
|
||||
|
||||
# If want_svn=1, then the SVN r number will be included in the overall
|
||||
# PLPA version number in some form.
|
||||
@ -33,4 +33,4 @@ want_svn=0
|
||||
# distribution tarball is being made from an SVN checkout, the value
|
||||
# of svn_r in this file is replaced with the output of "svnversion".
|
||||
|
||||
svn_r=r197
|
||||
svn_r=r208
|
||||
|
@ -199,14 +199,14 @@ int PLPA_NAME(map_to_processor_id)(int socket_id, int core_id,
|
||||
int PLPA_NAME(map_to_socket_core)(int processor_id,
|
||||
int *socket_id, int *core_id);
|
||||
|
||||
/* Returns both the total number of processors in a system and the
|
||||
maximum Linux virtual processor ID (because it may be higher than
|
||||
the number of processors if there are "holes" in the available
|
||||
Linux virtual processor IDs). Returns 0 upon success. */
|
||||
/* This function is deprecated and will disappear in a future release.
|
||||
It is exactly equivalent to calling
|
||||
plpa_get_processor_data(PLPA_COUNT_ALL, num_processors,
|
||||
max_processor_id). */
|
||||
int PLPA_NAME(get_processor_info)(int *num_processors, int *max_processor_id);
|
||||
|
||||
/* Typedefs for specifying which processors / sockets / cores to count
|
||||
in get_processor_id() */
|
||||
in get_processor_data() and get_processor_id() */
|
||||
typedef enum {
|
||||
/* Only count online processors */
|
||||
PLPA_NAME_CAPS(COUNT_ONLINE),
|
||||
@ -216,14 +216,24 @@ typedef enum {
|
||||
PLPA_NAME_CAPS(COUNT_ALL)
|
||||
} PLPA_NAME(count_specification_t);
|
||||
|
||||
/* Returns both the number of processors in a system and the maximum
|
||||
Linux virtual processor ID (because it may be higher than the
|
||||
number of processors if there are "holes" in the available Linux
|
||||
virtual processor IDs). The count_spec argument specifies whether
|
||||
to count all processors, only online processors, or only offline
|
||||
processors. Returns 0 upon success. */
|
||||
int PLPA_NAME(get_processor_data)(PLPA_NAME(count_specification_t) count_spec,
|
||||
int *num_processors, int *max_processor_id);
|
||||
|
||||
/* Returns the Linux processor ID for the Nth processor. For example,
|
||||
if the Linux processor IDs have "holes", use this function to say
|
||||
"give me the Linux processor ID of the 4th processor." count_spec
|
||||
specifies whether to count online, offline, or all processors when
|
||||
looking for the processor_num'th processor. Returns 0 upon
|
||||
success. */
|
||||
int PLPA_NAME(get_processor_id)(int processor_num, int *processor_id,
|
||||
PLPA_NAME(count_specification_t) count_spec);
|
||||
int PLPA_NAME(get_processor_id)(int processor_num,
|
||||
PLPA_NAME(count_specification_t) count_spec,
|
||||
int *processor_id);
|
||||
|
||||
/* Check to see if a given Linux processor ID exists / is online.
|
||||
Returns 0 on success. */
|
||||
|
@ -454,7 +454,7 @@ static void load_cache(void)
|
||||
if (map_processor_id_to_tuple[k].socket_id == i &&
|
||||
map_processor_id_to_tuple[k].core_id == j) {
|
||||
*tuple_ptr = &map_processor_id_to_tuple[k];
|
||||
#if defined(PLPA_DEBUG) && PLPA_DEBUG
|
||||
#if defined(PLPA_DEBUG) && PLPA_DEBUG && 0
|
||||
printf("Creating map [%d]: (socket %d, core %d) -> ID %d\n",
|
||||
i * (max_core_id_overall + 1) + j,
|
||||
i, j, k);
|
||||
@ -599,10 +599,21 @@ int PLPA_NAME(map_to_socket_core)(int processor_id,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Deprecated function */
|
||||
int PLPA_NAME(get_processor_info)(int *num_processors_arg,
|
||||
int *max_processor_id_arg)
|
||||
{
|
||||
int ret;
|
||||
return PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_ALL),
|
||||
num_processors_arg,
|
||||
max_processor_id_arg);
|
||||
}
|
||||
|
||||
int PLPA_NAME(get_processor_data)(PLPA_NAME(count_specification_t) count_spec,
|
||||
int *num_processors_arg,
|
||||
int *max_processor_id_arg)
|
||||
{
|
||||
int i, ret;
|
||||
bool match;
|
||||
|
||||
/* Initialize if not already done so */
|
||||
if (!PLPA_NAME(initialized)) {
|
||||
@ -626,16 +637,52 @@ int PLPA_NAME(get_processor_info)(int *num_processors_arg,
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* All done */
|
||||
*num_processors_arg = num_processors;
|
||||
*max_processor_id_arg = max_processor_id;
|
||||
/* If we wanted all processors, we're done */
|
||||
if (PLPA_NAME_CAPS(COUNT_ALL) == count_spec) {
|
||||
*num_processors_arg = num_processors;
|
||||
*max_processor_id_arg = max_processor_id;
|
||||
} else {
|
||||
/* Otherwise, count the appropriate type */
|
||||
*num_processors_arg = 0;
|
||||
*max_processor_id_arg = 0;
|
||||
for (i = 0; i <= max_processor_id; ++i) {
|
||||
if (map_processor_id_to_tuple[i].processor_id >= 0) {
|
||||
match = false;
|
||||
switch (count_spec) {
|
||||
case PLPA_NAME_CAPS(COUNT_ONLINE):
|
||||
if (map_processor_id_to_tuple[i].online) {
|
||||
match = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case PLPA_NAME_CAPS(COUNT_OFFLINE):
|
||||
if (!map_processor_id_to_tuple[i].online) {
|
||||
match = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* Just so that compilers don't complain */
|
||||
break;
|
||||
}
|
||||
if (match) {
|
||||
++(*num_processors_arg);
|
||||
if (*max_processor_id_arg <
|
||||
map_processor_id_to_tuple[i].processor_id) {
|
||||
*max_processor_id_arg =
|
||||
map_processor_id_to_tuple[i].processor_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Returns the Linux processor ID for the Nth processor (starting with
|
||||
0). */
|
||||
int PLPA_NAME(get_processor_id)(int processor_num, int *processor_id,
|
||||
PLPA_NAME(count_specification_t) count_spec)
|
||||
int PLPA_NAME(get_processor_id)(int processor_num,
|
||||
PLPA_NAME(count_specification_t) count_spec,
|
||||
int *processor_id)
|
||||
{
|
||||
int ret, i, count;
|
||||
bool match;
|
||||
|
@ -27,7 +27,10 @@ int main(int argc, char *argv[])
|
||||
int need_help = 0;
|
||||
int show_topo = 0;
|
||||
int have_topo, num_sockets, max_socket_num, num_cores, max_core_id;
|
||||
int num_processors, max_processor_id, processor_id;
|
||||
int num_processors_online, max_processor_id_online;
|
||||
int num_processors_offline, max_processor_id_offline;
|
||||
int num_processors_total, max_processor_id_total;
|
||||
int processor_id;
|
||||
int socket_id, exists, online, num_offline;
|
||||
PLPA_NAME(api_type_t) api_probe;
|
||||
|
||||
@ -92,6 +95,61 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (show_topo) {
|
||||
if (have_topo) {
|
||||
/* Go through all the processors and count how many are
|
||||
offline; we have no topology information for offline
|
||||
processors */
|
||||
if (0 != PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_ALL),
|
||||
&num_processors_total,
|
||||
&max_processor_id_total) ||
|
||||
0 != PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_ONLINE),
|
||||
&num_processors_online,
|
||||
&max_processor_id_online) ||
|
||||
0 != PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_OFFLINE),
|
||||
&num_processors_offline,
|
||||
&max_processor_id_offline)) {
|
||||
fprintf(stderr, "plpa_get_processor_info failed\n");
|
||||
exit(1);
|
||||
}
|
||||
/* This is a little overkill; this information should
|
||||
never mismatch. But what the heck. */
|
||||
if (num_processors_online + num_processors_offline !=
|
||||
num_processors_total) {
|
||||
fprintf(stderr, "Number of online and offline processors do not seem to add up (online: %d, offline: %d, total: %d)\n",
|
||||
num_processors_online,
|
||||
num_processors_offline,
|
||||
num_processors_total);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("Number of processors online: %d\n", num_processors_online);
|
||||
printf("Number of processors offline: %d (no topology information available)\n",
|
||||
num_processors_offline);
|
||||
|
||||
/* Another "over the top" check -- these should never
|
||||
disagree. But what the heck; it's a good test of
|
||||
PLPA. */
|
||||
for (num_offline = i = 0; i < num_processors_total; ++i) {
|
||||
if (0 != PLPA_NAME(get_processor_id)(i,
|
||||
PLPA_NAME_CAPS(COUNT_ALL),
|
||||
&processor_id)) {
|
||||
fprintf(stderr, "pla_get_processor_id failed\n");
|
||||
break;
|
||||
}
|
||||
if (0 != PLPA_NAME(get_processor_flags)(processor_id,
|
||||
&exists,
|
||||
&online)) {
|
||||
fprintf(stderr, "plpa_get_processor_flags failed\n");
|
||||
break;
|
||||
}
|
||||
if (exists && !online) {
|
||||
++num_offline;
|
||||
}
|
||||
}
|
||||
if (num_offline != num_processors_offline) {
|
||||
fprintf(stderr, "Number of online and offline processors do not seem to add up (1)\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Go through all the sockets */
|
||||
for (i = 0; i < num_sockets; ++i) {
|
||||
/* Turn the socket number into a Linux socket ID */
|
||||
@ -110,34 +168,6 @@ int main(int argc, char *argv[])
|
||||
i, socket_id, num_cores, (1 == num_cores) ? "" : "s",
|
||||
max_core_id);
|
||||
}
|
||||
|
||||
/* Go through all the processors and count how many are
|
||||
offline; we have no topology information for offline
|
||||
processors */
|
||||
if (0 != PLPA_NAME(get_processor_info)(&num_processors,
|
||||
&max_processor_id)) {
|
||||
fprintf(stderr, "plpa_get_processor_info failed\n");
|
||||
} else {
|
||||
for (num_offline = i = 0; i < num_processors; ++i) {
|
||||
if (0 != PLPA_NAME(get_processor_id)(i, &processor_id,
|
||||
PLPA_NAME_CAPS(COUNT_ALL))) {
|
||||
fprintf(stderr, "pla_get_processor_id failed\n");
|
||||
break;
|
||||
}
|
||||
if (0 != PLPA_NAME(get_processor_flags)(processor_id,
|
||||
&exists,
|
||||
&online)) {
|
||||
fprintf(stderr, "plpa_get_processor_flags failed\n");
|
||||
break;
|
||||
}
|
||||
if (exists && !online) {
|
||||
++num_offline;
|
||||
}
|
||||
}
|
||||
if (num_offline > 0) {
|
||||
printf("%d processor%s offline (no topology information available)\n", num_offline, (1 == num_offline ? "" : "s"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printf("Kernel topology not supported -- cannot show topology information\n");
|
||||
exit(1);
|
||||
|
@ -22,9 +22,6 @@ if PLPA_BUILD_EXECUTABLES
|
||||
bin_PROGRAMS += plpa-taskset
|
||||
endif
|
||||
|
||||
# Force parser.c to be re-compiled when tokens.h is re-generated
|
||||
parser.c: tokens.h
|
||||
|
||||
plpa_taskset_SOURCES = \
|
||||
plpa-taskset.c \
|
||||
plpa-taskset.h \
|
||||
|
@ -1489,19 +1489,20 @@ static void cpu_set(PLPA_NAME(cpu_set_t) *out, int pos)
|
||||
|
||||
static void cpu_set_all(PLPA_NAME(cpu_set_t) *out, id_type_t type)
|
||||
{
|
||||
int i, max_id, max_id_num, s, c;
|
||||
int i, max_num, max_id, exists, online;
|
||||
PLPA_CPU_ZERO(out);
|
||||
|
||||
/* Only set processor ID's that exist */
|
||||
/* Only set processor ID's that exist and are online */
|
||||
if (ALL == type) {
|
||||
max_id_num = PLPA_BITMASK_CPU_MAX;
|
||||
max_id = PLPA_BITMASK_CPU_MAX;
|
||||
} else if (PROCESSOR == type) {
|
||||
plpa_get_processor_info(&max_id, &max_id_num);
|
||||
PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_ONLINE),
|
||||
&max_num, &max_id);
|
||||
}
|
||||
|
||||
for (i = 0; i <= max_id_num; ++i) {
|
||||
if (ALL == type ||
|
||||
(PROCESSOR == type && 0 == plpa_map_to_socket_core(i, &s, &c))) {
|
||||
for (i = 0; i <= max_id; ++i) {
|
||||
if (0 == PLPA_NAME(get_processor_flags)(i, &exists, &online) &&
|
||||
exists && online) {
|
||||
PLPA_CPU_SET(i, out);
|
||||
}
|
||||
}
|
||||
@ -1509,19 +1510,20 @@ static void cpu_set_all(PLPA_NAME(cpu_set_t) *out, id_type_t type)
|
||||
|
||||
static void cpu_set_even(PLPA_NAME(cpu_set_t) *out, id_type_t type)
|
||||
{
|
||||
int i, max_id, max_id_num, s, c;
|
||||
int i, max_num, max_id, exists, online;
|
||||
PLPA_CPU_ZERO(out);
|
||||
|
||||
/* Only set processor ID's that exist */
|
||||
/* Only set processor ID's that exist and are online */
|
||||
if (ALL == type) {
|
||||
max_id_num = PLPA_BITMASK_CPU_MAX;
|
||||
max_id = PLPA_BITMASK_CPU_MAX;
|
||||
} else if (PROCESSOR == type) {
|
||||
plpa_get_processor_info(&max_id, &max_id_num);
|
||||
PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_ONLINE),
|
||||
&max_num, &max_id);
|
||||
}
|
||||
|
||||
for (i = 0; i <= max_id_num; i += 2) {
|
||||
if (ALL == type ||
|
||||
(PROCESSOR == type && 0 == plpa_map_to_socket_core(i, &s, &c))) {
|
||||
for (i = 0; i <= max_id; i += 2) {
|
||||
if (0 == PLPA_NAME(get_processor_flags)(i, &exists, &online) &&
|
||||
exists && online) {
|
||||
PLPA_CPU_SET(i, out);
|
||||
}
|
||||
}
|
||||
@ -1529,19 +1531,20 @@ static void cpu_set_even(PLPA_NAME(cpu_set_t) *out, id_type_t type)
|
||||
|
||||
static void cpu_set_odd(PLPA_NAME(cpu_set_t) *out, id_type_t type)
|
||||
{
|
||||
int i, max_id, max_id_num, s, c;
|
||||
int i, max_num, max_id, exists, online;
|
||||
PLPA_CPU_ZERO(out);
|
||||
|
||||
/* Only set processor ID's that exist */
|
||||
if (ALL == type) {
|
||||
max_id_num = PLPA_BITMASK_CPU_MAX;
|
||||
max_id = PLPA_BITMASK_CPU_MAX;
|
||||
} else if (PROCESSOR == type) {
|
||||
plpa_get_processor_info(&max_id, &max_id_num);
|
||||
PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_ONLINE),
|
||||
&max_num, &max_id);
|
||||
}
|
||||
|
||||
for (i = 1; i <= max_id_num; i += 2) {
|
||||
if (ALL == type ||
|
||||
(PROCESSOR == type && 0 == plpa_map_to_socket_core(i, &s, &c))) {
|
||||
for (i = 1; i <= max_id; i += 2) {
|
||||
if (0 == PLPA_NAME(get_processor_flags)(i, &exists, &online) &&
|
||||
exists && online) {
|
||||
PLPA_CPU_SET(i, out);
|
||||
}
|
||||
}
|
||||
@ -1590,7 +1593,7 @@ static void sc_merge(PLPA_NAME(cpu_set_t) *out,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (0 != plpa_get_socket_info(&num_sockets, &max_socket_id)) {
|
||||
if (0 != PLPA_NAME(get_socket_info)(&num_sockets, &max_socket_id)) {
|
||||
fprintf(stderr, "ERROR: Unable to retrieve socket information\n");
|
||||
exit(1);
|
||||
}
|
||||
@ -1608,8 +1611,8 @@ static void sc_merge(PLPA_NAME(cpu_set_t) *out,
|
||||
socket, max_socket_id);
|
||||
exit(1);
|
||||
} else if (sockets_are_valid &&
|
||||
ENOENT == plpa_get_core_info(socket, &num_cores,
|
||||
&max_core_id) &&
|
||||
ENOENT == PLPA_NAME(get_core_info)(socket, &num_cores,
|
||||
&max_core_id) &&
|
||||
PLPA_CPU_ISSET(socket, sockets)) {
|
||||
fprintf(stderr, "ERROR: Invalid socket ID specified (%d does not exist)\n",
|
||||
socket);
|
||||
|
@ -196,19 +196,20 @@ static void cpu_set(PLPA_NAME(cpu_set_t) *out, int pos)
|
||||
|
||||
static void cpu_set_all(PLPA_NAME(cpu_set_t) *out, id_type_t type)
|
||||
{
|
||||
int i, max_id, max_id_num, s, c;
|
||||
int i, max_num, max_id, exists, online;
|
||||
PLPA_CPU_ZERO(out);
|
||||
|
||||
/* Only set processor ID's that exist */
|
||||
/* Only set processor ID's that exist and are online */
|
||||
if (ALL == type) {
|
||||
max_id_num = PLPA_BITMASK_CPU_MAX;
|
||||
max_id = PLPA_BITMASK_CPU_MAX;
|
||||
} else if (PROCESSOR == type) {
|
||||
plpa_get_processor_info(&max_id, &max_id_num);
|
||||
PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_ONLINE),
|
||||
&max_num, &max_id);
|
||||
}
|
||||
|
||||
for (i = 0; i <= max_id_num; ++i) {
|
||||
if (ALL == type ||
|
||||
(PROCESSOR == type && 0 == plpa_map_to_socket_core(i, &s, &c))) {
|
||||
for (i = 0; i <= max_id; ++i) {
|
||||
if (0 == PLPA_NAME(get_processor_flags)(i, &exists, &online) &&
|
||||
exists && online) {
|
||||
PLPA_CPU_SET(i, out);
|
||||
}
|
||||
}
|
||||
@ -216,19 +217,20 @@ static void cpu_set_all(PLPA_NAME(cpu_set_t) *out, id_type_t type)
|
||||
|
||||
static void cpu_set_even(PLPA_NAME(cpu_set_t) *out, id_type_t type)
|
||||
{
|
||||
int i, max_id, max_id_num, s, c;
|
||||
int i, max_num, max_id, exists, online;
|
||||
PLPA_CPU_ZERO(out);
|
||||
|
||||
/* Only set processor ID's that exist */
|
||||
/* Only set processor ID's that exist and are online */
|
||||
if (ALL == type) {
|
||||
max_id_num = PLPA_BITMASK_CPU_MAX;
|
||||
max_id = PLPA_BITMASK_CPU_MAX;
|
||||
} else if (PROCESSOR == type) {
|
||||
plpa_get_processor_info(&max_id, &max_id_num);
|
||||
PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_ONLINE),
|
||||
&max_num, &max_id);
|
||||
}
|
||||
|
||||
for (i = 0; i <= max_id_num; i += 2) {
|
||||
if (ALL == type ||
|
||||
(PROCESSOR == type && 0 == plpa_map_to_socket_core(i, &s, &c))) {
|
||||
for (i = 0; i <= max_id; i += 2) {
|
||||
if (0 == PLPA_NAME(get_processor_flags)(i, &exists, &online) &&
|
||||
exists && online) {
|
||||
PLPA_CPU_SET(i, out);
|
||||
}
|
||||
}
|
||||
@ -236,19 +238,20 @@ static void cpu_set_even(PLPA_NAME(cpu_set_t) *out, id_type_t type)
|
||||
|
||||
static void cpu_set_odd(PLPA_NAME(cpu_set_t) *out, id_type_t type)
|
||||
{
|
||||
int i, max_id, max_id_num, s, c;
|
||||
int i, max_num, max_id, exists, online;
|
||||
PLPA_CPU_ZERO(out);
|
||||
|
||||
/* Only set processor ID's that exist */
|
||||
if (ALL == type) {
|
||||
max_id_num = PLPA_BITMASK_CPU_MAX;
|
||||
max_id = PLPA_BITMASK_CPU_MAX;
|
||||
} else if (PROCESSOR == type) {
|
||||
plpa_get_processor_info(&max_id, &max_id_num);
|
||||
PLPA_NAME(get_processor_data)(PLPA_NAME_CAPS(COUNT_ONLINE),
|
||||
&max_num, &max_id);
|
||||
}
|
||||
|
||||
for (i = 1; i <= max_id_num; i += 2) {
|
||||
if (ALL == type ||
|
||||
(PROCESSOR == type && 0 == plpa_map_to_socket_core(i, &s, &c))) {
|
||||
for (i = 1; i <= max_id; i += 2) {
|
||||
if (0 == PLPA_NAME(get_processor_flags)(i, &exists, &online) &&
|
||||
exists && online) {
|
||||
PLPA_CPU_SET(i, out);
|
||||
}
|
||||
}
|
||||
@ -297,7 +300,7 @@ static void sc_merge(PLPA_NAME(cpu_set_t) *out,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (0 != plpa_get_socket_info(&num_sockets, &max_socket_id)) {
|
||||
if (0 != PLPA_NAME(get_socket_info)(&num_sockets, &max_socket_id)) {
|
||||
fprintf(stderr, "ERROR: Unable to retrieve socket information\n");
|
||||
exit(1);
|
||||
}
|
||||
@ -315,8 +318,8 @@ static void sc_merge(PLPA_NAME(cpu_set_t) *out,
|
||||
socket, max_socket_id);
|
||||
exit(1);
|
||||
} else if (sockets_are_valid &&
|
||||
ENOENT == plpa_get_core_info(socket, &num_cores,
|
||||
&max_core_id) &&
|
||||
ENOENT == PLPA_NAME(get_core_info)(socket, &num_cores,
|
||||
&max_core_id) &&
|
||||
PLPA_CPU_ISSET(socket, sockets)) {
|
||||
fprintf(stderr, "ERROR: Invalid socket ID specified (%d does not exist)\n",
|
||||
socket);
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user