The GNU C library includes several header files, each of which provides definitions and declarations for a group of related facilities; this information is used by the C compiler when processing your program. GNU C library (glibc) is one of the most important components of GNU Hurd and most modern GNU/Linux distributions. It is used by almost all C programs and provides the most essential APIs, including the C standard library and other standard libraries.
GSL - GNU Scientific Library
Introduction
The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers. It is free software under the GNU General Public License.
The library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting. There are over 1000 functions in total with an extensive test suite.
The complete range of subject areas covered by the library includes,
Complex Numbers | Roots of Polynomials |
Special Functions | Vectors and Matrices |
Permutations | Sorting |
BLAS Support | Linear Algebra |
Eigensystems | Fast Fourier Transforms |
Quadrature | Random Numbers |
Quasi-Random Sequences | Random Distributions |
Statistics | Histograms |
N-Tuples | Monte Carlo Integration |
Simulated Annealing | Differential Equations |
Interpolation | Numerical Differentiation |
Chebyshev Approximation | Series Acceleration |
Discrete Hankel Transforms | Root-Finding |
Minimization | Least-Squares Fitting |
Physical Constants | IEEE Floating-Point |
Discrete Wavelet Transforms | Basis splines |
Running Statistics | Sparse Matrices and Linear Algebra |
Unlike the licenses of proprietary numerical libraries the license of GSL does not restrict scientific cooperation. It allows you to share your programs freely with others.
Downloading GSL
The current stable version is GSL-2.6. It was released on 20 August 2019. Details of recent changes can be found in the NEWS file.
GSL can be found in the gsl subdirectory on your nearest GNU mirror http://ftpmirror.gnu.org/gsl/.
- Main GNU ftp site: ftp://ftp.gnu.org/gnu/gsl/
For other ways to obtain GSL, please read How to get GNU Software
Installation instructions can be found in the included README and INSTALL files.
Precompiled binary packages are included in most GNU/Linux distributions.
A compiled version of GSL is available as part of Cygwin on Windows.
Verifying GSL Signature
To verify the signature of the GSL tarball, please download both the gsl-X.Y.tar.gz and gsl-X.Y.tar.gz.sig files. The key used to sign the official releases can be found here.
The signature can be verified with the following steps:
Documentation
GSL includes a reference manual in reStructuredText format. You can view the manual in HTML and PDF, or read it on your system using the shell command info gsl-ref (if the library is installed).
The GSL Reference Manual is available online,
The manual has been published as a printed book (under the GNU Free Documentation License), the latest edition is
GNU Scientific Library Reference Manual - Third Edition (January 2009),
M. Galassi et al, ISBN 0954612078 (paperback) RRP $39.95.
See www.network-theory.co.uk for ordering information.
A Japanese translation is also available online (may not be the most recent version).
- GSL Reference Manual - Japanese Translation (by Daisuke Tominaga, AIST Computational Biology Research Center)
A Portuguese translation is also available online.
- GSL Reference Manual - Portuguese Translation (by Jorge Barros de Abreu)
Donate
If you use and value GSL please consider a donation to help us improve the library.
Supported Platforms
GSL is developed on the following platform,
- GNU/Linux with gcc
It has been reported to compile on the following other platforms,
- SunOS 4.1.3 & Solaris 2.x (Sparc)
- Alpha GNU/Linux, gcc
- HP-UX 9/10/11, PA-RISC, gcc/cc
- IRIX 6.5, gcc
- m68k NeXTSTEP, gcc
- Compaq Alpha Tru64 Unix, gcc
- FreeBSD, OpenBSD & NetBSD, gcc
- Cygwin
- Apple Darwin 5.4
- Hitachi SR8000 Super Technical Server, cc
- Microsoft Windows
Several people have contributed tools to allow GSL to be easily built on Windows platforms. More information can be found here.
We require that GSL should build on any UNIX-like system with an ANSI C compiler, so if doesn't, that's a bug and we would love a patch! The complete library should also pass 'make check'.
Gnu C Standard Library
If you have found a bug, please report it to bug-gsl@gnu.org.
Previously submitted bug reports can be found in the bug-gsl mailing list archives and the GSL bug database.
Mailing Lists
Follow the links to the individual mailing lists below to subscribe or view the list archives:
- Bug-gsl <bug-gsl@gnu.org> mailing list -- bug reports for the GNU Scientific Library should be sent here
- Help-gsl <help-gsl@gnu.org> users mailing list -- for questions about installation, how GSL works and how it is used, or general questions concerning GSL.
- Info-gsl <info-gsl@gnu.org> mailing list -- announcements of new releases are made here.
You can also follow announcements via the Savannah GSL RSS feed.
Motivation
Here are some of the main benefits of using a free scientific library under the GNU General Public License,
- allows easier collaboration, library is freely available to everyone.
- software using the library can be released publicly as source-code.
- you can adapt the source code to your needs.
- respects your privacy - does not impose any conditions on 'in-house' use.
- you can contribute back improvements to the user community.
Special Features
The library uses an object-oriented design. Different algorithms can be plugged-in easily or changed at run-time without recompiling the program.
It is intended for ordinary scientific users. Anyone who knows some C programming will be able to start using the library straight-away.
The interface was designed to be simple to link into very high-level languages, such as GNU Guile or Python
The library is thread-safe.
Where possible the routines have been based on reliable public-domain Fortran packages such as FFTPACK and QUADPACK, which the developers of GSL have reimplemented in C with modern coding conventions.
The library is easy to compile and does not have any dependencies on other packages.
Licensing
GSL is distributed under the terms of the GNU General Public License (GPL).
The reasons why the GNU Project uses the GPL are described in the following articles:
- Copyleft: Pragmatic Idealism by Richard Stallman
- Why you should not use the Lesser GPL for your next library by Richard Stallman
Additional information for researchers is available in the following article:
- Releasing Free Software if you work at a University by Richard Stallman
Some answers to common questions about the license:
If I write an application which uses GSL, am I forced to distribute that application?
No. The license gives you the option to distribute your application if you want to. You do not have to exercise this option in the license.
If I wanted to distribute an application which uses GSL, what license would I need to use?
The GNU General Public License (GPL).
The bottom line for commercial users:
GSL can be used internally ('in-house') without restriction, but only redistributed in other software that is under the GNU GPL.
More Information
If you would like to refer to the GNU Scientific Library in a journal article, the recommended way is to cite the reference manual, e.g. M. Galassi et al, GNU Scientific Library Reference Manual (3rd Ed.), ISBN 0954612078.
If you want to give a url, use 'http://www.gnu.org/software/gsl/'.
Related Packages
GSL requires a BLAS library for vector and matrix operations. The default CBLAS library supplied with GSL can be replaced by the tuned ATLAS library for better performance,
- ATLAS - a portable self-optimising BLAS library with CBLAS interface
ATLAS is free software and its license is compatible with the GNU GPL.
Other packages that are useful for scientific computing are:
- GLPK - GNU Linear Programming Kit
- FFTW - Large-scale Fast Fourier Transforms
- NLopt - nonlinear optimization with unconstrained, bound-constrained, and general nonlinear inequality constraints
All these packages are free software (GNU GPL/LGPL).
Development
GSL development is hosted on Savannah.gnu.org at http://savannah.gnu.org/projects/gsl
The repository is available via 'git' with
Note: if you use git, you will need automake, autoconf, libtool, GNU m4, GNU make, and GNU Texinfo (makeinfo).
To begin the build process from a checkout, start with: ./autogen.sh
which will prepare the package for compilation. You can then use ./configure --enable-maintainer-mode
and make
in the usual way.
Commit notifications are available through the git repository news feed.
In addition to the GSL Reference Manual, anyone wanting to work on the library should read the GSL design document,
GSL is a mature library with a stable API. The main emphasis is on ensuring the stability of the existing functions, tidying up and fixing any bugs that are reported, and adding new, useful algorithms which have been well tested and documented. Potential contributors are encouraged to gain familiarity with the library by investigating and fixing known problems in the BUGS database.
The project is always looking to introduce new capabilities and expand or improve existing functionality. To maintain stability, any new functionality is encouraged as packages, built on top of GSL and maintained independently by their authors, as in other free software projects. The design of GSL permits extensions to be used alongside the existing library easily by simple linking. Once a new extension is proven useful and stable, it can be incorporated into the main GSL repository.
Discussions about the development of the library take place on the gsl-discuss@sourceware.org mailing list. Any comments from experts in numerical analysis are welcome. You can subscribe to gsl-discuss here.
GSL is part of the GNU Project and so follows the GNU Coding Standards.
Extensions/Applications
The following third-party packages provide extensions to GSL.
If you want to add a feature to GSL we recommend that you make it an extension first. We will list it here so that people can try it out. Extensions can be incorporated after they have been tested in real use (see 'How to help' for more information).
- MIXMAX - MIXMAX generator of psuedo-random numbers (http://mixmax.hepforge.org)
- quasimontecarlo - quasi-Monte Carlo integration routines (David Zaslavsky)
- ISVD - Incremental Singular Value Decomposition (Attila Axt)
- Marray and Tensor - extensions for multidimensional arrays and tensors (Jordi Burguet Castell)
- ndlinear - simpler interface for N-dimensional least squares fits (Patrick Alken)
- Annealing - reworking of simulating annealing with new API (alpha - Marco Maggi)
- jacobi-0.9 - Jacobi polynomials and operations related to Gauss-jacobi quadrature (integration, derivatives and interpolation) (Paulo Jabardo)
- Ziggurat Gaussian - faster gaussian generator using Ziggurat method (Jochen Voss) -- now incorporated in GSL 1.8
- wigner.c - alternative Wigner coefficient calculations (large j) (J. Underwood)
- adaptint.c - adaptive multidimensional integration, similar to cubpack (Steven G. Johnson)
- jsqrng - higher dimensional quasi-random sequences (J. Scott)
- qrngextra - extended dimensionality QRNGs (Philipp Baecker)
- CQP - solves convex quadratic problems (Ewgenij Hübner)
- Bundle - powerful bundle minimisation algorithm (needs CQP) (Ewgenij Hübner - upgraded to v1.2, Oct 2006)
- Geczy - additional minimisation algorithms (Peter Geczy)
- Quartic - quartic polynomial solver (Andrew Steiner)
- Fresnel - sine and cosine fresnel integrals (Aleksey Dmitriev)
- SimplexImproved - alternative simplex minimiser (Ivo Alxneit)
- TAMUANOVA - the TAMU ANOVA package, provides single and two factor ANOVA.
- OOL - the 'Open Optimization Library', provides GSL-compatible constrained optimization methods (under development).
- rngextra-0.2 - additional random number generators (Brian Gough, example package)
Other packages:
- Dieharder - extensive random number test suite for GSL based on Marsaglia's Diehard tests and the NIST Statistical Test Suite (Robert G. Brown)
- VFGEN - generates C source code for GSL ODE systems from a user-supplied specification of a vector field (Warren Weckesser)
Some applications using GSL that we know of:
- GSL Shell (Lua) - interface to GSL routines using the Lua scripting language.
- NEMO -N-body stellar dynamics toolbox, a unix-like toolset of libraries and programs, also has tools to operate on ascii tables and other types of data
- LUSH - Lisp Universal Shell, an object-oriented programming language with full interfaces to GSL, LAPACK, and BLAS.
- NumExp - interactive graphical exploration of numerical functions and algorithms (uses Gtk)
- LabPlot - software for data analysis and visualisation
- Qumax - a Quantum Monte Carlo Software for Atoms, Molecules and Solids
- ORSA - Orbit Reconstruction, Simulation and Analysis.
- QtiPlot - scientific plotting and data analysis application
- Rlabplus - libraries for Rlab, a high-level language for numerics
- Blahut - computes information theoretic rate-distortion and channel capacity
Wrappers for Other Languages (not necessarily complete):
- JavaCPP - Java wrappers for GSL
- Math::GSL - Perl interface to GSL
- VALA - VALA bindings for GSL
- GSLL - Common Lisp interface to GSL
- FGSL - Fortran interface to GSL (under development)
- PyGSL - Python Bindings for GSL
- PyrexGsl - Pyrex interface to GSL (Pyrex is a version of Python which allows mixing of Python and C datatypes)
- ctypesGsl - Python ctypes-style interface to GSL (under development)
- Ruby/GSL - Ruby Bindings for GSL
- PDL::GSL - Perl Data Language interface to GSL Random Numbers (included in the main PDL distribution)
- R gsl - package, bindings for GSL special functions in GNU R
- RcppGSL - package, bindings for GSL special functions in GNU R
- S-lang/GSL - bindings for GSL and S-Lang
- Zoom - C++ wrappers for GSL special functions
- OCAML GSL - bindings for the OCAML functional language
- O2scl - a numerical C++ class library which is compatible with GSL datatypes (A.Steiner)
Textbooks:
- 'Numerische Physik', 2nd edition, by Harald Wiedemann (ISBN 978-3-662-58186-5, Published by Springer (2019), 360 pages, in German)
A textbook on numerical physics, covering classical mechanics, electrodynamics, optics, statistical physics and quantum mechanics. The example programs in the book use the GNU Scientific Library and are free software (the source code can be downloaded from the Springer site below).
Further information about this book is available from the publisher at springer.com.
Project Background
The project was conceived in 1996 by Dr M. Galassi and Dr J. Theiler of Los Alamos National Laboratory.
They were joined by other physicists who also felt that the licenses of existing libraries were hindering scientific cooperation.
Most of the library has been written by a relatively small number of people with backgrounds in computational physics in order to provide a consistent and reasonably-designed framework.
Overall development of the library and the design and implementation of the major modules was carried out by Dr G. Jungman and Dr B. Gough. Modules were also written by Dr J. Davies, R. Priedhorsky, Dr M. Booth, Dr F. Rossi, and Dr P. Alken, along with many useful contributions from others in the user community. Debian packages for the library are maintained by Dr D. Eddelbuettel.
Release History
- gsl-2.6 was released in August 2019.
- gsl-2.5 was released in June 2018.
- gsl-2.4 was released in June 2017.
- gsl-2.3 was released in December 2016.
- gsl-2.2.1 was released in August 2016.
- gsl-2.2 was released in August 2016.
- gsl-2.1 was released in November 2015.
- gsl-2.0 was released in October 2015.
- gsl-1.16 was released in July 2013.
- gsl-1.15 was released in May 2011.
- gsl-1.14 was released in March 2010.
- gsl-1.13 was released in September 2009.
- gsl-1.12 was released in December 2008.
- gsl-1.11 was released in March 2008.
- gsl-1.10 was released in September 2007.
- gsl-1.9 was released in February 2007.
- gsl-1.8 was released in April 2006.
- gsl-1.7 was released in September 2005.
- gsl-1.6 was released in December 2004.
- gsl-1.5 was released in June 2004.
- gsl-1.4 was released in August 2003.
- gsl-1.3 was released in December 2002.
- gsl-1.2 was released in July 2002.
- gsl-1.1.1 was released in March 2002.
- gsl-1.1 was released in February 2002.
- gsl-1.0 was released in November 2001.
- gsl-0.9.4 was released in October 2001 (fifth beta-test release).
- gsl-0.9.3 was released in September 2001 (fourth beta-test release).
- gsl-0.9.2 was released in September 2001 (third beta-test release).
- gsl-0.9.1 was released in August 2001 (second beta-test release).
- gsl-0.9 was released in July 2001 (first beta-test release).
- gsl-0.8 was released in May 2001.
- gsl-0.7 was released in October 2000.
- gsl-0.6 was released in June 2000.
- gsl-0.5 was released in December 1999.
- gsl-0.4.1 was released in February 1999.
- gsl-0.4 was released in August 1998.
- gsl-0.3f was released in May 1998.
- gsl-0.3b was released in February 1998.
- gsl-0.2 was released in October 1996.
- gsl-0.1 was released in sometime in 1996.
- gsl-0.0 was released in sometime in 1996.
- The gsl project was started in May 1996 (earliest recorded changelog entry).
Previous: Traditional Scheduling, Up: Priority [Contents][Index]
22.3.5 Limiting execution to certain CPUs
On a multi-processor system the operating system usually distributesthe different processes which are runnable on all available CPUs in away which allows the system to work most efficiently. Which processesand threads run can be to some extend be control with the schedulingfunctionality described in the last sections. But which CPU finallyexecutes which process or thread is not covered.
There are a number of reasons why a program might want to have controlover this aspect of the system as well:
- One thread or process is responsible for absolutely critical workwhich under no circumstances must be interrupted or hindered frommaking progress by other processes or threads using CPU resources. Inthis case the special process would be confined to a CPU which noother process or thread is allowed to use.
- The access to certain resources (RAM, I/O ports) has different costsfrom different CPUs. This is the case in NUMA (Non-Uniform MemoryArchitecture) machines. Preferably memory should be accessed locallybut this requirement is usually not visible to the scheduler.Therefore forcing a process or thread to the CPUs which have localaccess to the most-used memory helps to significantly boost theperformance.
- In controlled runtimes resource allocation and book-keeping work (forinstance garbage collection) is performance local to processors. Thiscan help to reduce locking costs if the resources do not have to beprotected from concurrent accesses from different processors.
The POSIX standard up to this date is of not much help to solve thisproblem. The Linux kernel provides a set of interfaces to allowspecifying affinity sets for a process. The scheduler willschedule the thread or process on CPUs specified by the affinitymasks. The interfaces which the GNU C Library define follow to someextent the Linux kernel interface.
This data set is a bitset where each bit represents a CPU. How thesystem’s CPUs are mapped to bits in the bitset is system dependent.The data type has a fixed size; in the unlikely case that the numberof bits are not sufficient to describe the CPUs of the system adifferent interface has to be used.
This type is a GNU extension and is defined in sched.h.
To manipulate the bitset, to set and reset bits, a number of macros aredefined. Some of the macros take a CPU number as a parameter. Hereit is important to never exceed the size of the bitset. The followingmacro specifies the number of bits in the cpu_set_t
bitset.
The value of this macro is the maximum number of CPUs which can behandled with a cpu_set_t
object.
The type cpu_set_t
should be considered opaque; allmanipulation should happen via the next four macros.
Preliminary:| MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
This macro initializes the CPU set set to be the empty set.
This macro is a GNU extension and is defined in sched.h.
Preliminary:| MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
This macro adds cpu to the CPU set set.
The cpu parameter must not have side effects since it isevaluated more than once.
This macro is a GNU extension and is defined in sched.h.
Preliminary:| MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
This macro removes cpu from the CPU set set.
The cpu parameter must not have side effects since it isevaluated more than once.
This macro is a GNU extension and is defined in sched.h.
Preliminary:| MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
This macro returns a nonzero value (true) if cpu is a memberof the CPU set set, and zero (false) otherwise.
The cpu parameter must not have side effects since it isevaluated more than once.
This macro is a GNU extension and is defined in sched.h.
CPU bitsets can be constructed from scratch or the currently installedaffinity mask can be retrieved from the system.
Preliminary:| MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
This function stores the CPU affinity mask for the process or threadwith the ID pid in the cpusetsize bytes long bitmappointed to by cpuset. If successful, the function alwaysinitializes all bits in the cpu_set_t
object and returns zero.
If pid does not correspond to a process or thread on the systemthe or the function fails for some other reason, it returns -1
and errno
is set to represent the error condition.
ESRCH
No process or thread with the given ID found.
EFAULT
The pointer cpuset does not point to a valid object.
This function is a GNU extension and is declared in sched.h.
Note that it is not portably possible to use this information toretrieve the information for different POSIX threads. A separateinterface must be provided for that.
Preliminary:| MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
This function installs the cpusetsize bytes long affinity maskpointed to by cpuset for the process or thread with the ID pid.If successful the function returns zero and the scheduler will in the futuretake the affinity information into account.
If the function fails it will return -1
and errno
is setto the error code:
ESRCH
No process or thread with the given ID found.
EFAULT
The pointer cpuset does not point to a valid object.
EINVAL
The bitset is not valid. This might mean that the affinity set mightnot leave a processor for the process or thread to run on.
This function is a GNU extension and is declared in sched.h.
Preliminary:| MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
The getcpu
function identifies the processor and node on whichthe calling thread or process is currently running and writes them intothe integers pointed to by the cpu and node arguments. Theprocessor is a unique nonnegative integer identifying a CPU. The nodeis a unique nonnegative integer identifying a NUMA node. When eithercpu or node is NULL
, nothing is written to therespective pointer.
The return value is 0
on success and -1
on failure. Thefollowing errno
error condition is defined for this function:
ENOSYS
The operating system does not support this function.
This function is Linux-specific and is declared in sched.h.
Gnu C Library On Mac Download
Previous: Traditional Scheduling, Up: Priority [Contents][Index]