Skip to content

Commit

Permalink
Ok, this mandel runs, but its not a very good mandel
Browse files Browse the repository at this point in the history
  • Loading branch information
rrnewton committed Jul 8, 2014
1 parent e886ed0 commit ddfb972
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 7 deletions.
2 changes: 1 addition & 1 deletion accelerate/common/gen_variants.sh
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions 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
21 changes: 21 additions & 0 deletions 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
64 changes: 62 additions & 2 deletions 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.
Expand All @@ -7,7 +9,7 @@
import qualified Mandel
-- import Config

import Data.Label
-- import Data.Label
import Control.Monad
import Foreign.Ptr
import Foreign.ForeignPtr
Expand All @@ -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 ------------------------------------------------------------------------
Expand All @@ -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 ()
10 changes: 6 additions & 4 deletions accelerate/mandelbrot/common/Mandel.hs
Expand Up @@ -3,15 +3,15 @@
-- A Mandelbrot set generator.
-- Originally submitted by Simon Marlow as part of Issue #49.
--
module Mandel (
module Mandel {-(
-- Types
View, Render, Bitmap,
-- Pretty pictures
mandelbrot, prettyRGBA,
) where
)-} where

import Prelude as P
import Data.Array.Accelerate as A hiding ( size )
Expand All @@ -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 --------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -172,3 +173,4 @@ rampColourHotToCold vmin vmax vNotNorm
in
rgba32OfFloat result
-}
21 changes: 21 additions & 0 deletions 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
21 changes: 21 additions & 0 deletions 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
21 changes: 21 additions & 0 deletions 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
21 changes: 21 additions & 0 deletions 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
21 changes: 21 additions & 0 deletions 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
21 changes: 21 additions & 0 deletions 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
21 changes: 21 additions & 0 deletions 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

0 comments on commit ddfb972

Please sign in to comment.