[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] parallel matrix multiply (dph, par/pseq)

Subject: Re: [Haskell-cafe] parallel matrix multiply dph, par/pseq
From: Rafael Gustavo da Cunha Pereira Pinto
Date: Mon, 18 Jan 2010 08:35:42 -0200
I never used DPH, but for Matrices, I always tend to use Array (Int,Int) Double, as it accesses its elements in O(1). Arrays also can be unboxed (UArray), which are much faster, or monadic and mutable (MArray), which are more flexible.

I don't know if it is possible to use Arrays with DPH...

On Sun, Jan 17, 2010 at 21:35, Johannes Waldmann <[email protected]> wrote:

How can I multiply matrices (of Doubles)
with dph (-0.4.0)?  (ghc-6.12.1)  -  I was trying

type Vector = [:Double:]
type Matrix = [:Vector:]

times :: Matrix -> Matrix -> Matrix
times a b =
     ( \ row -> mapP ( \ col -> sumP ( zipWithP (*) row col  ) )
                     ( transposeP b )
     ) a

but there is no such thing as transposeP.

When I try any kind of index manipulations,
the compiler invariably tells me
that it does not want to build  [: :] - lists of indices
(e.g., there is no enumFromToP)
(I guess because I'm using Data.Array.Parallel.Prelude.Double)

Puzzled - J.W.

PS: what's the recommended way to multiply matrices
(better modelled as   Array (Int,Int) Double   or  [[Double]] ?)
with the  par/pseq  approach (if this is recommended at all)?

As I said earlier, I just want to have some nice and easy benchmarks
for demonstration in a lecture (to be run on 2, 4, or 8 cores).
Of course if they work, I'd use them in real life as well...

Haskell-Cafe mailing list
[email protected]

Rafael Gustavo da Cunha Pereira Pinto

Haskell-Cafe mailing list
[email protected]
<Prev in Thread] Current Thread [Next in Thread>