Skip to content

Commit 3e61945

Browse files
committed
Revert "WIP: decision Tree"
This reverts commit 041007c9722f0a20b26c5f86c2ffcbbaa504cef6. Will make a PR instead
1 parent 0ceeac5 commit 3e61945

File tree

4 files changed

+19
-113
lines changed

4 files changed

+19
-113
lines changed

gibbon-compiler/examples/layout_bench/DecisionTree.hs

Lines changed: 0 additions & 79 deletions
This file was deleted.

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

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -97,34 +97,22 @@ greedyOrderOfVertices ee = let edges' = P.map (\((a, b), c) -> ((P.fromInteg
9797
graph = buildG bounds edgesWithoutWeight
9898
weightMap = P.foldr (\(e, w) mm -> M.insert e w mm) M.empty edges'
9999
v'' = greedyOrderOfVerticesHelper graph (topSort graph) weightMap S.empty
100-
in v'' -- dbgTraceIt (sdoc ((topSort graph), (M.elems weightMap))) dbgTraceIt (sdoc (v'', (M.elems weightMap)))
100+
in v'' -- dbgTraceIt (sdoc (v'', (M.elems weightMap)))
101101

102102

103103
greedyOrderOfVerticesHelper :: Graph -> [Int] -> M.Map (Int, Int) Int -> S.Set Int -> [Int]
104104
greedyOrderOfVerticesHelper graph vertices' weightMap visited = case vertices' of
105105
[] -> []
106106
x:xs -> if S.member x visited
107107
then greedyOrderOfVerticesHelper graph xs weightMap visited
108-
else let successors = succGraph x (G.edges graph) visited
108+
else let successors = reachable graph x
109109
removeCurr = S.toList $ S.delete x (S.fromList successors)
110110
orderedSucc = orderedSuccsByWeight removeCurr x weightMap visited
111-
visited' = P.foldr S.insert visited orderedSucc
111+
visited' = P.foldr S.insert S.empty orderedSucc
112112
v'' = greedyOrderOfVerticesHelper graph xs weightMap visited'
113-
in [x] ++ orderedSucc ++ v''
114-
-- dbgTraceIt (sdoc (x, successors, removeCurr, orderedSucc, v'', S.toList visited' , S.toList visited ))
115-
--then dbgTraceIt (sdoc (x, successors, removeCurr, orderedSucc, v'', S.toList visited')) orderedSucc ++ v'' --dbgTraceIt (sdoc (v'', orderedSucc))
116-
--else dbgTraceIt (sdoc (x, successors, removeCurr, orderedSucc, v'', S.toList visited')) [x] ++ orderedSucc ++ v''
117-
118-
119-
succGraph :: Int -> [(Int, Int)] -> S.Set Int -> [Int]
120-
succGraph node edges visited = case edges of
121-
[] -> []
122-
(a, b):xs -> if S.member b visited || S.member a visited
123-
then succGraph node xs visited
124-
else
125-
if node == a then [b] ++ succGraph node xs visited
126-
else succGraph node xs visited
127-
113+
in if successors == [x]
114+
then orderedSucc ++ v'' --dbgTraceIt (sdoc (v'', orderedSucc))
115+
else [x] ++ orderedSucc ++ v''
128116

129117
orderedSuccsByWeight :: [Int] -> Int -> M.Map (Int, Int) Int -> S.Set Int -> [Int]
130118
orderedSuccsByWeight s i weightMap visited = case s of
@@ -283,7 +271,7 @@ removeDuplicates list =
283271
-- | a.) Multiple datacon fields read in the same expression.
284272
-- | Since this will be run after flatten, it is safe to assume that only possibly a maximum of two variables can be read in one let binding.
285273
-- | Except function calls! where more than two fields can be passed as arguments.
286-
evaluateExpressionFieldGraph :: (Out l, Out d, Out (e l d)) =>
274+
evaluateExpressionFieldGraph ::
287275
Maybe (DataCon, Integer) ->
288276
(G.Vertex -> (((PreExp e l d), Integer), Integer, [Integer])) ->
289277
(Integer -> Maybe G.Vertex) ->
@@ -428,22 +416,19 @@ evaluateExpressionFieldGraph currField nodeFromVertex vertexFromNode graph xs ma
428416
{- list of tuples, where each tuple == ([(dcon, id), ... ], likelihood) -}
429417
succDataCon' =
430418
P.zipWith (\x y -> (x, y)) succDataCon succprob
431-
-- FIXME: TODO: This might be needed for the other cases in this function as well.
432-
-- This is to make sure we recurse on all possible successors.
433-
newEdges' = constructFieldGraph (Just (dcon, pred)) nodeFromVertex vertexFromNode graph succVertices map datacon
434-
newEdges = newEdges' ++ (
419+
newEdges =
435420
P.concat $
436421
P.map
437422
( \x ->
438423
case x of
439424
(varsl, prob) ->
440425
P.map (\y -> ((pred, snd y), prob)) varsl
441426
)
442-
succDataCon' )
427+
succDataCon'
443428
in case newEdges of
444429
[] ->
445430
case successors of
446-
[] -> --dbgTraceIt (sdoc (currField, succVertices, newEdges, newEdges'))
431+
[] ->
447432
[]
448433
++ constructFieldGraph
449434
Nothing
@@ -453,7 +438,7 @@ evaluateExpressionFieldGraph currField nodeFromVertex vertexFromNode graph xs ma
453438
xs
454439
map
455440
datacon
456-
_ -> --dbgTraceIt (sdoc (currField, succVertices, newEdges, newEdges'))
441+
_ ->
457442
newEdges
458443
++ constructFieldGraph
459444
(Just (dcon, pred))
@@ -463,7 +448,7 @@ evaluateExpressionFieldGraph currField nodeFromVertex vertexFromNode graph xs ma
463448
xs
464449
map
465450
datacon
466-
_ -> --dbgTraceIt (sdoc (currField, succVertices, newEdges, newEdges'))
451+
_ ->
467452
newEdges
468453
++ constructFieldGraph
469454
Nothing
@@ -526,7 +511,7 @@ evaluateExpressionFieldGraph currField nodeFromVertex vertexFromNode graph xs ma
526511
error
527512
"evaluateExpressionFieldGraph: More than one variable from DataCon in a let binding not modelled into Field dependence graph yet!"
528513

529-
constructFieldGraph :: (Out l, Out d, Out (e l d)) =>
514+
constructFieldGraph ::
530515
Maybe (DataCon, Integer) ->
531516
(G.Vertex -> (((PreExp e l d), Integer), Integer, [Integer])) ->
532517
(Integer -> Maybe G.Vertex) ->
@@ -709,7 +694,7 @@ constructFieldGraph currField nodeFromVertex vertexFromNode graph progress map d
709694
_ -> error "not expected"
710695

711696
-- | From an expression provided, Recursively find all the variables that come from a DataCon expression, that is, are fields in a DataConE.
712-
findFieldInDataConFromVariableInExpression :: (Out l, Out d, Out (e l d)) =>
697+
findFieldInDataConFromVariableInExpression ::
713698
(PreExp e l d) ->
714699
[(((PreExp e l d), Integer), Integer, [Integer])] ->
715700
VariableMap ->
@@ -737,7 +722,7 @@ findFieldInDataConFromVariableInExpression exp graph map datacon =
737722
let freeVars = freeVarsInOrder rhs
738723
fromDataCon = P.map (\v -> M.findWithDefault Nothing v map) freeVars
739724
removeMaybe = Mb.catMaybes fromDataCon
740-
newDatacons = --dbgTraceIt (sdoc (v, freeVars))
725+
newDatacons =
741726
[ if dcon == datacon
742727
then Just (dcon, id')
743728
else Nothing

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Data.Set as S
1818

1919
-- Haskell Imports
2020
import Prelude as P
21-
import Text.PrettyPrint.GenericPretty
21+
2222

2323
-- | CFGfunctionMap ex, a map storing a function, represented by Var (function name) to its control flow graph
2424
-- | Edge == (ex, Integer) the IR expression and its corresponding probability
@@ -58,11 +58,11 @@ type CFGfunctionMap ex
5858

5959
-- | Generate a CFG out of a Function definition.
6060
-- | Returns a map mapping a function to its corresponding CFG
61-
getFunctionCFG :: (Out l, Out d, Out (e l d)) => FunDef (PreExp e l d) -> CFGfunctionMap (PreExp e l d)
61+
getFunctionCFG :: FunDef (PreExp e l d) -> CFGfunctionMap (PreExp e l d)
6262
getFunctionCFG f@FunDef {funName, funBody, funTy, funArgs} =
6363
let (edgeList, _, _) = generateCFGExp 0 100 funBody
6464
(graph, nodeFromVertex, vertexFromKey) = G.graphFromEdges edgeList
65-
in M.insert funName (graph, nodeFromVertex, vertexFromKey) (M.empty) --dbgTraceIt (sdoc edgeList)
65+
in M.insert funName (graph, nodeFromVertex, vertexFromKey) (M.empty)
6666

6767

6868
-- | generate the Edges from the IR expression.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ getVariableAndProducer funName pMap venv@Env2{vEnv, fEnv} ddefs dconName exp =
746746
justVariables = Maybe.catMaybes potentialVarsOfTy
747747
in if P.null justVariables
748748
-- dbgTraceIt (sdoc (funName, dconName, args, venv))
749-
then Nothing-- dbgTraceIt (sdoc (funName, dconName, args, venv)) error "getVariableAndProducer: no variables of Ty to optimize found!"
749+
then error "getVariableAndProducer: no variables of Ty to optimize found!"
750750
else
751751
if P.length justVariables > 1
752752
then error "getVariableAndProducer: More than one variable of the type being optimized is passed to function call. Not implemented yet!"

0 commit comments

Comments
 (0)