On 12/11/2016 08:29 AM, Marc Feeley wrote:
That will be a perfect use case for the multiple-threaded VM.
That's why I told you about it, to tempt you ;-).
Can you write a parallel version of the algorithm, using thread-start! and thread-join! to manage the parallelism? You can test it on a single-threaded VM and then I can give it a try here on a 64 processor machine.
You want me to do the work and you to have the fun!
More seriously, I just looked through the thread section of the Gambit manual and I do not yet understand the thread model that you've built into Gambit. So I don't know how to do what you want.
I'm attaching the single-threaded code. It has the lines
(let* ((mid (quotient (+ a b) 2)) (gpq1 (ch-split a mid)) ;<<<<==== (gpq2 (ch-split mid b)) ;<<<<==== (g1 (car gpq1)) (p1 (cadr gpq1)) (q1 (caddr gpq1)) (g2 (car gpq2)) (p2 (cadr gpq2)) (q2 (caddr gpq2)))
The two calls to ch-split can be made in parallel.
I recommend introducing a parameter M and running those two calls in parallel if $b-a>M$. M is the number of terms to be computed in the partial series at that point; M of the order of 10,000 or so should work.
The resulting code might be a good extended example for the manual.
Sorry I can't be more help.
Brad
PS: By the way, a partial run in the interpreter on my linux box at home yields
firefly:~/programs/gambit/gambiteer> gsi chud2 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: 0.. Last 5 digits 1989. Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 10000, CPU time: .012. Last 5 digits 75678. Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 100000, CPU time: .216. Last 5 digits 24646. Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 1000000, CPU time: 3.0439999999999996. Last 5 digits 58151. Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 10000000, CPU time: 47.112. Last 5 digits 55897.