[clean-list] Parallel machines (Am I missing something)?
Philippos Apolinarius
phi500ac at yahoo.ca
Fri Oct 23 06:00:41 MEST 2009
I am playing with Haskell and Clean in a machines with four processors. I started with a program that does something stupid that takes time. Let us assum that the program is in file para.hs. I compile it thus:
ghc pfib.hs -threaded --make
I can run it in 2 of my four cores. Here is how I did it:
pfib.exe +RTS -N2
I used something to monitor core activity, and discovered that two of the cores were working like crazy. The two core changed from execution to execution. The rule seems to be the following:
First run: Core 1 and core 2
Second run: Core 2 and core 3
Third run: Core 3 and core 4
Forth run: Core 4 and core 1
And so on. As soon as execution stops, activity drops to zero in the busy cores. Now, let us increase the number of cores to 4:
pfib +RTS -N4
Now, I see activity in all four cores. So, Haskell seem to be working as anounced. Problem is... if I create 2 or 4 processes in Clean (using ObjectIO), I get exactly the same pattern, i.e., Clean programs are distributed between the cores. If I use 2 processes, they are distributed between 2 cores, if I use 4 processes, the problem activates four cores, etc. Is Clean parallel too, or I am missing something?
I am curious. Does parallel processes or threads work only with Xeon cpus, or do they work with any quadricore cpu? I mean, if I use a a Pentium 4 or something else, do I get the same result as in Xeon?
import Control.Parallel
import System (getArgs)
import IO
fib :: Int -> Int
fib n | n <= 1 = 1
| otherwise = par n1 (seq n2 (n1 + n2 + 1))
where
n1 = fib (n-1)
n2 = fib (n-2)
main= do
a <- getArgs
print $ fib (read (head a))
__________________________________________________________________
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now
http://ca.toolbar.yahoo.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.science.ru.nl/pipermail/clean-list/attachments/20091022/7539331d/attachment.html
More information about the clean-list
mailing list