Skip to content

Commit

Permalink
Merge pull request #81 from GraphIt-DSL/yunming
Browse files Browse the repository at this point in the history
Yunming
  • Loading branch information
yunmingzhang17 authored Nov 17, 2018
2 parents 3f8725c + 862dcb1 commit 79f8340
Show file tree
Hide file tree
Showing 61 changed files with 536 additions and 4,401 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,16 @@ schedule:

The **test/input** and **test/input\_with\_schedules** directories contain many examples of the algorithm and schedule files. Use them as references when writing your own schedule.

We provide **more detailed instructions on evaluating the code generation and performance capability** of GraphIt in **graphit/graphit_eval/GraphIt_Evaluation_Guide.md**. In the guide, we provide instructions for using a series of scripts that make it easeir for people to evaluate GraphIt..

Input Graph Formats
===========

GraphIt reuses [GAPBS input formats](https://github.com/sbeamer/gapbs). Specifically, we have tested with edge list file (.el), weighted edge list file (.wel), binary edge list (.sg), and weighted binary edge list (.wsg) formats. Users can use the converters in GAPBS (GAPBS/src/converter.cc) to convert other graph formats into the supported formats, or convert weighted and unweighted edge list files into their respective binary formats.

We have provided sample input graph files in the `graphit/test/graphs/` directory. The python tests use the sample input files.

Autotuning GraphIt Schedules
===========
Pleaes refer to **README.md** in **graphit/auotune** for more details.
The auotuner is still somehwat experimental. Please read the instructions carefully before trying it out.
11 changes: 7 additions & 4 deletions apps/bfs.gt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ func main()
startTimer();
vertices.apply(reset);
var frontier : vertexset{Vertex} = new vertexset{Vertex}(0);
frontier.addVertex(14);
parent[14] = 14;
var start_vertex : int = atoi(argv[2]);
frontier.addVertex(start_vertex);
parent[start_vertex] = start_vertex;

while (frontier.getVertexSetSize() != 0)
#s1# frontier = edges.from(frontier).to(toFilter).applyModified(updateEdge,parent, true);
#s1# var output : vertexset{Vertex} = edges.from(frontier).to(toFilter).applyModified(updateEdge,parent, true);
delete frontier;
frontier = output;
end

delete frontier;
var elapsed_time : float = stopTimer();
print "elapsed time: ";
print elapsed_time;
Expand Down
6 changes: 4 additions & 2 deletions apps/cc.gt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ func main()
var frontier : vertexset{Vertex} = new vertexset{Vertex}(n);
vertices.apply(init);
while (frontier.getVertexSetSize() != 0)
#s1# frontier = edges.from(frontier).applyModified(updateEdge,IDs);
#s1# var output: vertexset{Vertex} = edges.from(frontier).applyModified(updateEdge,IDs);
delete frontier;
frontier = output;
end

delete frontier;
var elapsed_time : float = stopTimer();
print "elapsed time: ";
print elapsed_time;
Expand Down
8 changes: 6 additions & 2 deletions apps/pagerankdelta.gt
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ func main()

for i in 1:11
#s1# edges.from(frontier).apply(updateEdge);
var output : vertexset{Vertex};
if i == 1
frontier = vertices.where(updateVertexFirstRound);
output = vertices.where(updateVertexFirstRound);
else
frontier = vertices.where(updateVertex);
output = vertices.where(updateVertex);
end
delete frontier;
frontier = output;
end
delete frontier;

var elapsed_time : double = stopTimer();
print "elapsed time: ";
Expand Down
5 changes: 3 additions & 2 deletions apps/sssp.gt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ func main()
vertices.apply(reset);
var n : int = edges.getVertices();
var frontier : vertexset{Vertex} = new vertexset{Vertex}(0);
frontier.addVertex(14); %add source vertex
SP[14] = 14;
var start_vertex : int = atoi(argv[2]);
frontier.addVertex(start_vertex); %add source vertex
SP[start_vertex] = 0;

var rounds : int = 0;
while (frontier.getVertexSetSize() != 0)
Expand Down
44 changes: 44 additions & 0 deletions autotune/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
GraphIt Auotuner
=========
The autotuner for GraphIt aims to automatically find the best schedules for a given input algorithm specification and input graph. The autotuner is built on top of OpenTuner to efficiently search for the best combination of schedules (optimizations). **Currently, the autotuner still requires the user to place a label "s1" on the operator that nees to be tuned.**

The autotuner is still very experimental. Please read the instructions below carefully before using it.

Dependencies
-------------------


Please first install [OpenTuner](https://github.com/jansel/opentuner). GraphIt's autotuner is built on top of OpenTuner.

Autotune Schedules
-------------------

Currently it is the easiet to use the graphit files under autotune/apps because we need to have hardcoded starting points for the BFS and SSSP. If you want to change the starting point for BFS or SSSP, simply edit bfs_benmark.gt or sssp_benchmark.gt.


To tune the performance of bfs on the small test graph 4.el, use the following command. `--algo_file` specifies the algorithm file, and `--graph` specifies the input graph to tune on. The autotuner have options that enable/disable parallelization, enable/disable NUMA optimizations (by default we disabled NUMA optimization), and other options such as setting an upper bound on the number of segments to use for configNumSSG. We usually put a **time limt** on tuning with the `--stop-after` option. Even for programs that run on a large input graph, we can usually finish within 5000 seconds.
```
#change into the directory for autotuner
cd graphit/auotune
#autotune serial pagerank with 4.el graph for 10 seconds
python graphit_autotuner.py --enable_parallel_tuning 0 --algo_file apps/pagerank_benchmark.gt --graph ../test/graphs/4.el --stop-after 10
#autotune parallel pagerank with 4.el graph for 10 seconds
python graphit_autotuner.py --enable_parallel_tuning 1 --algo_file apps/pagerank_benchmark.gt --graph ../test/graphs/4.el --stop-after 10
```

To see all the options
```
python graphit_autotuner.py -h
```

The final result will be displayed as a configuration in the standard output, and also in `final_config.json`. One example is shown below. You can then translate that into the scheduling commands. At this time, this translation step still has to be done manually.
```
('Final Configuration:', {'parallelization': 'serial', 'direction': 'SparsePush', 'numSSG': 5, 'DenseVertexSet': 'boolean-array'})
```

You can also set the serial and parallel compiler used for the C++ files in the graphit_autotune.py file by modifying the variables `serial_compiler` and `par_compiler`.

Currently, the autotuner can not tune the data layout. So the user would need to provide schedules for fusing together different vectors. The user can provide some scheduling commands in a file as a necessary schedule using the `--default_schedule_file` option.
4 changes: 2 additions & 2 deletions autotune/apps/bfs_benchmark.gt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ func main()
vertices.apply(reset);
var frontier : vertexset{Vertex} = new vertexset{Vertex}(0);
frontier.addVertex(14);
parent[14] = 14;
parent[5] = 5;

while (frontier.getVertexSetSize() != 0)
#s1# frontier = edges.from(frontier).to(toFilter).applyModified(updateEdge,parent);
#s1# frontier = edges.from(frontier).to(toFilter).applyModified(updateEdge,parent, true);
end

var elapsed_time : float = stopTimer();
Expand Down
11 changes: 7 additions & 4 deletions autotune/graphit_autotuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
from sys import exit
import argparse

py_graphitc_file = "../build/bin/graphitc.py"
serial_compiler = "icc"
par_compiler = "icpc"

class GraphItTuner(MeasurementInterface):
new_schedule_file_name = ''
Expand Down Expand Up @@ -167,15 +170,15 @@ def compile(self, cfg, id):


#compile the schedule file along with the original algorithm file
compile_graphit_cmd = 'python graphitc.py -a {algo_file} -f {schedule_file} -i ../include/ -l ../build/lib/libgraphitlib.a -o test.cpp'.format(algo_file=self.args.algo_file, schedule_file=self.new_schedule_file_name)
compile_graphit_cmd = 'python ' + py_graphitc_file + ' -a {algo_file} -f {schedule_file} -i ../include/ -l ../build/lib/libgraphitlib.a -o test.cpp'.format(algo_file=self.args.algo_file, schedule_file=self.new_schedule_file_name)

if not self.use_NUMA:
if not self.enable_parallel_tuning:
# if parallel icpc compiler is not needed (only tuning serial schedules)
compile_cpp_cmd = 'g++ -std=c++11 -I ../src/runtime_lib/ -O3 test.cpp -o test'
compile_cpp_cmd = serial_compiler + ' -std=c++11 -I ../src/runtime_lib/ -O3 test.cpp -o test'
else:
# if parallel icpc compiler is supported and needed
compile_cpp_cmd = 'icpc -std=c++11 -DCILK -I ../src/runtime_lib/ -O3 test.cpp -o test'
compile_cpp_cmd = par_compiler + ' -std=c++11 -DCILK -I ../src/runtime_lib/ -O3 test.cpp -o test'
else:
#add the additional flags for NUMA
compile_cpp_cmd = 'icpc -std=c++11 -DOPENMP -lnuma -DNUMA -qopenmp -I ../src/runtime_lib/ -O3 test.cpp -o test'
Expand Down Expand Up @@ -307,7 +310,7 @@ def save_final_config(self, configuration):
parser = argparse.ArgumentParser(parents=opentuner.argparsers())
parser.add_argument('--graph', type=str, default="../test/graphs/4.sg",
help='the graph to tune on')
parser.add_argument('--enable_NUMA_tuning', type=int, default=1, help='enable tuning NUMA-aware schedules. 1 for enable (default), 0 for disable')
parser.add_argument('--enable_NUMA_tuning', type=int, default=0, help='enable tuning NUMA-aware schedules. 1 for enable (default), 0 for disable')
parser.add_argument('--enable_parallel_tuning', type=int, default=1, help='enable tuning paralleliation schedules. 1 for enable (default), 0 for disable')
parser.add_argument('--enable_denseVertexSet_tuning', type=int, default=1, help='enable tuning denseVertexSet schedules. 1 for enable (default), 0 for disable')
parser.add_argument('--algo_file', type=str, required=True, help='input algorithm file')
Expand Down
56 changes: 0 additions & 56 deletions autotune/main.cpp

This file was deleted.

Loading

0 comments on commit 79f8340

Please sign in to comment.