Exemple #1
0
def find_same_level_regions(region):
    # Load graph
    graph = load_graph()
    if not graph:
        logger.error("Can't trace multiple regions: Region call graph not available.\n\
                      Run cere profile.\n\
                      Tracing region {0}".format(region))
        return

    # Find region node id
    region_node = get_region_id(region, graph)

    #Find roots
    roots = [n for n,d in graph.in_degree().items() if d==0]

    #Compute for every nodes, the max distance from himself to each root
    max_path_len = {}
    for root in roots:
        for n, d in graph.nodes(data=True):
            if n not in max_path_len: max_path_len[n]=0
            #Get every paths from the current root to the node
            paths = list(nx.all_simple_paths(graph, root, n))
            #Keep the max length path
            for path in paths:
                if len(path)-1 > max_path_len[n]:
                    max_path_len[n] = len(path)-1

    #Keep region which have the same depth than the requested region
    for n, p in max_path_len.iteritems():
        if p == max_path_len[region_node]:
            yield graph.node[n]['_name']
Exemple #2
0
 def compute_coverage(self):
     #There is two ways of computing coverage
     #1) If we have gperftool results:
     from common.graph_utils import load_graph
     import networkx as nx
     graph = load_graph()
     if graph:
         logger.info("Computing coverage using google perf tool")
         for n, d in graph.nodes(data=True):
             if d['_name'] == self.region:
                 self.coverage = float(d['_self_coverage'])
                 return
     #2) Compute the coverage manually
     elif os.path.isfile("{0}/app_cycles.csv".format(
             var.CERE_PROFILE_PATH)):
         logger.info("Computing coverage using rdtsc tool")
         with open("{0}/app_cycles.csv".format(
                 var.CERE_PROFILE_PATH)) as app:
             reader = csv.DictReader(app)
             for row in reader:
                 app_cycles = float(row["CPU_CLK_UNHALTED_CORE"])
         self.coverage = (self.invivo_cycles / app_cycles) * 100
     else:
         self.coverage = "NA"
         logger.warning(
             "Cannot compute coverage for region {0}. Try to run cere profile"
             .format(self.region))
Exemple #3
0
def find_same_level_regions(region):
    # Load graph
    graph = load_graph()
    if not graph:
        logger.error(
            "Can't trace multiple regions: Region call graph not available.\n\
                      Run cere profile.\n\
                      Tracing region {0}".format(region))
        return

    # Find region node id
    region_node = get_region_id(region, graph)

    #Find roots
    roots = [n for n, d in graph.in_degree().items() if d == 0]

    #Compute for every nodes, the max distance from himself to each root
    max_path_len = {}
    for root in roots:
        for n, d in graph.nodes(data=True):
            if n not in max_path_len: max_path_len[n] = 0
            #Get every paths from the current root to the node
            paths = list(nx.all_simple_paths(graph, root, n))
            #Keep the max length path
            for path in paths:
                if len(path) - 1 > max_path_len[n]:
                    max_path_len[n] = len(path) - 1

    #Keep region which have the same depth than the requested region
    for n, p in max_path_len.iteritems():
        if p == max_path_len[region_node]:
            yield graph.node[n]['_name']
Exemple #4
0
 def compute_coverage(self):
     #There is two ways of computing coverage
     #1) If we have gperftool results:
     from common.graph_utils import load_graph
     import networkx as nx
     graph = load_graph()
     if graph:
         logger.info("Computing coverage using google perf tool")
         for n, d in graph.nodes(data=True):
             if d['_name'] == self.region:
                 self.coverage = float(d['_self_coverage'])
                 return
     #2) Compute the coverage manually
     elif os.path.isfile("{0}/app_cycles.csv".format(var.CERE_PROFILE_PATH)):
         logger.info("Computing coverage using rdtsc tool")
         with open("{0}/app_cycles.csv".format(var.CERE_PROFILE_PATH)) as app:
             reader = csv.DictReader(app)
             for row in reader:
                 app_cycles = float(row["CPU_CLK_UNHALTED_CORE"])
         self.coverage = (self.invivo_cycles/app_cycles)*100
     else:
         self.coverage = "NA"
         logger.warning("Cannot compute coverage for region {0}. Try to run cere profile".format(self.region))