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
7c371fb4
Commit
7c371fb4
authored
4 months ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
make no assumptions about warp_size for Target.HIP
parent
9e729903
No related branches found
No related tags found
1 merge request
!458
HIP Target and Platform
Pipeline
#76708
canceled
4 months ago
Stage: Code Quality
Stage: Unit Tests
Stage: legacy_test
Stage: docs
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/pystencils/codegen/driver.py
+3
-1
3 additions, 1 deletion
src/pystencils/codegen/driver.py
src/pystencils/codegen/gpu_indexing.py
+14
-6
14 additions, 6 deletions
src/pystencils/codegen/gpu_indexing.py
tests/kernelcreation/test_gpu.py
+3
-2
3 additions, 2 deletions
tests/kernelcreation/test_gpu.py
with
20 additions
and
9 deletions
src/pystencils/codegen/driver.py
+
3
−
1
View file @
7c371fb4
from
__future__
import
annotations
from
typing
import
cast
,
Sequence
,
Callable
,
TYPE_CHECKING
from
dataclasses
import
dataclass
,
replace
from
warnings
import
warn
from
.target
import
Target
from
.config
import
(
...
...
@@ -410,7 +411,8 @@ class DefaultKernelCreationDriver:
if
warp_size
is
None
:
warp_size
=
GpuOptions
.
default_warp_size
(
self
.
_target
)
# TODO: Warn if warp_size is None and assume_warp_aligned_block_size is True
if
warp_size
is
None
and
assume_warp_aligned_block_size
:
warn
(
"
GPU warp size is unknown - ignoring assumption `assume_warp_aligned_block_size`.
"
)
return
GpuIndexing
(
self
.
_ctx
,
...
...
This diff is collapsed.
Click to expand it.
src/pystencils/codegen/gpu_indexing.py
+
14
−
6
View file @
7c371fb4
...
...
@@ -30,7 +30,7 @@ _Dim3Lambda = tuple[Lambda, Lambda, Lambda]
@dataclass
class
HardwareProperties
:
warp_size
:
int
warp_size
:
int
|
None
max_threads_per_block
:
int
max_block_sizes
:
dim3
...
...
@@ -204,6 +204,7 @@ class ManualLaunchConfiguration(GpuLaunchConfiguration):
if
(
self
.
_assume_warp_aligned_block_size
and
self
.
_hw_props
.
warp_size
is
not
None
and
prod
(
self
.
_block_size
)
%
self
.
_hw_props
.
warp_size
!=
0
):
raise
CodegenError
(
...
...
@@ -316,7 +317,7 @@ class DynamicBlockSizeLaunchConfiguration(GpuLaunchConfiguration):
return
(
*
to_round
[:
index_to_round
],
ceil_to_multiple
(
to_round
[
index_to_round
],
warp_size
),
*
to_round
[
index_to_round
+
1
:],
*
to_round
[
index_to_round
+
1
:],
)
else
:
return
(
...
...
@@ -351,7 +352,8 @@ class DynamicBlockSizeLaunchConfiguration(GpuLaunchConfiguration):
if
(
self
.
_assume_warp_aligned_block_size
and
prod
(
ret
)
%
self
.
_hw_props
.
warp_size
!=
0
and
hw_props
.
warp_size
is
not
None
and
prod
(
ret
)
%
hw_props
.
warp_size
!=
0
):
self
.
_round_block_sizes_to_warp_size
(
ret
,
hw_props
.
warp_size
)
...
...
@@ -387,6 +389,10 @@ class DynamicBlockSizeLaunchConfiguration(GpuLaunchConfiguration):
return
ret
trimmed
=
trim
(
list
(
block_size
))
if
hw_props
.
warp_size
is
None
:
return
tuple
(
trimmed
)
if
(
prod
(
trimmed
)
>=
hw_props
.
warp_size
and
prod
(
trimmed
)
%
hw_props
.
warp_size
==
0
...
...
@@ -493,14 +499,13 @@ class GpuIndexing:
ctx
:
KernelCreationContext
,
target
:
Target
,
scheme
:
GpuIndexingScheme
,
warp_size
:
int
,
warp_size
:
int
|
None
,
manual_launch_grid
:
bool
=
False
,
assume_warp_aligned_block_size
:
bool
=
False
,
)
->
None
:
self
.
_ctx
=
ctx
self
.
_target
=
target
self
.
_scheme
=
scheme
self
.
_warp_size
=
warp_size
self
.
_manual_launch_grid
=
manual_launch_grid
self
.
_assume_warp_aligned_block_size
=
assume_warp_aligned_block_size
...
...
@@ -608,7 +613,10 @@ class GpuIndexing:
# impossible to use block size determination function since the iteration space is unknown
# -> round block size in fastest moving dimension up to multiple of warp size
rounded_block_size
:
PsExpression
if
self
.
_assume_warp_aligned_block_size
:
if
(
self
.
_assume_warp_aligned_block_size
and
self
.
_hw_props
.
warp_size
is
not
None
):
warp_size
=
self
.
_ast_factory
.
parse_index
(
self
.
_hw_props
.
warp_size
)
rounded_block_size
=
self
.
_ast_factory
.
parse_index
(
PsIntDiv
(
...
...
This diff is collapsed.
Click to expand it.
tests/kernelcreation/test_gpu.py
+
3
−
2
View file @
7c371fb4
...
...
@@ -145,8 +145,9 @@ def test_block_size_adaptations(
cfg
=
CreateKernelConfig
(
target
=
target
)
cfg
.
gpu
.
indexing_scheme
=
"
linear3d
"
cfg
.
gpu
.
assume_warp_aligned_block_size
=
assume_warp_aligned_block_size
warp_size
=
cfg
.
gpu
.
default_warp_size
(
cfg
.
get_target
())
warp_size
=
32
cfg
.
gpu
.
warp_size
=
warp_size
ast
=
create_kernel
(
asm
,
cfg
)
kernel
=
ast
.
compile
()
...
...
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