
I trying to learn a bit about data parallel haskell, and started from the wiki page here: http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell. Two questions: The examples express the dot product as: dotp_double xs ys = sumP [:x * http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:. y | x <- xs | y <- ys:] Unless I'm missing something, shouldn't this actually be: dotp_double xs ys = sumP [:x * http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:. y | x <- xs, y <- ys:] Second, when I run Main with the prescribed 10000 element array, everything seems to work quite nicely. The task takes about 2 seconds on my 4 processor x86_64, and threadscope shows all processors nicely utilized. However, when bumping this to 100000 elements, rather than taking 10x longer as I expected, the process never terminates. During one run I even lost control of my machine and needed to do a hard reset. Are there known limits to the array sizes that can be handled with dph, or can someone suggest what might be going wrong here? Thanks, Warren

On Friday 15 October 2010 14:59:18, Warren Harris wrote:
I trying to learn a bit about data parallel haskell, and started from the wiki page here: http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell. Two questions:
The examples express the dot product as:
dotp_double xs ys = sumP [:x * <http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:.
y | x <- xs | y <- ys:]
Unless I'm missing something, shouldn't this actually be:
dotp_double xs ys = sumP [:x * <http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:.
y | x <- xs, y <- ys:]
No, it's supposed to be a parallel list comprehension, the dot product is sum $ zipWith (*) xs ys and the { blah x y | x <- xs | y <- ys } syntax (where {, } stand in for [, ] in parallel list comprehensions and for [:, :] in parallel array comprehensions) means { blah x y | (x,y) <- zip xs ys }
Second, when I run Main with the prescribed 10000 element array, everything seems to work quite nicely. The task takes about 2 seconds on my 4 processor x86_64, and threadscope shows all processors nicely utilized. However, when bumping this to 100000 elements, rather than taking 10x longer as I expected, the process never terminates. During one run I even lost control of my machine and needed to do a hard reset. Are there known limits to the array sizes that can be handled with dph, or can someone suggest what might be going wrong here? Thanks,
Warren

Got it - thanks. Any idea about the run-away process problem? Thanks,
Warren
On Fri, Oct 15, 2010 at 9:32 AM, Daniel Fischer
On Friday 15 October 2010 14:59:18, Warren Harris wrote:
I trying to learn a bit about data parallel haskell, and started from the wiki page here: http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell. Two questions:
The examples express the dot product as:
dotp_double xs ys = sumP [:x * <http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:.
y | x <- xs | y <- ys:]
Unless I'm missing something, shouldn't this actually be:
dotp_double xs ys = sumP [:x * <http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:.
y | x <- xs, y <- ys:]
No, it's supposed to be a parallel list comprehension, the dot product is
sum $ zipWith (*) xs ys
and the
{ blah x y | x <- xs | y <- ys }
syntax (where {, } stand in for [, ] in parallel list comprehensions and for [:, :] in parallel array comprehensions) means
{ blah x y | (x,y) <- zip xs ys }
Second, when I run Main with the prescribed 10000 element array, everything seems to work quite nicely. The task takes about 2 seconds on my 4 processor x86_64, and threadscope shows all processors nicely utilized. However, when bumping this to 100000 elements, rather than taking 10x longer as I expected, the process never terminates. During one run I even lost control of my machine and needed to do a hard reset. Are there known limits to the array sizes that can be handled with dph, or can someone suggest what might be going wrong here? Thanks,
Warren

I trying to learn a bit about data parallel haskell, and started from the wiki page here:http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell. Two questions:
The examples express the dot product as:
dotp_double xs ys = sumP [:x * http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:. y | x <- xs | y <- ys:]
Unless I'm missing something, shouldn't this actually be:
dotp_double xs ys = sumP [:x * http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:. y | x <- xs, y <- ys:]
No, array comprehension desugaring works the same way as for list comprehension. So this correct: dotp_double xs ys = sumP [:x * y | x <- xs | y <- ys:] After desugaring this will be translated into (simplified): dotp_double xs ys = sumP (zipWithP (*) xs ys) which will multiply the arrays element wise and sum the result. The other definition dotp_double xs ys = sumP [:x * y | x <- xs, y <- ys:] will be translated into (something equivalent): dotp_double xs ys = sumP (concatMapP (\x -> mapP (\y -> x * y)) xs ys) which definitely is not the dot product.
participants (3)
-
Daniel Fischer
-
steffen
-
Warren Harris