guile-user
[Top][All Lists]
Advanced

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

ice-9 threads parallel


From: Vok Vojwo
Subject: ice-9 threads parallel
Date: Wed, 26 Oct 2011 17:38:44 +0200

On my system current-processor-count returns 2. I use random with the
same seed: first in normal evaluation order and second in parallel.
But the two evaluations return the same result. I expected that the
order of the random numbers differs but it is the same. Why?

This is the example:

(use-modules (ice-9 threads))

(define (slow-random)
  (sleep 1)
  (random 10))

(begin
  (set! *random-state* (seed->random-state 42))
  (values
   (list
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random))
   (list
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random))))

(begin
  (set! *random-state* (seed->random-state 42))
  (parallel
   (list
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random))
   (list
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random))))

(current-processor-count)



reply via email to

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