Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.scheme

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 10-26-2004, 10:27 AM
F?rster_vom_Silberwald
Guest
 
Posts: n/a
Default Some observations: Bigloo<->Stalin

One thing worth to mention is the fact that Bigloo will serve you very
well provided one comply to some rules. The following two code snippets
demonstrate that Stalin is indeed a good code analyzer.

The following is a code snippet from a code which solves for simple
ordinary first order differential equations.**

But that is not the problem here; important is the fact that one has to
use a bit of a different technique in order to make the best out of
Bigloo programming, provided he is after performance.

1. Stalin snippet:

==
(define (eul-alpha n h delx u K R gamma-i A B)
(let* ((alpha-i (/ (&vr R 0)
(&vr B 0))))
(let loop-alpha ((i 2) (erg (list alpha-i)))
(if (= i (+ n 1))
(o==> (list->vector (reverse erg)))
(begin
(let ((indx (- i 1)))
(set! alpha-i (/ (- (&vr R indx)
(* (&vr A indx) alpha-i))
(+ (&vr B indx)
(* (&vr A indx)
(&vr gamma-i (- indx 1))))))
(loop-alpha (+ i 1) (cons alpha-i erg))))))))
==

2. The Bigloo snippet:

==
(define-macro (/. x y)
`(cond-expand
(bigloo (/fl ,x ,y))
(else (/ ,x ,y))))

; etc. macros here

(define (eul-alpha n h delx u K R gamma-i A B)
(let ((erg (make-vector n 0.0))
(alpha-i (/. (v& R 0)
(v& B 0))))
(vector-set! erg 0 alpha-i)
(do ((i 2 (+ i 1)))
((= i (+ n 1)))
(let ((indx (- i 1)))
(set! alpha-i
(/. (-. (v& R indx)
(*. (v& A indx) alpha-i))
(+. (v& B indx)
(*. (v& A indx)
(v& gamma-i (- indx 1))))))
(vector-set! erg indx alpha-i)))
(o==> erg)))
==

As you see: in order to get to the same performance as under Stalin one
has to use in Bigloo: a) pre-dimensionized vectors b) Bigloo operators.
The latter macros concerning the operators have been made so as to use
the code -- for test reasons -- under Stalin too.

Although, you see: in Stalin you use: a) consing-lists (list is
converted to a vector upon exit) b) normal operators.

If I had used the same Stalin code (the one with consing lists) under
Bigloo I would have had to wait much, much longer for the result. I do
not know why Stalin automatically transforms the list-consing code to
something similar to the vector code (see Bigloo code snippet).

And no: I would in no way cancel Bigloo in favor of Stalin. Bigloo
provides me much, much more; since one knows about some Bigloo tricks
and the Stalin performance advantage vanishes, at least in that special
"differential equation solver". Documentatin of ones own Bigloo code
with some basic types is at top of my list!

Förster vom Silberwald
** I made also a C++ version, because to my surprise the Bigloo output
and the Stalin output differ (same code)! However, the Bigloo output and
C++ output are the same! I implementted the solver after an example in a
book about atmospheric physics; one of the book examples provided me
only the initial particle concentration but not the result. Hence I am
not aware whether the Bigloo and C++ version is in error or Stalin. I am
still not sure whether my code converges eventually. But nevertheless: I
thought they -- Bigloo and Stalin, respectively -- rely on the same
internal (numerical) C layout - or don't they?
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: SET and observations read nospam@HOWLES.COM (Howard Schreier Newsgroup comp.soft-sys.sas 0 08-05-2005 11:22 AM
Re: On Key-Indexing Dorfman, Paul Newsgroup comp.soft-sys.sas 0 07-21-2005 07:23 PM
Re: challenging merge (I am not up to it) David L. Cassell Newsgroup comp.soft-sys.sas 0 04-21-2005 01:30 AM
Re: challenging merge (I am not up to it) Cornel Lencar Newsgroup comp.soft-sys.sas 0 04-20-2005 10:31 PM
Re: Deleted Observations in a dataset? Nat Wooding Newsgroup comp.soft-sys.sas 0 10-25-2004 05:21 PM



All times are GMT. The time now is 12:31 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.