diff --git a/loopy/transform/instruction.py b/loopy/transform/instruction.py index 92bcb0bf4b230a435ba0729fb48aec52063eae19..7c9c9688604179dce2aa7dcd6954d76a0df32cc7 100644 --- a/loopy/transform/instruction.py +++ b/loopy/transform/instruction.py @@ -92,13 +92,18 @@ def add_dependency(kernel, insn_match, depends_on): if isinstance(depends_on, str) and depends_on in kernel.id_to_insn: added_deps = frozenset([depends_on]) else: - added_deps = find_instructions(depends_on) + added_deps = frozenset( + dep.id for dep in find_instructions(kernel, depends_on)) if not added_deps: - raise LoopyError("no instructions found matching '%s'" % depends_on) + raise LoopyError("no instructions found matching '%s' " + "(to add as dependencies)" % depends_on) + + matched = [False] def add_dep(insn): new_deps = insn.depends_on + matched[0] = True if new_deps is None: new_deps = added_deps else: @@ -106,7 +111,13 @@ def add_dependency(kernel, insn_match, depends_on): return insn.copy(depends_on=new_deps) - return map_instructions(kernel, insn_match, add_dep) + result = map_instructions(kernel, insn_match, add_dep) + + if not matched[0]: + raise LoopyError("no instructions found matching '%s' " + "(to which dependencies would be added)" % insn_match) + + return result # }}} diff --git a/loopy/transform/precompute.py b/loopy/transform/precompute.py index 5ab9dfab3c8ac0669c3e7eaf4091bb3ab4b0e2a2..a19e06ecdf7c9966501ebb9600ea4e01614363f4 100644 --- a/loopy/transform/precompute.py +++ b/loopy/transform/precompute.py @@ -799,7 +799,7 @@ def precompute(kernel, subst_use, sweep_inames=[], within=None, if temporary_scope == temp_var_scope.GLOBAL: barrier_insn_id = kernel.make_unique_instruction_id( - based_on=c_subst_name+"_b") + based_on=c_subst_name+"_barrier") from loopy.kernel.instruction import BarrierInstruction barrier_insn = BarrierInstruction( id=barrier_insn_id, diff --git a/test/test_reduction.py b/test/test_reduction.py index fec72138da24d41cc14da357ebe596b189b5d2f4..820c669da494f4d8863d274120cd5c0c7eb4420f 100644 --- a/test/test_reduction.py +++ b/test/test_reduction.py @@ -239,7 +239,7 @@ def test_global_parallel_reduction(ctx_factory, size): knl = lp.realize_reduction(knl) knl = lp.add_dependency( knl, "writes:acc_i_outer", - "red_i_outer_arg_b") + "id:red_i_outer_arg_barrier") lp.auto_test_vs_ref( ref_knl, ctx, knl, parameters={"n": size}, @@ -279,7 +279,7 @@ def test_global_mc_parallel_reduction(ctx_factory, size): knl = lp.realize_reduction(knl) knl = lp.add_dependency( knl, "writes:acc_i_outer", - "red_i_outer_arg_b") + "id:red_i_outer_arg_barrier") lp.auto_test_vs_ref( ref_knl, ctx, knl, parameters={"n": size})