- Timestamp:
- Jul 13, 2017, 11:01:58 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/scripts/create_graph.py
r823 r826 22 22 from common import * 23 23 24 # Creates graphes for random images with a density varying from 0 to 100% 24 25 25 use_rand_images = True26 with_features = False27 26 28 threads = [1, 2, 4, 8, 16, 32, 64] 27 with_features = True 28 29 threads = [1, 4, 16, 64] 29 30 use_dsk = True 30 31 img_size = 2048 31 granularit y = 132 granularities = [1, 4, 16] 32 33 rand_seed = 7 33 34 … … 36 37 pyconf_file = os.path.join(scripts_path, "config.py") 37 38 38 base_data_dir = "data " # For timing information extracted39 base_data_dir = "data_2016_09_21" # For timing information extracted 39 40 base_graph_dir = "graphes" # For storing generated graphes 40 41 41 42 42 # Each of these configuration must have been run with both features activated and deactivated43 # if with_features, each of these configuration must have been run with both features activated and deactivated 43 44 configs = [ 44 45 #{'SLOW':'1', 'FAST':'0', 'PARMERGE':'0', 'ARSP':'0'}, 45 #{'SLOW':'0', 'FAST':'1', 'PARMERGE':'0', 'ARSP':'0'},46 #{'SLOW':'0', 'FAST':'1', 'PARMERGE':'1', 'ARSP':'0'},46 {'SLOW':'0', 'FAST':'1', 'PARMERGE':'0', 'ARSP':'0'}, 47 {'SLOW':'0', 'FAST':'1', 'PARMERGE':'1', 'ARSP':'0'}, 47 48 {'SLOW':'0', 'FAST':'1', 'PARMERGE':'1', 'ARSP':'1'}, 48 49 ] … … 87 88 88 89 90 # Phase 1: Extracting execution times 89 91 exec_time = {} 90 92 for config in configs: … … 93 95 for thread in threads: 94 96 exec_time[fconfig][thread] = {} 95 for ftrs in features: # Features or No features 96 exec_time[fconfig][thread][ftrs] = {} 97 for density in range(0, 101): 98 exec_time[fconfig][thread][ftrs][density] = {} 99 random_img_file = get_random_img_file(density, img_size, img_size, granularity, rand_seed) 100 img_basename = os.path.splitext(random_img_file)[0] 101 log_file = get_filename(data_dir, thread, config, ftrs == "FT", img_basename) 102 lines = open(log_file, 'r') 103 for line in lines: 104 tokens = line.split() 105 if len(tokens) == 0: 106 continue 107 tag = tokens[0] 108 pattern = re.compile('\[STEP_([0-9]+)\]') 109 match = pattern.match(tag) 110 if match: 111 step = int(match.group(1)) 112 nb_step = max(int(step) + 1, nb_step) 113 value = tokens[len(tokens) - 1] 114 exec_time[fconfig][thread][ftrs][density][step] = value 115 #print("exec_time[fconfig][%d][%s][%d][%s] = %s" % (thread, ftrs, density, step, exec_time[fconfig][thread][ftrs][density][step])) 97 for granularity in granularities: 98 exec_time[fconfig][thread][granularity] = {} 99 for ftrs in features: # Features or No features 100 exec_time[fconfig][thread][granularity][ftrs] = {} 101 for density in range(0, 101): 102 exec_time[fconfig][thread][granularity][ftrs][density] = {} 103 random_img_file = get_random_img_file(density, img_size, img_size, granularity, rand_seed) 104 #random_img_file = get_short_random_img_file(density, granularity) 105 img_basename = os.path.splitext(random_img_file)[0] 106 log_file = get_filename(data_dir, thread, config, ftrs == "FT", img_basename) 107 lines = open(log_file, 'r') 108 for line in lines: 109 tokens = line.split() 110 if len(tokens) == 0: 111 continue 112 tag = tokens[0] 113 pattern = re.compile('\[STEP_([0-9]+)\]') 114 match = pattern.match(tag) 115 if match: 116 step = int(match.group(1)) 117 nb_step = max(int(step) + 1, nb_step) 118 value = tokens[len(tokens) - 1] 119 exec_time[fconfig][thread][granularity][ftrs][density][step] = value 120 #print("exec_time[fconfig][%d][%d][%s][%d][%s] = %s" % (thread, granularity, ftrs, density, step, exec_time[fconfig][thread][granularity][ftrs][density][step])) 116 121 117 122 118 123 119 124 # Phase 2: Creating plots 120 125 for config in configs: 121 126 fconfig = frozenset(config.items()) 122 127 for thread in threads: 123 plotter = Stack(["red", "blue", "#CAFE01", "#CA01FE", "#01CAFE"], "Légende", "X", "Y") 124 X = [x for x in range(0, 101)] 125 plotter.add_x(X) 126 assert(nb_step == 4) 127 YPAR1 = [float(int(exec_time[fconfig][thread]["NF"][density][0]) / math.pow(img_size, 2)) for density in range(0, 101)] # Parallel Labeling 128 YPAR2 = [float(int(exec_time[fconfig][thread]["NF"][density][1]) / math.pow(img_size, 2)) for density in range(0, 101)] # Merging (Parallel or Pyramidal) 129 YPTC2 = [float(int(exec_time[fconfig][thread]["NF"][density][2]) / math.pow(img_size, 2)) for density in range(0, 101)] # Parallel Transitive Closure 130 YPAR3 = [float(int(exec_time[fconfig][thread]["NF"][density][3]) / math.pow(img_size, 2)) for density in range(0, 101)] # Parallel Relabeling 128 for granularity in granularities: 129 plotter = Stack(["red", "blue", "green", "orange", "pink", "purple"], "Légende", "X", "Y") 130 X = [x for x in range(0, 101)] 131 plotter.add_x(X) 132 assert(nb_step == 5) 133 # Parallel Labeling 134 YPAR1 = [float(int(exec_time[fconfig][thread][granularity]["NF"][density][0]) / math.pow(img_size, 2)) for density in range(0, 101)] 135 # Merging (Parallel or Pyramidal) 136 YPAR2 = [float(int(exec_time[fconfig][thread][granularity]["NF"][density][1]) / math.pow(img_size, 2)) for density in range(0, 101)] 137 # Parallel Transitive Closure 138 YPTC2 = [float(int(exec_time[fconfig][thread][granularity]["NF"][density][2]) / math.pow(img_size, 2)) for density in range(0, 101)] 139 # Propagate Features if Features and ARSP, nothing otherwise 140 YPRF2 = [float(int(exec_time[fconfig][thread][granularity]["NF"][density][3]) / math.pow(img_size, 2)) for density in range(0, 101)] 141 # Parallel Relabelling 142 YPAR3 = [float(int(exec_time[fconfig][thread][granularity]["NF"][density][4]) / math.pow(img_size, 2)) for density in range(0, 101)] 131 143 132 plotter.add_y(YPAR1) 133 plotter.add_y(YPAR2) 134 plotter.add_y(YPTC2) 135 # Not displaying PAR3 144 plotter.add_y(YPAR1) 145 plotter.add_y(YPAR2) 146 plotter.add_y(YPTC2) 147 plotter.add_y(YPRF2) 148 # displaying PAR3 149 plotter.add_y(YPAR3) 136 150 137 if with_features: 138 YPAR1f = [float(int(exec_time[fconfig][thread]["FT"][density][0]) / math.pow(img_size, 2)) for density in range(0, 101)] # Parallel Labeling 139 YPAR2f = [float(int(exec_time[fconfig][thread]["FT"][density][1]) / math.pow(img_size, 2)) for density in range(0, 101)] # Merging (Parallel or Pyramidal) 140 deltaYPAR1 = [max(0, x - y) for x, y in zip (YPAR1f, YPAR1)] 141 deltaYPAR2 = [max(0, x - y) for x, y in zip (YPAR2f, YPAR2)] 142 YFTC = [x + y for x, y in zip (deltaYPAR1, deltaYPAR2)] # Features Computation 143 plotter.add_y(YFTC) 151 if with_features: 152 YPAR1F = [float(int(exec_time[fconfig][thread][granularity]["FT"][density][0]) / math.pow(img_size, 2)) for density in range(0, 101)] 153 YPAR2F = [float(int(exec_time[fconfig][thread][granularity]["FT"][density][1]) / math.pow(img_size, 2)) for density in range(0, 101)] 154 YPTC2F = [float(int(exec_time[fconfig][thread][granularity]["FT"][density][2]) / math.pow(img_size, 2)) for density in range(0, 101)] 155 YPRF2F = [float(int(exec_time[fconfig][thread][granularity]["FT"][density][3]) / math.pow(img_size, 2)) for density in range(0, 101)] 156 YPAR3F = [float(int(exec_time[fconfig][thread][granularity]["FT"][density][4]) / math.pow(img_size, 2)) for density in range(0, 101)] 157 TotalNF = [x + y + z + t + u for x, y, z, t, u in zip(YPAR1, YPAR2, YPTC2, YPRF2, YPAR3)] # Total No Features 158 TotalFT = [x + y + z + t + u for x, y, z, t, u in zip(YPAR1F, YPAR2F, YPTC2F, YPRF2F, YPAR3F)] # Total with Features 159 YFCT = [max(0, x - y) for x, y in zip(TotalFT, TotalNF)] # Difference = Features Computation Time 160 plotter.add_y(YFCT) 144 161 145 plotter.plot()146 graph_name = get_graph_filename(graph_dir, thread, config, ".pdf")147 print("# Creating graph %s" % short_path(graph_name))148 plotter.save(graph_name)162 plotter.plot() 163 graph_name = get_graph_filename(graph_dir, thread, granularity, config, ".pdf") 164 print("# Creating graph %s" % short_path(graph_name)) 165 plotter.save(graph_name) 149 166 150 167
Note: See TracChangeset
for help on using the changeset viewer.