Ejemplo n.º 1
0
from __future__ import with_statement  # this is to work with python2.5
# convertion of Semantics/all04.tpips into pyps
# tests usage of capply
from pyps import workspace, module
with workspace('capply01.f', deleteOnClose=True) as w:
    print " Initial code with preconditions for ALL04 after cleanup"
    w.activate(module.transformers_inter_full)
    w.activate("interprocedural_summary_precondition")
    w.activate(module.preconditions_inter_full)
    w.activate(module.print_code_cumulated_effects)

    w.all.display()
    # there is a capply there
    w.all.partial_eval(concurrent=True)
    w.all.display()
    # and there
    w.all.suppress_dead_code(concurrent=True)
    w.all.display()
Ejemplo n.º 2
0
from __future__ import with_statement
from pyps import workspace, module
with workspace("min01.c") as w:
    w.fun.ening.display(module.print_code_regions)

Ejemplo n.º 3
0
from __future__ import with_statement  # this is to work with python2.5
from pyps import workspace

with workspace('include.c', name='include', deleteOnClose=True) as ws:
    pass
Ejemplo n.º 4
0
from __future__ import with_statement
from pyps import workspace, module
from glob import glob
with workspace(*(glob("*s.c") + ["wtime.c"]), name='common') as w:
    w.activate(module.must_regions)
    w.all_functions.display()
    w.all_functions.print_code_proper_effects()
    w.all_functions.print_code_cumulated_effects()
    w.all_functions.print_code_transformers()
    w.all_functions.print_code_preconditions()
    w.all_functions.print_code_regions()
Ejemplo n.º 5
0
import pyps
import os
pyps.workspace.delete("basics4")
w = pyps.workspace("basics3.c", name="basics4", deleteOnClose=True)
m = w.fun.main
print m.cu
print m.workspace.name
print m.name
m.edit(editor="sed -i 's/h/b/'")
m.display()
m.run(["sed", "s/b/c/"])
m.display()
m.show("PRINTED_FILE")
print str(m.code)
m.display()
m.code = """int main() {
for(int j=0;j<10;j++)
for(int k=0;k>-6;k--)
puts("ah");
}
"""
m.display()
for i in m.loops():
    print i.label
for i in m.inner_loops():
    print i.label
map(pyps.modules.display, m.callers)
map(pyps.modules.display, m.callees)

m.saveas(os.path.join(w.tmpdirname, "a.c"))
w.close()
Ejemplo n.º 6
0
from pyps import workspace
workspace.delete("bb")
workspace("a a a /spaces01.c", name="bb",
          recoverInclude=False).fun.main.display()
Ejemplo n.º 7
0
from __future__ import with_statement
import pyps
pyps.workspace.delete("unfolding10")
with pyps.workspace("unfolding10.c", name="unfolding10",
                    deleteOnClose=True) as w:
    w.fun.main.display()
    w.fun.main.outline(label=w.fun.main.loops(1).loops(0).label,
                       module_name="new")
    w.fun.main.display()
    w.fun.new.display()
    w.fun.new.unfolding()
    w.fun.new.display()
Ejemplo n.º 8
0
import pyps

w = pyps.workspace('scope01.c')

r = w.fun.Run

print "******** Without points-to analysis ********"

r.privatize_module()
r.coarse_grain_parallelization()
r.display()

print "******** With points-to analysis ********"

w.activate("proper_effects_with_points_to")
r.privatize_module()
r.coarse_grain_parallelization()
r.display()
Ejemplo n.º 9
0
from __future__ import with_statement # this is to work with python2.5
from pyps import workspace, module

def invoke_function(fu, ws):
	return fu._get_code(activate = module.{{template_module}})

if __name__=="__main__":
	workspace.delete('{{template_name}}')
	with workspace('{{template_name}}.c',name='{{template_name}}',deleteOnClose=True) as ws:
		for fu in ws.fun:
			print invoke_function(fu, ws)

Ejemplo n.º 10
0
#!/usr/bin/env python
from pyps import workspace
import binary_size

w = workspace("func_size.c", verbose=False, deleteOnClose=True) 
t= w.fun.muladd

(s,c) = t.binary_size()
# reference is on Linux 32bit Debian Sid
th_c = 31;
if c < th_c - 20 or c > th_c + 20:
	# This can happen for many reasons (including good ones).
	# say with gcc 4.8 on ubuntu trusty 64 bits: changed limit from 16 to 20
	print "Instruction count " + str(c) + " is far from the reference instruction count " + str(th_c)
else:
	print "Instruction count ok"

if s < 10 or s > 1000:
	#This can happen for many reasons (including good ones).
	print "Binary size " + str(s) + " is either very huge or very small"
else:
	print "Binary size ok"
Ejemplo n.º 11
0
from __future__ import with_statement  # this is to work with python2.5
from pyps import workspace

with workspace('exception.c', name='exception', deleteOnClose=True) as ws:
    try:
        ws0 = workspace(['exception.c'], name='exception')
    except RuntimeError:
        print "grrrrr, same workspace"
Ejemplo n.º 12
0
from pyps import workspace

# Create an empty workspace 
w = workspace();

w.add_source("add_source2.c");
w.fun.source2.display()
Ejemplo n.º 13
0
import pyps
from sys import argv
if len(argv) == 1:
    # this source include a main() with a call to foo() ; but foo() isn't defined !
    w = pyps.workspace("broker01.c")

    # We give a method to resolve missing module (here foo())
    w.props.preprocessor_missing_file_handling = "external_resolver"
    w.props.preprocessor_missing_file_generator = "python broker01.py"

    # We display with cumulated effects because we want callees to be computed
    w.fun.main.display(pyps.module.print_code_cumulated_effects)
else:
    # tricky, use the test file as a simple broker too :p
    print "foo.c"
Ejemplo n.º 14
0
from __future__ import with_statement
from pyps import workspace, module

#Deleting workspace
workspace.delete("hyantes")

#Creating workspace
w = workspace("hyantes/hyantes.c",
              "hyantes/options.c",
              cppflags='-Ihyantes',
              name="hyantes",
              deleteOnClose=True)

#Add some default property
w.props.abort_on_user_error = True

w.activate(module.region_chains)

w.props.constant_path_effects = False

w["hyantes!do_run_AMORTIZED_DISK"].privatize_module()

#Closing workspace
w.close()
Ejemplo n.º 15
0
from __future__ import with_statement  # this is to work with python2.5
from pyps import workspace

w = workspace("properties1.c", deleteOnClose=True)

# mandatory for A&K (Rice) parallization on C files
w.props.memory_effects_only = False

print str(w.props.OMP_MERGE_POLICY)
print str(w.props.PRETTYPRINT_SEQUENTIAL_STYLE)

w.props.PRETTYPRINT_SEQUENTIAL_STYLE = "do"
w.props.OMP_MERGE_POLICY = "inner"

#Here we expect to have some update properites and this should
#work
print str(w.props.OMP_MERGE_POLICY)
print str(w.props.PRETTYPRINT_SEQUENTIAL_STYLE)

#Get foo function
main = w.fun.main

main.privatize_module()
main.flag_parallel_reduced_loops_with_openmp_directives()
main.internalize_parallel_code()
main.ompify_code()

# The merge_pragma work differently depending on the property OMP_MERGE_POLICY
# Here we set the property to "inner" but the value seen from the phase is still
# "outer" which is the default value. As a consequence the pragma are merge on
# the outer loop and not on the inner loop as expected.
Ejemplo n.º 16
0
from __future__ import with_statement # this is to work with python2.5
from pyps import workspace, module
with workspace("string06.c",deleteOnClose=True) as w:
    map(module.display,w.fun)
Ejemplo n.º 17
0
from __future__ import with_statement
from pyps import workspace
wname = "float02"
with workspace(wname + ".c",
               name=wname,
               deleteOnCLose=True,
               deleteOnCreate=True) as w:
    w.fun.main.display()
Ejemplo n.º 18
0
from pyps import workspace

with workspace("duplicate.c","duplicate/duplicate.c", recoverInclude=False, preprocessor_file_name_conflict_handling=True) as w:
    print ":".join([f.name for f in w.fun])

Ejemplo n.º 19
0
from __future__ import with_statement  # this is to work with python2.5
from pyps import workspace
with workspace("properties0.c", verbose=False, deleteOnClose=True) as w:
    print w.props.MUST_REGIONS
    w.props["MUST_REGIONS"] = not w.props["MUST_REGIONS"]
    print w.props.must_regions
Ejemplo n.º 20
0
#! /usr/bin/env python

# grrr...
from __future__ import print_function

from pyps import workspace

with workspace('hello_world.c', recoverInclude=True, deleteOnClose=True) as w:
    # save does some post-filtering to recover includes
    w.save()
    f = open(w.tmpdirname + '/hello_world.c')
    for l in f.readlines():
        print(l, end='')
    f.close()
Ejemplo n.º 21
0
# test vectorization when the vector size is equal to that of a member : no vectorization in that case
from __future__ import with_statement
from pyps import workspace
with workspace("simdizer10.c", "include/SIMD.c") as w:
    try:
        w.fun.foo_l.simdizer(sac_simd_register_width=64)
        print "should not be reached"
    except:
        w.fun.foo_l.display()
        w.fun.foo_l.simdizer(sac_simd_register_width=128)
        w.fun.foo_l.display()
Ejemplo n.º 22
0
from __future__ import with_statement  # this is to work with python2.5
from pyps import workspace, module
import p3

with workspace("pragma0.c", deleteOnClose=True) as w:
    w.fun.transfo.display()
    w.all.p3()
    w.fun.transfo.display()
Ejemplo n.º 23
0
from __future__ import with_statement  # this is to work with python2.5
#!/usr/bin/env python

# import everything so that a session looks like tpips one
from pyps import workspace
import shutil, os

# a worspace ID is automagically created ... may be not a good feature
# the with statements ensure correct code cleaning
with workspace("basics0.c", deleteOnClose=True) as w:

    # you can get module object from the modules table
    foo = w.fun.foo
    bar = w.fun.bar
    malabar = w.fun.malabar
    mb = w["megablast"]

    # and apply transformation to modules
    foo.inlining(callers="bar", use_initialization_list=False)

    #the good old display, default to PRINTED_FILE, but you can give args
    foo.display()
    bar.display()
    malabar.display()
    bar.print_code()

    # you can also preform operations on loops
    mb.display(rc="loops_file")
    for l in mb.loops():
        l.unroll(rate=2)
    mb.display()
Ejemplo n.º 24
0
from pyps import workspace

# Create a workspace
w = workspace('add_source1.c')

w.fun.main.display()

w.add_source("add_source2.c")
w.fun.source2.display()
from __future__ import with_statement  # this is to work with python2.5

# Here we add an example for interacting with PoCC
# it requires that polycc is in the PATH
# we can't run it in the validation because PoCC isn't installed

from pyps import workspace
import pocc

with workspace("pocc_example.c", name="poly", deleteOnCreate=True) as w:
    w.all_functions.poccify()
    w.fun.main.display()
from __future__ import with_statement  # this is to work with python2.5
from pyps import workspace
with workspace("loops_loops_loops.c", verbose=False, deleteOnClose=True) as w:
    m = w.fun.looping

    print "= first level loops"
    for l0 in m.loops():
        print l0.label

    print "= second level loops"
    for l0 in m.loops():
        print "== loops of", l0.label
        for l1 in l0.loops():
            print l1.label

    print "= third level loops"
    for l0 in m.loops():
        for l1 in l0.loops():
            print "== loops of", l1.label
            for l2 in l1.loops():
                print l2.label
    m.loops("l99995")
    m.display()
Ejemplo n.º 27
0
 def get_workspace(self, c_files):
     return pyps.workspace(*c_files)
from __future__ import with_statement # this is to work with python2.5
from pyps import workspace
from sac import workspace as sac_workspace
from os import remove
filename="biquad_N_sections"
with workspace(filename+".c", parents=[sac_workspace], driver="sse",deleteOnClose=True) as w:
	m=w.fun.main
	m.display()
	m.sac()
	m.display()
	a_out=w.simd_compile(rep="d.out")
	remove(a_out)

import os
from pyps import workspace

w = workspace("recoverInclude0.c",
              cppflags="-Iinclude",
              deleteOnClose=True,
              name="recoverInclude0")
(sources, headers) = w.save()
print sources
print headers
for i in sources:
    os.system(os.getenv("PAGER", "cat") + " " + i)

w.close()
Ejemplo n.º 30
0
from __future__ import with_statement  # this is to work with python2.5
#!/usr/bin/env python

import sys, os, shutil

from pyps import workspace

with workspace("effects.c", name="effects", deleteOnClose=True) as ws:
    ws.props.ABORT_ON_USER_ERROR = True

    print "cumulated effects on only one function"
    fct = ws.fun.add_comp
    fct.print_code_cumulated_effects()
    fct.display()