[Haskell-cafe] Accelerate package (CUDA). How to actually create an array?

briand at aracnet.com briand at aracnet.com
Tue May 17 16:32:55 CEST 2011

On Mon, 16 May 2011 20:33:12 +0400
Grigory Sarnitskiy <sargrigory at ya.ru> wrote:

> Hello!
> I'm probing CUDA with Haskell, accelerate package to be exact. Sound stupid, but I couldn't find how to actually construct an array, for example Vector Float.
> There is quite a number of examples provided with the package, but they seem not simple enough for me just to start.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Have a fish :-)

import Data.Array.Repa as A
import Data.Array.Repa.Index
import Data.Array.Repa.Shape as AS

newArray :: Int -> Array DIM2 Double
newArray n = 
--    A.fromList ((AS.shapeOfList [n, n])::(DIM2)) ((Prelude.map fromIntegral [1..n*n])::[Double])
    A.fromList (AS.shapeOfList [n, n]) (Prelude.map fromIntegral [1..n*n])

main = do
  let x = newArray 5
  let y = newArray 5
  let z = A.zipWith(+) x y
  putStrLn $ show x
  putStrLn $ show y
  putStrLn $ show z

*Main> main

I can't remember what Prelude.map collided with.


More information about the Haskell-Cafe mailing list