Skip to content

Commit 0344417

Browse files
committed
[LayoutOptimization] Test multiple functions. Producer Consumer boundary optimization.
1 parent 90a2043 commit 0344417

File tree

7 files changed

+477
-371
lines changed

7 files changed

+477
-371
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(Layout1 ->i ->i ->i (Header Vector) ->i ->i ->i (ID 8) ->i ->i ->i (Author Vector) ->i ->i ->i (Date Vector) ->i (Content (Plain (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 (Emph (Cons_v_1131 (Emph (Cons_v_1131 ->i (Str Vector) (Nil_v_1131))) (Nil_v_1131))) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Nil_v_1131))))))))))))))))))))))))))))))))))))))))))))))))))))) (TagList (Nil_v_1132)) ->r (Layout1 ->i ->i ->i (Header Vector) ->i ->i ->i (ID 9) ->i ->i ->i (Author Vector) ->i ->i ->i (Date Vector) ->i (Content (Plain (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 (Emph (Cons_v_1131 (Emph (Cons_v_1131 ->i (Str Vector) (Nil_v_1131))) (Nil_v_1131))) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) ->r (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 (Emph (Cons_v_1131 (Emph (Cons_v_1131 ->i (Str Vector) (Nil_v_1131))) (Nil_v_1131))) (Cons_v_1131 ->i (Str Vector) (Cons_v_1131 ->i (Str Vector) (Nil_v_1131))))))))))))))))))))))))))))))))))))))))))))))))))))) (TagList (Nil_v_1132)) ->r (End)))'#()
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import Basics
2+
import GenerateLayout1
3+
4+
type Text = Vector Char
5+
6+
7+
emphKeywordInContent :: Text -> Blog -> Blog
8+
emphKeywordInContent keyword blogs =
9+
case blogs of
10+
End -> End
11+
Layout1 header id author date content tags rst -> let newContent = case content of
12+
Content block -> Content (emphasizeKeywordInBlock keyword block)
13+
newRst = emphKeywordInContent keyword rst
14+
in Layout1 header id author date newContent tags newRst
15+
16+
17+
18+
filterByKeywordInTagList :: Text -> Blog -> Blog
19+
filterByKeywordInTagList keyword blogs = case blogs of
20+
End -> End
21+
Layout1 header id author date content tags rst -> let present = searchBlogTags keyword tags
22+
in if present then
23+
let newRst = filterByKeywordInTagList keyword rst
24+
in Layout1 header id author date content tags newRst
25+
else filterByKeywordInTagList keyword rst
26+
27+
28+
emphKeywordInTag :: Text -> Blog -> Blog
29+
emphKeywordInTag keyword blogs = case blogs of
30+
End -> End
31+
Layout1 header id author date content tags rst -> let present = searchBlogTags keyword tags
32+
in if (present)
33+
then let newContent = case content of
34+
Content block -> Content (emphasizeKeywordInBlock keyword block)
35+
newRst = emphKeywordInTag keyword rst
36+
in Layout1 header id author date newContent tags newRst
37+
else
38+
let newRst = emphKeywordInTag keyword rst
39+
in Layout1 header id author date content tags newRst
40+
41+
42+
-- main function
43+
gibbon_main =
44+
let blogs = mkBlogs_layout1 2
45+
keyword :: Vector Char
46+
keyword = "a"
47+
newblgs = emphKeywordInContent keyword blogs
48+
newblgs' = emphKeywordInTag keyword newblgs
49+
newblgs'' = filterByKeywordInTagList keyword newblgs'
50+
in printPacked newblgs''

gibbon-compiler/src/Gibbon/Compiler.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,10 @@ passes config@Config{dynflags} l0 = do
642642

643643
-- Note: L1 -> L2
644644
l1 <- if opt_layout
645-
then goE1 "optimizeADTLayout" optimizeADTLayout l1
645+
then do
646+
after_layout_out <- goE1 "optimizeADTLayout" optimizeADTLayout l1
647+
flatten_after_opt <- goE1 "L1.flatten2" flattenL1 after_layout_out
648+
pure flatten_after_opt
646649
else return l1
647650
l1 <- goE1 "copyOutOfOrderPacked" copyOutOfOrderPacked l1
648651
l1 <- goE1 "simplify_2" simplifyL1 l1

0 commit comments

Comments
 (0)