Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christoph Alt
pystencils
Commits
c8ce1744
Commit
c8ce1744
authored
Jun 08, 2021
by
Markus Holzer
Committed by
Michael Kuron
Jun 08, 2021
Browse files
Use int64 for indexing
parent
e8b9fa9c
Changes
4
Hide whitespace changes
Inline
Side-by-side
pystencils/backends/opencl_backend.py
View file @
c8ce1744
...
...
@@ -83,7 +83,7 @@ class OpenClSympyPrinter(CudaSympyPrinter):
function_name
,
dimension
=
tuple
(
symbol_name
.
split
(
"."
))
dimension
=
self
.
DIMENSION_MAPPING
[
dimension
]
function_name
=
self
.
INDEXING_FUNCTION_MAPPING
[
function_name
]
return
f
"(int)
{
function_name
}
(
{
dimension
}
)"
return
f
"(int
64_t
)
{
function_name
}
(
{
dimension
}
)"
def
_print_TextureAccess
(
self
,
node
):
raise
NotImplementedError
()
...
...
pystencils/boundaries/boundaryhandling.py
View file @
c8ce1744
...
...
@@ -430,7 +430,7 @@ class BoundaryOffsetInfo(CustomCodeNode):
inverse_dir
=
tuple
([
-
i
for
i
in
direction
])
inv_dirs
.
append
(
str
(
stencil
.
index
(
inverse_dir
)))
code
+=
"const int %s [] = { %s };
\n
"
%
(
self
.
INV_DIR_SYMBOL
.
name
,
", "
.
join
(
inv_dirs
))
code
+=
"const int
64_t
%s [] = { %s };
\n
"
%
(
self
.
INV_DIR_SYMBOL
.
name
,
", "
.
join
(
inv_dirs
))
offset_symbols
=
BoundaryOffsetInfo
.
_offset_symbols
(
dim
)
super
(
BoundaryOffsetInfo
,
self
).
__init__
(
code
,
symbols_read
=
set
(),
symbols_defined
=
set
(
offset_symbols
+
[
self
.
INV_DIR_SYMBOL
]))
...
...
@@ -439,13 +439,12 @@ class BoundaryOffsetInfo(CustomCodeNode):
def
_offset_symbols
(
dim
):
return
[
TypedSymbol
(
f
"c
{
d
}
"
,
create_type
(
np
.
int64
))
for
d
in
[
'x'
,
'y'
,
'z'
][:
dim
]]
INV_DIR_SYMBOL
=
TypedSymbol
(
"invdir"
,
"
int
"
)
INV_DIR_SYMBOL
=
TypedSymbol
(
"invdir"
,
np
.
int
64
)
def
create_boundary_kernel
(
field
,
index_field
,
stencil
,
boundary_functor
,
target
=
'cpu'
,
**
kernel_creation_args
):
elements
=
[
BoundaryOffsetInfo
(
stencil
)]
index_arr_dtype
=
index_field
.
dtype
.
numpy_dtype
dir_symbol
=
TypedSymbol
(
"dir"
,
index_arr_dtype
.
fields
[
'dir'
][
0
])
dir_symbol
=
TypedSymbol
(
"dir"
,
np
.
int64
)
elements
+=
[
Assignment
(
dir_symbol
,
index_field
[
0
](
'dir'
))]
elements
+=
boundary_functor
(
field
,
direction_symbol
=
dir_symbol
,
index_field
=
index_field
)
return
create_indexed_kernel
(
elements
,
[
index_field
],
target
=
target
,
**
kernel_creation_args
)
pystencils/cpu/kernelcreation.py
View file @
c8ce1744
from
typing
import
List
,
Union
import
sympy
as
sp
import
numpy
as
np
import
pystencils.astnodes
as
ast
from
pystencils.assignment
import
Assignment
from
pystencils.astnodes
import
Block
,
KernelFunction
,
LoopOverCoordinate
,
SympyAssignment
from
pystencils.cpu.cpujit
import
make_python_function
from
pystencils.data_types
import
BasicType
,
StructType
,
TypedSymbol
,
create_type
from
pystencils.data_types
import
StructType
,
TypedSymbol
,
create_type
from
pystencils.field
import
Field
,
FieldType
from
pystencils.transformations
import
(
add_types
,
filtered_tree_iteration
,
get_base_buffer_index
,
get_optimal_loop_ordering
,
...
...
@@ -127,7 +128,7 @@ def create_indexed_kernel(assignments: AssignmentOrAstNodeList, index_fields, fu
data_type
=
idx_field
.
dtype
if
data_type
.
has_element
(
name
):
rhs
=
idx_field
[
0
](
name
)
lhs
=
TypedSymbol
(
name
,
BasicType
(
data_type
.
get_element_type
(
name
))
)
lhs
=
TypedSymbol
(
name
,
np
.
int64
)
return
SympyAssignment
(
lhs
,
rhs
)
raise
ValueError
(
f
"Index
{
name
}
not found in any of the passed index fields"
)
...
...
pystencils/gpucuda/kernelcreation.py
View file @
c8ce1744
import
numpy
as
np
from
pystencils.astnodes
import
Block
,
KernelFunction
,
LoopOverCoordinate
,
SympyAssignment
from
pystencils.data_types
import
BasicType
,
StructType
,
TypedSymbol
from
pystencils.data_types
import
StructType
,
TypedSymbol
from
pystencils.field
import
Field
,
FieldType
from
pystencils.gpucuda.cudajit
import
make_python_function
from
pystencils.gpucuda.indexing
import
BlockIndexing
...
...
@@ -129,7 +131,7 @@ def created_indexed_cuda_kernel(assignments,
data_type
=
ind_f
.
dtype
if
data_type
.
has_element
(
name
):
rhs
=
ind_f
[
0
](
name
)
lhs
=
TypedSymbol
(
name
,
BasicType
(
data_type
.
get_element_type
(
name
))
)
lhs
=
TypedSymbol
(
name
,
np
.
int64
)
return
SympyAssignment
(
lhs
,
rhs
)
raise
ValueError
(
f
"Index
{
name
}
not found in any of the passed index fields"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment