On 8-Dec-07, at 1:05 PM, Bradley Lucier wrote:
I believe the answer is roughly as follows.
There were various versions of Gambit that generated 68020 code for early macintoshes and BBN Butterfly computers, for example; the version that is now "Gambit" started as the version that generated "C" code, hence "Gambit-C".
Brad
That's the closest to the real answer.
Gambit (without the C suffix) is the generic name of the system which spans all possible target platforms. Up to now only two target platforms have been supported: initially Gambit had a back-end generating Motorola 68020 code (Sun workstation, Apple Macintosh, BBN butterfly multiprocessor, etc), then around 1994 a back-end generating C code was introduced. When the C back-end was released I decided to distinguish the systems with a suffix, so Gambit-68K was the first system and Gambit-C is the one generating C code. Note that at that point both front ends were identical, but the front-end of Gambit-C has evolved to support the C FFI and other extensions. I haven't worked on Gambit-68K in a long time, because my focus has shifted to portability rather than raw performance. Portability is the primary concern, followed by featurefullness, followed by performance. I think that's what most users want. Gambit-C is very portable, it works on any system with a decent C compiler (all the major workstations are covered of course, but Gambit-C has also been used on unusual target platforms such as the embedded PowerPC processor in Xilinx FPGAs and the ARM processor on the Nintendo DS). Gambit-C's abstraction of the target platform allows using it as a virtual machine (so that the same program will work on Unix, MacOS, Windows, and other systems with no modifications). Sorry, I'm rambling...
Marc
Afficher les réponses par date
On Sun, 9 Dec 2007, Marc Feeley wrote:
I think that's what most users want. Gambit-C is very portable, it works on any system with a decent C compiler (all the major workstations are covered of course, but Gambit-C has also been used on unusual target platforms such as the embedded PowerPC processor in Xilinx FPGAs and the ARM processor on the Nintendo DS).
If a function definition happens at run time, is Gambit-C able to invoke the C compiler and get it to compile something that will be usable at runtime? (e.g. using dlopen)
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
On 9-Dec-07, at 8:04 PM, Mathieu Bouchard wrote:
On Sun, 9 Dec 2007, Marc Feeley wrote:
I think that's what most users want. Gambit-C is very portable, it works on any system with a decent C compiler (all the major workstations are covered of course, but Gambit-C has also been used on unusual target platforms such as the embedded PowerPC processor in Xilinx FPGAs and the ARM processor on the Nintendo DS).
If a function definition happens at run time, is Gambit-C able to invoke the C compiler and get it to compile something that will be usable at runtime? (e.g. using dlopen)
Yes. Compiled code and interpreted code can interact seamlessly in a program.
If you want to compile Scheme code on the fly, it is best to use "gsc" (Gambit Scheme compiler) which provides the function "compile- file", which compiles a file of Scheme code to an "object file" that can be loaded at run time using Scheme's "load" procedure. Here is a complete example which shows that it takes about 0.14 seconds to generate, compile and load a small Scheme function on a 2GHz MacBook Pro (over 90% of the time is spent in the C compiler, which in this case is gcc).
;;; File: "compeval.scm"
;;; The "compeval" procedure behaves like "eval" but always evaluates ;;; in the global environment.
(define compeval (let ((counter 0))
(define (definition? expr) (and (pair? expr) (eq? (car expr) 'define)))
(lambda (expr) (set! counter (+ counter 1)) (let* ((fn (string-append "_compeval" (number->string counter))) (fn-scm (string-append fn ".scm"))) (with-output-to-file fn-scm (lambda () (pretty-print (if (definition? expr) `(begin ,expr (define _compeval-result (void))) `(define _compeval-result ,expr))))) (compile-file fn-scm) (load fn) _compeval-result))))
(define _compeval-result (void))
;;; Tests.
(define (test n) (let loop ((i 0)) (if (< i n) (let ((result (compeval `(define (f x) (list ,i (* x ,i)))))) (loop (+ i 1))))))
(time (test 1000))
(pp (f 1000000))
(compeval '(define g (c-lambda (int) int "___result = ___arg1 * ___arg1;")))
(pp (g 20))
;; The output is: ;; ;; % gsc -i compeval.scm ;; (time (test 1000)) ;; 142113 ms real time ;; 10656 ms cpu time (6273 user, 4383 system) ;; 743 collections accounting for 2162 ms real time (1736 user, 374 system) ;; 498876368 bytes allocated ;; no minor faults ;; no major faults ;; (999 999000000) ;; 400