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

update API in docs

parent 8847aa12
No related branches found
No related tags found
1 merge request!433Consolidate codegen and JIT modules.
Pipeline #70775 passed
......@@ -12,7 +12,12 @@ BUILDDIR = build
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
clean:
rm -rf source/reference/generated
rm -rf source/backend/generated
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help clean Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
......
......@@ -2,5 +2,5 @@
Just-In-Time Compilation
************************
.. automodule:: pystencils.backend.jit
.. automodule:: pystencils.jit
:members:
......@@ -76,7 +76,7 @@ The above alignment property, for instance, may be added to a pointer symbol by
to document its assumption that the pointer be properly aligned, in order to emit aligned load and store instructions.
It then becomes the responsibility of the runtime system embedding the kernel to check this prequesite before calling the kernel.
To make sure this information becomes visible, any properties attached to symbols exposed as kernel parameters will also
be added to their respective `KernelParameter` instance.
be added to their respective `Parameter` instance.
Buffers
-------
......@@ -110,7 +110,7 @@ The context makes sure to avoid name conflicts between buffers.
API Documentation
=================
.. automodule:: pystencils.backend.properties
.. automodule:: pystencils.codegen.properties
:members:
.. automodule:: pystencils.backend.memory
......
......@@ -49,9 +49,9 @@ ps.inspect(kernel)
```
The `kernel` object returned by the code generator in above snippet is an instance
of the {py:class}`GpuKernelFunction` class.
It extends {py:class}`KernelFunction` with some GPU-specific information.
In particular, it defines the {any}`threads_range <GpuKernelFunction.threads_range>`
of the {py:class}`GpuKernel` class.
It extends {py:class}`Kernel` with some GPU-specific information.
In particular, it defines the {any}`threads_range <GpuKernel.threads_range>`
property, which tells us how many threads the kernel is expecting to be executed with:
```{code-cell} ipython3
......@@ -193,8 +193,8 @@ only a part of the triangle is being processed.
:nosignatures:
:template: autosummary/recursive_class.rst
pystencils.backend.kernelfunction.GpuKernelFunction
pystencils.backend.jit.gpu_cupy.CupyKernelWrapper
pystencils.codegen.GpuKernel
pystencils.jit.gpu_cupy.CupyKernelWrapper
```
:::{admonition} Developers To Do:
......
......@@ -37,7 +37,7 @@ and their effects on the generated kernel.
The primary way to invoke the code generation engine is through the `create_kernel` function.
It takes two arguments:
- the list of assignment that make up the kernel (optionally wrapped as an ``AssignmentCollection``),
- and a configuration object, an instance of {any}`CreateKernelConfig <pystencils.config.CreateKernelConfig>`.
- and a configuration object, an instance of {any}`CreateKernelConfig <pystencils.codegen.config.CreateKernelConfig>`.
```{eval-rst}
.. module:: pystencils.kernelcreation
......@@ -81,7 +81,7 @@ The above snippet defines a five-point-stencil Jacobi update. A few noteworthy t
## Inspecting the Generated Code
The object returned by the code generator, here named `kernel`, is an instance of the {any}`KernelFunction` class.
The object returned by the code generator, here named `kernel`, is an instance of the {any}`Kernel` class.
This object stores the kernel's name, its list of parameters, the set of fields it operates on, and its hardware target.
Also, it of course holds the kernel itself, in the form of an [abstract syntax tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (AST).
This tree can be printed out as compilable code in the target language (C++ or, in this case, CUDA),
......@@ -105,7 +105,7 @@ their interaction and effects, use cases and caveats.
```{eval-rst}
.. module:: pystencils.config
.. module:: pystencils.codegen.config
.. autosummary::
:toctree: generated
......@@ -131,14 +131,14 @@ their interaction and effects, use cases and caveats.
Pystencils supports code generation for a variety of CPU and GPU hardware.
```{eval-rst}
.. currentmodule:: pystencils.config
.. currentmodule:: pystencils.codegen.config
.. autosummary::
:nosignatures:
CreateKernelConfig.target
.. module:: pystencils.target
.. module:: pystencils.codegen.target
.. autosummary::
:toctree: generated
......@@ -197,7 +197,7 @@ are using the `int32` data type, as specified in {py:data}`index_dtype <CreateKe
```{code-cell} ipython3
:tags: [remove-input]
driver = ps.kernelcreation.get_driver(cfg, retain_intermediates=True)
driver = ps.codegen.get_driver(cfg, retain_intermediates=True)
kernel = driver(assignments)
ps.inspect(driver.intermediates.materialized_ispace)
```
......@@ -207,7 +207,7 @@ To learn more about inspecting code after different stages of the code generator
:::
```{eval-rst}
.. currentmodule:: pystencils.config
.. currentmodule:: pystencils.codegen.config
.. autosummary::
:nosignatures:
......@@ -241,7 +241,7 @@ only one of which can be specified at a time:
:::
```{eval-rst}
.. currentmodule:: pystencils.config
.. currentmodule:: pystencils.codegen
.. autosummary::
:nosignatures:
......@@ -281,7 +281,7 @@ boundary values or exchange data in MPI-parallel simulations.
##### Automatic Ghost Layers
The easiest way to define an iteration space with ghost layers
is to set `ghost_layers=ps.config.AUTO`, which is also the default
is to set `ghost_layers=ps.AUTO`, which is also the default
when no iteration space options are specified.
In this case, the code generator will examine the kernel to find the maximum range
of its stencil -- that is, the maximum neighbor offset encountered in any field access.
......@@ -301,11 +301,11 @@ To illustrate, the following kernel accesses neighbor nodes with a maximum offse
```{code-cell} ipython3
ranged_update = ps.Assignment(u.center(), v[-2, -2] + v[2, 2])
cfg = ps.CreateKernelConfig(ghost_layers=ps.config.AUTO)
cfg = ps.CreateKernelConfig(ghost_layers=ps.AUTO)
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.AUTO`, its iteration space will look like this (yellow cells are included, purple cells excluded):
```{code-cell} ipython3
:tags: [remove-input]
......@@ -516,7 +516,7 @@ assignments = [
```
```{code-cell} ipython3
driver = ps.kernelcreation.get_driver(cfg, retain_intermediates=True)
driver = ps.codegen.get_driver(cfg, retain_intermediates=True)
kernel = driver(assignments)
ps.inspect(driver.intermediates)
```
......@@ -524,14 +524,14 @@ ps.inspect(driver.intermediates)
## API: Kernel Parameters and Function Objects
```{eval-rst}
.. module:: pystencils.backend.kernelfunction
.. module:: pystencils.codegen
.. autosummary::
:toctree: generated
:nosignatures:
:template: autosummary/entire_class.rst
KernelParameter
KernelFunction
GpuKernelFunction
Parameter
Kernel
GpuKernel
```
......@@ -7,6 +7,7 @@ from .codegen import (
VectorizationConfig,
OpenMpConfig,
GpuIndexingConfig,
AUTO
)
from .defaults import DEFAULTS
from . import fd
......@@ -53,6 +54,7 @@ __all__ = [
"VectorizationConfig",
"GpuIndexingConfig",
"OpenMpConfig",
"AUTO",
"create_kernel",
"create_staggered_kernel",
"Kernel",
......
......@@ -5,6 +5,7 @@ from .config import (
VectorizationConfig,
OpenMpConfig,
GpuIndexingConfig,
AUTO,
)
from .parameters import Parameter
from .kernel import Kernel, GpuKernel, GpuThreadsRange
......@@ -17,6 +18,7 @@ __all__ = [
"VectorizationConfig",
"OpenMpConfig",
"GpuIndexingConfig",
"AUTO",
"Parameter",
"Kernel",
"GpuKernel",
......
......@@ -222,7 +222,7 @@ class CreateKernelConfig:
"""Just-in-time compiler used to compile and load the kernel for invocation from the current Python environment.
If left at `None`, a default just-in-time compiler will be inferred from the `target` parameter.
To explicitly disable JIT compilation, pass `pystencils.backend.jit.no_jit`.
To explicitly disable JIT compilation, pass `pystencils.no_jit <pystencils.jit.no_jit>`.
"""
function_name: str = "kernel"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment