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
f2260b3b
Commit
f2260b3b
authored
2 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Fix indexing
parent
3e1f6114
No related branches found
No related tags found
2 merge requests
!353
Draft: Generalise usage of Structs for nested array access
,
!341
Refactor gpu indexing
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/gpu/indexing.py
+4
-3
4 additions, 3 deletions
pystencils/gpu/indexing.py
pystencils/gpu/kernelcreation.py
+2
-0
2 additions, 0 deletions
pystencils/gpu/kernelcreation.py
with
6 additions
and
3 deletions
pystencils/gpu/indexing.py
+
4
−
3
View file @
f2260b3b
...
@@ -6,7 +6,7 @@ from typing import Tuple
...
@@ -6,7 +6,7 @@ from typing import Tuple
import
sympy
as
sp
import
sympy
as
sp
from
sympy.core.cache
import
cacheit
from
sympy.core.cache
import
cacheit
from
pystencils.astnodes
import
Block
,
Conditional
from
pystencils.astnodes
import
Block
,
Conditional
,
LoopOverCoordinate
,
SympyAssignment
from
pystencils.typing
import
TypedSymbol
,
create_type
from
pystencils.typing
import
TypedSymbol
,
create_type
from
pystencils.integer_functions
import
div_ceil
,
div_floor
from
pystencils.integer_functions
import
div_ceil
,
div_floor
from
pystencils.sympyextensions
import
is_integer_sequence
,
prod
from
pystencils.sympyextensions
import
is_integer_sequence
,
prod
...
@@ -169,7 +169,8 @@ class BlockIndexing(AbstractIndexing):
...
@@ -169,7 +169,8 @@ class BlockIndexing(AbstractIndexing):
def
call_parameters
(
self
,
arr_shape
):
def
call_parameters
(
self
,
arr_shape
):
numeric_iteration_slice
=
_get_numeric_iteration_slice
(
self
.
_iteration_space
,
arr_shape
)
numeric_iteration_slice
=
_get_numeric_iteration_slice
(
self
.
_iteration_space
,
arr_shape
)
widths
=
[
len
(
range
(
*
s
.
indices
(
s
.
stop
)))
for
s
in
numeric_iteration_slice
]
widths
=
[
s
.
stop
-
s
.
start
for
s
in
numeric_iteration_slice
]
widths
=
[
w
if
w
>
0
else
1
for
w
in
widths
]
extend_bs
=
(
1
,)
*
(
3
-
len
(
self
.
_block_size
))
extend_bs
=
(
1
,)
*
(
3
-
len
(
self
.
_block_size
))
block_size
=
self
.
_block_size
+
extend_bs
block_size
=
self
.
_block_size
+
extend_bs
...
@@ -192,7 +193,7 @@ class BlockIndexing(AbstractIndexing):
...
@@ -192,7 +193,7 @@ class BlockIndexing(AbstractIndexing):
def
guard
(
self
,
kernel_content
,
arr_shape
):
def
guard
(
self
,
kernel_content
,
arr_shape
):
arr_shape
=
arr_shape
[:
self
.
_dim
]
arr_shape
=
arr_shape
[:
self
.
_dim
]
numeric_iteration_slice
=
_get_numeric_iteration_slice
(
self
.
_iteration_space
,
arr_shape
)
numeric_iteration_slice
=
_get_numeric_iteration_slice
(
self
.
_iteration_space
,
arr_shape
)
end
=
[
s
.
stop
for
s
in
numeric_iteration_slice
]
end
=
[
s
.
stop
if
s
.
stop
!=
0
else
1
for
s
in
numeric_iteration_slice
]
conditions
=
[
c
<
e
for
c
,
e
in
zip
(
self
.
coordinates
,
end
)]
conditions
=
[
c
<
e
for
c
,
e
in
zip
(
self
.
coordinates
,
end
)]
for
cuda_index
,
iter_slice
in
zip
(
self
.
cuda_indices
,
self
.
_iteration_space
):
for
cuda_index
,
iter_slice
in
zip
(
self
.
cuda_indices
,
self
.
_iteration_space
):
...
...
This diff is collapsed.
Click to expand it.
pystencils/gpu/kernelcreation.py
+
2
−
0
View file @
f2260b3b
...
@@ -69,6 +69,8 @@ def create_cuda_kernel(assignments: Union[AssignmentCollection, NodeCollection],
...
@@ -69,6 +69,8 @@ def create_cuda_kernel(assignments: Union[AssignmentCollection, NodeCollection],
else
:
else
:
iteration_space
=
normalize_slice
(
iteration_slice
,
common_shape
)
iteration_space
=
normalize_slice
(
iteration_slice
,
common_shape
)
iteration_space
=
tuple
([
s
if
isinstance
(
s
,
slice
)
else
slice
(
s
,
s
,
1
)
for
s
in
iteration_space
])
indexing
=
indexing_creator
(
iteration_space
=
iteration_space
,
data_layout
=
common_field
.
layout
)
indexing
=
indexing_creator
(
iteration_space
=
iteration_space
,
data_layout
=
common_field
.
layout
)
coord_mapping
=
indexing
.
coordinates
coord_mapping
=
indexing
.
coordinates
...
...
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