Example #1
0
    def get_metric_by_function(inpfilename):
        '''
        get depth level for each function in the call tree
        '''
        print(f"Processing {inpfilename}...")

        call_tree = ct.get_call_tree(inpfilename)

        func_node = next(node for node in ct.iterate_on_call_tree(call_tree)
                         if node.fname == funcname)

        children_info = [
            node.fname + "," + str(node.cnode_id)
            for node in ct.iterate_on_call_tree(func_node, 1)
        ]

        #####
        #
        output_i = mg.process_cubex(inpfilename, exclusive=exclincl)

        # We convert the Cnode IDs to short callpaths in the dataframe.
        df_i = ic.convert_index(output_i.df,
                                output_i.ctree_df,
                                target='Short Callpath')

        res_df = df_i.loc[children_info]

        res = res_df.reset_index()[[
            'Short Callpath', 'Thread ID', metric
        ]].groupby('Short Callpath').sum().sort_values([metric],
                                                       ascending=False)[metric]

        res = res.head(11 if len(res) > 11 else len(res))

        return res
    def get_metric_by_level(inpfilename):
        """
        get depth level for each function in the call tree
        """
        print(f"Processing {inpfilename}")

        # This gives us a number of outputs
        # (see https://cupybelib.readthedocs.io/en/latest/merger.html)
        output_i = mg.process_cubex(inpfilename, exclusive=exclincl)

        parent_series = output_i.ctree_df.set_index(
            "Cnode ID").loc[:, "Parent Cnode ID"]

        # get depth level for each function in the call tree
        levels = ct.get_level(parent_series)

        # We convert the Cnode IDs to short callpaths in the dataframe.
        df_i = ic.convert_index(output_i.df,
                                output_i.ctree_df,
                                target="Short Callpath")

        # extract the data
        res = (df_i.reset_index()[[
            "Short Callpath", "Thread ID", metric
        ]].groupby("Short Callpath").sum().sort_values([metric])[metric])

        res_df = pd.DataFrame(res)

        time = res_df.reset_index()["time"]
        fname = res_df.reset_index()["Short Callpath"].str.extract(
            r"(\w+),([0-9]+)")[0]
        cnode_id = (res_df.reset_index()["Short Callpath"].str.extract(
            r"(\w+),([0-9]+)")[1].astype(int))

        combined = pd.merge(
            left=(pd.concat([time, fname, cnode_id], axis="columns").rename(
                {
                    "time": "time",
                    0: "fname",
                    1: "Cnode ID"
                }, axis="columns")),
            right=levels.reset_index().rename({0: "level"}, axis="columns"),
            on="Cnode ID",
        )

        # to extract functions called only at the 3rd level
        time_data = combined[combined["level"] == 2].sort_values(
            by=["level", "time"], ascending=False)

        return time_data
Example #3
0
def test_process_multi():
    files = glob.glob(f'{SCALASCA_OUTPUT}/*/profile.cubex')
    
    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    print("Processing single dump")
    res = mg.process_cubex(files[0])
    print("Calltree:")
    print(res.ctree)
    print("Metrics:")
    print(res.df)
    
    print("Processing multiple dump")
    
    output  = mg.process_multi(files)
    print("Common metrics to all the profile files:")
    print(output.common)
    print("Metrics specific to single profile files:")
    print(output.noncommon)
Example #4
0
    import index_conversions as ic
    import matplotlib.pyplot as plt
    import calltree as ct
    import os

    data_dir = "../test_data"
    inpfilename = os.path.join(data_dir, "profile-5m-nproc40-nsteps10.cubex")
    metric = "time"
    exclincl = False

    rootfuncname = "ns3d_"

    ### Processing

    # Reading, parsing and loading data in the cubex file
    output_i = mg.process_cubex(inpfilename, exclusive=exclincl)

    call_tree = output_i.ctree

    func_node = next(node for node in ct.iterate_on_call_tree(call_tree)
                     if node.fname == rootfuncname)

    children_info = [
        node.fname + "," + str(node.cnode_id)
        for node in ct.iterate_on_call_tree(func_node, 1)
    ]

    # We convert the Cnode IDs to short callpaths in the dataframe.
    df_i = ic.convert_index(output_i.df,
                            output_i.ctree_df,
                            target="Short Callpath")
Example #5
0
    import merger as mg
    import index_conversions as ic
    import pandas as pd

    from sys import argv

    # This gives us a number of outputs
    # (see https://cupybe.readthedocs.io/en/latest/merger.html)

    if len(argv) == 1:
        input_file = "../test_data/profile.cubex"
    else:
        input_file = argv[1]
        print("Opening file", input_file)

    output_i = mg.process_cubex(input_file, exclusive=False)

    df_i = output_i.df  # Dataframes with the metrics

    tree = output_i.ctree_df  # Dataframe containing info on the calltree

    # We convert the Cnode IDs to short callpaths in the dataframe.
    df_i = ic.convert_index(df_i, tree, target="Short Callpath")

    # We calculate the mean of the time
    times_mean = df_i.time.groupby("Short Callpath").mean()

    # We do a merge (=join) on the tree dataframe to find the parent-child relation
    parent_child = (
        pd.merge(
            left=tree,
Example #6
0
#!/usr/bin/env python3
'''
Just a test to see that everything runs correctly.
'''
import glob
import merger as mg
from sys import argv
import logging
files = glob.glob(f'{argv[1]}/*/profile.cubex')

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
print("Processing single dump")
res = mg.process_cubex(files[0])
print("Calltree:")
print(res.ctree)
print("Metrics:")
print(res.df)

print("Processing multiple dump")

output = mg.process_multi(files)
print("Common metrics to all the profile files:")
print(output.common)
print("Metrics specific to single profile files:")
print(output.noncommon)
Example #7
0
#!/usr/bin/env python3
import merger as mg
import index_conversions as ic
import pandas as pd

# This gives us a number of outputs 
# (see https://pycubelib.readthedocs.io/en/latest/merger.html)
output_i = mg.process_cubex('../test_data/profile.cubex', exclusive=False)

df_i = output_i.df # Dataframes with the metrics

tree = output_i.ctree_df # Dataframe containing info on the calltree

# We convert the Cnode IDs to short callpaths in the dataframe.
df_i = ic.convert_index(
        df_i,
        tree,
        target = 'Short Callpath')

# We calculate the mean of the time
times_mean = df_i.time.groupby('Short Callpath').mean().rename('mean')

# We get a measure of imbalance between threads 
times_max = df_i.time.groupby('Short Callpath').max()
times_min = df_i.time.groupby('Short Callpath').min()
times_imbalance = ((times_max - times_min)/times_mean).rename('imbalance')

# We do a merge (=join) on the tree dataframe to find the parent-child relation 
parent_child = ( pd.merge(left=tree,                     #
                          right=tree,                    #
                          left_on='Cnode ID',            #