1
1

Back out r17702; it went very badly.

This commit was SVN r17704.

The following SVN revision numbers were found above:
  r17702 --> open-mpi/ompi@3df754ebd7
Этот коммит содержится в:
Jeff Squyres 2008-03-05 00:42:39 +00:00
родитель 1bedaea79b
Коммит 8189fcc7d5
51 изменённых файлов: 2853 добавлений и 39205 удалений

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

@ -1047,7 +1047,7 @@ if test "$ompi_cv_asm_arch" != "WINDOWS" ; then
AC_MSG_CHECKING([whether possible to generate assembly file])
mkdir -p opal/asm/generated
ompi_cv_asm_file="atomic-local.s"
ompi_try='$PERL $top_ompi_srcdir/opal/asm/generate-asm.pl $ompi_cv_asm_arch $ompi_cv_asm_format $top_ompi_srcdir/opal/asm/base $top_ompi_builddir/opal/asm/generated/$ompi_cv_asm_file >conftest.out 2>&1'
ompi_try='$PERL $top_ompi_srcdir/opal/asm/generate-asm.pl $ompi_cv_asm_arch "$ompi_cv_asm_format" $top_ompi_srcdir/opal/asm/base $top_ompi_builddir/opal/asm/generated/$ompi_cv_asm_file >conftest.out 2>&1'
if AC_TRY_EVAL(ompi_try) ; then
# save the warnings
cat conftest.out >&AC_FD_CC

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

@ -1210,10 +1210,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);
}

21
opal/mca/paffinity/linux/plpa/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,21 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
SUBDIRS = src
DIST_SUBDIRS = config $(SUBDIRS)
EXTRA_DIST = README VERSION LICENSE AUTHORS
if PLPA_BUILD_STANDALONE
dist-hook:
csh "$(top_srcdir)/config/distscript.csh" "$(top_srcdir)" "$(distdir)" "$(PLPA_VERSION)" "$(PLPA_SVN_R)"
endif

95
opal/mca/paffinity/linux/plpa/NEWS Обычный файл
Просмотреть файл

@ -0,0 +1,95 @@
Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
University Research and Technology
Corporation. All rights reserved.
Copyright (c) 2004-2005 The Regents of the University of California.
All rights reserved.
Copyright (c) 2006-2007 Cisco Systems, Inc. All rights reserved.
$COPYRIGHT$
Additional copyrights may follow
$HEADER$
===========================================================================
This file contains the main features as well as overviews of specific
bug fixes (and other actions) for each version of PLPA since
version 1.0.
1.1
---
- New command: plpa-taskset. It is intended as a drop-in replacement
for the "taskset" command, except it also understands sockets and
cores. See the man page for more details.
- Renamed "plpa_info" to "plpa-info".
- Added PLPA_{MAJOR|MINOR|RELEASE}_VERSION integer macros in plpa.h.
This release, they have the values of 1, 1, and 0, respectively.
- Add new API functions to map from (socket,core) back and forth from
the Linux virtual processor ID. Thanks to AMD for the initial code
contribution that made this possible. See the man page for
plpa_map_to_processor_id(3) as a starting point for more
information.
- Added man pages for executables and API functions.
- Various fixes to "included" mode.
1.0.5
-----
- Fix an issue where the PLPA get/set affinity functions would only
operate on the current process; the PID argument to these functions
was effectively ignored.
1.0.4
-----
- Fix some 64 bit issues. Thanks to David Creasy for reporting the
problems.
- Fix plpa.h to be C++-friendly. Thanks to Emmanuel Paris for
pointing out this problem.
1.0.3
-----
- Resolve some sizing / units ambiguities that mistakenly did not make
it into 1.0.1. Thanks to Bert Wesarg for pointing these problems out.
1.0.2
-----
- Ensure that plpa_sched_[set|get]affinity() returns 0 upon success.
Thanks to David Creasy for bringing this to our attention.
1.0.1
-----
- Specify that cpusetsize should be in units of bytes and add some
missing "* 8"'s in plpa_dispatch.c.
1.0
---
- Initial release.
0.9a2
-----
- Change the back-end type of the plpa_bitmask_t to unsigned long
instead of unsigned char to avoid an endian problem.
- No longer attempt to set the affinity in plpa_api_probe() to avoid a
possible race condition (setting it after getting it).
- Fix PLPA_CPU_ZERO macro. Thanks to Bogdan Costescu for pointing
this out.
0.9a1
-----
Initial public release.

484
opal/mca/paffinity/linux/plpa/README Обычный файл
Просмотреть файл

@ -0,0 +1,484 @@
Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
University Research and Technology
Corporation. All rights reserved.
Copyright (c) 2004-2005 The Regents of the University of California.
All rights reserved.
Copyright (c) 2006-2007 Cisco Systems, Inc. All rights reserved.
$COPYRIGHT$
See LICENSE file for a rollup of all copyright notices.
$HEADER$
===========================================================================
This is the Portable Linux Processor Affinity (PLPA) package
(pronounced "pli-pa"). It is intended for developers who wish to use
Linux processor affinity via the sched_setaffinity() and
sched_getaffinity() library calls, but don't want to wade through the
morass of 3 different APIs that have been offered through the life of
these calls in various Linux distributions and glibc versions.
Specifically, to compile for any given Linux system, you need some
complex compile-time tests to figure out which of the 3 APIs to use.
And if you want your application to be binary portable across
different Linux distributions, more complex run-time tests (and horrid
compile-time trickery) are required to figure out which API the system
you are running on uses.
These problems all stem from the fact that the same 2 symbols have had
three different APIs (with different numbers and types of
parameters) throughout their life in Linux. Ick.
The PLPA is an attempt to solve this problem by providing a single API
that developers can write to. It provides three things:
1. A single API that developers can write to, regardless of what
back-end API the system you are compiling on has.
2. A run-time test and dispatch that will invoke the Right back-end
API depending on what back-end API the system you are running on
has.
3. Mapping information between (socket, core) tuples and Linux virtual
processor IDs.
This package is actually pretty small. It does not attempt to have
many extra bells and whistles. Anyone could write it and package it.
We did it simply because it appears that no one else has yet done
this. In a world where larger scale SMPs are [again] becoming more
common, particularly where at least some of them are NUMA-based
architectures, processor affinity is going to become more and more
important. Just because developers have not yet realized that they
have this problem does not mean that they won't evenutally figure it
out. :-)
Note that if you're looking into processor affinity, if you're on a
NUMA machine, you probably also want to look into libnuma:
ftp://ftp.suse.com/pub/people/ak/numa/
We hope that PLPA helps you.
===========================================================================
What, exactly, is the problem?
------------------------------
There are at least 3 different ways that sched_setaffinity is
implemented in glibc (only one of which is documented in the
sched_setaffinity(2) man page), and some corresponding changes
to what the kernel considers to be valid arguments:
1. int sched_setaffinity(pid_t pid, unsigned int len, unsigned
long *mask);
This originated in the time period of 2.5 kernels and some distros
back-ported it to their 2.4 kernels and libraries. It's unknown if
this version was ever packaged with any 2.6 kernels.
2. int sched_setaffinity (pid_t __pid, size_t __cpusetsize,
const cpu_set_t *__cpuset);
This appears to be in recent distros using 2.6 kernels. We don't
know exactly when #1 changed into #2. However, this prototype is nice
because the cpu_set_t type is accompanied by fdset-like CPU_ZERO(),
CPU_SET(), CPU_ISSET(), etc. macros.
3. int sched_setaffinity (pid_t __pid, const cpu_set_t *__mask);
(note the missing len parameter) This is in at least some Linux
distros (e.g., MDK 10.0 with a 2.6.3 kernel, and SGI Altix, even
though the Altix uses a 2.4-based kernel and therefore likely
back-ported the 2.5 work or originated it in the first place).
Similar to #2, the cpu_set_t type is accompanied by fdset-like
CPU_ZERO(), CPU_SET(), CPU_ISSET(), etc. macros.
But wait, it gets worse.
Remember that getting/setting processor affinity has to involve the
kernel. The sched_[sg]etaffinity() glibc functions typically do a
little error checking and then make a syscall down into the kernel to
actually do the work. There are multiple possibilities for problems
here as the amount of checking has changed:
1. The glibc may support the affinity functions, but the kernel may
not (and vice versa).
This is typically only an issue with slightly older Linux distributions.
Mandrake 9.2 is an example of this. PLPA can detect this at run-time
and turn its internal functions into no-ops and return appropriate error
codes (ENOSYS).
2. The glibc affinity functions may be buggy (i.e., they pass bad data
down to the syscall).
This is fortunately restricted to some older versions of glibc, and
is relatively easy to check for at run-time. PLPA reliably detects
this situation at run-time and returns appropriate error codes
(ENOSYS).
The original SuSE 9.1 version seems to have this problem, but it was
fixed it somewhere in the SuSE patching history (it is unknown exactly
when). Specifically, updating to the latest SuSE 9.1 patch level
(as of Dec 2005) seems to fix the problem.
3. The CPU_* macros for manipulating cpu_set_t bitmasks may not
compile because of typo bugs in system header files.
PLPA avoids this problem by providing its own PLPA_CPU_* macros for
manipulating CPU bitmasks. See "How do I use PLPA?", below, for
more details.
The PLPA avoids all the glibc issues by using syscall() to directly
access the kernel set and get affinity functions. This is described
below.
===========================================================================
How does PLPA work?
-------------------
Jeff Squyres initially sent a mail to the Open MPI developer's mailing
list explaining the Linux processor affinity problems and asking for
help coming up with a solution (particularly for binary
compatibility):
http://www.open-mpi.org/community/lists/devel/2005/11/0558.php
Discussion on that thread and others eventually resulted in the
run-time tests that form the heart of the PLPA. Many thanks to Paul
Hargrove and Bogdan Costescu for their time and effort to get these
tests right.
PLPA was written so that other developers who want to use processor
affinity in Linux don't have to go through this mess. The PLPA
provides a single interface that can be used on any platform,
regardless of which back-end API variant it has. This includes both
the sched_setaffinity() and sched_getaffinity() calls as well as the
CPU_*() macros.
The PLPA avoids glibc altogether -- although tests were developed that
could *usually* figure out which glibc variant to use at run time,
there were still some cases where it was either impossible to
determine or the glibc interface itself was buggy. Hence, it was
decided that a simpler approach was simply to use syscall() to invoke
the back-end kernel functions directly.
The kernel functions have gone through a few changes as well, so the
PLPA does a few run-time tests to determine which variant to use
before actually invoking the back-end functions with the
user-specified arguments.
NOTE: The run-time tests that the PLPA performs involve getting the
current affinity for the process in question and then attempting to
set them back to the same value. By definition, this introduces a
race condition (there is no atomic get-and-set functionality for
processor affinity). The PLPA cannot guarantee consistent results if
multiple entities (such as multiple threads or multiple processes) are
setting the affinity for a process at the same time. In a worst case
scenario, the PLPA may actually determine that it cannot determine the
kernel variant at run time if another entity modifies a process'
affinity while PLPA is executing its run-time tests.
===========================================================================
Does PLPA make truly portable binaries?
---------------------------------------
As much as Linux binaries are portable, yes. That is, if you have
within your power to make a binary that is runnable on several
different Linux distributions/versions/etc., then you may run into
problems with the Linux processor affinity functions. PLPA attempts
to solve this problem for you by *also* making the Linux processor
affinity calls be binary portable.
Hence, you need to start with something that is already binary
portable (perhaps linking everything statically) -- then PLPA will be
of help to you. Do not fall into the misconception that PLPA will
magically make your executable be binary portable between different
Linux variants.
===========================================================================
How do I use PLPA?
------------------
There are two main uses of the PLPA:
1. Using the plpa_info executable to check if your system supports
processor affinity and the PLPA can determine which to use at run-time.
2. Developers using the PLPA library to enable source and binary Linux
processor affinity portability.
In more detail:
1. The plpa_info executable is a simple call into the PLPA library
that checks which API variant the system it is running on has. If
the kernel supports processor affinity and the PLPA is able to
figure out which API variant to use, it prints "PLPA_PROBE_OK".
Other responses indicate an error.
Since the PLPA library abstracts this kind of problem away, this is
more a diagnostic tool than anything else. Note that plpa_info is
*only* compiled and installed if PLPA is installed as a standalone
package (see below).
2. Developers can use this package by including the <plpa.h> header
file and using the following prototypes:
int plpa_sched_setaffinity(pid_t pid, size_t cpusetsize,
const plpa_cpu_set_t *cpuset);
int plpa_sched_getaffinity(pid_t pid, size_t cpusetsize,
const plpa_cpu_set_t *cpuset)
These functions perform run-time tests to determine which back-end
API variant exists on the system and then dispatch to it correctly.
The units of cpusetsize is number of bytes. This should normally
just be sizeof(*cpuset), but is made available as a parameter to
allow for future expansion of the PLPA (stay tuned).
The observant reader will notice that this is remarkably similar to
the one of the Linux API's (the function names are different and
the CPU set type is different). PLPA also provides several macros
for manipulating the plpa_cpu_set_t bitmask, quite similar to FDSET
macros (see "What, Exactly, Is the Problem?" above for a
description of problems with the native CPU_* macros):
- PLPA_CPU_ZERO(&cpuset): Sets all bits in a plpa_cpu_set_t to
zero.
- PLPA_CPU_SET(num, &cpuset): Sets bit <num> of <cpuset> to one.
- PLPA_CPU_CLR(num, &cpuset): Sets bit <num> of <cpuset> to zero.
- PLPA_CPU_ISSET(num, &cpuset): Returns one if bit <num> of
<cpuset> is one; returns zero otherwise.
Note that all four macros take a *pointer* to a plpa_cpu_set_t, as
denoted by "&cpuset" in the descriptions above.
The following API functions are also available on kernels that
support topology information (e.g., 2.6.16 or later):
- plpa_map_to_processor_id()
- plpa_map_to_socket_core()
- plpa_max_processor_id()
- plpa_max_socket()
- plpa_max_core()
On unsupported kernels, a negative value is returned to indicate
graceful failure. Additionally, the function
plpa_have_topology_information() can be called to determine whether
a kernel supports the topology information or not. It returns 1 if
the information is available (and therefore the above plpa_*()
functions return meaningful values) or 0 if the information is
unavailable (and therefore the above plpa_*() functions return a
negative value indicating failure).
Note that invoking any of the topology functions (including
plpa_have_topology_information()) will allocate memory from the
heap. To release this memory, call plpa_finalize().
Note that the special case of invoking any of the topology
functions on an unsupported kernel will not allocate any memory;
invoking plpa_finalize() is therefore unnecessary, but harmless.
===========================================================================
How do I compile / install the PLPA as a standalone package?
------------------------------------------------------------
The PLPA uses the standard GNU Autoconf/Automake/Libtool toolset to
build and install itself. This means that generally, the following
works:
shell$ ./configure --prefix=/where/you/want/to/install
[...lots of output...]
shell$ make all
[...lots of output...]
shell$ make install
Depending on your --prefix, you may need to run the "make install"
step as root or some other privileged user.
"make install" will install the following:
- <plpa.h> in $includedir (typically $prefix/include)
- libplpa.la and libplpa.a and/or libplpa.so in $libdir (typically
$prefix/lib)
- plpa_info executable in $bindir (typically $prefix/bin)
Note that since PLPA builds itself with GNU Libtool, it can be built
as a static or shared library (or both). The default is to build a
shared library. You can enable building a static library by supplying
the "--enable-static" argument to configure; you can disable building
the shared library by supplying the "--disable-shared" argument to
configure. "make install" will install whichever library was built
(or both).
"make uninstall" will fully uninstall PLPA from the prefix directory
(again, depending in filesystem permissions, you may need to run this
as root or some privileged user).
===========================================================================
How do I include PLPA in my software package?
---------------------------------------------
It can be desirable to include PLPA in a larger software package
(be sure to check out the LICENSE file) so that users don't have to
separately download and install it before installing your software
(after all, PLPA is a tiny little project -- why make users bother
with it?).
When used in "included" mode, PLPA will:
- not install any header files
- not build or install plpa_info
- not build libplpa.* -- instead, it will build libplpa_included.*
There are two ways to put PLPA into "included" mode. From the
configure command line:
shell$ ./configure --enable-included-mode ...
Or by directly integrating PLPA's m4 configure macro in your configure
script and invoking a specific macro to enable the included mode.
Every project is different, and there are many different ways of
integrating PLPA into yours. What follows is *one* example of how to
do it.
Copy the PLPA directory in your source tree and include the plpa.m4
file in your configure script -- perhaps with the following line in
acinclude.m4 (assuming the use of Automake):
m4_include(path/to/plpa.m4)
The following macros can then be used from your configure script:
- PLPA_INIT(action-upon-success, action-upon-failure)
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_STANDALONE
Force the building of PLPA in standalone mode. Overrides the
--enable-included-mode command line switch.
- PLPA_INCLUDED
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"
instead of "plpa_". This is recommended behavior if you are
including PLPA in a larger project -- it is possible that your
software will be combined with other software that also includes
PLPA. If you both use different symbol prefixes, there will be no
type/symbol clashes, and everything will compile and link
successfully. If you both include PLPA and do not change the symbol
prefix, it is likely that you will get multiple symbol definitions
when linking.
Here's an example of integrating with a larger project named sandbox:
shell$ cd sandbox
shell$ cp -r /somewhere/else/plpa-<version> .
shell$ edit acinclude.m4
...add the line "m4_include(plpa-<version>/config/plpa.m4)"...
shell$ edit Makefile.am
...add "plpa-<version>" to SUBDIRS...
...add "$(top_builddir)/plpa-<version>/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 error checking for plpa_happy=no case...
shell$ edit src/my_program.c
...add #include <plpa.h>...
...add calls to plpa_sched_setaffinity()...
shell$ aclocal
shell$ autoconf
shell$ libtoolize --automake
shell$ automake -a
shell$ ./configure
...lots of output...
shell$ make
...lots of output...
===========================================================================
How can I tell if PLPA is working?
----------------------------------
Run plpa_info; if it says "PLPA_PROBE_OK", then PLPA is working
properly.
If you want to compile your own test program to verify it, try
compiling and running the following:
---------------------------------------------------------------------------
#include <stdio.h>
#include <plpa.h>
int main(int argc, char* argv[]) {
if (PLPA_PROBE_OK == plpa_api_probe()) {
printf("All is good!\n");
}
return 0;
}
---------------------------------------------------------------------------
You may need to supply appropriate -I and -L arguments to the
compiler/linker, respectively, to tell it where to find the PLPA
header and library files. Also don't forget to supply -lplpa to link
in the PLPA library itself. For example, if you configured PLPA with:
shell$ ./configure --prefix=$HOME/my-plpa-install
Then you would compile the above program with:
shell$ gcc my-plpa-test.c \
-I$HOME/my-plpa-install/include \
-L$HOME/my-plpa-install/lib -lplpa \
-o my-plpa-test
shell$ ./my-plpa-test
If it compiles, links, runs, and prints "All is good!", then all
should be well.
===========================================================================
What license does PLPA use?
---------------------------
This package is distributed under the BSD license (see the LICENSE
file in the top-level directory of a PLPA distribution). The
copyrights of several institutions appear throughout the code base
because some of the code was directly derived from the Open MPI
project (http://www.open-mpi.org/), which is also distributed under
the BSD license.
===========================================================================
How do I get involved in PLPA?
------------------------------
Hopefully, PLPA is so simple that it won't need to be modified much
after its first few releases. However, it is possible that we'll need
to modify the run-time test if new variants of the Linux processor
affinity API emerge.
The best way to report bugs, send comments, or ask questions is to
sign up on the user's mailing list:
plpa-users@open-mpi.org
Because of spam, only subscribers are allowed to post to this list
(ensure that you subscribe with and post from exactly the same e-mail
address -- joe@example.com is considered different than
joe@mycomputer.example.com!). Visit this page to subscribe to the
list:
http://www.open-mpi.org/mailman/listinfo.cgi/plpa-users
Thanks for your time.

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

@ -0,0 +1,63 @@
(from helpful AMD engineers...)
Jeff,
Bill asked me to expand on what I previously wrote by documenting the
/sys interface. Without further ado:
All the information you need for determining the topology of a given
core is located in the /sys/devices/system/cpu/cpuX/topology/
directory, where X is a core number from 0 to N - 1, given N total
cores present on the system. On an AMD64 system, this directory will
contain the following entries, readable in ASCII form:
physical_package_id - which socket am I in?
core_id - in my socket, which core am
I? (0 or 1
for dual-core CPUs)
core_siblings - who are my sibling cores in this
socket? (see below)
thread_siblings - who are my sibling threads
in this
socket? (not really useful for AMD64)
The sibling fields are given as bit masks of core IDs, represented as
hexdecimal numbers delimited by commas into groups of eight for easier
readability. So for example, given a kernel that supports a maximum
of 128 cores:
cparrott@compute-2:~> cat
/sys/devices/system/cpu/cpu0/topology/core_siblings
00000000,00000000,00000000,00000003
would tell us that cores 0 and 1 are the sibling cores of core 0.
Each core is included in its own sibling core mask, so you would still
get a meaningful result if you happened to be running on a single-core
system.
Given that these are NUMA systems, you may assume that each socket may
or may not have a region of memory associated with it. Most systems
do, but I have seen a few that had sockets without associated memory.
My dual-Opteron Linux workstation system at my desk is a prime example
of this -- all of its memory appears to the kernel as being directly
connected to socket 0.
Unfortunately, I am not aware of an easy mechanism for determining the
memory associated with a given socket, although this information does
show up in the kernel messages buffer during boot. (i.e. run dmesg)
Perhaps Ray might know.
------
Followup to this:
The /sys/devices/system/node/ directory tree contains the memory node
topology. Of particular interest here is numastat entry: this will
give stats on which of this node's pages are physically located here
versus foreign nodes, for example.
Unfortunately, memory mappings for specific address ranges to nodes
are not available. I suspect that this is probably due to the fact
that Linux uses virtual addressing everywhere in userland, so any
physical address ranges corresponding to a particular memory node are
meaningless in userland.

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

@ -16,12 +16,12 @@ release=0
# requirement is that it must be entirely printable ASCII characters
# and have no white space.
greek=
greek=a1
# If want_svn=1, then the SVN r number will be included in the overall
# PLPA version number in some form.
want_svn=0
want_svn=1
# If svn_r=-1, then the SVN r numbere will be obtained dynamically at
# run time, either 1) via the "svnversion" command (if this is a
@ -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=r147:149
svn_r=-1

8764
opal/mca/paffinity/linux/plpa/aclocal.m4 поставляемый

Разница между файлами не показана из-за своего большого размера Загрузить разницу

386
opal/mca/paffinity/linux/plpa/autogen.sh Исполняемый файл
Просмотреть файл

@ -0,0 +1,386 @@
#! /bin/bash
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2007 Cisco, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# This script is run on developer copies of PLPA -- *not* distribution
# tarballs.
#set -x
##############################################################################
#
# User-definable parameters (search path and minimum supported versions)
#
# Note: use ';' to separate parameters
##############################################################################
ompi_aclocal_search="aclocal"
if test ! -z "$ACLOCAL"; then
ompi_aclocal_search="$ACLOCAL"
fi
ompi_autoheader_search="autoheader"
if test ! -z "$AUTOHEADER"; then
ompi_autoheader_search="$AUTOHEADER"
fi
ompi_autoconf_search="autoconf"
if test ! -z "$AUTOCONF"; then
ompi_autoconf_search="$AUTOCONF"
fi
ompi_libtoolize_search="libtoolize;glibtoolize"
if test ! -z "$LIBTOOLIZE"; then
ompi_libtoolize_search="$LIBTOOLIZE"
fi
ompi_automake_search="automake"
if test ! -z "$AUTOMAKE"; then
ompi_automake_search="$AUTOMAKE"
fi
ompi_automake_version="1.9.6"
ompi_autoconf_version="2.59"
ompi_libtool_version="1.5.22"
##############################################################################
#
# Global variables - should not need to modify defaults
#
##############################################################################
ompi_aclocal_version="$ompi_automake_version"
ompi_autoheader_version="$ompi_autoconf_version"
ompi_libtoolize_version="$ompi_libtool_version"
# program names to execute
ompi_aclocal=""
ompi_autoheader=""
ompi_autoconf=""
ompi_libtoolize=""
ompi_automake=""
mca_no_configure_components_file="config/mca_no_configure_components.m4"
mca_no_config_list_file="mca_no_config_list"
mca_no_config_env_file="mca_no_config_env"
mca_m4_include_file="mca_m4_config_include.m4"
mca_m4_config_env_file="mca_m4_config_env"
autogen_subdir_file="autogen.subdirs"
############################################################################
#
# Version check - does major,minor,release check (hopefully ignoring
# beta et al)
#
# INPUT:
# - minimum version allowable
# - version we found
#
# OUTPUT:
# - 0 version is ok
# - 1 version is not ok
#
# SIDE EFFECTS:
# none
#
##############################################################################
check_version() {
local min_version="$1"
local version="$2"
local min_major_version="`echo $min_version | cut -f1 -d.`"
local min_minor_version="`echo $min_version | cut -f2 -d.`"
local min_release_version="`echo $min_version | cut -f3 -d.`"
if test "$min_release_version" = "" ; then
min_release_version=0
fi
local major_version="`echo $version | cut -f1 -d.`"
local minor_version="`echo $version | cut -f2 -d.`"
local release_version="`echo $version | cut -f3 -d.`"
if test "$release_version" = "" ; then
release_version=0
fi
if test $min_major_version -lt $major_version ; then
return 0
elif test $min_major_version -gt $major_version ; then
return 1
fi
if test $min_minor_version -lt $minor_version ; then
return 0
elif test $min_minor_version -gt $minor_version ; then
return 1
fi
if test $min_release_version -gt $release_version ; then
return 1
fi
return 0
}
##############################################################################
#
# find app - find a version of the given application that is new
# enough for use
#
# INPUT:
# - name of application (eg aclocal)
#
# OUTPUT:
# none
#
# SIDE EFFECTS:
# - sets application_name variable to working executable name
# - aborts on error finding application
#
##############################################################################
find_app() {
local app_name="$1"
local version="0.0.0"
local min_version="99.99.99"
local found=0
local tmpIFS=$IFS
eval "min_version=\"\$ompi_${app_name}_version\""
eval "search_path=\"\$ompi_${app_name}_search\""
IFS=";"
for i in $search_path ; do
IFS="$tmpIFS"
version="`${i} --version 2>&1`"
if test "$?" != 0 ; then
IFS=";"
continue
fi
version="`echo $version | cut -f2 -d')'`"
version="`echo $version | cut -f1 -d' '`"
if check_version $min_version $version ; then
eval "ompi_${app_name}=\"${i}\""
found=1
break
fi
done
IFS="$tmpIFS"
if test "$found" = "0" ; then
cat <<EOF
I could not find a recent enough copy of ${app_name}.
I am gonna abort. :-(
Please make sure you are using at least the following versions of the
GNU tools:
GNU Autoconf $ompi_autoconf_version
GNU Automake $ompi_automake_version
NOTE: You may need Automake 1.8.5 (or higher) in order to run
"make dist" successfully
GNU Libtool $ompi_libtool_version
EOF
exit 1
fi
}
##############################################################################
#
# run_and_check - run the right GNU tool, printing warning on failure
#
# INPUT:
# - name of application (eg aclocal)
# - program arguments
#
# OUTPUT:
# none
#
# SIDE EFFECTS:
# - aborts on error running application
#
##############################################################################
run_and_check() {
local rac_progs="$*"
echo "[Running] $rac_progs"
eval $rac_progs
if test "$?" != 0; then
cat <<EOF
-------------------------------------------------------------------------
It seems that the execution of "$rac_progs" has failed. See above for
the specific error message that caused it to abort.
This *MAY* be caused by an older version of one of the required
packages. Please make sure you are using at least the following
versions:
GNU Autoconf $ompi_autoconf_version
GNU Automake $ompi_automake_version
GNU Libtool $ompi_libtool_version
-------------------------------------------------------------------------
EOF
exit 1
fi
}
##############################################################################
#
# find_and_delete - look for standard files in a number of common places
# (e.g., ./config.guess, config/config.guess, dist/config.guess), and
# delete it. If it's not found there, look for AC_CONFIG_AUX_DIR in
# the configure.in script and try there. If it's not there, oh well.
#
# INPUT:
# - file to delete
#
# OUTPUT:
# none
#
# SIDE EFFECTS:
# - files may disappear
#
##############################################################################
find_and_delete() {
local fad_file="$1"
local fad_cfile
local auxdir
# Look for the file in "standard" places
if test -f $fad_file; then
rm -f $fad_file
elif test -d config/$fad_file; then
rm -f config/$fad_file
elif test -d dist/$fad_file; then
rm -f dist/$fad_file
else
# Didn't find it -- look for an AC_CONFIG_AUX_DIR line in
# configure.[in|ac]
if test -f configure.in; then
fad_cfile=configure.in
elif test -f configure.ac; then
fad_cfile=configure.ac
else
echo "--> Errr... there's no configure.in or configure.ac file!"
fi
if test -n "$fad_cfile"; then
auxdir="`grep AC_CONFIG_AUX_DIR $fad_cfile | cut -d\( -f 2 | cut -d\) -f 1`"
fi
if test -f "$auxdir/$fad_file"; then
rm -f "$auxdir/$fad_file"
fi
fi
}
##############################################################################
#
# run_gnu_tools - run the GNU tools in a given directory
#
# INPUT:
# none
#
# OUTPUT:
# none
#
# SIDE EFFECTS:
# - assumes that the directory is ready to have the GNU tools run
# in it (i.e., there's some form of configure.*)
# - may preprocess the directory before running the GNU tools
# (e.g., generale Makefile.am's from configure.params, etc.)
#
##############################################################################
run_gnu_tools() {
# Find and delete the GNU helper script files
find_and_delete config.guess
find_and_delete config.sub
find_and_delete depcomp
find_and_delete compile
find_and_delete install-sh
find_and_delete ltconfig
find_and_delete ltmain.sh
find_and_delete missing
find_and_delete mkinstalldirs
find_and_delete libtool
# Run the GNU tools
echo "*** Running GNU tools"
run_and_check $ompi_aclocal
run_and_check $ompi_autoheader
run_and_check $ompi_autoconf
run_and_check $ompi_libtoolize --automake --copy
run_and_check $ompi_automake --foreign -a --copy --include-deps
}
##############################################################################
#
# main - do the real work...
#
##############################################################################
# announce
echo "[Checking] prerequisites"
# sanity check to make sure user isn't being stupid
if test ! -d .svn ; then
cat <<EOF
This doesn't look like a developer copy of PLPA. You probably do not
want to run autogen.sh - it is normally not needed for a release
source tree. Giving you 5 seconds to reconsider and kill me.
EOF
sleep 5
fi
if test -f VERSION -a -f configure.ac -a -f src/libplpa/plpa_bottom.h ; then
# Top level of PLPA tree
uptime > /dev/null
else
cat <<EOF
You must run this script from either the top level of the OMPI
directory tree or the top-level of an MCA component directory tree.
EOF
exit 1
fi
# find all the apps we are going to run
find_app "aclocal"
find_app "autoheader"
find_app "autoconf"
find_app "libtoolize"
find_app "automake"
run_gnu_tools
# All done
exit 0

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

@ -1,142 +0,0 @@
#! /bin/sh
# Wrapper for compilers which do not understand `-c -o'.
scriptversion=2005-05-14.22
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand `-c -o'.
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file `INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
esac
ofile=
cfile=
eat=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as `compile cc -o foo foo.c'.
# So we strip `-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no `-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# `.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
# Create the lock directory.
# Note: use `[/.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

Разница между файлами не показана из-за своего большого размера Загрузить разницу

1658
opal/mca/paffinity/linux/plpa/config/config.sub поставляемый

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,584 +0,0 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2006-10-15.18
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
# Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
# Add `dependent.h:' lines.
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mechanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

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

@ -1,507 +0,0 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2006-10-14.15
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
posix_glob=
posix_mkdir=
# Desired mode of installed file.
mode=0755
chmodcmd=$chmodprog
chowncmd=
chgrpcmd=
stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=
dst=
dir_arg=
dstarg=
no_target_directory=
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
-c (ignored)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
--help display this help and exit.
--version display version info and exit.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) shift
continue;;
-d) dir_arg=true
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
shift
shift
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t) dstarg=$2
shift
shift
continue;;
-T) no_target_directory=true
shift
continue;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
done
if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
trap '(exit $?); exit' 1 2 13 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writeable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix=/ ;;
-*) prefix=./ ;;
*) prefix= ;;
esac
case $posix_glob in
'')
if (set -f) 2>/dev/null; then
posix_glob=true
else
posix_glob=false
fi ;;
esac
oIFS=$IFS
IFS=/
$posix_glob && set -f
set fnord $dstdir
shift
$posix_glob && set +f
IFS=$oIFS
prefixes=
for d
do
test -z "$d" && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dst"; then
$doit $rmcmd -f "$dst" 2>/dev/null \
|| { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \
&& { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\
|| {
echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
} || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,367 +0,0 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2006-05-10.23
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case $1 in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
autom4te touch the output file, or create a stub one
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
esac
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program).
case $1 in
lex|yacc)
# Not GNU programs, they don't have --version.
;;
tar)
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case $1 in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case $f in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if test $# -ne 1; then
eval LASTARG="\${$#}"
case $LASTARG in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if test ! -f y.tab.h; then
echo >y.tab.h
fi
if test ! -f y.tab.c; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if test $# -ne 1; then
eval LASTARG="\${$#}"
case $LASTARG in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if test ! -f lex.yy.c; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '
/^@setfilename/{
s/.* \([^ ]*\) *$/\1/
p
q
}' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
test -f $file || exit 1
touch $file
;;
tar)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case $firstarg in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case $firstarg in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

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

@ -5,7 +5,7 @@
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2006-2008 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2006-2007 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
@ -22,8 +22,6 @@
AC_DEFUN([PLPA_INIT],[
AC_REQUIRE([_PLPA_INTERNAL_SETUP])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AM_PROG_LEX])
AC_REQUIRE([AC_PROG_YACC])
# Check for syscall()
AC_CHECK_FUNC([syscall], [happy=1], [happy=0])
@ -83,15 +81,6 @@ int i = 1;],
[$2])
PLPA_DO_AM_CONDITIONALS
AC_CONFIG_FILES(
plpa_config_prefix[/Makefile]
plpa_config_prefix[/config/Makefile]
plpa_config_prefix[/src/Makefile]
plpa_config_prefix[/src/libplpa/Makefile]
plpa_config_prefix[/src/plpa-info/Makefile]
plpa_config_prefix[/src/plpa-taskset/Makefile]
)
# Cleanup
unset happy
])dnl
@ -112,33 +101,52 @@ AC_DEFUN([PLPA_INCLUDED],[
m4_define([plpa_config_prefix],[$1])
AC_REQUIRE([_PLPA_INTERNAL_SETUP])
plpa_mode=included
PLPA_DISABLE_EXECUTABLES
plpa_executables=no
])dnl
#-----------------------------------------------------------------------
dnl JMS: No fortran bindings yet
dnl # Set whether the fortran bindings will be built or not
dnl AC_DEFUN([PLPA_FORTRAN],[
dnl AC_REQUIRE([_PLPA_INTERNAL_SETUP])
dnl
dnl # Need [] around entire following line to escape m4 properly
dnl [plpa_tmp=`echo $1 | tr '[:upper:]' '[:lower:]'`]
dnl if test "$1" = "0" -o "$1" = "n"; then
dnl plpa_fortran=no
dnl elif test "$1" = "1" -o "$1" = "y"; then
dnl plpa_fortran=yes
dnl else
dnl AC_MSG_WARN([Did not understand PLPA_FORTRAN argument ($1) -- ignored])
dnl fi
dnl ])dnl
# Set whether the fortran bindings will be built or not
AC_DEFUN([PLPA_FORTRAN],[
AC_REQUIRE([_PLPA_INTERNAL_SETUP])
# Need [] around entire following line to escape m4 properly
[plpa_tmp=`echo $1 | tr '[:upper:]' '[:lower:]'`]
if test "$1" = "0" -o "$1" = "n"; then
plpa_fortran=no
elif test "$1" = "1" -o "$1" = "y"; then
plpa_fortran=yes
else
AC_MSG_WARN([Did not understand PLPA_FORTRAN argument ($1) -- ignored])
fi
])dnl
#-----------------------------------------------------------------------
# Disable building the executables
AC_DEFUN([PLPA_DISABLE_EXECUTABLES],[
# Set whether to build and install the executables or not
AC_DEFUN([PLPA_EXECUTABLES],[
AC_REQUIRE([_PLPA_INTERNAL_SETUP])
plpa_executables=no
# Need [] around entire following line to escape m4 properly
[plpa_tmp=`echo $1 | tr '[:upper:]' '[:lower:]'`]
if test "$1" = "0" -o "$1" = "n"; then
plpa_executables=no
elif test "$1" = "1" -o "$1" = "y"; then
plpa_executables=yes
else
AC_MSG_WARN([Did not understand PLPA_EXECUTABLES argument ($1) -- ignored])
fi
#
# need to check for plpa_mode = included and plpa_executables=yes
# and print a big AC_MSG_WARN if both are true
if test "$plpa_mode" = "included" -a "$plpa_executables" = "yes" ; then
AC_MSG_WARN([ Attempting to build executables in included mode ])
AC_MSG_WARN([ This will fail - libplpa_included will be built ])
AC_MSG_WARN([ Executables expect libplpa ])
fi
])dnl
#-----------------------------------------------------------------------
@ -173,16 +181,15 @@ AC_DEFUN([_PLPA_INTERNAL_SETUP],[
plpa_mode=standalone
fi
dnl JMS: No fortran bindings yet
dnl # Fortran bindings, or no?
dnl AC_ARG_ENABLE([fortran],
dnl AC_HELP_STRING([--disable-fortran],
dnl [Using --disable-fortran disables building the Fortran PLPA API bindings]))
dnl if test "$enable_fortran" = "yes" -o "$enable_fortran" = ""; then
dnl plpa_fortran=yes
dnl else
dnl plpa_fortran=no
dnl fi
# Fortran bindings, or no?
AC_ARG_ENABLE([fortran],
AC_HELP_STRING([--disable-fortran],
[Using --disable-fortran disables building the Fortran PLPA API bindings]))
if test "$enable_fortran" = "yes" -o "$enable_fortran" = ""; then
plpa_fortran=yes
else
plpa_fortran=no
fi
# Build and install the executables or no?
AC_ARG_ENABLE([executables],
@ -217,16 +224,21 @@ AC_DEFUN([_PLPA_INIT],[
# We need to set a path for header, etc files depending on whether
# we're standalone or included. this is taken care of by PLPA_INCLUDED.
# Move AC_CONFIG_HEADER and AC_CONFIG_FILES to here, using the
# path prefix from PLPA_INCLUDED
AC_MSG_CHECKING([for PLPA config prefix])
AC_MSG_RESULT(plpa_config_prefix)
# Note that plpa_config.h *MUST* be listed first so that it
# becomes the "main" config header file. Any AM_CONFIG_HEADERs
# after that (plpa.h) will only have selective #defines replaced,
# not the entire file.
AM_CONFIG_HEADER(plpa_config_prefix[/src/libplpa/plpa_config.h])
AM_CONFIG_HEADER(plpa_config_prefix[/src/libplpa/plpa.h])
AC_CONFIG_FILES(
plpa_config_prefix[/Makefile]
plpa_config_prefix[/config/Makefile]
plpa_config_prefix[/src/Makefile]
plpa_config_prefix[/src/libplpa/Makefile]
plpa_config_prefix[/src/plpa-info/Makefile]
plpa_config_prefix[/src/plpa-taskset/Makefile]
)
# What prefix are we using?
AC_MSG_CHECKING([for PLPA symbol prefix])
@ -239,10 +251,9 @@ AC_DEFUN([_PLPA_INIT],[
[The PLPA symbol prefix in all caps])
AC_MSG_RESULT([$plpa_symbol_prefix_value])
dnl JMS: No fortran bindings yet
dnl # Check for fortran
dnl AC_MSG_CHECKING([whether to build PLPA Fortran API])
dnl AC_MSG_RESULT([$plpa_fortran])
# Check for fortran
AC_MSG_CHECKING([whether to build PLPA Fortran API])
AC_MSG_RESULT([$plpa_fortran])
# Check whether to build the exectuables or not
AC_MSG_CHECKING([whether to build PLPA executables])
@ -252,6 +263,9 @@ dnl AC_MSG_RESULT([$plpa_fortran])
if test "$plpa_executables" = "yes"; then
AC_C_INLINE
fi
# Always need these for make dist (both included and standalone)
AM_PROG_LEX
AC_PROG_YACC
# Success
$1
@ -265,8 +279,7 @@ dnl AC_MSG_RESULT([$plpa_fortran])
AC_DEFUN([PLPA_DO_AM_CONDITIONALS],[
if test "$plpa_did_am_conditionals" != "yes"; then
AM_CONDITIONAL([PLPA_BUILD_STANDALONE], [test "$plpa_mode" = "standalone"])
dnl JMS: No fortran bindings yet
dnl AM_CONDITIONAL(PLPA_BUILD_FORTRAN, [test "$plpa_fortran" = "yes"])
AM_CONDITIONAL(PLPA_BUILD_FORTRAN, [test "$plpa_fortran" = "yes"])
AM_CONDITIONAL(PLPA_BUILD_EXECUTABLES, [test "$plpa_executables" = "yes"])
fi
plpa_did_am_conditionals=yes

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

@ -1,223 +0,0 @@
#! /bin/sh
# ylwrap - wrapper for lex/yacc invocations.
scriptversion=2005-05-14.22
# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
case "$1" in
'')
echo "$0: No files given. Try \`$0 --help' for more information." 1>&2
exit 1
;;
--basedir)
basedir=$2
shift 2
;;
-h|--h*)
cat <<\EOF
Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
Wrapper for lex/yacc invocations, renaming files as desired.
INPUT is the input file
OUTPUT is one file PROG generates
DESIRED is the file we actually want instead of OUTPUT
PROGRAM is program to run
ARGS are passed to PROG
Any number of OUTPUT,DESIRED pairs may be used.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v|--v*)
echo "ylwrap $scriptversion"
exit $?
;;
esac
# The input.
input="$1"
shift
case "$input" in
[\\/]* | ?:[\\/]*)
# Absolute path; do nothing.
;;
*)
# Relative path. Make it absolute.
input="`pwd`/$input"
;;
esac
pairlist=
while test "$#" -ne 0; do
if test "$1" = "--"; then
shift
break
fi
pairlist="$pairlist $1"
shift
done
# The program to run.
prog="$1"
shift
# Make any relative path in $prog absolute.
case "$prog" in
[\\/]* | ?:[\\/]*) ;;
*[\\/]*) prog="`pwd`/$prog" ;;
esac
# FIXME: add hostname here for parallel makes that run commands on
# other machines. But that might take us over the 14-char limit.
dirname=ylwrap$$
trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
mkdir $dirname || exit 1
cd $dirname
case $# in
0) $prog "$input" ;;
*) $prog "$@" "$input" ;;
esac
ret=$?
if test $ret -eq 0; then
set X $pairlist
shift
first=yes
# Since DOS filename conventions don't allow two dots,
# the DOS version of Bison writes out y_tab.c instead of y.tab.c
# and y_tab.h instead of y.tab.h. Test to see if this is the case.
y_tab_nodot="no"
if test -f y_tab.c || test -f y_tab.h; then
y_tab_nodot="yes"
fi
# The directory holding the input.
input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
# Quote $INPUT_DIR so we can use it in a regexp.
# FIXME: really we should care about more than `.' and `\'.
input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
while test "$#" -ne 0; do
from="$1"
# Handle y_tab.c and y_tab.h output by DOS
if test $y_tab_nodot = "yes"; then
if test $from = "y.tab.c"; then
from="y_tab.c"
else
if test $from = "y.tab.h"; then
from="y_tab.h"
fi
fi
fi
if test -f "$from"; then
# If $2 is an absolute path name, then just use that,
# otherwise prepend `../'.
case "$2" in
[\\/]* | ?:[\\/]*) target="$2";;
*) target="../$2";;
esac
# We do not want to overwrite a header file if it hasn't
# changed. This avoid useless recompilations. However the
# parser itself (the first file) should always be updated,
# because it is the destination of the .y.c rule in the
# Makefile. Divert the output of all other files to a temporary
# file so we can compare them to existing versions.
if test $first = no; then
realtarget="$target"
target="tmp-`echo $target | sed s/.*[\\/]//g`"
fi
# Edit out `#line' or `#' directives.
#
# We don't want the resulting debug information to point at
# an absolute srcdir; it is better for it to just mention the
# .y file with no path.
#
# We want to use the real output file name, not yy.lex.c for
# instance.
#
# We want the include guards to be adjusted too.
FROM=`echo "$from" | sed \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
TARGET=`echo "$2" | sed \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
-e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
# Check whether header files must be updated.
if test $first = no; then
if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
echo "$2" is unchanged
rm -f "$target"
else
echo updating "$2"
mv -f "$target" "$realtarget"
fi
fi
else
# A missing file is only an error for the first file. This
# is a blatant hack to let us support using "yacc -d". If -d
# is not specified, we don't want an error when the header
# file is "missing".
if test $first = yes; then
ret=1
fi
fi
shift
shift
first=no
done
else
ret=$?
fi
# Remove the directory.
cd ..
rm -rf $dirname
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

13714
opal/mca/paffinity/linux/plpa/configure поставляемый

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -10,7 +10,7 @@
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2006-2008 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2006-2007 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
@ -66,7 +66,7 @@ AH_TOP([/* -*- c -*-
* All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -74,18 +74,23 @@ AH_TOP([/* -*- c -*-
* $HEADER$
*/
#ifndef PLPA_CONFIG_H
#define PLPA_CONFIG_H
#ifndef PLPA_H
#define PLPA_H
])
AH_BOTTOM([
#endif /* PLPA_CONFIG_H */
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
#include "plpa_bottom.h"
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
#endif /* PLPA_H */
])
# Compiler stuff
CFLAGS_save="$CFLAGS"
AC_PROG_CC
AM_PROG_CC_C_O
CFLAGS="$CFLAGS_save"
# For the common developer case, if we're in a Subversion checkout and
# using the GNU compilers, turn on maximum warnings unless

199
opal/mca/paffinity/linux/plpa/contrib/dist/make_dist_tarball поставляемый Исполняемый файл
Просмотреть файл

@ -0,0 +1,199 @@
#!/bin/sh
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
#
# Version of auto tools that we want
#
AM_TARGET_VERSION=1.9.6
AC_TARGET_VERSION=2.59
LT_TARGET_VERSION=1.5.22
#
# First things first -- check that the auto versions that we have are
# the ones that we want.
#
check_gnu_version() {
prog="$1"
target="$2"
ver="`$prog --version | head -n 1 | cut -d\ -f 4`"
if test "$ver" != "$target"; then
cat <<EOF
ERROR: Program "$prog" does not have the correct/expected version:
Found: $ver
Expected versions:
Automake: $AM_TARGET_VERSION
Autoconf: $AC_TARGET_VERSION
Libtool: $LT_TARGET_VERSION
Either change this script to match the found version, or install
the correct version of the tools.
EOF
exit 1
fi
}
#
# Subroutine to actually make a tarball
#
make_tarball() {
#
# Autogen
#
echo "*** Removing old configure..."
# Ensure that configure is re-generated -- sometimes it won't be
# (if it hasn't changed), and therefore VERSION could be newer
# than configure, and that leads to all kinds of problems
rm -f configure
echo "*** Running autogen.sh..."
./autogen.sh 2>&1 | tee auto.out
if test ! "$?" = "0"; then
echo "Autogen failed. Aborting"
exit 1
fi
#
# Configure
#
echo "*** Running configure..."
./configure --enable-dist 2>&1 | tee config.out
if test ! "$?" = "0"; then
echo "Configure failed. Aborting"
exit 1
fi
#
# Remove autogen.sh (just to ensure users don't try to run it)
#
echo "*** Removing autogen.sh from the tarball before make dist"
rm -rf autogen.sh
#
# make tarball
#
echo "*** Running make distcheck..."
save_LD=$LD_LIBRARY_PATH
LD_LIBRARY_PATH=
make distcheck 2>&1 | tee dist.out
if test ! "$?" = "0"; then
echo "Make dist failed. Aborting"
exit 1
fi
LD_LIBRARY_PATH=$save_LD
#
# move
#
echo "*** Moving tarballs..."
mv plpa-* ..
echo "*** All done"
#
# bring back autogen.sh
#
svn up autogen.sh
}
#########################################################################
# main
#########################################################################
echo "*** Checking GNU tools versions..."
check_gnu_version automake $AM_TARGET_VERSION
check_gnu_version autoconf $AC_TARGET_VERSION
check_gnu_version libtool $LT_TARGET_VERSION
#
# Verify that we're in a top PLPA dir
#
echo "*** Checking to ensure in top-level PLPA directory..."
if test -f VERSION -a -f configure.ac -a -f config/plpa.m4; then
happy=1
else
echo "Do not appear to be in a PLPA top directory. Abort!"
exit 1
fi
#
# Do svn up and all that
#
echo "*** Removing old VERSION files..."
find . -name VERSION -exec rm -f {} \; -print
echo "*** Running svn up..."
svn up
if test ! "$?" = "0"; then
echo "SVN update failed. Aborting"
exit 1
fi
#
# Ditch "svn" from all version numbers
#
echo "*** Removing svn version numbers..."
svn_r="r`svnversion .`"
version_files="`find . -name VERSION`"
for file in $version_files; do
echo " - $file"
sed -e 's/^want_svn=.*/want_svn=0/' \
-e 's/^svn_r=.*/'svn_r=$svn_r/ $file > $file.new
cp -f $file.new $file
rm $file.new
done
#
# Make 2 tarballs:
#
# - one with the greek
# - one without the greek
#
# unless the user specifically said --greekonly, then only make the
# greek tarball. Making both tarballs at once allows us to guarantee
# to have two tarballs -- one greek and one not -- that have exactly
# the same SVN r number (as opposed to, for example, running this
# script to make a greek tarball, then running it again to make a
# non-greek tarball -- there is a race condition that someone could
# commit in the meantime and change the SVN r number in the 2nd
# tarball)
#
# First, make greek tarball
echo "*** Making greek tarball"
make_tarball
# Now if ! --greekonly, make the non-greek tarball
if test "$1" != "-greekonly" -a "$1" != "--greekonly"; then
echo "*** REMOVING ALL GREEK FROM VERSION NUMBERS!!"
for file in $version_files; do
echo " - $file"
sed -e 's/^greek=.*/greek=/' $file > $file.new
cp -f $file.new $file
rm $file.new
done
echo "Making non-greek tarball"
make_tarball
fi

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

@ -0,0 +1,15 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
SUBDIRS = libplpa plpa-info plpa-taskset

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

@ -20,26 +20,30 @@
# Defaults
lib_LTLIBRARIES =
noinst_LTLIBRARIES =
include_HEADERS =
nodist_include_HEADERS =
noinst_HEADERS = plpa_internal.h
nodist_noinst_HEADERS =
# Note that this file is generated by configure, so we don't want to
# ship it in the tarball. Hence the "nodist_" prefixes to the HEADERS
# macros, below.
public_headers = plpa.h
nodist_public_headers = \
plpa.h
public_headers = \
plpa_bottom.h
# See which mode we're building in
if PLPA_BUILD_STANDALONE
lib_LTLIBRARIES += libplpa.la
nodist_include_HEADERS += $(public_headers)
include_HEADERS += $(public_headers)
nodist_include_HEADERS += $(nodist_public_headers)
else
noinst_LTLIBRARIES += libplpa_included.la
nodist_noinst_HEADERS += $(public_headers)
noinst_HEADERS += $(public_headers)
nodist_noinst_HEADERS += $(nodist_public_headers)
endif
# The sources
plpa_sources = \
plpa_internal.h \
plpa_api_probe.c \
plpa_dispatch.c \
plpa_runtime.c \

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

@ -1,214 +1,119 @@
/* ./src/libplpa/plpa.h.in. Generated from configure.ac by autoheader. */
/* -*- c -*-
*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2008 Cisco, Inc. All rights reserved.
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/*
* Some notes about the declarations and definitions in this file:
*
* This file is a mix of internal and public declarations.
* Applications are warned against using the internal types; they are
* subject to change with no warning.
*
* The PLPA_NAME() and PLPA_NAME_CAPS() macros are used for prefixing
* the PLPA type names, enum names, and symbol names when embedding
* PLPA. When not embedding, the default prefix is "plpa_" (or
* "PLPA_" when using PLPA_NAME_CAPS()). Hence, if you see a
* declaration like this:
*
* int PLPA_NAME(foo)(void);
*
* It's a function named plpa_foo() that returns an int and takes no
* arguments when building PLPA as a standalone library. It's a
* function with a different prefix than "plpa_" when the
* --enable-included-mode and --with-plpa-symbol-prefix options are
* supplied to PLPA's configure script.
*/
#ifndef PLPA_H
#define PLPA_H
/* Absolutely must not include <sched.h> here or it will generate
conflicts. */
/* For memset() */
#include <string.h>
/* For pid_t and size_t */
#include <sys/types.h>
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/***************************************************************************
* Internal types
***************************************************************************/
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Whether we're in debugging mode or not */
#undef PLPA_DEBUG
/* Major version of PLPA */
#undef PLPA_MAJOR_VERSION
/* Minor version of PLPA */
#undef PLPA_MINOR_VERSION
/* Release version of PLPA */
#undef PLPA_RELEASE_VERSION
/* If we're building PLPA itself, <plpa_config.h> will have already
been included. But <plpa_config.h> is a private header file; it is
not installed into $includedir. Hence, applications including
<plpa.h> will not have included <plpa_config.h> (this is by
design). So include just enough information here to allow us to
continue. */
#ifndef PLPA_CONFIG_H
/* The PLPA symbol prefix */
#define PLPA_SYM_PREFIX plpa_
#undef PLPA_SYM_PREFIX
/* The PLPA symbol prefix in all caps */
#define PLPA_SYM_PREFIX_CAPS PLPA_
#undef PLPA_SYM_PREFIX_CAPS
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
`char[]'. */
#undef YYTEXT_POINTER
/* Emulated value */
#undef __NR_sched_getaffinity
/* Emulated value */
#undef __NR_sched_setaffinity
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
/* Preprocessors are fun -- the double inderection is unfortunately
necessary. */
#define PLPA_MUNGE_NAME(a, b) PLPA_MUNGE_NAME2(a, b)
#define PLPA_MUNGE_NAME2(a, b) a ## b
#define PLPA_NAME(name) PLPA_MUNGE_NAME(PLPA_SYM_PREFIX, name)
#define PLPA_NAME_CAPS(name) PLPA_MUNGE_NAME(PLPA_SYM_PREFIX_CAPS, name)
/***************************************************************************
* Public type
***************************************************************************/
/* Values that can be returned from plpa_api_probe() */
typedef enum {
/* Sentinel value */
PLPA_NAME_CAPS(PROBE_UNSET),
/* sched_setaffinity syscall available */
PLPA_NAME_CAPS(PROBE_OK),
/* syscall unavailable/unimplemented */
PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED),
/* we experienced some strange failure that the user should report */
PLPA_NAME_CAPS(PROBE_UNKNOWN)
} PLPA_NAME(api_type_t);
/***************************************************************************
* Internal types
***************************************************************************/
/* Internal PLPA bitmask type. This type should not be used by
external applications! */
typedef unsigned long int PLPA_NAME(bitmask_t);
#define PLPA_BITMASK_T_NUM_BITS (sizeof(PLPA_NAME(bitmask_t)) * 8)
#define PLPA_BITMASK_CPU_MAX 1024
#define PLPA_BITMASK_NUM_ELEMENTS (PLPA_BITMASK_CPU_MAX / PLPA_BITMASK_T_NUM_BITS)
/***************************************************************************
* Public type
***************************************************************************/
/* Public type for the PLPA cpu set. */
typedef struct { PLPA_NAME(bitmask_t) bitmask[PLPA_BITMASK_NUM_ELEMENTS]; } PLPA_NAME(cpu_set_t);
/***************************************************************************
* Internal macros
***************************************************************************/
/* Internal macro for identifying the byte in a bitmask array. This
macro should not be used by external applications! */
#define PLPA_CPU_BYTE(num) ((num) / PLPA_BITMASK_T_NUM_BITS)
/* Internal macro for identifying the bit in a bitmask array. This
macro should not be used by external applications! */
#define PLPA_CPU_BIT(num) ((num) % PLPA_BITMASK_T_NUM_BITS)
/***************************************************************************
* Public macros
***************************************************************************/
/* Public macro to zero out a PLPA cpu set (analogous to the FD_ZERO()
macro; see select(2)). */
#define PLPA_CPU_ZERO(cpuset) \
memset((cpuset), 0, sizeof(PLPA_NAME(cpu_set_t)))
/* Public macro to set a bit in a PLPA cpu set (analogous to the
FD_SET() macro; see select(2)). */
#define PLPA_CPU_SET(num, cpuset) \
(cpuset)->bitmask[PLPA_CPU_BYTE(num)] |= ((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))
/* Public macro to clear a bit in a PLPA cpu set (analogous to the
FD_CLR() macro; see select(2)). */
#define PLPA_CPU_CLR(num, cpuset) \
(cpuset)->bitmask[PLPA_CPU_BYTE(num)] &= ~((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))
/* Public macro to test if a bit is set in a PLPA cpu set (analogous
to the FD_ISSET() macro; see select(2)). */
#define PLPA_CPU_ISSET(num, cpuset) \
(0 != (((cpuset)->bitmask[PLPA_CPU_BYTE(num)]) & ((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))))
/***************************************************************************
* Public functions
***************************************************************************/
/* Setup PLPA internals. This function is optional; it will be
automatically invoked by all the other API functions if you do not
invoke it explicitly. Returns 0 upon success. */
int PLPA_NAME(init)(void);
/* Check what API is on this machine. If api_type returns
PLPA_PROBE_OK, then PLPA can function properly on this machine.
Returns 0 upon success. */
int PLPA_NAME(api_probe)(PLPA_NAME(api_type_t) *api_type);
/* Set processor affinity. Use the PLPA_CPU_* macros to set the
cpuset value. The same rules and restrictions about pid apply as
they do for the sched_setaffinity(2) system call. Returns 0 upon
success. */
int PLPA_NAME(sched_setaffinity)(pid_t pid, size_t cpusetsize,
const PLPA_NAME(cpu_set_t) *cpuset);
/* Get processor affinity. Use the PLPA_CPU_* macros to analyze the
returned value of cpuset. The same rules and restrictions about
pid apply as they do for the sched_getaffinity(2) system call.
Returns 0 upon success. */
int PLPA_NAME(sched_getaffinity)(pid_t pid, size_t cpusetsize,
PLPA_NAME(cpu_set_t) *cpuset);
/* Return whether topology information is available (i.e.,
plpa_map_to_*, plpa_max_*). The topology functions will be
available if supported == 1 and the function returns 0. */
int PLPA_NAME(have_topology_information)(int *supported);
/* Map (socket,core) tuple to virtual processor ID. processor_id is
then suitable for use with the PLPA_CPU_* macros, probably leading
to a call to plpa_sched_setaffinity(). Returns 0 upon success. */
int PLPA_NAME(map_to_processor_id)(int socket, int core, int *processor_id);
/* Map processor_id to (socket,core) tuple. The processor_id input is
usually obtained from the return from the plpa_sched_getaffinity()
call, using PLPA_CPU_ISSET to find individual bits in the map that
were set/unset. plpa_map_to_socket_core() can map the bit indexes
to a socket/core tuple. Returns 0 upon success. */
int PLPA_NAME(map_to_socket_core)(int processor_id, int *socket, int *core);
/* Return the max processor ID. Returns both the number of processors
(cores) 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);
/* Returns both the number of sockets in the system and the maximum
socket ID number (in case there are "holes" in the list of available
socket IDs). Returns 0 upon sucess. */
int PLPA_NAME(get_socket_info)(int *num_sockets, int *max_socket_id);
/* Return both the number of cores and the max code ID for a given
socket (in case there are "holes" in the list of available core
IDs). Returns 0 upon success. */
int PLPA_NAME(get_core_info)(int socket, int *num_cores, int *max_core_id);
/* Shut down PLPA. This function releases resources used by the PLPA.
It should be the last PLPA function invoked, or can be used to
forcibly cause PLPA to dump its topology cache and re-analyze the
underlying system the next time another PLPA function is called.
Specifically: it is safe to call plpa_init() (or any other PLPA
function) again after plpa_finalized(). Returns 0 upon success. */
int PLPA_NAME(finalize)(void);
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
#include "plpa_bottom.h"
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
#endif /* PLPA_H */

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

@ -4,7 +4,7 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2008 Cisco, Inc. All rights reserved.
* Copyright (c) 2007 Cisco, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -12,7 +12,6 @@
* $HEADER$
*/
#include "plpa_config.h"
#include "plpa.h"
#include "plpa_internal.h"

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

@ -0,0 +1,134 @@
/* -*- c -*-
*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PLPA_BOTTOM_H
#define PLPA_BOTTOM_H
/* Absolutely must not include <sched.h> here or it will generate
conflicts. */
/* For memset() */
#include <string.h>
/* For pid_t and size_t */
#include <sys/types.h>
/***************************************************************************/
/* Internal macro to munge names */
/* 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
#define PLPA_NAME(name) PLPA_MUNGE_NAME(PLPA_SYM_PREFIX, name)
#define PLPA_NAME_CAPS(name) PLPA_MUNGE_NAME(PLPA_SYM_PREFIX_CAPS, name)
/***************************************************************************/
/* Values that can be returned from plpa_api_probe() */
typedef enum {
/* Sentinel value */
PLPA_NAME_CAPS(PROBE_UNSET),
/* sched_setaffinity syscall available */
PLPA_NAME_CAPS(PROBE_OK),
/* syscall unavailable/unimplemented */
PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED),
/* we experienced some strange failure that the user should report */
PLPA_NAME_CAPS(PROBE_UNKNOWN)
} PLPA_NAME(api_type_t);
/* Values that can be used in plpa_max_id() */
typedef enum {
/* Linux virtual processor */
PLPA_NAME_CAPS(ID_TYPE_PROCESSOR),
/* CPU sockets */
PLPA_NAME_CAPS(ID_TYPE_SOCKET),
/* CPU cores */
PLPA_NAME_CAPS(ID_TYPE_CORE),
/* Sentinel value */
PLPA_NAME_CAPS(ID_TYPE_MAX)
} PLPA_NAME(plpa_id_type_t);
/* PLPA bitmask type */
typedef unsigned long int PLPA_NAME(bitmask_t);
#define PLPA_BITMASK_T_NUM_BITS (sizeof(PLPA_NAME(bitmask_t)) * 8)
#define PLPA_BITMASK_CPU_MAX 1024
#define PLPA_BITMASK_NUM_ELEMENTS (PLPA_BITMASK_CPU_MAX / PLPA_BITMASK_T_NUM_BITS)
typedef struct { PLPA_NAME(bitmask_t) bitmask[PLPA_BITMASK_NUM_ELEMENTS]; } PLPA_NAME(cpu_set_t);
/***************************************************************************/
/* Internal macro for identifying the byte in a bitmask array */
#define PLPA_CPU_BYTE(num) ((num) / PLPA_BITMASK_T_NUM_BITS)
/* Internal macro for identifying the bit in a bitmask array */
#define PLPA_CPU_BIT(num) ((num) % PLPA_BITMASK_T_NUM_BITS)
/***************************************************************************/
/* Public macro to zero out a PLPA cpu set */
#define PLPA_CPU_ZERO(cpuset) \
memset((cpuset), 0, sizeof(PLPA_NAME(cpu_set_t)))
/* Public macro to set a bit in a PLPA cpu set */
#define PLPA_CPU_SET(num, cpuset) \
(cpuset)->bitmask[PLPA_CPU_BYTE(num)] |= ((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))
/* Public macro to clear a bit in a PLPA cpu set */
#define PLPA_CPU_CLR(num, cpuset) \
(cpuset)->bitmask[PLPA_CPU_BYTE(num)] &= ~((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))
/* Public macro to test if a bit is set in a PLPA cpu set */
#define PLPA_CPU_ISSET(num, cpuset) \
(0 != (((cpuset)->bitmask[PLPA_CPU_BYTE(num)]) & ((PLPA_NAME(bitmask_t))1 << PLPA_CPU_BIT(num))))
/***************************************************************************/
/* Setup PLPA internals */
int PLPA_NAME(init)(void);
/* Check what API is on this machine */
int PLPA_NAME(api_probe)(PLPA_NAME(api_type_t) *api_type);
/* Set processor affinity */
int PLPA_NAME(sched_setaffinity)(pid_t pid, size_t cpusetsize,
const PLPA_NAME(cpu_set_t) *cpuset);
/* Get processor affinity */
int PLPA_NAME(sched_getaffinity)(pid_t pid, size_t cpusetsize,
PLPA_NAME(cpu_set_t) *cpuset);
/* Return whether topology information is available (i.e.,
plpa_map_to_*, plpa_max_*) */
int PLPA_NAME(have_topology_information)(int *supported);
/* Map (socket,core) tuple to virtual processor ID */
int PLPA_NAME(map_to_processor_id)(int socket, int core, int *processor_id);
/* Map processor_id to (socket,core) tuple */
int PLPA_NAME(map_to_socket_core)(int processor_id, int *socket, int *core);
/* Return the max processor ID */
int PLPA_NAME(max_processor_id)(int *max_processor_id);
/* Return the max socket number */
int PLPA_NAME(max_socket)(int *max_socket);
/* Return the max core number for a given socket */
int PLPA_NAME(max_core)(int socket, int *max_core);
/* Shut down PLPA */
int PLPA_NAME(finalize)(void);
#endif /* PLPA_BOTTOM_H */

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

@ -1,112 +0,0 @@
/* ./src/libplpa/plpa_config.h.in. Generated from configure.ac by autoheader. */
/* -*- c -*-
*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2008 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PLPA_CONFIG_H
#define PLPA_CONFIG_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Whether we're in debugging mode or not */
#undef PLPA_DEBUG
/* Major version of PLPA */
#undef PLPA_MAJOR_VERSION
/* Minor version of PLPA */
#undef PLPA_MINOR_VERSION
/* Release version of PLPA */
#undef PLPA_RELEASE_VERSION
/* The PLPA symbol prefix */
#undef PLPA_SYM_PREFIX
/* The PLPA symbol prefix in all caps */
#undef PLPA_SYM_PREFIX_CAPS
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
`char[]'. */
#undef YYTEXT_POINTER
/* Emulated value */
#undef __NR_sched_getaffinity
/* Emulated value */
#undef __NR_sched_setaffinity
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
#endif /* PLPA_CONFIG_H */

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

@ -4,7 +4,7 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -12,7 +12,6 @@
* $HEADER$
*/
#include "plpa_config.h"
#include "plpa.h"
#include "plpa_internal.h"
@ -20,7 +19,7 @@
#include <sys/syscall.h>
#include <unistd.h>
/**
/*
* Call the kernel's setaffinity, massaging the user's input
* parameters as necessary
*/
@ -54,6 +53,9 @@ int PLPA_NAME(sched_setaffinity)(pid_t pid, size_t cpusetsize,
if (cpusetsize > sizeof(*cpuset)) {
return EINVAL;
}
if (NULL == cpuset) {
return EINVAL;
}
/* If the user-supplied bitmask is smaller than what the
kernel wants, zero out a temporary buffer of the size that
@ -128,7 +130,7 @@ int PLPA_NAME(sched_setaffinity)(pid_t pid, size_t cpusetsize,
}
/**
/*
* Call the kernel's getaffinity, massaging the user's input
* parameters as necessary
*/
@ -159,6 +161,9 @@ int PLPA_NAME(sched_getaffinity)(pid_t pid, size_t cpusetsize,
if (PLPA_NAME(len) > sizeof(*cpuset)) {
return EINVAL;
}
if (NULL == cpuset) {
return EINVAL;
}
/* If the user supplied a buffer that is too small, then don't
even bother */

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

@ -113,7 +113,6 @@
personal jurisdiction and venue of these courts.
============================================================ */
#include "plpa_config.h"
#include "plpa.h"
#include "plpa_internal.h"
@ -131,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_id = -1;
static int *max_core_id = NULL;
static int *num_cores = NULL;
static int max_core_id_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_id) {
free(max_core_id);
max_core_id = 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);
@ -164,17 +156,15 @@ static void clear_cache(void)
map_tuple_to_processor_id = NULL;
}
num_processors = max_processor_num = -1;
num_sockets = max_socket_id = -1;
max_core_id_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);
@ -183,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;
@ -217,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_id) {
max_socket_id = 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_id = malloc(sizeof(int) * (max_socket_id + 1));
if (NULL == max_core_id) {
clear_cache();
return;
}
num_cores = malloc(sizeof(int) * (max_socket_id + 1));
if (NULL == num_cores) {
clear_cache();
return;
}
for (i = 0; i <= max_socket_id; ++i) {
num_cores[i] = -1;
max_core_id[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_id[map_processor_id_to_tuple[i].socket]) {
max_core_id[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_id[map_processor_id_to_tuple[i].socket] >
max_core_id_overall) {
max_core_id_overall =
max_core_id[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_id 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_id; ++i) {
if (max_core_id[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_id[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_id + 1));
if (NULL == cores_on_sockets) {
clear_cache();
return;
}
for (i = 0; i <= max_socket_id; ++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_id; ++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];
}
}
@ -337,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_id + 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_id + 1) *
(max_core_id_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_id; ++i) {
for (i = 1; i <= max_socket; ++i) {
map_tuple_to_processor_id[i] =
map_tuple_to_processor_id[i - 1] + max_core_id_overall + 1;
map_tuple_to_processor_id[i - 1] + max_core_overall;
}
/* Compute map */
for (i = 0; i <= max_socket_id; ++i) {
for (j = 0; j <= max_core_id_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,
@ -368,15 +288,11 @@ 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] =
&map_processor_id_to_tuple[k];
#if defined(PLPA_DEBUG) && PLPA_DEBUG
printf("Creating map: (socket %d, core %d) -> ID %d\n",
i, j, k);
#endif
break;
}
}
@ -450,24 +366,18 @@ int PLPA_NAME(map_to_processor_id)(int socket, int core, int *processor_id)
/* If this system doesn't support mapping, sorry Charlie */
if (!supported) {
return ENOSYS;
return ENOENT;
}
/* Check for some invalid entries */
if (socket < 0 || socket > max_socket_id ||
core < 0 || core > max_core_id_overall) {
return ENOENT;
}
/* If the mapping returns -1, then this is a non-existent
socket/core combo (even though they fall within the max socket
/ max core overall values) */
ret = map_tuple_to_processor_id[socket][core]->processor_id;
if (-1 == ret) {
return ENOENT;
if (socket < 0 || socket > max_socket ||
core < 0 || core > max_core_overall ||
NULL == processor_id) {
return EINVAL;
}
/* Ok, all should be good -- return the mapping */
*processor_id = ret;
*processor_id = map_tuple_to_processor_id[socket][core]->processor_id;
return 0;
}
@ -489,26 +399,23 @@ int PLPA_NAME(map_to_socket_core)(int processor_id, int *socket, int *core)
/* If this system doesn't support mapping, sorry Charlie */
if (!supported) {
return ENOSYS;
return ENOENT;
}
/* Check for some invalid entries */
if (processor_id < 0 || processor_id > max_processor_num) {
return ENOENT;
}
ret = map_processor_id_to_tuple[processor_id].socket;
if (-1 == ret) {
return ENOENT;
if (processor_id < 0 || processor_id > max_processor ||
NULL == socket ||
NULL == core) {
return EINVAL;
}
/* Ok, all should be good -- return the mapping */
*socket = ret;
*socket = map_processor_id_to_tuple[processor_id].socket;
*core = map_processor_id_to_tuple[processor_id].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;
@ -520,23 +427,22 @@ 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;
}
/* If this system doesn't support mapping, sorry Charlie */
if (!supported) {
return ENOSYS;
return ENOENT;
}
/* 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_id_arg)
int PLPA_NAME(max_socket)(int *max_socket_arg)
{
int ret;
@ -548,24 +454,22 @@ int PLPA_NAME(get_socket_info)(int *num_sockets_arg, int *max_socket_id_arg)
}
/* Check for bozo arguments */
if (NULL == max_socket_id_arg || NULL == num_sockets_arg) {
if (NULL == max_socket_arg) {
return EINVAL;
}
/* If this system doesn't support mapping, sorry Charlie */
if (!supported) {
return ENOSYS;
return ENOENT;
}
/* All done */
*num_sockets_arg = num_sockets;
*max_socket_id_arg = max_socket_id;
*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_id_arg)
/* Return the max core number for a given socket */
int PLPA_NAME(max_core)(int socket, int *max_core_arg)
{
int ret;
@ -577,26 +481,21 @@ int PLPA_NAME(get_core_info)(int socket, int *num_cores_arg,
}
/* Check for bozo arguments */
if (NULL == max_core_id_arg || NULL == num_cores_arg) {
if (NULL == max_core_arg) {
return EINVAL;
}
/* If this system doesn't support mapping, sorry Charlie */
if (!supported) {
return ENOSYS;
return ENOENT;
}
/* Check for some invalid entries */
if (socket < 0 || socket > max_socket_id || -1 == max_core_id[socket]) {
return ENOENT;
}
ret = num_cores[socket];
if (-1 == ret) {
return ENOENT;
if (socket < 0 || socket > max_socket) {
return EINVAL;
}
/* All done */
*num_cores_arg = ret;
*max_core_id_arg = max_core_id[socket];
*max_core_arg = max_core[socket];
return 0;
}

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

@ -2,7 +2,6 @@
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
*/
#include "plpa_config.h"
#include "plpa.h"
#include "plpa_internal.h"

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

@ -0,0 +1,26 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Default to empty
bin_PROGRAMS=
AM_CPPFLAGS = -I$(top_srcdir)/src/libplpa
# See which mode we're building in
if PLPA_BUILD_EXECUTABLES
bin_PROGRAMS += plpa-info
endif
plpa_info_SOURCES = plpa-info.c
plpa_info_LDADD = $(top_builddir)/src/libplpa/libplpa.la

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

@ -0,0 +1,103 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <plpa.h>
int main(int argc, char *argv[])
{
int i;
int ret = 0;
int need_help = 0;
int show_topo = 0;
int have_topo, max_socket, max_core;
PLPA_NAME(api_type_t) api_probe;
for (i = 1; i < argc; ++i) {
if (0 == strcmp("--version", argv[i])) {
printf("PLPA version %s\n", PACKAGE_VERSION);
exit(0);
} else if (0 == strcmp("--help", argv[i])) {
need_help = 1;
ret = 0;
break;
} else if (0 == strcmp("--topo", argv[i])) {
show_topo = 1;
} else {
printf("%s: unrecognized option: %s\n",
argv[0], argv[i]);
need_help = 1;
ret = 1;
}
}
if (need_help) {
printf("usage: %s [--version | --topo] [--help]\n", argv[0]);
return ret;
}
/* Is affinity supported at all? */
if (0 != PLPA_NAME(api_probe)(&api_probe)) {
api_probe = PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED);
}
printf("Kernel affinity support: ");
switch (api_probe) {
case PLPA_NAME_CAPS(PROBE_OK):
printf("yes\n");
break;
case PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED):
printf("no\n");
break;
default:
printf("unknonwn (no)\n");
break;
}
/* What about topology? */
if (0 != PLPA_NAME(have_topology_information)(&have_topo)) {
have_topo = 0;
}
printf("Kernel topology support: %s\n", have_topo ? "yes" : "no");
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 */
if (show_topo) {
if (have_topo) {
/* Remember that max_socket and max_core values are
0-indexed */
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, max_core + 1,
(0 == max_core) ? "" : "s");
} else {
printf("Socket %d: unknown cores\n", i);
}
}
} else {
printf("Kernel topology not supported -- cannot show topology information\n");
exit(1);
}
}
return 0;
}

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

@ -0,0 +1,38 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Default to empty
bin_PROGRAMS=
AM_CPPFLAGS = -I$(top_srcdir)/src/libplpa
AM_YFLAGS = -d
if PLPA_BUILD_EXECUTABLES
bin_PROGRAMS += plpa-taskset
endif
# Force recognition that tokens.h is generated via tokens.c; there's a
# rule to create tokens.c from tokens.y.
tokens.c: tokens.y
tokens.h: tokens.c
# 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 \
parser.l \
tokens.y
plpa_taskset_LDADD = $(top_builddir)/src/libplpa/libplpa.la

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

@ -0,0 +1,53 @@
The requirements are:
1. devise a relatively simple command line syntax to bind a single
process to a set of (socket,core) tuples
2. be compatible with the "taskset" precedent, meaning:
- specify the sets of tuples in a single command line token (e.g.,
comma delimited?)
- be able to clearly differentiate this notation from the
"taskset" processor mask and list specifications (so that it's
clear when to treat a command line token as a processor mask, a
processor list, and a set of (socket,core) tuples)
3. be able to specify a single tuple with a some kind of "stride" for
repeating simple patterns (analogous to taskset's "x-y:step" range
notation)
4. include ability to wildcard sockets or cores. For example:
- bind to all cores on sockets x, y, z
- bind to cores x, y, z on all sockets
5. not force the user to use escapes in common shells (e.g., avoid the
use of *, !, and other shell-special characters)
Here's what I have figured out so far:
- use the general notation "<core>@<socket>"
- wildcard values:
- "all" -- all sockets/cores (depending on context)
- "even" -- even numbered sockets/cores
- "odd" -- odd numbered sockets/cores
- "not" -- negate the specified sockets and/or cores
- ...easy enough to add others
- sockets and cores are numbered starting with 0 (just like processor
IDs)
- multiple tuples can be specified as a comma delimited list
- core/socket ranges can be specified as "x-y", where x<=y
- {} can be used to specify lists of cores or sockets, and can be used
to make complex tuples
- examples:
- binding to core 3 on socket 1 is "3@1"
- binding to core 1 on all sockets is "1@all"
- binding to all cores on socket 2 is "all@2"
- binding to all cores on sockets 2 and 3 is "all@2,all@3" OR
"all@{2,3}"
- binding to cores 1 and 2 on sockets 0, 1, and 3 is
"{1,2}@{0,1,3}"
- binding to cores 0, 1, and 2 on sockets 0, 1, 2, and 5 is
"{0-2}@{0-2,5}"
- binding to all cores on all sockets (effectively disables PA) is
"all@all"
- binding to all cores on all sockets *except* all cores on socket
0 is "all@not0"

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,78 @@
%{ /* -*- C -*- */
/*
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "plpa.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "plpa-taskset.h"
#include "tokens.h"
/*
* local functions
*/
static int finish_parsing(void);
#define yyterminate() \
return finish_parsing()
/*
* Make lex-generated files not issue compiler warnings
*/
#define YY_STACK_USED 0
#define YY_ALWAYS_INTERACTIVE 0
#define YY_NEVER_INTERACTIVE 0
#define YY_MAIN 0
#define YY_NO_UNPUT 1
%}
%option noyywrap
%%
[0-9]* { yylval.number = atoi(yytext); return TOKENS_NUMBER; }
"all" { return TOKENS_STRING_ALL; }
"even" { return TOKENS_STRING_EVEN; }
"odd" { return TOKENS_STRING_ODD; }
"not" { return TOKENS_STRING_NOT; }
. { return *yytext; }
%%
/*
* This cleans up at the end of the parse (since, in this case, we
* always parse the entire file) and prevents a memory leak.
*/
static int finish_parsing(void)
{
if (NULL != YY_CURRENT_BUFFER) {
yy_delete_buffer(YY_CURRENT_BUFFER);
#if defined(YY_CURRENT_BUFFER_LVALUE)
YY_CURRENT_BUFFER_LVALUE = NULL;
#else
YY_CURRENT_BUFFER = NULL;
#endif /* YY_CURRENT_BUFFER_LVALUE */
}
return YY_NULL;
}
void parser_setup_string(char *str)
{
yy_scan_string(str);
}

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

@ -0,0 +1,438 @@
/*
* Copyright (c) 2007 Cisco, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
* And before you ask: no, none of this code is lifted from the GPL'ed
* taskset source. I looked at that source code just enough to read
* the header and realize that it was GPL. This is entirely new
* source code unencumbered by the GPL. I read the man page to make
* this functionality similar to that of the taskset command. The
* goal here is to make an executable that behaves like the venerable
* taskset command but has some more options, such as for socket and
* core mapping.
*/
/* Needed for getopt_long() */
#define GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <plpa.h>
#include <errno.h>
#include <unistd.h>
#include <getopt.h>
#include <ctype.h>
#include "plpa-taskset.h"
static void show_help(char *argv0, int ret)
{
printf("plpa_taskset version %s\n", PACKAGE_VERSION);
printf("usage: %s [options] [mask | cpu-list] [pid | cmd [args...]]\n",
argv0);
printf("set or get the affinity of a process\n\n");
printf(" -p, --pid operating on existing given pid\n");
printf(" pid can also be \"self\" or \"parent\"\n");
printf(" -c, --cpu-list display and specify cpus in list format\n");
printf(" -h, --help display this help\n");
printf(" -v, --version output version information\n");
printf("\n");
printf("The default behavior is to run a new command:\n");
printf(" %s 03 sshd -b 1024\n", argv0);
printf("You can retrieve the mask of an existing task:\n");
printf(" %s -p 700\n", argv0);
printf("Or set it:\n");
printf(" %s -p 03 700\n", argv0);
printf("List format uses a comma-separated list instead of a mask:\n");
printf(" %s -pc 0,3,7-11 700\n", argv0);
printf("Ranges in list format can take a stride argument:\n");
printf(" e.g. 0-31:2 is equivalent to mask 0x55555555\n");
printf("\n");
printf("Core/socket tuples can be specified with <core>@<socket> syntax:\n");
printf(" %s -pc 1@3,0@2 700\n", argv0);
printf("\"all\", \"even\", and \"odd\" are valid in the socket/core syntax:\n");
printf(" %s -pc all@3,2@even 700\n", argv0);
printf("\"all\" can be used to disable affinity:\n");
printf(" %s -pc all@all 700\n", argv0);
printf("Complex core/socket tuples can be specified with {}:\n");
printf(" %s -pc {0-2}@{0-2,5} 700\n", argv0);
printf("\"parent\" can be used as the PID:\n");
printf(" %s -pc even@all parent\n", argv0);
printf("\n");
exit(ret);
}
static void show_version(void)
{
printf("plpa_taskset version %s\n", PACKAGE_VERSION);
exit(0);
}
static void append(char *str, int val)
{
char temp[8];
if ('\0' != str[0]) {
strcat(str, ",");
}
snprintf(temp, sizeof(temp) - 1, "%d", val);
strcat(str, temp);
}
static char *cpu_set_to_list(const PLPA_NAME(cpu_set_t) *cpu_set)
{
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_NUM_ELEMENTS + 1 comma for each */
static char str[PLPA_BITMASK_NUM_ELEMENTS * 5];
char temp[8];
if (sizeof(mask_value) * 8 < size) {
size = sizeof(mask_value) * 8;
}
/* Only print ranges for 3 or more consecutive bits, otherwise
print individual numbers. */
str[0] = '\0';
for (i = 0; i < size; ++i) {
if (PLPA_CPU_ISSET(i, cpu_set)) {
/* This bit is set -- is it part of a longer series? */
/* Simple answer: if this is the last or next-to-last bit,
just print it */
if (i == size - 1 || i == size - 2) {
append(str, i);
continue;
}
/* Simple answer: if next bit is not set, then just print
it */
else if (!PLPA_CPU_ISSET(i + 1, cpu_set)) {
append(str, i);
continue;
}
/* Look for the next unset bit */
last_bit = i;
for (j = i + 1; j < size; ++j) {
if (!PLPA_CPU_ISSET(j, cpu_set)) {
last_bit = j - 1;
break;
}
}
/* If we fell off the end of the array without finding an
unset bit, then they're all set. */
if (j >= size) {
last_bit = size - 1;
}
if (i != last_bit) {
/* last_bit is now the last bit set after i (and it
might actually be i). So if last_bit > i+2, print
the range. */
if (last_bit >= i + 2) {
append(str, i);
strcat(str, "-");
snprintf(temp, sizeof(temp) - 1, "%d", (int) last_bit);
strcat(str, temp);
} else {
/* It wasn't worth printing a range, so print
i, and possibly print last_bit */
append(str, i);
if (last_bit != i) {
append(str, last_bit);
}
}
i = last_bit + 1;
}
}
}
return str;
}
static unsigned long long cpu_set_to_ll(const PLPA_NAME(cpu_set_t) *cpu_set)
{
size_t i, size = PLPA_BITMASK_NUM_ELEMENTS;
unsigned long long mask_value = 0;
if (sizeof(mask_value) * 8 < size) {
size = sizeof(mask_value) * 8;
}
for (i = 0; i < size; ++i) {
if (PLPA_CPU_ISSET(i, cpu_set)) {
mask_value += 1 << i;
}
}
return mask_value;
}
static int cpu_list_to_cpu_set(char *str, PLPA_NAME(cpu_set_t) *cpu_set)
{
int ret;
if (NULL == str) {
return 1;
}
parser_setup_string(str);
ret = token_parse(cpu_set);
return ret;
}
static int mask_to_cpu_set(char *mask_string, PLPA_NAME(cpu_set_t) *cpu_set)
{
size_t i;
unsigned int mask_value;
PLPA_CPU_ZERO(cpu_set);
sscanf(mask_string, "%x", &mask_value);
for (i = 0; i < sizeof(mask_value) * 8; ++i) {
if (0 != (mask_value & (1 << i))) {
PLPA_CPU_SET(i, cpu_set);
}
}
return 0;
}
static void run_test(int use_cpu_list, char *str)
{
int ret = 0;
PLPA_NAME(cpu_set_t) cpu_set;
PLPA_CPU_ZERO(&cpu_set);
if (use_cpu_list) {
if (0 == cpu_list_to_cpu_set(str, &cpu_set)) {
printf("in:%s\nout:%s\n", str, cpu_set_to_list(&cpu_set));
} else {
ret = 1;
}
} else {
if (0 == mask_to_cpu_set(str, &cpu_set)) {
printf("%s\n%llx\n", str, cpu_set_to_ll(&cpu_set));
} else {
ret = 1;
}
}
exit(ret);
}
static int get_pid_affinity(int use_cpu_list, char *pid_string)
{
int ret, pid = atoi(pid_string);
PLPA_NAME(cpu_set_t) cpu_set;
/* Check for the special pid_strings of "self" and "parent" */
if (0 == strcmp(pid_string, "self")) {
pid = getpid();
} else if (0 == strcmp(pid_string, "parent")) {
pid = getppid();
}
/* Report the affinity */
ret = PLPA_NAME(sched_getaffinity)((pid_t) pid, sizeof(cpu_set), &cpu_set);
switch (ret) {
case 0:
if (use_cpu_list) {
printf("pid %d's current affinity list: %s\n", pid,
cpu_set_to_list(&cpu_set));
} else {
printf("pid %d's current affinity mask: %llx\n", pid,
cpu_set_to_ll(&cpu_set));
}
break;
case ENOSYS:
printf("sched_getaffinity: processor affinity is not supported on this kernel\n");
printf("failed to get pid %d's affinity.\n", pid);
break;
default:
perror("sched_getaffinity");
printf("failed to get pid %d's affinity.\n", pid);
break;
}
return ret;
}
static int set_pid_affinity(int use_cpu_list, char *mask_string,
char *pid_string)
{
int ret, pid;
PLPA_NAME(cpu_set_t) cpu_set;
/* Print the original affinity */
ret = get_pid_affinity(use_cpu_list, pid_string);
if (0 != ret) {
return ret;
}
/* Convert the argv token mask string to a PLPA cpu set */
PLPA_CPU_ZERO(&cpu_set);
if (use_cpu_list) {
if (0 != (ret = cpu_list_to_cpu_set(mask_string, &cpu_set))) {
return ret;
}
} else {
if (0 != (ret = mask_to_cpu_set(mask_string, &cpu_set))) {
return ret;
}
}
/* Set the affinity */
/* Check for the special pid_strings of "self" and "parent" */
if (0 == strcmp(pid_string, "self")) {
pid = getpid();
} else if (0 == strcmp(pid_string, "parent")) {
pid = getppid();
} else {
pid = atoi(pid_string);
}
ret = PLPA_NAME(sched_setaffinity)((pid_t) pid, sizeof(cpu_set), &cpu_set);
switch (ret) {
case 0:
if (use_cpu_list) {
printf("pid %d's new affinity list: %s\n",
pid, cpu_set_to_list(&cpu_set));
} else {
printf("pid %d's new affinity mask: %llx\n",
pid, cpu_set_to_ll(&cpu_set));
}
break;
case ENOSYS:
printf("sched_setaffinity: processor affinity is not supported on this kernel\n");
printf("failed to set pid %d's affinity.\n", pid);
break;
default:
perror("sched_setaffinity");
printf("failed to set pid %d's affinity.\n", pid);
break;
}
return ret;
}
static int launch_task(int use_cpu_list, char **argv)
{
int ret, cmd_begins;
PLPA_NAME(cpu_set_t) cpu_set;
/* The next argument is the list/mask, optionally followed by
"--", then the argv to launch */
PLPA_CPU_ZERO(&cpu_set);
if (use_cpu_list) {
if (0 != (ret = cpu_list_to_cpu_set(argv[0], &cpu_set))) {
exit(ret);
}
} else {
if (0 != (ret = mask_to_cpu_set(argv[0], &cpu_set))) {
exit(ret);
}
}
if (0 != PLPA_NAME(sched_setaffinity)(getpid(), sizeof(cpu_set), &cpu_set)) {
perror("sched_setaffinity");
fprintf(stderr, "failed to set pid %d's affinity.\n", getpid());
}
/* The next argument may be "--". If so, ignore it */
if (0 == strcmp(argv[1], "--")) {
cmd_begins = 2;
} else {
cmd_begins = 1;
}
execvp(argv[cmd_begins], &argv[cmd_begins]);
/* If we get here, Something Bad Happened(tm) */
perror("execvp");
fprintf(stderr, "failed to execute %s\n", argv[cmd_begins]);
exit(1);
}
int main(int argc, char *argv[])
{
int option;
int getting_pid = 0;
int use_cpu_list = 0;
int testing = 0;
struct option options[] = {
{ "pid", 0, NULL, 'p' },
{ "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 }
};
while (-1 != (option = getopt_long(argc, argv, "+pchVt", options, NULL))) {
switch (option) {
case 'p':
getting_pid = 1;
break;
case 'c':
use_cpu_list = 1;
break;
case 'h':
show_help(argv[0], 0);
break;
case 'V':
show_version();
break;
case 't':
testing = 1;
break;
default:
show_help(argv[0], 1);
break;
}
}
/* No argv? Show the help. */
if (1 == argc) {
show_help(argv[0], 1);
}
/* Undocumented testing function */
if (testing) {
run_test(use_cpu_list, argv[optind]);
}
/* If we're getting_pid:
- If there's 1 argument, it's the PID to *get*
- If there's 2 arguments, it's the mask/list and the PID to *set*
- Otherwise, it's an error -- show the help message */
if (getting_pid) {
if (optind + 1 == argc) {
return get_pid_affinity(use_cpu_list, argv[optind]);
} else if (optind + 2 == argc) {
return set_pid_affinity(use_cpu_list,
argv[optind], argv[optind + 1]);
} else {
show_help(argv[0], 1);
}
}
/* Otherwise, it looks like we're launching a command */
launch_task(use_cpu_list, argv + optind);
/* We should never get here */
return 1;
}

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

@ -0,0 +1,32 @@
/*
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PLPA_TASKSET_H
#define PLPA_TASKSET_H
#include <plpa.h>
/*
* Function in flexer to set up the parser to read from a string
* (vs. reading from a file)
*/
void parser_setup_string(char* str);
/*
* Main bison parser.
*/
int token_parse(PLPA_NAME(cpu_set_t) *cpu_set);
/*
* Main flex parser
*/
int yylex(void);
#endif

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

@ -0,0 +1,26 @@
#!/usr/bin/env perl
use strict;
open(FILE, "test_cases.txt") or die "Can't open test_cases.txt file";
my $test_num = 1;
while (<FILE>) {
chomp;
/(\S+)\s+(\S+)/m;
my $in = $1;
my $expected_out = $2;
if ($in ne "") {
my $stdout = `./plpa_taskset -tc $in`;
chomp $stdout;
$stdout =~ /(.+?)\n(.+)/;
my $real_out = $2;
print "Test $test_num: ";
if ($real_out ne $expected_out) {
print "FAILED\n In: $in\n Out: $real_out\n Expected: $expected_out\n";
} else {
print "PASSED\n";
}
++$test_num;
}
}
close(FILE);

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

@ -0,0 +1,14 @@
3@1
1@all
all@1
all@2,all@3
all@{2,3}
{1,2}@{3,4,5}
{0-2}@{0-2,5}
all@all
## not{0@0}
not0@0
0@not0
{0-2}@not{1,2}
##not{0@even,1@odd}
not0@even,not1@odd

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

@ -0,0 +1,39 @@
0 0
2 2
0-2 0-2
0,2 0,2
0-2,4 0-2,4
0,2-4 0,2-4
0,2,4 0,2,4
0-2,4,6 0-2,4,6
0-2,4-6 0-2,4-6
0,2-4,6 0,2-4,6
0,2,4-6 0,2,4-6
0,2,4,6,8 0,2,4,6,8
0-2,4,6,8 0-2,4,6,8
0-2,4-6,8 0-2,4-6,8
0-2,4,6-8 0-2,4,6-8
0,2-4,6,8 0,2-4,6,8
0,2-4,6-8 0,2-4,6-8
0,2,4-6,8 0,2,4-6,8
0,2,4,6-8 0,2,4,6-8
0,1,2 0-2
0-2,3 0-3
0-2,3,4-5 0-5
0-2,3,4-6 0-6
0-4:1 0-4
0-4:2 0,2,4
0-4:3 0,3
0-4:2,6 0,2,4,6
0-4:1,5 0-5
0-4:1,5,6 0-6
0-4:2,6,8 0,2,4,6,8
0-4:2,6,7,8 0,2,4,6-8
0-4:2,6-8 0,2,4,6-8
0-4:2,6-8:2 0,2,4,6,8
0-4:2,6-10:2 0,2,4,6,8,10
0-4:2,6-10:2,8 0,2,4,6,8,10
0-4:2,6-10:2,9 0,2,4,6,8-10
0-4:2,6-10:2,13 0,2,4,6,8,10,13
0-4:2,6-10:2,13,15 0,2,4,6,8,10,13,15
0-31 0-31

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,64 +0,0 @@
/* A Bison parser, made by GNU Bison 1.875c. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
TOKENS_STRING_ALL = 258,
TOKENS_STRING_EVEN = 259,
TOKENS_STRING_ODD = 260,
TOKENS_STRING_NOT = 261,
TOKENS_NUMBER = 262
};
#endif
#define TOKENS_STRING_ALL 258
#define TOKENS_STRING_EVEN 259
#define TOKENS_STRING_ODD 260
#define TOKENS_STRING_NOT 261
#define TOKENS_NUMBER 262
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 59 "tokens.y"
typedef union YYSTYPE {
PLPA_NAME(cpu_set_t) cpu_set;
int number;
} YYSTYPE;
/* Line 1275 of yacc.c. */
#line 56 "tokens.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;

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

@ -0,0 +1,286 @@
%{
#include "plpa.h"
#include <stdio.h>
#include <stdlib.h>
#include "plpa-taskset.h"
/*
* Could this be done more efficiently? Absolutely.
*
* But this is neat, elegant, and easy to understand / maintain.
* Performance is not an issue here.
*/
/*
* Global functions
*/
int token_parse(PLPA_NAME(cpu_set_t) *cpu_set);
void yyerror(char const *s);
/*
* Local functions
*/
static void set_merge(PLPA_NAME(cpu_set_t) *out, PLPA_NAME(cpu_set_t) *a,
PLPA_NAME(cpu_set_t) *b);
static void set_copy(PLPA_NAME(cpu_set_t) *out, PLPA_NAME(cpu_set_t) *in);
static void cpu_set(PLPA_NAME(cpu_set_t) *out, int pos);
static void cpu_set_all(PLPA_NAME(cpu_set_t) *out);
static void cpu_set_even(PLPA_NAME(cpu_set_t) *out);
static void cpu_set_odd(PLPA_NAME(cpu_set_t) *out);
static void cpu_set_range(PLPA_NAME(cpu_set_t) *out, int min, int max);
static void cpu_compliment(PLPA_NAME(cpu_set_t) *out, PLPA_NAME(cpu_set_t) *in);
static void sc_merge(PLPA_NAME(cpu_set_t) *out, PLPA_NAME(cpu_set_t) *cores,
PLPA_NAME(cpu_set_t) *sockets);
/*
* Local variables
*/
static int socket_list[PLPA_BITMASK_CPU_MAX];
static PLPA_NAME(cpu_set_t) *return_value;
%}
%union {
PLPA_NAME(cpu_set_t) cpu_set;
int number;
}
%token <cpu_set> TOKENS_STRING_ALL
%token <cpu_set> TOKENS_STRING_EVEN
%token <cpu_set> TOKENS_STRING_ODD
%token <cpu_set> TOKENS_STRING_NOT
%token <number> TOKENS_NUMBER
%type <cpu_set> start
%type <cpu_set> cpu_list
%type <cpu_set> cpu_numbers
%type <cpu_set> cpu_strings
%type <cpu_set> sc_list
%type <cpu_set> sc_expr
%type <cpu_set> sc_item
%type <cpu_set> sc_item_list
%type <cpu_set> sc_strings
%% /* Grammar rules and actions follow. */
start: cpu_list
{ set_copy(return_value, &$1); }
| sc_list
{ set_copy(return_value, &$1); }
cpu_list: cpu_strings
{ set_copy(&$$, &$1); }
| cpu_numbers
{ set_copy(&$$, &$1); }
cpu_numbers: TOKENS_NUMBER
{ cpu_set(&$$, $1); }
| TOKENS_NUMBER '-' TOKENS_NUMBER
{ cpu_set_range(&$$, $1, $3); }
| cpu_list ',' TOKENS_NUMBER
{ PLPA_NAME(cpu_set_t) temp; cpu_set(&temp, $3); set_merge(&$$, &$1, &temp); }
| cpu_list ',' TOKENS_NUMBER '-' TOKENS_NUMBER
{ PLPA_NAME(cpu_set_t) temp; cpu_set_range(&temp, $3, $5); set_merge(&$$, &$1, &temp); }
cpu_strings: TOKENS_STRING_ALL
{ cpu_set_all(&$$); }
| TOKENS_STRING_EVEN
{ cpu_set_even(&$$); }
| TOKENS_STRING_ODD
{ cpu_set_odd(&$$); }
sc_list: sc_expr
{ set_copy(&$$, &$1); }
| sc_list ',' sc_expr
{ set_merge(&$$, &$1, &$3); }
sc_expr: sc_item '@' sc_item
{ sc_merge(&$$, &$1, &$3); }
sc_item: sc_strings
{ set_copy(&$$, &$1); }
| TOKENS_NUMBER
{ cpu_set(&$$, $1); }
| TOKENS_STRING_NOT TOKENS_NUMBER
{ PLPA_NAME(cpu_set_t) temp; cpu_set(&temp, $2); cpu_compliment(&$$, &temp); }
| TOKENS_STRING_NOT '{' sc_item_list '}'
{ cpu_compliment(&$$, &$3); }
| '{' sc_item_list '}'
{ set_copy(&$$, &$2); }
| '{' sc_strings '}'
{ set_copy(&$$, &$2); }
sc_item_list: TOKENS_NUMBER
{ cpu_set(&$$, $1); }
| TOKENS_NUMBER '-' TOKENS_NUMBER
{ cpu_set_range(&$$, $1, $3); }
| sc_item_list ',' TOKENS_NUMBER
{ PLPA_NAME(cpu_set_t) temp; cpu_set(&temp, $3); set_merge(&$$, &$1, &temp); }
| sc_item_list ',' TOKENS_NUMBER '-' TOKENS_NUMBER
{ PLPA_NAME(cpu_set_t) temp; cpu_set_range(&temp, $3, $5); set_merge(&$$, &$1, &temp); }
sc_strings: TOKENS_STRING_ALL
{ cpu_set_all(&$$); }
| TOKENS_STRING_EVEN
{ cpu_set_even(&$$); }
| TOKENS_STRING_ODD
{ cpu_set_odd(&$$); }
%%
int token_parse(PLPA_NAME(cpu_set_t) *cpu_set)
{
int ret;
PLPA_CPU_ZERO(cpu_set);
return_value = cpu_set;
ret = yyparse();
if (0 != ret) {
return ret;
}
return 0;
}
void yyerror (char const *s)
{
fprintf(stderr, "ERROR: %s\n", s);
}
static void set_merge(PLPA_NAME(cpu_set_t) *out, PLPA_NAME(cpu_set_t) *a,
PLPA_NAME(cpu_set_t) *b)
{
int i;
PLPA_CPU_ZERO(out);
for (i = 0; i < PLPA_BITMASK_CPU_MAX; ++i) {
if (PLPA_CPU_ISSET(i, a) || PLPA_CPU_ISSET(i, b)) {
PLPA_CPU_SET(i, out);
}
}
}
static void set_copy(PLPA_NAME(cpu_set_t) *out, PLPA_NAME(cpu_set_t) *in)
{
int i;
for (i = 0; i < PLPA_BITMASK_CPU_MAX; ++i) {
if (PLPA_CPU_ISSET(i, in)) {
PLPA_CPU_SET(i, out);
}
}
}
static void cpu_set(PLPA_NAME(cpu_set_t) *out, int pos)
{
PLPA_CPU_ZERO(out);
if (pos < PLPA_BITMASK_CPU_MAX) {
PLPA_CPU_SET(pos, out);
}
}
static void cpu_set_all(PLPA_NAME(cpu_set_t) *out)
{
int i;
PLPA_CPU_ZERO(out);
for (i = 0; i < PLPA_BITMASK_CPU_MAX; ++i) {
PLPA_CPU_SET(i, out);
}
}
static void cpu_set_even(PLPA_NAME(cpu_set_t) *out)
{
int i;
PLPA_CPU_ZERO(out);
for (i = 0; i < PLPA_BITMASK_CPU_MAX; i += 2) {
PLPA_CPU_SET(i, out);
}
}
static void cpu_set_odd(PLPA_NAME(cpu_set_t) *out)
{
int i;
PLPA_CPU_ZERO(out);
for (i = 1; i < PLPA_BITMASK_CPU_MAX; i += 2) {
PLPA_CPU_SET(i, out);
}
}
static void cpu_set_range(PLPA_NAME(cpu_set_t) *out, int min, int max)
{
int i;
PLPA_CPU_ZERO(out);
for (i = min; i < max && i < PLPA_BITMASK_CPU_MAX; ++i) {
PLPA_CPU_SET(i, out);
}
}
static void cpu_compliment(PLPA_NAME(cpu_set_t) *out, PLPA_NAME(cpu_set_t) *in)
{
int i;
PLPA_CPU_ZERO(out);
for (i = 0; i < PLPA_BITMASK_CPU_MAX; ++i) {
if (!PLPA_CPU_ISSET(i, in)) {
PLPA_CPU_SET(i, out);
}
}
}
static void sc_merge(PLPA_NAME(cpu_set_t) *out, PLPA_NAME(cpu_set_t) *cores,
PLPA_NAME(cpu_set_t) *sockets)
{
int i, core, socket, id, have_topo;
/* This is just about the only function that's tricky. Take a
bitmask representing all the cores and a bitmask representing
all the sockets and merge them into a single cpu_set_t
representing real CPU id's using the plpa_map_to_processor_id()
function. But error out if this system doesn't support the
topology information (because we won't be able to do the
mapping).
*/
PLPA_CPU_ZERO(out);
if (0 != PLPA_NAME(have_topology_information)(&have_topo) ||
0 == have_topo) {
fprintf(stderr, "ERROR: This system does not support topology information\n");
exit(1);
}
/* Even though I officially don't care about performance here,
intentionally putting in a loop that is
O(PLPA_BITMASK_CPU_MAX^2) gives me pause. :-) So scan through
the sockets array once and generate a list of the set bits in a
much shorter array. */
for (i = socket = 0; socket < PLPA_BITMASK_CPU_MAX; ++socket) {
if (PLPA_CPU_ISSET(socket, sockets)) {
socket_list[i++] = socket;
}
}
/* Bozo case: if there were no sockets set, we're done */
if (0 == i) {
return;
}
/* Otherwise, do the loop to create the mapping of sockets and
cores, seting the final bitmask. Yes, this is a double loop,
but hopefully it's much smaller than
PLPA_BITMASK_CPU_MAX^2. */
for (core = 0; core < PLPA_BITMASK_CPU_MAX; ++core) {
if (PLPA_CPU_ISSET(core, cores)) {
for (socket = 0; socket < i; ++socket) {
if (0 != PLPA_NAME(map_to_processor_id)(socket_list[socket],
core, &id)) {
fprintf(stderr, "ERROR: Failed to map %d@%d to processor ID\n",
core, socket);
exit(1);
}
printf("Setting id: %d\n", id);
PLPA_CPU_SET(id, out);
}
}
}
}

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

@ -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;
}

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

@ -695,31 +695,6 @@ internal_waitpid_callback(int fd, short event, void *arg)
#elif defined(__WINDOWS__)
static volatile int cb_enabled = true;
static opal_mutex_t mutex;
static opal_list_t pending_pids;
static opal_list_t registered_cb;
/*********************************************************************
*
* Wait Object Declarations
*
********************************************************************/
static void message_event_destructor(orte_message_event_t *ev)
{
OBJ_RELEASE(ev->buffer);
}
static void message_event_constructor(orte_message_event_t *ev)
{
ev->buffer = OBJ_NEW(opal_buffer_t);
}
OBJ_CLASS_INSTANCE(orte_message_event_t,
opal_object_t,
message_event_constructor,
message_event_destructor);
typedef struct {
opal_list_item_t super;
pid_t pid;
@ -787,15 +762,6 @@ orte_wait_finalize(void)
return ORTE_SUCCESS;
}
void orte_trigger_event(int trig)
{
int data=1;
write(trig, &data, sizeof(int));
opal_progress();
}
/**
* Internal function which find a corresponding process structure
* based on the pid. If create is true and the pid does not have a
@ -988,34 +954,6 @@ orte_wait_cb_enable(void)
return ORTE_SUCCESS;
}
int orte_wait_event(opal_event_t **event, int *trig,
void (*cbfunc)(int, short, void*))
{
int p[2];
if (pipe(p) < 0) {
ORTE_ERROR_LOG(ORTE_ERR_SYS_LIMITS_PIPES);
return ORTE_ERR_SYS_LIMITS_PIPES;
}
/* create the event */
*event = (opal_event_t*)malloc(sizeof(opal_event_t));
/* pass back the write end of the pipe */
*trig = p[1];
/* define the event to fire when someone writes to the pipe */
opal_event_set(*event, p[0], OPAL_EV_READ, cbfunc, NULL);
/* Add it to the active events, without a timeout */
opal_event_add(*event, NULL);
/* all done */
return ORTE_SUCCESS;
}
int
orte_wait_kill(int sig)
{