Skip to content

Commit

Permalink
Precompute more chunk counts.
Browse files Browse the repository at this point in the history
This is mostly to track the change in the parallelisation of Replicate
in the preceding commit.
  • Loading branch information
athas committed Feb 27, 2023
1 parent 5ad43af commit 7bbf324
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/Futhark/CodeGen/ImpGen/GPU/Group.hs
Original file line number Diff line number Diff line change
Expand Up @@ -684,19 +684,25 @@ data Precomputed = Precomputed
segOpSizes :: Stms GPUMem -> SegOpSizes
segOpSizes = onStms
where
onStms = foldMap (onExp . stmExp)
onExp (Op (Inner (SegOp op))) =
onStms = foldMap onStm
onStm (Let _ _ (Op (Inner (SegOp op)))) =
case segVirt $ segLevel op of
SegNoVirtFull seq_dims ->
S.singleton $ map snd $ snd $ partitionSeqDims seq_dims $ segSpace op
_ -> S.singleton $ map snd $ unSegSpace $ segSpace op
onExp (BasicOp (Replicate shape _)) =
S.singleton $ shapeDims shape
onExp (Match _ cases defbody _) =
onStm (Let (Pat [pe]) _ (BasicOp (Replicate {}))) =
S.singleton $ arrayDims $ patElemType pe
onStm (Let (Pat [pe]) _ (BasicOp (Iota {}))) =
S.singleton $ arrayDims $ patElemType pe
onStm (Let (Pat [pe]) _ (BasicOp (Copy {}))) =
S.singleton $ arrayDims $ patElemType pe
onStm (Let (Pat [pe]) _ (BasicOp (Manifest {}))) =
S.singleton $ arrayDims $ patElemType pe
onStm (Let _ _ (Match _ cases defbody _)) =
foldMap (onStms . bodyStms . caseBody) cases <> onStms (bodyStms defbody)
onExp (DoLoop _ _ body) =
onStm (Let _ _ (DoLoop _ _ body)) =
onStms (bodyStms body)
onExp _ = mempty
onStm _ = mempty

-- | Precompute various constants and useful information.
precomputeConstants :: Count GroupSize (Imp.TExp Int64) -> Stms GPUMem -> CallKernelGen Precomputed
Expand Down

0 comments on commit 7bbf324

Please sign in to comment.