[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pthreads] performance test using fib.scm

From: Mikael Djurfeldt
Subject: [pthreads] performance test using fib.scm
Date: Tue, 10 Dec 2002 19:16:04 +0100

In the announcement of the pthreads support, I attached a program

(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)))
         (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)
        (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

Anyone keen on some debugging? :-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]