Index: trunk/platforms/tsar_generic_xbar/scripts/create_graphs.py
===================================================================
--- trunk/platforms/tsar_generic_xbar/scripts/create_graphs.py	(revision 1012)
+++ trunk/platforms/tsar_generic_xbar/scripts/create_graphs.py	(revision 1048)
@@ -7,12 +7,13 @@
 
 
+apps = [ 'blackscholes', 'filt_ga', 'fft_ga', 'histo-opt', 'kmeans-opt', 'linear_regression', 'lu', 'mandel', 'pca-opt', 'radix_ga', 'string_match' ]
+#apps = [ 'blackscholes', 'fft_ga', 'filt_ga', 'histo-opt', 'kmeans-opt', 'linear_regression', 'lu', 'mandel', 'pca-opt', 'radix_ga' ]
 #apps = [ 'histo-opt', 'mandel', 'filt_ga', 'radix_ga', 'fft_ga', 'pca-opt', 'fft', 'radix', 'filter', 'kmeans-opt' ]
-apps = [ 'fft_ga', 'filt_ga', 'lu', 'radix_ga', 'histo-opt', 'mandel', 'pca-opt', 'kmeans-opt' ]
 #apps = [ 'histogram', 'mandel', 'filter', 'fft', 'fft_ga', 'filt_ga', 'pca', 'lu' ]  # radix radix_ga kmeans
-#apps = [ 'histo-opt', 'histogram2', 'histo-opt2' ]
-#nb_procs = [ 1, 4, 8, 16, 32, 64, 128, 256 ]
+#apps = [ 'fal_sh_2' ]
 nb_procs = [ 1, 4, 8, 16, 32, 64, 128, 256 ]
-single_protocols = ['dhccp', 'hmesi']
-joint_protocols = ['dhccp', 'hmesi']
+#nb_procs = [ 256 ]
+single_protocols = ['dhccp', 'th0', 'hmesi', 'wtidl']
+joint_protocols = ['dhccp', 'th0', 'hmesi', 'wtidl' ]
 #joint_protocols = []
 
@@ -31,8 +32,9 @@
 log_term_name = '_term_'
 
-coherence_tmpl = os.path.join(scripts_path, template_dir, 'coherence_template.gp') # 1 graph per appli
-speedup_tmpl   = os.path.join(scripts_path, template_dir, 'speedup_template.gp')
-metric_tmpl    = os.path.join(scripts_path, template_dir, 'metric_template.gp') # 1 graph per metric
-stacked_tmpl   = os.path.join(scripts_path, template_dir, 'stacked_template.gp')
+coherence_tmpl     = os.path.join(scripts_path, template_dir, 'coherence_template.gp') # 1 graph per appli
+speedup_tmpl       = os.path.join(scripts_path, template_dir, 'speedup_template.gp')
+metric_tmpl        = os.path.join(scripts_path, template_dir, 'metric_template.gp') # 1 graph per metric
+stacked_tmpl       = os.path.join(scripts_path, template_dir, 'stacked_template.gp')
+cst_exec_time_tmpl = os.path.join(scripts_path, template_dir, 'cst_exec_time_template.gp')
 
 
@@ -140,5 +142,6 @@
          metrics_val[prot][app][i]['direct_cost']     = metrics_val[prot][app][i]['read_cost']       + metrics_val[prot][app][i]['write_cost']
          metrics_val[prot][app][i]['broadcast_cost']  = metrics_val[prot][app][i]['broadcast'] * 2 * (x * y - 1)
-         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]['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]['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']
          if metrics_val[prot][app][i]['broadcast'] < metrics_val[prot][app][i]['write_broadcast']:
             # test to patch a bug in mem_cache
@@ -159,312 +162,315 @@
 subprocess.call([ 'mkdir', '-p', os.path.join(scripts_path, graph_dir) ])
 
-############################################################
-### Graph 1 : Coherence traffic Cost per application     ###
-############################################################
-
-for prot in single_protocols:
-   for app in apps:
-      data_coherence_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_coherence.dat')
-      gp_coherence_name   = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_coherence.gp')
-   
-      # Creating the data file
-      width = 15
-      content = ""
-      
-      for metric in [ '#nb_procs' ] + grouped_metrics:
-         content += metric + " "
-         nb_spaces = width - len(metric)
-         content += nb_spaces * ' '
-      content += "\n"
-   
-      for i in nb_procs:
-         content += "%-15d " % i
-         for metric in grouped_metrics:
-            val = float(metrics_val[prot][app][i][metric]) / exec_time[prot][app][i] * 1000
-            content += "%-15f " % val
-         content += "\n"
-      
-      create_file(data_coherence_name, content)
-   
-      # Creating the gp file
-      template_file = open(coherence_tmpl, 'r')
-      template = template_file.read()
-      
-      plot_str = ""
-      col = 2
-      for metric in grouped_metrics:
-         if metric != grouped_metrics[0]:
-            plot_str += ", \\\n    "
-         plot_str += "\"" + data_coherence_name + "\" using ($1):($" + str(col) + ") lc rgb " + colors[col - 2] + " title \"" + m_metric_name[metric] + "\" with linespoint"
-         col += 1
-      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'))
-      
-      create_file(gp_coherence_name, gp_commands)
-      
-      # Calling gnuplot
-      print "gnuplot", gp_coherence_name
-      subprocess.call([ 'gnuplot', gp_coherence_name ])
-
-
-############################################################
-### Graph 2 : Speedup per Application                    ###
-############################################################
-
-for prot in single_protocols:
-   for app in apps:
-   
-      data_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_speedup.dat')
-      gp_speedup_name   = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_speedup.gp')
-      
-      # Creating data file
-      width = 15
-      content = "#nb_procs"
-      nb_spaces = width - len(content)
-      content += nb_spaces * ' '
-      content += "speedup\n"
-   
-      for i in nb_procs:
-         content += "%-15d " % i
-         val = exec_time[prot][app][i]
-         content += "%-15f\n" % (exec_time[prot][app][1] / float(val))
-   
-      plot_str = "\"" + data_speedup_name + "\" using ($1):($2) lc rgb \"#654387\" title \"Speedup\" with linespoint"
-      
-      create_file(data_speedup_name, content)
-      
-      # Creating the gp file
-      template_file = open(speedup_tmpl, 'r')
-      template = template_file.read()
-      
-      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'))
-      
-      create_file(gp_speedup_name, gp_commands)
-      
-      # Calling gnuplot
-      print "gnuplot", gp_speedup_name
-      subprocess.call([ 'gnuplot', gp_speedup_name ])
-
-
-############################################################
-### Graph 3 : All speedups on the same Graph             ###
-############################################################
-
-for prot in single_protocols:
-   # This graph uses the same template as the graph 2
-   data_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_all_speedup.dat')
-   gp_speedup_name   = os.path.join(scripts_path, gen_dir, prot + '_all_speedup.gp')
-   
-   # Creating data file
-   width = 15
-   content = "#nb_procs"
-   nb_spaces = width - len(content)
-   content += (nb_spaces + 1) * ' '
-   for app in apps:
-      content += app + " "
-      content += (width - len(app)) * " "
-   content += "\n"
-   
-   for i in nb_procs:
-      content += "%-15d " % i
-      for app in apps:
-         val = exec_time[prot][app][i]
-         content += "%-15f " % (exec_time[prot][app][1] / float(val))
-      content += "\n"
-   
-   create_file(data_speedup_name, content)
-   
-   # Creating gp file
-   template_file = open(speedup_tmpl, 'r')
-   template = template_file.read()
-   
-   plot_str = ""
-   col = 2
-   for app in apps:
-      if app != apps[0]:
-         plot_str += ", \\\n     "
-      plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2])  + m_app_name[app] + "\" with linespoint"
-      col += 1
-   
-   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'))
-      
-   create_file(gp_speedup_name, gp_commands)
-      
-   # Calling gnuplot
-   print "gnuplot", gp_speedup_name
-   subprocess.call([ 'gnuplot', gp_speedup_name ])
-
-
-############################################################
-### Graph 4 : Graph per metric                           ###
-############################################################
-
-# The following section creates the graphs grouped by measure (e.g. #broadcasts)
-# The template file cannot be easily created otherwise it would not be generic
-# in many ways. This is why it is mainly created here.
-# Graphs are created for metric in the "individual_metrics" list
-
-for prot in single_protocols:
-   for metric in individual_metrics:
-      data_metric_name = os.path.join(scripts_path, gen_dir, prot + '_' + metric + '.dat')
-      gp_metric_name   = os.path.join(scripts_path, gen_dir, prot + '_' + metric + '.gp')
-   
-      # Creating the gp file
-      # Setting xtics, i.e. number of procs for each application
-      xtics_str = "("
-      first = True
-      xpos = 1
-      app_labels = ""
-      for num_appli in range(0, len(apps)):
-         for i in nb_procs:
-            if not first:
-               xtics_str += ", "
-            first = False
-            if i == nb_procs[0]:
-               xpos_first = xpos
-            xtics_str += "\"%d\" %.1f" % (i, xpos)
-            xpos_last = xpos
-            xpos += 1.5
-         xpos += 0.5
-         app_name_xpos = float((xpos_first + xpos_last)) / 2
-         app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
-      xtics_str += ")"
-   
-      xmax_val = float(xpos - 1)
-   
-      # Writing the lines of "plot"
-      plot_str = ""
-      xpos = 0
-      first = True
-      column = 2
-      for i in range(0, len(nb_procs)):
-         if not first:
-            plot_str += ", \\\n    "
-         first = False
-         plot_str += "\"%s\" using ($1+%.1f):($%d) lc rgb %s notitle with boxes" % (data_metric_name, xpos, column, colors[i])
-         column += 1
-         xpos += 1.5
-   
-      template_file = open(metric_tmpl, 'r')
-      template = template_file.read()
-   
-      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))
-   
-      create_file(gp_metric_name, gp_commands)
-      
-      # Creating the data file
-      width = 15
-      content = "#x_pos"
-      nb_spaces = width - len(content)
-      content += nb_spaces * ' '
-      for i in nb_procs:
-         content += "%-15d" % i
-      content += "\n"
-   
-      x_pos = 1
-      for app in apps:
-         # Computation of x_pos
-         content += "%-15f" % x_pos
-         x_pos += len(nb_procs) * 1.5 + 0.5
-         for i in nb_procs:
-            if m_metric_norm[metric] == "N":
-               content += "%-15d" % (metrics_val[prot][app][i][metric])
-            elif m_metric_norm[metric] == "P":
-               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / i)
-            elif m_metric_norm[metric] == "C":
-               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / exec_time[prot][app][i] * 1000)
-            elif m_metric_norm[metric] == "W":
-               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_write'])) # Number of writes
-            elif m_metric_norm[metric] == "R":
-               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_read'])) # Number of reads
-            elif m_metric_norm[metric] == "D":
-               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_direct'])) # Number of req.
-            elif is_numeric(m_metric_norm[metric]):
-               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][int(m_metric_norm[metric])][metric]))
-            else:
-               assert(False)
-   
-         app_name = m_app_name[app]
-         content += "#" + app_name + "\n"
-      
-      create_file(data_metric_name, content)
-   
-      # Calling gnuplot
-      print "gnuplot", gp_metric_name
-      subprocess.call([ 'gnuplot', gp_metric_name ])
-
-
-############################################################
-### Graph 5 : Stacked histogram with counters            ###
-############################################################
-
-# The following section creates a stacked histogram containing
-# the metrics in the "stacked_metric" list
-# It is normalized per application w.r.t the values on 256 procs
-
-for prot in single_protocols:
-   data_stacked_name = os.path.join(scripts_path, gen_dir, prot + '_stacked.dat')
-   gp_stacked_name   = os.path.join(scripts_path, gen_dir, prot + '_stacked.gp')
-   
-   norm_factor_value = nb_procs[-1]
-   
-   # Creating the gp file
-   template_file = open(stacked_tmpl, 'r')
-   template = template_file.read()
-   
-   xtics_str = "("
-   first = True
-   xpos = 1
-   app_labels = ""
-   for num_appli in range(0, len(apps)):
-      for i in nb_procs[1:len(nb_procs)]: # skipping values for 1 proc
-         if not first:
-            xtics_str += ", "
-         first = False
-         if i == nb_procs[1]:
-            xpos_first = xpos
-         xtics_str += "\"%d\" %d -1" % (i, xpos)
-         xpos_last = xpos
-         xpos += 1
-      xpos += 1
-      app_name_xpos = float((xpos_first + xpos_last)) / 2
-      app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
-   xtics_str += ")"
-   
-   plot_str = "newhistogram \"\""
-   n = 1
-   for stacked_metric in stacked_metrics:
-      plot_str += ", \\\n    " + "'" + data_stacked_name + "'" + " using " + str(n) + " lc rgb " + colors[n] + " title \"" + m_metric_name[stacked_metric] + "\""
-      n += 1
-   
-   ylabel_str = "Breakdown of Coherence Traffic Normalized w.r.t. \\nthe Values on %d Processors" % norm_factor_value
-   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 = "")
-   
-   create_file(gp_stacked_name, content)
-   
-   # Creating the data file
-   # Values are normalized by application, w.r.t. the number of requests for a given number of procs
-   content = "#"
-   for stacked_metric in stacked_metrics:
-      content += stacked_metric
-      content += ' ' + ' ' * (15 - len(stacked_metric))
-   content += "\n"
-   for app in apps:
-      if app != apps[0]:
-         for i in range(0, len(stacked_metrics)):
-            content += "%-15f" % 0.0
-         content += "\n"
-      for i in nb_procs[1:len(nb_procs)]:
-         for stacked_metric in stacked_metrics:
-            metric_val = metrics_val[prot][app][norm_factor_value]['total_stacked'] # Normalisation
-            if metric_val != 0:
-               content += "%-15f" % (float(metrics_val[prot][app][i][stacked_metric]) / metric_val)
-            else:
-               content += "%-15f" % 0
-         content += "\n"
-   
-   create_file(data_stacked_name, content)
-   # Calling gnuplot
-   print "gnuplot", gp_stacked_name
-   subprocess.call([ 'gnuplot', gp_stacked_name ])
+#############################################################
+#### Graph 1 : Coherence traffic Cost per application     ###
+#############################################################
+#
+#for prot in single_protocols:
+#   for app in apps:
+#      data_coherence_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_coherence.dat')
+#      gp_coherence_name   = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_coherence.gp')
+#   
+#      # Creating the data file
+#      width = 15
+#      content = ""
+#      
+#      for metric in [ '#nb_procs' ] + grouped_metrics:
+#         content += metric + " "
+#         nb_spaces = width - len(metric)
+#         content += nb_spaces * ' '
+#      content += "\n"
+#   
+#      for i in nb_procs:
+#         content += "%-15d " % i
+#         for metric in grouped_metrics:
+#            #print "app : %s - prot : %s - i : %d" % (app, prot, i)
+#            val = float(metrics_val[prot][app][i][metric]) / exec_time[prot][app][i] * 1000
+#            content += "%-15f " % val
+#         content += "\n"
+#      
+#      create_file(data_coherence_name, content)
+#   
+#      # Creating the gp file
+#      template_file = open(coherence_tmpl, 'r')
+#      template = template_file.read()
+#      
+#      plot_str = ""
+#      col = 2
+#      for metric in grouped_metrics:
+#         if metric != grouped_metrics[0]:
+#            plot_str += ", \\\n    "
+#         plot_str += "\"" + data_coherence_name + "\" using ($1):($" + str(col) + ") lc rgb " + colors[col - 2] + " title \"" + m_metric_name[metric] + "\" with linespoint"
+#         col += 1
+#      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'))
+#      
+#      create_file(gp_coherence_name, gp_commands)
+#      
+#      # Calling gnuplot
+#      print "gnuplot", gp_coherence_name
+#      subprocess.call([ 'gnuplot', gp_coherence_name ])
+#
+#
+#############################################################
+#### Graph 2 : Speedup per Application                    ###
+#############################################################
+#
+#if 1 in nb_procs:
+#   for prot in single_protocols:
+#      for app in apps:
+#   
+#         data_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_speedup.dat')
+#         gp_speedup_name   = os.path.join(scripts_path, gen_dir, prot + '_' + app + '_speedup.gp')
+#         
+#         # Creating data file
+#         width = 15
+#         content = "#nb_procs"
+#         nb_spaces = width - len(content)
+#         content += nb_spaces * ' '
+#         content += "speedup\n"
+#   
+#         for i in nb_procs:
+#            content += "%-15d " % i
+#            val = exec_time[prot][app][i]
+#            content += "%-15f\n" % (exec_time[prot][app][1] / float(val))
+#   
+#         plot_str = "\"" + data_speedup_name + "\" using ($1):($2) lc rgb \"#654387\" title \"Speedup\" with linespoint"
+#         
+#         create_file(data_speedup_name, content)
+#         
+#         # Creating the gp file
+#         template_file = open(speedup_tmpl, 'r')
+#         template = template_file.read()
+#         
+#         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'))
+#         
+#         create_file(gp_speedup_name, gp_commands)
+#         
+#         # Calling gnuplot
+#         print "gnuplot", gp_speedup_name
+#         subprocess.call([ 'gnuplot', gp_speedup_name ])
+#
+#
+#############################################################
+#### Graph 3 : All speedups on the same Graph             ###
+#############################################################
+#
+#if 1 in nb_procs:
+#   for prot in single_protocols:
+#      # This graph uses the same template as the graph 2
+#      data_speedup_name = os.path.join(scripts_path, gen_dir, prot + '_all_speedup.dat')
+#      gp_speedup_name   = os.path.join(scripts_path, gen_dir, prot + '_all_speedup.gp')
+#      
+#      # Creating data file
+#      width = 15
+#      content = "#nb_procs"
+#      nb_spaces = width - len(content)
+#      content += (nb_spaces + 1) * ' '
+#      for app in apps:
+#         content += app + " "
+#         content += (width - len(app)) * " "
+#      content += "\n"
+#      
+#      for i in nb_procs:
+#         content += "%-15d " % i
+#         for app in apps:
+#            val = exec_time[prot][app][i]
+#            content += "%-15f " % (exec_time[prot][app][1] / float(val))
+#         content += "\n"
+#      
+#      create_file(data_speedup_name, content)
+#      
+#      # Creating gp file
+#      template_file = open(speedup_tmpl, 'r')
+#      template = template_file.read()
+#      
+#      plot_str = ""
+#      col = 2
+#      for app in apps:
+#         if app != apps[0]:
+#            plot_str += ", \\\n     "
+#         plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2])  + m_app_name[app] + "\" with linespoint"
+#         col += 1
+#      
+#      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'))
+#         
+#      create_file(gp_speedup_name, gp_commands)
+#         
+#      # Calling gnuplot
+#      print "gnuplot", gp_speedup_name
+#      subprocess.call([ 'gnuplot', gp_speedup_name ])
+#
+#
+#############################################################
+#### Graph 4 : Graph per metric                           ###
+#############################################################
+#
+## The following section creates the graphs grouped by measure (e.g. #broadcasts)
+## The template file cannot be easily created otherwise it would not be generic
+## in many ways. This is why it is mainly created here.
+## Graphs are created for metric in the "individual_metrics" list
+#
+#for prot in single_protocols:
+#   for metric in individual_metrics:
+#      data_metric_name = os.path.join(scripts_path, gen_dir, prot + '_' + metric + '.dat')
+#      gp_metric_name   = os.path.join(scripts_path, gen_dir, prot + '_' + metric + '.gp')
+#   
+#      # Creating the gp file
+#      # Setting xtics, i.e. number of procs for each application
+#      xtics_str = "("
+#      first = True
+#      xpos = 1
+#      app_labels = ""
+#      for num_appli in range(0, len(apps)):
+#         for i in nb_procs:
+#            if not first:
+#               xtics_str += ", "
+#            first = False
+#            if i == nb_procs[0]:
+#               xpos_first = xpos
+#            xtics_str += "\"%d\" %.1f" % (i, xpos)
+#            xpos_last = xpos
+#            xpos += 1.5
+#         xpos += 0.5
+#         app_name_xpos = float((xpos_first + xpos_last)) / 2
+#         app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
+#      xtics_str += ")"
+#   
+#      xmax_val = float(xpos - 1)
+#   
+#      # Writing the lines of "plot"
+#      plot_str = ""
+#      xpos = 0
+#      first = True
+#      column = 2
+#      for i in range(0, len(nb_procs)):
+#         if not first:
+#            plot_str += ", \\\n    "
+#         first = False
+#         plot_str += "\"%s\" using ($1+%.1f):($%d) lc rgb %s notitle with boxes" % (data_metric_name, xpos, column, colors[i])
+#         column += 1
+#         xpos += 1.5
+#   
+#      template_file = open(metric_tmpl, 'r')
+#      template = template_file.read()
+#   
+#      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))
+#   
+#      create_file(gp_metric_name, gp_commands)
+#      
+#      # Creating the data file
+#      width = 15
+#      content = "#x_pos"
+#      nb_spaces = width - len(content)
+#      content += nb_spaces * ' '
+#      for i in nb_procs:
+#         content += "%-15d" % i
+#      content += "\n"
+#   
+#      x_pos = 1
+#      for app in apps:
+#         # Computation of x_pos
+#         content += "%-15f" % x_pos
+#         x_pos += len(nb_procs) * 1.5 + 0.5
+#         for i in nb_procs:
+#            if m_metric_norm[metric] == "N":
+#               content += "%-15d" % (metrics_val[prot][app][i][metric])
+#            elif m_metric_norm[metric] == "P":
+#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / i)
+#            elif m_metric_norm[metric] == "C":
+#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / exec_time[prot][app][i] * 1000)
+#            elif m_metric_norm[metric] == "W":
+#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_write'])) # Number of writes
+#            elif m_metric_norm[metric] == "R":
+#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_read'])) # Number of reads
+#            elif m_metric_norm[metric] == "D":
+#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][i]['total_direct'])) # Number of req.
+#            elif is_numeric(m_metric_norm[metric]):
+#               content += "%-15f" % (float(metrics_val[prot][app][i][metric]) / float(metrics_val[prot][app][int(m_metric_norm[metric])][metric]))
+#            else:
+#               assert(False)
+#   
+#         app_name = m_app_name[app]
+#         content += "#" + app_name + "\n"
+#      
+#      create_file(data_metric_name, content)
+#   
+#      # Calling gnuplot
+#      print "gnuplot", gp_metric_name
+#      subprocess.call([ 'gnuplot', gp_metric_name ])
+#
+#
+#############################################################
+#### Graph 5 : Stacked histogram with counters            ###
+#############################################################
+#
+## The following section creates a stacked histogram containing
+## the metrics in the "stacked_metric" list
+## It is normalized per application w.r.t the values on 256 procs
+#
+#for prot in single_protocols:
+#   data_stacked_name = os.path.join(scripts_path, gen_dir, prot + '_stacked.dat')
+#   gp_stacked_name   = os.path.join(scripts_path, gen_dir, prot + '_stacked.gp')
+#   
+#   norm_factor_value = nb_procs[-1]
+#   
+#   # Creating the gp file
+#   template_file = open(stacked_tmpl, 'r')
+#   template = template_file.read()
+#   
+#   xtics_str = "("
+#   first = True
+#   xpos = 1
+#   app_labels = ""
+#   for num_appli in range(0, len(apps)):
+#      for i in nb_procs[1:len(nb_procs)]: # skipping values for 1 proc
+#         if not first:
+#            xtics_str += ", "
+#         first = False
+#         if i == nb_procs[1]:
+#            xpos_first = xpos
+#         xtics_str += "\"%d\" %d -1" % (i, xpos)
+#         xpos_last = xpos
+#         xpos += 1
+#      xpos += 1
+#      app_name_xpos = float((xpos_first + xpos_last)) / 2
+#      app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
+#   xtics_str += ")"
+#   
+#   plot_str = "newhistogram \"\""
+#   n = 1
+#   for stacked_metric in stacked_metrics:
+#      plot_str += ", \\\n    " + "'" + data_stacked_name + "'" + " using " + str(n) + " lc rgb " + colors[n] + " title \"" + m_metric_name[stacked_metric] + "\""
+#      n += 1
+#   
+#   ylabel_str = "Breakdown of Coherence Traffic Normalized w.r.t. \\nthe Values on %d Processors" % norm_factor_value
+#   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 = "")
+#   
+#   create_file(gp_stacked_name, content)
+#   
+#   # Creating the data file
+#   # Values are normalized by application, w.r.t. the number of requests for a given number of procs
+#   content = "#"
+#   for stacked_metric in stacked_metrics:
+#      content += stacked_metric
+#      content += ' ' + ' ' * (15 - len(stacked_metric))
+#   content += "\n"
+#   for app in apps:
+#      if app != apps[0]:
+#         for i in range(0, len(stacked_metrics)):
+#            content += "%-15f" % 0.0
+#         content += "\n"
+#      for i in nb_procs[1:len(nb_procs)]:
+#         for stacked_metric in stacked_metrics:
+#            metric_val = metrics_val[prot][app][norm_factor_value]['total_stacked'] # Normalisation
+#            if metric_val != 0:
+#               content += "%-15f" % (float(metrics_val[prot][app][i][stacked_metric]) / metric_val)
+#            else:
+#               content += "%-15f" % 0
+#         content += "\n"
+#   
+#   create_file(data_stacked_name, content)
+#   # Calling gnuplot
+#   print "gnuplot", gp_stacked_name
+#   subprocess.call([ 'gnuplot', gp_stacked_name ])
 
 
@@ -508,5 +514,5 @@
             xpos += 3
       app_name_xpos = float((xpos_first + xpos_last)) / 2
-      app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
+      app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,28\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
       #xpos += 1
    xtics_str += ")"
@@ -518,5 +524,5 @@
       n += 1
    
-   ylabel_str = "Coherence Cost Compared to Direct Requests Cost,\\nNormalized per Application for each Number of Processors"
+   ylabel_str = "Coherence Cost Vs. Direct Requests Cost,\\nNormalized w.r.t. Direct Requests Cost"
    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 = "")
    
@@ -581,44 +587,45 @@
 
 
-for app in apps:
-
-   data_speedup_name = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_speedup.dat')
-   gp_speedup_name   = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_speedup.gp')
-   
-   # Creating data file
-   width = 15
-   content = "#nb_procs"
-   nb_spaces = width - len(content)
-   content += nb_spaces * ' '
-   content += "speedup\n"
-
-   for i in nb_procs:
-      content += "%-15d " % i
-      for prot in joint_protocols:
-         val = exec_time[prot][app][i]
-         content += "%-15f " % (exec_time[joint_protocols[0]][app][1] / float(val))
-      content += "\n"
-
-   create_file(data_speedup_name, content)
-   
-   # Creating the gp file
-   template_file = open(speedup_tmpl, 'r')
-   template = template_file.read()
-  
-   plot_str = ""
-   col = 2
-   for prot in joint_protocols:
-      if prot != joint_protocols[0]:
-         plot_str += ", \\\n     "
-      plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2])  + m_prot_name[prot] + "\" with linespoint"
-      col += 1
-  
-   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'))
-   
-   create_file(gp_speedup_name, gp_commands)
-   
-   # Calling gnuplot
-   print "gnuplot", gp_speedup_name
-   subprocess.call([ 'gnuplot', gp_speedup_name ])
+#if 1 in nb_procs:
+#   for app in apps:
+#   
+#      data_speedup_name = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_speedup.dat')
+#      gp_speedup_name   = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_speedup.gp')
+#      
+#      # Creating data file
+#      width = 15
+#      content = "#nb_procs"
+#      nb_spaces = width - len(content)
+#      content += nb_spaces * ' '
+#      content += "speedup\n"
+#   
+#      for i in nb_procs:
+#         content += "%-15d " % i
+#         for prot in joint_protocols:
+#            val = exec_time[prot][app][i]
+#            content += "%-15f " % (exec_time[joint_protocols[0]][app][1] / float(val))
+#         content += "\n"
+#   
+#      create_file(data_speedup_name, content)
+#      
+#      # Creating the gp file
+#      template_file = open(speedup_tmpl, 'r')
+#      template = template_file.read()
+#     
+#      plot_str = ""
+#      col = 2
+#      for prot in joint_protocols:
+#         if prot != joint_protocols[0]:
+#            plot_str += ", \\\n     "
+#         plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2])  + m_prot_name[prot] + "\" with linespoint"
+#         col += 1
+#     
+#      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'))
+#      
+#      create_file(gp_speedup_name, gp_commands)
+#      
+#      # Calling gnuplot
+#      print "gnuplot", gp_speedup_name
+#      subprocess.call([ 'gnuplot', gp_speedup_name ])
 
 
@@ -638,8 +645,9 @@
 template_file = open(stacked_tmpl, 'r')
 template = template_file.read()
-   
+ 
 xtics_str = "("
 first = True
-xpos = 1 # successive x position of the center of the first bar in a application
+barwidth = 1
+xpos = 1 # successive x position of the center of the first bar in an application
 app_labels = ""
 prot_labels = ""
@@ -650,5 +658,5 @@
          x = 0 # local var for computing position of protocol names
          for prot in joint_protocols:
-            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?)
+            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?)
             x += 2
 
@@ -660,9 +668,10 @@
             xpos_first = xpos
          xtics_str += "\"%d\" %f -1" % (i, float(xpos - 0.5 + len(joint_protocols)))
+         #xtics_str += "\"\" %f -1" % (float(xpos - 0.5 + len(joint_protocols))) # not to have proc number displayed
          xpos_last = xpos
-         xpos += 1 + len(joint_protocols) * 2
-   app_name_xpos = float((xpos_first + xpos_last)) / 2
+         xpos += 1 + len(joint_protocols) * 2 * barwidth
+   app_name_xpos = float((xpos_first + xpos_last)) / 2 + 2
    app_labels += "set label \"%s\" at first %f,character 1 center font \"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
-   xpos += 1
+   #xpos += 1
 xtics_str += ")"
 
@@ -673,5 +682,5 @@
    n += 1
 
-ylabel_str = "Coherence Cost and Direct Requests Cost,\\nNormalized per Application for each Number of Processors"
+ylabel_str = "Coherence Cost vs. Direct Requests Cost,\\nNormalized per Application for each Number of Processors"
 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)
 
@@ -800,4 +809,51 @@
 
 
-
-
+#########################################################################################################
+### Graph 10: Normalized exec times with no log scale: when scalability is achieved by constant time  ###
+#########################################################################################################
+
+
+if 1 in nb_procs:
+   for app in apps:
+   
+      data_speedup_name = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_cst_exec_time.dat')
+      gp_speedup_name   = os.path.join(scripts_path, gen_dir, 'joint_' + app + '_cst_exec_time.gp')
+      
+      # Creating data file
+      width = 15
+      content = "#nb_procs"
+      nb_spaces = width - len(content)
+      content += nb_spaces * ' '
+      content += "norm_exec_time\n"
+   
+      for i in nb_procs:
+         content += "%-15d " % i
+         for prot in joint_protocols:
+            val = exec_time[prot][app][i]
+            content += "%-15f " % (float(val) / exec_time[joint_protocols[0]][app][1])
+         content += "\n"
+   
+      create_file(data_speedup_name, content)
+      
+      # Creating the gp file
+      template_file = open(cst_exec_time_tmpl, 'r')
+      template = template_file.read()
+     
+      plot_str = ""
+      col = 2
+      for prot in joint_protocols:
+         if prot != joint_protocols[0]:
+            plot_str += ", \\\n     "
+         plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2])  + m_prot_name[prot] + "\" with linespoint"
+         col += 1
+     
+      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'))
+      
+      create_file(gp_speedup_name, gp_commands)
+      
+      # Calling gnuplot
+      print "gnuplot", gp_speedup_name
+      subprocess.call([ 'gnuplot', gp_speedup_name ])
+
+
+
