[706] | 1 | #!/usr/bin/python |
---|
| 2 | |
---|
| 3 | import subprocess |
---|
| 4 | import os |
---|
| 5 | import re |
---|
[779] | 6 | import sys |
---|
[706] | 7 | |
---|
| 8 | |
---|
[836] | 9 | apps = [ 'filter', 'lu', 'fft_ga' ] |
---|
| 10 | #apps = [ 'histogram', 'mandel', 'filter', 'fft', 'fft_ga', 'filt_ga', 'pca', 'lu' ] # radix radix_ga kmeans |
---|
| 11 | #apps = [ 'filt_ga' ] |
---|
| 12 | nb_procs = [ 1, 4, 8, 16, 32, 64 ] |
---|
| 13 | single_protocols = ['dhccp', 'rwt' ] |
---|
| 14 | joint_protocols = ['dhccp', 'rwt' ] |
---|
[790] | 15 | #joint_protocols = [] |
---|
[706] | 16 | |
---|
| 17 | top_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..") |
---|
| 18 | scripts_path = os.path.join(top_path, 'scripts') |
---|
| 19 | counter_defs_name = os.path.join(scripts_path, "counter_defs.py") |
---|
| 20 | |
---|
| 21 | exec(file(counter_defs_name)) |
---|
| 22 | |
---|
| 23 | gen_dir = 'generated' |
---|
| 24 | graph_dir = 'graph' |
---|
| 25 | template_dir = 'templates' |
---|
| 26 | data_dir = 'data' |
---|
| 27 | |
---|
[779] | 28 | log_stdo_name = '_stdo_' |
---|
| 29 | log_term_name = '_term_' |
---|
[706] | 30 | |
---|
| 31 | coherence_tmpl = os.path.join(scripts_path, template_dir, 'coherence_template.gp') # 1 graph per appli |
---|
| 32 | speedup_tmpl = os.path.join(scripts_path, template_dir, 'speedup_template.gp') |
---|
| 33 | metric_tmpl = os.path.join(scripts_path, template_dir, 'metric_template.gp') # 1 graph per metric |
---|
| 34 | stacked_tmpl = os.path.join(scripts_path, template_dir, 'stacked_template.gp') |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | def create_file(name, content): |
---|
| 39 | file = open(name, 'w') |
---|
| 40 | file.write(content) |
---|
| 41 | file.close() |
---|
| 42 | |
---|
| 43 | def is_numeric(s): |
---|
| 44 | try: |
---|
| 45 | float(s) |
---|
| 46 | return True |
---|
| 47 | except ValueError: |
---|
| 48 | return False |
---|
| 49 | |
---|
| 50 | def get_x_y(nb_procs): |
---|
| 51 | x = 1 |
---|
| 52 | y = 1 |
---|
| 53 | to_x = True |
---|
| 54 | while (x * y * 4 < nb_procs): |
---|
| 55 | if to_x: |
---|
| 56 | x = x * 2 |
---|
| 57 | else: |
---|
| 58 | y = y * 2 |
---|
| 59 | to_x = not to_x |
---|
| 60 | return x, y |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | # We first fill the m_metric_id table |
---|
| 65 | for metric in all_metrics: |
---|
| 66 | for tag in all_tags: |
---|
| 67 | if m_metric_tag[metric] == tag: |
---|
| 68 | m_metric_id[tag] = metric |
---|
| 69 | break |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | # We start by processing all the log files |
---|
| 73 | # Term files are processed for exec time only |
---|
| 74 | # Init files are processed for all metrics |
---|
| 75 | exec_time = {} |
---|
| 76 | metrics_val = {} |
---|
[779] | 77 | for prot in single_protocols: |
---|
| 78 | metrics_val[prot] = {} |
---|
| 79 | exec_time[prot] = {} |
---|
| 80 | for app in apps: |
---|
| 81 | exec_time[prot][app] = {} |
---|
| 82 | metrics_val[prot][app] = {} |
---|
| 83 | for i in nb_procs: |
---|
| 84 | metrics_val[prot][app][i] = {} |
---|
| 85 | log_stdo_file = os.path.join(scripts_path, data_dir, app + '_' + prot + log_stdo_name + str(i)) |
---|
| 86 | log_term_file = os.path.join(scripts_path, data_dir, app + '_' + prot + log_term_name + str(i)) |
---|
| 87 | |
---|
| 88 | # Term |
---|
| 89 | lines = open(log_term_file, 'r') |
---|
| 90 | for line in lines: |
---|
| 91 | tokens = line[:-1].split() |
---|
| 92 | if len(tokens) > 0 and tokens[0] == "[PARALLEL_COMPUTE]": |
---|
| 93 | exec_time[prot][app][i] = int(tokens[len(tokens) - 1]) |
---|
| 94 | |
---|
| 95 | # Init files |
---|
| 96 | lines = open(log_stdo_file, 'r') |
---|
| 97 | for line in lines: |
---|
| 98 | tokens = line[:-1].split() |
---|
| 99 | if len(tokens) == 0: |
---|
| 100 | continue |
---|
| 101 | tag = tokens[0] |
---|
| 102 | value = tokens[len(tokens) - 1] |
---|
| 103 | pattern = re.compile('\[0[0-9][0-9]\]') |
---|
| 104 | if pattern.match(tag): |
---|
| 105 | metric = m_metric_id[tag] |
---|
| 106 | if (not metrics_val[prot][app][i].has_key(metric) or tag == "[000]" or tag == "[001]"): |
---|
| 107 | # We don't add cycles of all Memcaches (they must be the same for all) |
---|
| 108 | metrics_val[prot][app][i][metric] = int(value) |
---|
| 109 | else: |
---|
| 110 | metrics_val[prot][app][i][metric] += int(value) |
---|
| 111 | |
---|
| 112 | # Completing unset metrics (i.e. they are not present in the data file) with 0 |
---|
| 113 | for prot in single_protocols: |
---|
| 114 | for app in apps: |
---|
| 115 | for i in nb_procs: |
---|
| 116 | for metric in all_metrics: |
---|
| 117 | if metric not in metrics_val[prot][app][i]: |
---|
| 118 | metrics_val[prot][app][i][metric] = 0 |
---|
[706] | 119 | |
---|
| 120 | # We make a 2nd pass to fill the derived fields, e.g. nb_total_updates |
---|
[779] | 121 | for prot in single_protocols: |
---|
| 122 | for app in apps: |
---|
| 123 | for i in nb_procs: |
---|
| 124 | x, y = get_x_y(i) |
---|
[790] | 125 | metrics_val[prot][app][i]['total_read'] = metrics_val[prot][app][i]['local_read'] + metrics_val[prot][app][i]['remote_read'] |
---|
| 126 | metrics_val[prot][app][i]['total_write'] = metrics_val[prot][app][i]['local_write'] + metrics_val[prot][app][i]['remote_write'] |
---|
| 127 | metrics_val[prot][app][i]['total_ll'] = metrics_val[prot][app][i]['local_ll'] + metrics_val[prot][app][i]['remote_ll'] |
---|
| 128 | metrics_val[prot][app][i]['total_sc'] = metrics_val[prot][app][i]['local_sc'] + metrics_val[prot][app][i]['remote_sc'] |
---|
| 129 | metrics_val[prot][app][i]['total_cas'] = metrics_val[prot][app][i]['local_cas'] + metrics_val[prot][app][i]['remote_cas'] |
---|
| 130 | metrics_val[prot][app][i]['total_update'] = metrics_val[prot][app][i]['local_update'] + metrics_val[prot][app][i]['remote_update'] |
---|
| 131 | metrics_val[prot][app][i]['total_m_inv'] = metrics_val[prot][app][i]['local_m_inv'] + metrics_val[prot][app][i]['remote_m_inv'] |
---|
| 132 | metrics_val[prot][app][i]['total_cleanup'] = metrics_val[prot][app][i]['local_cleanup'] + metrics_val[prot][app][i]['remote_cleanup'] |
---|
| 133 | metrics_val[prot][app][i]['total_cleanup_d'] = metrics_val[prot][app][i]['local_cleanup_d'] + metrics_val[prot][app][i]['remote_cleanup_d'] |
---|
| 134 | metrics_val[prot][app][i]['total_getm'] = metrics_val[prot][app][i]['local_getm'] + metrics_val[prot][app][i]['remote_getm'] |
---|
| 135 | metrics_val[prot][app][i]['total_inval_ro'] = metrics_val[prot][app][i]['local_inval_ro'] + metrics_val[prot][app][i]['remote_inval_ro'] |
---|
| 136 | metrics_val[prot][app][i]['total_direct'] = metrics_val[prot][app][i]['total_read'] + metrics_val[prot][app][i]['total_write'] |
---|
| 137 | metrics_val[prot][app][i]['total_ncc_to_cc'] = metrics_val[prot][app][i]['ncc_to_cc_read'] + metrics_val[prot][app][i]['ncc_to_cc_write'] |
---|
| 138 | metrics_val[prot][app][i]['direct_cost'] = metrics_val[prot][app][i]['read_cost'] + metrics_val[prot][app][i]['write_cost'] |
---|
[779] | 139 | metrics_val[prot][app][i]['broadcast_cost'] = metrics_val[prot][app][i]['broadcast'] * (x * y - 1) |
---|
| 140 | if metrics_val[prot][app][i]['broadcast'] < metrics_val[prot][app][i]['write_broadcast']: |
---|
| 141 | # test to patch a bug in mem_cache |
---|
| 142 | metrics_val[prot][app][i]['nonwrite_broadcast'] = 0 |
---|
[790] | 143 | print "*** Error which should not happen anymore: incorrect number of Broadcasts/Write Broadcasts" |
---|
[779] | 144 | else: |
---|
| 145 | metrics_val[prot][app][i]['nonwrite_broadcast'] = metrics_val[prot][app][i]['broadcast'] - metrics_val[prot][app][i]['write_broadcast'] |
---|
| 146 | |
---|
| 147 | metrics_val[prot][app][i]['total_stacked'] = 0 |
---|
| 148 | for stacked_metric in stacked_metrics: |
---|
| 149 | metrics_val[prot][app][i]['total_stacked'] += metrics_val[prot][app][i][stacked_metric] |
---|
[706] | 150 | |
---|
| 151 | |
---|
| 152 | print "mkdir -p", os.path.join(scripts_path, gen_dir) |
---|
| 153 | subprocess.call([ 'mkdir', '-p', os.path.join(scripts_path, gen_dir) ]) |
---|
| 154 | |
---|
| 155 | print "mkdir -p", os.path.join(scripts_path, graph_dir) |
---|
| 156 | subprocess.call([ 'mkdir', '-p', os.path.join(scripts_path, graph_dir) ]) |
---|
| 157 | |
---|
| 158 | ############################################################ |
---|
| 159 | ### Graph 1 : Coherence traffic Cost per application ### |
---|
| 160 | ############################################################ |
---|
| 161 | |
---|
[779] | 162 | for prot in single_protocols: |
---|
| 163 | for app in apps: |
---|
| 164 | data_coherence_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_coherence.dat') |
---|
| 165 | gp_coherence_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_coherence.gp') |
---|
[706] | 166 | |
---|
[779] | 167 | # Creating the data file |
---|
| 168 | width = 15 |
---|
| 169 | content = "" |
---|
| 170 | |
---|
| 171 | for metric in [ '#nb_procs' ] + grouped_metrics: |
---|
| 172 | content += metric + " " |
---|
| 173 | nb_spaces = width - len(metric) |
---|
| 174 | content += nb_spaces * ' ' |
---|
[706] | 175 | content += "\n" |
---|
| 176 | |
---|
[779] | 177 | for i in nb_procs: |
---|
| 178 | content += "%-15d " % i |
---|
| 179 | for metric in grouped_metrics: |
---|
| 180 | val = float(metrics_val[prot][app][i][metric]) / exec_time[prot][app][i] * 1000 |
---|
| 181 | content += "%-15f " % val |
---|
| 182 | content += "\n" |
---|
| 183 | |
---|
| 184 | create_file(data_coherence_name, content) |
---|
| 185 | |
---|
| 186 | # Creating the gp file |
---|
| 187 | template_file = open(coherence_tmpl, 'r') |
---|
| 188 | template = template_file.read() |
---|
| 189 | |
---|
| 190 | plot_str = "" |
---|
| 191 | col = 2 |
---|
| 192 | for metric in grouped_metrics: |
---|
| 193 | if metric != grouped_metrics[0]: |
---|
| 194 | plot_str += ", \\\n " |
---|
| 195 | plot_str += "\"" + data_coherence_name + "\" using ($1):($" + str(col) + ") lc rgb " + colors[col - 2] + " title \"" + m_metric_name[metric] + "\" with linespoint" |
---|
| 196 | col += 1 |
---|
| 197 | gp_commands = template % dict(app_name = m_app_name[app], nb_procs = nb_procs[-1] + 1, plot_str = plot_str, svg_name = os.path.join(graph_dir, prot + '_' + app + '_coherence')) |
---|
| 198 | |
---|
| 199 | create_file(gp_coherence_name, gp_commands) |
---|
| 200 | |
---|
| 201 | # Calling gnuplot |
---|
| 202 | print "gnuplot", gp_coherence_name |
---|
| 203 | subprocess.call([ 'gnuplot', gp_coherence_name ]) |
---|
[706] | 204 | |
---|
[779] | 205 | |
---|
| 206 | ############################################################ |
---|
| 207 | ### Graph 2 : Speedup per Application ### |
---|
| 208 | ############################################################ |
---|
| 209 | |
---|
| 210 | for prot in single_protocols: |
---|
| 211 | for app in apps: |
---|
[706] | 212 | |
---|
[779] | 213 | data_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_speedup.dat') |
---|
| 214 | gp_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_speedup.gp') |
---|
| 215 | |
---|
| 216 | # Creating data file |
---|
| 217 | width = 15 |
---|
| 218 | content = "#nb_procs" |
---|
| 219 | nb_spaces = width - len(content) |
---|
| 220 | content += nb_spaces * ' ' |
---|
| 221 | content += "speedup\n" |
---|
[706] | 222 | |
---|
[779] | 223 | for i in nb_procs: |
---|
| 224 | content += "%-15d " % i |
---|
| 225 | val = exec_time[prot][app][i] |
---|
| 226 | content += "%-15f\n" % (exec_time[prot][app][1] / float(val)) |
---|
[706] | 227 | |
---|
[779] | 228 | plot_str = "\"" + data_speedup_name + "\" using ($1):($2) lc rgb \"#654387\" title \"Speedup\" with linespoint" |
---|
| 229 | |
---|
| 230 | create_file(data_speedup_name, content) |
---|
| 231 | |
---|
| 232 | # Creating the gp file |
---|
| 233 | template_file = open(speedup_tmpl, 'r') |
---|
| 234 | template = template_file.read() |
---|
| 235 | |
---|
| 236 | gp_commands = template % dict(appli = m_app_name[app], nb_procs = nb_procs[-1] + 1, plot_str = plot_str, svg_name = os.path.join(graph_dir, prot + '_' + app + '_speedup')) |
---|
| 237 | |
---|
| 238 | create_file(gp_speedup_name, gp_commands) |
---|
| 239 | |
---|
| 240 | # Calling gnuplot |
---|
| 241 | print "gnuplot", gp_speedup_name |
---|
| 242 | subprocess.call([ 'gnuplot', gp_speedup_name ]) |
---|
[706] | 243 | |
---|
| 244 | |
---|
| 245 | ############################################################ |
---|
[779] | 246 | ### Graph 3 : All speedups on the same Graph ### |
---|
[706] | 247 | ############################################################ |
---|
| 248 | |
---|
[779] | 249 | for prot in single_protocols: |
---|
| 250 | # This graph uses the same template as the graph 2 |
---|
| 251 | data_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_all_speedup.dat') |
---|
| 252 | gp_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_all_speedup.gp') |
---|
[706] | 253 | |
---|
| 254 | # Creating data file |
---|
| 255 | width = 15 |
---|
| 256 | content = "#nb_procs" |
---|
| 257 | nb_spaces = width - len(content) |
---|
[779] | 258 | content += (nb_spaces + 1) * ' ' |
---|
| 259 | for app in apps: |
---|
| 260 | content += app + " " |
---|
| 261 | content += (width - len(app)) * " " |
---|
| 262 | content += "\n" |
---|
| 263 | |
---|
[706] | 264 | for i in nb_procs: |
---|
| 265 | content += "%-15d " % i |
---|
[779] | 266 | for app in apps: |
---|
| 267 | val = exec_time[prot][app][i] |
---|
| 268 | content += "%-15f " % (exec_time[prot][app][1] / float(val)) |
---|
| 269 | content += "\n" |
---|
[706] | 270 | |
---|
| 271 | create_file(data_speedup_name, content) |
---|
| 272 | |
---|
[779] | 273 | # Creating gp file |
---|
[706] | 274 | template_file = open(speedup_tmpl, 'r') |
---|
| 275 | template = template_file.read() |
---|
| 276 | |
---|
[779] | 277 | plot_str = "" |
---|
| 278 | col = 2 |
---|
| 279 | for app in apps: |
---|
| 280 | if app != apps[0]: |
---|
| 281 | plot_str += ", \\\n " |
---|
| 282 | plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2]) + m_app_name[app] + "\" with linespoint" |
---|
| 283 | col += 1 |
---|
[706] | 284 | |
---|
[779] | 285 | gp_commands = template % dict(appli = "All Applications", nb_procs = nb_procs[-1] + 1, plot_str = plot_str, svg_name = os.path.join(graph_dir, prot + '_all_speedup')) |
---|
| 286 | |
---|
[706] | 287 | create_file(gp_speedup_name, gp_commands) |
---|
[779] | 288 | |
---|
[706] | 289 | # Calling gnuplot |
---|
| 290 | print "gnuplot", gp_speedup_name |
---|
| 291 | subprocess.call([ 'gnuplot', gp_speedup_name ]) |
---|
| 292 | |
---|
| 293 | |
---|
| 294 | ############################################################ |
---|
[779] | 295 | ### Graph 4 : Graph per metric ### |
---|
[706] | 296 | ############################################################ |
---|
| 297 | |
---|
[779] | 298 | # The following section creates the graphs grouped by measure (e.g. #broadcasts) |
---|
| 299 | # The template file cannot be easily created otherwise it would not be generic |
---|
| 300 | # in many ways. This is why it is mainly created here. |
---|
| 301 | # Graphs are created for metric in the "individual_metrics" list |
---|
[706] | 302 | |
---|
[779] | 303 | for prot in single_protocols: |
---|
| 304 | for metric in individual_metrics: |
---|
| 305 | data_metric_name = os.path.join(scripts_path, gen_dir, prot + '_' + metric + '.dat') |
---|
| 306 | gp_metric_name = os.path.join(scripts_path, gen_dir, prot + '_' + metric + '.gp') |
---|
[706] | 307 | |
---|
[779] | 308 | # Creating the gp file |
---|
| 309 | # Setting xtics, i.e. number of procs for each application |
---|
| 310 | xtics_str = "(" |
---|
| 311 | first = True |
---|
| 312 | xpos = 1 |
---|
| 313 | app_labels = "" |
---|
| 314 | for num_appli in range(0, len(apps)): |
---|
| 315 | for i in nb_procs: |
---|
| 316 | if not first: |
---|
| 317 | xtics_str += ", " |
---|
| 318 | first = False |
---|
| 319 | if i == nb_procs[0]: |
---|
| 320 | xpos_first = xpos |
---|
| 321 | xtics_str += "\"%d\" %.1f" % (i, xpos) |
---|
| 322 | xpos_last = xpos |
---|
| 323 | xpos += 1.5 |
---|
| 324 | xpos += 0.5 |
---|
| 325 | app_name_xpos = float((xpos_first + xpos_last)) / 2 |
---|
| 326 | app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos) |
---|
| 327 | xtics_str += ")" |
---|
[706] | 328 | |
---|
[779] | 329 | xmax_val = float(xpos - 1) |
---|
| 330 | |
---|
| 331 | # Writing the lines of "plot" |
---|
| 332 | plot_str = "" |
---|
| 333 | xpos = 0 |
---|
| 334 | first = True |
---|
| 335 | column = 2 |
---|
| 336 | for i in range(0, len(nb_procs)): |
---|
| 337 | if not first: |
---|
| 338 | plot_str += ", \\\n " |
---|
| 339 | first = False |
---|
| 340 | plot_str += "\"%s\" using ($1+%.1f):($%d) lc rgb %s notitle with boxes" % (data_metric_name, xpos, column, colors[i]) |
---|
| 341 | column += 1 |
---|
| 342 | xpos += 1.5 |
---|
| 343 | |
---|
| 344 | template_file = open(metric_tmpl, 'r') |
---|
| 345 | template = template_file.read() |
---|
| 346 | |
---|
| 347 | gp_commands = template % dict(xtics_str = xtics_str, app_labels = app_labels, ylabel_str = m_metric_name[metric], norm_factor_str = m_norm_factor_name[m_metric_norm[metric]], xmax_val = xmax_val, plot_str = plot_str, svg_name = os.path.join(graph_dir, prot + '_' + metric)) |
---|
| 348 | |
---|
| 349 | create_file(gp_metric_name, gp_commands) |
---|
| 350 | |
---|
| 351 | # Creating the data file |
---|
| 352 | width = 15 |
---|
| 353 | content = "#x_pos" |
---|
| 354 | nb_spaces = width - len(content) |
---|
| 355 | content += nb_spaces * ' ' |
---|
| 356 | for i in nb_procs: |
---|
| 357 | content += "%-15d" % i |
---|
| 358 | content += "\n" |
---|
| 359 | |
---|
| 360 | x_pos = 1 |
---|
| 361 | for app in apps: |
---|
| 362 | # Computation of x_pos |
---|
| 363 | content += "%-15f" % x_pos |
---|
| 364 | x_pos += len(nb_procs) * 1.5 + 0.5 |
---|
| 365 | for i in nb_procs: |
---|
| 366 | if m_metric_norm[metric] == "N": |
---|
| 367 | content += "%-15d" % (metrics_val[prot][app][i][metric]) |
---|
| 368 | elif m_metric_norm[metric] == "P": |
---|
| 369 | content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / i) |
---|
| 370 | elif m_metric_norm[metric] == "C": |
---|
| 371 | content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / exec_time[prot][app][i] * 1000) |
---|
| 372 | elif m_metric_norm[metric] == "W": |
---|
| 373 | content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_write'])) # Number of writes |
---|
| 374 | elif m_metric_norm[metric] == "R": |
---|
| 375 | content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_read'])) # Number of reads |
---|
| 376 | elif m_metric_norm[metric] == "D": |
---|
| 377 | content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_direct'])) # Number of req. |
---|
| 378 | elif is_numeric(m_metric_norm[metric]): |
---|
| 379 | content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][int(m_metric_norm[metric])][metric])) |
---|
| 380 | else: |
---|
| 381 | assert(False) |
---|
| 382 | |
---|
| 383 | app_name = m_app_name[app] |
---|
| 384 | content += "#" + app_name + "\n" |
---|
| 385 | |
---|
| 386 | create_file(data_metric_name, content) |
---|
| 387 | |
---|
| 388 | # Calling gnuplot |
---|
| 389 | print "gnuplot", gp_metric_name |
---|
| 390 | subprocess.call([ 'gnuplot', gp_metric_name ]) |
---|
[706] | 391 | |
---|
| 392 | |
---|
| 393 | ############################################################ |
---|
[779] | 394 | ### Graph 5 : Stacked histogram with counters ### |
---|
[706] | 395 | ############################################################ |
---|
| 396 | |
---|
[779] | 397 | # The following section creates a stacked histogram containing |
---|
| 398 | # the metrics in the "stacked_metric" list |
---|
| 399 | # It is normalized per application w.r.t the values on 256 procs |
---|
[706] | 400 | |
---|
[779] | 401 | for prot in single_protocols: |
---|
| 402 | data_stacked_name = os.path.join(scripts_path, gen_dir, prot + '_stacked.dat') |
---|
| 403 | gp_stacked_name = os.path.join(scripts_path, gen_dir, prot + '_stacked.gp') |
---|
| 404 | |
---|
[836] | 405 | norm_factor_value = nb_procs[-1] |
---|
[779] | 406 | |
---|
[706] | 407 | # Creating the gp file |
---|
[779] | 408 | template_file = open(stacked_tmpl, 'r') |
---|
| 409 | template = template_file.read() |
---|
| 410 | |
---|
[706] | 411 | xtics_str = "(" |
---|
| 412 | first = True |
---|
| 413 | xpos = 1 |
---|
| 414 | app_labels = "" |
---|
| 415 | for num_appli in range(0, len(apps)): |
---|
| 416 | for i in nb_procs: |
---|
| 417 | if not first: |
---|
| 418 | xtics_str += ", " |
---|
| 419 | first = False |
---|
| 420 | if i == nb_procs[0]: |
---|
| 421 | xpos_first = xpos |
---|
[779] | 422 | xtics_str += "\"%d\" %d -1" % (i, xpos) |
---|
[706] | 423 | xpos_last = xpos |
---|
[779] | 424 | xpos += 1 |
---|
| 425 | xpos += 1 |
---|
[706] | 426 | app_name_xpos = float((xpos_first + xpos_last)) / 2 |
---|
[779] | 427 | app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos) |
---|
[706] | 428 | xtics_str += ")" |
---|
[779] | 429 | |
---|
| 430 | plot_str = "newhistogram \"\"" |
---|
| 431 | n = 1 |
---|
| 432 | for stacked_metric in stacked_metrics: |
---|
| 433 | plot_str += ", \\\n " + "'" + data_stacked_name + "'" + " using " + str(n) + " lc rgb " + colors[n] + " title \"" + m_metric_name[stacked_metric] + "\"" |
---|
| 434 | n += 1 |
---|
| 435 | |
---|
| 436 | ylabel_str = "Breakdown of Coherence Traffic Normalized w.r.t. \\nthe Values on %d Processors" % norm_factor_value |
---|
| 437 | content = template % dict(svg_name = os.path.join(graph_dir, prot + '_stacked'), xtics_str = xtics_str, plot_str = plot_str, ylabel_str = ylabel_str, app_labels = app_labels, prot_labels = "") |
---|
| 438 | |
---|
| 439 | create_file(gp_stacked_name, content) |
---|
| 440 | |
---|
| 441 | # Creating the data file |
---|
| 442 | # Values are normalized by application, w.r.t. the number of requests for a given number of procs |
---|
| 443 | content = "#" |
---|
| 444 | for stacked_metric in stacked_metrics: |
---|
| 445 | content += stacked_metric |
---|
| 446 | content += ' ' + ' ' * (15 - len(stacked_metric)) |
---|
| 447 | content += "\n" |
---|
| 448 | for app in apps: |
---|
| 449 | if app != apps[0]: |
---|
| 450 | for i in range(0, len(stacked_metrics)): |
---|
| 451 | content += "%-15f" % 0.0 |
---|
| 452 | content += "\n" |
---|
| 453 | for i in nb_procs: |
---|
| 454 | for stacked_metric in stacked_metrics: |
---|
| 455 | content += "%-15f" % (float(metrics_val[prot][app][i][stacked_metric]) / metrics_val[prot][app][norm_factor_value]['total_stacked']) |
---|
| 456 | content += "\n" |
---|
| 457 | |
---|
| 458 | create_file(data_stacked_name, content) |
---|
| 459 | # Calling gnuplot |
---|
| 460 | print "gnuplot", gp_stacked_name |
---|
| 461 | subprocess.call([ 'gnuplot', gp_stacked_name ]) |
---|
[706] | 462 | |
---|
| 463 | |
---|
| 464 | |
---|
[779] | 465 | ################################################################################# |
---|
| 466 | ### Graph 6 : Stacked histogram with coherence cost compared to r/w cost ### |
---|
| 467 | ################################################################################# |
---|
[706] | 468 | |
---|
[779] | 469 | # The following section creates pairs of stacked histograms, normalized w.r.t. the first one. |
---|
| 470 | # The first one contains the cost of reads and writes, the second contains the cost |
---|
| 471 | # of m_inv, m_up and broadcasts (extrapolated) |
---|
[706] | 472 | |
---|
[779] | 473 | for prot in single_protocols: |
---|
| 474 | data_cost_filename = os.path.join(scripts_path, gen_dir, prot + '_relative_cost.dat') |
---|
| 475 | gp_cost_filename = os.path.join(scripts_path, gen_dir, prot + '_relative_cost.gp') |
---|
[706] | 476 | |
---|
[779] | 477 | direct_cost_metrics = [ 'read_cost', 'write_cost' ] |
---|
| 478 | coherence_cost_metrics = ['update_cost', 'm_inv_cost', 'broadcast_cost' ] |
---|
| 479 | |
---|
| 480 | # Creating the gp file |
---|
| 481 | template_file = open(stacked_tmpl, 'r') |
---|
| 482 | template = template_file.read() |
---|
| 483 | |
---|
| 484 | xtics_str = "(" |
---|
| 485 | first = True |
---|
| 486 | xpos = 1 |
---|
| 487 | app_labels = "" |
---|
| 488 | for num_appli in range(0, len(apps)): |
---|
| 489 | first_proc = True |
---|
| 490 | for i in nb_procs: |
---|
| 491 | if i > 4: |
---|
| 492 | if not first: |
---|
| 493 | xtics_str += ", " |
---|
| 494 | first = False |
---|
| 495 | if first_proc: |
---|
| 496 | first_proc = False |
---|
| 497 | xpos_first = xpos |
---|
| 498 | xtics_str += "\"%d\" %f -1" % (i, float(xpos + 0.5)) |
---|
| 499 | xpos_last = xpos |
---|
| 500 | xpos += 3 |
---|
| 501 | app_name_xpos = float((xpos_first + xpos_last)) / 2 |
---|
| 502 | app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos) |
---|
| 503 | #xpos += 1 |
---|
| 504 | xtics_str += ")" |
---|
| 505 | |
---|
| 506 | plot_str = "newhistogram \"\"" |
---|
| 507 | n = 1 |
---|
| 508 | for cost_metric in direct_cost_metrics + coherence_cost_metrics: |
---|
| 509 | plot_str += ", \\\n " + "'" + data_cost_filename + "'" + " using " + str(n) + " lc rgb " + colors[n] + " title \"" + m_metric_name[cost_metric] + "\"" |
---|
| 510 | n += 1 |
---|
| 511 | |
---|
| 512 | ylabel_str = "Coherence Cost Compared to Direct Requests Cost,\\nNormalized per Application for each Number of Processors" |
---|
| 513 | content = template % dict(svg_name = os.path.join(graph_dir, prot + '_rel_cost'), xtics_str = xtics_str, plot_str = plot_str, ylabel_str = ylabel_str, app_labels = app_labels, prot_labels = "") |
---|
| 514 | |
---|
| 515 | create_file(gp_cost_filename, content) |
---|
| 516 | |
---|
[706] | 517 | # Creating the data file |
---|
[779] | 518 | # Values are normalized by application, w.r.t. the number of requests for a given number of procs |
---|
| 519 | content = "#" |
---|
| 520 | for cost_metric in direct_cost_metrics: |
---|
| 521 | content += cost_metric |
---|
| 522 | content += ' ' + ' ' * (15 - len(cost_metric)) |
---|
| 523 | for cost_metric in coherence_cost_metrics: |
---|
| 524 | content += cost_metric |
---|
| 525 | content += ' ' + ' ' * (15 - len(cost_metric)) |
---|
[706] | 526 | content += "\n" |
---|
| 527 | for app in apps: |
---|
[779] | 528 | if app != apps[0]: |
---|
| 529 | for i in range(0, len(direct_cost_metrics) + len(coherence_cost_metrics)): |
---|
| 530 | content += "%-15f" % 0.0 |
---|
| 531 | content += "\n" |
---|
[706] | 532 | for i in nb_procs: |
---|
[779] | 533 | if i > 4: |
---|
| 534 | for cost_metric in direct_cost_metrics: |
---|
| 535 | content += "%-15f" % (float(metrics_val[prot][app][i][cost_metric]) / metrics_val[prot][app][i]['direct_cost']) |
---|
| 536 | for cost_metric in coherence_cost_metrics: |
---|
| 537 | content += "%-15f" % 0.0 |
---|
| 538 | content += "\n" |
---|
| 539 | for cost_metric in direct_cost_metrics: |
---|
| 540 | content += "%-15f" % 0.0 |
---|
| 541 | for cost_metric in coherence_cost_metrics: |
---|
| 542 | content += "%-15f" % (float(metrics_val[prot][app][i][cost_metric]) / metrics_val[prot][app][i]['direct_cost']) |
---|
| 543 | content += "\n" |
---|
| 544 | if i != nb_procs[-1]: |
---|
| 545 | for j in range(0, len(direct_cost_metrics) + len(coherence_cost_metrics)): |
---|
| 546 | content += "%-15f" % 0.0 |
---|
| 547 | content += "\n" |
---|
[706] | 548 | |
---|
[779] | 549 | create_file(data_cost_filename, content) |
---|
[706] | 550 | # Calling gnuplot |
---|
[779] | 551 | print "gnuplot", gp_cost_filename |
---|
| 552 | subprocess.call([ 'gnuplot', gp_cost_filename ]) |
---|
[706] | 553 | |
---|
| 554 | |
---|
[779] | 555 | ################################################################################# |
---|
| 556 | ### Joint Graphs to several architectures ### |
---|
| 557 | ################################################################################# |
---|
[706] | 558 | |
---|
[779] | 559 | if len(joint_protocols) == 0: |
---|
| 560 | sys.exit() |
---|
[706] | 561 | |
---|
[779] | 562 | ################################################################################# |
---|
| 563 | ### Graph 7: Comparison of Speedups (normalized w.r.t. 1 proc on first arch) ### |
---|
| 564 | ################################################################################# |
---|
[706] | 565 | |
---|
| 566 | |
---|
[779] | 567 | for app in apps: |
---|
[706] | 568 | |
---|
[779] | 569 | data_speedup_name = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_speedup.dat') |
---|
| 570 | gp_speedup_name = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_speedup.gp') |
---|
| 571 | |
---|
| 572 | # Creating data file |
---|
| 573 | width = 15 |
---|
| 574 | content = "#nb_procs" |
---|
| 575 | nb_spaces = width - len(content) |
---|
| 576 | content += nb_spaces * ' ' |
---|
| 577 | content += "speedup\n" |
---|
[706] | 578 | |
---|
| 579 | for i in nb_procs: |
---|
[779] | 580 | content += "%-15d " % i |
---|
| 581 | for prot in joint_protocols: |
---|
| 582 | val = exec_time[prot][app][i] |
---|
| 583 | content += "%-15f " % (exec_time[joint_protocols[0]][app][1] / float(val)) |
---|
[706] | 584 | content += "\n" |
---|
| 585 | |
---|
[779] | 586 | create_file(data_speedup_name, content) |
---|
| 587 | |
---|
| 588 | # Creating the gp file |
---|
| 589 | template_file = open(speedup_tmpl, 'r') |
---|
| 590 | template = template_file.read() |
---|
| 591 | |
---|
| 592 | plot_str = "" |
---|
| 593 | col = 2 |
---|
| 594 | for prot in joint_protocols: |
---|
| 595 | if prot != joint_protocols[0]: |
---|
| 596 | plot_str += ", \\\n " |
---|
| 597 | plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2]) + m_prot_name[prot] + "\" with linespoint" |
---|
| 598 | col += 1 |
---|
| 599 | |
---|
| 600 | gp_commands = template % dict(appli = m_app_name[app] + " Normalized w.r.t. " + m_prot_name[joint_protocols[0]] + " on 1 Processor", nb_procs = nb_procs[-1] + 1, plot_str = plot_str, svg_name = os.path.join(graph_dir, 'joint_' + app + '_speedup')) |
---|
| 601 | |
---|
| 602 | create_file(gp_speedup_name, gp_commands) |
---|
| 603 | |
---|
| 604 | # Calling gnuplot |
---|
| 605 | print "gnuplot", gp_speedup_name |
---|
| 606 | subprocess.call([ 'gnuplot', gp_speedup_name ]) |
---|
[706] | 607 | |
---|
| 608 | |
---|
| 609 | ################################################################################# |
---|
[779] | 610 | ### Graph 8 : Joint Stacked histogram with coherence cost and r/w cost ### |
---|
[706] | 611 | ################################################################################# |
---|
| 612 | |
---|
[779] | 613 | # The following section creates pairs of stacked histograms for each arch for each number of proc for each app, normalized by (app x number of procs) (with first arch, R/W cost, first of the 2*num_arch histo). It is close to Graph 6 |
---|
[706] | 614 | |
---|
[779] | 615 | data_cost_filename = os.path.join(scripts_path, gen_dir, 'joint_relative_cost.dat') |
---|
| 616 | gp_cost_filename = os.path.join(scripts_path, gen_dir, 'joint_relative_cost.gp') |
---|
| 617 | |
---|
[836] | 618 | direct_cost_metrics = [ 'read_cost', 'write_cost', 'getm_cost' ] |
---|
| 619 | coherence_cost_metrics = ['update_cost', 'm_inv_cost', 'broadcast_cost', 'inval_ro_cost', 'cleanup_cost', 'cleanup_d_cost' ] |
---|
| 620 | |
---|
[706] | 621 | # Creating the gp file |
---|
| 622 | template_file = open(stacked_tmpl, 'r') |
---|
| 623 | template = template_file.read() |
---|
[779] | 624 | |
---|
[706] | 625 | xtics_str = "(" |
---|
| 626 | first = True |
---|
[779] | 627 | xpos = 1 # successive x position of the center of the first bar in a application |
---|
[706] | 628 | app_labels = "" |
---|
[779] | 629 | prot_labels = "" |
---|
[706] | 630 | for num_appli in range(0, len(apps)): |
---|
| 631 | first_proc = True |
---|
| 632 | for i in nb_procs: |
---|
| 633 | if i > 4: |
---|
[779] | 634 | x = 0 # local var for computing position of protocol names |
---|
| 635 | for prot in joint_protocols: |
---|
| 636 | prot_labels += "set label \"%s\" at first %f, character 2 center font \"Times,10\"\n" % (m_prot_name[prot], float((xpos - 0.5)) + x) # -0.5 instead of +0.5, don't know why... (bug gnuplot?) |
---|
| 637 | x += 2 |
---|
| 638 | |
---|
[706] | 639 | if not first: |
---|
| 640 | xtics_str += ", " |
---|
| 641 | first = False |
---|
| 642 | if first_proc: |
---|
| 643 | first_proc = False |
---|
| 644 | xpos_first = xpos |
---|
[779] | 645 | xtics_str += "\"%d\" %f -1" % (i, float(xpos - 0.5 + len(joint_protocols))) |
---|
[706] | 646 | xpos_last = xpos |
---|
[779] | 647 | xpos += 1 + len(joint_protocols) * 2 |
---|
[706] | 648 | app_name_xpos = float((xpos_first + xpos_last)) / 2 |
---|
[779] | 649 | app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos) |
---|
[706] | 650 | xpos += 1 |
---|
| 651 | xtics_str += ")" |
---|
| 652 | |
---|
| 653 | plot_str = "newhistogram \"\"" |
---|
| 654 | n = 1 |
---|
| 655 | for cost_metric in direct_cost_metrics + coherence_cost_metrics: |
---|
| 656 | plot_str += ", \\\n " + "'" + data_cost_filename + "'" + " using " + str(n) + " lc rgb " + colors[n] + " title \"" + m_metric_name[cost_metric] + "\"" |
---|
| 657 | n += 1 |
---|
| 658 | |
---|
[779] | 659 | ylabel_str = "Coherence Cost and Direct Requests Cost,\\nNormalized per Application for each Number of Processors" |
---|
| 660 | content = template % dict(svg_name = os.path.join(graph_dir, 'joint_rel_cost'), xtics_str = xtics_str, plot_str = plot_str, ylabel_str = ylabel_str, app_labels = app_labels, prot_labels = prot_labels) |
---|
[706] | 661 | |
---|
| 662 | create_file(gp_cost_filename, content) |
---|
| 663 | |
---|
| 664 | # Creating the data file |
---|
| 665 | # Values are normalized by application, w.r.t. the number of requests for a given number of procs |
---|
| 666 | content = "#" |
---|
| 667 | for cost_metric in direct_cost_metrics: |
---|
| 668 | content += cost_metric |
---|
| 669 | content += ' ' + ' ' * (15 - len(cost_metric)) |
---|
| 670 | for cost_metric in coherence_cost_metrics: |
---|
| 671 | content += cost_metric |
---|
| 672 | content += ' ' + ' ' * (15 - len(cost_metric)) |
---|
| 673 | content += "\n" |
---|
| 674 | for app in apps: |
---|
| 675 | if app != apps[0]: |
---|
[779] | 676 | for j in range(0, len(direct_cost_metrics) + len(coherence_cost_metrics)): |
---|
[706] | 677 | content += "%-15f" % 0.0 |
---|
| 678 | content += "\n" |
---|
| 679 | for i in nb_procs: |
---|
| 680 | if i > 4: |
---|
[779] | 681 | for prot in joint_protocols: |
---|
| 682 | for cost_metric in direct_cost_metrics: |
---|
| 683 | content += "%-15f" % (float(metrics_val[prot][app][i][cost_metric]) / metrics_val[joint_protocols[0]][app][i]['direct_cost']) |
---|
| 684 | for cost_metric in coherence_cost_metrics: |
---|
| 685 | content += "%-15f" % 0.0 |
---|
| 686 | content += "\n" |
---|
| 687 | for cost_metric in direct_cost_metrics: |
---|
| 688 | content += "%-15f" % 0.0 |
---|
| 689 | for cost_metric in coherence_cost_metrics: |
---|
| 690 | content += "%-15f" % (float(metrics_val[prot][app][i][cost_metric]) / metrics_val[joint_protocols[0]][app][i]['direct_cost']) |
---|
| 691 | content += "\n" |
---|
| 692 | if i != nb_procs[-1]: |
---|
| 693 | for j in range(0, len(direct_cost_metrics) + len(coherence_cost_metrics)): |
---|
| 694 | content += "%-15f" % 0.0 |
---|
| 695 | content += "\n" |
---|
[706] | 696 | |
---|
| 697 | create_file(data_cost_filename, content) |
---|
| 698 | # Calling gnuplot |
---|
| 699 | print "gnuplot", gp_cost_filename |
---|
| 700 | subprocess.call([ 'gnuplot', gp_cost_filename ]) |
---|
| 701 | |
---|
| 702 | |
---|
[779] | 703 | |
---|
[836] | 704 | ################################################################################# |
---|
| 705 | ### Graph 9 : ### |
---|
| 706 | ################################################################################# |
---|
[779] | 707 | |
---|
| 708 | |
---|
[836] | 709 | data_metric_filename = os.path.join(scripts_path, gen_dir, 'single_metric.dat') |
---|
| 710 | gp_metric_filename = os.path.join(scripts_path, gen_dir, 'single_metric.gp') |
---|
| 711 | |
---|
| 712 | metric = 'total_write' |
---|
| 713 | |
---|
| 714 | # Creating the gp file |
---|
| 715 | template_file = open(stacked_tmpl, 'r') |
---|
| 716 | template = template_file.read() |
---|
| 717 | |
---|
| 718 | xtics_str = "(" |
---|
| 719 | first = True |
---|
| 720 | xpos = 0 # successive x position of the center of the first bar in a application |
---|
| 721 | app_labels = "" |
---|
| 722 | prot_labels = "" |
---|
| 723 | for num_appli in range(0, len(apps)): |
---|
| 724 | first_proc = True |
---|
| 725 | for i in nb_procs: |
---|
| 726 | x = 0 # local var for computing position of protocol names |
---|
| 727 | #for prot in joint_protocols: |
---|
| 728 | #prot_labels += "set label \"%s\" at first %f, character 2 center font \"Times,10\"\n" % (m_prot_name[prot], float((xpos - 0.5)) + x) # -0.5 instead of +0.5, don't know why... (bug gnuplot?) |
---|
| 729 | #x += 1 |
---|
| 730 | |
---|
| 731 | if not first: |
---|
| 732 | xtics_str += ", " |
---|
| 733 | first = False |
---|
| 734 | if first_proc: |
---|
| 735 | first_proc = False |
---|
| 736 | xpos_first = xpos |
---|
| 737 | xtics_str += "\"%d\" %f -1" % (i, float(xpos - 0.5 + len(joint_protocols))) |
---|
| 738 | xpos_last = xpos |
---|
| 739 | xpos += 1 + len(joint_protocols) |
---|
| 740 | app_name_xpos = float((xpos_first + xpos_last)) / 2 |
---|
| 741 | app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos) |
---|
| 742 | xpos += 1 |
---|
| 743 | xtics_str += ")" |
---|
| 744 | |
---|
| 745 | n = 1 |
---|
| 746 | plot_str = "newhistogram \"\"" |
---|
| 747 | for prot in joint_protocols: |
---|
| 748 | plot_str += ", \\\n " + "'" + data_metric_filename + "'" + " using " + str(n) + " lc rgb " + colors[n] + " title \"" + m_metric_name[metric] + " for " + m_prot_name[prot] + "\"" |
---|
| 749 | n += 1 |
---|
| 750 | |
---|
| 751 | ylabel_str = "%(m)s" % dict(m = m_metric_name[metric]) |
---|
| 752 | content = template % dict(svg_name = os.path.join(graph_dir, 'single_metric'), xtics_str = xtics_str, plot_str = plot_str, ylabel_str = ylabel_str, app_labels = app_labels, prot_labels = prot_labels) |
---|
| 753 | |
---|
| 754 | create_file(gp_metric_filename, content) |
---|
| 755 | |
---|
| 756 | # Creating the data file |
---|
| 757 | content = "#" + metric |
---|
| 758 | content += "\n" |
---|
| 759 | for app in apps: |
---|
| 760 | if app != apps[0]: |
---|
| 761 | for prot in joint_protocols: |
---|
| 762 | for p in joint_protocols: |
---|
| 763 | content += "%-15f " % 0.0 |
---|
| 764 | content += "\n" |
---|
| 765 | for i in nb_procs: |
---|
| 766 | for prot in joint_protocols: |
---|
| 767 | for p in joint_protocols: |
---|
| 768 | if p != prot: |
---|
| 769 | content += "%-15f " % 0 |
---|
| 770 | else: |
---|
| 771 | content += "%-15f " % (float(metrics_val[prot][app][i][metric])) |
---|
| 772 | content += "\n" |
---|
| 773 | if i != nb_procs[-1]: |
---|
| 774 | for p in joint_protocols: |
---|
| 775 | content += "%-15f " % 0.0 |
---|
| 776 | content += "\n" |
---|
| 777 | |
---|
| 778 | create_file(data_metric_filename, content) |
---|
| 779 | # Calling gnuplot |
---|
| 780 | print "gnuplot", gp_metric_filename |
---|
| 781 | subprocess.call([ 'gnuplot', gp_metric_filename ]) |
---|
| 782 | |
---|
| 783 | |
---|
| 784 | |
---|
| 785 | |
---|