Discussion:
[gambit-list] Native backend
Marc Feeley
2018-09-29 19:29:56 UTC
Permalink
For those interested in how the native backend for Gambit is progressing, here are some links to the paper that was presented yesterday at the Scheme workshop, and the slides of the talk. Laurent Huberdeau did a great job!

http://www.iro.umontreal.ca/~gambit/SW2018-talk.pdf

https://www.brinckerhoff.org/scheme2018/papers/Huberdeau_Feeley.pdf

Marc
Alex Silva
2018-10-01 08:24:19 UTC
Permalink
Hallo,
Post by Marc Feeley
For those interested in how the native backend for Gambit is progressing, here are some links to the paper that was presented yesterday at the Scheme workshop, and the slides of the talk. Laurent Huberdeau did a great job!
This is very interesting! In which branch is this being developed? How
can we try it out?

Cheers,
--
-alex
https://unendli.ch/
Marc Feeley
2018-10-01 15:42:59 UTC
Permalink
Post by Alex Silva
Hallo,
Post by Marc Feeley
For those interested in how the native backend for Gambit is progressing, here are some links to the paper that was presented yesterday at the Scheme workshop, and the slides of the talk. Laurent Huberdeau did a great job!
This is very interesting! In which branch is this being developed? How
can we try it out?
Here are the steps (on a x86-64 platform):

% git checkout cpu
% ./configure --enable-single-host CC="gcc -D___SUPPORT_LOWLEVEL_EXEC"
% make
% cp bin/gambcomp-C bin/gambcomp-x86-64
% cat > fib.scm
(declare (standard-bindings) (block) (not safe))

(define (fib n)
(if (fx< n 2)
n
(fx+ (fib (fx- n 1))
(fib (fx- n 2)))))

(pp (time (fib 40)))
^D
% gsc/gsc -:=. -target x86-64 fib.scm
% gsi/gsi fib
(time (fib 40))
289 ms real time
288 ms cpu time (288 user, 0 system)
no collections
no bytes allocated
1 minor fault
no major faults
102334155
% gsc/gsc -:=. fib.scm
% gsi/gsi fib
(time (fib 40))
315 ms real time
316 ms cpu time (316 user, 0 system)
no collections
no bytes allocated
1 minor fault
no major faults
102334155

Here is a list of the primitives that are inlined by the native backend.
If you use other primitives, they will be actual calls to the runtime
library compiled with the C backend (i.e. slow). Remember that this is
work in progress and that some things are not yet optimized and some
things are unimplemented or broken.

##not
##identity

##fixnum?
##pair?
##null?
##char?
##special?
##mem-allocated?

##fx+
##fx+?
##fx-
##fx-?
##fx<
##fx<=
##fx>
##fx>=
##fx=

##cons
##car
##cdr
##set-car!
##set-cdr!

##vector-ref
##vector-set!
##vector-length

So at this point the native backend is more a “proof of concept” and there is still lots of work to be done before this is a practical alternative to the C backend.

Marc
Bradley Lucier
2018-10-01 20:58:42 UTC
Permalink
Post by Marc Feeley
Here is a list of the primitives that are inlined by the native backend.
If you use other primitives, they will be actual calls to the runtime
library compiled with the C backend (i.e. slow). Remember that this is
work in progress and that some things are not yet optimized and some
things are unimplemented or broken.
##not
##identity
##fixnum?
##pair?
##null?
##char?
##special?
##mem-allocated?
##fx+
##fx+?
##fx-
##fx-?
##fx<
##fx<=
##fx>
##fx>=
##fx=
##cons
##car
##cdr
##set-car!
##set-cdr!
##vector-ref
##vector-set!
##vector-length
So at this point the native backend is more a “proof of concept” and there is still lots of work to be done before this is a practical alternative to the C backend.
And here's roughly how many "primitives" there are in a backend:

heine:~/programs/gambit/gambit/gsc> grep '("##' _prims.scm | wc
459 3230 34354

Many of the remaining vector primitives (##u8vector-ref, ...) can be
modeled on the currently implemented primitives, but there are many
others that will require some thought. And perhaps many can remain
accessed in the existing C versions through the new "bridge" put
together by Marc and Laurent.

Once complex routines (beyond ack, fib, tak, ...) are tested, issues
about register allocation, etc. (all the things that are big issues in
any compiler) will become more important.

Brad

Continue reading on narkive:
Loading...