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
061ab58b
Commit
061ab58b
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Allow creation of indexed kernels with opencl
parent
e6a30483
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!119
Opencl datahandling
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils/kernelcreation.py
+13
-5
13 additions, 5 deletions
pystencils/kernelcreation.py
with
13 additions
and
5 deletions
pystencils/kernelcreation.py
+
13
−
5
View file @
061ab58b
from
itertools
import
combinations
import
functools
import
itertools
from
types
import
MappingProxyType
import
sympy
as
sp
...
...
@@ -12,7 +13,6 @@ from pystencils.simp.assignment_collection import AssignmentCollection
from
pystencils.stencil
import
direction_string_to_offset
,
inverse_direction_string
from
pystencils.transformations
import
(
loop_blocking
,
move_constants_before_loop
,
remove_conditionals_in_staggered_kernel
)
import
functools
def
create_kernel
(
assignments
,
...
...
@@ -143,7 +143,9 @@ def create_indexed_kernel(assignments,
cpu_openmp
=
True
,
gpu_indexing
=
'
block
'
,
gpu_indexing_params
=
MappingProxyType
({}),
use_textures_for_interpolation
=
True
):
use_textures_for_interpolation
=
True
,
opencl_queue
=
None
,
opencl_ctx
=
None
):
"""
Similar to :func:`create_kernel`, but here not all cells of a field are updated but only cells with
coordinates which are stored in an index field. This traversal method can e.g. be used for boundary handling.
...
...
@@ -193,7 +195,7 @@ def create_indexed_kernel(assignments,
return
ast
elif
target
==
'
llvm
'
:
raise
NotImplementedError
(
"
Indexed kernels are not yet supported in LLVM backend
"
)
elif
target
==
'
gpu
'
:
elif
target
==
'
gpu
'
or
target
==
'
opencl
'
:
from
pystencils.gpucuda
import
created_indexed_cuda_kernel
idx_creator
=
indexing_creator_from_params
(
gpu_indexing
,
gpu_indexing_params
)
ast
=
created_indexed_cuda_kernel
(
assignments
,
...
...
@@ -202,6 +204,12 @@ def create_indexed_kernel(assignments,
coordinate_names
=
coordinate_names
,
indexing_creator
=
idx_creator
,
use_textures_for_interpolation
=
use_textures_for_interpolation
)
if
target
==
'
opencl
'
:
from
pystencils.opencl.opencljit
import
make_python_function
ast
.
_backend
=
'
opencl
'
ast
.
compile
=
functools
.
partial
(
make_python_function
,
ast
,
opencl_queue
,
opencl_ctx
)
ast
.
_target
=
'
opencl
'
ast
.
_backend
=
'
opencl
'
return
ast
else
:
raise
ValueError
(
"
Unknown target %s. Has to be either
'
cpu
'
or
'
gpu
'"
%
(
target
,))
...
...
@@ -298,7 +306,7 @@ def create_staggered_kernel(assignments, target='cpu', gpu_exclusive_conditions=
outer_assignment
=
None
conditions
=
{
direction
:
condition
(
direction
)
for
direction
in
stencil
}
for
num_conditions
in
range
(
len
(
stencil
)):
for
combination
in
combinations
(
conditions
.
values
(),
num_conditions
):
for
combination
in
itertools
.
combinations
(
conditions
.
values
(),
num_conditions
):
for
assignment
in
assignments
:
direction
=
stencil
[
assignment
.
lhs
.
index
[
0
]]
if
conditions
[
direction
]
in
combination
:
...
...
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