[gambit-list] SMP Gambit
Marc Feeley
feeley at iro.umontreal.ca
Sat Jan 28 20:16:31 EST 2017
I have just created the “smp” branch which contains a major refactoring of the thread scheduler to support parallel thread execution.
Please note that this is an experimental branch that omits some of the thread features of Gambit (thread priorities, thread interruption, etc). So you should avoid those features in your experiments, and don’t use the smp branch for production code!
I have done some quick testing on OS X and linux, on intel architecture. I’m interested in feedback on Windows and other processor architectures, ARM in particular. I have also only tried the GNU gcc C compiler.
There are special steps needed to build the smp branch. Here are the commands starting with a git clone:
git clone https://github.com/gambit/gambit.git
cd gambit
git checkout master
./configure
make -j4 latest-release
./configure --enable-single-host
make -j4 from-scratch
git checkout smp
cp gsc/_prims.scm gsc/_prims.scm-smp
cp gsc/_t-c-2.scm gsc/_t-c-2.scm-smp
git checkout master
cp gsc/_prims.scm-smp gsc/_prims.scm
cp gsc/_t-c-2.scm-smp gsc/_t-c-2.scm
make -j4
make bootstrap
git reset --hard
git checkout smp
make bootclean
./configure --enable-single-host --enable-multiple-threaded-vms
make -j4
make check
Preliminary performance testing on 4 and 64 core machines show good performance. Threaded fibonacci of 45, which creates 317810 threads and has a thread granularity of 0.2 ms, runs 7.96x faster when using 8 processors instead of 1, and it runs 30x faster when using 64 processors (see attached transcript).
So please give it a try and report any issues!
Marc
% gsc/gsc -:=. tfib.scm
% gsi/gsi -:p1 tfib
(time (tfib 45))
69957 ms real time
69983 ms cpu time (69249 user, 733 system)
9 collections accounting for 1811 ms real time (1577 user, 235 system)
521655584 bytes allocated
215447 minor faults
no major faults
1836311903
% gsi/gsi -:p8 tfib
(time (tfib 45))
8794 ms real time
70097 ms cpu time (69745 user, 353 system)
14 collections accounting for 200 ms real time (1307 user, 107 system)
104214752 bytes allocated
69552 minor faults
no major faults
1836311903
% gsi/gsi -:p64 tfib
(time (tfib 45))
2333 ms real time
143035 ms cpu time (141703 user, 1332 system)
8 collections accounting for 395 ms real time (18796 user, 992 system)
10612584 bytes allocated
29126 minor faults
no major faults
1836311903
% cat tfib.scm
(declare (standard-bindings) (not safe) (fixnum) (block))
(define (tfib n)
(if (< n 2)
1
(if (< n 20)
(+ (tfib (- n 1)) (tfib (- n 2)))
(let ((x (make-thread (lambda () (tfib (- n 1))))))
(thread-start! x)
(let ((y (tfib (- n 2))))
(+ (thread-join! x) y))))))
(pp (time (tfib 45)))
More information about the Gambit-list
mailing list