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
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
Jan Hönig
pystencils
Commits
9577deec
Commit
9577deec
authored
3 years ago
by
Jan Hönig
Browse files
Options
Downloads
Patches
Plain Diff
Benchmark works again
parent
a534e81b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/notebooks/demo_ve.ipynb
+25
-61
25 additions, 61 deletions
doc/notebooks/demo_ve.ipynb
with
25 additions
and
61 deletions
doc/notebooks/demo_ve.ipynb
+
25
−
61
View file @
9577deec
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
29
,
"execution_count":
1
,
"id": "5d56a49c-5963-4f86-a8d8-0b753a971e52",
"id": "5d56a49c-5963-4f86-a8d8-0b753a971e52",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
30
,
"execution_count":
2
,
"id": "9c204a47-a39b-450b-9026-9bb63cf54e83",
"id": "9c204a47-a39b-450b-9026-9bb63cf54e83",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
...
@@ -64,7 +64,7 @@
...
@@ -64,7 +64,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 3
1
,
"execution_count": 3,
"id": "5bbc4118-e1b7-412b-9dc8-7d7d524786df",
"id": "5bbc4118-e1b7-412b-9dc8-7d7d524786df",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
...
@@ -75,19 +75,19 @@
...
@@ -75,19 +75,19 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
32
,
"execution_count":
4
,
"id": "85641913-f00a-4f95-af69-c7646ad5b3d0",
"id": "85641913-f00a-4f95-af69-c7646ad5b3d0",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"@ps.kernel(config)\n",
"@ps.kernel
_config
(config)\n",
"def vadd():\n",
"def vadd():\n",
" a[0] @= b[0] + c[0]"
" a[0] @= b[0] + c[0]"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
33
,
"execution_count":
5
,
"id": "33097862-9f60-4624-a1f2-0fdfd82831bc",
"id": "33097862-9f60-4624-a1f2-0fdfd82831bc",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
...
@@ -115,19 +115,19 @@
...
@@ -115,19 +115,19 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
34
,
"execution_count":
6
,
"id": "99aee06b-1704-4d06-b261-cc07a6a7f9a3",
"id": "99aee06b-1704-4d06-b261-cc07a6a7f9a3",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"@ps.kernel(config)\n",
"@ps.kernel
_config
(config)\n",
"def daxpy():\n",
"def daxpy():\n",
" b[0] @= alpha * a[0] + b[0]"
" b[0] @= alpha * a[0] + b[0]"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
35
,
"execution_count":
7
,
"id": "e79ab7bb-128e-47ee-9d53-8779c4f55d7e",
"id": "e79ab7bb-128e-47ee-9d53-8779c4f55d7e",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
...
@@ -155,19 +155,19 @@
...
@@ -155,19 +155,19 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
36
,
"execution_count":
8
,
"id": "4bb14872-11de-42cc-b5fc-4f995c7a6725",
"id": "4bb14872-11de-42cc-b5fc-4f995c7a6725",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"@ps.kernel(config)\n",
"@ps.kernel
_config
(config)\n",
"def daxpy_one_off():\n",
"def daxpy_one_off():\n",
" b[0] @= alpha * a[0] + b[0]"
" b[0] @= alpha * a[0] + b[0]"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
37
,
"execution_count":
9
,
"id": "457cc1fe-1aef-44bd-9fd1-f914e019c933",
"id": "457cc1fe-1aef-44bd-9fd1-f914e019c933",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
...
@@ -195,87 +195,51 @@
...
@@ -195,87 +195,51 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 38,
"execution_count": 12,
"id": "fea2f8e4",
"metadata": {},
"outputs": [],
"source": [
"#from pystencils.kerncraft_coupling import generate_benchmark"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "4fbd5c90",
"metadata": {},
"outputs": [],
"source": [
"#print(generate_benchmark(kernel_vadd))"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "ae05beb9-745f-4885-ad4f-667aae867f05",
"id": "ae05beb9-745f-4885-ad4f-667aae867f05",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"from pystencils
.
benchmark import kernel_header, kernel_source, generate_benchmark\n",
"from pystencils
_
benchmark import kernel_header, kernel_source, generate_benchmark\n",
"from pathlib import Path"
"from pathlib import Path"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
4
1,
"execution_count": 1
3
,
"id": "7dfa86e1-8962-47df-900c-3133883a19c7",
"id": "7dfa86e1-8962-47df-900c-3133883a19c7",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"example_path = Path.cwd() / 'example'\n",
"example_path = Path.cwd() / 'example'"
"example_path.mkdir(parents=True, exist_ok=True)"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
4
2,
"execution_count": 2
1
,
"id": "dd39502f-d935-4b88-b8c8-896b1a294bf9",
"id": "dd39502f-d935-4b88-b8c8-896b1a294bf9",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [],
{
"ename": "ValueError",
"evalue": "Unknown dialect='c'",
"output_type": "error",
"traceback": [
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
"\u001B[0;31mValueError\u001B[0m Traceback (most recent call last)",
"\u001B[0;32m/tmp/ipykernel_209040/990452426.py\u001B[0m in \u001B[0;36m<module>\u001B[0;34m\u001B[0m\n\u001B[0;32m----> 1\u001B[0;31m \u001B[0mgenerate_benchmark\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mkernel_vadd\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mexample_path\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m 2\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
"\u001B[0;32m~/git/pystencils/pystencils/benchmark/benchmark.py\u001B[0m in \u001B[0;36mgenerate_benchmark\u001B[0;34m(kernel_ast, path, dialect, kernel_name)\u001B[0m\n\u001B[1;32m 13\u001B[0m \u001B[0mkernel_name\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mkernel_ast\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mfunction_name\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m 14\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m---> 15\u001B[0;31m \u001B[0mheader\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mkernel_header\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mkernel_ast\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mdialect\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m 16\u001B[0m \u001B[0;32mwith\u001B[0m \u001B[0mopen\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mpath\u001B[0m \u001B[0;34m/\u001B[0m \u001B[0;34mf'{kernel_name}.h'\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0;34m'w+'\u001B[0m\u001B[0;34m)\u001B[0m \u001B[0;32mas\u001B[0m \u001B[0mf\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m 17\u001B[0m \u001B[0mf\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mwrite\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mheader\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
"\u001B[0;32m~/git/pystencils/pystencils/benchmark/benchmark.py\u001B[0m in \u001B[0;36mkernel_header\u001B[0;34m(kernel_ast, dialect)\u001B[0m\n\u001B[1;32m 23\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m 24\u001B[0m \u001B[0;32mdef\u001B[0m \u001B[0mkernel_header\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mkernel_ast\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mdialect\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;34m'c'\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m---> 25\u001B[0;31m \u001B[0mfunction_signature\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mgenerate_c\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mkernel_ast\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mdialect\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0mdialect\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0msignature_only\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;32mTrue\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m 26\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m 27\u001B[0m jinja_context = {\n",
"\u001B[0;32m~/git/pystencils/pystencils/backends/cbackend.py\u001B[0m in \u001B[0;36mgenerate_c\u001B[0;34m(ast_node, signature_only, dialect, custom_backend, with_globals)\u001B[0m\n\u001B[1;32m 76\u001B[0m \u001B[0mprinter\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mOpenClBackend\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0msignature_only\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0msignature_only\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m 77\u001B[0m \u001B[0;32melse\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m---> 78\u001B[0;31m \u001B[0;32mraise\u001B[0m \u001B[0mValueError\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34mf'Unknown {dialect=}'\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m 79\u001B[0m \u001B[0mcode\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mprinter\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mast_node\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m 80\u001B[0m \u001B[0;32mif\u001B[0m \u001B[0;32mnot\u001B[0m \u001B[0msignature_only\u001B[0m \u001B[0;32mand\u001B[0m \u001B[0misinstance\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mast_node\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mKernelFunction\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
"\u001B[0;31mValueError\u001B[0m: Unknown dialect='c'"
]
}
],
"source": [
"source": [
"generate_benchmark(kernel_vadd, example_path)"
"generate_benchmark(
[
kernel_vadd,
kernel_daxpy, kernel_daxpy_one_off],
example_path)"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
20
,
"id": "f084548f-3a8e-4d45-8c7e-5845013b222e",
"id": "f084548f-3a8e-4d45-8c7e-5845013b222e",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"# Examples:\n",
"# Examples:\n",
"generate_benchmark(kernel_daxpy, example_path)\n",
"
#
generate_benchmark(kernel_daxpy, example_path)\n",
"generate_benchmark(kernel_vadd, example_path)\n",
"
#
generate_benchmark(kernel_vadd, example_path)\n",
"generate_benchmark(kernel_daxpy_one_off, example_path)"
"
#
generate_benchmark(kernel_daxpy_one_off, example_path)"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
15
,
"id": "954b5ec7-a88a-4723-bd7f-227a3919b32d",
"id": "954b5ec7-a88a-4723-bd7f-227a3919b32d",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
...
@@ -283,7 +247,7 @@
...
@@ -283,7 +247,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
15
,
"id": "f51f2aff-f232-4de9-a0c4-94d3682eff86",
"id": "f51f2aff-f232-4de9-a0c4-94d3682eff86",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
...
...
%% Cell type:markdown id:b79814e5-9a10-4b20-a886-c16db785bc48 tags:
%% Cell type:markdown id:b79814e5-9a10-4b20-a886-c16db785bc48 tags:
# LLVM-VE Vector Intrinsics
# LLVM-VE Vector Intrinsics
-
[
Tutorial
](
https://sx-aurora-dev.github.io/ve-intrinsics-tutorial/
)
-
[
Tutorial
](
https://sx-aurora-dev.github.io/ve-intrinsics-tutorial/
)
-
[
List of intrinsics
](
https://sx-aurora-dev.github.io/velintrin.html
)
-
[
List of intrinsics
](
https://sx-aurora-dev.github.io/velintrin.html
)
-
[
Assembly manual
](
https://www.hpc.nec/documents/sdk/pdfs/VectorEngine-as-manual-v1.3.pdf
)
-
[
Assembly manual
](
https://www.hpc.nec/documents/sdk/pdfs/VectorEngine-as-manual-v1.3.pdf
)
## Vector Register
## Vector Register
-
`__vr`
: 256 x 64 bit values
-
`__vr`
: 256 x 64 bit values
-
64 registers available (
**beware of spilling**
)
-
64 registers available (
**beware of spilling**
)
## Intrinsic Functions
## Intrinsic Functions
-
format:
`_vel_<asm>_<suffix>`
-
format:
`_vel_<asm>_<suffix>`
-
`<asm>`
: instruction mnemonic in the
[
assembly manual
](
https://www.hpc.nec/documents/sdk/pdfs/VectorEngine-as-manual-v1.3.pdf
)
-
`<asm>`
: instruction mnemonic in the
[
assembly manual
](
https://www.hpc.nec/documents/sdk/pdfs/VectorEngine-as-manual-v1.3.pdf
)
-
has one suffix which handles the type:
`d`
: double
-
has one suffix which handles the type:
`d`
: double
-
`<suffix>`
: list of return value and arguments
-
`<suffix>`
: list of return value and arguments
-
`v`
: vector
-
`v`
: vector
-
`s`
: scalar
-
`s`
: scalar
-
`m`
and
`M`
: mask for 256 and 512 elements
-
`m`
and
`M`
: mask for 256 and 512 elements
-
`l`
: vector length
-
`l`
: vector length
## Vector Load/Store
## Vector Load/Store
-
64 bit:
`_vel_vld_vssl`
-
64 bit:
`_vel_vld_vssl`
-
32 bit: upper, lower or "packed"
-
32 bit: upper, lower or "packed"
-
2
`s`
arguments: stride; base adress
-
2
`s`
arguments: stride; base adress
## Vector Length and Pass Through Argument
## Vector Length and Pass Through Argument
-
`l`
defines how many elements are updated
-
`l`
defines how many elements are updated
-
all instructions with additional
`v`
available, which is passed to the non-updated elements (pass-through:
`pt`
)
-
all instructions with additional
`v`
available, which is passed to the non-updated elements (pass-through:
`pt`
)
## NT-Stores
## NT-Stores
-
`nc`
variants of memory access intrinsics (e.g.
`_vel_vldnc_vssl`
)
-
`nc`
variants of memory access intrinsics (e.g.
`_vel_vldnc_vssl`
)
## Vector Mask
## Vector Mask
-
`__vm256`
: 256 bit
-
`__vm256`
: 256 bit
-
8 registers
-
8 registers
-
0 bit -> no update
-
0 bit -> no update
-
instructions with
`m`
suffix
-
instructions with
`m`
suffix
## Packed Instructions
## Packed Instructions
-
operations on 512 elements of
`fp32`
or
`int32`
.
-
operations on 512 elements of
`fp32`
or
`int32`
.
-
`p`
prefix (e.g.
`_vel_pvfadd_vl`
)
-
`p`
prefix (e.g.
`_vel_pvfadd_vl`
)
-
TBD...
-
TBD...
%% Cell type:code id:5d56a49c-5963-4f86-a8d8-0b753a971e52 tags:
%% Cell type:code id:5d56a49c-5963-4f86-a8d8-0b753a971e52 tags:
```
python
```
python
from
pystencils.session
import
*
from
pystencils.session
import
*
import
pystencils
as
ps
import
pystencils
as
ps
```
```
%% Cell type:code id:9c204a47-a39b-450b-9026-9bb63cf54e83 tags:
%% Cell type:code id:9c204a47-a39b-450b-9026-9bb63cf54e83 tags:
```
python
```
python
config
=
ps
.
CreateKernelConfig
(
cpu_vectorize_info
=
{
'
instruction_set
'
:
'
ve
'
})
config
=
ps
.
CreateKernelConfig
(
cpu_vectorize_info
=
{
'
instruction_set
'
:
'
ve
'
})
```
```
%% Cell type:code id:5bbc4118-e1b7-412b-9dc8-7d7d524786df tags:
%% Cell type:code id:5bbc4118-e1b7-412b-9dc8-7d7d524786df tags:
```
python
```
python
a
,
b
,
c
=
ps
.
fields
(
a
=
np
.
ones
(
4000000
),
b
=
np
.
ones
(
4000000
),
c
=
np
.
ones
(
4000000
))
a
,
b
,
c
=
ps
.
fields
(
a
=
np
.
ones
(
4000000
),
b
=
np
.
ones
(
4000000
),
c
=
np
.
ones
(
4000000
))
alpha
=
sp
.
symbols
(
'
alpha
'
)
alpha
=
sp
.
symbols
(
'
alpha
'
)
```
```
%% Cell type:code id:85641913-f00a-4f95-af69-c7646ad5b3d0 tags:
%% Cell type:code id:85641913-f00a-4f95-af69-c7646ad5b3d0 tags:
```
python
```
python
@ps.kernel
(
config
)
@ps.kernel
_config
(
config
)
def
vadd
():
def
vadd
():
a
[
0
]
@=
b
[
0
]
+
c
[
0
]
a
[
0
]
@=
b
[
0
]
+
c
[
0
]
```
```
%% Cell type:code id:33097862-9f60-4624-a1f2-0fdfd82831bc tags:
%% Cell type:code id:33097862-9f60-4624-a1f2-0fdfd82831bc tags:
```
python
```
python
kernel_vadd
=
ps
.
create_kernel
(
**
vadd
)
kernel_vadd
=
ps
.
create_kernel
(
**
vadd
)
ps
.
show_code
(
kernel_vadd
)
ps
.
show_code
(
kernel_vadd
)
```
```
%% Output
%% Output
%% Cell type:code id:99aee06b-1704-4d06-b261-cc07a6a7f9a3 tags:
%% Cell type:code id:99aee06b-1704-4d06-b261-cc07a6a7f9a3 tags:
```
python
```
python
@ps.kernel
(
config
)
@ps.kernel
_config
(
config
)
def
daxpy
():
def
daxpy
():
b
[
0
]
@=
alpha
*
a
[
0
]
+
b
[
0
]
b
[
0
]
@=
alpha
*
a
[
0
]
+
b
[
0
]
```
```
%% Cell type:code id:e79ab7bb-128e-47ee-9d53-8779c4f55d7e tags:
%% Cell type:code id:e79ab7bb-128e-47ee-9d53-8779c4f55d7e tags:
```
python
```
python
kernel_daxpy
=
ps
.
create_kernel
(
**
daxpy
)
kernel_daxpy
=
ps
.
create_kernel
(
**
daxpy
)
ps
.
show_code
(
kernel_daxpy
)
ps
.
show_code
(
kernel_daxpy
)
```
```
%% Output
%% Output
%% Cell type:code id:4bb14872-11de-42cc-b5fc-4f995c7a6725 tags:
%% Cell type:code id:4bb14872-11de-42cc-b5fc-4f995c7a6725 tags:
```
python
```
python
@ps.kernel
(
config
)
@ps.kernel
_config
(
config
)
def
daxpy_one_off
():
def
daxpy_one_off
():
b
[
0
]
@=
alpha
*
a
[
0
]
+
b
[
0
]
b
[
0
]
@=
alpha
*
a
[
0
]
+
b
[
0
]
```
```
%% Cell type:code id:457cc1fe-1aef-44bd-9fd1-f914e019c933 tags:
%% Cell type:code id:457cc1fe-1aef-44bd-9fd1-f914e019c933 tags:
```
python
```
python
kernel_daxpy_one_off
=
ps
.
create_kernel
(
**
daxpy_one_off
)
kernel_daxpy_one_off
=
ps
.
create_kernel
(
**
daxpy_one_off
)
ps
.
show_code
(
kernel_daxpy_one_off
)
ps
.
show_code
(
kernel_daxpy_one_off
)
```
```
%% Output
%% Output
%% Cell type:code id:fea2f8e4 tags:
```
python
#from pystencils.kerncraft_coupling import generate_benchmark
```
%% Cell type:code id:4fbd5c90 tags:
```
python
#print(generate_benchmark(kernel_vadd))
```
%% Cell type:code id:ae05beb9-745f-4885-ad4f-667aae867f05 tags:
%% Cell type:code id:ae05beb9-745f-4885-ad4f-667aae867f05 tags:
```
python
```
python
from
pystencils
.
benchmark
import
kernel_header
,
kernel_source
,
generate_benchmark
from
pystencils
_
benchmark
import
kernel_header
,
kernel_source
,
generate_benchmark
from
pathlib
import
Path
from
pathlib
import
Path
```
```
%% Cell type:code id:7dfa86e1-8962-47df-900c-3133883a19c7 tags:
%% Cell type:code id:7dfa86e1-8962-47df-900c-3133883a19c7 tags:
```
python
```
python
example_path
=
Path
.
cwd
()
/
'
example
'
example_path
=
Path
.
cwd
()
/
'
example
'
example_path
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
```
```
%% Cell type:code id:dd39502f-d935-4b88-b8c8-896b1a294bf9 tags:
%% Cell type:code id:dd39502f-d935-4b88-b8c8-896b1a294bf9 tags:
```
python
```
python
generate_benchmark
(
kernel_vadd
,
example_path
)
generate_benchmark
(
[
kernel_vadd
,
kernel_daxpy
,
kernel_daxpy_one_off
],
example_path
)
```
```
%% Output
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/tmp/ipykernel_209040/990452426.py in <module>
----> 1 generate_benchmark(kernel_vadd, example_path)
2
~/git/pystencils/pystencils/benchmark/benchmark.py in generate_benchmark(kernel_ast, path, dialect, kernel_name)
13 kernel_name = kernel_ast.function_name
14
---> 15 header = kernel_header(kernel_ast, dialect)
16 with open(path / f'{kernel_name}.h', 'w+') as f:
17 f.write(header)
~/git/pystencils/pystencils/benchmark/benchmark.py in kernel_header(kernel_ast, dialect)
23
24 def kernel_header(kernel_ast, dialect='c'):
---> 25 function_signature = generate_c(kernel_ast, dialect=dialect, signature_only=True)
26
27 jinja_context = {
~/git/pystencils/pystencils/backends/cbackend.py in generate_c(ast_node, signature_only, dialect, custom_backend, with_globals)
76 printer = OpenClBackend(signature_only=signature_only)
77 else:
---> 78 raise ValueError(f'Unknown {dialect=}')
79 code = printer(ast_node)
80 if not signature_only and isinstance(ast_node, KernelFunction):
ValueError: Unknown dialect='c'
%% Cell type:code id:f084548f-3a8e-4d45-8c7e-5845013b222e tags:
%% Cell type:code id:f084548f-3a8e-4d45-8c7e-5845013b222e tags:
```
python
```
python
# Examples:
# Examples:
generate_benchmark
(
kernel_daxpy
,
example_path
)
#
generate_benchmark(kernel_daxpy, example_path)
generate_benchmark
(
kernel_vadd
,
example_path
)
#
generate_benchmark(kernel_vadd, example_path)
generate_benchmark
(
kernel_daxpy_one_off
,
example_path
)
#
generate_benchmark(kernel_daxpy_one_off, example_path)
```
```
%% Cell type:code id:954b5ec7-a88a-4723-bd7f-227a3919b32d tags:
%% Cell type:code id:954b5ec7-a88a-4723-bd7f-227a3919b32d tags:
```
python
```
python
``
`
``
`
%%
Cell
type
:
code
id
:
f51f2aff
-
f232
-
4
de9
-
a0c4
-
94
d3682eff86
tags
:
%%
Cell
type
:
code
id
:
f51f2aff
-
f232
-
4
de9
-
a0c4
-
94
d3682eff86
tags
:
```
python
```
python
```
```
...
...
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