Skip to content

Commit

Permalink
buildable commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vidsinghal committed Dec 1, 2024
1 parent ca1eba4 commit f212e7b
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 56 deletions.
4 changes: 3 additions & 1 deletion gibbon-compiler/src/Gibbon/NewL2/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ instance NFData LREM where
rnf (LREM a b c d) = rnf a `seq` rnf b `seq` rnf c `seq` rnf d

fromLRM :: Old.LRM -> LREM
fromLRM (Old.LRM loc reg mode) = LREM loc (Old.regionToVar reg) (toEndV (Old.regionToVar reg)) mode
fromLRM (Old.LRM loc reg mode) = case reg of
Old.AoSR r -> LREM loc (Old.regionToVar r) (toEndV (Old.regionToVar r)) mode
Old.SoAR _ _ -> error "TODO: NewL2/Syntax.hs, fromLRM, implement SoA region."

data LocArg = Loc LREM
| EndWitness LREM Var
Expand Down
5 changes: 4 additions & 1 deletion gibbon-compiler/src/Gibbon/Passes/AddRAN.hs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ needsRAN Prog{ddefs,fundefs,mainExp} =
then S.empty
else let tyenv = M.fromList $ zip funArgs (inTys funTy)
env2 = Env2 tyenv funenv
renv = M.fromList $ L.map (\lrm -> (lrmLoc lrm, regionToVar (lrmReg lrm))) (locVars funTy)
renv = M.fromList $ L.map (\lrm -> case (lrmReg lrm) of
AoSR reg -> (lrmLoc lrm, regionToVar reg)
SoAR _ _ -> error "TODO: needsRAN structure of arrays not implemented yet."
) (locVars funTy)
in needsRANExp ddefs fundefs env2 renv M.empty [] funBody

funs = M.foldr (\f acc -> acc `S.union` dofun f) S.empty fundefs
Expand Down
5 changes: 4 additions & 1 deletion gibbon-compiler/src/Gibbon/Passes/AddTraversals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ addTraversalsFn ddefs fundefs f@FunDef{funName, funArgs, funTy, funBody} = do
let funenv = initFunEnv fundefs
tyenv = M.fromList $ fragileZip funArgs (inTys funTy)
env2 = Env2 tyenv funenv
renv = M.fromList $ L.map (\lrm -> (lrmLoc lrm, regionToVar (lrmReg lrm)))
renv = M.fromList $ L.map (\lrm -> case (lrmReg lrm) of
AoSR reg -> (lrmLoc lrm, regionToVar reg)
SoAR _ _ -> error "TODO: addTraversalsFn structure of arrays not implemented yet."
)
(locVars funTy)
bod' <- addTraversalsExp ddefs fundefs env2 renv (fromVar funName) funBody
return $ f {funBody = bod'}
Expand Down
5 changes: 4 additions & 1 deletion gibbon-compiler/src/Gibbon/Passes/CalculateBounds.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ calculateBoundsFun ddefs env2 varSzEnv f@FunDef { funName, funBody, funTy, funAr
if "_" `L.isPrefixOf` fromVar funName
then return f
else do
let locRegEnv = M.fromList $ map (\lv -> (lrmLoc lv, regionToVar $ lrmReg lv)) (locVars funTy)
let locRegEnv = M.fromList $ map (\lv -> case (lrmReg lv) of
AoSR reg -> (lrmLoc lv, regionToVar reg)
SoAR _ _ -> error "TODO: calculateBoundsFn SoA region not implemented."
) (locVars funTy)
let locTyEnv = M.map (const $ BoundedSize 0) locRegEnv
let argTys = M.fromList $ zip funArgs (arrIns funTy)
let env2' = env2 { vEnv = argTys }
Expand Down
2 changes: 1 addition & 1 deletion gibbon-compiler/src/Gibbon/Passes/InferLocations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ convertFunTy (from,to,isPar) = do
where
toLRM md ls =
mapM (\v -> do r <- freshLocVar "r"
return $ LRM v (VarR (unwrapLocVar r)) md)
return $ LRM v (AoSR $ VarR (unwrapLocVar r)) md)
(F.toList ls)

convertTy :: Ty1 -> PassM Ty2
Expand Down
5 changes: 4 additions & 1 deletion gibbon-compiler/src/Gibbon/Passes/ParAlloc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ parAlloc Prog{ddefs,fundefs,mainExp} = do
when (hasParallelism funTy && hasPacked ret_ty && gopt Opt_Gibbon1 dflags) $
error "gibbon: Cannot compile parallel allocations in Gibbon1 mode."

let initRegEnv = M.fromList $ map (\(LRM lc r _) -> (lc, regionToVar r)) (locVars funTy)
let initRegEnv = M.fromList $ map (\(LRM lc r _) -> case r of
AoSR reg -> (lc, regionToVar reg)
SoAR _ _ -> error "TODO: parAlloc structure of arrays not implemented yet."
) (locVars funTy)
funArgs' = L.map Single funArgs
initTyEnv = M.fromList $ zip funArgs' (arrIns funTy)
env2 = Env2 initTyEnv (initFunEnv' fundefs)
Expand Down
5 changes: 4 additions & 1 deletion gibbon-compiler/src/Gibbon/Passes/RemoveCopies.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ removeCopies Prog{ddefs,fundefs,mainExp} = do

removeCopiesFn :: DDefs Ty2 -> FunDefs2 -> FunDef2 -> PassM FunDef2
removeCopiesFn ddefs fundefs f@FunDef{funArgs,funTy,funBody} = do
let initLocEnv = M.fromList $ map (\(LRM lc r _) -> (lc, regionToVar r)) (locVars funTy)
let initLocEnv = M.fromList $ map (\(LRM lc r _) -> case r of
AoSR reg -> (lc, regionToVar reg)
SoAR _ _ -> error "TODO: removeCopiesFn structure of arrays not implemented yet."
) (locVars funTy)
initTyEnv = M.fromList $ zip funArgs (arrIns funTy)
env2 = Env2 initTyEnv (initFunEnv fundefs)
bod' <- removeCopiesExp ddefs fundefs initLocEnv env2 funBody
Expand Down
17 changes: 10 additions & 7 deletions gibbon-compiler/src/Gibbon/Passes/ReorderScalarWrites.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ writeOrderMarkers (Prog ddefs fundefs mainExp) = do
gofun f@FunDef{funArgs,funBody,funTy} = do
let (reg_env, alloc_env) =
foldr (\(L2.LRM loc reg mode) (renv,aenv) ->
let renv' = M.insert loc reg renv
aenv' = case mode of
L2.Output ->
let reg_locs = RegionLocs [loc] S.empty
in M.insert reg reg_locs aenv
L2.Input -> aenv
in (renv',aenv'))
case reg of
L2.AoSR rr -> let renv' = M.insert loc rr renv
aenv' = case mode of
L2.Output ->
let reg_locs = RegionLocs [loc] S.empty
in M.insert rr reg_locs aenv
L2.Input -> aenv
in (renv',aenv')
L2.SoAR _ _ -> error "TODO: writeOrderMarkers structure of arrays not implemented yet."
)
(M.empty,M.empty)
(L2.locVars funTy)
init_ty_env = M.fromList $ zip funArgs (L2.arrIns funTy)
Expand Down
Loading

0 comments on commit f212e7b

Please sign in to comment.