jtootf

CUDA 2012-02-20 13:41:59.495049 UTC

1module Main
2 where
3
4import System.Environment
5
6import Data.Array.Unboxed
7
8import qualified Data.ByteString.Lazy.Char8 as L
9
10import qualified Data.Array.Accelerate as Acc
11import qualified Data.Array.Accelerate.CUDA as CUDA
12
13generateArray :: Int -> Acc.Array Acc.DIM3 Int
14generateArray n = Acc.fromList (Acc.Z Acc.:. n Acc.:. n Acc.:. n) [0..n*n*n]
15
16generateArray' :: Int -> Acc.Array Acc.DIM3 Float
17generateArray' n = Acc.fromIArray $ generateArrayU n
18
19generateArray1 :: Int -> Acc.Array Acc.DIM1 Int
20generateArray1 n = Acc.fromList (Acc.Z Acc.:. n*n*n) [0..n*n*n]
21
22generateArrayU :: Int -> Array (Int, Int, Int) Float
23generateArrayU n = listArray ((0, 0, 0), (n, n, n)) (map fromIntegral [0..n*n*n])
24
25main :: IO ()
26main = do [s] <- getArgs
27 L.putStrLn $ (L.pack . show) $ generateArray1 (read s)