Skip to content

Commit

Permalink
Do not short-circuit into free blocks in SegOps.
Browse files Browse the repository at this point in the history
Not completely sure this is the right way to do it, but it works.
  • Loading branch information
athas committed Jul 8, 2023
1 parent 9be376f commit 0534f78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/Futhark/Optimise/ArrayShortCircuiting/ArrayCoalescing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,10 @@ shortCircuitSegOpHelper num_reds lvlOK lvl lutab pat@(Pat ps0) pat_certs space0
(aggSummaryMapPartial (scalarTable td_env) $ unSegSpace space0)
(S.toList s)
Undeterminable -> pure Undeterminable
let res = noMemOverlap td_env destination_uses source_writes
if res
-- Do not allow short-circuiting from a segop-local memory
-- block (not in the topdown scope) to an outer memory block.
if dstmem entry `M.member` scope td_env
&& noMemOverlap td_env destination_uses source_writes
then pure bu_env_f
else do
let (ac, inh) = markFailedCoal (activeCoals bu_env_f, inhibit bu_env_f) k
Expand Down
5 changes: 3 additions & 2 deletions tests/issue1774.fut
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
-- ==
-- structure mc-mem { Alloc 2 }
-- compiled random input { [3]f32 [100]f32 [10]f32 } auto output
-- structure mc-mem { Alloc 3 }

let f [n] [m] [l] (xs: [n]f32) (ys: [m]f32) (zs: *[l]f32) : [n][m]f32 =
map (\x ->
map (\y -> f32.sum (map (*y) (map (*x) zs)))
map (\y -> f32.sum (map (*y) (map (*x) zs)))
ys)
xs

Expand Down

0 comments on commit 0534f78

Please sign in to comment.