module Main where
import qualified Data.Array.Accelerate.CUFFT.Batched as Batched
import qualified Data.Array.Accelerate.CUFFT.Single as Single
import qualified Data.Array.Accelerate.CUDA.Foreign as AF
import qualified Data.Array.Accelerate.CUDA as CUDA
import qualified Data.Array.Accelerate as A
import Data.Array.Accelerate (Z(Z), (:.)((:.)))
mainSingle :: IO ()
mainSingle = do
let dim = Z:.7
hf <- AF.inDefaultContext $ Single.plan1D Single.forwardReal dim
let spec =
CUDA.run1 (Single.transform hf) $
A.fromList dim $ 0 : 1 : repeat (0 :: Float)
print spec
hb <- AF.inDefaultContext $ Single.plan1D Single.inverseReal dim
print $ CUDA.run1 (Single.transform hb) spec
mainBatched :: IO ()
mainBatched = do
let count, width :: Int
count = 3; width = 7
dim :: A.DIM2
dim = Z:.count:.width
hf <- AF.inDefaultContext $ Batched.plan1D Batched.forwardReal dim
let spec =
CUDA.run1 (Batched.transform hf) $
A.fromList dim $ concat $
take count $ map (take width) $
iterate (0:) $ 1 : repeat (0 :: Float)
print spec
hb <- AF.inDefaultContext $ Batched.plan1D Batched.inverseReal dim
print $ CUDA.run1 (Batched.transform hb) spec
main :: IO ()
main = mainSingle >> mainBatched