Skip to content
Snippets Groups Projects
Commit da56108e authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

PEP8 loopy.codgen.

parent 71659c19
No related branches found
No related tags found
No related merge requests found
......@@ -23,14 +23,10 @@ THE SOFTWARE.
"""
from pytools import Record
import islpy as isl
# {{{ support code for AST wrapper objects
class GeneratedInstruction(Record):
......@@ -43,6 +39,7 @@ class GeneratedInstruction(Record):
"""
__slots__ = ["insn_id", "implemented_domain", "ast"]
class GeneratedCode(Record):
"""Objects of this type are wrapped around ASTs upon
return from generation calls to collect information about them.
......@@ -53,6 +50,7 @@ class GeneratedCode(Record):
"""
__slots__ = ["ast", "implemented_domains"]
def gen_code_block(elements):
from cgen import Block, Comment, Line, Initializer
......@@ -96,6 +94,7 @@ def gen_code_block(elements):
return GeneratedCode(ast=ast, implemented_domains=implemented_domains)
def wrap_in(cls, *args):
inner = args[-1]
args = args[:-1]
......@@ -109,6 +108,7 @@ def wrap_in(cls, *args):
return GeneratedCode(ast=cls(*args),
implemented_domains=inner.implemented_domains)
def wrap_in_if(condition_codelets, inner):
from cgen import If
......@@ -119,6 +119,7 @@ def wrap_in_if(condition_codelets, inner):
return inner
def add_comment(cmt, code):
if cmt is None:
return code
......@@ -132,6 +133,7 @@ def add_comment(cmt, code):
# }}}
# {{{ code generation state
class CodeGenerationState(object):
......@@ -167,6 +169,7 @@ class CodeGenerationState(object):
# }}}
# {{{ initial assignments
def make_initial_assignments(kernel):
......@@ -182,11 +185,9 @@ def make_initial_assignments(kernel):
if isinstance(tag, LocalIndexTag):
hw_axis_expr = var("lid")(tag.axis)
hw_axis_size = local_size[tag.axis]
elif isinstance(tag, GroupIndexTag):
hw_axis_expr = var("gid")(tag.axis)
hw_axis_size = global_size[tag.axis]
else:
continue
......@@ -200,10 +201,12 @@ def make_initial_assignments(kernel):
# }}}
# {{{ cgen overrides
from cgen import POD as PODBase
class POD(PODBase):
def get_decl_pair(self):
from pyopencl.tools import dtype_to_ctype
......@@ -211,6 +214,7 @@ class POD(PODBase):
# }}}
# {{{ main code generation entrypoint
def generate_code(kernel, with_annotation=False,
......@@ -317,7 +321,8 @@ def generate_code(kernel, with_annotation=False,
# }}}
initial_implemented_domain = isl.BasicSet.from_params(kernel.assumptions)
codegen_state = CodeGenerationState(initial_implemented_domain, c_code_mapper=ccm)
codegen_state = CodeGenerationState(
initial_implemented_domain, c_code_mapper=ccm)
from loopy.codegen.loop import set_up_hw_parallel_loops
gen_code = set_up_hw_parallel_loops(kernel, 0, codegen_state)
......@@ -359,7 +364,7 @@ def generate_code(kernel, with_annotation=False,
dedup_preambles.append(preamble)
mod = ([LiteralLines(lines) for lines in dedup_preambles]
+[Line()] + mod)
+ [Line()] + mod)
# }}}
......@@ -371,7 +376,6 @@ def generate_code(kernel, with_annotation=False,
return result
# }}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment