def main(): R = Region([4], fspace) for field_name in R.keys(): pygion.fill(R, field_name, 0) inc(R, 20) check(R, 20) mul(R, 3) check_except_c128(R, 60)
def check_except_c128(R, expected): for field_name, field in R.items(): print(field_name, field) assert field[0] == expected
def inc(R, step): for field_name, field in R.items(): numpy.add(field, step, out=field)
def mul(R, fact): for field_name, field in R.items(): numpy.multiply(field, fact, out=field)
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 = pygion.extern_task_wrapper else: extern_task = pygion.extern_task stencil = extern_task( task_id=10001, argument_types=[ Region, Region, Region, Region, Region, Region, pygion.bool_ ], privileges=[RW, N, R('input'), R('input'), R('input'), R('input')], return_type=pygion.void, calling_convention='regent') increment = extern_task(task_id=10002, argument_types=[ Region, Region, Region, Region, Region, Region, pygion.bool_ ], privileges=[ RW('input'), N, RW('input'), RW('input'),
@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(): pygion.fill(R, field_name, 0) inc(R, 20) check(R, 20) mul(R, 3) check_except_c128(R, 60)
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'))
argument_types=[Region, Region, Region, Region], privileges=[N, N, N, RW('mapsp1', 'mapsp1_r', 'mapsp2', 'mapsp2_r')], return_type=pygion.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=pygion.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=pygion.void, calling_convention='regent') init_hydro = extern_task( task_id=10007, argument_types=[ Region, pygion.float64, pygion.float64, pygion.float64, pygion.float64, pygion.float64, pygion.float64, pygion.float64, pygion.float64 ], privileges=[ R('zx_x', 'zx_y', 'zvol') + RW('zr', 'ze', 'zwrate', 'zm', 'zetot') ], return_type=pygion.void, 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=pygion.void, calling_convention='regent') calculate_new_currents = extern_task( task_id=10004, argument_types=[ pygion.bool_, pygion.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=pygion.void, calling_convention='regent') distribute_charge = extern_task( task_id=10005, argument_types=[Region, Region, Region, Region], privileges=[ Reduce('+', 'charge'),
RW('mapsp1', 'mapsp1_r', 'mapsp2', 'mapsp2_r'), R], return_type=pygion.void, calling_convention='regent') init_mesh_zones = pygion.extern_task( task_id=10013, argument_types=[Region, Region], privileges=[RW('zx_x', 'zx_y', 'zarea', 'zvol'), R], return_type=pygion.void, calling_convention='regent') calc_centers_full = pygion.extern_task( task_id=10014, argument_types=[Region, Region, Region, Region, Region, pygion.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=pygion.void, calling_convention='regent') calc_volumes_full = pygion.extern_task( task_id=10015, argument_types=[Region, Region, Region, Region, Region, pygion.bool_], privileges=[ R('zx_x', 'zx_y', 'znump') + RW('zarea', 'zvol'), R('px_x', 'px_y'), R('px_x', 'px_y'),
_constant_time_launches = True if _constant_time_launches: extern_task = pygion.extern_task # extern_task = pygion.extern_task_wrapper else: extern_task = pygion.extern_task stencil = extern_task( task_id=10001, argument_types=[ Region, Region, Region, Region, Region, Region, Region, pygion.bool_ ], privileges=[RW, N, R('input'), R('input'), R('input'), R('input'), RW], return_type=pygion.void, calling_convention='regent') increment = extern_task(task_id=10002, argument_types=[ Region, Region, Region, Region, Region, Region, Region, pygion.bool_ ], privileges=[ RW('input'), N, RW('input'), RW('input'),
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=pygion.void, calling_convention='regent') calculate_new_currents = extern_task( task_id=10004, argument_types=[pygion.bool_, pygion.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=pygion.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=pygion.void,
@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': pygion.float64, 'y': pygion.float64}) pygion.fill(R, 'x', 101)