Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • fhennig/devel
  • master
  • rangersbach/c-interfacing
  • v0.1a1
  • v0.1a2
  • v0.1a3
  • v0.1a4
7 results

Target

Select target project
  • ob28imeq/pystencils-sfg
  • brendan-waters/pystencils-sfg
  • pycodegen/pystencils-sfg
3 results
Select Git revision
  • frontend-cleanup
  • lbwelding-features
  • master
  • refactor-indexing-params
  • unit_tests
  • v0.1a1
  • v0.1a2
  • v0.1a3
  • v0.1a4
9 results
Show changes
Showing
with 1373 additions and 1603 deletions
from pystencils import Target, CreateKernelConfig, no_jit
from lbmpy import create_lb_update_rule, LBMOptimisation
from pystencilssfg import SourceFileGenerator, SfgConfig
sfg_config = SfgConfig()
sfg_config.extensions.impl = "cu"
sfg_config.output_directory = "out/test_cuda"
sfg_config.outer_namespace = "gen_code"
with SourceFileGenerator(sfg_config) as sfg:
gen_config = CreateKernelConfig(target=Target.CUDA, jit=no_jit)
opt = LBMOptimisation(field_layout="fzyx")
update = create_lb_update_rule()
kernel = sfg.kernels.create(update, "lbm_update", gen_config)
sfg.function("lb_update")(sfg.call(kernel))
from pystencils import Target, CreateKernelConfig, create_kernel, no_jit
from lbmpy import create_lb_update_rule, LBMOptimisation
from pystencilssfg import SourceFileGenerator, SfgConfiguration, SfgOutputMode
from pystencilssfg.lang.cpp import mdspan_ref
sfg_config = SfgConfiguration(
output_directory="out/test_sycl",
outer_namespace="gen_code",
impl_extension="ipp",
output_mode=SfgOutputMode.INLINE
)
with SourceFileGenerator(sfg_config) as sfg:
gen_config = CreateKernelConfig(target=Target.SYCL, jit=no_jit)
opt = LBMOptimisation(field_layout="fzyx")
update = create_lb_update_rule()
kernel = sfg.kernels.create(update, "lbm_update", gen_config)
sfg.function("lb_update")(
sfg.call(kernel)
)
from pystencils import Target, CreateKernelConfig, no_jit
from lbmpy import create_lb_update_rule, LBMOptimisation
from pystencilssfg import SourceFileGenerator, SfgConfig
from pystencilssfg.lang.cpp.sycl_accessor import SyclAccessor
import pystencilssfg.extensions.sycl as sycl
from itertools import chain
sfg_config = SfgConfig(
output_directory="out/test_sycl_buffer",
outer_namespace="gen_code",
header_only=True
)
with SourceFileGenerator(sfg_config) as sfg:
sfg = sycl.SyclComposer(sfg)
gen_config = CreateKernelConfig(target=Target.SYCL, jit=no_jit)
opt = LBMOptimisation(field_layout="fzyx")
update = create_lb_update_rule(lbm_optimisation=opt)
kernel = sfg.kernels.create(update, "lbm_update", gen_config)
cgh = sfg.sycl_handler("handler")
rang = sfg.sycl_range(update.method.dim, "range")
mappings = [
sfg.map_field(field, SyclAccessor.from_field(field))
for field in chain(update.free_fields, update.bound_fields)
]
sfg.function("lb_update")(
cgh.parallel_for(rang)(
*mappings,
sfg.call(kernel),
),
)
site_name: pystencils Source File Generator Documentation
site_author: Frederik Hennig
copyright: © 2023 Frederik Hennig
repo_name: GitLab
repo_url: https://i10git.cs.fau.de/pycodegen/pystencils-sfg
theme:
name: material
features:
- navigation.tabs
- content.code.copy
palette:
scheme: slate
primary: deep purple
extra_css:
- css/mkdocstrings.css
plugins:
- search
- autorefs
- mkdocstrings:
default_handler: python
handlers:
python:
paths: [src]
options:
heading_level: 2
members_order: source
group_by_category: False
show_root_heading: True
show_root_full_path: True
show_symbol_type_heading: True
show_symbol_type_toc: True
show_source: False
show_signature_annotations: True
signature_crossrefs: True
markdown_extensions:
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.superfences
nav:
- Home: index.md
- 'User Guides':
- 'Overview': usage/index.md
- 'Writing Generator Scripts': usage/generator_scripts.md
- 'In-Depth: Building Source Files': usage/building.md
- 'CLI and Build System Integration': usage/cli_and_build_system.md
- 'Tips and Tricks': usage/tips_n_tricks.md
- 'API Documentation':
- 'Overview': api/index.md
- 'Front End':
- 'Source File Generator': api/generator.md
- 'Code Generation Context': api/context.md
- 'Composer': api/composer.md
- 'Source File Modelling':
- 'Source File Components': api/source_components.md
- 'Kernel Call Tree': api/tree.md
- 'High-Level Language Concepts':
- 'Base Classes': 'api/source_objects.md'
- 'C++ Standard Library': 'api/cpp_std.md'
- 'Code Generation':
- 'Emission and Printing': api/emission.md
...@@ -3,3 +3,6 @@ python_version=3.10 ...@@ -3,3 +3,6 @@ python_version=3.10
[mypy-pystencils.*] [mypy-pystencils.*]
ignore_missing_imports=true ignore_missing_imports=true
[mypy-sympy.*]
ignore_missing_imports=true
from __future__ import annotations
from typing import Sequence
import nox
nox.options.sessions = ["lint", "typecheck", "testsuite"]
def add_pystencils_git(session: nox.Session):
"""Clone the pystencils 2.0 development branch and install it in the current session"""
cache_dir = session.cache_dir
pystencils_dir = cache_dir / "pystencils"
if pystencils_dir.exists():
with session.chdir(pystencils_dir):
session.run_install("git", "pull", external=True)
else:
session.run_install(
"git",
"clone",
"--branch",
"v2.0-dev",
"--single-branch",
"https://i10git.cs.fau.de/pycodegen/pystencils.git",
pystencils_dir,
external=True,
)
session.install("-e", str(pystencils_dir))
def editable_install(session: nox.Session, opts: Sequence[str] = ()):
add_pystencils_git(session)
if opts:
opts_str = "[" + ",".join(opts) + "]"
else:
opts_str = ""
session.install("-e", f".{opts_str}")
@nox.session(python="3.10", tags=["qa", "code-quality"])
def lint(session: nox.Session):
"""Lint code using flake8"""
session.install("flake8")
session.run("flake8", "src/pystencilssfg")
@nox.session(python="3.10", tags=["qa", "code-quality"])
def typecheck(session: nox.Session):
"""Run MyPy for static type checking"""
editable_install(session)
session.install("mypy")
session.run("mypy", "src/pystencilssfg")
@nox.session(python=["3.10", "3.11", "3.12", "3.13"], tags=["tests"])
def testsuite(session: nox.Session):
"""Run the testsuite and measure coverage."""
editable_install(session, ["testsuite"])
session.run(
"pytest",
"-v",
"--cov=src/pystencilssfg",
"--cov-report=term",
"--cov-config=pyproject.toml",
)
session.run("coverage", "html")
session.run("coverage", "xml")
@nox.session(python=["3.10"], tags=["docs"])
def docs(session: nox.Session):
"""Build the documentation pages"""
editable_install(session, ["docs"])
env = {}
session_args = session.posargs
if "--fail-on-warnings" in session_args:
env["SPHINXOPTS"] = "-W --keep-going"
session.chdir("docs")
if "--clean" in session_args:
session.run("make", "clean", external=True)
session.run("make", "html", external=True)
@nox.session()
def dev_env(session: nox.Session):
"""Set up the development environment at .venv"""
session.install("virtualenv")
session.run("virtualenv", ".venv", "--prompt", "pystencils-sfg")
session.run(
".venv/bin/pip",
"install",
"git+https://i10git.cs.fau.de/pycodegen/pystencils.git@v2.0-dev",
external=True,
)
session.run(".venv/bin/pip", "install", "-e", ".[dev]", external=True)
This diff is collapsed.
...@@ -5,11 +5,11 @@ authors = [ ...@@ -5,11 +5,11 @@ authors = [
{name = "Frederik Hennig", email = "frederik.hennig@fau.de"}, {name = "Frederik Hennig", email = "frederik.hennig@fau.de"},
] ]
dependencies = [ dependencies = [
"pystencils>=1.3.2", "pystencils>=2.0.dev0",
] ]
requires-python = ">=3.10" requires-python = ">=3.10"
readme = "README.md" readme = "README.md"
license = {text = "noneyet"} license = { file = "LICENSE" }
dynamic = ["version"] dynamic = ["version"]
[project.scripts] [project.scripts]
...@@ -18,23 +18,34 @@ sfg-cli = "pystencilssfg.cli:cli_main" ...@@ -18,23 +18,34 @@ sfg-cli = "pystencilssfg.cli:cli_main"
[build-system] [build-system]
requires = [ requires = [
"setuptools>=69", "setuptools>=69",
"versioneer>=0.29", "versioneer[toml]>=0.29",
"tomli; python_version < '3.11'"
] ]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[tool.pdm.dev-dependencies] [project.optional-dependencies]
interactive = [ dev = [
"ipython>=8.17.2", "flake8",
"mypy",
"black",
"clang-format",
] ]
code_quality = [ testsuite = [
"flake8>=6.1.0", "pytest",
"mypy>=1.7.0", "pytest-cov",
"pyyaml",
"requests",
"fasteners",
] ]
docs = [ docs = [
"mkdocs>=1.5.3", "sphinx",
"mkdocs-material>=9.4.8", "pydata-sphinx-theme==0.15.4",
"mkdocstrings[python]>=0.24.0", "sphinx-book-theme==1.1.3", # workaround for https://github.com/executablebooks/sphinx-book-theme/issues/865
"myst-nb",
"sphinx_design",
"sphinx_autodoc_typehints",
"sphinx-copybutton",
"packaging",
"clang-format"
] ]
[tool.versioneer] [tool.versioneer]
...@@ -42,5 +53,21 @@ VCS = "git" ...@@ -42,5 +53,21 @@ VCS = "git"
style = "pep440" style = "pep440"
versionfile_source = "src/pystencilssfg/_version.py" versionfile_source = "src/pystencilssfg/_version.py"
versionfile_build = "pystencilssfg/_version.py" versionfile_build = "pystencilssfg/_version.py"
tag_prefix = "" tag_prefix = "v"
parentdir_prefix = "pystencilssfg-" parentdir_prefix = "pystencilssfg-"
[tool.coverage.run]
omit = [
"setup.py",
"noxfile.py",
"src/pystencilssfg/_version.py",
"integration/*"
]
[tool.coverage.report]
exclude_also = [
"\\.\\.\\.\n",
"if TYPE_CHECKING:",
"@(abc\\.)?abstractmethod",
"assert False"
]
[pytest]
testpaths = src/pystencilssfg tests/
python_files = "test_*.py"
# Need to ignore the generator scripts, otherwise they would be executed
# during test collection
addopts =
--doctest-modules
--ignore=tests/generator_scripts/source
--ignore=tests/generator_scripts/deps
--ignore=tests/generator_scripts/expected
--ignore=tests/data
--ignore=tests/integration/cmake_project
doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
from .configuration import SfgConfiguration from .config import SfgConfig, GLOBAL_NAMESPACE
from .generator import SourceFileGenerator from .generator import SourceFileGenerator
from .composer import SfgComposer from .composer import SfgComposer
from .context import SfgContext from .context import SfgContext
from .lang import SfgVar, AugExpr
from .exceptions import SfgException
__all__ = [ __all__ = [
"SourceFileGenerator", "SfgComposer", "SfgConfiguration", "SfgContext" "SfgConfig",
"GLOBAL_NAMESPACE",
"SourceFileGenerator",
"SfgComposer",
"SfgContext",
"SfgVar",
"AugExpr",
"SfgException",
] ]
from . import _version from . import _version
__version__ = _version.get_versions()['version']
__version__ = _version.get_versions()["version"]
if __name__ == "__main__": if __name__ == "__main__":
from .cli import cli_main from .cli import cli_main
cli_main("python -m pystencilssfg") cli_main("python -m pystencilssfg")
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
from __future__ import annotations
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from ..context import SfgContext from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .composer import SfgComposer
class CustomGenerator(ABC): class CustomGenerator(ABC):
"""Abstract base class for custom code generators that may be passed to """Abstract base class for custom code generators that may be passed to
[SfgComposer.generate][pystencilssfg.SfgComposer.generate].""" `SfgBasicComposer.generate`."""
@abstractmethod @abstractmethod
def generate(self, ctx: SfgContext) -> None: def generate(self, sfg: SfgComposer) -> None: ...
...