Parallel machines (Am I missing something)?

View: New views
2 Messages — Rating Filter:   Alert me  

Parallel machines (Am I missing something)?

by Philippos Apolinarius :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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







Looking for the perfect gift? Give the gift of Flickr!
_______________________________________________
clean-list mailing list
clean-list@...
http://mailman.science.ru.nl/mailman/listinfo/clean-list

Re: Parallel machines (Am I missing something)?

by John van Groningen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Philippos Apolinarius wrote:

>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?

No, currently all ObjectIO's processes use the same thread. The scheduler of
the operating system is probably not using the same core every time the thread
is scheduled for execution.

>..

Kind regards,

John van Groningen
_______________________________________________
clean-list mailing list
clean-list@...
http://mailman.science.ru.nl/mailman/listinfo/clean-list