Skip to content

Commit

Permalink
New contrib: SB-GMP
Browse files Browse the repository at this point in the history
 This contrib was developed by Stephan Frank to replace some of our
 bignum and rational arithmetic code with calls to libgmp.  Simply
 loading the contrib will transparently accelerate arithmetic on
 large rationals when libgmp is available; if libgmp cannot be found,
 the contrib should change nothing.

 The contrib also wraps additional functions in GNU MP, so that they
 accept and return SBCL-native integers or ratios.  See GNU MP's manual
 for more information.
  • Loading branch information
pkhuong committed Jun 28, 2013
1 parent d30da16 commit 1656e54
Show file tree
Hide file tree
Showing 7 changed files with 1,191 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CREDITS
Expand Up @@ -588,6 +588,10 @@ Andreas Fuchs:
regressions of SBCL. He assisted with the integration of the
Unicode work.

Stephan Frank:
He contributed the SB-GMP contrib to exploit libgmp in bignum and
ratio arithmetic.

Nathan Froyd:
He has fixed various bugs, and also done a lot of internal
cleanup, not visible at the user level but important for
Expand Down Expand Up @@ -856,6 +860,7 @@ NS Nikodemus Siivola
PFD Paul F. Dietz
PRM Pierre Mai
PVE Peter Van Eynde
PK/PVK Paul-Virak Khuong
PW Paul Werkowski
RAM Robert MacLachlan
RLT Raymond Toy
Expand Down
2 changes: 2 additions & 0 deletions NEWS
@@ -1,5 +1,7 @@
;;;; -*- coding: utf-8; fill-column: 78 -*-
changes relative to sbcl-1.1.8:
* new feature: the contrib SB-GMP links with libgmp at runtime to speed
up arithmetic on bignums and ratios. (contributed by Stephan Frank)
* enhancement: disassemble now annotates some previously missing static
functions, like LENGTH.
* enhancement: clean.sh now also cleans doc/internals.
Expand Down
2 changes: 2 additions & 0 deletions contrib/sb-gmp/Makefile
@@ -0,0 +1,2 @@
SYSTEM=sb-gmp
include ../asdf-module.mk
39 changes: 39 additions & 0 deletions contrib/sb-gmp/README.md
@@ -0,0 +1,39 @@
SB-GMP
======

GMP integration for SBCL

This contrib enables the use of bignum computation routines from the
GMP library for SBCL internal bignum calculations.

Some functions can be transparently replaced within SBCL, namely:

- sb-bignum:multiply-bignum
- sb-bignum:bignum-truncate
- sb-bignum:bignum-gcd
- sb-kernel::two-arg-lcm
- cl:isqrt

and for making use of the GMP rational arithmetic:

- sb-kernel::two-arg-+
- sb-kernel::two-arg--
- sb-kernel::two-arg-*
- sb-kernel::two-arg-/

Most of the other SBCL bignum routines rely on these functions for the
heavy computational lifting.

However, SB-GMP also provides easy and transparent access to several
other functions of the GMP library and may be able to replace other
parts of the SBCL bignum machinery in the future. Refer to the GMP
documentation for the respective function specification.

The transparent SBCL integration is automatically activated by loading
SB-GMP. Some care is taken to behave correctly across core saves and
loads; however, if this does not work correctly, `SB-GMP:UNLOAD-GMP`
and `SB-GMP:LOAD-GMP` can be called to explicitly unload and reload
libgmp and uninstall/reinstall the hooks. The hooks can also be
directly uninstalled and installed with `SB-GMP:UNINSTALL-GMP-FUNS`
and `SB-GMP:INSTALL-GMP-FUNS`. However, in most cases, binding
`SB-GMP:*GMP-DISABLED*` to `T` should suffice.

0 comments on commit 1656e54

Please sign in to comment.