def main(): assert R == R assert RW == RW assert WD == WD assert N == N assert Reduce('+') == Reduce('+') assert R != RW assert R != WD assert R != N assert Reduce('+') != Reduce('*') 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 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'))
return_type=legion.void, calling_convention='regent') calc_rho_half = extern_task(task_id=10015, argument_types=[Region, legion.bool_], privileges=[R('zvolp', 'zm') + RW('zrp')], return_type=legion.void, calling_convention='regent') sum_point_mass = extern_task( task_id=10016, argument_types=[Region, Region, Region, Region, legion.bool_], privileges=[ R('zareap', 'zrp'), RW('pmaswt'), Reduce('+', 'pmaswt'), R('mapsz', 'mapsp1', 'mapsp1_r', 'mapss3', 'smf') ], return_type=legion.void, calling_convention='regent') calc_state_at_half = extern_task( task_id=10017, argument_types=[ Region, legion.float64, legion.float64, legion.float64, legion.bool_ ], privileges=[ R('zvol0', 'zvolp', 'zm', 'zr', 'ze', 'zwrate') + RW('zp', 'zss') ], return_type=legion.void, calling_convention='regent')
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'), Reduce('+', 'charge'), Reduce('+', 'charge'), R('in_ptr', 'in_ptr_r', 'out_ptr', 'out_ptr_r', 'current_0', 'current_9') ], return_type=legion.void, calling_convention='regent') update_voltages = legion.extern_task( task_id=10006, argument_types=[legion.bool_, Region, Region], privileges=[ None, R('node_cap', 'leakage') + RW('node_voltage', 'charge'), R('node_cap', 'leakage') + RW('node_voltage', 'charge')
'i16': legion.int16, 'i32': legion.int32, 'i64': legion.int64, 'u16': legion.uint16, 'u32': legion.uint32, 'u64': legion.uint64, 'f32': legion.float32, 'f64': legion.float64, 'c64': legion.complex64, 'c128': legion.complex128, } fields_except_c128 = tuple(set(fspace.keys()) - set(['c128'])) @task(privileges=[Reduce('+')]) def inc(R, step): for field_name, field in R.items(): numpy.add(field, step, out=field) @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)
import data_collector from phaseret import InitialState, Phaser from phaseret.generator3D import Projection import pysingfel as ps ### ### Solver ### N_POINTS = 201 @task(privileges=[R, R, R, R, Reduce('+')], leaf=True) def preprocess(images, orientations, active, pixels, diffraction, voxel_length): print(f"Aligning {active.active[0]} events") for l in range(active.active[0]): ps.merge_slice( images.image[l], pixels.momentum, orientations.orientation[l], diffraction.accumulator, diffraction.weight, voxel_length, inverse=False) @task(privileges=[R, RW], leaf=True) def solve_step(diffraction, reconstruction, rank, iteration, hio_iter, hio_beta, er_iter, sw_thresh): numpy.seterr(invalid='ignore', divide='ignore') amplitude = numpy.nan_to_num(fft.ifftshift( (diffraction.accumulator + diffraction.accumulator[::-1,::-1,::-1])
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from __future__ import print_function import legion from legion import task, Region, Reduce import numpy @task(privileges=[Reduce('+')]) def inc(R, step): numpy.add(R.x, step, out=R.x) numpy.add(R.y, step, out=R.y) @task def main(): R = Region([4, 4], {'x': legion.float64, 'y': legion.int32}) legion.fill(R, 'x', 1.25) legion.fill(R, 'y', 2) inc(R, 20) print(R.x) print(R.y) assert R.x[0, 0] == 21.25 assert R.y[0, 0] == 22