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:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
# %: Makefile
html:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
clean:
rm -rf source/reference/generated
rm -rf source/api/generated
rm -rf source/backend/generated
@$(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::
:toctree: generated
:nosignatures:
create_kernel
.. module:: pystencils.config
get_driver
Configuration
-------------
.. autosummary::
:toctree: generated
......@@ -26,4 +31,27 @@ Code Generator and Configuration
:toctree: generated
:nosignatures:
AUTO
\ No newline at end of file
AUTO
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
platforms
transformations
errors
jit
extensions
Internal Representation
......
************************
Just-In-Time Compilation
************************
.. automodule:: pystencils.jit
:members:
......@@ -69,28 +69,36 @@ Topics
------
.. toctree::
:maxdepth: 1
:caption: Getting Started
:maxdepth: 1
:caption: Getting Started
installation
tutorials/index
installation
tutorials/index
.. toctree::
:maxdepth: 1
:caption: Reference Guides
:maxdepth: 1
:caption: Reference Guides
reference/symbolic_language
reference/kernelcreation
reference/gpu_kernels
reference/types
reference/api/index
reference/symbolic_language
reference/kernelcreation
reference/gpu_kernels
reference/types
.. toctree::
:maxdepth: 1
:caption: Advanced
:maxdepth: 1
:caption: API
migration
backend/index
api/field
api/sympyextensions
api/codegen
api/jit
.. toctree::
:maxdepth: 1
:caption: Advanced
migration
backend/index
Projects using pystencils
-------------------------
......
***
API
***
Modules
=======
.. toctree::
:maxdepth: 1
field
sympyextensions
codegen
......@@ -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
......@@ -208,12 +208,10 @@ only a part of the triangle is being processed.
```{eval-rst}
.. autosummary::
:toctree: generated
: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:
......
......@@ -34,17 +34,19 @@ and their effects on the generated kernel.
## 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:
- 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>`.
```{eval-rst}
.. currentmodule:: pystencils.codegen
.. autosummary::
:nosignatures:
pystencils.kernelcreation.create_kernel
pystencils.config.CreateKernelConfig
create_kernel
CreateKernelConfig
```
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.
Pystencils supports code generation for a variety of CPU and GPU hardware.
```{eval-rst}
.. currentmodule:: pystencils.codegen.config
.. currentmodule:: pystencils.codegen
.. autosummary::
:nosignatures:
CreateKernelConfig.target
.. module:: pystencils.codegen.target
.. autosummary::
:toctree: generated
:nosignatures:
:template: autosummary/recursive_class.rst
Target
```
### Data Types
......@@ -176,7 +171,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, show_cpp=False)
```
......@@ -186,7 +181,7 @@ To learn more about inspecting code after different stages of the code generator
:::
```{eval-rst}
.. currentmodule:: pystencils.codegen.config
.. currentmodule:: pystencils.codegen
.. autosummary::
:nosignatures:
......@@ -220,7 +215,7 @@ only one of which can be specified at a time:
:::
```{eval-rst}
.. currentmodule:: pystencils.codegen.config
.. currentmodule:: pystencils.codegen
.. autosummary::
:nosignatures:
......@@ -281,7 +276,7 @@ To illustrate, the following kernel accesses neighbor nodes with a maximum offse
```{code-cell} ipython3
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)
```
......@@ -510,18 +505,3 @@ driver = ps.codegen.get_driver(cfg, retain_intermediates=True)
kernel = driver(assignments)
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.
from .jit import JitBase, NoJit, KernelWrapper
from .legacy_cpu import LegacyCpuJit
from .gpu_cupy import CupyJit
from .gpu_cupy import CupyJit, CupyKernelWrapper, LaunchGrid
no_jit = NoJit()
"""Disables just-in-time compilation for a kernel."""
......@@ -36,4 +36,6 @@ __all__ = [
"NoJit",
"no_jit",
"CupyJit",
"CupyKernelWrapper",
"LaunchGrid"
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment