Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loopy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ben Sepanski
loopy
Commits
da56108e
Commit
da56108e
authored
11 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
PEP8 loopy.codgen.
parent
71659c19
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
loopy/codegen/__init__.py
+13
-9
13 additions, 9 deletions
loopy/codegen/__init__.py
with
13 additions
and
9 deletions
loopy/codegen/__init__.py
+
13
−
9
View file @
da56108e
...
...
@@ -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
# }}}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment