Skip to content

Commit

Permalink
Split permutationTableFromIndexTable into seperate functions
Browse files Browse the repository at this point in the history
  • Loading branch information
0scar committed Oct 11, 2023
1 parent b40602d commit 3d4cd50
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Futhark/Pass/CoalesceAccess.hs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ permutationTableFromIndexTable sortCoalescing =
-- a permutation instead of [DimIdxPat]
filterMap null $
filterMap null $
filterMap predPermutation convert
filterMap predPermutation (permutationFromMemoryEntry sortCoalescing)
where
-- wraps a function in a mapMaybe, if the predicate is true then return
-- nothing. When sequenced as above, the "nothings" will then propagate and
Expand All @@ -341,9 +341,8 @@ permutationTableFromIndexTable sortCoalescing =
predPermutation perm =
perm `L.isPrefixOf` [0 ..] || isNothing (isMapTranspose perm)

-- Sorts the dimensions in a given memory entry and returns it as
-- a permutation.
convert = map originalDimension . (sortCoalescing . dimensions)
permutationFromMemoryEntry :: ([DimIdxPat rep] -> [DimIdxPat rep]) -> MemoryEntry rep -> Permutation
permutationFromMemoryEntry ordering = map originalDimension . (ordering . dimensions)

lookupPermutation :: Ctx -> VName -> IndexExprName -> ArrayName -> Maybe Permutation
lookupPermutation ctx segName idxName arrayName =
Expand Down

0 comments on commit 3d4cd50

Please sign in to comment.