[gambit-list] decreasing GC

Zhen Shen zhenshen10 at outlook.com
Wed Apr 24 15:21:35 EDT 2013


Marc,

Sorry if my joke didn't come across as one. I am new to scheme.

If I understand you correctly, the calculations in this stmt will be performed with bignum arith?

(declare (flonum))
(if (> x 0.01)
  (* x a 3.0)
  (/ x a))

and to avoid that for max speed, i'd rewrite it as follows??

(declare (flonum))
(define x ..)
(define a ..)

(define p (* x a 3.0))
(define q (/ x a))
(define r (> x 0.01))
(if r p q)



> Subject: Re: [gambit-list] decreasing GC
> From: feeley at iro.umontreal.ca
> Date: Wed, 24 Apr 2013 14:17:39 -0400
> CC: kumoyuki at gmail.com; gambit-list at iro.umontreal.ca
> To: zhenshen10 at outlook.com
> 
> 
> On 2013-04-24, at 12:37 PM, Zhen Shen <zhenshen10 at outlook.com> wrote:
> 
> > Havens!! Do gambit users launch rockets into space, is that the reason for having bignum arithmetic by default??!
> 
> I'm not sure if you mean that question as a criticism of Scheme, a criticism of Gambit, or an actual question (in which case the answer is yes).  It is not so much that bignum arithmetic is "on by default".  It is really a consequence of the language design which specifies that Scheme arithmetic corresponds to mathematics when operating on exact numbers.  There are plenty of languages to choose from if you prefer (expt 2 31) returning -2147483648 .
> 
> > Oh, and speaking of "exact" arithmetic, I thought that was impossible cause digital computers cant store reals?
> > 
> > Anyhow, thanks to your and brad's suggestions, I made significant improvements:
> > memory usage is 3GB (down from 18GB!) and execution time descreased by 80%. This is mostly due to the flonums.
> > 
> > Now, doing (declare (flonum)) at the top level, does this stop gambit from boxing flonums across function calls?
> 
> No, flonums are kept unboxed only within a basic-block of code (a block of code uninterrupted by a jump, such as an "if" or function call).  So it pays to think carefully about where floating point calculations are placed.  Sometimes it is beneficial to recompute a result if it prevents carrying an intermediate result accross a jump.
> 
> Marc
> 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20130424/5dba9286/attachment.htm>


More information about the Gambit-list mailing list