Bakul Shah wrote a particularly elegant Scheme program for Chudnovskys'
algorithm for pi based on the Common Lisp program here:
https://bitbucket.org/tarballs_are_good/numericl/src/5fe8fe7089f48ab1c8a388…
Nick Craig-Wood wrote a Python program using the GMP multiprecision
library that appears to use exactly the same algorithm here:
http://www.craig-wood.com/nick/articles/pi-chudnovsky/
I modified both programs a bit and include them here.
They time the calculation of $10^n$ digits of pi for $n=1,2,3,4,5,6,7$.
The results are
heine:~/programs/gambiteer/gambit> !py
python pi_chudnovsky_bs_gmpy.py
31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
('chudnovsky_gmpy_mpz_bs: digits', 10, 'time', 1.0967254638671875e-05)
('chudnovsky_gmpy_mpz_bs: digits', 100, 'time', 3.0040740966796875e-05)
Last 5 digits 70679 OK
('chudnovsky_gmpy_mpz_bs: digits', 1000, 'time', 0.00025582313537597656)
Last 5 digits 01989 OK
('chudnovsky_gmpy_mpz_bs: digits', 10000, 'time', 0.00386810302734375)
Last 5 digits 75678 OK
('chudnovsky_gmpy_mpz_bs: digits', 100000, 'time', 0.0834801197052002)
Last 5 digits 24646 OK
('chudnovsky_gmpy_mpz_bs: digits', 1000000, 'time', 1.655979871749878)
Last 5 digits 58151 OK
('chudnovsky_gmpy_mpz_bs: digits', 10000000, 'time', 30.67442488670349)
Last 5 digits 55897 OK
heine:~/programs/gambiteer/gambit> gsi chud1.scm
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits
10, CPU time: 0..
Last 5 digits 26535.
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits
100, CPU time: 0..
Last 5 digits 70679.
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits
1000, CPU time: .004.
Last 5 digits 1989.
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits
10000, CPU time: .028.
Last 5 digits 75678.
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits
100000, CPU time: .472.
Last 5 digits 24646.
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits
1000000, CPU time: 6.448.
Last 5 digits 58151.
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits
10000000, CPU time: 98.612.
Last 5 digits 55897.
So it appears that for this algorithm applied to large integers, GMP's
bignum routines are about 3-4 times as fast as Gambit's bignum
routines. Not so bad. For smaller bignums, GMP has a bigger advantage.
The C program gmp-chudnovsky.c includes certain optimizations to this
basic algorithm:
http://gmplib.org/pi-with-gmp.htmlftp://ftp.gmplib.org/pub/misc/gmp-chudnovsky.c
On my machine, compiled with
gcc -O3 -march=native -o gmp-chudnovsky gmp-chudnovsky.c -lgmp -lm
the CPU times for 1,000,000 and 10,000,000 digits are 1.064 and 18.200
seconds, respectively.
This is with a somewhat older machine
model name : Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz
running Ubuntu 13.04 with
heine:~/programs/gambiteer/gambit> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.7.3-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib
--enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --enable-plugin --with-system-zlib
--enable-objc-gc --with-cloog --enable-cloog-backend=ppl
--disable-cloog-version-check --disable-ppl-version-check
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)
heine:~/programs/gambiteer/gambit> gsi -v
v4.6.9 20130607151908 x86_64-unknown-linux-gnu "./configure
'--enable-single-host' '--enable-multiple-versions' '--enable-shared'"
and the Ubuntu-provided GMP 5.0.5. (I'm sure the GMP folks have a
better way to build GMP on my machine than the "generic" 64-bit version
provided by Ubuntu.)
Brad
Hello. I have been preparing the next release of Gambit and the work is close to be done. As far as I can see most of what remains to be done are additional changes to the documentation, mostly concerning modules. I will concentrate on that these next few days.
I would greatly appreciate some external testing of commit 5c8e698ed97ab0cefc1938214a481e666c76349d . Of particular importance is trying various combinations of configure options on different operating systems and C compilers.
Many things have been added since v4.9.3 which was released in 2019. Here are the main changes:
- Better R7RS conformance (not quite 100% conformance but close)
- Performance enhancements, in particular a new C trampoline that improves the speed of interpretation and intermodule jumps
- A module system which supports “primitive” modules and R7RS modules
- Decentralized package distribution and installation based on git (try: gsi github.com/gambit/hello/demo)
- A growing set of builtin modules including popular SRFIs
- A production quality JavaScript backend with “infix” FFI
- A web version of the Gambit interpreter (currently available on try.scheme.org)
- A more thorough “make check" that now verifies that module exports are complete and consistent
- A new website (temporarily available as staging.gambitscheme.org)
- The “Forensics” system to track the performance over the commit history (see forensics.gambitscheme.org)
Notice that the build procedure is still basically “git clone …;./configure;make”. There is no need for an explicit “make modules” as this is part of the normal build procedure. If you want to avoid building the modules you can “make core”. Moreover the JavaScript backend is built by default (this can be disabled with a “--enable-targets=” configure option). The JavaScript backend supports the gsc -exe option to create a script that uses nodejs, or a .html file that can be viewed with a browser, for example:
$ cat hello.scm
(pp (list 'hello (expt 2 200))) (read)
$ gsc -target js -exe -o hello.exe hello.scm
$ ./hello.exe
(hello 1606938044258990275541962092341162602522202993782792835301376)
$ gsc -target js -exe -o hello.html hello.scm
$ open hello.html
Your feedback is welcome!
Marc
CALL FOR WORKSHOP AND CO-LOCATED EVENT PROPOSALS
ICFP 2022
27th ACM SIGPLAN International Conference on Functional Programming
September 11 - 16, 2022
Ljubljana, Slovenia
https://icfp22.sigplan.org/
The 27th ACM SIGPLAN International Conference on Functional
Programming will be held in Ljubljana, Slovenia on September 11 - 16,
2022, with the option of virtual participation. ICFP provides a forum
for researchers and developers to hear about the latest work on the
design, implementations, principles, and uses of functional
programming.
Proposals are invited for workshops (and other co-located events, such
as symposiums) to be affiliated with ICFP 2022 and sponsored by
SIGPLAN. These events should be less formal and more focused than ICFP
itself, include sessions that enable interaction among the attendees,
and foster the exchange of new ideas. The preference is for one-day
events, but other schedules can also be considered.
The workshops are scheduled to occur on September 11th (the day before
ICFP) and September 15-16th (the two days after ICFP).
----------------------------------------------------------------------
Submission details
Deadline for submission: December 24, 2021
Notification of acceptance: January 10, 2022
Prospective organizers of workshops or other co-located events are
invited to submit a completed workshop proposal form in plain text
format to the ICFP 2022 workshop co-chairs (Arthur Azevedo de Amorim
and Zoe Paraskevopoulou) via email to
icfp-workshops-2022(a)googlegroups.com
by December 24, 2021. (For proposals of co-located events other than
workshops, please fill in the workshop proposal form and just leave
blank any sections that do not apply.) Please note that this is a firm
deadline.
Organizers will be notified if their event proposal is accepted by
January 10, 2022, and if successful, depending on the event, they
will be asked to produce a final report after the event has taken
place that is suitable for publication in SIGPLAN Notices.
The proposal form is available at:
http://www.icfpconference.org/icfp2022-files/icfp22-workshops-form.txt
Further information about SIGPLAN sponsorship is available at:
http://www.sigplan.org/Resources/Proposals/Sponsored/
----------------------------------------------------------------------
Selection committee
The proposals will be evaluated by a committee comprising the
following members of the ICFP 2022 organizing committee, together with
the members of the SIGPLAN executive committee.
Workshop Co-Chair: Arthur Azevedo de Amorim (Boston University)
Workshop Co-Chair: Zoe Paraskevopoulou (Northeastern University)
General Chair: Andrej Bauer (University of Ljubljana)
Program Chair: Zena Ariola (University of Oregon)
----------------------------------------------------------------------
Further information
Any queries should be addressed to the workshop co-chairs (Arthur
Azevedo de Amorim and Zoe Paraskevopoulou), via email to
icfp-workshops-2022(a)googlegroups.com.