Exemplo n.º 1
0

@schedule
def mul(a, b):
    return a*b


@schedule
def my_sum(a, buildin_sum=sum):
    return buildin_sum(a)


# a bit more complicated example
# -------------------------------
r1 = add(1, 1)
r2 = sub(3, r1)


def foo(a, b, c):
    return mul(add(a, b), c)


multiples = [foo(i, r2, r1) for i in range(6)]

r5 = my_sum(gather(*multiples))

draw_workflow("graph-example2.svg", r5)
answer = run_parallel(r5, 4)

print("The answer is: {0}".format(answer))
Exemplo n.º 2
0
from noodles import schedule
from prototype import draw_workflow


@schedule
def f(a, b):
    return a + b


@schedule
def g(a, b):
    return a - b


@schedule
def h(a, b):
    return a * b


# run example program
# --------------------
u = f(5, 4)
v = g(u, 3)
w = g(u, 2)
x = h(v, w)

# draw the execution graph
# -------------------------
draw_workflow("callgraph.png", x)
Exemplo n.º 3
0
from noodles import schedule
from prototype import draw_workflow


@schedule
def f(a, b):
    return a+b


@schedule
def g(a, b):
    return a-b


@schedule
def h(a, b):
    return a*b


# run example program
# --------------------
u = f(5, 4)
v = g(u, 3)
w = g(u, 2)
x = h(v, w)


# draw the execution graph
# -------------------------
draw_workflow("callgraph.png", x)