Skip to content
Snippets Groups Projects
Commit 7308f616 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

minor fixes; move kernelcreation API

parent 8af40ae4
Branches
Tags
1 merge request!430Jupyter Inspection Framework, Book Theme, and Initial Drafts for Codegen Reference Guides
Pipeline #70936 passed
...@@ -25,6 +25,7 @@ The following feature sets are available: ...@@ -25,6 +25,7 @@ The following feature sets are available:
- `interactive` (**recommended**): Install dependencies for using pystencils interactively from - `interactive` (**recommended**): Install dependencies for using pystencils interactively from
within Jupyter notebooks. within Jupyter notebooks.
Setting this flag will cause pip to install `jupyter`, `matplotlib`, and `graphviz`, among others, alongside pystencils.
- `alltrafos` (**recommended**): Install dependencies to enable a wider set of code transformation. - `alltrafos` (**recommended**): Install dependencies to enable a wider set of code transformation.
These include [islpy](https://pypi.org/project/islpy/) for polyhedral loop transformations, These include [islpy](https://pypi.org/project/islpy/) for polyhedral loop transformations,
and [py-cpuinfo](https://pypi.org/project/py-cpuinfo/) for detecting the current hardware in order and [py-cpuinfo](https://pypi.org/project/py-cpuinfo/) for detecting the current hardware in order
......
Code Generator and Configuration
================================
.. module:: pystencils.kernelcreation
.. autosummary::
:toctree: generated
:nosignatures:
create_kernel
.. module:: pystencils.config
.. autosummary::
:toctree: generated
:nosignatures:
:template: autosummary/entire_class.rst
CreateKernelConfig
CpuOptimConfig
OpenMpConfig
VectorizationConfig
GpuIndexingConfig
.. autosummary::
:toctree: generated
:nosignatures:
AUTO
\ No newline at end of file
...@@ -10,3 +10,4 @@ Modules ...@@ -10,3 +10,4 @@ Modules
field field
sympyextensions sympyextensions
codegen
...@@ -40,13 +40,11 @@ It takes two arguments: ...@@ -40,13 +40,11 @@ It takes two arguments:
- and a configuration object, an instance of {any}`CreateKernelConfig <pystencils.config.CreateKernelConfig>`. - and a configuration object, an instance of {any}`CreateKernelConfig <pystencils.config.CreateKernelConfig>`.
```{eval-rst} ```{eval-rst}
.. module:: pystencils.kernelcreation
.. autosummary:: .. autosummary::
:toctree: generated
:nosignatures: :nosignatures:
create_kernel pystencils.kernelcreation.create_kernel
pystencils.config.CreateKernelConfig
``` ```
For a simple kernel, an invocation of the code generator might look like this: For a simple kernel, an invocation of the code generator might look like this:
...@@ -106,28 +104,6 @@ The code generation engine can be configured using a wide range of options. ...@@ -106,28 +104,6 @@ The code generation engine can be configured using a wide range of options.
This section aims at explaining the majority of these options, This section aims at explaining the majority of these options,
their interaction and effects, use cases and caveats. their interaction and effects, use cases and caveats.
```{eval-rst}
.. module:: pystencils.config
.. autosummary::
:toctree: generated
:nosignatures:
:template: autosummary/entire_class.rst
CreateKernelConfig
CpuOptimConfig
OpenMpConfig
VectorizationConfig
GpuIndexingConfig
.. autosummary::
:toctree: generated
:nosignatures:
AUTO
```
### Target Specification ### Target Specification
...@@ -291,7 +267,8 @@ of its stencil -- that is, the maximum neighbor offset encountered in any field ...@@ -291,7 +267,8 @@ of its stencil -- that is, the maximum neighbor offset encountered in any field
If, for instance, a neighbor node in $x$-direction with offset $k$ is accessed by the kernel, If, for instance, a neighbor node in $x$-direction with offset $k$ is accessed by the kernel,
it cannot legally execute on the outermost $k$ layers of nodes in that direction since it would it cannot legally execute on the outermost $k$ layers of nodes in that direction since it would
access memory out-of-bounds. access memory out-of-bounds.
Therefore, an automatic number of $k$ ghost layers is inferred. Therefore, an automatic number of $k$ ghost layers at each domain border is inferred.
As we can see in the example below, the number of inferred ghost layers at each domain border will be set to the maximum required in any dimension.
```{code-cell} ipython3 ```{code-cell} ipython3
:tags: [remove-cell] :tags: [remove-cell]
...@@ -302,13 +279,13 @@ u, v = ps.fields("u, v: [2D]") ...@@ -302,13 +279,13 @@ u, v = ps.fields("u, v: [2D]")
To illustrate, the following kernel accesses neighbor nodes with a maximum offset of two: To illustrate, the following kernel accesses neighbor nodes with a maximum offset of two:
```{code-cell} ipython3 ```{code-cell} ipython3
ranged_update = ps.Assignment(u.center(), v[-2, -2] + v[2, 2]) ranged_update = ps.Assignment(u.center(), v[-2, -1] + v[2, 1])
cfg = ps.CreateKernelConfig(ghost_layers=ps.config.AUTO) cfg = ps.CreateKernelConfig(ghost_layers=ps.config.AUTO)
kernel = ps.create_kernel(ranged_update, cfg) kernel = ps.create_kernel(ranged_update, cfg)
``` ```
With `ghost_layers=ps.config.AUTO`, its iteration space will look like this (yellow cells are included, purple cells excluded): With `ghost_layers=ps.config.AUTO`, its iteration space will look like this (yellow cells are included, purple cells excluded).
```{code-cell} ipython3 ```{code-cell} ipython3
:tags: [remove-input] :tags: [remove-input]
...@@ -453,7 +430,7 @@ and use a step size of two: ...@@ -453,7 +430,7 @@ and use a step size of two:
$$ $$
start(y)= start(y)=
\begin{cases} \begin{cases}
0 & \quad \text{if } y \% 2 = 0 \\ 0 & \quad \text{if } y \; \mathrm{rem} \; 2 = 0 \\
1 & \quad \text{otherwise} 1 & \quad \text{otherwise}
\end{cases} \end{cases}
$$ $$
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment