Ignore:
Timestamp:
Jul 13, 2017, 11:01:58 AM (7 years ago)
Author:
meunier
Message:
  • Mise à jour NR2 et Rosenfeld
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/rosenfeld/scripts/create_graph.py

    r823 r826  
    2222from common import *
    2323
     24# Creates graphes for random images with a density varying from 0 to 100%
    2425
    25 use_rand_images = True
    26 with_features = False
    2726
    28 threads = [1, 2, 4, 8, 16, 32, 64]
     27with_features = True
     28
     29threads = [1, 4, 16, 64]
    2930use_dsk = True
    3031img_size = 2048
    31 granularity = 1
     32granularities = [1, 4, 16]
    3233rand_seed = 7
    3334
     
    3637pyconf_file   = os.path.join(scripts_path, "config.py")
    3738
    38 base_data_dir  = "data"    # For timing information extracted
     39base_data_dir  = "data_2016_09_21"    # For timing information extracted
    3940base_graph_dir = "graphes" # For storing generated graphes
    4041
    4142
    42 # Each of these configuration must have been run with both features activated and deactivated
     43# if with_features, each of these configuration must have been run with both features activated and deactivated
    4344configs = [
    4445        #{'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'},
    4748        {'SLOW':'0', 'FAST':'1', 'PARMERGE':'1', 'ARSP':'1'},
    4849]
     
    8788
    8889
     90# Phase 1: Extracting execution times
    8991exec_time = {}
    9092for config in configs:
     
    9395    for thread in threads:
    9496        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]))
    116121
    117122                   
    118123
    119 
     124# Phase 2: Creating plots
    120125for config in configs:
    121126    fconfig = frozenset(config.items())
    122127    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)]
    131143
    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)
    136150
    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)
    144161
    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)
    149166
    150167
Note: See TracChangeset for help on using the changeset viewer.