Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils-sfg
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
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-sfg
Commits
f8ed8ad8
Commit
f8ed8ad8
authored
6 months ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
Added a generator script to test the sycl accessors
parent
0ee586ef
No related branches found
No related tags found
1 merge request
!3
Add support for sycl accessors
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/generator_scripts/scripts/TestSyclBuffer.py
+35
-0
35 additions, 0 deletions
tests/generator_scripts/scripts/TestSyclBuffer.py
tests/generator_scripts/test_generator_scripts.py
+14
-4
14 additions, 4 deletions
tests/generator_scripts/test_generator_scripts.py
with
49 additions
and
4 deletions
tests/generator_scripts/scripts/TestSyclBuffer.py
0 → 100644
+
35
−
0
View file @
f8ed8ad8
import
pystencils
as
ps
import
sympy
as
sp
from
pystencilssfg
import
SourceFileGenerator
from
pystencilssfg.lang.cpp.sycl_accessor
import
sycl_accessor_ref
import
pystencilssfg.extensions.sycl
as
sycl
with
SourceFileGenerator
()
as
sfg
:
sfg
=
sycl
.
SyclComposer
(
sfg
)
u_src
,
u_dst
,
f
=
ps
.
fields
(
"
u_src, u_dst, f : double[2D]
"
,
layout
=
"
fzyx
"
)
h
=
sp
.
Symbol
(
"
h
"
)
jacobi_update
=
[
ps
.
Assignment
(
u_dst
.
center
(),
(
h
**
2
*
f
[
0
,
0
]
+
u_src
[
1
,
0
]
+
u_src
[
-
1
,
0
]
+
u_src
[
0
,
1
]
+
u_src
[
0
,
-
1
])
/
4
,
)
]
kernel_config
=
ps
.
CreateKernelConfig
(
target
=
ps
.
Target
.
SYCL
)
jacobi_kernel
=
sfg
.
kernels
.
create
(
jacobi_update
,
config
=
kernel_config
)
cgh
=
sfg
.
sycl_handler
(
"
handler
"
)
rang
=
sfg
.
sycl_range
(
2
,
"
range
"
)
mappings
=
[
sfg
.
map_field
(
u_src
,
sycl_accessor_ref
(
u_src
)),
sfg
.
map_field
(
u_dst
,
sycl_accessor_ref
(
u_dst
)),
sfg
.
map_field
(
f
,
sycl_accessor_ref
(
f
)),
]
sfg
.
function
(
"
jacobiUpdate
"
)(
cgh
.
parallel_for
(
rang
)(
*
mappings
,
sfg
.
call
(
jacobi_kernel
)),
)
This diff is collapsed.
Click to expand it.
tests/generator_scripts/test_generator_scripts.py
+
14
−
4
View file @
f8ed8ad8
...
...
@@ -74,7 +74,7 @@ SCRIPTS = [
"
--sfg-file-extensionss
"
,
"
.c++,.h++
"
,
),
should_fail
=
True
should_fail
=
True
,
),
ScriptInfo
.
make
(
"
TestExtraCommandLineArgs
"
,
...
...
@@ -85,13 +85,19 @@ SCRIPTS = [
"
--precision
"
,
"
float32
"
,
"
test1
"
,
"
test2
"
"
test2
"
,
),
),
ScriptInfo
.
make
(
"
Structural
"
,
(
"
hpp
"
,
"
cpp
"
)),
ScriptInfo
.
make
(
"
SimpleJacobi
"
,
(
"
hpp
"
,
"
cpp
"
),
compilable_output
=
"
cpp
"
),
ScriptInfo
.
make
(
"
SimpleClasses
"
,
(
"
hpp
"
,
"
cpp
"
)),
ScriptInfo
.
make
(
"
Variables
"
,
(
"
hpp
"
,
"
cpp
"
),
compilable_output
=
"
cpp
"
),
ScriptInfo
.
make
(
"
TestSyclBuffer
"
,
(
"
hpp
"
,
"
cpp
"
),
compilable_output
=
"
cpp
"
if
shutil
.
which
(
"
icpx
"
)
else
None
,
compile_cmd
=
"
icpx -fsycl -std=c++20
"
if
shutil
.
which
(
"
icpx
"
)
else
""
,
),
]
...
...
@@ -113,13 +119,17 @@ def test_generator_script(script_info: ScriptInfo):
shutil
.
rmtree
(
output_dir
)
os
.
makedirs
(
output_dir
,
exist_ok
=
True
)
args
=
[
"
python
"
,
script_file
,
"
--sfg-output-dir
"
,
output_dir
]
+
list
(
script_info
.
args
)
args
=
[
"
python
"
,
script_file
,
"
--sfg-output-dir
"
,
output_dir
]
+
list
(
script_info
.
args
)
result
=
subprocess
.
run
(
args
)
if
script_info
.
should_fail
:
if
result
.
returncode
==
0
:
pytest
.
fail
(
f
"
Generator script
{
script_name
}
was supposed to fail, but didn
'
t.
"
)
pytest
.
fail
(
f
"
Generator script
{
script_name
}
was supposed to fail, but didn
'
t.
"
)
return
if
result
.
returncode
!=
0
:
...
...
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