Skip to content

Commit

Permalink
Merge pull request #139 from ecmwf-ifs/naml-derived-args-optional
Browse files Browse the repository at this point in the history
Make derived argument flattening optional in loki_transform convert
  • Loading branch information
reuterbal authored Sep 5, 2023
2 parents 400ebbb + ca67d9a commit 38e347a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions cmake/loki_transform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ endmacro()
# [OMNI_INCLUDE <omni-inc1> [<omni-inc2> ...]]
# [XMOD <xmod-dir1> [<xmod-dir2> ...]]
# [REMOVE_OPENMP] [DATA_OFFLOAD] [GLOBAL_VAR_OFFLOAD]
# [TRIM_VECTOR_SECTIONS]
# [TRIM_VECTOR_SECTIONS] [NO_REMOVE_DERIVED_ARGS]
# )
#
# Call ``loki-transform.py convert ...`` with the provided arguments.
Expand All @@ -199,7 +199,7 @@ endmacro()

function( loki_transform_convert )

set( options CPP DATA_OFFLOAD REMOVE_OPENMP GLOBAL_VAR_OFFLOAD TRIM_VECTOR_SECTIONS )
set( options CPP DATA_OFFLOAD REMOVE_OPENMP GLOBAL_VAR_OFFLOAD TRIM_VECTOR_SECTIONS NO_REMOVE_DERIVED_ARGS )
set( oneValueArgs MODE DIRECTIVE FRONTEND CONFIG PATH OUTPATH )
set( multiValueArgs OUTPUT DEPENDS INCLUDES INCLUDE HEADERS HEADER DEFINITIONS DEFINE OMNI_INCLUDE XMOD )

Expand Down Expand Up @@ -244,6 +244,10 @@ function( loki_transform_convert )
list( APPEND _ARGS --trim-vector-sections )
endif()

if( ${_PAR_NO_REMOVE_DERIVED_ARGS} )
list( APPEND _ARGS --no-remove-derived-args )
endif()

_loki_transform_env_setup()

add_custom_command(
Expand Down
12 changes: 9 additions & 3 deletions scripts/loki_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,13 @@ def cli(debug):
help='Trim vector loops in SCC transform to exclude scalar assignments.')
@click.option('--global-var-offload', is_flag=True, default=False,
help="Generate offload instructions for global vars imported via 'USE' statements.")
def convert(out_path, path, header, cpp, directive, include, define, omni_include, xmod,
data_offload, remove_openmp, mode, frontend, config, trim_vector_sections, global_var_offload):
@click.option('--remove-derived-args/--no-remove-derived-args', default=True,
help="Remove derived-type arguments and replace with canonical arguments")
def convert(
out_path, path, header, cpp, directive, include, define, omni_include, xmod,
data_offload, remove_openmp, mode, frontend, config, trim_vector_sections,
global_var_offload, remove_derived_args
):
"""
Single Column Abstraction (SCA): Convert kernel into single-column
format and adjust driver to apply it over in a horizontal loop.
Expand Down Expand Up @@ -191,7 +196,8 @@ def convert(out_path, path, header, cpp, directive, include, define, omni_includ
definitions=definitions, **build_args)

# First, remove all derived-type arguments; caller first!
scheduler.process(transformation=DerivedTypeArgumentsTransformation())
if remove_derived_args:
scheduler.process(transformation=DerivedTypeArgumentsTransformation())

# Remove DR_HOOK and other utility calls first, so they don't interfere with SCC loop hoisting
if 'scc' in mode:
Expand Down

0 comments on commit 38e347a

Please sign in to comment.