Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils
Commits
6718973d
Commit
6718973d
authored
4 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Reveal base_pointer_spec for the user
parent
03909356
No related branches found
No related tags found
1 merge request
!210
WIP: Assembly
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pystencils/cpu/kernelcreation.py
+4
-2
4 additions, 2 deletions
pystencils/cpu/kernelcreation.py
pystencils/gpucuda/kernelcreation.py
+4
-2
4 additions, 2 deletions
pystencils/gpucuda/kernelcreation.py
pystencils/kernelcreation.py
+6
-3
6 additions, 3 deletions
pystencils/kernelcreation.py
with
14 additions
and
7 deletions
pystencils/cpu/kernelcreation.py
+
4
−
2
View file @
6718973d
...
...
@@ -18,7 +18,7 @@ AssignmentOrAstNodeList = List[Union[Assignment, ast.Node]]
def
create_kernel
(
assignments
:
AssignmentOrAstNodeList
,
function_name
:
str
=
"
kernel
"
,
type_info
=
'
double
'
,
split_groups
=
(),
iteration_slice
=
None
,
ghost_layers
=
None
,
skip_independence_check
=
False
)
->
KernelFunction
:
skip_independence_check
=
False
,
base_pointer_spec
=
None
)
->
KernelFunction
:
"""
Creates an abstract syntax tree for a kernel function, by taking a list of update rules.
Loops are created according to the field accesses in the equations.
...
...
@@ -39,6 +39,7 @@ def create_kernel(assignments: AssignmentOrAstNodeList, function_name: str = "ke
all dimensions
skip_independence_check: don
'
t check that loop iterations are independent. This is needed e.g. for
periodicity kernel, that access the field outside the iteration bounds. Use with care!
base_pointer_spec: specifies which field accesses are resolved by pointers see :func:`parse_base_pointer_info`
Returns:
AST node representing a function, that can be printed as C or CUDA code
...
...
@@ -73,7 +74,8 @@ def create_kernel(assignments: AssignmentOrAstNodeList, function_name: str = "ke
typed_split_groups
=
[[
type_symbol
(
s
)
for
s
in
split_group
]
for
split_group
in
split_groups
]
split_inner_loop
(
ast_node
,
typed_split_groups
)
base_pointer_spec
=
[[
'
spatialInner0
'
],
[
'
spatialInner1
'
]]
if
len
(
loop_order
)
>=
2
else
[[
'
spatialInner0
'
]]
if
base_pointer_spec
is
None
:
base_pointer_spec
=
[[
'
spatialInner0
'
],
[
'
spatialInner1
'
]]
if
len
(
loop_order
)
>=
2
else
[[
'
spatialInner0
'
]]
base_pointer_info
=
{
field
.
name
:
parse_base_pointer_info
(
base_pointer_spec
,
loop_order
,
field
.
spatial_dimensions
,
field
.
index_dimensions
)
for
field
in
fields_without_buffers
}
...
...
This diff is collapsed.
Click to expand it.
pystencils/gpucuda/kernelcreation.py
+
4
−
2
View file @
6718973d
...
...
@@ -15,7 +15,8 @@ def create_cuda_kernel(assignments,
iteration_slice
=
None
,
ghost_layers
=
None
,
skip_independence_check
=
False
,
use_textures_for_interpolation
=
True
):
use_textures_for_interpolation
=
True
,
base_pointer_spec
=
None
):
assert
assignments
,
"
Assignments must not be empty!
"
fields_read
,
fields_written
,
assignments
=
add_types
(
assignments
,
type_info
,
not
skip_independence_check
)
all_fields
=
fields_read
.
union
(
fields_written
)
...
...
@@ -73,7 +74,8 @@ def create_cuda_kernel(assignments,
implement_interpolations
(
ast
,
implement_by_texture_accesses
=
use_textures_for_interpolation
)
base_pointer_spec
=
[[
'
spatialInner0
'
]]
if
base_pointer_spec
is
None
:
base_pointer_spec
=
[[
'
spatialInner0
'
]]
base_pointer_info
=
{
f
.
name
:
parse_base_pointer_info
(
base_pointer_spec
,
[
2
,
1
,
0
],
f
.
spatial_dimensions
,
f
.
index_dimensions
)
for
f
in
all_fields
}
...
...
This diff is collapsed.
Click to expand it.
pystencils/kernelcreation.py
+
6
−
3
View file @
6718973d
...
...
@@ -31,7 +31,8 @@ def create_kernel(assignments,
cpu_prepend_optimizations
=
[],
use_auto_for_assignments
=
False
,
opencl_queue
=
None
,
opencl_ctx
=
None
):
opencl_ctx
=
None
,
base_pointer_spec
=
None
):
"""
Creates abstract syntax tree (AST) of kernel, using a list of update equations.
...
...
@@ -57,6 +58,7 @@ def create_kernel(assignments,
gpu_indexing_params: dict with indexing parameters (constructor parameters of indexing class)
e.g. for
'
block
'
one can specify
'
{
'
block_size
'
: (20, 20, 10) }
'
cpu_prepend_optimizations: list of extra optimizations to perform first on the AST
base_pointer_spec: specifies which field accesses are resolved by pointers see :func:`parse_base_pointer_info`
Returns:
abstract syntax tree (AST) object, that can either be printed as source code with `show_code` or
...
...
@@ -94,7 +96,7 @@ def create_kernel(assignments,
from
pystencils.cpu
import
add_openmp
ast
=
create_kernel
(
assignments
,
type_info
=
data_type
,
split_groups
=
split_groups
,
iteration_slice
=
iteration_slice
,
ghost_layers
=
ghost_layers
,
skip_independence_check
=
skip_independence_check
)
skip_independence_check
=
skip_independence_check
,
base_pointer_spec
=
base_pointer_spec
)
for
optimization
in
cpu_prepend_optimizations
:
optimization
(
ast
)
omp_collapse
=
None
...
...
@@ -119,7 +121,8 @@ def create_kernel(assignments,
indexing_creator
=
indexing_creator_from_params
(
gpu_indexing
,
gpu_indexing_params
),
iteration_slice
=
iteration_slice
,
ghost_layers
=
ghost_layers
,
skip_independence_check
=
skip_independence_check
,
use_textures_for_interpolation
=
use_textures_for_interpolation
)
use_textures_for_interpolation
=
use_textures_for_interpolation
,
base_pointer_spec
=
base_pointer_spec
)
if
target
==
'
opencl
'
:
from
pystencils.opencl.opencljit
import
make_python_function
ast
.
_backend
=
'
opencl
'
...
...
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