diff --git a/cmake/loki_transform.cmake b/cmake/loki_transform.cmake index dc14af58e..6ca391992 100644 --- a/cmake/loki_transform.cmake +++ b/cmake/loki_transform.cmake @@ -25,6 +25,7 @@ include( loki_transform_helpers ) # [CPP] # [FRONTEND ] # [INLINE_MEMBERS] +# [FIX_SCALAR_SYNTAX] # [BUILDDIR ] # [SOURCES [ ...]] # [HEADERS [ ...]] @@ -46,7 +47,7 @@ function( loki_transform ) set( options CPP DATA_OFFLOAD REMOVE_OPENMP ASSUME_DEVICEPTR TRIM_VECTOR_SECTIONS GLOBAL_VAR_OFFLOAD - REMOVE_DERIVED_ARGS INLINE_MEMBERS DERIVE_ARGUMENT_ARRAY_SHAPE + REMOVE_DERIVED_ARGS INLINE_MEMBERS FIX_SCALAR_SYNTAX DERIVE_ARGUMENT_ARRAY_SHAPE ) set( oneValueArgs COMMAND MODE DIRECTIVE FRONTEND CONFIG BUILDDIR @@ -193,7 +194,7 @@ endfunction() # [DIRECTIVE ] # [SOURCES [ ...]] # [HEADERS [ ...]] -# [NO_PLAN_SOURCEDIR COPY_UNMODIFIED INLINE_MEMBERS] +# [NO_PLAN_SOURCEDIR COPY_UNMODIFIED INLINE_MEMBERS FIX_SCALAR_SYNTAX] # ) # # Applies a Loki bulk transformation to the source files belonging to a particular @@ -222,7 +223,7 @@ endfunction() function( loki_transform_target ) - set( options NO_PLAN_SOURCEDIR COPY_UNMODIFIED CPP CPP_PLAN INLINE_MEMBERS ) + set( options NO_PLAN_SOURCEDIR COPY_UNMODIFIED CPP CPP_PLAN INLINE_MEMBERS FIX_SCALAR_SYNTAX ) set( single_value_args TARGET COMMAND MODE DIRECTIVE FRONTEND CONFIG PLAN ) set( multi_value_args SOURCES HEADERS ) @@ -291,6 +292,10 @@ function( loki_transform_target ) list( APPEND _TRANSFORM_OPTIONS INLINE_MEMBERS ) endif() + if( _PAR_FIX_SCALAR_SYNTAX ) + list( APPEND _TRANSFORM_OPTIONS FIX_SCALAR_SYNTAX ) + endif() + loki_transform( COMMAND ${_PAR_COMMAND} OUTPUT ${LOKI_SOURCES_TO_APPEND} @@ -384,7 +389,7 @@ or set( options CPP DATA_OFFLOAD REMOVE_OPENMP ASSUME_DEVICEPTR GLOBAL_VAR_OFFLOAD - TRIM_VECTOR_SECTIONS REMOVE_DERIVED_ARGS INLINE_MEMBERS + TRIM_VECTOR_SECTIONS REMOVE_DERIVED_ARGS INLINE_MEMBERS FIX_SCALAR_SYNTAX ) set( oneValueArgs MODE DIRECTIVE FRONTEND CONFIG PATH OUTPATH diff --git a/cmake/loki_transform_helpers.cmake b/cmake/loki_transform_helpers.cmake index a3a5b344d..4dc871e36 100644 --- a/cmake/loki_transform_helpers.cmake +++ b/cmake/loki_transform_helpers.cmake @@ -112,6 +112,10 @@ macro( _loki_transform_parse_options ) list( APPEND _ARGS --inline-members ) endif() + if( _PAR_FIX_SCALAR_SYNTAX ) + list( APPEND _ARGS --fix-scalar-syntax ) + endif() + if( _PAR_DERIVE_ARGUMENT_ARRAY_SHAPE ) list( APPEND _ARGS --derive-argument-array-shape ) endif() diff --git a/scripts/loki_transform.py b/scripts/loki_transform.py index 1679a66a4..61ee9e54b 100644 --- a/scripts/loki_transform.py +++ b/scripts/loki_transform.py @@ -108,12 +108,15 @@ def cli(debug): help="Remove derived-type arguments and replace with canonical arguments") @click.option('--inline-members/--no-inline-members', default=False, help='Inline member functions for SCC-class transformations.') +@click.option('--fix-scalar-syntax/--no-fix-scalar-syntax', default=False, + help='Replace array arguments passed as scalars with arrays.') @click.option('--derive-argument-array-shape/--no-derive-argument-array-shape', default=False, help="Recursively derive explicit shape dimension for argument arrays") def convert( mode, config, build, source, header, cpp, directive, include, define, omni_include, xmod, data_offload, remove_openmp, assume_deviceptr, frontend, trim_vector_sections, - global_var_offload, remove_derived_args, inline_members, derive_argument_array_shape + global_var_offload, remove_derived_args, inline_members, fix_scalar_syntax, + derive_argument_array_shape ): """ Batch-processing mode for Fortran-to-Fortran transformations that @@ -207,7 +210,8 @@ def convert( if mode in ['scc', 'scc-hoist', 'scc-stack']: # Apply the basic SCC transformation set scheduler.process( SCCBaseTransformation( - horizontal=horizontal, directive=directive, inline_members=inline_members + horizontal=horizontal, directive=directive, + inline_members=inline_members, fix_scalar_syntax=fix_scalar_syntax )) scheduler.process( SCCDevectorTransformation( horizontal=horizontal, trim_vector_sections=trim_vector_sections diff --git a/transformations/transformations/single_column_coalesced.py b/transformations/transformations/single_column_coalesced.py index 77712e0fc..d1ac75bde 100644 --- a/transformations/transformations/single_column_coalesced.py +++ b/transformations/transformations/single_column_coalesced.py @@ -40,12 +40,13 @@ class methods can be called directly. Enable full source-inlining of member subroutines; default: False. """ - def __init__(self, horizontal, directive=None, inline_members=False): + def __init__(self, horizontal, directive=None, inline_members=False, fix_scalar_syntax=False): self.horizontal = horizontal assert directive in [None, 'openacc'] self.directive = directive + self.fix_scalar_syntax = fix_scalar_syntax self.inline_members = inline_members @classmethod @@ -291,7 +292,9 @@ def process_kernel(self, routine): # Find the iteration index variable for the specified horizontal v_index = self.get_integer_variable(routine, name=self.horizontal.index) - fix_scalar_syntax(routine) + # Transform arrays passed with scalar syntax to array syntax + if self.fix_scalar_syntax: + fix_scalar_syntax(routine) # Perform full source-inlining for member subroutines if so requested if self.inline_members: