Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a108ad7
Made the lowering function for the atrace
MikevanHuizen2912 Feb 18, 2026
8ff2a8e
Made the atrace function
MikevanHuizen2912 Feb 18, 2026
858f6e8
Merge branch 'new-pipeline' of https://github.com/ivogabe/accelerate …
MikevanHuizen2912 Feb 19, 2026
4a7736c
Merge branch 'new-pipeline' of https://github.com/ivogabe/accelerate …
MikevanHuizen2912 Feb 19, 2026
c5c37d3
removed my old type of Atrace
MikevanHuizen2912 Feb 19, 2026
0d99df1
Finished the operations for atrace
MikevanHuizen2912 Feb 21, 2026
f686899
Implemented trace in simplify
MikevanHuizen2912 Feb 21, 2026
a1743f9
Adjusted the tupe of atrace otherwise it would be optimized out
MikevanHuizen2912 Feb 21, 2026
9bd5b8a
Implemented trace in substitution
MikevanHuizen2912 Feb 21, 2026
d30d4bf
Printing with inspectcompiler for operation
MikevanHuizen2912 Feb 21, 2026
38ce7c9
Used more of the TupR functions to make the code more clean
MikevanHuizen2912 Feb 24, 2026
70de6e1
Made the bounds check for atrace
MikevanHuizen2912 Feb 24, 2026
65cc5ab
uses of prettyTupR
MikevanHuizen2912 Feb 24, 2026
9f26292
use some of the predefined functions for the simplifyArrayDescriptor
MikevanHuizen2912 Feb 25, 2026
262ec74
implement trace in the LiveVars
MikevanHuizen2912 Feb 25, 2026
86d5302
add some reindex to export
MikevanHuizen2912 Feb 25, 2026
bb14d02
Made a new trace data type
MikevanHuizen2912 Feb 25, 2026
da5de1f
Add trace to the ILP
MikevanHuizen2912 Feb 25, 2026
54179be
will make idxset into a monoid
MikevanHuizen2912 Feb 26, 2026
781abf5
move the arrayDescriptor to idxset and made a new type for arrayDescr…
MikevanHuizen2912 Feb 26, 2026
adfd181
adjust the code to work with the new place and implementation of the …
MikevanHuizen2912 Feb 26, 2026
07b4dbb
Continued working on the Partial
MikevanHuizen2912 Feb 26, 2026
2dd239f
correct some small changes and rewrote a function
MikevanHuizen2912 Feb 26, 2026
a59c62a
Change all the TupR (ArrayDescriptor env) t to ArrayDescriptors env t
MikevanHuizen2912 Feb 26, 2026
52be505
remove unused language extention
MikevanHuizen2912 Feb 26, 2026
12970fa
remove some small accidental changes
MikevanHuizen2912 Feb 26, 2026
1a829af
actually use the available
MikevanHuizen2912 Feb 26, 2026
636d080
make a case for atrace in analyseSyncEnv'
MikevanHuizen2912 Feb 27, 2026
a110c74
remove the not needed exp type of trace
MikevanHuizen2912 Feb 27, 2026
a8258d1
remove a small mistake which caused atrace to dissapear
MikevanHuizen2912 Feb 27, 2026
f4ae999
remove reindexTupR and work with the new type arrayDescriptors
MikevanHuizen2912 Mar 1, 2026
ef4e83b
add a case for atrace
MikevanHuizen2912 Mar 1, 2026
e547ab8
use the new function I made
MikevanHuizen2912 Mar 1, 2026
184ed10
make it possible to weaken the trace function
MikevanHuizen2912 Mar 3, 2026
87f7fe9
Added trace to liveVars for partitioned
MikevanHuizen2912 Mar 3, 2026
cf32026
add the pretty print for atrace
MikevanHuizen2912 Mar 3, 2026
4b37b4c
set trivial on true for atrace
MikevanHuizen2912 Mar 3, 2026
1c4214a
add comment
MikevanHuizen2912 Mar 3, 2026
20eeeb9
add the functions that are called from accelerate-llvm
MikevanHuizen2912 Mar 4, 2026
daeb5aa
make the prettyprint prettier
MikevanHuizen2912 Mar 4, 2026
a38fff1
remove resolved TODOs
MikevanHuizen2912 Mar 5, 2026
8bbb1c5
Merge branch 'new-pipeline' of https://github.com/ivogabe/accelerate …
MikevanHuizen2912 Mar 8, 2026
1b0e459
fix bug where Atrace function would be stuck
MikevanHuizen2912 Mar 18, 2026
acfabe4
Merge branch 'new-pipeline' of https://github.com/Doppie23/accelerate…
MikevanHuizen2912 Mar 18, 2026
17eefe0
resolve bug where program signals are resolved to early
MikevanHuizen2912 Apr 2, 2026
15142af
remove added space
MikevanHuizen2912 Apr 2, 2026
71716e3
Merge branch 'new-pipeline' of https://github.com/ivogabe/accelerate …
MikevanHuizen2912 Apr 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Data/Array/Accelerate/AST/IdxSet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ instance Eq (IdxSet env) where
IdxSet (PNone a) == IdxSet (PNone b) = IdxSet a == IdxSet b
_ == _ = False

instance Semigroup (IdxSet env) where
(<>) = union

instance Monoid (IdxSet env) where
mempty = empty

overlaps :: IdxSet env -> IdxSet env -> Bool
overlaps (IdxSet (PPush _ _)) (IdxSet (PPush _ _)) = True
overlaps (IdxSet (PPush a _)) (IdxSet (PNone b )) = overlaps (IdxSet a) (IdxSet b)
Expand Down
42 changes: 36 additions & 6 deletions src/Data/Array/Accelerate/AST/Operation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,23 @@

Var', Exp', Fun', In, Out, Mut,

ArrayDescriptor(..), weakenArrayDescriptor,
ArrayDescriptor(..), ArrayDescriptors, weakenArrayDescriptor, weakenArrayDescriptors,

OpenExp, OpenFun, Exp, Fun, ArrayInstr(..),
expGroundVars, funGroundVars, arrayInstrsInExp, arrayInstrsInFun,

encodeGroundR, encodeGroundsR, encodeGroundVar, encodeGroundVars,
encodeGroundR, encodeGroundsR, encodeGroundVar, encodeGroundVars, encodeArrayDescriptors,
rnfGroundR, rnfGroundsR, rnfGroundVar, rnfGroundVars, rnfUniqueness,
liftGroundR, liftGroundsR, liftGroundVar, liftGroundVars,

bufferImpossible, groundFunctionImpossible,

paramIn, paramsIn, paramIn', paramsIn',

ReindexPartial, reindexArg, reindexArgs, reindexExp, reindexPreArgs, reindexVar, reindexVars,
ReindexPartial, reindexArg, reindexArgs, reindexExp, reindexPreArgs, reindexVar, reindexVars, reindexArrayDescriptors,
reindexIdxSet,
weakenReindex,
arrayDescriptorsIdxSet,
argVars, argsVars, argsInputs, argsOutputs, AccessGroundR(..),

mapAccExecutable, mapAfunExecutable,
Expand Down Expand Up @@ -187,7 +188,7 @@
-> PreOpenAcc op env a

Atrace :: Text
-> TupR (ArrayDescriptor env) t
-> ArrayDescriptors env t
-> PreOpenAcc op env Word8

-- | Asserts that the given expression evaluates to true.
Expand Down Expand Up @@ -295,9 +296,26 @@
-> GroundVars env (Buffers e)
-> ArrayDescriptor env (Array sh e)

type ArrayDescriptors env = TupR (ArrayDescriptor env)

weakenArrayDescriptors :: env :> env' -> ArrayDescriptors env a -> ArrayDescriptors env' a
weakenArrayDescriptors k = mapTupR (weakenArrayDescriptor k)

weakenArrayDescriptor :: env :> env' -> ArrayDescriptor env a -> ArrayDescriptor env' a
weakenArrayDescriptor k (ArrayDescriptor shr sh buffers) = ArrayDescriptor shr (weakenVars k sh) (weakenVars k buffers)

arrayDescriptorIdxSet :: ArrayDescriptor env t -> IdxSet env
arrayDescriptorIdxSet (ArrayDescriptor _ sh buffers) = IdxSet.fromVars sh `IdxSet.union` IdxSet.fromVars buffers

arrayDescriptorsIdxSet :: ArrayDescriptors env t -> IdxSet env
arrayDescriptorsIdxSet = foldMapTupR arrayDescriptorIdxSet

encodeArrayDescriptors :: ArrayDescriptors env t -> Builder
encodeArrayDescriptors = encodeTupR encodeArrayDescriptor

encodeArrayDescriptor :: ArrayDescriptor env t -> Builder
encodeArrayDescriptor (ArrayDescriptor shape sh buffer) = encodeShapeR shape <> encodeGroundVars sh <> encodeGroundVars buffer

Check warning on line 317 in src/Data/Array/Accelerate/AST/Operation.hs

View workflow job for this annotation

GitHub Actions / stack | ubuntu-latest-x64

This binding for ‘shape’ shadows the existing binding

Check warning on line 317 in src/Data/Array/Accelerate/AST/Operation.hs

View workflow job for this annotation

GitHub Actions / stack | windows-latest-x64

This binding for `shape' shadows the existing binding

Check warning on line 317 in src/Data/Array/Accelerate/AST/Operation.hs

View workflow job for this annotation

GitHub Actions / stack | macOS-latest-x64

This binding for ‘shape’ shadows the existing binding

-- | The arguments to be passed to an operation of type `t`.
-- This type is represented as a cons list, separated by (->) and ending
-- in (). This function type represents the type of the operations.
Expand Down Expand Up @@ -418,7 +436,7 @@
instance HasGroundsR (PreOpenAcc op env) where
groundsR (Exec _ _) = TupRunit
groundsR (Return vars) = groundsR vars
groundsR (Manifest var) = groundsR var
groundsR (Manifest var) = groundsR var
groundsR (Compute e) = groundsR e
groundsR (Alet _ _ _ a) = groundsR a
groundsR (Alloc _ tp _) = TupRsingle $ GroundRbuffer tp
Expand All @@ -428,6 +446,7 @@
groundsR (Awhile _ _ _ a) = groundsR a
groundsR (Aassert _ _) = TupRsingle $ GroundRscalar scalarTypeWord8
groundsR (Aassume _) = TupRsingle $ GroundRscalar scalarTypeWord8
groundsR (Atrace _ _) = TupRsingle $ GroundRscalar scalarTypeWord8
groundsR (Fence _ a) = groundsR a

instance HasGroundsR (GroundVar env) where
Expand Down Expand Up @@ -585,13 +604,19 @@
reindexAcc r (Awhile tr poa poa' tr') = Awhile tr <$> reindexAfun r poa <*> reindexAfun r poa' <*> reindexVars r tr'
reindexAcc r (Aassert msg cond) = Aassert msg <$> reindexExp r cond
reindexAcc r (Aassume cond) = Aassume <$> reindexExp r cond
reindexAcc r (Atrace msg t) = Atrace msg <$> reindexArrayDescriptors r t
reindexAcc r (Fence set e) = Fence <$> reindexIdxSet r set <*> reindexAcc r e

reindexArrayDescriptors :: (Applicative f) => ReindexPartial f env env' -> ArrayDescriptors env a -> f (ArrayDescriptors env' a)
reindexArrayDescriptors k = traverseTupR (reindexArrayDescriptor k)

reindexArrayDescriptor :: Applicative f => ReindexPartial f env env' -> ArrayDescriptor env a -> f (ArrayDescriptor env' a)
reindexArrayDescriptor k (ArrayDescriptor shr sh buffers) = ArrayDescriptor shr <$> reindexVars k sh <*> reindexVars k buffers

reindexAfun :: Applicative f => ReindexPartial f env env' -> PreOpenAfun op env t -> f (PreOpenAfun op env' t)
reindexAfun r (Abody poa) = Abody <$> reindexAcc r poa
reindexAfun r (Alam lhs poa) = reindexLHS r lhs $ \lhs' r' -> Alam lhs' <$> reindexAfun r' poa


reindexLHS :: Applicative f => ReindexPartial f env env' -> LeftHandSide s t env env1 -> (forall env1'. LeftHandSide s t env' env1' -> ReindexPartial f env1 env1' -> r) -> r
reindexLHS r (LeftHandSideSingle st) k = k (LeftHandSideSingle st) $ \case
ZeroIdx -> pure ZeroIdx
Expand Down Expand Up @@ -670,6 +695,7 @@
Awhile uniqueness c g a -> Awhile uniqueness (mapAfunExecutable f c) (mapAfunExecutable f g) a
Aassert msg cond -> Aassert msg cond
Aassume cond -> Aassume cond
Atrace msg t -> Atrace msg t
Fence set e -> Fence set (mapAccExecutable f e)

mapAfunExecutable :: (forall args benv'. op args -> Args benv' args -> op' args) -> PreOpenAfun op benv t -> PreOpenAfun op' benv t
Expand Down Expand Up @@ -703,8 +729,12 @@
rnf (Awhile us cond step initial) = rnfTupR rnfUniqueness us `seq` rnf cond `seq` rnf step `seq` rnfGroundVars initial
rnf (Aassert _ cond) = rnfOpenExp cond
rnf (Aassume cond) = rnfOpenExp cond
rnf (Atrace _ t) = rnfTupR rnf t
rnf (Fence set a) = IdxSet.rnfIdxSet set `seq` rnf a

instance NFData (ArrayDescriptor env a) where
rnf (ArrayDescriptor shr sh buffers) = rnfShapeR shr `seq` rnfGroundVars sh `seq` rnfGroundVars buffers

instance NFData' op => NFData (OperationAfun op env a) where
rnf (Abody a) = rnf a
rnf (Alam lhs f) = rnfLeftHandSide rnfGroundR lhs `seq` rnf f
Expand Down
3 changes: 3 additions & 0 deletions src/Data/Array/Accelerate/AST/Schedule/Uniform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ data Effect kernel env where

Aassert :: Text -> Exp env PrimBool -> Effect kernel env

Atrace :: Text -> ArrayDescriptors env t -> Effect kernel env

-- A base value in the schedule is a scalar, buffer, a signal (resolver)
-- or a (possibly mutable) reference
--
Expand Down Expand Up @@ -399,6 +401,7 @@ effectFreeVars (SignalAwait signals) = IdxSet.fromList $ map Exists $ signal
effectFreeVars (SignalResolve resolvers) = IdxSet.fromList $ map Exists resolvers
effectFreeVars (RefWrite ref value) = IdxSet.insertVar ref $ IdxSet.singletonVar value
effectFreeVars (Aassert _ cond) = bindingFreeVars $ Compute cond
effectFreeVars (Atrace _ t) = arrayDescriptorsIdxSet t

sargVar :: SArg env t -> Exists (Idx env)
sargVar (SArgScalar v) = Exists $ varIdx v
Expand Down
4 changes: 4 additions & 0 deletions src/Data/Array/Accelerate/Analysis/Hash/Schedule/Uniform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ encodeEffect = \case
intHost $(hashQ "Aassert")
<> intHost (Hashable.hash msg)
<> encodeOpenExp cond
Atrace msg t ->
intHost $(hashQ "Atrace")
<> intHost (Hashable.hash msg)
<> encodeArrayDescriptors t

encodeIO :: InputOutputR input output -> Builder
encodeIO = \case
Expand Down
5 changes: 5 additions & 0 deletions src/Data/Array/Accelerate/Pretty/Operation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ prettyOpenAcc env = \case
<> hardline <> hang 4 (" ( " <> prettyOpenAfun env step)
<> hardline <> " )"
<> hardline <> indent 2 (prettyVars (val env) 10 initial)
Atrace msg t ->
hang 2 (group $ vsep [annotate Statement "atrace", prettyText msg, prettyArrayDescriptor (val env) t])
Aassert msg g ->
hang 2 (group $ vsep [annotate Statement "assert", prettyText msg, prettyExp (val env) g])
Aassume g ->
Expand All @@ -112,6 +114,9 @@ prettyOpenAcc env = \case
<> hardline
<> prettyOpenAcc env next

prettyArrayDescriptor :: Val env -> ArrayDescriptors env t -> Adoc
prettyArrayDescriptor env = prettyTupR (\p (ArrayDescriptor _ sh buffer) -> prettyShapeVars env sh <+> " " <+> prettyVars env p buffer) 0

prettyArgs :: Val benv -> Args benv f -> Adoc
prettyArgs env args = tupled $ map (\(Exists a) -> prettyArg env a) $ argsToList args

Expand Down
6 changes: 6 additions & 0 deletions src/Data/Array/Accelerate/Pretty/Schedule/Uniform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ prettyEffect env = \case
SignalResolve signals -> hang 2 $ group $ vsep [annotate Statement "resolve", list $ map (prettyIdx env) signals]
RefWrite ref value -> hang 2 $ group $ vsep ["*" <> prettyVar env ref <+> "=", prettyVar env value]
Aassert msg cond -> hang 2 $ group $ vsep [annotate Statement "assert", prettyText msg, prettyExp (val env) cond]
Atrace msg t -> hang 2 $ group $ vsep [annotate Statement "atrace", prettyText msg, prettyArrayDescriptors env t]

prettyKernelFun :: forall kernel env f. PrettyKernel kernel => Val' env -> KernelFun kernel f -> SArgs env f -> Adoc
prettyKernelFun env fun args = case prettyKernel of
Expand Down Expand Up @@ -233,3 +234,8 @@ prettyShapeVars :: Val' env -> Vars s env sh -> Adoc
prettyShapeVars _ TupRunit = "Z"
prettyShapeVars env vars = encloseSep "Z :. " "" " :. " $ map (\(Exists v) -> prettyVar env v) $ flattenTupR vars

prettyArrayDescriptors :: Val' env -> ArrayDescriptors env t -> Adoc
prettyArrayDescriptors env = foldMapTupR (prettyArrayDescriptor env)

prettyArrayDescriptor :: Val' env -> ArrayDescriptor env t -> Adoc
prettyArrayDescriptor env (ArrayDescriptor _ sh buffer) = "Array: (" <+> prettyShapeVars env sh <+> prettyVars env 0 buffer <+> ")"
2 changes: 2 additions & 0 deletions src/Data/Array/Accelerate/Trafo/Operation/Bounds.hs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ boundsOptimizeAcc env@(BoundsEnv _ _ zero bindings) acc = case acc of
, env'' <- env{ boundsGraph = boundsGraphClearNodes (boundsGraph env) $ accIdxSet modified }
-> (IdxSet.empty, env'', bottomsGround zero $ groundsR acc, Fence set $ body')

Atrace msg t -> (IdxSet.empty, env, TupRsingle $ bottom zero scalarTypeWord8, Atrace msg t)

Aassert msg expr
| (_, expr') <- boundsOptimizeExp env expr
, expr'' <- simplifyExp expr'
Expand Down
15 changes: 14 additions & 1 deletion src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
stronglyLiveVariables, stronglyLiveVariablesFun,

SLVOperation(..), ShrinkOperation(..), ShrunkOperation(..), SubArgs(..), SubArg(..),
reEnvArrayInstr,
reEnvArrayInstr,
reEnvArrayDescriptors,
ShrinkArg(..), shrinkArgs, composeSubArgs,

defaultSlvGenerate, defaultSlvMap, defaultSlvBackpermute,
Expand Down Expand Up @@ -211,6 +212,15 @@
liveness3
$ \re _ ->
Left $ Awhile us' (condition' re) (step' re) $ expectJust $ reEnvVars re initial
Atrace msg t
| free <- arrayDescriptorsIdxSet t
, liveness1 <- setIdxSetLive free liveness ->
LVAnalysis
liveness1
$ \re s -> case s of
SubTupRkeep -> Right $ Atrace msg $ reEnvArrayDescriptors re t
SubTupRskip -> Right $ Return TupRunit

Fence set next
| liveness1 <- setIdxSetLive set liveness
, LVAnalysis liveness2 next' <- stronglyLiveVariables' liveness1 returns us next ->
Expand Down Expand Up @@ -307,7 +317,7 @@
defaultSlvGenerate
:: (forall sh' t'. op (Fun' (sh' -> t') -> Out sh' t' -> ()))
-> Maybe (ShrinkOperation op (Fun' (sh -> t) -> Out sh t -> ()))
defaultSlvGenerate mkGenerate = Just $ ShrinkOperation $ \subArgs args@(ArgFun f :>: array :>: ArgsNil) _ -> case subArgs of

Check warning on line 320 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | ubuntu-latest-x64

Pattern match(es) are non-exhaustive

Check warning on line 320 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | windows-latest-x64

Pattern match(es) are non-exhaustive

Check warning on line 320 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | macOS-latest-x64

Pattern match(es) are non-exhaustive
SubArgKeep `SubArgsLive` SubArgKeep `SubArgsLive` SubArgsNil
-> ShrunkOperation mkGenerate args
SubArgKeep `SubArgsLive` SubArgOut subTp `SubArgsLive` SubArgsNil
Expand All @@ -317,7 +327,7 @@
defaultSlvMap
:: (forall sh' s' t'. op (Fun' (s' -> t') -> In sh' s' -> Out sh' t' -> ()))
-> Maybe (ShrinkOperation op (Fun' (s -> t) -> In sh s -> Out sh t -> ()))
defaultSlvMap mkMap = Just $ ShrinkOperation $ \subArgs args@(ArgFun f :>: input :>: output :>: ArgsNil) _ -> case subArgs of

Check warning on line 330 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | ubuntu-latest-x64

Pattern match(es) are non-exhaustive

Check warning on line 330 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | windows-latest-x64

Pattern match(es) are non-exhaustive

Check warning on line 330 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | macOS-latest-x64

Pattern match(es) are non-exhaustive
SubArgKeep `SubArgsLive` SubArgKeep `SubArgsLive` SubArgKeep `SubArgsLive` SubArgsNil
-> ShrunkOperation mkMap args
SubArgKeep `SubArgsLive` SubArgKeep `SubArgsLive` SubArgOut subTp `SubArgsLive` SubArgsNil
Expand All @@ -327,7 +337,7 @@
defaultSlvBackpermute
:: (forall sh1' sh2' t'. op (Fun' (sh2' -> sh1') -> In sh1' t' -> Out sh2' t' -> ()))
-> Maybe (ShrinkOperation op (Fun' (sh2 -> sh1) -> In sh1 t -> Out sh2 t -> ()))
defaultSlvBackpermute mkBackpermute = Just $ ShrinkOperation $ \subArgs args@(f :>: ArgArray In (ArrayR shr r) sh buf :>: output :>: ArgsNil) _ -> case subArgs of

Check warning on line 340 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | ubuntu-latest-x64

Pattern match(es) are non-exhaustive

Check warning on line 340 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | windows-latest-x64

Pattern match(es) are non-exhaustive

Check warning on line 340 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | macOS-latest-x64

Pattern match(es) are non-exhaustive
SubArgKeep `SubArgsLive` SubArgKeep `SubArgsLive` SubArgKeep `SubArgsLive` SubArgsNil
-> ShrunkOperation mkBackpermute args
SubArgKeep `SubArgsLive` SubArgKeep `SubArgsLive` SubArgOut s `SubArgsLive` SubArgsNil
Expand All @@ -348,6 +358,9 @@
reEnvArg re (ArgFun f) = ArgFun $ mapArrayInstrFun (reEnvArrayInstr re) f
reEnvArg re (ArgArray m repr sh buffers) = ArgArray m repr (expectJust $ reEnvVars re sh) (expectJust $ reEnvVars re buffers)

reEnvArrayDescriptors :: ReEnv env subenv -> ArrayDescriptors env t -> TupR (ArrayDescriptor subenv) t
reEnvArrayDescriptors re = expectJust . traverseTupR (\(ArrayDescriptor shape sh buffer) -> ArrayDescriptor shape <$> reEnvVars re sh <*> reEnvVars re buffer)

Check warning on line 362 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | ubuntu-latest-x64

This binding for ‘shape’ shadows the existing binding

Check warning on line 362 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | windows-latest-x64

This binding for `shape' shadows the existing binding

Check warning on line 362 in src/Data/Array/Accelerate/Trafo/Operation/LiveVars.hs

View workflow job for this annotation

GitHub Actions / stack | macOS-latest-x64

This binding for ‘shape’ shadows the existing binding

-- Captures existential f'
data ReEnvSubArgs subenv f where
ReEnvSubArgs :: SubArgs f f'
Expand Down
13 changes: 13 additions & 0 deletions src/Data/Array/Accelerate/Trafo/Operation/Simplify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ simplify' uniquenesses = \case
$ awhileSimplifyInvariant us (cond' env') (step' env') $ simplifyReturnVars env us initial
)

Atrace msg t ->
let
set = arrayDescriptorsIdxSet t
in
( set
, \env ->
fence (syncSubstitutes env set)
$ Atrace msg $ simplifyArrayDescriptor env t
)

Aassert msg cond ->
( IdxSet.empty
, \env ->
Expand Down Expand Up @@ -379,6 +389,9 @@ simplify' uniquenesses = \case
(next' env')
)

simplifyArrayDescriptor :: InfoEnv env -> ArrayDescriptors env t -> ArrayDescriptors env t
simplifyArrayDescriptor env = mapTupR (\(ArrayDescriptor shape sh buffers) -> ArrayDescriptor shape (mapTupR (weaken $ substitute env) sh) (mapTupR (weaken $ substitute env) buffers))

-- Given an environment, the set of updated variables and a list of copies of
-- an operation, checks whether the operation copies all its outputs from
-- undefined buffers.
Expand Down
5 changes: 5 additions & 0 deletions src/Data/Array/Accelerate/Trafo/Operation/Substitution.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ reindexArrayInstr' k (Parameter v) = Parameter <$> reindexVar' k v
reindexExp' :: (Applicative f, RebuildableExp e) => SunkReindexPartial f benv benv' -> e (ArrayInstr benv) env t -> f (e (ArrayInstr benv') env t)
reindexExp' k = rebuildArrayInstrPartial (rebuildArrayInstrMap $ reindexArrayInstr' k)

reindexArrayDescriptor' :: (Applicative f) => SunkReindexPartial f env env' -> ArrayDescriptors env t -> f (TupR (ArrayDescriptor env') t)
reindexArrayDescriptor' k = traverseTupR (\(ArrayDescriptor shape sh buffer) -> ArrayDescriptor shape <$> reindexVars' k sh <*> reindexVars' k buffer)

reindexIdxSet'
:: forall f env env' . Applicative f
=> SunkReindexPartial f env env'
Expand All @@ -127,6 +130,7 @@ reindexA' k = \case
Unit var -> Unit <$> reindexVar' k var
Acond c t f -> Acond <$> reindexVar' k c <*> travA t <*> travA f
Awhile uniqueness c f i -> Awhile uniqueness <$> reindexAfun' k c <*> reindexAfun' k f <*> reindexVars' k i
Atrace msg t -> Atrace msg <$> reindexArrayDescriptor' k t
Aassert msg g -> Aassert msg <$> reindexExp' k g
Aassume g -> Aassume <$> reindexExp' k g
Fence set next -> Fence <$> reindexIdxSet' k set <*> travA next
Expand Down Expand Up @@ -183,6 +187,7 @@ makeManifest acc = case acc of
-- condition is evaluated at compile time.
Acond c t f -> Acond c (makeManifest t) (makeManifest f)
Awhile{} -> acc -- Can't fuse anyway
Atrace{} -> acc -- Same as compute
Return vars -> go vars
Fence set next -> Fence set $ makeManifest next
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ openReconstruct' singletons labelenv graph clusterslist mlab subclustersmap symb
SBlk {} -> error "wrong type: block"
SRet env' vars -> Exists $ Return (fromJust $ reindexVars (mkReindexPartial' env' env) vars)
SCmp env' expr -> Exists $ Compute (fromJust $ reindexExp (mkReindexPartial' env' env) expr)
SAtr msg env' t -> Exists $ Atrace msg (fromJust $ reindexArrayDescriptors (mkReindexPartial' env' env) t)
SAsr msg env' expr -> Exists $ Aassert msg (fromJust $ reindexExp (mkReindexPartial' env' env) expr)
SAsu env' expr -> Exists $ Aassume (fromJust $ reindexExp (mkReindexPartial' env' env) expr)
SAlc env' shr e sh -> Exists $ Alloc shr e (fromJust $ reindexVars (mkReindexPartial' env' env) sh)
Expand Down
9 changes: 9 additions & 0 deletions src/Data/Array/Accelerate/Trafo/Partitioning/ILP/Graph.hs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ data Symbol (op :: Type -> Type) where
SCmp :: Env env -> Exp env a -> Symbol op
SAlc :: Env env -> ShapeR sh -> ScalarType e -> ExpVars env sh -> Symbol op
SUnt :: Env env -> ExpVar env e -> Symbol op
SAtr :: Text -> Env env -> ArrayDescriptors env t -> Symbol op
SAsr :: Text -> Env env -> Exp env PrimBool -> Symbol op
SAsu :: Env env -> Exp env PrimBool -> Symbol op
SFen :: Env env -> IdxSet env -> Symbol op
Expand All @@ -590,6 +591,7 @@ instance Show (Symbol op) where
show (SCmp {}) = "Cmp"
show (SAlc {}) = "Alc"
show (SUnt {}) = "Unt"
show (SAtr {}) = "Atr"
show (SAsr {}) = "Asr"
show (SAsu {}) = "Asu"
show (SFen {}) = "Fen"
Expand Down Expand Up @@ -1058,6 +1060,13 @@ mkFusionGraph (Awhile u cond body init) = do
symbol whileN ?= SWhl env condN bodyN init u
return res -- to return a fresh value of the same type as the initial value.

mkFusionGraph (Atrace msg t) = do
c <- freshComp
env <- use environment
c `requiresBuffers` getIdxSetDeps (arrayDescriptorsIdxSet t) env
symbol c ?= SAtr msg env t
TupRsingle <$> freshVal c (GroundRscalar scalarTypeWord8)

mkFusionGraph (Aassert msg cond) = do
c <- freshComp
env <- use environment
Expand Down
Loading
Loading