
Hello, I am trying to use the code rels list = let o1 = (map makeCompEntry) $ head $ splitList list o2 = (map makeCompEntry) $ head $ tail $ splitList list o3 = (map makeCompEntry) $ head $ tail $ tail $ splitList list in case (head $ tail $ tail $ tail $ splitList list) of [] -> o1 `par` o2 `par` o3 `seq` o1 : o2 : o3 : [] _ -> let o4 = rels (head $ tail $ tail $ tail $ splitList list) in o1 `par` o2 `par` o3 `par` o4 `seq` o1 : o2 : o3 : o4 to apply some operation on some lists in parallel. The input list "list" is quite long (about 10^17) entries, and I split it into chunks of 1000 entries each. I am compiling with the options " -O2 --make -smp -threaded" and when running the file with "+RTS -N2 -sstderr -RTS", I see that only one worker thread is really doing anything. I am using a vanilla build of ghc-6.6.1 running on Ubuntu 7.10. I am currently wondering about what I am doing wrong. Regards, Dominik -- Dominik Luecke Phone +49-421-218-64265 Dept. of Computer Science Fax +49-421-218-9864265 University of Bremen luecke@informatik.uni-bremen.de P.O.Box 330440, D-28334 Bremen PGP-Key ID 0x2D82571B

Hello Dominik, I have used something like this and it worked very well: import Control.Parallel.Strategies inParallel = parMap rwhnf id [a,b] = inParallel [f x, g y] I hope it helps, Alberto On Thursday 25 October 2007 11:36, Dominik Luecke wrote:
Hello,
I am trying to use the code
rels list = let o1 = (map makeCompEntry) $ head $ splitList list o2 = (map makeCompEntry) $ head $ tail $ splitList list o3 = (map makeCompEntry) $ head $ tail $ tail $ splitList list in case (head $ tail $ tail $ tail $ splitList list) of [] -> o1 `par` o2 `par` o3 `seq` o1 : o2 : o3 : [] _ -> let o4 = rels (head $ tail $ tail $ tail $ splitList list) in o1 `par` o2 `par` o3 `par` o4 `seq` o1 : o2 : o3 : o4
to apply some operation on some lists in parallel. The input list "list" is quite long (about 10^17) entries, and I split it into chunks of 1000 entries each. I am compiling with the options " -O2 --make -smp -threaded" and when running the file with "+RTS -N2 -sstderr -RTS", I see that only one worker thread is really doing anything. I am using a vanilla build of ghc-6.6.1 running on Ubuntu 7.10. I am currently wondering about what I am doing wrong.
Regards, Dominik

Hello, it looks quite similar, but it is not completely what I need, I rather need something like inParallel = parMap rwhnf outList = inParallel (map f) listOfLists If I use your construction on the first 2 elements of my list, I see several threads working, but not in the other case. Regards, Dominik On Thu, 2007-10-25 at 11:53 +0200, Alberto Ruiz wrote:
Hello Dominik,
I have used something like this and it worked very well:
import Control.Parallel.Strategies
inParallel = parMap rwhnf id
[a,b] = inParallel [f x, g y]
I hope it helps,
Alberto
On Thursday 25 October 2007 11:36, Dominik Luecke wrote:
Hello,
I am trying to use the code
rels list = let o1 = (map makeCompEntry) $ head $ splitList list o2 = (map makeCompEntry) $ head $ tail $ splitList list o3 = (map makeCompEntry) $ head $ tail $ tail $ splitList list in case (head $ tail $ tail $ tail $ splitList list) of [] -> o1 `par` o2 `par` o3 `seq` o1 : o2 : o3 : [] _ -> let o4 = rels (head $ tail $ tail $ tail $ splitList list) in o1 `par` o2 `par` o3 `par` o4 `seq` o1 : o2 : o3 : o4
to apply some operation on some lists in parallel. The input list "list" is quite long (about 10^17) entries, and I split it into chunks of 1000 entries each. I am compiling with the options " -O2 --make -smp -threaded" and when running the file with "+RTS -N2 -sstderr -RTS", I see that only one worker thread is really doing anything. I am using a vanilla build of ghc-6.6.1 running on Ubuntu 7.10. I am currently wondering about what I am doing wrong.
Regards, Dominik -- Dominik Luecke Phone +49-421-218-64265 Dept. of Computer Science Fax +49-421-218-9864265 University of Bremen luecke@informatik.uni-bremen.de P.O.Box 330440, D-28334 Bremen PGP-Key ID 0x2D82571B

Dominik Luecke wrote:
I am trying to use the code
rels list = let o1 = (map makeCompEntry) $ head $ splitList list o2 = (map makeCompEntry) $ head $ tail $ splitList list o3 = (map makeCompEntry) $ head $ tail $ tail $ splitList list in case (head $ tail $ tail $ tail $ splitList list) of
you've written 'splitList list' 4 times here. The compiler might be clever enough to common them up, but personally I wouldn't rely on it. Your code can be shortened quite a lot, e.g: let (o1:o2:o3:rest) = map makeCompEntry (splitList list) in case rest of ...
[] -> o1 `par` o2 `par` o3 `seq` o1 : o2 : o3 : [] _ -> let o4 = rels (head $ tail $ tail $ tail $ splitList list) in o1 `par` o2 `par` o3 `par` o4 `seq` o1 : o2 : o3 : o4
without knowing what splitList and the rest of the program does, it's hard to say why you don't get any parallelism here. But note that when you say: o1 `par` o2 `par` o3 `seq` o1 : o2 : o3 : [] what this does is create "sparks" for o1-o3 before returning the list [o1,o2,o3]. Now, something else is consuming this list - if whatever consumes it looks at the head of the list first, then you've immediately lost the opportunity to overlap o1 with anything else, because the program is demanding it eagerly. All this is quite hard to think about, and there is a serious lack of tools at the moment to tell you what's going on. We do hope to address that in the future. Right now, I suggest keeping things really simple. Use large-grain parallelism, in a very few places in your program. Use strategies - parMap is a good one because it hides the laziness aspect, you don't need to worry about what is getting evaluated when. Cheers, Simon
participants (3)
-
Alberto Ruiz
-
Dominik Luecke
-
Simon Marlow