Skip to content

Commit caa8364

Browse files
committed
edits
1 parent 1602358 commit caa8364

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

gibbon-compiler/examples/soa_examples/list.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ id lst = lst
3838

3939
gibbon_main = let
4040
lst = mkList 100
41-
lst' = (add1 lst)
41+
lst' = id (add1 lst)
4242
in sumList lst'
4343

4444

gibbon-compiler/src/Gibbon/Passes/Cursorize.hs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,20 +1348,25 @@ cursorizePackedExp freeVarToVarEnv lenv ddfs fundefs denv tenv senv ex =
13481348
let_assign_write_cur <$> LetE (d',[], CursorTy, Ext $ WriteVector write_vector_at rnd' (stripTyLocs el_ty)) <$>
13491349
go2 marker_added fvarenv' aft_dloc from_rec_end aft_flocs' rst
13501350

1351-
_ -> error $ "TODO: Cursorize: cursorizePackedExp: Ty not implemented!! " ++ show (ty)
1351+
-- _ -> error $ "TODO: Cursorize: cursorizePackedExp: Ty not implemented!! " ++ show (ty)
13521352

13531353
-- -- Write a pointer to a vector
13541354
-- ListTy el_ty -> do
13551355
-- rnd' <- cursorizeExp freeVarToVarEnv ddfs fundefs denv tenv senv rnd
13561356
-- LetE (d',[], CursorTy, Ext $ WriteList d rnd' (stripTyLocs el_ty)) <$>
13571357
-- go2 marker_added d' rst
13581358

1359-
-- -- shortcut pointer
1360-
-- CursorTy -> do
1361-
-- rnd' <- cursorizeExp freeVarToVarEnv ddfs fundefs denv tenv senv rnd
1362-
-- LetE (d',[], CursorTy, Ext $ WriteTaggedCursor d rnd') <$>
1363-
-- go2 marker_added d' rst
1364-
-- _ -> error $ "Unknown type encounterred while cursorizing DataConE. Type was " ++ show ty
1359+
-- shortcut pointer
1360+
-- SoA case
1361+
-- Fix case for indirection/shortcut pointers
1362+
CursorTy -> do
1363+
rnd' <- cursorizeExp freeVarToVarEnv lenv ddfs fundefs denv tenv senv rnd
1364+
after_indirection <- gensym "aft_indirection"
1365+
LetE (d',[], CursorTy, Ext $ WriteTaggedCursor aft_dloc rnd') <$>
1366+
LetE (after_indirection,[], CursorTy, VarE d') <$> --Ext $ AddCursor aft_dloc (L3.LitE 8)
1367+
go2 marker_added freeVarToVarEnv after_indirection from_rec_end aft_flocs rst
1368+
1369+
_ -> error $ "Unknown type encounterred while cursorizing DataConE. Type was " ++ show ty
13651370

13661371

13671372

@@ -1576,7 +1581,11 @@ cursorizePackedExp freeVarToVarEnv lenv ddfs fundefs denv tenv senv ex =
15761581
if gopt Opt_DisableGC dflags
15771582
-- || (from_reg == "dummy" || to_reg == "dummy") -- HACK!!!
15781583
-- [2022.03.02]: ckoparkar:WTH does this hack enable?
1579-
then go freeVarToVarEnv tenv senv (DataConE from dcon [VarE (((unwrapLocVar . toLocVar)) to)])
1584+
then do
1585+
let locs_var = case M.lookup (fromLocArgToFreeVarsTy to) freeVarToVarEnv of
1586+
Nothing -> error "Did not find variable for location!"
1587+
Just var -> var
1588+
go freeVarToVarEnv tenv senv (DataConE from dcon [VarE locs_var])
15801589
else do
15811590
start <- gensym "start"
15821591
end <- gensym "end"

gibbon-compiler/src/Gibbon/Passes/RemoveCopies.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ removeCopiesFn :: DDefs Ty2 -> FunDefs2 -> FunDef2 -> PassM FunDef2
3737
removeCopiesFn ddefs fundefs f@FunDef{funArgs,funTy,funBody} = do
3838
let initLocEnv = M.fromList $ map (\(LRM lc r _) -> case r of
3939
_ -> (lc, regionToVar r)
40-
SoAR _ _ -> error "TODO: removeCopiesFn structure of arrays not implemented yet."
4140
) (locVars funTy)
4241
initTyEnv = M.fromList $ zip funArgs (arrIns funTy)
4342
env2 = Env2 initTyEnv (initFunEnv fundefs)
@@ -59,14 +58,14 @@ removeCopiesExp ddefs fundefs lenv env2 ex =
5958
[] -> error $ "removeCopies: No indirection constructor found for: " ++ sdoc tycon
6059
[dcon] -> do
6160
let reg_lout = case (lenv # lout) of
62-
SingleR v -> v
63-
SoARv _ _ -> error "removeCopies: structure of arrays not implemented yet."
61+
SingleR v -> fromRegVarToLocVar $ (SingleR v)
62+
r@(SoARv _ _) -> fromRegVarToLocVar r
6463
let reg_lin = case (lenv # lin) of
65-
SingleR v -> v
66-
SoARv _ _ -> error "removeCopies: structure of arrays not implemented yet."
64+
SingleR v -> fromRegVarToLocVar $ (SingleR v)
65+
r@(SoARv _ _) -> fromRegVarToLocVar r
6766
return $
6867
mkLets ([(indirection,[],PackedTy tycon lout,
69-
Ext $ IndirectionE tycon dcon (lout , singleLocVar $ reg_lout) (lin, singleLocVar $ reg_lin) arg)])
68+
Ext $ IndirectionE tycon dcon (lout , reg_lout) (lin, reg_lin) arg)])
7069
(VarE indirection)
7170
oth -> error $ "removeCopies: Multiple indirection constructors: " ++ sdoc oth
7271

0 commit comments

Comments
 (0)