From fdc2b43793b357c16999ad88a129571a28cf8712 Mon Sep 17 00:00:00 2001 From: tj-sun Date: Wed, 29 Nov 2017 17:41:58 +0000 Subject: [PATCH 1/2] count flops outside of loops once --- loopy/statistics.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/loopy/statistics.py b/loopy/statistics.py index e27a0f482..0ff82e5ab 100755 --- a/loopy/statistics.py +++ b/loopy/statistics.py @@ -1197,6 +1197,9 @@ def get_unused_hw_axes_factor(knl, insn, disregard_local_axes, space=None): def count_insn_runs(knl, insn, count_redundant_work, disregard_local_axes=False): insn_inames = knl.insn_inames(insn) + if not insn_inames: + p = isl.PwQPolynomial('{ 1 }') + return GuardedPwQPolynomial(p, isl.Set.universe(p.domain().space)) if disregard_local_axes: from loopy.kernel.data import LocalIndexTag -- GitLab From b812c7197b1abd2cf5d3d17876e96bab9365ae09 Mon Sep 17 00:00:00 2001 From: tj-sun Date: Thu, 30 Nov 2017 11:08:08 +0000 Subject: [PATCH 2/2] add test --- test/test_statistics.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_statistics.py b/test/test_statistics.py index ea0bdb62b..14944407c 100644 --- a/test/test_statistics.py +++ b/test/test_statistics.py @@ -71,6 +71,24 @@ def test_op_counter_basic(): assert i32add == n*m*2 +def test_op_outsite(): + + data = [lp.GlobalArg("a", shape=(10,), dtype=float), + lp.GlobalArg("b", shape=(10,), dtype=float), + lp.GlobalArg("c", shape=(10,), dtype=float)] + + knl = lp.make_kernel( + "[] -> {[]}", + "a[0] = b[0] + c[0]", + kernel_data=data + ) + + op = lp.get_op_map(knl) + flops = op.sum().eval_with_dict({}) + + assert flops == 1 + + def test_op_counter_reduction(): knl = lp.make_kernel( -- GitLab