Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pystencils-benchmark
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
Container 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
pycodegen
pystencils-benchmark
Commits
4b1f3f53
Commit
4b1f3f53
authored
1 year ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
fixed the _add_launch_bounds and also added some small tests
parent
4ee400e9
No related branches found
No related tags found
1 merge request
!1
Add CUDA support
Pipeline
#55133
skipped
Stage: docker-build
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils_benchmark/gpu/benchmark.py
+7
-3
7 additions, 3 deletions
pystencils_benchmark/gpu/benchmark.py
tests/test_launch_bounds.py
+19
-0
19 additions, 0 deletions
tests/test_launch_bounds.py
with
26 additions
and
3 deletions
pystencils_benchmark/gpu/benchmark.py
+
7
−
3
View file @
4b1f3f53
...
...
@@ -18,9 +18,13 @@ from pystencils_benchmark.enums import Compiler
def
_add_launch_bound
(
code
:
str
,
launch_bounds
:
tuple
)
->
str
:
lb_str
=
f
"
__launch_bounds__(
{
'
,
'
.
join
(
str
(
lb
)
for
lb
in
launch_bounds
)
}
)
"
splitted
=
code
.
split
(
"
void
"
)
return
splitted
[
0
]
+
lb_str
+
""
.
join
(
splitted
[
1
:])
lb_str
=
f
"
__launch_bounds__(
{
'
,
'
.
join
(
str
(
lb
)
for
lb
in
launch_bounds
)
}
)
"
splitted
=
code
.
split
(
"
void
"
)
prefix
=
splitted
[
0
]
if
code
.
startswith
(
"
void
"
):
# just in case that there is nothing before the first void
prefix
=
""
return
prefix
+
"
void
"
+
lb_str
+
"
void
"
.
join
(
splitted
[
1
:])
def
generate_benchmark
(
kernel_asts
:
Union
[
KernelFunction
,
List
[
KernelFunction
]],
...
...
This diff is collapsed.
Click to expand it.
tests/test_launch_bounds.py
0 → 100644
+
19
−
0
View file @
4b1f3f53
import
numpy
as
np
import
pystencils
as
ps
from
pystencils_benchmark.gpu.benchmark
import
kernel_header
,
_add_launch_bound
,
kernel_source
def
test_launch_bounds
():
a
,
b
,
c
=
ps
.
fields
(
a
=
np
.
ones
(
4000000
),
b
=
np
.
ones
(
4000000
),
c
=
np
.
ones
(
4000000
))
@ps.kernel_config
(
ps
.
CreateKernelConfig
(
target
=
ps
.
Target
.
GPU
))
def
vadd
():
a
[
0
]
@=
b
[
0
]
+
c
[
0
]
kernel_vadd
=
ps
.
create_kernel
(
**
vadd
)
launch_bounds
=
(
256
,
2
)
header
=
kernel_header
(
kernel_vadd
)
header
=
_add_launch_bound
(
header
,
launch_bounds
)
assert
"
void __launch_bounds__(256, 2)
"
in
header
source
=
kernel_source
(
kernel_vadd
)
source
=
_add_launch_bound
(
source
,
launch_bounds
)
assert
"
void __launch_bounds__(256, 2)
"
in
source
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