Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
vox9 committed Oct 13, 2024
1 parent b246be0 commit 2e21d68
Show file tree
Hide file tree
Showing 35 changed files with 588 additions and 564 deletions.
2 changes: 1 addition & 1 deletion src/Futhark/CLI/REPL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ typeCommand = genTypeCommand parseExp T.checkExp $ \(ps, e) ->
annotate italicized $
"\n\nPolymorphic in"
<+> mconcat (intersperse " " $ map pretty ps)
<> "."
<> "."
else mempty

mtypeCommand :: Command
Expand Down
46 changes: 23 additions & 23 deletions src/Futhark/CodeGen/Backends/GenericPython/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,48 +126,48 @@ instance Pretty PyStmt where
pretty (If cond [] []) =
"if"
<+> pretty cond
<> ":"
</> indent 2 "pass"
<> ":"
</> indent 2 "pass"
pretty (If cond [] fbranch) =
"if"
<+> pretty cond
<> ":"
</> indent 2 "pass"
</> "else:"
</> indent 2 (stack $ map pretty fbranch)
<> ":"
</> indent 2 "pass"
</> "else:"
</> indent 2 (stack $ map pretty fbranch)
pretty (If cond tbranch []) =
"if"
<+> pretty cond
<> ":"
</> indent 2 (stack $ map pretty tbranch)
<> ":"
</> indent 2 (stack $ map pretty tbranch)
pretty (If cond tbranch fbranch) =
"if"
<+> pretty cond
<> ":"
</> indent 2 (stack $ map pretty tbranch)
</> "else:"
</> indent 2 (stack $ map pretty fbranch)
<> ":"
</> indent 2 (stack $ map pretty tbranch)
</> "else:"
</> indent 2 (stack $ map pretty fbranch)
pretty (Try pystms pyexcepts) =
"try:"
</> indent 2 (stack $ map pretty pystms)
</> stack (map pretty pyexcepts)
pretty (While cond body) =
"while"
<+> pretty cond
<> ":"
</> indent 2 (stack $ map pretty body)
<> ":"
</> indent 2 (stack $ map pretty body)
pretty (For i what body) =
"for"
<+> pretty i
<+> "in"
<+> pretty what
<> ":"
</> indent 2 (stack $ map pretty body)
<> ":"
</> indent 2 (stack $ map pretty body)
pretty (With what body) =
"with"
<+> pretty what
<> ":"
</> indent 2 (stack $ map pretty body)
<> ":"
</> indent 2 (stack $ map pretty body)
pretty (Assign e1 e2) = pretty e1 <+> "=" <+> pretty e2
pretty (AssignOp op e1 e2) = pretty e1 <+> pretty (op ++ "=") <+> pretty e2
pretty (Comment s body) = "#" <> pretty s </> stack (map pretty body)
Expand All @@ -188,16 +188,16 @@ instance Pretty PyFunDef where
pretty (Def fname params body) =
"def"
<+> pretty fname
<> parens (commasep $ map pretty params)
<> ":"
</> indent 2 (stack (map pretty body))
<> parens (commasep $ map pretty params)
<> ":"
</> indent 2 (stack (map pretty body))

instance Pretty PyClassDef where
pretty (Class cname body) =
"class"
<+> pretty cname
<> ":"
</> indent 2 (stack (map pretty body))
<> ":"
</> indent 2 (stack (map pretty body))

instance Pretty PyExcept where
pretty (Catch pyexp stms) =
Expand Down
26 changes: 13 additions & 13 deletions src/Futhark/CodeGen/ImpCode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,8 @@ instance (Pretty op) => Pretty (Code op) where
<> pretty space
<> rangle
<> brackets (pretty i)
<+> "<-"
<+> pretty val
<+> "<-"
<+> pretty val
where
vol' = case vol of
Volatile -> "volatile "
Expand All @@ -591,12 +591,12 @@ instance (Pretty op) => Pretty (Code op) where
pretty name
<+> "<-"
<+> pretty v
<> langle
<> vol'
<> pretty bt
<> pretty space
<> rangle
<> brackets (pretty is)
<> langle
<> vol'
<> pretty bt
<> pretty space
<> rangle
<> brackets (pretty is)
where
vol' = case vol of
Volatile -> "volatile "
Expand All @@ -614,17 +614,17 @@ instance (Pretty op) => Pretty (Code op) where
<> (parens . align)
( foldMap (brackets . pretty) shape
<> ","
</> p dst dstspace dstoffset dststrides
<> ","
</> p src srcspace srcoffset srcstrides
</> p dst dstspace dstoffset dststrides
<> ","
</> p src srcspace srcoffset srcstrides
)
where
p mem space offset strides =
pretty mem
<> pretty space
<> "+"
<> pretty offset
<+> foldMap (brackets . pretty) strides
<+> foldMap (brackets . pretty) strides
pretty (If cond tbranch fbranch) =
"if"
<+> pretty cond
Expand All @@ -642,7 +642,7 @@ instance (Pretty op) => Pretty (Code op) where
<+> commasep (map pretty dests)
<+> "<-"
<+> pretty fname
<> parens (commasep $ map pretty args)
<> parens (commasep $ map pretty args)
pretty (Comment s code) =
"--" <+> pretty s </> pretty code
pretty (DebugPrint desc (Just e)) =
Expand Down
58 changes: 29 additions & 29 deletions src/Futhark/CodeGen/ImpCode/GPU.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ instance Pretty HostOp where
pretty dest
<+> "<-"
<+> "get_size"
<> parens (commasep [pretty key, pretty size_class])
<> parens (commasep [pretty key, pretty size_class])
pretty (GetSizeMax dest size_class) =
pretty dest <+> "<-" <+> "get_size_max" <> parens (pretty size_class)
pretty (CmpSizeLe dest name size_class x) =
pretty dest
<+> "<-"
<+> "get_size"
<> parens (commasep [pretty name, pretty size_class])
<+> "<"
<+> pretty x
<> parens (commasep [pretty name, pretty size_class])
<+> "<"
<+> pretty x
pretty (CallKernel c) =
pretty c

Expand Down Expand Up @@ -223,17 +223,17 @@ instance Pretty KernelOp where
pretty dest
<+> "<-"
<+> "get_tblock_id"
<> parens (pretty i)
<> parens (pretty i)
pretty (GetLocalId dest i) =
pretty dest
<+> "<-"
<+> "get_local_id"
<> parens (pretty i)
<> parens (pretty i)
pretty (GetLocalSize dest i) =
pretty dest
<+> "<-"
<+> "get_local_size"
<> parens (pretty i)
<> parens (pretty i)
pretty (GetLockstepWidth dest) =
pretty dest
<+> "<-"
Expand All @@ -256,68 +256,68 @@ instance Pretty KernelOp where
pretty old
<+> "<-"
<+> "atomic_add_"
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
pretty (Atomic _ (AtomicFAdd t old arr ind x)) =
pretty old
<+> "<-"
<+> "atomic_fadd_"
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
pretty (Atomic _ (AtomicSMax t old arr ind x)) =
pretty old
<+> "<-"
<+> "atomic_smax"
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
pretty (Atomic _ (AtomicSMin t old arr ind x)) =
pretty old
<+> "<-"
<+> "atomic_smin"
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
pretty (Atomic _ (AtomicUMax t old arr ind x)) =
pretty old
<+> "<-"
<+> "atomic_umax"
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
pretty (Atomic _ (AtomicUMin t old arr ind x)) =
pretty old
<+> "<-"
<+> "atomic_umin"
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
pretty (Atomic _ (AtomicAnd t old arr ind x)) =
pretty old
<+> "<-"
<+> "atomic_and"
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
pretty (Atomic _ (AtomicOr t old arr ind x)) =
pretty old
<+> "<-"
<+> "atomic_or"
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
pretty (Atomic _ (AtomicXor t old arr ind x)) =
pretty old
<+> "<-"
<+> "atomic_xor"
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
pretty (Atomic _ (AtomicCmpXchg t old arr ind x y)) =
pretty old
<+> "<-"
<+> "atomic_cmp_xchg"
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x, pretty y])
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x, pretty y])
pretty (Atomic _ (AtomicXchg t old arr ind x)) =
pretty old
<+> "<-"
<+> "atomic_xchg"
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
<> pretty t
<> parens (commasep [pretty arr <> brackets (pretty ind), pretty x])
pretty (Atomic _ (AtomicWrite t arr ind x)) =
"atomic_write"
<> pretty t
Expand Down
10 changes: 5 additions & 5 deletions src/Futhark/CodeGen/ImpGen/GPU/SegHist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ histKernelGlobalPass map_pes num_tblocks tblock_size space slugs kbody histogram
chk_beg
.<=. flat_bucket
.&&. flat_bucket
.<. (chk_beg + hist_H_chk)
.<. (chk_beg + hist_H_chk)
.&&. inBounds (Slice (map DimFix bucket')) dest_shape'
vs_params = takeLast (length vs') $ lambdaParams lam

Expand Down Expand Up @@ -748,9 +748,9 @@ histKernelLocalPass
bucket_in_bounds =
inBounds (Slice (map DimFix bucket')) dest_shape'
.&&. chk_beg
.<=. flat_bucket
.<=. flat_bucket
.&&. flat_bucket
.<. (chk_beg + tvExp hist_H_chk)
.<. (chk_beg + tvExp hist_H_chk)
bucket_is =
[sExt64 thread_local_subhisto_i, flat_bucket - chk_beg]
vs_params = takeLast (length vs') $ lambdaParams lam
Expand Down Expand Up @@ -1021,9 +1021,9 @@ localMemoryCase map_pes hist_T space hist_H hist_el_size hist_N _ slugs kbody =
.&&. (local_mem_needed .<=. tvExp hist_L)
.&&. (hist_S .<=. max_S)
.&&. hist_C
.<=. hist_B
.<=. hist_B
.&&. tvExp hist_M
.>. 0
.>. 0

run = do
emit $ Imp.DebugPrint "## Using shared memory" Nothing
Expand Down
8 changes: 4 additions & 4 deletions src/Futhark/CodeGen/ImpGen/GPU/SegRed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ smallSegmentsReduction (Pat segred_pes) num_tblocks tblock_size _ space segbinop
.>. 0
.&&. isActive (init $ zip gtids dims)
.&&. ltid
.<. segment_size
* segments_per_block
.<. segment_size
* segments_per_block
)
in_bounds
out_of_bounds
Expand All @@ -460,8 +460,8 @@ smallSegmentsReduction (Pat segred_pes) num_tblocks tblock_size _ space segbinop
( sExt64 virttblock_id
* segments_per_block
+ sExt64 ltid
.<. num_segments
.&&. ltid
.<. num_segments
.&&. ltid
.<. segments_per_block
)
$ forM2_ segred_pes (concat reds_arrs)
Expand Down
8 changes: 4 additions & 4 deletions src/Futhark/IR/GPU/Op.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ instance PP.Pretty KernelGrid where
"grid="
<> pretty num_tblocks
<> PP.semi
<+> "blocksize="
<> pretty tblock_size
<+> "blocksize="
<> pretty tblock_size

instance PP.Pretty SegLevel where
pretty (SegThread virt grid) =
Expand Down Expand Up @@ -210,8 +210,8 @@ instance PP.Pretty SizeOp where
pretty (CmpSizeLe name size_class x) =
"cmp_size"
<> parens (commasep [pretty name, pretty size_class])
<+> "<="
<+> pretty x
<+> "<="
<+> pretty x
pretty (CalcNumBlocks w max_num_tblocks tblock_size) =
"calc_num_tblocks" <> parens (commasep [pretty w, pretty max_num_tblocks, pretty tblock_size])

Expand Down
Loading

0 comments on commit 2e21d68

Please sign in to comment.