From 0db2c6a440cefde24f091e5073d02d012d80172d Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Wed, 2 Oct 2019 18:53:14 +0100 Subject: [PATCH 1/2] Expunge across_dim_types from isl align_foo calls Was deprecated in islpy!13. --- loopy/codegen/loop.py | 6 ++---- loopy/kernel/__init__.py | 2 +- loopy/preprocess.py | 9 +++------ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/loopy/codegen/loop.py b/loopy/codegen/loop.py index 58f055b7b..128e4fbc8 100644 --- a/loopy/codegen/loop.py +++ b/loopy/codegen/loop.py @@ -364,8 +364,7 @@ def generate_sequential_loop_dim_code(codegen_state, sched_index): # {{{ find bounds - aligned_domain = isl.align_spaces(domain, slab, across_dim_types=True, - obj_bigger_ok=True) + aligned_domain = isl.align_spaces(domain, slab, obj_bigger_ok=True) dom_and_slab = aligned_domain & slab @@ -389,8 +388,7 @@ def generate_sequential_loop_dim_code(codegen_state, sched_index): impl_domain = isl.align_spaces( codegen_state.implemented_domain, dom_and_slab, - obj_bigger_ok=True, - across_dim_types=True + obj_bigger_ok=True ).params() lbound = ( diff --git a/loopy/kernel/__init__.py b/loopy/kernel/__init__.py index 42d7c0f1e..80a7ad031 100644 --- a/loopy/kernel/__init__.py +++ b/loopy/kernel/__init__.py @@ -633,7 +633,7 @@ class LoopKernel(ImmutableRecordWithoutPickling): result = dom else: aligned_dom, aligned_result = isl.align_two( - dom, result, across_dim_types=True) + dom, result) result = aligned_result & aligned_dom return result diff --git a/loopy/preprocess.py b/loopy/preprocess.py index 2afcd3db4..c08cbf46e 100644 --- a/loopy/preprocess.py +++ b/loopy/preprocess.py @@ -376,18 +376,15 @@ def _check_reduction_is_triangular(kernel, expr, scan_param): sweep_lower_bound = isl.align_spaces( scan_param.sweep_lower_bound, - affs[0], - across_dim_types=True) + affs[0]) sweep_upper_bound = isl.align_spaces( scan_param.sweep_upper_bound, - affs[0], - across_dim_types=True) + affs[0]) scan_lower_bound = isl.align_spaces( scan_param.scan_lower_bound, - affs[0], - across_dim_types=True) + affs[0]) from itertools import product -- GitLab From a910a3e0f11f13cfa39e1dbdd1c3e752917c98a0 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Thu, 3 Oct 2019 08:58:28 +0100 Subject: [PATCH 2/2] Squash deprecation warnings for scope -> address_space change --- loopy/preprocess.py | 4 ++-- loopy/transform/buffer.py | 2 +- loopy/transform/data.py | 2 +- loopy/transform/save.py | 2 +- test/test_apps.py | 14 ++++++++------ test/test_c_execution.py | 4 ++-- test/test_loopy.py | 16 ++++++++-------- test/test_reduction.py | 4 ++-- test/test_transform.py | 2 +- test/testlib.py | 3 +-- 10 files changed, 27 insertions(+), 26 deletions(-) diff --git a/loopy/preprocess.py b/loopy/preprocess.py index c08cbf46e..c0eb91ea6 100644 --- a/loopy/preprocess.py +++ b/loopy/preprocess.py @@ -796,7 +796,7 @@ def _hackily_ensure_multi_assignment_return_values_are_scoped_private(kernel): TemporaryVariable( name=new_assignee_name, dtype=None, - scope=AddressSpace.PRIVATE)) + address_space=AddressSpace.PRIVATE)) from pymbolic import var new_assignee = var(new_assignee_name) @@ -982,7 +982,7 @@ def realize_reduction(kernel, insn_id_filter=None, unknown_types_ok=True, name=name, shape=(), dtype=None, - scope=AddressSpace.PRIVATE) + address_space=AddressSpace.PRIVATE) from pymbolic import var temp_vars = tuple(var(n) for n in temp_var_names) diff --git a/loopy/transform/buffer.py b/loopy/transform/buffer.py index 63d3a40fb..7f4779cc7 100644 --- a/loopy/transform/buffer.py +++ b/loopy/transform/buffer.py @@ -378,7 +378,7 @@ def buffer_array(kernel, var_name, buffer_inames, init_expression=None, dtype=var_descr.dtype, base_indices=(0,)*len(abm.non1_storage_shape), shape=tuple(abm.non1_storage_shape), - scope=temporary_scope) + address_space=temporary_scope) new_temporary_variables[buf_var_name] = temp_var diff --git a/loopy/transform/data.py b/loopy/transform/data.py index 7fbc595f2..a6a2d7b4f 100644 --- a/loopy/transform/data.py +++ b/loopy/transform/data.py @@ -696,7 +696,7 @@ def set_temporary_scope(kernel, temp_var_names, scope): except KeyError: raise LoopyError("temporary '%s' not found" % tv_name) - new_temp_vars[tv_name] = tv.copy(scope=scope) + new_temp_vars[tv_name] = tv.copy(address_space=scope) return kernel.copy(temporary_variables=new_temp_vars) diff --git a/loopy/transform/save.py b/loopy/transform/save.py index cca62bc52..baa558a72 100644 --- a/loopy/transform/save.py +++ b/loopy/transform/save.py @@ -228,7 +228,7 @@ class TemporarySaver(object): return TemporaryVariable( name=self.name, dtype=temporary.dtype, - scope=AddressSpace.GLOBAL, + address_space=AddressSpace.GLOBAL, shape=self.new_shape) @property diff --git a/test/test_apps.py b/test/test_apps.py index e7f4004fa..e07262dbd 100644 --- a/test/test_apps.py +++ b/test/test_apps.py @@ -619,7 +619,8 @@ def test_poisson_fem(ctx_factory): def test_domain_tree_nesting(): # From https://github.com/inducer/loopy/issues/78 - from loopy.kernel.data import temp_var_scope as scopes + + AS = lp.AddressSpace # noqa out_map = np.array([1, 2], dtype=np.int32) if_val = np.array([-1, 0], dtype=np.int32) @@ -651,12 +652,13 @@ def test_domain_tree_nesting(): end """, [ - TV('out_map', initializer=out_map, read_only=True, scope=scopes.PRIVATE), - TV('if_val', initializer=if_val, read_only=True, scope=scopes.PRIVATE), - TV('vals', initializer=vals, read_only=True, scope=scopes.PRIVATE), - TV('num_vals', initializer=num_vals, read_only=True, scope=scopes.PRIVATE), + TV('out_map', initializer=out_map, read_only=True, address_space=AS.PRIVATE), + TV('if_val', initializer=if_val, read_only=True, address_space=AS.PRIVATE), + TV('vals', initializer=vals, read_only=True, address_space=AS.PRIVATE), + TV('num_vals', initializer=num_vals, read_only=True, + address_space=AS.PRIVATE), TV('num_vals_offset', initializer=num_vals_offset, read_only=True, - scope=scopes.PRIVATE), + address_space=AS.PRIVATE), lp.GlobalArg('B', shape=(100, 31), dtype=np.float64), lp.GlobalArg('out', shape=(100, 12), dtype=np.float64)]) diff --git a/test/test_c_execution.py b/test/test_c_execution.py index bf168c11d..b0ca7ade2 100644 --- a/test/test_c_execution.py +++ b/test/test_c_execution.py @@ -275,7 +275,7 @@ def test_c_execution_with_global_temporaries(): # global constant temporaries is None from loopy.target.c import ExecutableCTarget - from loopy.kernel.data import temp_var_scope as scopes + AS = lp.AddressSpace # noqa n = 10 knl = lp.make_kernel('{[i]: 0 <= i < n}', @@ -287,7 +287,7 @@ def test_c_execution_with_global_temporaries(): initializer=np.arange(n, dtype=np.int32), dtype=np.int32, read_only=True, - scope=scopes.GLOBAL)], + address_space=AS.GLOBAL)], target=ExecutableCTarget()) knl = lp.fix_parameters(knl, n=n) diff --git a/test/test_loopy.py b/test/test_loopy.py index d101f6fd0..c06d1d5e1 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -69,7 +69,7 @@ def test_globals_decl_once_with_multi_subprogram(ctx_factory): """, [lp.TemporaryVariable( 'cnst', shape=('n'), initializer=cnst, - scope=lp.AddressSpace.GLOBAL, + address_space=lp.AddressSpace.GLOBAL, read_only=True), '...']) knl = lp.fix_parameters(knl, n=16) knl = lp.add_barrier(knl, "id:first", "id:second") @@ -947,7 +947,7 @@ def test_atomic_load(ctx_factory, dtype): lp.GlobalArg("a", dtype, shape=lp.auto), lp.GlobalArg("b", dtype, shape=lp.auto), lp.TemporaryVariable('temp', dtype, for_atomic=True, - scope=AddressSpace.LOCAL), + address_space=AddressSpace.LOCAL), "..." ], silenced_warnings=["write_race(init)", "write_race(temp_sum)"]) @@ -1862,7 +1862,7 @@ def test_temp_initializer(ctx_factory, src_order, tmp_order): lp.TemporaryVariable("tmp", initializer=a, shape=lp.auto, - scope=lp.AddressSpace.PRIVATE, + address_space=lp.AddressSpace.PRIVATE, read_only=True, order=tmp_order), "..." @@ -1887,7 +1887,7 @@ def test_const_temp_with_initializer_not_saved(): lp.TemporaryVariable("tmp", initializer=np.arange(10), shape=lp.auto, - scope=lp.AddressSpace.PRIVATE, + address_space=lp.AddressSpace.PRIVATE, read_only=True), "..." ], @@ -2110,7 +2110,7 @@ def test_integer_reduction(ctx_factory): var_int = np.random.randint(1000, size=n).astype(vtype) var_lp = lp.TemporaryVariable('var', initializer=var_int, read_only=True, - scope=lp.AddressSpace.PRIVATE, + address_space=lp.AddressSpace.PRIVATE, dtype=to_loopy_type(vtype), shape=lp.auto) @@ -2301,7 +2301,7 @@ def test_barrier_in_overridden_get_grid_size_expanded_kernel(): end """, [lp.TemporaryVariable("a", np.float32, shape=(10,), order='C', - scope=lp.AddressSpace.LOCAL), + address_space=lp.AddressSpace.LOCAL), lp.GlobalArg("b", np.float32, shape=(11,), order='C')], seq_dependencies=True) @@ -2553,7 +2553,7 @@ def test_preamble_with_separate_temporaries(ctx_factory): [lp.GlobalArg('out', shape=('n',)), lp.TemporaryVariable( 'offsets', shape=(offsets.size,), initializer=offsets, - scope=lp.AddressSpace.GLOBAL, + address_space=lp.AddressSpace.GLOBAL, read_only=True), lp.GlobalArg('data', shape=(data.size,), dtype=np.float64)], ) @@ -2687,7 +2687,7 @@ def test_no_barriers_for_nonoverlapping_access(second_index, expect_barrier): """ % second_index, [ lp.TemporaryVariable("a", lp.auto, shape=(256,), - scope=lp.AddressSpace.LOCAL), + address_space=lp.AddressSpace.LOCAL), ]) knl = lp.tag_inames(knl, "i:l.0") diff --git a/test/test_reduction.py b/test/test_reduction.py index ef229d5cd..4ce063454 100644 --- a/test/test_reduction.py +++ b/test/test_reduction.py @@ -240,7 +240,7 @@ def test_global_parallel_reduction(ctx_factory, size): knl = reduction_arg_to_subst_rule(knl, "i_outer") knl = lp.precompute(knl, "red_i_outer_arg", "i_outer", - temporary_scope=lp.temp_var_scope.GLOBAL, + temporary_address_space=lp.AddressSpace.GLOBAL, default_tag="l.auto") knl = lp.realize_reduction(knl) knl = lp.tag_inames(knl, "i_outer_0:g.0") @@ -285,7 +285,7 @@ def test_global_mc_parallel_reduction(ctx_factory, size): from loopy.transform.data import reduction_arg_to_subst_rule knl = reduction_arg_to_subst_rule(knl, "i_outer") knl = lp.precompute(knl, "red_i_outer_arg", "i_outer", - temporary_scope=lp.temp_var_scope.GLOBAL, + temporary_address_space=lp.AddressSpace.GLOBAL, default_tag="l.auto") knl = lp.realize_reduction(knl) knl = lp.add_dependency( diff --git a/test/test_transform.py b/test/test_transform.py index 3ee67b703..cdc0c14b8 100644 --- a/test/test_transform.py +++ b/test/test_transform.py @@ -135,7 +135,7 @@ def test_to_batched_temp(ctx_factory): "cnst", dtype=np.float32, shape=(), - scope=lp.temp_var_scope.PRIVATE), '...']) + address_space=lp.AddressSpace.PRIVATE), '...']) knl = lp.add_and_infer_dtypes(knl, dict(out=np.float32, x=np.float32, a=np.float32)) diff --git a/test/testlib.py b/test/testlib.py index ad290ee7c..67c5ba04f 100644 --- a/test/testlib.py +++ b/test/testlib.py @@ -80,7 +80,6 @@ class SeparateTemporariesPreambleTestMangler( class SeparateTemporariesPreambleTestPreambleGenerator( SeparateTemporariesPreambleTestDataHolder): def __call__(self, preamble_info): - from loopy.kernel.data import temp_var_scope as scopes # find a function matching our name func_match = next( @@ -96,7 +95,7 @@ class SeparateTemporariesPreambleTestPreambleGenerator( var = lp.TemporaryVariable( 'lookup', initializer=self.arr, dtype=self.arr.dtype, shape=self.arr.shape, - scope=scopes.GLOBAL, read_only=True) + address_space=lp.AddressSpace.GLOBAL, read_only=True) # and code code = """ int {name}(int start, int end, int match) -- GitLab