@@ -29,57 +29,117 @@ def manipulator(self):
2929 Define the search space by creating a
3030 ConfigurationManipulator
3131 """
32+ manipulator = ConfigurationManipulator ()
33+ if self .args .edge_only :
34+ #manipulator.add_parameter(EnumParameter('LB_0', ['VERTEX_BASED','TWC', 'TWCE', 'WM', 'CM', 'STRICT', 'EDGE_ONLY']))
35+ manipulator .add_parameter (EnumParameter ('LB_0' , ['VERTEX_BASED' ,'TWC' , 'TWCE' , 'WM' , 'CM' , 'EDGE_ONLY' ]))
36+ manipulator .add_parameter (EnumParameter ('EB_0' , ['ENABLED' , 'DISABLED' ]))
37+ manipulator .add_parameter (IntegerParameter ('BS_0' , 1 , 20 ))
38+ else :
39+ #manipulator.add_parameter(EnumParameter('LB_0', ['VERTEX_BASED','TWC', 'TWCE', 'WM', 'CM', 'STRICT']))
40+ manipulator .add_parameter (EnumParameter ('LB_0' , ['VERTEX_BASED' ,'TWC' , 'TWCE' , 'WM' , 'CM' ]))
3241
42+ manipulator .add_parameter (EnumParameter ('direction_0' , ['PUSH' , 'PULL' ]))
43+ manipulator .add_parameter (EnumParameter ('dedup_0' , ['ENABLED' , 'DISABLED' ]))
44+ manipulator .add_parameter (EnumParameter ('frontier_output_0' , ['FUSED' , 'UNFUSED_BITMAP' , 'UNFUSED_BOOLMAP' ]))
45+ manipulator .add_parameter (EnumParameter ('pull_rep_0' , ['BITMAP' , 'BOOLMAP' ]))
3346
47+ if self .args .hybrid_schedule :
48+ #manipulator.add_parameter(EnumParameter('LB_1', ['VERTEX_BASED','TWC', 'TWCE', 'WM', 'CM', 'STRICT']))
49+ manipulator .add_parameter (EnumParameter ('LB_1' , ['VERTEX_BASED' ,'TWC' , 'TWCE' , 'WM' , 'CM' ]))
50+
51+ manipulator .add_parameter (EnumParameter ('direction_1' , ['PUSH' , 'PULL' ]))
52+ manipulator .add_parameter (EnumParameter ('dedup_1' , ['ENABLED' , 'DISABLED' ]))
53+ manipulator .add_parameter (EnumParameter ('frontier_output_1' , ['FUSED' , 'UNFUSED_BITMAP' , 'UNFUSED_BOOLMAP' ]))
54+ manipulator .add_parameter (EnumParameter ('pull_rep_1' , ['BITMAP' , 'BOOLMAP' ]))
55+
56+ # We also choose the hybrid schedule threshold here
57+ manipulator .add_parameter (IntegerParameter ('threshold' , 0 , 1000 ))
58+
59+
3460
35- manipulator = ConfigurationManipulator ()
36- manipulator .add_parameter (
37- EnumParameter ('LB' ,
38- ['VERTEX_BASED' ,'TWC' , 'TWCE' , 'WM' , 'CM' , 'STRICT' ]))
39-
40- #'edge-aware-dynamic-vertex-parallel' not supported with the latest g++ cilk implementation
41- manipulator .add_parameter (EnumParameter ('direction' , ['PUSH' , 'PULL' ]))
42- manipulator .add_parameter (EnumParameter ('dedup' , ['ENABLED' , 'DISABLED' ]))
43- manipulator .add_parameter (EnumParameter ('frontier_output' , ['FUSED' , 'UNFUSED_BITMAP' , 'UNFUSED_BOOLMAP' ]))
4461 # adding new parameters for PriorityGraph (Ordered GraphIt)
45- manipulator .add_parameter (IntegerParameter ('delta' , 1 , self .args .max_delta ))
62+ # Currently since delta is allowed to be configured only once for the entire program, we will make a single decision even if the schedule is hybrid
63+ if self .args .tune_delta :
64+ manipulator .add_parameter (IntegerParameter ('delta' , 1 , self .args .max_delta ))
65+
66+
67+ if self .args .kernel_fusion :
68+ manipulator .add_parameter (EnumParameter ('kernel_fusion' , ['DISABLED' , 'ENABLED' ]))
4669
47- manipulator .add_parameter (EnumParameter ('kernel_fusion' , ['DISABLED' , 'ENABLED' ]))
48- manipulator .add_parameter (EnumParameter ('pull_rep' , ['BITMAP' , 'BOOLMAP' ]))
4970 return manipulator
5071
5172
5273 def write_cfg_to_schedule (self , cfg ):
5374 #write into a schedule file the configuration
54- direction = cfg ['direction' ]
55- delta = cfg ['delta' ]
56- dedup = cfg ['dedup' ]
57- frontier_output = cfg ['frontier_output' ]
58- kernel_fusion = cfg ['kernel_fusion' ]
59- pull_rep = cfg ['pull_rep' ]
60- LB = cfg ['LB' ]
75+
76+ direction_0 = cfg ['direction_0' ]
77+ if self .args .tune_delta :
78+ delta_0 = cfg ['delta' ]
79+ dedup_0 = cfg ['dedup_0' ]
80+ frontier_output_0 = cfg ['frontier_output_0' ]
81+ pull_rep_0 = cfg ['pull_rep_0' ]
82+ LB_0 = cfg ['LB_0' ]
6183
6284 new_schedule = "schedule:\n "
85+
6386 new_schedule += "SimpleGPUSchedule s1;\n " ;
64- new_schedule += "s1.configLoadBalance(" + LB + ");\n "
65- new_schedule += "s1.configFrontierCreation(" + frontier_output + ");\n "
66- if direction == "PULL" :
67- new_schedule += "s1.configDirection(PULL, " + pull_rep + ");\n "
87+ if LB_0 == "EDGE_ONLY" and cfg ['EB_0' ] == "ENABLED" :
88+ new_schedule += "s1.configLoadBalance(EDGE_ONLY, BLOCKED, " + str (int (int (self .args .num_vertices )/ cfg ['BS_0' ])) + ");\n "
89+ direction_0 = "PUSH"
90+ else :
91+ new_schedule += "s1.configLoadBalance(" + LB_0 + ");\n "
92+ new_schedule += "s1.configFrontierCreation(" + frontier_output_0 + ");\n "
93+ if direction_0 == "PULL" :
94+ new_schedule += "s1.configDirection(PULL, " + pull_rep_0 + ");\n "
6895 else :
6996 new_schedule += "s1.configDirection(PUSH);\n "
70- new_schedule += "s1.configDelta(" + str (delta ) + ");\n "
71- new_schedule += "s1.configDeduplication(" + dedup + ");\n "
72- new_schedule += "program->applyGPUSchedule(\" s0:s1\" , s1);\n "
73- new_schedule += "SimpleGPUSchedule s0;\n "
74- new_schedule += "s0.configKernelFusion(" + kernel_fusion + ");\n "
75- # We will currently not apply this. Use this after kernel fusion is fixed
76- #new_schedule += "program->applyGPUSchedule(\"s0\", s0);\n"
97+ if self .args .tune_delta :
98+ new_schedule += "s1.configDelta(" + str (delta_0 ) + ");\n "
99+ new_schedule += "s1.configDeduplication(" + dedup_0 + ");\n "
100+
101+ if self .args .hybrid_schedule :
102+ direction_1 = cfg ['direction_1' ]
103+ if self .args .tune_delta :
104+ delta_1 = cfg ['delta' ]
105+ dedup_1 = cfg ['dedup_1' ]
106+ frontier_output_1 = cfg ['frontier_output_1' ]
107+ pull_rep_1 = cfg ['pull_rep_1' ]
108+ LB_1 = cfg ['LB_1' ]
109+
110+ #threshold = self.args.hybrid_threshold
111+ threshold = cfg ['threshold' ]
112+
113+ new_schedule += "SimpleGPUSchedule s2;\n " ;
114+ new_schedule += "s2.configLoadBalance(" + LB_1 + ");\n "
115+ new_schedule += "s2.configFrontierCreation(" + frontier_output_1 + ");\n "
116+ if direction_1 == "PULL" :
117+ new_schedule += "s2.configDirection(PULL, " + pull_rep_1 + ");\n "
118+ else :
119+ new_schedule += "s2.configDirection(PUSH);\n "
120+ if self .args .tune_delta :
121+ new_schedule += "s2.configDelta(" + str (delta_1 ) + ");\n "
122+ new_schedule += "s2.configDeduplication(" + dedup_1 + ");\n "
123+
124+ new_schedule += "HybridGPUSchedule h1(INPUT_VERTEXSET_SIZE, " + str (threshold / 1000 ) + ", s1, s2);\n "
125+ new_schedule += "program->applyGPUSchedule(\" s0:s1\" , h1);\n "
126+
127+ else :
128+ new_schedule += "program->applyGPUSchedule(\" s0:s1\" , s1);\n "
129+
130+
131+
132+ if self .args .kernel_fusion :
133+ kernel_fusion = cfg ['kernel_fusion' ]
134+ new_schedule += "SimpleGPUSchedule s0;\n "
135+ new_schedule += "s0.configKernelFusion(" + kernel_fusion + ");\n "
136+ new_schedule += "program->applyGPUSchedule(\" s0\" , s0);\n "
77137
78138 print (cfg )
79- print (new_schedule )
139+ # print (new_schedule)
80140
81141 self .new_schedule_file_name = 'schedule_0'
82- print (self .new_schedule_file_name )
142+ # print (self.new_schedule_file_name)
83143 f1 = open (self .new_schedule_file_name , 'w' )
84144 f1 .write (new_schedule )
85145 f1 .close ()
@@ -174,7 +234,7 @@ def compile_and_run(self, desired_result, input, limit):
174234 Compile and run a given configuration then
175235 return performance
176236 """
177- print ("input graph: " + self .args .graph )
237+ # print ("input graph: " + self.args.graph)
178238
179239 cfg = desired_result .configuration .data
180240
@@ -190,7 +250,7 @@ def compile_and_run(self, desired_result, input, limit):
190250 def save_final_config (self , configuration ):
191251 """called at the end of tuning"""
192252 print ('Final Configuration:' , configuration .data )
193- self .manipulator ().save_to_file (configuration .data ,'final_config.json' )
253+ self .manipulator ().save_to_file (configuration .data , self . args . final_config )
194254
195255
196256
@@ -200,11 +260,21 @@ def save_final_config(self, configuration):
200260 parser .add_argument ('--start_vertex' , type = str , default = "0" , help = "Start vertex if applicable" )
201261
202262 parser .add_argument ('--algo_file' , type = str , required = True , help = 'input algorithm file' )
263+ parser .add_argument ('--final_config' , type = str , help = 'Final config file' , default = "final_config.json" )
203264 parser .add_argument ('--default_schedule_file' , type = str , required = False , default = "" , help = 'default schedule file' )
204265 parser .add_argument ('--runtime_limit' , type = float , default = 300 , help = 'a limit on the running time of each program' )
205266 parser .add_argument ('--max_delta' , type = int , default = 800000 , help = 'maximum delta used for priority coarsening' )
206267 parser .add_argument ('--memory_limit' , type = int , default = - 1 ,help = 'set memory limit on unix based systems [does not quite work yet]' )
207268 parser .add_argument ('--killed_process_report_runtime_limit' , type = int , default = 0 , help = 'reports runtime_limit when a process is killed by the shell. 0 for disable (default), 1 for enable' )
269+
270+ parser .add_argument ('--kernel_fusion' , type = bool , default = False , help = 'Choose if you want to also tune kernel fusion' )
271+ parser .add_argument ('--hybrid_schedule' , type = bool , default = False , help = 'Choose if you want to also explore hybrid schedules' )
272+ parser .add_argument ('--edge_only' , type = bool , default = False , help = 'Choose if you want to also enable EDGE_ONLY schedules' )
273+ parser .add_argument ('--num_vertices' , type = int , required = True , help = 'Supply number of vertices in the graph' )
274+ parser .add_argument ('--tune_delta' , type = bool , default = False , help = 'Also tune the delta parameter' )
275+ parser .add_argument ('--hybrid_threshold' , type = int , default = 1000 , help = 'Threshold value on 1000' )
276+
277+
208278 args = parser .parse_args ()
209279 # pass the argumetns into the tuner
210280 GraphItTuner .main (args )
0 commit comments