1
1

Update to PLPA v1.2b3. Sorry again for the mid-day configure change...

This commit was SVN r19292.
Этот коммит содержится в:
Jeff Squyres 2008-08-14 14:26:26 +00:00
родитель 5946d84023
Коммит a6e0589f01
5 изменённых файлов: 72 добавлений и 39 удалений

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

@ -429,13 +429,7 @@ PLPA_INIT *must* be invoked if using the m4 macros):
--enable-included-mode command line switch.
- PLPA_INCLUDED
or
PLPA_INCLUDED(config-prefix)
NOTE: 1-argument form is deprecated and will be removed in PLPA
v1.2
Force the building of PLPA in included mode. See PLPA_INIT for a
description of config-prefix (note that passing config-prefix
through PLPA_INIT is the preferred way to set it).
Force the building of PLPA in included mode.
- PLPA_SET_SYMBOL_PREFIX(foo)
Tells the PLPA to prefix all types and public symbols with "foo"
@ -467,19 +461,15 @@ PLPA_INIT *must* be invoked if using the m4 macros):
executables.
- PLPA_INIT(config-prefix, action-upon-success, action-upon-failure)
or
PLPA_INIT(action-upon-success, action-upon-failure)
NOTE: 2-argument form is deprecated and will be removed in PLPA
v1.2
Invoke the PLPA tests and setup the PLPA to build. A traversal of
"make" into the PLPA directory should build everything (it is safe
to list the PLPA directory in the SUBDIRS of a higher-level
Makefile.am, for example). PLPA_INIT must be invoked after the
INCLUDED / STANDALONE / SET_SYMBOL_PREFIX macros. The first
argument is the 3-argument form is the prefix to use for AC_OUTPUT
files. Hence, if your embedded PLPA is located in the source tree
at contrib/plpa, you'd pass [contrib/plpa] as the first argument.
The 2-argument form assumes the prefix ".".
Makefile.am, for example). ***PLPA_INIT must be invoked after the
STANDALONE, INCLUDED, SET_SYMBOL_PREFIX, DISABLE_EXECUTABLES, and
ENABLE_EXECUTABLES macros.*** The first argument is the prefix to
use for AC_OUTPUT files. Hence, if your embedded PLPA is located in
the source tree at contrib/plpa, you should pass [contrib/plpa] as
the first argument.
- PLPA_DO_AM_CONDITIONALS
If you embed PLPA in a larger project and build it conditionally
@ -494,17 +484,17 @@ PLPA_INIT *must* be invoked if using the m4 macros):
Here's an example of integrating with a larger project named sandbox:
shell$ cd sandbox
shell$ cp -r /somewhere/else/plpa-<version> .
shell$ cp -r /somewhere/else/plpa-<version> plpa
shell$ edit acinclude.m4
...add the line "m4_include(plpa-<version>/config/plpa.m4)"...
...add the line "m4_include(plpa/config/plpa.m4)"...
shell$ edit Makefile.am
...add "plpa-<version>" to SUBDIRS...
...add "$(top_builddir)/plpa-<version>/src/libplpa/libplpa_included.la" to
...add "plpa" to SUBDIRS...
...add "$(top_builddir)/plpa/src/libplpa/libplpa_included.la" to
my executable's LDADD line...
shell$ edit configure.ac
...add "PLPA_INCLUDED" line...
...add "PLPA_SET_SYMBOL_PREFIX(sandbox_plpa_)" line...
...add "PLPA_INIT(plpa_happy=yes, plpa_happy=no)" line...
...add "PLPA_INIT([./plpa], [plpa_happy=yes], [plpa_happy=no])" line...
...add error checking for plpa_happy=no case...
shell$ edit src/my_program.c
...add #include <plpa.h>...

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

@ -16,7 +16,7 @@ release=0
# requirement is that it must be entirely printable ASCII characters
# and have no white space.
greek=b2
greek=b3
# 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=r192
svn_r=r197

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

@ -199,17 +199,31 @@ 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 number of processors (cores) in a system and the
/* 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. */
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() */
typedef enum {
/* Only count online processors */
PLPA_NAME_CAPS(COUNT_ONLINE),
/* Only count offline processors */
PLPA_NAME_CAPS(COUNT_OFFLINE),
/* Count all processors (online and offline) */
PLPA_NAME_CAPS(COUNT_ALL)
} PLPA_NAME(count_specification_t);
/* 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." Returns 0
upon success. */
int PLPA_NAME(get_processor_id)(int processor_num, int *processor_id);
"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);
/* Check to see if a given Linux processor ID exists / is online.
Returns 0 on success. */
@ -222,7 +236,10 @@ int PLPA_NAME(get_socket_info)(int *num_sockets, int *max_socket_id);
/* Returns the Linux socket ID for the Nth socket. For example, if
the socket IDs have "holes", use this function to say "give me the
Linux socket ID of the 2nd socket." Returns 0 upon success. */
Linux socket ID of the 2nd socket." Linux does not specify the
socket/core tuple information for offline processors, so a
plpa_count_specification_t parameter is not used here. Returns 0
upon success. */
int PLPA_NAME(get_socket_id)(int socket_num, int *socket_id);
/* Return both the number of cores and the max code ID for a given
@ -233,7 +250,9 @@ int PLPA_NAME(get_core_info)(int socket_id, int *num_cores, int *max_core_id);
/* Given a specific socket, returns the Linux core ID for the Nth
core. For example, if the core IDs have "holes", use this function
to say "give me the Linux core ID of the 4th core on socket ID 7."
Returns 0 upon success. */
Linux does not specify the socket/core tuple information for
offline processors, so a plpa_count_specification_t parameter is
not used here. Returns 0 upon success. Returns 0 upon success. */
int PLPA_NAME(get_core_id)(int socket_id, int core_num, int *core_id);
/* Check to see if a given Linux (socket_id,core_id) tuple exists / is
@ -241,7 +260,8 @@ int PLPA_NAME(get_core_id)(int socket_id, int core_num, int *core_id);
int PLPA_NAME(get_core_flags)(int socket_id, int core_id,
int *exists, int *online);
/* Set PLPA's cache behavior. Returns 0 upon success. */
/* Typedefs for specifying the cache behavior via
plpa_set_cache_behavior() */
typedef enum {
/* Use the cache (default behavior); fills the cache right now if
it's not already full */
@ -252,6 +272,8 @@ typedef enum {
/* Refresh the cache right now */
PLPA_NAME_CAPS(CACHE_REFRESH)
} PLPA_NAME(cache_behavior_t);
/* Set PLPA's cache behavior. Returns 0 upon success. */
int PLPA_NAME(set_cache_behavior)(PLPA_NAME(cache_behavior_t));
/* Shut down PLPA. This function releases resources used by the PLPA.

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

@ -126,6 +126,7 @@
#include <limits.h>
#include <errno.h>
#include <stdlib.h>
#include <stdbool.h>
typedef struct tuple_t_ {
int processor_id, socket_id, core_id, online;
@ -633,9 +634,11 @@ int PLPA_NAME(get_processor_info)(int *num_processors_arg,
/* Returns the Linux processor ID for the Nth processor (starting with
0). */
int PLPA_NAME(get_processor_id)(int processor_num, int *processor_id)
int PLPA_NAME(get_processor_id)(int processor_num, int *processor_id,
PLPA_NAME(count_specification_t) count_spec)
{
int ret, i, count;
bool match;
/* Initialize if not already done so */
if (!PLPA_NAME(initialized)) {
@ -667,9 +670,29 @@ int PLPA_NAME(get_processor_id)(int processor_num, int *processor_id)
/* Find the processor_num'th processor */
for (count = i = 0; i <= max_processor_id; ++i) {
if (map_processor_id_to_tuple[i].processor_id >= 0) {
if (count++ == processor_num) {
*processor_id = map_processor_id_to_tuple[i].processor_id;
return 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;
case PLPA_NAME_CAPS(COUNT_ALL):
match = true;
break;
}
if (match) {
if (count++ == processor_num) {
*processor_id = map_processor_id_to_tuple[i].processor_id;
return 0;
}
}
}
}
@ -781,7 +804,6 @@ int PLPA_NAME(get_socket_id)(int socket_num, int *socket_id)
/* Check for bozo arguments */
if (NULL == socket_id) {
printf("get_socket_id bad 1\n");
return EINVAL;
}
@ -792,7 +814,6 @@ int PLPA_NAME(get_socket_id)(int socket_num, int *socket_id)
/* Check for out of range params */
if (socket_num < 0 || socket_num > num_sockets) {
printf("get_socket_id bad 2\n");
return EINVAL;
}
@ -814,7 +835,6 @@ int PLPA_NAME(get_socket_id)(int socket_num, int *socket_id)
}
/* Didn't find it */
printf("get_socket id bad 3\n");
return ENODEV;
}

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

@ -119,7 +119,8 @@ int main(int argc, char *argv[])
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)) {
if (0 != PLPA_NAME(get_processor_id)(i, &processor_id,
PLPA_NAME_CAPS(COUNT_ALL))) {
fprintf(stderr, "pla_get_processor_id failed\n");
break;
}