Beispiel #1
0
def main():
    R = Region([4], fspace)
    for field_name in R.keys():
        legion.fill(R, field_name, 0)
    inc(R, 20)
    check(R, 20)
    mul(R, 3)
    check_except_c128(R, 60)
Beispiel #2
0
        colors.rect[tile] = (
            [idx[0]*n[0]/nt[0], clamp((idx[1]+direction)*RADIUS, 0, nt[1]*RADIUS)],
            [(idx[0]+1)*n[0]/nt[0] - 1, clamp((idx[1]+1+direction)*RADIUS - 1, -1, nt[1]*RADIUS - 1)])
    kind = disjoint_complete if direction == 0 else disjoint_incomplete
    return Partition.image(points, colors_part, 'rect', tiles, kind)

_constant_time_launches = True
if _constant_time_launches:
    extern_task = legion.extern_task_wrapper
else:
    extern_task = legion.extern_task

stencil = extern_task(
    task_id=10001,
    argument_types=[Region, Region, Region, Region, Region, Region, legion.bool_],
    privileges=[RW, N, R('input'), R('input'), R('input'), R('input')],
    return_type=legion.void,
    calling_convention='regent')

increment = extern_task(
    task_id=10002,
    argument_types=[Region, Region, Region, Region, Region, Region, legion.bool_],
    privileges=[RW('input'), N, RW('input'), RW('input'), RW('input'), RW('input')],
    return_type=legion.void,
    calling_convention='regent')

check = extern_task(
    task_id=10003,
    argument_types=[Region, Region, legion.int64, legion.int64],
    privileges=[R, N],
    return_type=legion.void,
Beispiel #3
0
from legion import task, R, Region, RW, WD, N
import numpy

@task(privileges=[RW('x')])
def init_x(R):
    R.x.fill(123)

@task(privileges=[RW('y')])
def init_y(R):
    R.y.fill(456)

@task(privileges=[RW('x')])
def inc(R, step):
    numpy.add(R.x, step, out=R.x)

@task(privileges=[R('x', 'y')])
def check(R):
    assert numpy.all(R.x == 2035)
    assert numpy.all(R.y == 456)
    print('Test passed')

@task(privileges=[RW('x') + R('y')])
def saxpy(R, a):
    numpy.add(R.x, a * R.y, out=R.x)

@task
def main():
    R = Region([4, 4], {'x': legion.float64, 'y': legion.float64})
    legion.fill(R, 'x', 101)
    legion.fill(R, 'y', 102)
    init_x(R)
Beispiel #4
0
def main():
    assert R == R
    assert RW == RW
    assert WD == WD
    assert N == N
    assert Reduce('+') == Reduce('+')

    assert not (R == RW)
    assert not (R == WD)
    assert not (R == N)
    assert not (R == Reduce('+'))

    assert R != RW
    assert R != WD
    assert R != N
    assert Reduce('+') != Reduce('*')

    assert not (R != R)
    assert not (RW != RW)
    assert not (WD != WD)
    assert not (N != N)

    assert R('x') == R('x')
    assert R('x') != R('y')
    assert R('x') != R

    assert R + R == R
    assert R + RW == RW
    assert R + WD == WD

    assert not (R + RW == R)

    assert R('x') + R('y') == R('x', 'y')
    assert R('x') + R('y') != R('y', 'x')

    assert R('x', 'y') + RW('y') == R('x') + RW('y')
    assert R('x') + RW('x', 'y') == RW('x', 'y')

    assert R + Reduce('+') == RW
    assert Reduce('+') + Reduce('*') == RW
    assert Reduce('+') + WD == WD

    assert R('x', 'y') + Reduce('+', 'y', 'z') == R('x') + RW('y') + Reduce(
        '+', 'z')

    print(R('x'))
    print(R('x') + RW('y'))
    print(RW('x') + RW('y'))
Beispiel #5
0
    argument_types=[Region, Region, Region, Region],
    privileges=[N, N, N,
                RW('mapsp1', 'mapsp1_r', 'mapsp2', 'mapsp2_r')],
    return_type=legion.void,
    calling_convention='regent')

init_mesh_zones = extern_task(task_id=10005,
                              argument_types=[Region],
                              privileges=[RW('zx_x', 'zx_y', 'zarea', 'zvol')],
                              return_type=legion.void,
                              calling_convention='regent')

init_side_fracs = extern_task(
    task_id=10006,
    argument_types=[Region, Region, Region, Region],
    privileges=[R('zarea'), N, N,
                R('mapsz', 'sarea') + RW('smf')],
    return_type=legion.void,
    calling_convention='regent')

init_hydro = extern_task(
    task_id=10007,
    argument_types=[
        Region, legion.float64, legion.float64, legion.float64, legion.float64,
        legion.float64, legion.float64, legion.float64, legion.float64
    ],
    privileges=[
        R('zx_x', 'zx_y', 'zvol') + RW('zr', 'ze', 'zwrate', 'zm', 'zetot')
    ],
    return_type=legion.void,
    calling_convention='regent')
Beispiel #6
0
init_pointers = legion.extern_task(
    task_id=10003,
    argument_types=[Region, Region, Region, Region],
    privileges=[N, N, N,
                RW('in_ptr', 'in_ptr_r', 'out_ptr', 'out_ptr_r')],
    return_type=legion.void,
    calling_convention='regent')

calculate_new_currents = legion.extern_task(
    task_id=10004,
    argument_types=[
        legion.bool_, legion.uint32, Region, Region, Region, Region
    ],
    privileges=[
        None, None,
        R('node_voltage'),
        R('node_voltage'),
        R('node_voltage'),
        R('in_ptr', 'in_ptr_r', 'out_ptr', 'out_ptr_r', 'inductance',
          'resistance', 'wire_cap') +
        RW(*['current_%d' % i
             for i in range(10)]) + RW(*['voltage_%d' % i for i in range(9)])
    ],
    return_type=legion.void,
    calling_convention='regent')

distribute_charge = legion.extern_task(
    task_id=10005,
    argument_types=[Region, Region, Region, Region],
    privileges=[
        Reduce('+', 'charge'),
Beispiel #7
0
def mul(R, fact):
    for field_name, field in R.items():
        numpy.multiply(field, fact, out=field)
Beispiel #8
0
def check_except_c128(R, expected):
    for field_name, field in R.items():
        print(field_name, field)
        assert field[0] == expected
Beispiel #9
0
def inc(R, step):
    for field_name, field in R.items():
        numpy.add(field, step, out=field)
Beispiel #10
0

@task(privileges=[Reduce('*', *fields_except_c128)])
def mul(R, fact):
    for field_name, field in R.items():
        numpy.multiply(field, fact, out=field)


@task(privileges=[R])
def check(R, expected):
    for field_name, field in R.items():
        print(field_name, field)
        assert field[0] == expected


@task(privileges=[R(*fields_except_c128)])
def check_except_c128(R, expected):
    for field_name, field in R.items():
        print(field_name, field)
        assert field[0] == expected


@task
def main():
    R = Region([4], fspace)
    for field_name in R.keys():
        legion.fill(R, field_name, 0)
    inc(R, 20)
    check(R, 20)
    mul(R, 3)
    check_except_c128(R, 60)
Beispiel #11
0
    c.task_graph_execute_point_scratch(graph, timestep, point, output_ptr,
                                       output_size, input_ptrs, input_sizes,
                                       len(inputs), scratch_ptr, scratch_size)


# Hack: Not sure it's possible to generate these programmatically, so
# until Legion supports variadic tasks this is what we have to do.

if use_native:
    execute_point_task_0_0 = legion.extern_task(
        task_id=2,
        argument_types=[
            task_graph, legion.uint32, legion.int32, legion.int32, Region
        ] + [Region] * 0,
        privileges=[None, None, None, None, RW('1')] + [R('0')] * 0,
        calling_convention='regent')
    execute_point_task_0_1 = legion.extern_task(
        task_id=3,
        argument_types=[
            task_graph, legion.uint32, legion.int32, legion.int32, Region
        ] + [Region] * 1,
        privileges=[None, None, None, None, RW('1')] + [R('0')] * 1,
        calling_convention='regent')
    execute_point_task_0_2 = legion.extern_task(
        task_id=4,
        argument_types=[
            task_graph, legion.uint32, legion.int32, legion.int32, Region
        ] + [Region] * 2,
        privileges=[None, None, None, None, RW('1')] + [R('0')] * 2,
        calling_convention='regent')
Beispiel #12
0
                RW('mapsp1', 'mapsp1_r', 'mapsp2', 'mapsp2_r'), R],
    return_type=legion.void,
    calling_convention='regent')

init_mesh_zones = legion.extern_task(
    task_id=10013,
    argument_types=[Region, Region],
    privileges=[RW('zx_x', 'zx_y', 'zarea', 'zvol'), R],
    return_type=legion.void,
    calling_convention='regent')

calc_centers_full = legion.extern_task(
    task_id=10014,
    argument_types=[Region, Region, Region, Region, Region, legion.bool_],
    privileges=[
        R('znump') + RW('zx_x', 'zx_y'),
        R('px_x', 'px_y'),
        R('px_x', 'px_y'),
        R('mapsz', 'mapsp1', 'mapsp1_r', 'mapsp2', 'mapsp2_r') +
        RW('ex_x', 'ex_y'), R
    ],
    return_type=legion.void,
    calling_convention='regent')

calc_volumes_full = legion.extern_task(
    task_id=10015,
    argument_types=[Region, Region, Region, Region, Region, legion.bool_],
    privileges=[
        R('zx_x', 'zx_y', 'znump') + RW('zarea', 'zvol'),
        R('px_x', 'px_y'),
        R('px_x', 'px_y'),
Beispiel #13
0
    calling_convention='regent')

init_pointers = extern_task(
    task_id=10003,
    argument_types=[Region, Region, Region, Region],
    privileges=[N, N, N, RW('in_ptr', 'in_ptr_r', 'out_ptr', 'out_ptr_r')],
    return_type=legion.void,
    calling_convention='regent')

calculate_new_currents = extern_task(
    task_id=10004,
    argument_types=[legion.bool_, legion.uint32, Region, Region, Region, Region],
    privileges=[
        None,
        None,
        R('node_voltage'),
        R('node_voltage'),
        R('node_voltage'),
        R('in_ptr', 'in_ptr_r', 'out_ptr', 'out_ptr_r', 'inductance', 'resistance', 'wire_cap') + RW(*['current_%d' % i for i in range(10)]) + RW(*['voltage_%d' % i for i in range(9)])],
    return_type=legion.void,
    calling_convention='regent')

distribute_charge = extern_task(
    task_id=10005,
    argument_types=[Region, Region, Region, Region],
    privileges=[
        Reduce('+', 'charge'),
        Reduce('+', 'charge'),
        Reduce('+', 'charge'),
        R('in_ptr', 'in_ptr_r', 'out_ptr', 'out_ptr_r', 'current_0', 'current_9')],
    return_type=legion.void,