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
a837cb73
Commit
a837cb73
authored
3 months ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
Permit custom numerical data type in BoundaryHandling
parent
6df2c640
Branches
Branches containing commit
No related tags found
1 merge request
!460
Fix data types in boundary handling. Fix deprecation checks.
Pipeline
#77907
passed
3 months ago
Stage: Code Quality
Stage: Unit Tests
Stage: legacy_test
Stage: docs
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pystencils/boundaries/boundaryhandling.py
+14
-6
14 additions, 6 deletions
src/pystencils/boundaries/boundaryhandling.py
with
14 additions
and
6 deletions
src/pystencils/boundaries/boundaryhandling.py
+
14
−
6
View file @
a837cb73
...
...
@@ -4,6 +4,7 @@ import numpy as np
import
sympy
as
sp
from
pystencils
import
create_kernel
,
CreateKernelConfig
,
Target
from
pystencils.types
import
UserTypeSpec
,
create_numeric_type
from
pystencils.assignment
import
Assignment
from
pystencils.boundaries.createindexlist
import
(
create_boundary_index_array
,
numpy_data_type_for_boundary_object
)
...
...
@@ -84,13 +85,14 @@ class FlagInterface:
class
BoundaryHandling
:
def
__init__
(
self
,
data_handling
,
field_name
,
stencil
,
name
=
"
boundary_handling
"
,
flag_interface
=
None
,
target
:
Target
=
Target
.
CPU
,
openmp
=
True
):
target
:
Target
=
Target
.
CPU
,
default_dtype
:
UserTypeSpec
=
"
float64
"
,
openmp
=
True
):
assert
data_handling
.
has_data
(
field_name
)
assert
data_handling
.
dim
==
len
(
stencil
[
0
]),
"
Dimension of stencil and data handling do not match
"
self
.
_data_handling
=
data_handling
self
.
_field_name
=
field_name
self
.
_index_array_name
=
name
+
"
IndexArrays
"
self
.
_target
=
target
self
.
_default_dtype
=
create_numeric_type
(
default_dtype
)
self
.
_openmp
=
openmp
self
.
_boundary_object_to_boundary_info
=
{}
self
.
stencil
=
stencil
...
...
@@ -313,8 +315,11 @@ class BoundaryHandling:
return
self
.
_boundary_object_to_boundary_info
[
boundary_obj
].
flag
def
_create_boundary_kernel
(
self
,
symbolic_field
,
symbolic_index_field
,
boundary_obj
):
return
create_boundary_kernel
(
symbolic_field
,
symbolic_index_field
,
self
.
stencil
,
boundary_obj
,
target
=
self
.
_target
,
cpu_openmp
=
self
.
_openmp
)
cfg
=
CreateKernelConfig
()
cfg
.
target
=
self
.
_target
cfg
.
default_dtype
=
self
.
_default_dtype
cfg
.
cpu
.
openmp
.
enable
=
self
.
_openmp
return
create_boundary_kernel
(
symbolic_field
,
symbolic_index_field
,
self
.
stencil
,
boundary_obj
,
cfg
)
def
_create_index_fields
(
self
):
dh
=
self
.
_data_handling
...
...
@@ -452,11 +457,14 @@ class BoundaryOffsetInfo:
return
sp
.
Symbol
(
"
invdir
"
)
def
create_boundary_kernel
(
field
,
index_field
,
stencil
,
boundary_functor
,
target
=
Target
.
CPU
,
**
kernel_creation_args
):
def
create_boundary_kernel
(
field
,
index_field
,
stencil
,
boundary_functor
,
cfg
:
CreateKernelConfig
):
# TODO: reconsider how to control the index_dtype in boundary kernels
config
=
CreateKernelConfig
(
index_field
=
index_field
,
target
=
target
,
index_dtype
=
SInt
(
32
),
**
kernel_creation_args
)
config
=
cfg
.
copy
()
config
.
index_field
=
index_field
idx_dtype
=
SInt
(
32
)
config
.
index_dtype
=
idx_dtype
offset_info
=
BoundaryOffsetInfo
(
stencil
,
config
.
inde
x_dtype
)
offset_info
=
BoundaryOffsetInfo
(
stencil
,
id
x_dtype
)
elements
=
offset_info
.
get_array_declarations
()
dir_symbol
=
TypedSymbol
(
"
dir
"
,
config
.
index_dtype
)
elements
+=
[
Assignment
(
dir_symbol
,
index_field
[
0
](
'
dir
'
))]
...
...
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