예제 #1
0
def deptest_cm_ic():
    print("CM-IC Test")
    # Dimensions
    dim  = 2
    # Type of dimensions
    dim_type = [1, 2]

    # code-motion 
    alp1  = [['e', 'r1', 't1'], ['e', 'r2l', 'r2r', 's1']]
    ord1  = [['e', 't1', 'r1'], ['e', 'r2l', 'r2r', 's1']]
    ord2  = [['e', 't1', 'r1'], ['e', 's1', 'r2l', 'r2r']]

    xform1 = Transformation(
        name         = 'cm',
        in_dim       = dim,
        out_dim      = dim,
        in_dim_type  = dim_type,
        in_alp       = alp1,
        in_ord       = ord1,
        out_ord      = ord2)
    
    # interchange
    dim1_ = 0
    dim2_ = 1
    
    xform2 = Transformation(
        name         ='ic',
        in_dim       = xform1.out_dim,
        out_dim      = xform1.out_dim,
        in_dim_type  = xform1.out_dim_type,
        in_alp       = xform1.out_alp,
        in_ord       = xform1.out_ord,
        dim_i1       = dim1_,
        dim_i2       = dim2_)
    
    xform = xform1.compose(xform2)
    
    # regex for witness tuple    
    rgx1 = [['t1'], ['s1']]
    rgx2 = [['r1', 't1'], ['(r2l|r2r)', 's1']]
    
    wtuple1 = WitnessTuple(dim, dim_type, alp1, ord1, rgx1, rgx2)
    wtuple1.set_fsa()

    Dep1 = Dependence(wtuple1)

    print("Tuple1: ", Dep1.test(xform))
    
    rgx3 = [['t1'], ['(r2l|r2r)', 's1']]
    rgx4 = [['t1'], ['s1']]
    
    wtuple2 = WitnessTuple(dim, dim_type, alp1, ord1, rgx3, rgx4)
    wtuple2.set_fsa()

    Dep2 = Dependence(wtuple2)

    print("Tuple2: ", Dep2.test(xform))
예제 #2
0
def deptest_cm_ic(filename):
    print("CM-IC Test")
    with open(filename, "r") as source:
        # reading the c file
        parser = c_parser.CParser()
        astc = parser.parse(source.read())
        # convert to python
        pysrc = CtoPy(astc)
        tree = ast.parse(pysrc.getPy())
        analyze = Analyze(tree)
        xform = Transform(analyze)
        # Input program
        print("\nInput Program")
        print(xform.codegen())
        # Dimensions
        in_dim  = xform.analyze.dims
        out_dim = in_dim
        # Type of dimensions
        in_dim_type = xform.analyze.getdimtype()
        # Input alphabet and order
        in_alp = xform.analyze.getalp()
        in_ord = xform.analyze.getord()
        # Output order
        out_ord = [['e', 't1', 'r1'], ['e', 's1', 'r2l', 'r2r']]
        
        xf1 = Transformation(
            name         = 'cm',
            in_dim       = in_dim,
            out_dim      = out_dim,
            in_dim_type  = in_dim_type,
            in_alp       = in_alp,
            in_ord       = in_ord,
            out_ord      = out_ord)

        # interchange
        dim1_ = 0
        dim2_ = 1

        xf2 = Transformation(
            name         ='ic',
            in_dim       = xf1.out_dim,
            out_dim      = xf1.out_dim,
            in_dim_type  = xf1.out_dim_type,
            in_alp       = xf1.out_alp,
            in_ord       = xf1.out_ord,
            dim_i1       = dim1_,
            dim_i2       = dim2_)

        xf = xf1.compose(xf2)

        xform.analyze.depanalyze()
        
        print(xform.analyze.deps)
        for i, wt in enumerate(xform.analyze.deps):
            Dep = Dependence(wt)
            print("Witness Tuple", i, ": ", Dep.test(xf))
예제 #3
0
def deptest():
    # Dimensions
    dim = 2
    # Type of dimensions
    dim_type = [1, 2]

    # code-motion
    alp1 = [['e', 'r1', 't1'], ['e', 'r2l', 'r2r', 's1']]
    ord1 = [['e', 't1', 'r1'], ['e', 'r2l', 'r2r', 's1']]
    ord2 = [['e', 't1', 'r1'], ['e', 's1', 'r2l', 'r2r']]

    xform1 = Transformation(name='cm',
                            in_dim=dim,
                            out_dim=dim,
                            in_dim_type=dim_type,
                            in_alp=alp1,
                            in_ord=ord1,
                            out_ord=ord2)

    # Strip Mining
    strip_dim = 0
    strip_size = 2

    xform2 = Transformation(name='sm',
                            in_dim=xform1.out_dim,
                            out_dim=xform1.out_dim + 1,
                            in_dim_type=xform1.out_dim_type,
                            in_alp=xform1.out_alp,
                            in_ord=xform1.out_ord,
                            dim_strip=strip_dim,
                            strip_size=strip_size)

    # Interchange
    dim1_ = 1
    dim2_ = 2

    xform3 = Transformation(name='ic',
                            in_dim=xform2.out_dim,
                            out_dim=xform2.out_dim,
                            in_dim_type=xform2.out_dim_type,
                            in_alp=xform2.out_alp,
                            in_ord=xform2.out_ord,
                            dim_i1=dim1_,
                            dim_i2=dim2_)

    # Inline
    dim_il = 1
    call_il = 1
    label_il = 'l'

    xform4 = Transformation(name='il',
                            in_dim=xform3.out_dim,
                            out_dim=xform3.out_dim,
                            in_dim_type=xform3.out_dim_type,
                            in_alp=xform3.out_alp,
                            in_ord=xform3.out_ord,
                            dim_inline=dim_il,
                            call_inline=call_il,
                            label=label_il)

    xform = xform1.compose(xform2).compose(xform3).compose(xform4)

    # regex for witness tuple
    rgx1 = [['t1'], ['s1']]
    rgx2 = [['r1', '(r1)*', 't1'], ['s1']]

    print("suffix1: ", rgx1)
    print("suffix2: ", rgx2)

    wtuple = WitnessTuple(dim, dim_type, alp1, ord1, rgx1, rgx2)
    wtuple.set_fsa()

    Dep = Dependence(wtuple)

    print("Input Program")
    xform.input_program()
    print("Output Program")
    xform.output_program()

    if Dep.test(xform):
        print("Dependence is preserved")
    else:
        print("Dependence is broken")
예제 #4
0
def trans():
    # Dimensions
    dim = 2
    # Type of dimensions
    dim_type = [1, 2]

    # code-motion
    alp1 = [['e', 'r1', 't1'], ['e', 'r2l', 'r2r', 's1']]
    ord1 = [['e', 't1', 'r1'], ['e', 'r2l', 'r2r', 's1']]
    ord2 = [['e', 't1', 'r1'], ['e', 's1', 'r2l', 'r2r']]

    xform1 = Transformation(name='cm',
                            in_dim=dim,
                            out_dim=dim,
                            in_dim_type=dim_type,
                            in_alp=alp1,
                            in_ord=ord1,
                            out_ord=ord2)

    # Strip Mining
    strip_dim = 0
    strip_size = 2

    xform2 = Transformation(name='sm',
                            in_dim=xform1.out_dim,
                            out_dim=xform1.out_dim + 1,
                            in_dim_type=xform1.out_dim_type,
                            in_alp=xform1.out_alp,
                            in_ord=xform1.out_ord,
                            dim_strip=strip_dim,
                            strip_size=strip_size)

    # Interchange
    dim1_ = 1
    dim2_ = 2

    xform3 = Transformation(name='ic',
                            in_dim=xform2.out_dim,
                            out_dim=xform2.out_dim,
                            in_dim_type=xform2.out_dim_type,
                            in_alp=xform2.out_alp,
                            in_ord=xform2.out_ord,
                            dim_i1=dim1_,
                            dim_i2=dim2_)

    # Inline
    dim_il = 1
    call_il = 1
    label_il = 'l'

    xform4 = Transformation(name='il',
                            in_dim=xform3.out_dim,
                            out_dim=xform3.out_dim,
                            in_dim_type=xform3.out_dim_type,
                            in_alp=xform3.out_alp,
                            in_ord=xform3.out_ord,
                            dim_inline=dim_il,
                            call_inline=call_il,
                            label=label_il)

    xform = xform1.compose(xform2).compose(xform3).compose(xform4)

    xform.input_program()
    print("\nTransformation: ", xform.name)
    xform.output_program()
예제 #5
0
def deptest_cm_sm_ic_il():
    print("CM-SM-IC-IL Test")
    # Dimensions
    dim  = 2
    # Type of dimensions
    dim_type = [1, 2]

    # code-motion 
    alp1  = [['e', 'r1', 't1'], ['e', 'r2l', 'r2r', 's1']]
    ord1  = [['e', 't1', 'r1'], ['e', 'r2l', 'r2r', 's1']]
    ord2  = [['e', 't1', 'r1'], ['e', 's1', 'r2l', 'r2r']]

    xform1 = Transformation(
        name         = 'cm',
        in_dim       = dim,
        out_dim      = dim,
        in_dim_type  = dim_type,
        in_alp       = alp1,
        in_ord       = ord1,
        out_ord      = ord2)

    # Strip Mining
    strip_dim  = 0
    strip_size = 2

    xform2 = Transformation(
        name        = 'sm',
        in_dim      = xform1.out_dim,
        out_dim     = xform1.out_dim+1,
        in_dim_type = xform1.out_dim_type,
        in_alp      = xform1.out_alp,
        in_ord      = xform1.out_ord,
        dim_strip   = strip_dim,
        strip_size  = strip_size)

    # Interchange
    dim1_ = 1
    dim2_ = 2
    
    xform3 = Transformation(
        name         ='ic',
        in_dim       = xform2.out_dim,
        out_dim      = xform2.out_dim,
        in_dim_type  = xform2.out_dim_type,
        in_alp       = xform2.out_alp,
        in_ord       = xform2.out_ord,
        dim_i1       = dim1_,
        dim_i2       = dim2_)

    # Inline
    dim_il   = 1
    call_il  = 1
    label_il = 'l'
    
    xform4 = Transformation(
        name        = 'il',
        in_dim      = xform3.out_dim,
        out_dim     = xform3.out_dim,
        in_dim_type = xform3.out_dim_type,
        in_alp      = xform3.out_alp,
        in_ord      = xform3.out_ord,
        dim_inline  = dim_il,
        call_inline = call_il,
        label       = label_il)

    xform = xform1.compose(xform2).compose(xform3).compose(xform4)
    
    # regex for witness tuple    
    rgx1 = [['t1'], ['s1']]
    rgx2 = [['r1', '(r1)*', 't1'], ['s1']]
    
    wtuple = WitnessTuple(dim, dim_type, alp1, ord1, rgx1, rgx2)
    wtuple.set_fsa()

    Dep = Dependence(wtuple)

    print(Dep.test(xform))