Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ce1f676
Hoist BoundsChecking
vidsinghal Sep 11, 2025
b99da19
Wip: Introduce mutable cursors for updating cursor value in place
vidsinghal Sep 12, 2025
006e8d4
add all possible correct answers
vidsinghal Sep 14, 2025
d9a25a4
save
vidsinghal Sep 14, 2025
8bc6eab
Make sure output locations are re-written to in redirection case
vidsinghal Sep 14, 2025
1f39a21
add region to type env
vidsinghal Sep 14, 2025
dbaecd4
edit error message
vidsinghal Sep 15, 2025
e1e569b
fix dereferencing mutable cursor, add nested soa examples, add colobu…
vidsinghal Sep 16, 2025
f410dc6
remove swp file
vidsinghal Sep 16, 2025
d842bce
Hoist BoundsChecking
vidsinghal Sep 11, 2025
e1793a6
fix redirections case
vidsinghal Sep 20, 2025
da11f7e
fix indirection in case bindings
vidsinghal Sep 20, 2025
6739846
edits
vidsinghal Sep 20, 2025
71bbc74
support SoA indirections when GC is off
vidsinghal Sep 20, 2025
6d6b42d
add new version of colobus to test suite with indirections without gc
vidsinghal Sep 20, 2025
1f413e8
restore test
vidsinghal Sep 20, 2025
9829a27
fix failing tests
vidsinghal Sep 21, 2025
977b09f
fixing indirections
vidsinghal Sep 22, 2025
2401ed1
new test
vidsinghal Sep 22, 2025
028e574
fixing indirections
vidsinghal Sep 23, 2025
d52c8f1
wip : fixing abs ran access
vidsinghal Sep 25, 2025
967741e
wip
vidsinghal Sep 25, 2025
66be049
wip fixing ran
vidsinghal Sep 26, 2025
04d4a84
add new func to test
vidsinghal Sep 26, 2025
9e90b9e
thread loc to var env in cursorize
vidsinghal Sep 27, 2025
423e6a6
add soa random access to test suite
vidsinghal Sep 27, 2025
ffba4ba
check in file
vidsinghal Sep 29, 2025
260d045
edits
vidsinghal Oct 7, 2025
55874ec
use clang
vidsinghal Oct 8, 2025
9906197
edits
vidsinghal Oct 1, 2025
4c61733
Merge branch 'main' into fixing_indirections
vidsinghal Oct 8, 2025
bd09f48
merge main
vidsinghal Oct 8, 2025
0f93a9c
edits
vidsinghal Oct 8, 2025
7ed999d
change codegen to do copying of stack allocated arrays
vidsinghal Oct 9, 2025
84a4867
edits
vidsinghal Oct 10, 2025
56737b0
Wip: use stack allocated arrays
vidsinghal Oct 10, 2025
0541f21
fix indirections with new stack allocation strategy
vidsinghal Oct 10, 2025
14ee91a
indirections work with new stack allocated model
vidsinghal Oct 11, 2025
98d74f1
edits
vidsinghal Oct 12, 2025
4d84992
edit bench
vidsinghal Oct 12, 2025
835de89
fix RAN
vidsinghal Oct 13, 2025
50d3730
wip: Nested SoA regions
vidsinghal Oct 14, 2025
62bf9fe
wip fixing nested regions
vidsinghal Oct 15, 2025
98700ab
wip
vidsinghal Oct 15, 2025
cceed08
edits
vidsinghal Oct 16, 2025
36302e2
edits helper function
vidsinghal Oct 16, 2025
31a02c6
wip nested soa
vidsinghal Oct 16, 2025
488835e
wip nested regions
vidsinghal Oct 19, 2025
87dae81
nested stack allocated array works, ran works
vidsinghal Oct 20, 2025
3545ab2
edits
vidsinghal Oct 28, 2025
5e7c418
allowing data types to have different memory layouts
vidsinghal Oct 29, 2025
7c0a4ab
fix bugs
vidsinghal Oct 29, 2025
3704a6e
edits
vidsinghal Oct 26, 2025
65b6999
add example
vidsinghal Oct 30, 2025
6571e9e
edits
vidsinghal Oct 31, 2025
b6b9f08
edits
vidsinghal Oct 31, 2025
60fdad6
edits
vidsinghal Nov 2, 2025
cea6462
fix test suite
vidsinghal Nov 2, 2025
0e3a663
fix import of foldl'
vidsinghal Nov 2, 2025
dea90e3
edits
vidsinghal Nov 6, 2025
4b590e7
microbench
vidsinghal Nov 7, 2025
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
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
packages: gibbon-compiler

program-options
ghc-options: -Werror
ghc-options: -Werror
92 changes: 0 additions & 92 deletions gibbon-compiler/examples/simple_tests/packedBuggyTree.hs

This file was deleted.

43 changes: 43 additions & 0 deletions gibbon-compiler/examples/soa_examples/MonoTree.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
-- test monomorphic things
module MonoTree where

data Tree = Leaf Int
| Node Int Tree Tree
deriving Show
{-# ANN type Tree "Factored" #-}

mkTree :: Int -> Int -> Tree
mkTree d acc =
if d == 0
then Leaf (acc)
else Node d (mkTree (d-1) (d+acc)) (mkTree (d-1) (d+acc))

add1Tree :: Tree -> Tree
add1Tree t =
case t of
Leaf x -> Leaf (x + 1)
Node d x1 x2 -> Node (d + 1) (add1Tree x1) (add1Tree x2)

rightMost :: Tree -> Int
rightMost t = case t of
Leaf x -> x
Node d x1 x2 -> rightMost x2

sumTree :: Tree -> Int
sumTree tr =
case tr of
Leaf n -> n
Node d l r -> d + (sumTree l) + (sumTree r)

id :: Tree -> Tree
id tree = tree

gibbon_main = let
tree = id (mkTree 23 0)
tree' = (add1Tree tree)
tree'' = (add1Tree tree')
val = iterate (rightMost tree'')
in (sumTree tree'') + val

main :: IO ()
main = print gibbon_main
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

data List = Cons Int List | Nil
{-# ANN type List "Factored" #-}

Expand All @@ -17,7 +16,7 @@ add1 lst = case lst of
Nil -> Nil
Cons i rst -> let
i1 = i + 1
in Cons i1 (add1 rst)
in Cons i1 (add1 rst)


--fieldDep :: List -> (Int, List)
Expand All @@ -33,13 +32,13 @@ sumList lst = case lst of
Cons i rst -> let sumRst = sumList rst
in i + sumRst

id :: List -> List
id lst = lst

gibbon_main = let
lst = mkList 20000
--lst' = iterate (add1 lst)
_ = printPacked lst
_ = printsym (quote "NEWLINE")
--(val, lst'') = fieldDep lst'
in sumList lst --() --printPacked lst' --val --sumList lst'
lst = mkList 100
lst' = id (add1 lst)
in sumList lst'



Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
data List = Cons Int List | Nil
data FloatList = FCons Float FloatList | FNil
data Tree = Node Int FloatList List Tree Tree | Leaf
{-# ANN type Tree "Factored" #-}
{-# ANN type List "Linear" #-}
{-# ANN type FloatList "Linear" #-}


mkList :: Int -> List
Expand All @@ -16,7 +19,7 @@ mkFloatList len = if len <= 0
mkTree :: Int -> Tree
mkTree d = if (d <= 0)
then Leaf
else Node d (mkFloatList d) (mkList d) (mkTree (d - 1)) (mkTree (d - 1))
else Node d (mkFloatList 50000) (mkList 50000) (mkTree (d - 1)) (mkTree (d - 1))

add1List :: List -> List
add1List lst = case lst of
Expand Down Expand Up @@ -70,7 +73,7 @@ sumFloatList :: FloatList -> Int
sumFloatList lst = 10

gibbon_main =
let tree = mkTree 5
tree' = add1Tree tree
in sumTree tree'
let tree = mkTree 3
tree' = iterate (add1Tree tree)
in iterate (sumTree tree')

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
data PackedInt = PacI Int
data List = Cons Int PackedInt List | Nil
{-# ANN type PackedInt "Linear" #-}
{-# ANN type List "Factored" #-}

addPackedInt' :: PackedInt -> Int -> PackedInt
addPackedInt' a b = case a of
Expand Down Expand Up @@ -40,13 +42,15 @@ sumList lst = case lst of
sumRst = sumList rst
in j + i' + sumRst

id :: List -> List
id lst = lst


gibbon_main = let
pi = mkPackedInt 10
lst = mkList 10
lst' = add1 lst
-- _ = printPacked lst'
--(val, lst'') = fieldDep lst'
in (sumList lst') --printPacked lst' --val --sumList lst'
lst = mkList 100
lst' = id (add1 lst)
in (sumList lst')



Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
data List = Cons Int List | Nil
data FloatList = FCons Float FloatList | FNil
data Tree = Node Int Float FloatList List Tree Tree Tree | Leaf

{-# ANN type Tree "Factored" #-}
{-# ANN type List "Linear" #-}
{-# ANN type FloatList "Linear" #-}

mkList :: Int -> List
mkList len = if len <= 0
Expand All @@ -18,6 +20,13 @@ mkTree d = if (d <= 0)
then Leaf
else Node d 1.0 (mkFloatList d) (mkList d) (mkTree (d - 1)) (mkTree (d - 1)) (mkTree (d - 1))


rightMostTree :: Tree -> Int
rightMostTree tree = case tree of
Node a b c d e f g -> rightMostTree g
Leaf -> 0


add1List :: List -> List
add1List lst = case lst of
Nil -> Nil
Expand Down Expand Up @@ -74,8 +83,12 @@ sumFloatList lst = case lst of
FNil -> 0
FCons x rst -> 1 + (sumFloatList rst)

id :: Tree -> Tree
id tree = tree

gibbon_main =
let tree = mkTree 5
tree' = add1Tree tree
in sumTree tree'
let tree = id (mkTree 5)
tree' = (id (add1Tree tree))
val = (sumTree tree')
in val

23 changes: 23 additions & 0 deletions gibbon-compiler/examples/soa_examples/test_copy.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
data Tree = Node Int Tree Tree | Leaf Int

foo :: Int -> Tree
foo i = let tree = Node i (Leaf i) (Leaf (i+1))
in tree

make_node :: Tree -> Tree -> Tree
make_node t1 t2 = Node 10 t1 t2

foo' :: Tree -> Tree
foo' tree = tree


gibbon_main =
let t1 = foo 20
t2 = foo 50
t3 = make_node t1 t2
t4 = foo' t3
--t4' = Node 12 (Leaf 1) (Leaf 2)
t5 = Node 12 (Leaf 1) t4 --Node 10 (Node 12 t4 t4') (Node 12 (Leaf 1) (Leaf 1))
in printPacked t5


1 change: 1 addition & 0 deletions gibbon-compiler/examples/soa_examples/test_list.ans
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5150
1 change: 1 addition & 0 deletions gibbon-compiler/examples/soa_examples/test_packed_list.ans
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10300
1 change: 1 addition & 0 deletions gibbon-compiler/examples/soa_examples/test_packed_tree.ans
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
919
3 changes: 3 additions & 0 deletions gibbon-compiler/examples/soa_examples/test_tree.ans
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(sum: 54604, rightmost: 1)

'#()
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@ add1Tree t =
rightmost :: Tree -> Int
rightmost tree = case tree of
Leaf i _ -> i
Node _ _ _ _ l r ll rr -> rightmost rr
Node a b c d l r ll rr -> rightmost r

sumTree :: Tree -> Int
sumTree tr =
case tr of
Leaf n m -> n
Node i j k _ l r ll rr -> i + j + k + (sumTree l) + (sumTree r) + (sumTree ll) + (sumTree rr)

id :: Tree -> Tree
id tree = tree

gibbon_main =
let tree = mkTree 10
-- _ = printPacked tree
tree' = add1Tree tree
--_ = printPacked tree'
val = sumTree tree'
_ = printsym (quote "\n\n(sum: ")
let tree = id (mkTree 10)
tree' = (add1Tree tree)
tree'' = iterate (id (add1Tree tree'))
val = (sumTree tree'')
_ = printsym (quote "(sum: ")
_ = printint val
_ = printsym (quote ", rightmost: ")
rmost = rightmost tree'
rmost = (rightmost tree'')
_ = printint rmost
_ = printsym (quote ")\n\n")
in sumTree tree'
in val
1 change: 1 addition & 0 deletions gibbon-compiler/gibbon.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ library
Gibbon.Passes.HoistBoundsCheck
Gibbon.Passes.ReorderLetExprs
Gibbon.Passes.AddCastInstructions
Gibbon.Passes.OptimizeL3

other-extensions: DeriveDataTypeable CPP

Expand Down
13 changes: 10 additions & 3 deletions gibbon-compiler/src/Gibbon/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ module Gibbon.Common

-- * Debugging/logging:
, dbgLvl, dbgPrint, dbgPrintLn, dbgTrace, dbgTraceIt, minChatLvl
, internalError, dumpIfSet, unwrapLocVar, singleLocVar, getDconLoc, getFieldLoc, freshCommonLoc, getAllFieldLocsSoA, varsInLocVar, varsInRegVar
, internalError, dumpIfSet, unwrapLocVar, singleLocVar, getDconLoc, getFieldLoc, freshCommonLoc, getAllFieldLocsSoA
, varsInLocVar, varsInRegVar, getAllFieldRegsSoA
, appendNameToLocVar

-- * Establish conventions for the output of #lang gibbon:
Expand Down Expand Up @@ -539,7 +540,7 @@ truePrinted = "#t"
falsePrinted :: String
falsePrinted = "#f"

unwrapLocVar :: LocVar -> Var
unwrapLocVar :: HasCallStack => LocVar -> Var
unwrapLocVar locvar = case locvar of
Single loc -> loc
SoA _dcon _fieldLocs ->
Expand Down Expand Up @@ -568,7 +569,7 @@ getDconLoc loc = case loc of
SoA dcon _fieldLocs -> Single dcon
Single _lc -> loc

getFieldLoc :: (DataCon, FieldIndex) -> LocVar -> LocVar
getFieldLoc :: HasCallStack => (DataCon, FieldIndex) -> LocVar -> LocVar
getFieldLoc (dcon, idx) loc = case loc of
SoA _ fieldLocs -> case Prelude.lookup (dcon, idx) fieldLocs of
Just loc' -> loc'
Expand All @@ -580,6 +581,12 @@ getAllFieldLocsSoA loc = case loc of
SoA _dcon fieldLocs -> fieldLocs
Single _lc -> error "getFieldLocs : Did not expect a non SoA location!"


getAllFieldRegsSoA :: RegVar -> [((DataCon, Int), RegVar)]
getAllFieldRegsSoA loc = case loc of
SoARv _dcon fieldLocs -> fieldLocs
SingleR _lc -> error "getFieldLocs : Did not expect a non SoA location!"

freshSingleLocVar :: String -> PassM LocVar
freshSingleLocVar m = do v <- gensym (toVar m)
return $ Single v
Expand Down
Loading
Loading