of graphs ben lewinter the language for high performance ...sedwards/classes/2018/4115... ·...
TRANSCRIPT
![Page 1: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/1.jpg)
The Language for High Performance Parsing of Graphs Ben Lewinter
bsl2121Manager
Irina Mateescuim2441
Language Guru
Harry Smithhs3061
System Architect
Yasunari Watanabeyw3239
Test Expert
![Page 2: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/2.jpg)
Motivation
![Page 3: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/3.jpg)
A Language for Graphs
Graph theory is an important field in computer science, with wide ranging applications
We thought there should be a language that made experimenting with and utilizing graphs easier!
giraph from Fall 2017 was a major inspiration for us, but we had some ideas for what could be added...
![Page 4: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/4.jpg)
Goals
1. Unified graph type - generic graph type that can handle any type of edge
2. Customizable node names - giving the user greater control over their graphs
3. Cypher-like query capabilities - especially helpful when using graph to store large amounts of data
4. Anonymous functions - for passing in user-defined graph operations
5. Search Strategy Type - specifying traversal method in graph iteration
![Page 5: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/5.jpg)
Workflow and Team Processes
![Page 6: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/6.jpg)
scanner.mll 70 lines
parser.mly 160
ast.ml 178
sast.ml 109
semant.ml 446
codegen.ml 823
graph.c 1,152
hippograph.ml 29
The end result
Plus
197 Test Scripts
156 Git Commits
2 Pies of Pizza
![Page 7: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/7.jpg)
Language Overview
![Page 8: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/8.jpg)
The Basics
● Operators:○ + - * / ; = . > < => <= == and or not
● Control Flow:○ While (true) {make_graphs();} ○ For (int i = 0; i <= 10; i = i + 1)○ If (you_dont_mind()) { do_it(); } else { dont_bother(); }
■ The ELSE clause is optional!● Primitive Types:
○ int, bool, string● Comments:
○ (* don’t run me! *)
![Page 9: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/9.jpg)
Function Flavors
The Standard:
return_type func_name(type1 arg1; type2 arg2; … ) { …
}
The Condensed:
fun<type1:type2: … :typek, ret_typ> f = ret_type (type1 … )( expr )
![Page 10: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/10.jpg)
The Condensed Function
● Allow declarations of functions within the bodies of other functions○ Stored in variables, which effectively provide the names of anonymous
functions○ Fall in and out of scope with the function!
● Implemented as expressions which resolve to a FUN type
● Passing functions as first class data: WIP.
![Page 11: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/11.jpg)
What about graphs?
● Node Expressions:
Node<t1:t2> = expr_of_t1 : expr_of_t2;Node<t1:t2> = expr_of_t1;Node<t1> = expr_of_t1;
● Graph Expressions:
Graph<int:bool, int> = [1:true <(5)> 3 <(3)- 8:true; 8 -(4)- 1];Graph<int> = [1 <()> 3 <()- 8; 8 -()- 1];
![Page 12: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/12.jpg)
Implementation
![Page 13: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/13.jpg)
Architecture
Scanner Parser Semantic Checker
Code Generation
LLVM
Graph.c
Executable
![Page 14: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/14.jpg)
Graphs
Implemented as adjacency lists
Union primitive allowed for flexible typing.
Under the hood, all edges are directed. Non-directional and bidirectional edges are implemented as two one-way edges.
![Page 15: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/15.jpg)
Semantic Checking
graph<string:int, int> = [“A”:4 -(3)> “B”:2 -()> “C”:22 <(1)> “A”];
A4
B2
3
C22
1
![Page 16: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/16.jpg)
Testing
For every new feature implemented, a small test was created to ensure it worked as expected.
![Page 17: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/17.jpg)
Demo
Bellman-Ford Algorithm
![Page 18: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/18.jpg)
Initial Graph
graph<string:int, int> g = ["S":500 -(10)> "A":500 -(2)> "C":500 -(2)> "B":500 -(1)> "A"; "S" -(8)>"E":500 -(1)> "D":500 -(1)>"C"; "D" -(4)> "A"];
A500S
50010
C500
1
E500
D500
B500
2
2
1
8
1
4
![Page 19: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/19.jpg)
Shortest-path Graph
A10
S0
10
C10
E8
D9
B12
2
1
8
1
![Page 20: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/20.jpg)
Negative Edge Weight Cycles in Graph
A500
S500
10
C500
E500
D500
B500
2
1
8
1
-71
4
![Page 21: of Graphs Ben Lewinter The Language for High Performance ...sedwards/classes/2018/4115... · Yasunari Watanabe yw3239 Test Expert. Motivation . A Language for Graphs Graph theory](https://reader033.vdocuments.net/reader033/viewer/2022041716/5e4bef5778ec6060490ae7cf/html5/thumbnails/21.jpg)
Thank you!
Special thanks to our TAJennifer “codejen.ml” Bi!