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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Sebastian Bindgen
pystencils
Commits
0e56c1e3
Commit
0e56c1e3
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Make SerialDataHandling.serialization_function work with OpenCL
parent
585084e7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/datahandling/serial_datahandling.py
+8
-1
8 additions, 1 deletion
pystencils/datahandling/serial_datahandling.py
pystencils/gpucuda/periodicity.py
+11
-4
11 additions, 4 deletions
pystencils/gpucuda/periodicity.py
with
19 additions
and
5 deletions
pystencils/datahandling/serial_datahandling.py
+
8
−
1
View file @
0e56c1e3
...
...
@@ -23,6 +23,7 @@ class SerialDataHandling(DataHandling):
periodicity
:
Union
[
bool
,
Sequence
[
bool
]]
=
False
,
default_target
:
str
=
'
cpu
'
,
opencl_queue
=
None
,
opencl_ctx
=
None
,
array_handler
=
None
)
->
None
:
"""
Creates a data handling for single node simulations.
...
...
@@ -44,6 +45,8 @@ class SerialDataHandling(DataHandling):
self
.
custom_data_cpu
=
DotDict
()
self
.
custom_data_gpu
=
DotDict
()
self
.
_custom_data_transfer_functions
=
{}
self
.
_opencl_queue
=
opencl_queue
self
.
_opencl_ctx
=
opencl_ctx
if
array_handler
:
self
.
array_handler
=
array_handler
...
...
@@ -315,11 +318,15 @@ class SerialDataHandling(DataHandling):
result
.
append
(
get_periodic_boundary_functor
(
filtered_stencil
,
ghost_layers
=
gls
))
else
:
from
pystencils.gpucuda.periodicity
import
get_periodic_boundary_functor
as
boundary_func
target
=
'
gpu
'
if
not
isinstance
(
self
.
array_handler
,
PyOpenClArrayHandler
)
else
'
opencl
'
result
.
append
(
boundary_func
(
filtered_stencil
,
self
.
_domainSize
,
index_dimensions
=
self
.
fields
[
name
].
index_dimensions
,
index_dim_shape
=
values_per_cell
,
dtype
=
self
.
fields
[
name
].
dtype
.
numpy_dtype
,
ghost_layers
=
gls
))
ghost_layers
=
gls
,
target
=
target
,
opencl_queue
=
self
.
_opencl_queue
,
opencl_ctx
=
self
.
_opencl_ctx
))
if
target
==
'
cpu
'
:
def
result_functor
():
...
...
This diff is collapsed.
Click to expand it.
pystencils/gpucuda/periodicity.py
+
11
−
4
View file @
0e56c1e3
import
numpy
as
np
import
pystencils.gpucuda
import
pystencils.opencl
from
pystencils
import
Assignment
,
Field
from
pystencils.gpucuda
import
make_python_function
from
pystencils.gpucuda.kernelcreation
import
create_cuda_kernel
from
pystencils.slicing
import
get_periodic_boundary_src_dst_slices
,
normalize_slice
...
...
@@ -25,16 +26,22 @@ def create_copy_kernel(domain_size, from_slice, to_slice, index_dimensions=0, in
update_eqs
.
append
(
eq
)
ast
=
create_cuda_kernel
(
update_eqs
,
iteration_slice
=
to_slice
,
skip_independence_check
=
True
)
return
make_python_function
(
ast
)
return
ast
def
get_periodic_boundary_functor
(
stencil
,
domain_size
,
index_dimensions
=
0
,
index_dim_shape
=
1
,
ghost_layers
=
1
,
thickness
=
None
,
dtype
=
float
):
thickness
=
None
,
dtype
=
float
,
target
=
'
gpu
'
,
opencl_queue
=
None
,
opencl_ctx
=
None
):
assert
target
in
[
'
gpu
'
,
'
opencl
'
]
src_dst_slice_tuples
=
get_periodic_boundary_src_dst_slices
(
stencil
,
ghost_layers
,
thickness
)
kernels
=
[]
index_dimensions
=
index_dimensions
for
src_slice
,
dst_slice
in
src_dst_slice_tuples
:
kernels
.
append
(
create_copy_kernel
(
domain_size
,
src_slice
,
dst_slice
,
index_dimensions
,
index_dim_shape
,
dtype
))
ast
=
create_copy_kernel
(
domain_size
,
src_slice
,
dst_slice
,
index_dimensions
,
index_dim_shape
,
dtype
)
if
target
==
'
gpu
'
:
kernels
.
append
(
pystencils
.
gpucuda
.
make_python_function
(
ast
))
else
:
kernels
.
append
(
pystencils
.
opencl
.
make_python_function
(
ast
,
opencl_queue
,
opencl_ctx
))
def
functor
(
pdfs
,
**
_
):
for
kernel
in
kernels
:
...
...
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