From 00872d1d05752454657467d3f66f09e588e49c2f Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Wed, 12 Oct 2011 07:50:07 -0400 Subject: [PATCH] Change label syntax. Add syntax for forced iname deps. --- MEMO | 24 ++++++++++++++++-------- loopy/kernel.py | 17 +++++++++++------ test/test_matmul.py | 2 +- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/MEMO b/MEMO index d7526fd0d..9aec2cce9 100644 --- a/MEMO +++ b/MEMO @@ -37,26 +37,30 @@ TODO: variable shuffle detection Things to consider ^^^^^^^^^^^^^^^^^^ -- implemented_domain may end up being smaller than requested in cse - evaluations--check that! - - Depedencies are pointwise for shared loop dimensions and global over non-shared ones (between dependent and ancestor) - multiple insns could fight over which iname gets local axis 0 -> complicated optimization problem +- Every loop in loopy is opened at most once. + Too restrictive? + +- Loop bounds currently may not depend on parallel dimensions + Does it make sense to relax this? + TODO ^^^^ +- implemented_domain may end up being smaller than requested in cse + evaluations--check that! + - Parallel dimension splitting/merging via tags - FIXME: Deal with insns losing a seq iname dep in a CSE realization a <- cse(reduce(stuff)) -- Every loop in loopy is opened at most once. - - reimplement add_prefetch - user interface for dim length prescription @@ -71,13 +75,17 @@ TODO - Sharing of checks across ILP instances -- Loop bounds currently may not depend on parallel dimensions - Does it make sense to relax this? +- Some things involving CSEs might be impossible to schedule + a[i,j] = cse(b[i]) * cse(c[j]) + +- Flag, exploit idempotence Dealt with ^^^^^^^^^^ -- make syntax for explicit loop dependencies +- Make syntax for iname dependencies + +- make syntax for insn dependencies - Implement get_problems() diff --git a/loopy/kernel.py b/loopy/kernel.py index a9e140551..2a8256ec4 100644 --- a/loopy/kernel.py +++ b/loopy/kernel.py @@ -404,15 +404,17 @@ class LoopKernel(Record): """ import re LABEL_DEP_RE = re.compile( - r"^(?:\{(?P<label>\w+)\})?" + r"^\s*(?:(?P<label>\w+):)?" + "\s*(?:\[(?P<iname_deps>[\s\w,]+)\])?" "\s*(?P<lhs>.+)\s*=\s*(?P<rhs>.+?)\s*?" - "(?:\:\s*(?P<deps>[\s\w,]+))?$" + "(?:\:\s*(?P<insn_deps>[\s\w,]+))?$" ) def parse_if_necessary(insn): from pymbolic import parse - deps = [] + insn_deps = [] + forced_iname_deps = [] label = "insn" if isinstance(insn, Instruction): @@ -425,8 +427,10 @@ class LoopKernel(Record): groups = label_dep_match.groupdict() if groups["label"] is not None: label = groups["label"] - if groups["deps"] is not None: - deps = [dep.strip() for dep in groups["deps"].split(",")] + if groups["insn_deps"] is not None: + insn_deps = [dep.strip() for dep in groups["insn_deps"].split(",")] + if groups["iname_deps"] is not None: + forced_iname_deps = [dep.strip() for dep in groups["iname_deps"].split(",")] lhs = parse(groups["lhs"]) from loopy.symbolic import FunctionToPrimitiveMapper @@ -434,7 +438,8 @@ class LoopKernel(Record): return Instruction( id=self.make_unique_instruction_id(insns, based_on=label), - insn_deps=deps, + insn_deps=insn_deps, + forced_iname_deps=forced_iname_deps, assignee=lhs, expression=rhs) if isinstance(domain, str): diff --git a/test/test_matmul.py b/test/test_matmul.py index 2ecdfdb27..418ab1201 100644 --- a/test/test_matmul.py +++ b/test/test_matmul.py @@ -203,7 +203,7 @@ def test_plain_matrix_mul_new_ui(ctx_factory): knl = lp.LoopKernel(ctx.devices[0], "[n] -> {[i,j,k]: 0<=i,j,k<n}", [ - "{label} c[i, j] = sum_float32(k, cse(a[i, k], lhsmat)*cse(b[k, j], rhsmat))" + "label: c[i, j] = sum_float32(k, cse(a[i, k], lhsmat)*cse(b[k, j], rhsmat))" ], [ lp.ArrayArg("a", dtype, shape=(n, n), order=order), -- GitLab