Index: trunk/platforms/tsar_generic_xbar/scripts/create_graphs.py
===================================================================
--- trunk/platforms/tsar_generic_xbar/scripts/create_graphs.py	(revision 836)
+++ trunk/platforms/tsar_generic_xbar/scripts/create_graphs.py	(revision 1012)
@@ -7,10 +7,12 @@
 
 
-apps = [ 'filter', 'lu', 'fft_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 = [ 'filt_ga' ]
-nb_procs = [ 1, 4, 8, 16, 32, 64 ]
-single_protocols = ['dhccp', 'rwt' ]
-joint_protocols = ['dhccp', 'rwt' ]
+#apps = [ 'histo-opt', 'histogram2', 'histo-opt2' ]
+#nb_procs = [ 1, 4, 8, 16, 32, 64, 128, 256 ]
+nb_procs = [ 1, 4, 8, 16, 32, 64, 128, 256 ]
+single_protocols = ['dhccp', 'hmesi']
+joint_protocols = ['dhccp', 'hmesi']
 #joint_protocols = []
 
@@ -75,5 +77,5 @@
 exec_time = {}
 metrics_val = {}
-for prot in single_protocols:
+for prot in joint_protocols:
    metrics_val[prot] = {}
    exec_time[prot] = {}
@@ -111,5 +113,5 @@
     
 # Completing unset metrics (i.e. they are not present in the data file) with 0
-for prot in single_protocols:
+for prot in joint_protocols:
    for app in apps:
       for i in nb_procs:
@@ -119,5 +121,5 @@
 
 # We make a 2nd pass to fill the derived fields, e.g. nb_total_updates
-for prot in single_protocols:
+for prot in joint_protocols:
    for app in apps:
       for i in nb_procs:
@@ -137,5 +139,6 @@
          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']
          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'] * (x * y - 1)
+         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']
          if metrics_val[prot][app][i]['broadcast'] < metrics_val[prot][app][i]['write_broadcast']:
             # test to patch a bug in mem_cache
@@ -414,9 +417,9 @@
    app_labels = ""
    for num_appli in range(0, len(apps)):
-      for i in nb_procs:
+      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[0]:
+         if i == nb_procs[1]:
             xpos_first = xpos
          xtics_str += "\"%d\" %d -1" % (i, xpos)
@@ -451,7 +454,11 @@
             content += "%-15f" % 0.0
          content += "\n"
-      for i in nb_procs:
+      for i in nb_procs[1:len(nb_procs)]:
          for stacked_metric in stacked_metrics:
-            content += "%-15f" % (float(metrics_val[prot][app][i][stacked_metric]) / metrics_val[prot][app][norm_factor_value]['total_stacked'])
+            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"
    
@@ -476,5 +483,6 @@
    
    direct_cost_metrics = [ 'read_cost', 'write_cost' ]
-   coherence_cost_metrics = ['update_cost', 'm_inv_cost', 'broadcast_cost' ]
+   #coherence_cost_metrics = ['update_cost', 'm_inv_cost', 'broadcast_cost' ]
+   coherence_cost_metrics = ['coherence_cost']
    
    # Creating the gp file
@@ -533,5 +541,9 @@
          if i > 4:
             for cost_metric in direct_cost_metrics:
-               content += "%-15f" % (float(metrics_val[prot][app][i][cost_metric]) / metrics_val[prot][app][i]['direct_cost'])
+               if metrics_val[prot][app][i]['direct_cost'] == 0:
+                  print "Error: prot : ", prot, " - app : ", app, " - i : ", i
+                  content += "%-15f" % 0
+               else:
+                  content += "%-15f" % (float(metrics_val[prot][app][i][cost_metric]) / metrics_val[prot][app][i]['direct_cost'])
             for cost_metric in coherence_cost_metrics:
                content += "%-15f" % 0.0
@@ -540,5 +552,9 @@
                content += "%-15f" % 0.0
             for cost_metric in coherence_cost_metrics:
-               content += "%-15f" % (float(metrics_val[prot][app][i][cost_metric]) / metrics_val[prot][app][i]['direct_cost'])
+               if metrics_val[prot][app][i]['direct_cost'] == 0:
+                  print "Error: prot : ", prot, " - app : ", app, " - i : ", i
+                  content += "%-15f" % 0
+               else:
+                  content += "%-15f" % (float(metrics_val[prot][app][i][cost_metric]) / metrics_val[prot][app][i]['direct_cost'])
             content += "\n"
             if i != nb_procs[-1]:
@@ -680,4 +696,6 @@
       if i > 4:
          for prot in joint_protocols:
+            if metrics_val[joint_protocols[0]][app][i]['direct_cost'] == 0:
+               continue
             for cost_metric in direct_cost_metrics:
                content += "%-15f" % (float(metrics_val[prot][app][i][cost_metric]) / metrics_val[joint_protocols[0]][app][i]['direct_cost'])
