[gambit-list] Re: Scheme/C help request for code needed for Math paper
Bill Richter
richter at math.northwestern.edu
Thu Jan 27 01:24:53 EST 2005
Guillaume, I'm really getting almost *30* times faster!!! Your advice
is better than I thought. I did t = 0 to 51 in 4.7 minutes. Yahoo!
you can speed up your code quite a bit simply by adding some
declarations in your code....Something like this [say, at the top
of 'Curtis-algorithm.scm']:
(declare
(standard-bindings)
(fixnum)
(not safe)
(inline)
(inlining-limit 1000)
(block))
Yesterday I goofed, and didn't put this quite at the top of the file.
I put it below the line (include "adem.scm") where as your profiler
showed, most of the action takes place. Now with your code at the
top, I did t = 0 to 51 in 4.7 minutes, but my previous mark was 134.9
minutes, in 4 stages:
;; t = 0--45, 489826 ms real time, 8.1 minutes
;; t = 46--49 1510112 ms real time, 25.2 minutes
;; t = 50, 2484842 ms real time, 41.4 minutes
;; t = 51 3613899 ms real time, 60.2 minutes
I calculate
(/ 134.9 4.7)
28.70212765957447
My goof graphically demonstrates the truth of the Gambit info node
"Miscellaneous extensions":
- special form: declare DECLARATION...
This form introduces declarations to be used by the compiler
... Declarations are lexically scoped in the same way as macros.
Yup! I said something else dumb yesterday: I whinged that your
profiler wouldn't work with gsc/gcc. But of course that's true: your
profiler looks at the hits of the Scheme program. If it was gcc, it
would looks at the hits of the C program, which wouldn't mean anything
to us, and with `gcc -O2', the C line numbers wouldn't mean anything
at all! I remember that from running gdb for Stallman on Emacs years
ago: if you want to gdb emacs, you can't make Emacs optimized.
I also tried rewriting my code to use s8vectors instead of lists for
Monomials, and it is not running faster. At least I got the right
answers up through (s, t) = (11, 50). Ah, I think I see the problem!
I have multiple definitions:
(define Min_t 55)
(define Max_t 55)
(define Min_t 0)
(define Max_t 51)
I should've commented the first pair out. It's funny, but I've
noticed this slows the a.out down by quite a bit. Dunno why.
The homogeneous vectors look like really nice stuff, partly because of
the extra functions we don't have for ordinary vectors:
- procedure: s8vector-append S8VECTOR...
- procedure: subs8vector S8VECTOR START END
Perhaps that should say
- procedure: subs8vector S8VECTOR START (- END 1)
More information about the Gambit-list
mailing list