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

2011-05-17 Thread briand
On Mon, 16 May 2011 20:33:12 +0400
Grigory Sarnitskiy sargrig...@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@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
[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0]
[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0]
[2.0,4.0,6.0,8.0,10.0,12.0,14.0,16.0,18.0,20.0,22.0,24.0,26.0,28.0,30.0,32.0,34.0,36.0,38.0,40.0,42.0,44.0,46.0,48.0,50.0]
*Main 

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

Brian


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2011-05-16 Thread Grigory Sarnitskiy
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@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2011-05-16 Thread Felipe Almeida Lessa
On Mon, May 16, 2011 at 1:33 PM, Grigory Sarnitskiy sargrig...@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.

There's fromIArray and fromList [1].  Does that answer your question?

[1] 
http://hackage.haskell.org/packages/archive/accelerate/0.8.1.0/doc/html/Data-Array-Accelerate.html#6

Cheers, =)

-- 
Felipe.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2011-05-16 Thread Grigory Sarnitskiy
 There's fromIArray and fromList [1].  Does that answer your question?

Huh, yes, thank you! But still I don't get it. Neither

arr1 = fromList 3 [1,2,3] :: Array DIM1 Int

nor

arr1 = fromList (1,3) [1,2,3] :: Array DIM1 Int

works

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2011-05-16 Thread Don Stewart
You might want to read the Repa tutorial:

http://www.haskell.org/haskellwiki/Numeric_Haskell:_A_Repa_Tutorial

e.g.

fromList (Z :. (3::Int)) [1,2,3]

2011/5/16 Grigory Sarnitskiy sargrig...@ya.ru:
 There's fromIArray and fromList [1].  Does that answer your question?

 Huh, yes, thank you! But still I don't get it. Neither

 arr1 = fromList 3 [1,2,3] :: Array DIM1 Int

 nor

 arr1 = fromList (1,3) [1,2,3] :: Array DIM1 Int

 works

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe