jtootf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Main
       where

import System.Environment

import Data.Array.Unboxed

import qualified Data.ByteString.Lazy.Char8 as L

import qualified Data.Array.Accelerate      as Acc
import qualified Data.Array.Accelerate.CUDA as CUDA

generateArray :: Int -> Acc.Array Acc.DIM3 Int
generateArray n = Acc.fromList (Acc.Z Acc.:. n Acc.:. n Acc.:. n) [0..n*n*n]

generateArray' :: Int -> Acc.Array Acc.DIM3 Float
generateArray' n = Acc.fromIArray $ generateArrayU n

generateArray1 :: Int -> Acc.Array Acc.DIM1 Int
generateArray1 n = Acc.fromList (Acc.Z Acc.:. n*n*n) [0..n*n*n]

generateArrayU :: Int -> Array (Int, Int, Int) Float
generateArrayU n = listArray ((0, 0, 0), (n, n, n)) (map fromIntegral [0..n*n*n])

main :: IO ()
main = do [s]  <- getArgs
          L.putStrLn $ (L.pack . show) $ generateArray1 (read s)