unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [pthreads] performance test using fib.scm
@ 2002-12-10 18:16 Mikael Djurfeldt
  2002-12-10 21:10 ` Wolfgang Jaehrling
       [not found] ` <200212110202.gBB22Et27423@mule.m17n.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Mikael Djurfeldt @ 2002-12-10 18:16 UTC (permalink / raw)
  Cc: djurfeldt

In the announcement of the pthreads support, I attached a program
fib.scm:

(define (par-fib n n-forks)
  (cond ((<= n 1) 1)
	((> n-forks 0)
	 (letpar ((f1 (par-fib (- n 1) (- n-forks 1)))
		  (f2 (par-fib (- n 2) (- n-forks 1))))
	   (+ f1 f2)))
	(else
	 (let ((f1 (mono-fib (- n 1)))
	       (f2 (mono-fib (- n 2))))
	   (+ f1 f2)))))

(define (mono-fib n)
  (let iter ((f1 1) (f2 1) (i 1))
    (if (>= i n)
	f2
	(iter f2 (+ f1 f2) (+ 1 i)))))

When I run this with a Guile compiled with COPT threads, it invariably
takes around 12 s to run (par-fib 40000 1) on my dual CPU machine.
"Top" reports 50% of CPU capacity usage during calculation.

With the new pthreads support (which now allows for real SMP), it
takes 2.6 s and top says 91%!

Still, for large fibonnaci numbers and large branch depths (many
threads), Guile often crashes in realloc.  That function should be
thread safe, shouldn't it?  Maybe we're trashing up the heap somewhere
else...

Anyone keen on some debugging? :-)

Mikael


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-12-11 23:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-10 18:16 [pthreads] performance test using fib.scm Mikael Djurfeldt
2002-12-10 21:10 ` Wolfgang Jaehrling
2002-12-10 20:10   ` Mikael Djurfeldt
2002-12-11 20:05     ` Christopher Cramer
2002-12-11  5:02   ` Maciej Stachowiak
2002-12-11  7:11     ` Mikael Djurfeldt
2002-12-11 13:48       ` Maciej Stachowiak
2002-12-11 23:43         ` Han-Wen Nienhuys
2002-12-11 16:59       ` Wolfgang Jaehrling
     [not found] ` <200212110202.gBB22Et27423@mule.m17n.org>
2002-12-11 17:27   ` Wolfgang Jaehrling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).