From e4f54a827904cb5640c1d47811ea40bfbe6c4c34 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 17 Oct 2024 15:24:59 +0000 Subject: [PATCH 1/4] Frontend: Add deprecation warning for OFP --- loki/frontend/ofp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/loki/frontend/ofp.py b/loki/frontend/ofp.py index c6daba981..0e1ab8236 100644 --- a/loki/frontend/ofp.py +++ b/loki/frontend/ofp.py @@ -58,6 +58,8 @@ def parse_ofp_file(filename): if not HAVE_OFP: error('OpenFortranParser is not available.') + warning('[DEPRECATION]: The OFP frontend is deprecated and will be removed soon!') + filepath = Path(filename) info(f'[Loki::OFP] Parsing {filepath}') return open_fortran_parser.parse(filepath, raise_on_error=True) From dc50ef5cb5a89a4e01e308439d776a4158315680 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 17 Oct 2024 15:32:00 +0000 Subject: [PATCH 2/4] Frontend: Remove OFP from `available_frontends` utility The effectively remove all parametrised test from the test base. --- loki/frontend/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/loki/frontend/util.py b/loki/frontend/util.py index 21d5ca1a5..88046b309 100644 --- a/loki/frontend/util.py +++ b/loki/frontend/util.py @@ -113,6 +113,8 @@ def my_test(frontend): # Build the list of parameters params = [] for f in Frontend: + if f == OFP: + continue # OFP is now deprecated! if f in skip: params += [pytest.param(f, marks=pytest.mark.skip(reason=skip[f]))] elif f in xfail: From 0bdbe01d30c5c0f0421cac565acb6d0af9af5d12 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 17 Oct 2024 16:24:16 +0000 Subject: [PATCH 3/4] Frontend: Remove OFP symbol and use `Frontend.OFP` internally This should make it unavailable to all tests, but keep the basic functionality intact. --- loki/frontend/ofp.py | 5 ++++- loki/frontend/preprocessing.py | 5 ++++- loki/frontend/util.py | 9 ++++----- loki/sourcefile.py | 5 ++++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/loki/frontend/ofp.py b/loki/frontend/ofp.py index 0e1ab8236..ca4577491 100644 --- a/loki/frontend/ofp.py +++ b/loki/frontend/ofp.py @@ -22,7 +22,7 @@ from loki.frontend.source import extract_source, extract_source_from_range from loki.frontend.preprocessing import sanitize_registry -from loki.frontend.util import OFP, sanitize_ir +from loki.frontend.util import sanitize_ir, Frontend from loki import ir from loki.ir import ( @@ -47,6 +47,9 @@ __all__ = ['HAVE_OFP', 'parse_ofp_file', 'parse_ofp_source', 'parse_ofp_ast'] +OFP = Frontend.OFP + + @Timer(logger=debug, text=lambda s: f'[Loki::OFP] Executed parse_ofp_file in {s:.2f}s') @disk_cached(argname='filename', suffix='ofpast') def parse_ofp_file(filename): diff --git a/loki/frontend/preprocessing.py b/loki/frontend/preprocessing.py index f3039f634..997be47e5 100644 --- a/loki/frontend/preprocessing.py +++ b/loki/frontend/preprocessing.py @@ -19,12 +19,15 @@ from loki.config import config from loki.tools import as_tuple, gettempdir, filehash from loki.ir import VariableDeclaration, Intrinsic, FindNodes -from loki.frontend.util import OMNI, OFP, FP, REGEX +from loki.frontend.util import OMNI, FP, REGEX, Frontend __all__ = ['preprocess_cpp', 'sanitize_input', 'sanitize_registry', 'PPRule'] +OFP = Frontend.OFP + + def preprocess_cpp(source, filepath=None, includes=None, defines=None): """ Invoke an external C-preprocessor to sanitize input files. diff --git a/loki/frontend/util.py b/loki/frontend/util.py index 88046b309..e1891367c 100644 --- a/loki/frontend/util.py +++ b/loki/frontend/util.py @@ -26,7 +26,7 @@ __all__ = [ - 'Frontend', 'OFP', 'OMNI', 'FP', 'REGEX', 'available_frontends', + 'Frontend', 'OMNI', 'FP', 'REGEX', 'available_frontends', 'read_file', 'InlineCommentTransformer', 'ClusterCommentTransformer', 'CombineMultilinePragmasTransformer', 'sanitize_ir' @@ -50,7 +50,6 @@ def __str__(self): return self.name.lower() # pylint: disable=no-member OMNI = Frontend.OMNI -OFP = Frontend.OFP FP = Frontend.FP REGEX = Frontend.REGEX @@ -113,7 +112,7 @@ def my_test(frontend): # Build the list of parameters params = [] for f in Frontend: - if f == OFP: + if f == Frontend.OFP: continue # OFP is now deprecated! if f in skip: params += [pytest.param(f, marks=pytest.mark.skip(reason=skip[f]))] @@ -383,10 +382,10 @@ def sanitize_ir(_ir, frontend, pp_registry=None, pp_info=None): # Revert OMNI's array dimension expansion from `a(n)` => `arr(1:n)` _ir = RangeIndexTransformer(invalidate_source=False).visit(_ir) - if frontend in (OMNI, OFP): + if frontend in (OMNI, Frontend.OFP): _ir = inline_labels(_ir) - if frontend in (FP, OFP): + if frontend in (FP, Frontend.OFP): _ir = CombineMultilinePragmasTransformer(inplace=True, invalidate_source=False).visit(_ir) _ir = RemoveDuplicateVariableDeclarationsForExternalProcedures(inplace=True, invalidate_source=False).visit(_ir) diff --git a/loki/sourcefile.py b/loki/sourcefile.py index 156c1a83d..5f5c1e1fa 100644 --- a/loki/sourcefile.py +++ b/loki/sourcefile.py @@ -15,7 +15,7 @@ from loki.backend.fgen import fgen from loki.backend.cufgen import cufgen from loki.frontend import ( - Frontend, OMNI, OFP, FP, REGEX, sanitize_input, Source, read_file, preprocess_cpp, + Frontend, OMNI, FP, REGEX, sanitize_input, Source, read_file, preprocess_cpp, parse_omni_source, parse_ofp_source, parse_fparser_source, parse_omni_ast, parse_ofp_ast, parse_fparser_ast, parse_regex_source, RegexParserClass @@ -32,6 +32,9 @@ __all__ = ['Sourcefile'] +OFP = Frontend.OFP + + class Sourcefile: """ Class to handle and manipulate source files, storing :any:`Module` and From f465077d7a21675d83b3d228c441a0d966699001 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 17 Oct 2024 18:27:20 +0000 Subject: [PATCH 4/4] Frontend: Purge the use of `OFP` from the test base --- loki/backend/tests/test_fgen.py | 7 ++--- loki/backend/tests/test_pygen.py | 4 +-- loki/batch/tests/test_scheduler.py | 6 ++--- loki/expression/tests/test_expression.py | 16 ++++------- loki/frontend/tests/test_frontends.py | 17 +++++------- loki/ir/tests/test_control_flow.py | 3 +-- loki/tests/test_derived_types.py | 6 ++--- loki/tests/test_modules.py | 6 ++--- loki/tests/test_sourcefile.py | 6 ++--- loki/tests/test_subroutine.py | 8 +++--- loki/tests/test_types.py | 2 +- .../build_system/tests/test_dependency.py | 5 ++-- .../extract/tests/test_extract_internal.py | 6 ++--- .../inline/tests/test_functions.py | 8 +++--- .../tests/test_inline_transformation.py | 6 ++--- .../single_column/tests/test_scc.py | 5 ++-- loki/transformations/tests/test_cloudsc.py | 3 +-- .../tests/test_pool_allocator.py | 27 +++++++++---------- .../transpile/tests/test_transpile.py | 14 +++------- 19 files changed, 60 insertions(+), 95 deletions(-) diff --git a/loki/backend/tests/test_fgen.py b/loki/backend/tests/test_fgen.py index 6774fa9f6..33d41a50c 100644 --- a/loki/backend/tests/test_fgen.py +++ b/loki/backend/tests/test_fgen.py @@ -10,7 +10,7 @@ from loki import Module, Subroutine, Sourcefile from loki.backend import fgen from loki.expression import symbols as sym -from loki.frontend import available_frontends, OMNI, OFP +from loki.frontend import available_frontends, OMNI from loki.ir import Intrinsic, DataDeclaration from loki.types import ProcedureType, BasicType @@ -107,10 +107,7 @@ def test_fgen_data_stmt(frontend): """.strip() routine = Subroutine.from_source(fcode, frontend=frontend) - if frontend == OFP: - assert isinstance(routine.spec.body[-1], Intrinsic) - else: - assert isinstance(routine.spec.body[-1], DataDeclaration) + assert isinstance(routine.spec.body[-1], DataDeclaration) spec_code = fgen(routine.spec) assert spec_code.lower().count('data ') == 2 assert spec_code.count('/') == 4 diff --git a/loki/backend/tests/test_pygen.py b/loki/backend/tests/test_pygen.py index fb65487ec..0807e9291 100644 --- a/loki/backend/tests/test_pygen.py +++ b/loki/backend/tests/test_pygen.py @@ -15,7 +15,7 @@ from loki import Subroutine from loki.backend import pygen from loki.build import jit_compile, clean_test -from loki.frontend import available_frontends, OFP, OMNI +from loki.frontend import available_frontends, OMNI from loki.transformations.transpile import FortranPythonTransformation @@ -452,7 +452,7 @@ def test_pygen_logical_statements(tmp_path, frontend): f2p.py_path.unlink() -@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'OFP cannot handle stmt functions')])) +@pytest.mark.parametrize('frontend', available_frontends()) def test_pygen_downcasing(tmp_path, frontend): """ A simple test routine to test the conversion to lower case. diff --git a/loki/batch/tests/test_scheduler.py b/loki/batch/tests/test_scheduler.py index 7d4f7f02c..6659d6b18 100644 --- a/loki/batch/tests/test_scheduler.py +++ b/loki/batch/tests/test_scheduler.py @@ -68,7 +68,7 @@ ) from loki.expression import Scalar, Array, Literal, ProcedureSymbol from loki.frontend import ( - available_frontends, OMNI, OFP, FP, REGEX, HAVE_FP, HAVE_OFP, HAVE_OMNI + available_frontends, OMNI, FP, REGEX, HAVE_FP, HAVE_OMNI ) from loki.ir import nodes as ir, FindNodes, FindInlineCalls from loki.transformations import ( @@ -76,7 +76,7 @@ ) -pytestmark = pytest.mark.skipif(not HAVE_FP and not HAVE_OFP, reason='Fparser and OFP not available') +pytestmark = pytest.mark.skipif(not HAVE_FP, reason='Fparser not available') @pytest.fixture(scope='module', name='here') @@ -116,7 +116,7 @@ def fixture_frontend(): independent from the specific frontend used. Cannot use OMNI for this as not all tests have dependencies fully resolved. """ - return FP if HAVE_FP else OFP + return FP @pytest.fixture(name='driverA_dependencies') diff --git a/loki/expression/tests/test_expression.py b/loki/expression/tests/test_expression.py index ee3ef99cf..1af426744 100644 --- a/loki/expression/tests/test_expression.py +++ b/loki/expression/tests/test_expression.py @@ -22,7 +22,7 @@ from loki.build import jit_compile, clean_test from loki.expression import symbols as sym, parse_expr, AttachScopesMapper from loki.frontend import ( - available_frontends, OFP, OMNI, FP, HAVE_FP, parse_fparser_expression + available_frontends, OMNI, FP, HAVE_FP, parse_fparser_expression ) from loki.ir import ( nodes as ir, FindNodes, FindVariables, FindExpressions, @@ -208,9 +208,7 @@ def test_boz_literals(tmp_path, frontend): assert stmts[5].rhs.parameters[0].value == 'z"babe"' -@pytest.mark.parametrize('frontend', available_frontends( - skip={OFP: "Not implemented because too stupid in OFP parse tree"}) -) +@pytest.mark.parametrize('frontend', available_frontends()) def test_complex_literals(tmp_path, frontend): """ Test complex literal values. @@ -310,9 +308,7 @@ def test_logical_array(tmp_path, frontend): clean_test(filepath) -@pytest.mark.parametrize('frontend', available_frontends( - xfail=[(OFP, 'Not implemented')] -)) +@pytest.mark.parametrize('frontend', available_frontends()) def test_array_constructor(tmp_path, frontend): """ Test various array constructor formats @@ -796,9 +792,7 @@ def test_masked_statements(tmp_path, frontend): clean_test(filepath) -@pytest.mark.parametrize('frontend', available_frontends(xfail=[ - (OFP, 'Current implementation does not handle nested where constructs') -])) +@pytest.mark.parametrize('frontend', available_frontends()) def test_masked_statements_nested(tmp_path, frontend): """ Nested masked statements (WHERE(...) ... [ELSEWHERE ...] ENDWHERE) @@ -1607,7 +1601,7 @@ def test_typebound_resolution_type_info(frontend, tmp_path): )) def test_stmt_func_heuristic(frontend, tmp_path): """ - Our Fparser/OFP translation has a heuristic to detect statement function declarations, + Our Fparser translation has a heuristic to detect statement function declarations, but that falsely misinterpreted some assignments as statement functions due to missing shape information (reported in #326) """ diff --git a/loki/frontend/tests/test_frontends.py b/loki/frontend/tests/test_frontends.py index f6d308cf8..56ee5f878 100644 --- a/loki/frontend/tests/test_frontends.py +++ b/loki/frontend/tests/test_frontends.py @@ -27,7 +27,7 @@ ) from loki.build import jit_compile, clean_test from loki.expression import symbols as sym -from loki.frontend import available_frontends, OMNI, OFP, FP, REGEX +from loki.frontend import available_frontends, OMNI, FP, REGEX from loki.ir import nodes as ir, FindNodes @@ -364,9 +364,7 @@ def test_enum(tmp_path, frontend): clean_test(filepath) -@pytest.mark.parametrize('frontend', available_frontends( - xfail=[(OFP, 'OFP fails to parse parameterized types')] -)) +@pytest.mark.parametrize('frontend', available_frontends()) @pytest.mark.usefixtures('reset_frontend_mode') def test_frontend_strict_mode(frontend, tmp_path): """ @@ -1622,7 +1620,7 @@ def test_regex_function_inline_return_type(): assert 'dot_product_ecv' in routine.variables -@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'No support for prefix implemented')])) +@pytest.mark.parametrize('frontend', available_frontends()) def test_regex_prefix(frontend, tmp_path): fcode = """ module some_mod @@ -1842,12 +1840,9 @@ def test_inline_comments(frontend): assert assigns[3].comment.text == '! wall !' comments = FindNodes(ir.Comment).visit(routine.body) - assert len(comments) == 1 if frontend == OFP else 4 - if frontend == OFP: - assert comments[0].text == '! Who said that?' - else: - assert comments[1].text == '! Who said that?' - assert comments[0].text == comments[2].text == comments[3].text == '' + assert len(comments) == 4 + assert comments[1].text == '! Who said that?' + assert comments[0].text == comments[2].text == comments[3].text == '' @pytest.mark.parametrize('from_file', (True, False)) diff --git a/loki/ir/tests/test_control_flow.py b/loki/ir/tests/test_control_flow.py index 85431c935..c2f75240d 100644 --- a/loki/ir/tests/test_control_flow.py +++ b/loki/ir/tests/test_control_flow.py @@ -11,7 +11,7 @@ from loki import Subroutine from loki.backend import fgen from loki.build import jit_compile, clean_test -from loki.frontend import available_frontends, OMNI, OFP +from loki.frontend import available_frontends, OMNI from loki.ir import nodes as ir, FindNodes @@ -610,7 +610,6 @@ def test_single_line_forall_masked_stmt(tmp_path, frontend): @pytest.mark.parametrize('frontend', available_frontends(xfail=[ (OMNI, 'Renames index variable to omnitmp000'), - (OFP, 'Parser fails to parse'), ])) def test_multi_line_forall_construct(tmp_path, frontend): fcode = """ diff --git a/loki/tests/test_derived_types.py b/loki/tests/test_derived_types.py index dcd3c8609..321eda76f 100644 --- a/loki/tests/test_derived_types.py +++ b/loki/tests/test_derived_types.py @@ -21,7 +21,7 @@ FindVariables ) from loki.build import jit_compile, jit_compile_lib, clean_test, Obj -from loki.frontend import available_frontends, OMNI, OFP +from loki.frontend import available_frontends, OMNI @pytest.fixture(name='builder') @@ -1204,9 +1204,7 @@ def test_derived_type_rescope_symbols_shadowed(tmp_path, shadowed_typedef_symbol clean_test(filepath) -@pytest.mark.parametrize('frontend', available_frontends(xfail=[ - (OFP, 'OFP cannot parse the Fortran') -])) +@pytest.mark.parametrize('frontend', available_frontends()) def test_derived_types_character_array_subscript(frontend, tmp_path): fcode = """ module derived_type_char_arr_mod diff --git a/loki/tests/test_modules.py b/loki/tests/test_modules.py index 0f844b940..52dce2dc6 100644 --- a/loki/tests/test_modules.py +++ b/loki/tests/test_modules.py @@ -14,7 +14,7 @@ Scalar, DeferredTypeSymbol, FindVariables, SubstituteExpressions, Literal ) from loki.build import jit_compile, clean_test -from loki.frontend import available_frontends, OFP, OMNI +from loki.frontend import available_frontends, OMNI from loki.sourcefile import Sourcefile @@ -933,9 +933,7 @@ def test_module_rename_imports_no_definitions(frontend, tmp_path): assert use_name is None or f'{s} => {use_name}' in fcode -@pytest.mark.parametrize('frontend', available_frontends( - xfail=[(OFP, 'hasModuleNature on use-stmt but without conveying actual nature')] -)) +@pytest.mark.parametrize('frontend', available_frontends()) def test_module_use_module_nature(frontend, tmp_path): """ Test module natures attributes in ``USE`` statements diff --git a/loki/tests/test_sourcefile.py b/loki/tests/test_sourcefile.py index 295ce8c51..e66d06595 100644 --- a/loki/tests/test_sourcefile.py +++ b/loki/tests/test_sourcefile.py @@ -16,7 +16,7 @@ StatementFunction, Comment, CommentBlock, RawSource, Scalar ) from loki.build import jit_compile, clean_test -from loki.frontend import available_frontends, OFP, OMNI, FP, REGEX +from loki.frontend import available_frontends, OMNI, FP, REGEX @pytest.fixture(scope='module', name='here') @@ -120,7 +120,7 @@ def test_sourcefile_pp_macros(here, frontend): @pytest.mark.parametrize('frontend', available_frontends(xfail=[ - (OFP, 'Cannot handle directives'), (OMNI, 'Files are preprocessed') + (OMNI, 'Files are preprocessed') ])) def test_sourcefile_pp_directives(here, frontend): filepath = here/'sources/sourcefile_pp_directives.F90' @@ -193,7 +193,7 @@ def test_sourcefile_cpp_preprocessing(here, frontend): assert 'b = 6' in fgen(routine) -@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'No support for statement functions')])) +@pytest.mark.parametrize('frontend', available_frontends()) def test_sourcefile_cpp_stmt_func(here, frontend, tmp_path): """ Test the correct identification of statement functions diff --git a/loki/tests/test_subroutine.py b/loki/tests/test_subroutine.py index 8376f209a..e7a4dfde0 100644 --- a/loki/tests/test_subroutine.py +++ b/loki/tests/test_subroutine.py @@ -18,7 +18,7 @@ ProcedureSymbol, StatementFunction, DeferredTypeSymbol ) from loki.build import jit_compile, jit_compile_lib, clean_test -from loki.frontend import available_frontends, OFP, OMNI, REGEX +from loki.frontend import available_frontends, OMNI, REGEX from loki.types import BasicType, DerivedType, ProcedureType from loki.ir import nodes as ir @@ -1465,7 +1465,7 @@ def test_subroutine_rescope_clone(frontend): ) -@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'No support for statement functions')])) +@pytest.mark.parametrize('frontend', available_frontends()) def test_subroutine_stmt_func(tmp_path, frontend): """ Test the correct identification of statement functions @@ -1537,7 +1537,7 @@ def test_mixed_declaration_interface(frontend): assert "Declarations must have intents" in str(error.value) -@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'Prefix support not implemented')])) +@pytest.mark.parametrize('frontend', available_frontends()) def test_subroutine_prefix(frontend): """ Test various prefixes that can occur in function/subroutine definitions @@ -1852,7 +1852,7 @@ def test_subroutine_lazy_arguments_incomplete2(frontend): assert all(isinstance(arg, Array) for arg in routine.arguments[4:]) -@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'Prefix support not implemented')])) +@pytest.mark.parametrize('frontend', available_frontends()) def test_subroutine_lazy_prefix(frontend): """ Test that prefixes for functions are correctly captured when the object is made diff --git a/loki/tests/test_types.py b/loki/tests/test_types.py index 7b07b686f..530577cb7 100644 --- a/loki/tests/test_types.py +++ b/loki/tests/test_types.py @@ -15,7 +15,7 @@ FindNodes, ProcedureDeclaration ) from loki.expression import symbols as sym -from loki.frontend import available_frontends, OFP, OMNI +from loki.frontend import available_frontends, OMNI @pytest.fixture(scope='module', name='here') diff --git a/loki/transformations/build_system/tests/test_dependency.py b/loki/transformations/build_system/tests/test_dependency.py index 34d0f3646..873691d99 100644 --- a/loki/transformations/build_system/tests/test_dependency.py +++ b/loki/transformations/build_system/tests/test_dependency.py @@ -9,7 +9,7 @@ from loki import Sourcefile from loki.batch import Scheduler, SchedulerConfig -from loki.frontend import available_frontends, OMNI, OFP +from loki.frontend import available_frontends, OMNI from loki.ir import ( FindNodes, CallStatement, Import, Interface, Intrinsic, FindInlineCalls ) @@ -445,8 +445,7 @@ def test_dependency_transformation_replace_interface(frontend, use_scheduler, mo assert intfs[0].symbols == ('kernel_test',) -@pytest.mark.parametrize('frontend', available_frontends( - xfail=[(OFP, 'OFP does not correctly handle result variable declaration.')])) +@pytest.mark.parametrize('frontend', available_frontends()) def test_dependency_transformation_inline_call(frontend): """ Test injection of suffixed kernel, accessed through inline function call. diff --git a/loki/transformations/extract/tests/test_extract_internal.py b/loki/transformations/extract/tests/test_extract_internal.py index 832275d18..b0bcdefb5 100644 --- a/loki/transformations/extract/tests/test_extract_internal.py +++ b/loki/transformations/extract/tests/test_extract_internal.py @@ -7,7 +7,7 @@ import pytest -from loki.frontend import available_frontends, OMNI, OFP +from loki.frontend import available_frontends, OMNI from loki.ir import CallStatement, Import, FindNodes, FindInlineCalls from loki.sourcefile import Sourcefile from loki.subroutine import Subroutine @@ -558,9 +558,7 @@ def test_extract_internal_procedures_basic_scalar_function(frontend): call = list(FindInlineCalls().visit(outer.body))[0] assert 'x' in call.kw_parameters -@pytest.mark.parametrize( - 'frontend', available_frontends(skip=(OFP, "ofp fails for unknown reason, likely frontend issue")) -) +@pytest.mark.parametrize('frontend', available_frontends()) def test_extract_internal_procedures_basic_scalar_function_both(frontend): """ Basic test for scalars highlighting that the outer and inner procedure may be functions. diff --git a/loki/transformations/inline/tests/test_functions.py b/loki/transformations/inline/tests/test_functions.py index 4dc815b9b..91f8b0508 100644 --- a/loki/transformations/inline/tests/test_functions.py +++ b/loki/transformations/inline/tests/test_functions.py @@ -9,7 +9,7 @@ from loki import Module, Subroutine from loki.build import jit_compile_lib, Builder, Obj -from loki.frontend import available_frontends, OMNI, OFP +from loki.frontend import available_frontends, OMNI from loki.ir import ( nodes as ir, FindNodes, FindVariables, FindInlineCalls ) @@ -195,8 +195,7 @@ def test_transform_inline_elemental_functions_extended(tmp_path, builder, fronte @pytest.mark.parametrize('frontend', available_frontends( - skip={OFP: "OFP apparently has problems dealing with those Statement Functions", - OMNI: "OMNI automatically inlines Statement Functions"} + skip={OMNI: "OMNI automatically inlines Statement Functions"} )) @pytest.mark.parametrize('stmt_decls', (True, False)) def test_inline_statement_functions(frontend, stmt_decls): @@ -242,8 +241,7 @@ def test_inline_statement_functions(frontend, stmt_decls): assert FindInlineCalls().visit(routine.body) @pytest.mark.parametrize('frontend', available_frontends( - skip={OFP: "OFP apparently has problems dealing with those Statement Functions", - OMNI: "OMNI automatically inlines Statement Functions"} + skip={OMNI: "OMNI automatically inlines Statement Functions"} )) @pytest.mark.parametrize('provide_myfunc', ('import', 'module', 'interface', 'intfb', 'routine')) def test_inline_statement_functions_inline_call(frontend, provide_myfunc, tmp_path): diff --git a/loki/transformations/inline/tests/test_inline_transformation.py b/loki/transformations/inline/tests/test_inline_transformation.py index 62da187f0..63385f1ec 100644 --- a/loki/transformations/inline/tests/test_inline_transformation.py +++ b/loki/transformations/inline/tests/test_inline_transformation.py @@ -8,16 +8,14 @@ import pytest from loki import Module, Subroutine -from loki.frontend import available_frontends, OFP +from loki.frontend import available_frontends from loki.ir import nodes as ir, FindNodes from loki.batch import Scheduler, SchedulerConfig from loki.transformations.inline import InlineTransformation -@pytest.mark.parametrize('frontend', available_frontends( - (OFP, 'Prefix/elemental support not implemented')) -) +@pytest.mark.parametrize('frontend', available_frontends()) @pytest.mark.parametrize('pass_as_kwarg', (False, True)) def test_inline_transformation(tmp_path, frontend, pass_as_kwarg): """Test combining recursive inlining via :any:`InliningTransformation`.""" diff --git a/loki/transformations/single_column/tests/test_scc.py b/loki/transformations/single_column/tests/test_scc.py index 00281189f..4196ee1c3 100644 --- a/loki/transformations/single_column/tests/test_scc.py +++ b/loki/transformations/single_column/tests/test_scc.py @@ -10,7 +10,7 @@ from loki import Subroutine, Sourcefile, Dimension, fgen from loki.batch import ProcedureItem from loki.expression import Scalar, Array, IntLiteral -from loki.frontend import available_frontends, OMNI, OFP +from loki.frontend import available_frontends, OMNI from loki.ir import ( FindNodes, Assignment, CallStatement, Conditional, Loop, Pragma, PragmaRegion, pragmas_attached, is_loki_pragma, @@ -633,8 +633,7 @@ def test_scc_variable_demotion(frontend, horizontal): assert isinstance(kernel.variable_map['c'], Scalar) -@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, - 'OFP fails to parse multiconditional with embedded call.')])) +@pytest.mark.parametrize('frontend', available_frontends()) def test_scc_multicond(frontend, horizontal, blocking): """ Test if horizontal loops in multiconditionals with CallStatements are diff --git a/loki/transformations/tests/test_cloudsc.py b/loki/transformations/tests/test_cloudsc.py index 8d660b6dc..613421602 100644 --- a/loki/transformations/tests/test_cloudsc.py +++ b/loki/transformations/tests/test_cloudsc.py @@ -16,7 +16,7 @@ from loki.tools import ( execute, write_env_launch_script, local_loki_setup, local_loki_cleanup ) -from loki.frontend import available_frontends, OMNI, OFP, HAVE_FP +from loki.frontend import available_frontends, OMNI, HAVE_FP from loki.logging import warning pytestmark = pytest.mark.skipif('CLOUDSC_DIR' not in os.environ, reason='CLOUDSC_DIR not set') @@ -49,7 +49,6 @@ def fixture_bundle_create(here, local_loki_bundle): @pytest.mark.usefixtures('bundle_create') @pytest.mark.parametrize('frontend', available_frontends( - xfail=[(OFP, 'Lack of elemental support makes C-transpilation impossible')], skip=[(OMNI, 'OMNI needs FParser for parsing headers')] if not HAVE_FP else None )) def test_cloudsc(here, frontend): diff --git a/loki/transformations/tests/test_pool_allocator.py b/loki/transformations/tests/test_pool_allocator.py index cde02ddf8..95d6bf2ef 100644 --- a/loki/transformations/tests/test_pool_allocator.py +++ b/loki/transformations/tests/test_pool_allocator.py @@ -10,7 +10,7 @@ from loki import Dimension from loki.batch import Scheduler, SchedulerConfig from loki.expression import InlineCall, simplify -from loki.frontend import available_frontends, OMNI, FP, OFP +from loki.frontend import available_frontends, OMNI, FP from loki.ir import ( FindNodes, CallStatement, Assignment, Allocation, Deallocation, Loop, Pragma, get_pragma_parameters, FindVariables, FindInlineCalls @@ -1170,20 +1170,19 @@ def test_pool_allocator_more_call_checks(tmp_path, frontend, block_dim, caplog, assert calls[0].arguments == ('klon', 'temp1', 'temp2') assert calls[0].kwarguments == expected_kwarguments - if not frontend == OFP: - # Now repeat the checks for the inline call - calls = [i for i in FindInlineCalls().visit(kernel.body) if not i.name.lower() in ('max', 'c_sizeof', 'real')] - if cray_ptr_loc_rhs: - assert len(calls) == 2 - if calls[0].name == 'inline_kernel': - relevant_call = calls[0] - else: - relevant_call = calls[1] - else: - assert len(calls) == 1 + # Now repeat the checks for the inline call + calls = [i for i in FindInlineCalls().visit(kernel.body) if not i.name.lower() in ('max', 'c_sizeof', 'real')] + if cray_ptr_loc_rhs: + assert len(calls) == 2 + if calls[0].name == 'inline_kernel': relevant_call = calls[0] - assert relevant_call.arguments == ('jl',) - assert relevant_call.kwarguments == expected_kwarguments + else: + relevant_call = calls[1] + else: + assert len(calls) == 1 + relevant_call = calls[0] + assert relevant_call.arguments == ('jl',) + assert relevant_call.kwarguments == expected_kwarguments assert 'Derived-type vars in Subroutine:: kernel not supported in pool allocator' in caplog.text diff --git a/loki/transformations/transpile/tests/test_transpile.py b/loki/transformations/transpile/tests/test_transpile.py index addcf4314..d49dddf09 100644 --- a/loki/transformations/transpile/tests/test_transpile.py +++ b/loki/transformations/transpile/tests/test_transpile.py @@ -12,7 +12,7 @@ from loki import Subroutine, Module, cgen, cppgen, cudagen, FindNodes, Dimension, Scheduler, read_file from loki.build import jit_compile, jit_compile_lib, clean_test, Builder, Obj import loki.expression.symbols as sym -from loki.frontend import available_frontends, OFP +from loki.frontend import available_frontends from loki import ir from loki.transformations.transpile import FortranCTransformation @@ -793,9 +793,7 @@ def test_transpile_multibody_conditionals(tmp_path, builder, frontend, use_c_ptr @pytest.mark.parametrize('use_c_ptr', (False, True)) -@pytest.mark.parametrize('frontend', available_frontends( - skip=[(OFP, 'Prefix/elemental support not implemented')] -)) +@pytest.mark.parametrize('frontend', available_frontends()) def test_transpile_inline_elemental_functions(tmp_path, builder, frontend, use_c_ptr): """ Test correct inlining of elemental functions in C transpilation. @@ -854,9 +852,7 @@ def test_transpile_inline_elemental_functions(tmp_path, builder, frontend, use_c @pytest.mark.parametrize('use_c_ptr', (False, True)) -@pytest.mark.parametrize('frontend', available_frontends( - skip=[(OFP, 'Prefix/elemental support not implemented')] -)) +@pytest.mark.parametrize('frontend', available_frontends()) def test_transpile_inline_elementals_recursive(tmp_path, builder, frontend, use_c_ptr): """ Test correct inlining of nested elemental functions. @@ -1212,9 +1208,7 @@ def test_transpile_multiconditional_simple(tmp_path, builder, frontend, codegen) assert out_var == expected_results[i] -@pytest.mark.parametrize('frontend', available_frontends( - skip=[(OFP, 'OFP got problems with RangeIndex as case value!')] -)) +@pytest.mark.parametrize('frontend', available_frontends()) def test_transpile_multiconditional(tmp_path, builder, frontend): """ A test to verify multiconditionals/select case statements.