Ignore:
Timestamp:
Feb 16, 2017, 3:51:52 PM (7 years ago)
Author:
meunier
Message:
  • Update of tsar_xbar_cluster (scripts and openmp support)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/platforms/tsar_generic_xbar/scripts/create_graphs.py

    r1012 r1048  
    77
    88
     9apps = [ 'blackscholes', 'filt_ga', 'fft_ga', 'histo-opt', 'kmeans-opt', 'linear_regression', 'lu', 'mandel', 'pca-opt', 'radix_ga', 'string_match' ]
     10#apps = [ 'blackscholes', 'fft_ga', 'filt_ga', 'histo-opt', 'kmeans-opt', 'linear_regression', 'lu', 'mandel', 'pca-opt', 'radix_ga' ]
    911#apps = [ 'histo-opt', 'mandel', 'filt_ga', 'radix_ga', 'fft_ga', 'pca-opt', 'fft', 'radix', 'filter', 'kmeans-opt' ]
    10 apps = [ 'fft_ga', 'filt_ga', 'lu', 'radix_ga', 'histo-opt', 'mandel', 'pca-opt', 'kmeans-opt' ]
    1112#apps = [ 'histogram', 'mandel', 'filter', 'fft', 'fft_ga', 'filt_ga', 'pca', 'lu' ]  # radix radix_ga kmeans
    12 #apps = [ 'histo-opt', 'histogram2', 'histo-opt2' ]
    13 #nb_procs = [ 1, 4, 8, 16, 32, 64, 128, 256 ]
     13#apps = [ 'fal_sh_2' ]
    1414nb_procs = [ 1, 4, 8, 16, 32, 64, 128, 256 ]
    15 single_protocols = ['dhccp', 'hmesi']
    16 joint_protocols = ['dhccp', 'hmesi']
     15#nb_procs = [ 256 ]
     16single_protocols = ['dhccp', 'th0', 'hmesi', 'wtidl']
     17joint_protocols = ['dhccp', 'th0', 'hmesi', 'wtidl' ]
    1718#joint_protocols = []
    1819
     
    3132log_term_name = '_term_'
    3233
    33 coherence_tmpl = os.path.join(scripts_path, template_dir, 'coherence_template.gp') # 1 graph per appli
    34 speedup_tmpl   = os.path.join(scripts_path, template_dir, 'speedup_template.gp')
    35 metric_tmpl    = os.path.join(scripts_path, template_dir, 'metric_template.gp') # 1 graph per metric
    36 stacked_tmpl   = os.path.join(scripts_path, template_dir, 'stacked_template.gp')
     34coherence_tmpl     = os.path.join(scripts_path, template_dir, 'coherence_template.gp') # 1 graph per appli
     35speedup_tmpl       = os.path.join(scripts_path, template_dir, 'speedup_template.gp')
     36metric_tmpl        = os.path.join(scripts_path, template_dir, 'metric_template.gp') # 1 graph per metric
     37stacked_tmpl       = os.path.join(scripts_path, template_dir, 'stacked_template.gp')
     38cst_exec_time_tmpl = os.path.join(scripts_path, template_dir, 'cst_exec_time_template.gp')
    3739
    3840
     
    140142         metrics_val[prot][app][i]['direct_cost']     = metrics_val[prot][app][i]['read_cost']       + metrics_val[prot][app][i]['write_cost']
    141143         metrics_val[prot][app][i]['broadcast_cost']  = metrics_val[prot][app][i]['broadcast'] * 2 * (x * y - 1)
    142          metrics_val[prot][app][i]['coherence_cost']  = metrics_val[prot][app][i]['broadcast_cost']  + metrics_val[prot][app][i]['m_inv_cost'] + metrics_val[prot][app][i]['update_cost']
     144         #metrics_val[prot][app][i]['coherence_cost']  = metrics_val[prot][app][i]['broadcast_cost']  + metrics_val[prot][app][i]['m_inv_cost'] + metrics_val[prot][app][i]['update_cost']
     145         metrics_val[prot][app][i]['coherence_cost']  = metrics_val[prot][app][i]['broadcast_cost']  + metrics_val[prot][app][i]['m_inv_cost'] + metrics_val[prot][app][i]['update_cost'] + metrics_val[prot][app][i]['cleanup_cost'] + metrics_val[prot][app][i]['cleanup_d_cost'] + metrics_val[prot][app][i]['inval_ro_cost']
    143146         if metrics_val[prot][app][i]['broadcast'] < metrics_val[prot][app][i]['write_broadcast']:
    144147            # test to patch a bug in mem_cache
     
    159162subprocess.call([ 'mkdir', '-p', os.path.join(scripts_path, graph_dir) ])
    160163
    161 ############################################################
    162 ### Graph 1 : Coherence traffic Cost per application     ###
    163 ############################################################
    164 
    165 for prot in single_protocols:
    166    for app in apps:
    167       data_coherence_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_coherence.dat')
    168       gp_coherence_name   = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_coherence.gp')
    169    
    170       # Creating the data file
    171       width = 15
    172       content = ""
    173      
    174       for metric in [ '#nb_procs' ] + grouped_metrics:
    175          content += metric + " "
    176          nb_spaces = width - len(metric)
    177          content += nb_spaces * ' '
    178       content += "\n"
    179    
    180       for i in nb_procs:
    181          content += "%-15d " % i
    182          for metric in grouped_metrics:
    183             val = float(metrics_val[prot][app][i][metric]) / exec_time[prot][app][i] * 1000
    184             content += "%-15f " % val
    185          content += "\n"
    186      
    187       create_file(data_coherence_name, content)
    188    
    189       # Creating the gp file
    190       template_file = open(coherence_tmpl, 'r')
    191       template = template_file.read()
    192      
    193       plot_str = ""
    194       col = 2
    195       for metric in grouped_metrics:
    196          if metric != grouped_metrics[0]:
    197             plot_str += ", \\\n    "
    198          plot_str += "\"" + data_coherence_name + "\" using ($1):($" + str(col) + ") lc rgb " + colors[col - 2] + " title \"" + m_metric_name[metric] + "\" with linespoint"
    199          col += 1
    200       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'))
    201      
    202       create_file(gp_coherence_name, gp_commands)
    203      
    204       # Calling gnuplot
    205       print "gnuplot", gp_coherence_name
    206       subprocess.call([ 'gnuplot', gp_coherence_name ])
    207 
    208 
    209 ############################################################
    210 ### Graph 2 : Speedup per Application                    ###
    211 ############################################################
    212 
    213 for prot in single_protocols:
    214    for app in apps:
    215    
    216       data_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_speedup.dat')
    217       gp_speedup_name   = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_speedup.gp')
    218      
    219       # Creating data file
    220       width = 15
    221       content = "#nb_procs"
    222       nb_spaces = width - len(content)
    223       content += nb_spaces * ' '
    224       content += "speedup\n"
    225    
    226       for i in nb_procs:
    227          content += "%-15d " % i
    228          val = exec_time[prot][app][i]
    229          content += "%-15f\n" % (exec_time[prot][app][1] / float(val))
    230    
    231       plot_str = "\"" + data_speedup_name + "\" using ($1):($2) lc rgb \"#654387\" title \"Speedup\" with linespoint"
    232      
    233       create_file(data_speedup_name, content)
    234      
    235       # Creating the gp file
    236       template_file = open(speedup_tmpl, 'r')
    237       template = template_file.read()
    238      
    239       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'))
    240      
    241       create_file(gp_speedup_name, gp_commands)
    242      
    243       # Calling gnuplot
    244       print "gnuplot", gp_speedup_name
    245       subprocess.call([ 'gnuplot', gp_speedup_name ])
    246 
    247 
    248 ############################################################
    249 ### Graph 3 : All speedups on the same Graph             ###
    250 ############################################################
    251 
    252 for prot in single_protocols:
    253    # This graph uses the same template as the graph 2
    254    data_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_all_speedup.dat')
    255    gp_speedup_name   = os.path.join(scripts_path, gen_dir, prot + '_all_speedup.gp')
    256    
    257    # Creating data file
    258    width = 15
    259    content = "#nb_procs"
    260    nb_spaces = width - len(content)
    261    content += (nb_spaces + 1) * ' '
    262    for app in apps:
    263       content += app + " "
    264       content += (width - len(app)) * " "
    265    content += "\n"
    266    
    267    for i in nb_procs:
    268       content += "%-15d " % i
    269       for app in apps:
    270          val = exec_time[prot][app][i]
    271          content += "%-15f " % (exec_time[prot][app][1] / float(val))
    272       content += "\n"
    273    
    274    create_file(data_speedup_name, content)
    275    
    276    # Creating gp file
    277    template_file = open(speedup_tmpl, 'r')
    278    template = template_file.read()
    279    
    280    plot_str = ""
    281    col = 2
    282    for app in apps:
    283       if app != apps[0]:
    284          plot_str += ", \\\n     "
    285       plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2])  + m_app_name[app] + "\" with linespoint"
    286       col += 1
    287    
    288    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'))
    289      
    290    create_file(gp_speedup_name, gp_commands)
    291      
    292    # Calling gnuplot
    293    print "gnuplot", gp_speedup_name
    294    subprocess.call([ 'gnuplot', gp_speedup_name ])
    295 
    296 
    297 ############################################################
    298 ### Graph 4 : Graph per metric                           ###
    299 ############################################################
    300 
    301 # The following section creates the graphs grouped by measure (e.g. #broadcasts)
    302 # The template file cannot be easily created otherwise it would not be generic
    303 # in many ways. This is why it is mainly created here.
    304 # Graphs are created for metric in the "individual_metrics" list
    305 
    306 for prot in single_protocols:
    307    for metric in individual_metrics:
    308       data_metric_name = os.path.join(scripts_path, gen_dir, prot + '_' + metric + '.dat')
    309       gp_metric_name   = os.path.join(scripts_path, gen_dir, prot + '_' + metric + '.gp')
    310    
    311       # Creating the gp file
    312       # Setting xtics, i.e. number of procs for each application
    313       xtics_str = "("
    314       first = True
    315       xpos = 1
    316       app_labels = ""
    317       for num_appli in range(0, len(apps)):
    318          for i in nb_procs:
    319             if not first:
    320                xtics_str += ", "
    321             first = False
    322             if i == nb_procs[0]:
    323                xpos_first = xpos
    324             xtics_str += "\"%d\" %.1f" % (i, xpos)
    325             xpos_last = xpos
    326             xpos += 1.5
    327          xpos += 0.5
    328          app_name_xpos = float((xpos_first + xpos_last)) / 2
    329          app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
    330       xtics_str += ")"
    331    
    332       xmax_val = float(xpos - 1)
    333    
    334       # Writing the lines of "plot"
    335       plot_str = ""
    336       xpos = 0
    337       first = True
    338       column = 2
    339       for i in range(0, len(nb_procs)):
    340          if not first:
    341             plot_str += ", \\\n    "
    342          first = False
    343          plot_str += "\"%s\" using ($1+%.1f):($%d) lc rgb %s notitle with boxes" % (data_metric_name, xpos, column, colors[i])
    344          column += 1
    345          xpos += 1.5
    346    
    347       template_file = open(metric_tmpl, 'r')
    348       template = template_file.read()
    349    
    350       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))
    351    
    352       create_file(gp_metric_name, gp_commands)
    353      
    354       # Creating the data file
    355       width = 15
    356       content = "#x_pos"
    357       nb_spaces = width - len(content)
    358       content += nb_spaces * ' '
    359       for i in nb_procs:
    360          content += "%-15d" % i
    361       content += "\n"
    362    
    363       x_pos = 1
    364       for app in apps:
    365          # Computation of x_pos
    366          content += "%-15f" % x_pos
    367          x_pos += len(nb_procs) * 1.5 + 0.5
    368          for i in nb_procs:
    369             if m_metric_norm[metric] == "N":
    370                content += "%-15d" % (metrics_val[prot][app][i][metric])
    371             elif m_metric_norm[metric] == "P":
    372                content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / i)
    373             elif m_metric_norm[metric] == "C":
    374                content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / exec_time[prot][app][i] * 1000)
    375             elif m_metric_norm[metric] == "W":
    376                content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_write'])) # Number of writes
    377             elif m_metric_norm[metric] == "R":
    378                content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_read'])) # Number of reads
    379             elif m_metric_norm[metric] == "D":
    380                content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_direct'])) # Number of req.
    381             elif is_numeric(m_metric_norm[metric]):
    382                content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][int(m_metric_norm[metric])][metric]))
    383             else:
    384                assert(False)
    385    
    386          app_name = m_app_name[app]
    387          content += "#" + app_name + "\n"
    388      
    389       create_file(data_metric_name, content)
    390    
    391       # Calling gnuplot
    392       print "gnuplot", gp_metric_name
    393       subprocess.call([ 'gnuplot', gp_metric_name ])
    394 
    395 
    396 ############################################################
    397 ### Graph 5 : Stacked histogram with counters            ###
    398 ############################################################
    399 
    400 # The following section creates a stacked histogram containing
    401 # the metrics in the "stacked_metric" list
    402 # It is normalized per application w.r.t the values on 256 procs
    403 
    404 for prot in single_protocols:
    405    data_stacked_name = os.path.join(scripts_path, gen_dir, prot + '_stacked.dat')
    406    gp_stacked_name   = os.path.join(scripts_path, gen_dir, prot + '_stacked.gp')
    407    
    408    norm_factor_value = nb_procs[-1]
    409    
    410    # Creating the gp file
    411    template_file = open(stacked_tmpl, 'r')
    412    template = template_file.read()
    413    
    414    xtics_str = "("
    415    first = True
    416    xpos = 1
    417    app_labels = ""
    418    for num_appli in range(0, len(apps)):
    419       for i in nb_procs[1:len(nb_procs)]: # skipping values for 1 proc
    420          if not first:
    421             xtics_str += ", "
    422          first = False
    423          if i == nb_procs[1]:
    424             xpos_first = xpos
    425          xtics_str += "\"%d\" %d -1" % (i, xpos)
    426          xpos_last = xpos
    427          xpos += 1
    428       xpos += 1
    429       app_name_xpos = float((xpos_first + xpos_last)) / 2
    430       app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
    431    xtics_str += ")"
    432    
    433    plot_str = "newhistogram \"\""
    434    n = 1
    435    for stacked_metric in stacked_metrics:
    436       plot_str += ", \\\n    " + "'" + data_stacked_name + "'" + " using " + str(n) + " lc rgb " + colors[n] + " title \"" + m_metric_name[stacked_metric] + "\""
    437       n += 1
    438    
    439    ylabel_str = "Breakdown of Coherence Traffic Normalized w.r.t. \\nthe Values on %d Processors" % norm_factor_value
    440    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 = "")
    441    
    442    create_file(gp_stacked_name, content)
    443    
    444    # Creating the data file
    445    # Values are normalized by application, w.r.t. the number of requests for a given number of procs
    446    content = "#"
    447    for stacked_metric in stacked_metrics:
    448       content += stacked_metric
    449       content += ' ' + ' ' * (15 - len(stacked_metric))
    450    content += "\n"
    451    for app in apps:
    452       if app != apps[0]:
    453          for i in range(0, len(stacked_metrics)):
    454             content += "%-15f" % 0.0
    455          content += "\n"
    456       for i in nb_procs[1:len(nb_procs)]:
    457          for stacked_metric in stacked_metrics:
    458             metric_val = metrics_val[prot][app][norm_factor_value]['total_stacked'] # Normalisation
    459             if metric_val != 0:
    460                content += "%-15f" % (float(metrics_val[prot][app][i][stacked_metric]) / metric_val)
    461             else:
    462                content += "%-15f" % 0
    463          content += "\n"
    464    
    465    create_file(data_stacked_name, content)
    466    # Calling gnuplot
    467    print "gnuplot", gp_stacked_name
    468    subprocess.call([ 'gnuplot', gp_stacked_name ])
     164#############################################################
     165#### Graph 1 : Coherence traffic Cost per application     ###
     166#############################################################
     167#
     168#for prot in single_protocols:
     169#   for app in apps:
     170#      data_coherence_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_coherence.dat')
     171#      gp_coherence_name   = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_coherence.gp')
     172#   
     173#      # Creating the data file
     174#      width = 15
     175#      content = ""
     176#     
     177#      for metric in [ '#nb_procs' ] + grouped_metrics:
     178#         content += metric + " "
     179#         nb_spaces = width - len(metric)
     180#         content += nb_spaces * ' '
     181#      content += "\n"
     182#   
     183#      for i in nb_procs:
     184#         content += "%-15d " % i
     185#         for metric in grouped_metrics:
     186#            #print "app : %s - prot : %s - i : %d" % (app, prot, i)
     187#            val = float(metrics_val[prot][app][i][metric]) / exec_time[prot][app][i] * 1000
     188#            content += "%-15f " % val
     189#         content += "\n"
     190#     
     191#      create_file(data_coherence_name, content)
     192#   
     193#      # Creating the gp file
     194#      template_file = open(coherence_tmpl, 'r')
     195#      template = template_file.read()
     196#     
     197#      plot_str = ""
     198#      col = 2
     199#      for metric in grouped_metrics:
     200#         if metric != grouped_metrics[0]:
     201#            plot_str += ", \\\n    "
     202#         plot_str += "\"" + data_coherence_name + "\" using ($1):($" + str(col) + ") lc rgb " + colors[col - 2] + " title \"" + m_metric_name[metric] + "\" with linespoint"
     203#         col += 1
     204#      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'))
     205#     
     206#      create_file(gp_coherence_name, gp_commands)
     207#     
     208#      # Calling gnuplot
     209#      print "gnuplot", gp_coherence_name
     210#      subprocess.call([ 'gnuplot', gp_coherence_name ])
     211#
     212#
     213#############################################################
     214#### Graph 2 : Speedup per Application                    ###
     215#############################################################
     216#
     217#if 1 in nb_procs:
     218#   for prot in single_protocols:
     219#      for app in apps:
     220#   
     221#         data_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_speedup.dat')
     222#         gp_speedup_name   = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_speedup.gp')
     223#         
     224#         # Creating data file
     225#         width = 15
     226#         content = "#nb_procs"
     227#         nb_spaces = width - len(content)
     228#         content += nb_spaces * ' '
     229#         content += "speedup\n"
     230#   
     231#         for i in nb_procs:
     232#            content += "%-15d " % i
     233#            val = exec_time[prot][app][i]
     234#            content += "%-15f\n" % (exec_time[prot][app][1] / float(val))
     235#   
     236#         plot_str = "\"" + data_speedup_name + "\" using ($1):($2) lc rgb \"#654387\" title \"Speedup\" with linespoint"
     237#         
     238#         create_file(data_speedup_name, content)
     239#         
     240#         # Creating the gp file
     241#         template_file = open(speedup_tmpl, 'r')
     242#         template = template_file.read()
     243#         
     244#         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'))
     245#         
     246#         create_file(gp_speedup_name, gp_commands)
     247#         
     248#         # Calling gnuplot
     249#         print "gnuplot", gp_speedup_name
     250#         subprocess.call([ 'gnuplot', gp_speedup_name ])
     251#
     252#
     253#############################################################
     254#### Graph 3 : All speedups on the same Graph             ###
     255#############################################################
     256#
     257#if 1 in nb_procs:
     258#   for prot in single_protocols:
     259#      # This graph uses the same template as the graph 2
     260#      data_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_all_speedup.dat')
     261#      gp_speedup_name   = os.path.join(scripts_path, gen_dir, prot + '_all_speedup.gp')
     262#     
     263#      # Creating data file
     264#      width = 15
     265#      content = "#nb_procs"
     266#      nb_spaces = width - len(content)
     267#      content += (nb_spaces + 1) * ' '
     268#      for app in apps:
     269#         content += app + " "
     270#         content += (width - len(app)) * " "
     271#      content += "\n"
     272#     
     273#      for i in nb_procs:
     274#         content += "%-15d " % i
     275#         for app in apps:
     276#            val = exec_time[prot][app][i]
     277#            content += "%-15f " % (exec_time[prot][app][1] / float(val))
     278#         content += "\n"
     279#     
     280#      create_file(data_speedup_name, content)
     281#     
     282#      # Creating gp file
     283#      template_file = open(speedup_tmpl, 'r')
     284#      template = template_file.read()
     285#     
     286#      plot_str = ""
     287#      col = 2
     288#      for app in apps:
     289#         if app != apps[0]:
     290#            plot_str += ", \\\n     "
     291#         plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2])  + m_app_name[app] + "\" with linespoint"
     292#         col += 1
     293#     
     294#      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'))
     295#         
     296#      create_file(gp_speedup_name, gp_commands)
     297#         
     298#      # Calling gnuplot
     299#      print "gnuplot", gp_speedup_name
     300#      subprocess.call([ 'gnuplot', gp_speedup_name ])
     301#
     302#
     303#############################################################
     304#### Graph 4 : Graph per metric                           ###
     305#############################################################
     306#
     307## The following section creates the graphs grouped by measure (e.g. #broadcasts)
     308## The template file cannot be easily created otherwise it would not be generic
     309## in many ways. This is why it is mainly created here.
     310## Graphs are created for metric in the "individual_metrics" list
     311#
     312#for prot in single_protocols:
     313#   for metric in individual_metrics:
     314#      data_metric_name = os.path.join(scripts_path, gen_dir, prot + '_' + metric + '.dat')
     315#      gp_metric_name   = os.path.join(scripts_path, gen_dir, prot + '_' + metric + '.gp')
     316#   
     317#      # Creating the gp file
     318#      # Setting xtics, i.e. number of procs for each application
     319#      xtics_str = "("
     320#      first = True
     321#      xpos = 1
     322#      app_labels = ""
     323#      for num_appli in range(0, len(apps)):
     324#         for i in nb_procs:
     325#            if not first:
     326#               xtics_str += ", "
     327#            first = False
     328#            if i == nb_procs[0]:
     329#               xpos_first = xpos
     330#            xtics_str += "\"%d\" %.1f" % (i, xpos)
     331#            xpos_last = xpos
     332#            xpos += 1.5
     333#         xpos += 0.5
     334#         app_name_xpos = float((xpos_first + xpos_last)) / 2
     335#         app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
     336#      xtics_str += ")"
     337#   
     338#      xmax_val = float(xpos - 1)
     339#   
     340#      # Writing the lines of "plot"
     341#      plot_str = ""
     342#      xpos = 0
     343#      first = True
     344#      column = 2
     345#      for i in range(0, len(nb_procs)):
     346#         if not first:
     347#            plot_str += ", \\\n    "
     348#         first = False
     349#         plot_str += "\"%s\" using ($1+%.1f):($%d) lc rgb %s notitle with boxes" % (data_metric_name, xpos, column, colors[i])
     350#         column += 1
     351#         xpos += 1.5
     352#   
     353#      template_file = open(metric_tmpl, 'r')
     354#      template = template_file.read()
     355#   
     356#      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))
     357#   
     358#      create_file(gp_metric_name, gp_commands)
     359#     
     360#      # Creating the data file
     361#      width = 15
     362#      content = "#x_pos"
     363#      nb_spaces = width - len(content)
     364#      content += nb_spaces * ' '
     365#      for i in nb_procs:
     366#         content += "%-15d" % i
     367#      content += "\n"
     368#   
     369#      x_pos = 1
     370#      for app in apps:
     371#         # Computation of x_pos
     372#         content += "%-15f" % x_pos
     373#         x_pos += len(nb_procs) * 1.5 + 0.5
     374#         for i in nb_procs:
     375#            if m_metric_norm[metric] == "N":
     376#               content += "%-15d" % (metrics_val[prot][app][i][metric])
     377#            elif m_metric_norm[metric] == "P":
     378#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / i)
     379#            elif m_metric_norm[metric] == "C":
     380#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / exec_time[prot][app][i] * 1000)
     381#            elif m_metric_norm[metric] == "W":
     382#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_write'])) # Number of writes
     383#            elif m_metric_norm[metric] == "R":
     384#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_read'])) # Number of reads
     385#            elif m_metric_norm[metric] == "D":
     386#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_direct'])) # Number of req.
     387#            elif is_numeric(m_metric_norm[metric]):
     388#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][int(m_metric_norm[metric])][metric]))
     389#            else:
     390#               assert(False)
     391#   
     392#         app_name = m_app_name[app]
     393#         content += "#" + app_name + "\n"
     394#     
     395#      create_file(data_metric_name, content)
     396#   
     397#      # Calling gnuplot
     398#      print "gnuplot", gp_metric_name
     399#      subprocess.call([ 'gnuplot', gp_metric_name ])
     400#
     401#
     402#############################################################
     403#### Graph 5 : Stacked histogram with counters            ###
     404#############################################################
     405#
     406## The following section creates a stacked histogram containing
     407## the metrics in the "stacked_metric" list
     408## It is normalized per application w.r.t the values on 256 procs
     409#
     410#for prot in single_protocols:
     411#   data_stacked_name = os.path.join(scripts_path, gen_dir, prot + '_stacked.dat')
     412#   gp_stacked_name   = os.path.join(scripts_path, gen_dir, prot + '_stacked.gp')
     413#   
     414#   norm_factor_value = nb_procs[-1]
     415#   
     416#   # Creating the gp file
     417#   template_file = open(stacked_tmpl, 'r')
     418#   template = template_file.read()
     419#   
     420#   xtics_str = "("
     421#   first = True
     422#   xpos = 1
     423#   app_labels = ""
     424#   for num_appli in range(0, len(apps)):
     425#      for i in nb_procs[1:len(nb_procs)]: # skipping values for 1 proc
     426#         if not first:
     427#            xtics_str += ", "
     428#         first = False
     429#         if i == nb_procs[1]:
     430#            xpos_first = xpos
     431#         xtics_str += "\"%d\" %d -1" % (i, xpos)
     432#         xpos_last = xpos
     433#         xpos += 1
     434#      xpos += 1
     435#      app_name_xpos = float((xpos_first + xpos_last)) / 2
     436#      app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
     437#   xtics_str += ")"
     438#   
     439#   plot_str = "newhistogram \"\""
     440#   n = 1
     441#   for stacked_metric in stacked_metrics:
     442#      plot_str += ", \\\n    " + "'" + data_stacked_name + "'" + " using " + str(n) + " lc rgb " + colors[n] + " title \"" + m_metric_name[stacked_metric] + "\""
     443#      n += 1
     444#   
     445#   ylabel_str = "Breakdown of Coherence Traffic Normalized w.r.t. \\nthe Values on %d Processors" % norm_factor_value
     446#   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 = "")
     447#   
     448#   create_file(gp_stacked_name, content)
     449#   
     450#   # Creating the data file
     451#   # Values are normalized by application, w.r.t. the number of requests for a given number of procs
     452#   content = "#"
     453#   for stacked_metric in stacked_metrics:
     454#      content += stacked_metric
     455#      content += ' ' + ' ' * (15 - len(stacked_metric))
     456#   content += "\n"
     457#   for app in apps:
     458#      if app != apps[0]:
     459#         for i in range(0, len(stacked_metrics)):
     460#            content += "%-15f" % 0.0
     461#         content += "\n"
     462#      for i in nb_procs[1:len(nb_procs)]:
     463#         for stacked_metric in stacked_metrics:
     464#            metric_val = metrics_val[prot][app][norm_factor_value]['total_stacked'] # Normalisation
     465#            if metric_val != 0:
     466#               content += "%-15f" % (float(metrics_val[prot][app][i][stacked_metric]) / metric_val)
     467#            else:
     468#               content += "%-15f" % 0
     469#         content += "\n"
     470#   
     471#   create_file(data_stacked_name, content)
     472#   # Calling gnuplot
     473#   print "gnuplot", gp_stacked_name
     474#   subprocess.call([ 'gnuplot', gp_stacked_name ])
    469475
    470476
     
    508514            xpos += 3
    509515      app_name_xpos = float((xpos_first + xpos_last)) / 2
    510       app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
     516      app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,28\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
    511517      #xpos += 1
    512518   xtics_str += ")"
     
    518524      n += 1
    519525   
    520    ylabel_str = "Coherence Cost Compared to Direct Requests Cost,\\nNormalized per Application for each Number of Processors"
     526   ylabel_str = "Coherence Cost Vs. Direct Requests Cost,\\nNormalized w.r.t. Direct Requests Cost"
    521527   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 = "")
    522528   
     
    581587
    582588
    583 for app in apps:
    584 
    585    data_speedup_name = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_speedup.dat')
    586    gp_speedup_name   = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_speedup.gp')
    587    
    588    # Creating data file
    589    width = 15
    590    content = "#nb_procs"
    591    nb_spaces = width - len(content)
    592    content += nb_spaces * ' '
    593    content += "speedup\n"
    594 
    595    for i in nb_procs:
    596       content += "%-15d " % i
    597       for prot in joint_protocols:
    598          val = exec_time[prot][app][i]
    599          content += "%-15f " % (exec_time[joint_protocols[0]][app][1] / float(val))
    600       content += "\n"
    601 
    602    create_file(data_speedup_name, content)
    603    
    604    # Creating the gp file
    605    template_file = open(speedup_tmpl, 'r')
    606    template = template_file.read()
    607  
    608    plot_str = ""
    609    col = 2
    610    for prot in joint_protocols:
    611       if prot != joint_protocols[0]:
    612          plot_str += ", \\\n     "
    613       plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2])  + m_prot_name[prot] + "\" with linespoint"
    614       col += 1
    615  
    616    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'))
    617    
    618    create_file(gp_speedup_name, gp_commands)
    619    
    620    # Calling gnuplot
    621    print "gnuplot", gp_speedup_name
    622    subprocess.call([ 'gnuplot', gp_speedup_name ])
     589#if 1 in nb_procs:
     590#   for app in apps:
     591#   
     592#      data_speedup_name = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_speedup.dat')
     593#      gp_speedup_name   = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_speedup.gp')
     594#     
     595#      # Creating data file
     596#      width = 15
     597#      content = "#nb_procs"
     598#      nb_spaces = width - len(content)
     599#      content += nb_spaces * ' '
     600#      content += "speedup\n"
     601#   
     602#      for i in nb_procs:
     603#         content += "%-15d " % i
     604#         for prot in joint_protocols:
     605#            val = exec_time[prot][app][i]
     606#            content += "%-15f " % (exec_time[joint_protocols[0]][app][1] / float(val))
     607#         content += "\n"
     608#   
     609#      create_file(data_speedup_name, content)
     610#     
     611#      # Creating the gp file
     612#      template_file = open(speedup_tmpl, 'r')
     613#      template = template_file.read()
     614#     
     615#      plot_str = ""
     616#      col = 2
     617#      for prot in joint_protocols:
     618#         if prot != joint_protocols[0]:
     619#            plot_str += ", \\\n     "
     620#         plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2])  + m_prot_name[prot] + "\" with linespoint"
     621#         col += 1
     622#     
     623#      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'))
     624#     
     625#      create_file(gp_speedup_name, gp_commands)
     626#     
     627#      # Calling gnuplot
     628#      print "gnuplot", gp_speedup_name
     629#      subprocess.call([ 'gnuplot', gp_speedup_name ])
    623630
    624631
     
    638645template_file = open(stacked_tmpl, 'r')
    639646template = template_file.read()
    640   
     647 
    641648xtics_str = "("
    642649first = True
    643 xpos = 1 # successive x position of the center of the first bar in a application
     650barwidth = 1
     651xpos = 1 # successive x position of the center of the first bar in an application
    644652app_labels = ""
    645653prot_labels = ""
     
    650658         x = 0 # local var for computing position of protocol names
    651659         for prot in joint_protocols:
    652             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?)
     660            prot_labels += "set label \"%s\" at first %f, character 2 center font \"Times,10\" rotate by 45\n" % (m_prot_name[prot], float((xpos - 0.5)) + x - 1) # -0.5 instead of +0.5, don't know why... (bug gnuplot?)
    653661            x += 2
    654662
     
    660668            xpos_first = xpos
    661669         xtics_str += "\"%d\" %f -1" % (i, float(xpos - 0.5 + len(joint_protocols)))
     670         #xtics_str += "\"\" %f -1" % (float(xpos - 0.5 + len(joint_protocols))) # not to have proc number displayed
    662671         xpos_last = xpos
    663          xpos += 1 + len(joint_protocols) * 2
    664    app_name_xpos = float((xpos_first + xpos_last)) / 2
     672         xpos += 1 + len(joint_protocols) * 2 * barwidth
     673   app_name_xpos = float((xpos_first + xpos_last)) / 2 + 2
    665674   app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
    666    xpos += 1
     675   #xpos += 1
    667676xtics_str += ")"
    668677
     
    673682   n += 1
    674683
    675 ylabel_str = "Coherence Cost and Direct Requests Cost,\\nNormalized per Application for each Number of Processors"
     684ylabel_str = "Coherence Cost vs. Direct Requests Cost,\\nNormalized per Application for each Number of Processors"
    676685content = 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)
    677686
     
    800809
    801810
    802 
    803 
     811#########################################################################################################
     812### Graph 10: Normalized exec times with no log scale: when scalability is achieved by constant time  ###
     813#########################################################################################################
     814
     815
     816if 1 in nb_procs:
     817   for app in apps:
     818   
     819      data_speedup_name = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_cst_exec_time.dat')
     820      gp_speedup_name   = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_cst_exec_time.gp')
     821     
     822      # Creating data file
     823      width = 15
     824      content = "#nb_procs"
     825      nb_spaces = width - len(content)
     826      content += nb_spaces * ' '
     827      content += "norm_exec_time\n"
     828   
     829      for i in nb_procs:
     830         content += "%-15d " % i
     831         for prot in joint_protocols:
     832            val = exec_time[prot][app][i]
     833            content += "%-15f " % (float(val) / exec_time[joint_protocols[0]][app][1])
     834         content += "\n"
     835   
     836      create_file(data_speedup_name, content)
     837     
     838      # Creating the gp file
     839      template_file = open(cst_exec_time_tmpl, 'r')
     840      template = template_file.read()
     841     
     842      plot_str = ""
     843      col = 2
     844      for prot in joint_protocols:
     845         if prot != joint_protocols[0]:
     846            plot_str += ", \\\n     "
     847         plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2])  + m_prot_name[prot] + "\" with linespoint"
     848         col += 1
     849     
     850      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 + '_cst_exec_time'))
     851     
     852      create_file(gp_speedup_name, gp_commands)
     853     
     854      # Calling gnuplot
     855      print "gnuplot", gp_speedup_name
     856      subprocess.call([ 'gnuplot', gp_speedup_name ])
     857
     858
     859
Note: See TracChangeset for help on using the changeset viewer.