Some initial results with DPH

Roman Leshchinskiy rl at
Tue Sep 23 04:49:52 EDT 2008

On 23/09/2008, at 14:59, Roman Leshchinskiy wrote:

>> dotp :: [:Int:] -> [:Int:] -> Int
>> dotp v w = I.sumP [: (I.*) x y | x <- v, y <- w :]
> The way the vectoriser works at the moment, it will repeat the array  
> w (lengthP v) times, i.e., create an array of length (lengthP v *  
> lengthP w). This is quite unfortunate and needs to be fused away but  
> isn't at the moment. The only advice I can give is to stay away from  
> array comprehensions for now. They work but are extremely slow. This  
> definition should work fine:
> dotp v w = I.sumP (zipWithP (I.*) v w)

Actually, I didn't pay attention when I wrote this. The two are not  
equivalent, of course. Only the second one computes the dot product.  
With comprehensions, you'd have to write

dotp v w = [: (I.*) x y | x <- v | y <- w :]

I suspect that will perform reasonably even now.


More information about the Glasgow-haskell-users mailing list