From 5e034586bf1549f2804cce0995d9c02834a77d4e Mon Sep 17 00:00:00 2001 From: Christoph Alt <christoph.alt@fau.de> Date: Tue, 7 Jan 2025 15:21:01 +0100 Subject: [PATCH 1/2] update cuda integration test example to new sfgconfig api --- integration/test_cuda.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/integration/test_cuda.py b/integration/test_cuda.py index 56a478c..6b1f1f4 100644 --- a/integration/test_cuda.py +++ b/integration/test_cuda.py @@ -1,13 +1,11 @@ -from pystencils import Target, CreateKernelConfig, create_kernel, no_jit +from pystencils import Target, CreateKernelConfig, no_jit from lbmpy import create_lb_update_rule, LBMOptimisation -from pystencilssfg import SourceFileGenerator, SfgConfiguration -from pystencilssfg.lang.cpp import mdspan_ref +from pystencilssfg import SourceFileGenerator, SfgConfig -sfg_config = SfgConfiguration( - output_directory="out/test_cuda", - outer_namespace="gen_code", - impl_extension="cu" -) +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) @@ -15,6 +13,4 @@ with SourceFileGenerator(sfg_config) as sfg: update = create_lb_update_rule() kernel = sfg.kernels.create(update, "lbm_update", gen_config) - sfg.function("lb_update")( - sfg.call(kernel) - ) + sfg.function("lb_update")(sfg.call(kernel)) -- GitLab From dcf4f7f7ec8a3a51363ba5e411cc93f347065d4d Mon Sep 17 00:00:00 2001 From: Christoph Alt <christoph.alt@fau.de> Date: Tue, 7 Jan 2025 15:21:51 +0100 Subject: [PATCH 2/2] HeaderFile.parse now removes a leading and a trailing " if it gets a string alreading containing the parentheses --- src/pystencilssfg/lang/headers.py | 3 +++ tests/lang/test_headers.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/lang/test_headers.py diff --git a/src/pystencilssfg/lang/headers.py b/src/pystencilssfg/lang/headers.py index fdb8f17..550dd4d 100644 --- a/src/pystencilssfg/lang/headers.py +++ b/src/pystencilssfg/lang/headers.py @@ -24,6 +24,9 @@ class HeaderFile: return header system_header = False + if header.startswith('"') and header.endswith('"'): + header = header[1:-1] + if header.startswith("<") and header.endswith(">"): header = header[1:-1] system_header = True diff --git a/tests/lang/test_headers.py b/tests/lang/test_headers.py new file mode 100644 index 0000000..3eaf040 --- /dev/null +++ b/tests/lang/test_headers.py @@ -0,0 +1,13 @@ +from pystencilssfg.lang import HeaderFile +import pytest + + +def test_parse_system(): + headerfile = HeaderFile.parse("<test>") + assert str(headerfile) == "<test>" and headerfile.system_header + + +@pytest.mark.parametrize("header_string", ["test.hpp", '"test.hpp"']) +def test_parse_private(header_string): + headerfile = HeaderFile.parse(header_string) + assert str(headerfile) == "test.hpp" and not headerfile.system_header -- GitLab