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

update docs

parent 3dfd3c62
No related branches found
No related tags found
1 merge request!433Consolidate codegen and JIT modules.
Pipeline #71132 passed
...@@ -21,10 +21,13 @@ clean: ...@@ -21,10 +21,13 @@ clean:
# Catch-all target: route all unknown targets to Sphinx using the new # Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile # %: Makefile
html:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
clean: clean:
rm -rf source/reference/generated rm -rf source/reference/generated
rm -rf source/api/generated
rm -rf source/backend/generated rm -rf source/backend/generated
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
Code Generator and Configuration pystencils.codegen
================================ ==================
.. module:: pystencils.kernelcreation .. module:: pystencils.codegen
Kernel Creation Driver
----------------------
.. autosummary:: .. autosummary::
:toctree: generated :toctree: generated
:nosignatures: :nosignatures:
create_kernel create_kernel
get_driver
.. module:: pystencils.config
Configuration
-------------
.. autosummary:: .. autosummary::
:toctree: generated :toctree: generated
...@@ -26,4 +31,27 @@ Code Generator and Configuration ...@@ -26,4 +31,27 @@ Code Generator and Configuration
:toctree: generated :toctree: generated
:nosignatures: :nosignatures:
AUTO AUTO
\ No newline at end of file
Target Specification
--------------------
.. autosummary::
:toctree: generated
:nosignatures:
:template: autosummary/recursive_class.rst
Target
Output Code Objects
-------------------
.. autosummary::
:toctree: generated
:nosignatures:
:template: autosummary/entire_class.rst
Kernel
GpuKernel
Parameter
GpuThreadsRange
File moved
pystencils.jit
==============
.. module:: pystencils.jit
Base Infrastructure
-------------------
.. autosummary::
:toctree: generated
:nosignatures:
:template: autosummary/entire_class.rst
KernelWrapper
JitBase
NoJit
.. autodata:: no_jit
Legacy CPU JIT
--------------
.. autosummary::
:toctree: generated
:nosignatures:
:template: autosummary/entire_class.rst
LegacyCpuJit
KernelWrapper
CuPy-based GPU JIT
------------------
.. autosummary::
:toctree: generated
:nosignatures:
:template: autosummary/entire_class.rst
CupyJit
CupyKernelWrapper
LaunchGrid
...@@ -18,7 +18,6 @@ who wish to customize or extend the behaviour of the code generator in their app ...@@ -18,7 +18,6 @@ who wish to customize or extend the behaviour of the code generator in their app
platforms platforms
transformations transformations
errors errors
jit
extensions extensions
Internal Representation Internal Representation
......
************************
Just-In-Time Compilation
************************
.. automodule:: pystencils.jit
:members:
...@@ -69,28 +69,36 @@ Topics ...@@ -69,28 +69,36 @@ Topics
------ ------
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
:caption: Getting Started :caption: Getting Started
installation installation
tutorials/index tutorials/index
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
:caption: Reference Guides :caption: Reference Guides
reference/symbolic_language reference/symbolic_language
reference/kernelcreation reference/kernelcreation
reference/gpu_kernels reference/gpu_kernels
reference/types reference/types
reference/api/index
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
:caption: Advanced :caption: API
migration api/field
backend/index api/sympyextensions
api/codegen
api/jit
.. toctree::
:maxdepth: 1
:caption: Advanced
migration
backend/index
Projects using pystencils Projects using pystencils
------------------------- -------------------------
......
***
API
***
Modules
=======
.. toctree::
:maxdepth: 1
field
sympyextensions
codegen
...@@ -49,9 +49,9 @@ ps.inspect(kernel) ...@@ -49,9 +49,9 @@ ps.inspect(kernel)
``` ```
The `kernel` object returned by the code generator in above snippet is an instance The `kernel` object returned by the code generator in above snippet is an instance
of the {py:class}`GpuKernelFunction` class. of the {py:class}`GpuKernel` class.
It extends {py:class}`KernelFunction` with some GPU-specific information. It extends {py:class}`Kernel` with some GPU-specific information.
In particular, it defines the {any}`threads_range <GpuKernelFunction.threads_range>` 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: property, which tells us how many threads the kernel is expecting to be executed with:
```{code-cell} ipython3 ```{code-cell} ipython3
...@@ -208,12 +208,10 @@ only a part of the triangle is being processed. ...@@ -208,12 +208,10 @@ only a part of the triangle is being processed.
```{eval-rst} ```{eval-rst}
.. autosummary:: .. autosummary::
:toctree: generated
:nosignatures: :nosignatures:
:template: autosummary/recursive_class.rst
pystencils.backend.kernelfunction.GpuKernelFunction pystencils.codegen.GpuKernel
pystencils.backend.jit.gpu_cupy.CupyKernelWrapper pystencils.jit.gpu_cupy.CupyKernelWrapper
``` ```
:::{admonition} Developers To Do: :::{admonition} Developers To Do:
......
...@@ -34,17 +34,19 @@ and their effects on the generated kernel. ...@@ -34,17 +34,19 @@ and their effects on the generated kernel.
## Running the Code Generator ## Running the Code Generator
The primary way to invoke the code generation engine is through the `create_kernel` function. The primary way to invoke the code generation engine is through the {any}`create_kernel` function.
It takes two arguments: It takes two arguments:
- the list of assignment that make up the kernel (optionally wrapped as an ``AssignmentCollection``), - the list of assignment that make up the kernel (optionally wrapped as an ``AssignmentCollection``),
- and a configuration object, an instance of {any}`CreateKernelConfig <pystencils.codegen.config.CreateKernelConfig>`. - and a configuration object, an instance of {any}`CreateKernelConfig <pystencils.codegen.config.CreateKernelConfig>`.
```{eval-rst} ```{eval-rst}
.. currentmodule:: pystencils.codegen
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:
pystencils.kernelcreation.create_kernel create_kernel
pystencils.config.CreateKernelConfig 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:
...@@ -110,21 +112,14 @@ their interaction and effects, use cases and caveats. ...@@ -110,21 +112,14 @@ their interaction and effects, use cases and caveats.
Pystencils supports code generation for a variety of CPU and GPU hardware. Pystencils supports code generation for a variety of CPU and GPU hardware.
```{eval-rst} ```{eval-rst}
.. currentmodule:: pystencils.codegen.config .. currentmodule:: pystencils.codegen
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:
CreateKernelConfig.target CreateKernelConfig.target
.. module:: pystencils.codegen.target
.. autosummary::
:toctree: generated
:nosignatures:
:template: autosummary/recursive_class.rst
Target Target
``` ```
### Data Types ### Data Types
...@@ -176,7 +171,7 @@ are using the `int32` data type, as specified in {py:data}`index_dtype <CreateKe ...@@ -176,7 +171,7 @@ are using the `int32` data type, as specified in {py:data}`index_dtype <CreateKe
```{code-cell} ipython3 ```{code-cell} ipython3
:tags: [remove-input] :tags: [remove-input]
driver = ps.kernelcreation.get_driver(cfg, retain_intermediates=True) driver = ps.codegen.get_driver(cfg, retain_intermediates=True)
kernel = driver(assignments) kernel = driver(assignments)
ps.inspect(driver.intermediates.materialized_ispace, show_cpp=False) ps.inspect(driver.intermediates.materialized_ispace, show_cpp=False)
``` ```
...@@ -186,7 +181,7 @@ To learn more about inspecting code after different stages of the code generator ...@@ -186,7 +181,7 @@ To learn more about inspecting code after different stages of the code generator
::: :::
```{eval-rst} ```{eval-rst}
.. currentmodule:: pystencils.codegen.config .. currentmodule:: pystencils.codegen
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:
...@@ -220,7 +215,7 @@ only one of which can be specified at a time: ...@@ -220,7 +215,7 @@ only one of which can be specified at a time:
::: :::
```{eval-rst} ```{eval-rst}
.. currentmodule:: pystencils.codegen.config .. currentmodule:: pystencils.codegen
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:
...@@ -281,7 +276,7 @@ To illustrate, the following kernel accesses neighbor nodes with a maximum offse ...@@ -281,7 +276,7 @@ To illustrate, the following kernel accesses neighbor nodes with a maximum offse
```{code-cell} ipython3 ```{code-cell} ipython3
ranged_update = ps.Assignment(u.center(), v[-2, -1] + v[2, 1]) 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.AUTO)
kernel = ps.create_kernel(ranged_update, cfg) kernel = ps.create_kernel(ranged_update, cfg)
``` ```
...@@ -510,18 +505,3 @@ driver = ps.codegen.get_driver(cfg, retain_intermediates=True) ...@@ -510,18 +505,3 @@ driver = ps.codegen.get_driver(cfg, retain_intermediates=True)
kernel = driver(assignments) kernel = driver(assignments)
ps.inspect(driver.intermediates) ps.inspect(driver.intermediates)
``` ```
## API: Kernel Parameters and Function Objects
```{eval-rst}
.. module:: pystencils.codegen
.. autosummary::
:toctree: generated
:nosignatures:
:template: autosummary/entire_class.rst
Parameter
Kernel
GpuKernel
```
...@@ -24,7 +24,7 @@ It is due to be replaced in the near future. ...@@ -24,7 +24,7 @@ It is due to be replaced in the near future.
from .jit import JitBase, NoJit, KernelWrapper from .jit import JitBase, NoJit, KernelWrapper
from .legacy_cpu import LegacyCpuJit from .legacy_cpu import LegacyCpuJit
from .gpu_cupy import CupyJit from .gpu_cupy import CupyJit, CupyKernelWrapper, LaunchGrid
no_jit = NoJit() no_jit = NoJit()
"""Disables just-in-time compilation for a kernel.""" """Disables just-in-time compilation for a kernel."""
...@@ -36,4 +36,6 @@ __all__ = [ ...@@ -36,4 +36,6 @@ __all__ = [
"NoJit", "NoJit",
"no_jit", "no_jit",
"CupyJit", "CupyJit",
"CupyKernelWrapper",
"LaunchGrid"
] ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment