diff --git a/accelerate/common/gen_variants.sh b/accelerate/common/gen_variants.sh index f87a805..c5be2b4 100755 --- a/accelerate/common/gen_variants.sh +++ b/accelerate/common/gen_variants.sh @@ -43,7 +43,7 @@ EOF } doit seq_c C -doit cilk CILK +doit cilk Cilk doit cuda CUDA -DNOSIMPLE doit fission1 FissionExampleBackend doit fission2 FissionCUDA diff --git a/accelerate/mandelbrot/2gpu/mandel-2gpu.cabal b/accelerate/mandelbrot/2gpu/mandel-2gpu.cabal new file mode 100644 index 0000000..f5b8abe --- /dev/null +++ b/accelerate/mandelbrot/2gpu/mandel-2gpu.cabal @@ -0,0 +1,21 @@ +Name: mandel-2gpu +Version: 0.0.0.1 +Build-type: Simple +Cabal-version: >=1.10 + +Executable bench-mandel-2gpu + Default-Language: Haskell2010 + main-is: Main.hs + hs-source-dirs: ../common ../../common + ghc-options: -O2 -threaded -rtsopts + cpp-options: -DACCBACKEND=Data.Array.Accelerate.Multi_2GPU -DEXTRAINITCUDA + build-depends: base >= 4.7 + , time, array >= 0.4, random + , mwc-random, vector >= 0.10 + , bytestring >= 0.10, bytestring-lexing >= 0.4 + , accelerate-backend-kit >= 0.15.0.4 + , accelerate-icc-opencl >= 0.15.0.0 + , accelerate-cuda >= 0.15.0.0 + , accelerate-multidev >= 0.15.0.0 + , accelerate >= 0.15.0.0 + , cuda >= 0.5.1.1 diff --git a/accelerate/mandelbrot/cilk/mandel-cilk.cabal b/accelerate/mandelbrot/cilk/mandel-cilk.cabal new file mode 100644 index 0000000..a076a70 --- /dev/null +++ b/accelerate/mandelbrot/cilk/mandel-cilk.cabal @@ -0,0 +1,21 @@ +Name: mandel-cilk +Version: 0.0.0.1 +Build-type: Simple +Cabal-version: >=1.10 + +Executable bench-mandel-cilk + Default-Language: Haskell2010 + main-is: Main.hs + hs-source-dirs: ../common ../../common + ghc-options: -O2 -threaded -rtsopts + cpp-options: -DACCBACKEND=Data.Array.Accelerate.Cilk + build-depends: base >= 4.7 + , time, array >= 0.4, random + , mwc-random, vector >= 0.10 + , bytestring >= 0.10, bytestring-lexing >= 0.4 + , accelerate-backend-kit >= 0.15.0.4 + , accelerate-icc-opencl >= 0.15.0.0 + , accelerate-cuda >= 0.15.0.0 + , accelerate-multidev >= 0.15.0.0 + , accelerate >= 0.15.0.0 + , cuda >= 0.5.1.1 diff --git a/accelerate/mandelbrot/common/Main.hs b/accelerate/mandelbrot/common/Main.hs index 9d4d3e7..adf17fd 100644 --- a/accelerate/mandelbrot/common/Main.hs +++ b/accelerate/mandelbrot/common/Main.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE NamedFieldPuns #-} -- -- A Mandelbrot set generator. -- Originally submitted by Simon Marlow as part of Issue #49. @@ -7,7 +9,7 @@ import qualified Mandel -- import Config -import Data.Label +-- import Data.Label import Control.Monad import Foreign.Ptr import Foreign.ForeignPtr @@ -20,8 +22,26 @@ import System.Environment ( getArgs, withArgs ) import Data.Array.Accelerate.Array.Data ( ptrsOfArrayData ) import Data.Array.Accelerate.Array.Sugar ( Array(..) ) +import Data.Array.Accelerate.BackendClass (runTimed, runTimedSimple, AccTiming(..), SimpleBackend(..)) +import Data.Array.Accelerate.BackendKit.CompilerPipeline (phase0, phase1) +import Data.Time.Clock (getCurrentTime, diffUTCTime) + import Prelude as P -import Data.Array.Accelerate as A hiding ( size ) +import Data.Array.Accelerate as A hiding ( size, (++)) +import System.Environment (getArgs, getEnvironment) + +#ifdef ACCBACKEND +import qualified ACCBACKEND as Bkend +#else +#error "Must specify ACCBACKEND CPP variable to build this nbody benchmark." +-- import qualified Data.Array.Accelerate.CUDA as Bkend +#endif + +-- Temp hack: +#ifdef EXTRAINITCUDA +import Foreign.CUDA.Driver (initialise) +#endif + -- Main ------------------------------------------------------------------------ @@ -44,4 +64,44 @@ main -- putStrLn $ "Warning: unrecognized options: " ++ show nops -- mandel + + -- let def_size = 512 + -- def_depth = 255 + + let def_size = 2000 + def_depth = 25 + + args <- getArgs + let (size,depth) = case args of + [] -> (def_size, def_depth) + [sz] -> (read sz, def_depth) + [sz,d] -> (read sz, read d) + putStrLn$"Mandel running on "++show size++"x"++show size++" image size, depth "++show depth + +#ifdef EXTRAINITCUDA + initialise [] + putStrLn$"CUDA initialized - this is a hack to work around an apparent accelerate-cuda bug." +#endif + + let view = (-0.25, -1.0, 0.0, -0.75) + fullacc :: Acc (Array DIM2 (Mandel.Complex Float,Int)) + fullacc = Mandel.mandelbrot size size depth (A.unit (A.constant view)) + let simpl = phase1 $ phase0 fullacc + tBegin <- getCurrentTime +#ifndef NOSIMPLE + (times,_output) <- runTimedSimple Bkend.defaultBackend Nothing Bkend.defaultTrafoConfig simpl + putStrLn$ "Finished executing through SimpleBackend. " +#else + (times,_output) <- runTimed Bkend.defaultBackend Nothing Bkend.defaultTrafoConfig fullacc +#endif + let AccTiming{compileTime,runTime,copyTime} = times + putStrLn$ " All timing: "P.++ show times + tEnd <- getCurrentTime +-- ifndef DONTPRINT +#if 1 + putStrLn$ "JITTIME: "P.++ show compileTime + putStrLn$ "SELFTIMED: "P.++ show (runTime + copyTime) +#endif + putStrLn$ "Total elapsed time: "P.++ show (diffUTCTime tEnd tBegin) + return () diff --git a/accelerate/mandelbrot/common/Mandel.hs b/accelerate/mandelbrot/common/Mandel.hs index 0f12e37..157a1b1 100644 --- a/accelerate/mandelbrot/common/Mandel.hs +++ b/accelerate/mandelbrot/common/Mandel.hs @@ -3,7 +3,7 @@ -- A Mandelbrot set generator. -- Originally submitted by Simon Marlow as part of Issue #49. -- -module Mandel ( +module Mandel {-( -- Types View, Render, Bitmap, @@ -11,7 +11,7 @@ module Mandel ( -- Pretty pictures mandelbrot, prettyRGBA, -) where +)-} where import Prelude as P import Data.Array.Accelerate as A hiding ( size ) @@ -27,10 +27,10 @@ type Complex a = (a, a) type ComplexPlane a = Array DIM2 (Complex a) -- Image data -type Bitmap = Array DIM2 RGBA32 +-- type Bitmap = Array DIM2 RGBA32 -- Action to render a frame -type Render a = Scalar (View a) -> Bitmap +-- type Render a = Scalar (View a) -> Bitmap -- Mandelbrot Set -------------------------------------------------------------- @@ -126,6 +126,7 @@ mkinit cs = A.zip cs (A.fill (A.shape cs) 0) -- b = (t * 3 `rem` 256 ) * 0x100 -- a = 0xFF +{- prettyRGBA :: forall a. (Elt a, IsFloating a) => Exp Int -> Exp (Complex a, Int) -> Exp RGBA32 prettyRGBA lIMIT s = let cmax = A.fromIntegral lIMIT :: Exp a @@ -172,3 +173,4 @@ rampColourHotToCold vmin vmax vNotNorm in rgba32OfFloat result +-} diff --git a/accelerate/mandelbrot/cpugpu/mandel-cpugpu.cabal b/accelerate/mandelbrot/cpugpu/mandel-cpugpu.cabal new file mode 100644 index 0000000..ac01b94 --- /dev/null +++ b/accelerate/mandelbrot/cpugpu/mandel-cpugpu.cabal @@ -0,0 +1,21 @@ +Name: mandel-cpugpu +Version: 0.0.0.1 +Build-type: Simple +Cabal-version: >=1.10 + +Executable bench-mandel-cpugpu + Default-Language: Haskell2010 + main-is: Main.hs + hs-source-dirs: ../common ../../common + ghc-options: -O2 -threaded -rtsopts + cpp-options: -DACCBACKEND=Data.Array.Accelerate.Multi_CPUGPU + build-depends: base >= 4.7 + , time, array >= 0.4, random + , mwc-random, vector >= 0.10 + , bytestring >= 0.10, bytestring-lexing >= 0.4 + , accelerate-backend-kit >= 0.15.0.4 + , accelerate-icc-opencl >= 0.15.0.0 + , accelerate-cuda >= 0.15.0.0 + , accelerate-multidev >= 0.15.0.0 + , accelerate >= 0.15.0.0 + , cuda >= 0.5.1.1 diff --git a/accelerate/mandelbrot/cuda/mandel-cuda.cabal b/accelerate/mandelbrot/cuda/mandel-cuda.cabal new file mode 100644 index 0000000..d15f6e9 --- /dev/null +++ b/accelerate/mandelbrot/cuda/mandel-cuda.cabal @@ -0,0 +1,21 @@ +Name: mandel-cuda +Version: 0.0.0.1 +Build-type: Simple +Cabal-version: >=1.10 + +Executable bench-mandel-cuda + Default-Language: Haskell2010 + main-is: Main.hs + hs-source-dirs: ../common ../../common + ghc-options: -O2 -threaded -rtsopts + cpp-options: -DACCBACKEND=Data.Array.Accelerate.CUDA -DNOSIMPLE + build-depends: base >= 4.7 + , time, array >= 0.4, random + , mwc-random, vector >= 0.10 + , bytestring >= 0.10, bytestring-lexing >= 0.4 + , accelerate-backend-kit >= 0.15.0.4 + , accelerate-icc-opencl >= 0.15.0.0 + , accelerate-cuda >= 0.15.0.0 + , accelerate-multidev >= 0.15.0.0 + , accelerate >= 0.15.0.0 + , cuda >= 0.5.1.1 diff --git a/accelerate/mandelbrot/fission1/mandel-fission1.cabal b/accelerate/mandelbrot/fission1/mandel-fission1.cabal new file mode 100644 index 0000000..4e6ae12 --- /dev/null +++ b/accelerate/mandelbrot/fission1/mandel-fission1.cabal @@ -0,0 +1,21 @@ +Name: mandel-fission1 +Version: 0.0.0.1 +Build-type: Simple +Cabal-version: >=1.10 + +Executable bench-mandel-fission1 + Default-Language: Haskell2010 + main-is: Main.hs + hs-source-dirs: ../common ../../common + ghc-options: -O2 -threaded -rtsopts + cpp-options: -DACCBACKEND=Data.Array.Accelerate.FissionExampleBackend + build-depends: base >= 4.7 + , time, array >= 0.4, random + , mwc-random, vector >= 0.10 + , bytestring >= 0.10, bytestring-lexing >= 0.4 + , accelerate-backend-kit >= 0.15.0.4 + , accelerate-icc-opencl >= 0.15.0.0 + , accelerate-cuda >= 0.15.0.0 + , accelerate-multidev >= 0.15.0.0 + , accelerate >= 0.15.0.0 + , cuda >= 0.5.1.1 diff --git a/accelerate/mandelbrot/fission2/mandel-fission2.cabal b/accelerate/mandelbrot/fission2/mandel-fission2.cabal new file mode 100644 index 0000000..2d11a91 --- /dev/null +++ b/accelerate/mandelbrot/fission2/mandel-fission2.cabal @@ -0,0 +1,21 @@ +Name: mandel-fission2 +Version: 0.0.0.1 +Build-type: Simple +Cabal-version: >=1.10 + +Executable bench-mandel-fission2 + Default-Language: Haskell2010 + main-is: Main.hs + hs-source-dirs: ../common ../../common + ghc-options: -O2 -threaded -rtsopts + cpp-options: -DACCBACKEND=Data.Array.Accelerate.FissionCUDA + build-depends: base >= 4.7 + , time, array >= 0.4, random + , mwc-random, vector >= 0.10 + , bytestring >= 0.10, bytestring-lexing >= 0.4 + , accelerate-backend-kit >= 0.15.0.4 + , accelerate-icc-opencl >= 0.15.0.0 + , accelerate-cuda >= 0.15.0.0 + , accelerate-multidev >= 0.15.0.0 + , accelerate >= 0.15.0.0 + , cuda >= 0.5.1.1 diff --git a/accelerate/mandelbrot/seq_c/mandel-seqc.cabal b/accelerate/mandelbrot/seq_c/mandel-seqc.cabal new file mode 100644 index 0000000..12f061e --- /dev/null +++ b/accelerate/mandelbrot/seq_c/mandel-seqc.cabal @@ -0,0 +1,21 @@ +Name: mandel-seqc +Version: 0.0.0.1 +Build-type: Simple +Cabal-version: >=1.10 + +Executable bench-mandel-seqc + Default-Language: Haskell2010 + main-is: Main.hs + hs-source-dirs: ../common ../../common + ghc-options: -O2 -threaded -rtsopts + cpp-options: -DACCBACKEND=Data.Array.Accelerate.C + build-depends: base >= 4.7 + , time, array >= 0.4, random + , mwc-random, vector >= 0.10 + , bytestring >= 0.10, bytestring-lexing >= 0.4 + , accelerate-backend-kit >= 0.15.0.4 + , accelerate-icc-opencl >= 0.15.0.0 + , accelerate-cuda >= 0.15.0.0 + , accelerate-multidev >= 0.15.0.0 + , accelerate >= 0.15.0.0 + , cuda >= 0.5.1.1 diff --git a/accelerate/mandelbrot/spmd1/mandel-spmd1.cabal b/accelerate/mandelbrot/spmd1/mandel-spmd1.cabal new file mode 100644 index 0000000..f85648a --- /dev/null +++ b/accelerate/mandelbrot/spmd1/mandel-spmd1.cabal @@ -0,0 +1,21 @@ +Name: mandel-spmd1 +Version: 0.0.0.1 +Build-type: Simple +Cabal-version: >=1.10 + +Executable bench-mandel-spmd1 + Default-Language: Haskell2010 + main-is: Main.hs + hs-source-dirs: ../common ../../common + ghc-options: -O2 -threaded -rtsopts + cpp-options: -DACCBACKEND=Data.Array.Accelerate.SPMD_Example1 -DNOSIMPLE + build-depends: base >= 4.7 + , time, array >= 0.4, random + , mwc-random, vector >= 0.10 + , bytestring >= 0.10, bytestring-lexing >= 0.4 + , accelerate-backend-kit >= 0.15.0.4 + , accelerate-icc-opencl >= 0.15.0.0 + , accelerate-cuda >= 0.15.0.0 + , accelerate-multidev >= 0.15.0.0 + , accelerate >= 0.15.0.0 + , cuda >= 0.5.1.1 diff --git a/accelerate/mandelbrot/spmd2/mandel-spmd2.cabal b/accelerate/mandelbrot/spmd2/mandel-spmd2.cabal new file mode 100644 index 0000000..0bc674a --- /dev/null +++ b/accelerate/mandelbrot/spmd2/mandel-spmd2.cabal @@ -0,0 +1,21 @@ +Name: mandel-spmd2 +Version: 0.0.0.1 +Build-type: Simple +Cabal-version: >=1.10 + +Executable bench-mandel-spmd2 + Default-Language: Haskell2010 + main-is: Main.hs + hs-source-dirs: ../common ../../common + ghc-options: -O2 -threaded -rtsopts + cpp-options: -DACCBACKEND=Data.Array.Accelerate.SPMD_Example2 + build-depends: base >= 4.7 + , time, array >= 0.4, random + , mwc-random, vector >= 0.10 + , bytestring >= 0.10, bytestring-lexing >= 0.4 + , accelerate-backend-kit >= 0.15.0.4 + , accelerate-icc-opencl >= 0.15.0.0 + , accelerate-cuda >= 0.15.0.0 + , accelerate-multidev >= 0.15.0.0 + , accelerate >= 0.15.0.0 + , cuda >= 0.5.1.1