Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvanbalen committed Jun 26, 2024
1 parent 3eb258e commit ce1db2b
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 304 deletions.
2 changes: 0 additions & 2 deletions accelerate.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,6 @@ library
, hashable >= 1.1
, hashtables >= 1.2.3
, hedgehog >= 0.5
-- , highs-lp >= 0.0
-- , linear-programming >= 0.0.0.1
, microlens >= 0.4
, microlens-th >= 0.4
, microlens-mtl >= 0.2
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Array/Accelerate/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ type Afun = OpenAfun ()

-- Vanilla open array computations
--
newtype OpenAcc aenv t = OpenAcc (PreOpenAcc OpenAcc aenv t)
newtype OpenAcc aenv t = OpenAcc { runOpenAcc :: PreOpenAcc OpenAcc aenv t }

-- | Closed array expression aka an array program
--
Expand Down Expand Up @@ -632,7 +632,7 @@ rnfPreOpenAcc rnfA pacc =
rnfB = rnfBoundary

rnfM :: Message a -> ()
rnfM (Message f g msg) = f `seq` rnfMaybe (\x -> x `seq` ()) g `seq` rnf msg
rnfM (Message f g msg) = f `seq` rnfMaybe (`seq` ()) g `seq` rnf msg
in
case pacc of
Alet lhs bnd body -> rnfALeftHandSide lhs `seq` rnfA bnd `seq` rnfA body
Expand Down
8 changes: 2 additions & 6 deletions src/Data/Array/Accelerate/AST/Schedule/Sequential.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_HADDOCK hide #-}
Expand Down Expand Up @@ -33,15 +30,14 @@ import Data.Array.Accelerate.Type
import Data.Array.Accelerate.Representation.Array
import Data.Array.Accelerate.Representation.Shape
import Data.Array.Accelerate.Representation.Type
import Data.Array.Accelerate.AST.Var
import Data.Array.Accelerate.AST.LeftHandSide
import qualified Data.Array.Accelerate.AST.Operation as Operation
import Data.Array.Accelerate.AST.Partitioned hiding (PreOpenAcc(..), PreOperationAfun(..), PartitionedAcc, PartitionedAfun)
import Data.Array.Accelerate.AST.Partitioned hiding (PreOpenAcc(..), PartitionedAcc, PartitionedAfun)
import qualified Data.Array.Accelerate.AST.Partitioned as Partition
import Data.Array.Accelerate.AST.Kernel
import Data.Array.Accelerate.AST.Schedule
import Data.Array.Accelerate.AST.Schedule.Uniform ( SArg(..), SArgs )
import Data.Array.Accelerate.Trafo.Schedule.Uniform ( compileKernel', CompiledKernel(..), rnfSArg, rnfSArgs )
import Data.Array.Accelerate.Trafo.Schedule.Uniform ( compileKernel', CompiledKernel(..), rnfSArgs )
import Data.Array.Accelerate.AST.Execute
import Control.Concurrent.MVar
import Data.Typeable ( (:~:)(..) )
Expand Down
7 changes: 1 addition & 6 deletions src/Data/Array/Accelerate/Backend.hs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}

-- |
-- Module : Data.Array.Accelerate.Backend
Expand Down Expand Up @@ -51,7 +47,7 @@ module Data.Array.Accelerate.Backend (
Pretty.PrettyOp(..),
Execute(..),
Operation.NFData'(..),
Operation.ShrinkArg(..), runWithObj, runNWithObj, runNBench, Benchmarking(..)
Operation.ShrinkArg(..), runWithObj, runNWithObj, runNBench, Benchmarking
) where

import qualified Data.Array.Accelerate.Smart as Smart
Expand All @@ -77,7 +73,6 @@ import Data.Type.Equality
import System.IO.Unsafe (unsafePerformIO)
import qualified Data.Array.Accelerate.AST.Operation as Operation
import qualified Data.Array.Accelerate.Trafo.Partitioning.ILP.Graph as Graph
import Data.Array.Accelerate.Eval (EvalOp)
import Data.Array.Accelerate.Trafo.Partitioning.ILP.Solve (Objective)
import Data.Array.Accelerate.Trafo.Partitioning.ILP (Benchmarking)

Expand Down
15 changes: 6 additions & 9 deletions src/Data/Array/Accelerate/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ module Data.Array.Accelerate.Interpreter (
) where

import Prelude hiding (take, (!!), sum, Either(..) )
import Data.Array.Accelerate.AST.Partitioned hiding (Empty)
import Data.Array.Accelerate.AST.Operation
import Data.Array.Accelerate.AST.Partitioned
import Data.Array.Accelerate.AST.Kernel
import Data.Array.Accelerate.Trafo.Desugar
import qualified Data.Array.Accelerate.Debug.Internal as Debug
Expand Down Expand Up @@ -82,7 +81,7 @@ import Lens.Micro ((.~), (&))
import Data.Array.Accelerate.Array.Buffer
import Data.Array.Accelerate.Pretty.Partitioned ()
import Data.Array.Accelerate.AST.Idx
import Data.Array.Accelerate.AST.LeftHandSide (LeftHandSide (LeftHandSideWildcard, LeftHandSideUnit))
import Data.Array.Accelerate.AST.LeftHandSide (LeftHandSide (LeftHandSideUnit))
import Data.Array.Accelerate.AST.Schedule

import Control.Concurrent (forkIO)
Expand All @@ -97,23 +96,21 @@ import qualified Data.Map as M
import Control.Monad (when)
import Data.Array.Accelerate.Trafo.Var (DeclareVars(DeclareVars), declareVars)
import Data.Array.Accelerate.Trafo.Operation.Substitution (alet, aletUnique, weaken, LHS (LHS), mkLHS)
import Control.DeepSeq (rnf)
import Data.Map (Map)
import System.IO.Unsafe (unsafePerformIO)

import Data.Array.Accelerate.Eval
import qualified Data.Array.Accelerate.AST.Partitioned as P
import Data.Functor.Identity
import Data.Array.Accelerate.Trafo.LiveVars
import qualified Debug.Trace
import Data.Maybe (fromJust)

data Interpreter
instance Backend Interpreter where
type Schedule Interpreter = UniformScheduleFun
type Kernel Interpreter = InterpretKernel


(!?!) :: (Ord a1, Show a1, Show a2) => Map a1 a2 -> a1 -> a2
map !?! key = case map M.!? key of
Just x -> x
Nothing -> error ("error: map "<> show map <> "does not contain key " <> show key)
Expand All @@ -128,7 +125,7 @@ instance Eq (BackendClusterArg2 InterpretOp env arg) where
BCA f x == BCA g y = map f [1..100] == map g [1..100] && x == y

instance Show (BackendClusterArg2 InterpretOp env arg) where
show (BCA f a) = "bca"
show (BCA _ _) = "bca"

instance StaticClusterAnalysis InterpretOp where
data BackendClusterArg2 InterpretOp env arg = BCA (Int -> Int) Int -- backpermute function and iteration size
Expand Down Expand Up @@ -714,15 +711,15 @@ doNTimes n f
linearIndexToSh :: ShapeR sh -> sh -> Int -> sh
linearIndexToSh ShapeRz () 0 = ()
linearIndexToSh ShapeRz () _ = error "non-zero index in unit array"
linearIndexToSh (ShapeRsnoc shr) (sh, outer) i = let
linearIndexToSh (ShapeRsnoc shr) (sh, _) i = let
innerSize = arrsize shr sh
outerIndex = i `div` innerSize
innerIndex = linearIndexToSh shr sh (i `mod` innerSize)
in (innerIndex, outerIndex)

shToLinearIndex :: ShapeR sh -> sh -> sh -> Int
shToLinearIndex ShapeRz () () = 0
shToLinearIndex (ShapeRsnoc shr) (sh, x) (sh', y) = let
shToLinearIndex (ShapeRsnoc shr) (sh, _) (sh', y) = let
innerSize = arrsize shr sh
innerIndex = shToLinearIndex shr sh sh'
in y*innerSize+innerIndex
Expand Down
19 changes: 1 addition & 18 deletions src/Data/Array/Accelerate/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_HADDOCK hide #-}
Expand All @@ -32,20 +30,15 @@ module Data.Array.Accelerate.Pretty (

-- ** Graphviz
Graph,
PrettyGraph(..), Detail(..),
PrettyGraph, Detail,
graphDelayedAcc, graphDelayedAfun,

) where

import Data.Array.Accelerate.AST hiding ( Acc, Exp )
import Data.Array.Accelerate.Debug.Internal.Flags
import Data.Array.Accelerate.Error
import Data.Array.Accelerate.Pretty.Graphviz
import Data.Array.Accelerate.Pretty.Print hiding ( Keyword(..) )
import Data.Array.Accelerate.Pretty.Exp hiding ( Keyword(..) )
import Data.Array.Accelerate.Smart ( Acc, Exp )
import Data.Array.Accelerate.Sugar.Array
import Data.Array.Accelerate.Sugar.Elt
-- import Data.Array.Accelerate.Trafo.Delayed

import Data.Maybe
Expand All @@ -58,7 +51,6 @@ import System.IO.Unsafe
import qualified Data.Text.Lazy as T
import qualified System.Console.ANSI as Term
import qualified System.Console.Terminal.Size as Term
import Data.Array.Accelerate.AST.Operation (OperationAcc, OperationAfun)

#if ACCELERATE_DEBUG
import Control.DeepSeq
Expand Down Expand Up @@ -87,13 +79,6 @@ instance PrettyEnv aenv => Show (OpenAcc aenv a) where
instance PrettyEnv aenv => Show (OpenAfun aenv f) where
show = renderForTerminal . prettyPreOpenAfun configPlain prettyOpenAcc (prettyEnv (pretty 'a'))

instance PrettyEnv aenv => Show (OperationAcc op aenv a) where
-- show = let config = if shouldPrintHash then configWithHash else configPlain
-- in renderForTerminal . prettyDelayedOpenAcc config context0 (prettyEnv (pretty 'a'))

instance PrettyEnv aenv => Show (OperationAfun op aenv f) where
-- show = let config = if shouldPrintHash then configWithHash else configPlain
-- in renderForTerminal . prettyPreOpenAfun config prettyDelayedOpenAcc (prettyEnv (pretty 'a'))

instance (PrettyEnv env, PrettyEnv aenv) => Show (OpenExp env aenv e) where
show = renderForTerminal . prettyOpenExp context0 (prettyEnv (pretty 'x')) (prettyEnv (pretty 'a'))
Expand Down Expand Up @@ -122,8 +107,6 @@ terminalSupportsANSI :: Bool
terminalSupportsANSI = unsafePerformIO $ Term.hSupportsANSI stdout

{-# NOINLINE terminalLayoutOptions #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeApplications #-}
terminalLayoutOptions :: LayoutOptions
terminalLayoutOptions
= unsafePerformIO
Expand Down
7 changes: 2 additions & 5 deletions src/Data/Array/Accelerate/Pretty/Operation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}

-- |
-- Module : Data.Array.Accelerate.Pretty.Operation
-- Copyright : [2008..2020] The Accelerate Team
Expand Down Expand Up @@ -40,7 +37,7 @@ import Data.Array.Accelerate.Representation.Elt
import Data.Array.Accelerate.Representation.Type
import Data.Array.Accelerate.Type

import Data.Text.Prettyprint.Doc
import Prettyprinter
import Data.String

import Prelude hiding (exp)
Expand Down
8 changes: 2 additions & 6 deletions src/Data/Array/Accelerate/Pretty/Print.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}
-- |
-- Module : Data.Array.Accelerate.Pretty.Print
Expand Down Expand Up @@ -96,7 +92,7 @@ ansiKeyword Execute = color Blue
ansiKeyword Modifier = colorDull Blue

-- Configuration for the pretty-printing functions
data PrettyConfig acc
newtype PrettyConfig acc
= PrettyConfig { confOperator :: forall aenv arrs.
PreOpenAcc acc aenv arrs
-> String
Expand Down Expand Up @@ -126,7 +122,7 @@ prettyPreOpenAfun
-> Val aenv
-> PreOpenAfun acc aenv f
-> Adoc
prettyPreOpenAfun config prettyAcc aenv0 = next (pretty '\\') aenv0
prettyPreOpenAfun config prettyAcc = next (pretty '\\')
where
next :: Adoc -> Val aenv' -> PreOpenAfun acc aenv' f' -> Adoc
next vs aenv (Abody body) =
Expand Down
Loading

0 comments on commit ce1db2b

Please sign in to comment.