Skip to content

Commit

Permalink
scalar_syntax -> sequence_association
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfhm committed Nov 9, 2023
1 parent e0c3f26 commit 64a959d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions cmake/loki_transform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include( loki_transform_helpers )
# [CPP]
# [FRONTEND <frontend>]
# [INLINE_MEMBERS]
# [FIX_SCALARS]
# [FIX_SEQUENCE_ASSOCIATION]
# [BUILDDIR <build-path>]
# [SOURCES <source1> [<source2> ...]]
# [HEADERS <header1> [<header2> ...]]
Expand All @@ -47,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 FIX_SCALARS DERIVE_ARGUMENT_ARRAY_SHAPE
REMOVE_DERIVED_ARGS INLINE_MEMBERS FIX_SEQUENCE_ASSOCIATION DERIVE_ARGUMENT_ARRAY_SHAPE
)
set( oneValueArgs
COMMAND MODE DIRECTIVE FRONTEND CONFIG BUILDDIR
Expand Down Expand Up @@ -194,7 +194,7 @@ endfunction()
# [DIRECTIVE <openacc|openmp|...>]
# [SOURCES <source1> [<source2> ...]]
# [HEADERS <header1> [<header2> ...]]
# [NO_PLAN_SOURCEDIR COPY_UNMODIFIED INLINE_MEMBERS FIX_SCALARS]
# [NO_PLAN_SOURCEDIR COPY_UNMODIFIED INLINE_MEMBERS FIX_SEQUENCE_ASSOCIATION]
# )
#
# Applies a Loki bulk transformation to the source files belonging to a particular
Expand Down Expand Up @@ -223,7 +223,7 @@ endfunction()

function( loki_transform_target )

set( options NO_PLAN_SOURCEDIR COPY_UNMODIFIED CPP CPP_PLAN INLINE_MEMBERS FIX_SCALARS )
set( options NO_PLAN_SOURCEDIR COPY_UNMODIFIED CPP CPP_PLAN INLINE_MEMBERS FIX_SEQUENCE_ASSOCIATION )
set( single_value_args TARGET COMMAND MODE DIRECTIVE FRONTEND CONFIG PLAN )
set( multi_value_args SOURCES HEADERS )

Expand Down Expand Up @@ -292,8 +292,8 @@ function( loki_transform_target )
list( APPEND _TRANSFORM_OPTIONS INLINE_MEMBERS )
endif()

if( _PAR_FIX_SCALARS )
list( APPEND _TRANSFORM_OPTIONS FIX_SCALARS )
if( _PAR_FIX_SEQUENCE_ASSOCIATION )
list( APPEND _TRANSFORM_OPTIONS FIX_SEQUENCE_ASSOCIATION )
endif()

loki_transform(
Expand Down Expand Up @@ -389,7 +389,7 @@ or

set( options
CPP DATA_OFFLOAD REMOVE_OPENMP ASSUME_DEVICEPTR GLOBAL_VAR_OFFLOAD
TRIM_VECTOR_SECTIONS REMOVE_DERIVED_ARGS INLINE_MEMBERS FIX_SCALARS
TRIM_VECTOR_SECTIONS REMOVE_DERIVED_ARGS INLINE_MEMBERS FIX_SEQUENCE_ASSOCIATION
)
set( oneValueArgs
MODE DIRECTIVE FRONTEND CONFIG PATH OUTPATH
Expand Down
4 changes: 2 additions & 2 deletions cmake/loki_transform_helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ macro( _loki_transform_parse_options )
list( APPEND _ARGS --inline-members )
endif()

if( _PAR_FIX_SCALARS )
list( APPEND _ARGS --fix-scalars )
if( _PAR_FIX_SEQUENCE_ASSOCIATION )
list( APPEND _ARGS --fix-sequence-association )
endif()

if( _PAR_DERIVE_ARGUMENT_ARRAY_SHAPE )
Expand Down
2 changes: 1 addition & 1 deletion loki/transform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
from loki.transform.build_system_transform import * # noqa
from loki.transform.transform_hoist_variables import * # noqa
from loki.transform.transform_parametrise import * # noqa
from loki.transform.transform_scalar_syntax import * # noqa
from loki.transform.transform_sequence_association import * # noqa
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


__all__ = [
'fix_scalar_syntax'
'fix_sequence_association'
]

def check_if_scalar_syntax(arg, dummy):
Expand Down Expand Up @@ -175,7 +175,7 @@ def process_symbol(symbol, caller, call):
if call.routine in caller.members and symbol in caller.variables:
return symbol

raise RuntimeError('[Loki::fix_scalar_syntax] Unable to resolve argument dimension. Module variable?')
raise RuntimeError('[Loki::fix_sequence_association] Unable to resolve argument dimension. Module variable?')


def construct_length(xrange, caller, call):
Expand All @@ -196,7 +196,7 @@ def construct_length(xrange, caller, call):
return single_sum(new_stop) - new_start + IntLiteral(1)


def fix_scalar_syntax(routine):
def fix_sequence_association(routine):
"""
Housekeeping routine to replace scalar syntax when passing arrays as arguments
For example, a call like
Expand Down
6 changes: 3 additions & 3 deletions scripts/loki_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ 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-scalars/--no-fix-scalars', default=False,
@click.option('--fix-sequence-association/--no-fix-sequence-association', 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, fix_scalars,
global_var_offload, remove_derived_args, inline_members, fix_sequence_association,
derive_argument_array_shape
):
"""
Expand Down Expand Up @@ -211,7 +211,7 @@ def convert(
# Apply the basic SCC transformation set
scheduler.process( SCCBaseTransformation(
horizontal=horizontal, directive=directive,
inline_members=inline_members, fix_scalars=fix_scalars
inline_members=inline_members, fix_sequence_association=fix_sequence_association
))
scheduler.process( SCCDevectorTransformation(
horizontal=horizontal, trim_vector_sections=trim_vector_sections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest

from conftest import available_frontends
from loki.transform import fix_scalar_syntax
from loki.transform import fix_sequence_association
from loki.module import Module
from loki.ir import CallStatement
from loki.visitors import FindNodes
Expand Down Expand Up @@ -126,7 +126,7 @@ def test_transform_scalar_notation(frontend):
module = Module.from_source(fcode, frontend=frontend)
routine = module['main']

fix_scalar_syntax(routine)
fix_sequence_association(routine)

calls = FindNodes(CallStatement).visit(routine.body)

Expand Down
10 changes: 5 additions & 5 deletions transformations/transformations/single_column_coalesced.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import re
from loki.expression import symbols as sym
from loki.transform import resolve_associates, inline_member_procedures, fix_scalar_syntax
from loki.transform import resolve_associates, inline_member_procedures, fix_sequence_association
from loki import (
Transformation, FindNodes, Transformer, info,
pragmas_attached, as_tuple, flatten, ir, FindExpressions,
Expand Down Expand Up @@ -40,14 +40,14 @@ class methods can be called directly.
Enable full source-inlining of member subroutines; default: False.
"""

def __init__(self, horizontal, directive=None, inline_members=False, fix_scalars=False):
def __init__(self, horizontal, directive=None, inline_members=False, fix_sequence_association=False):
self.horizontal = horizontal

assert directive in [None, 'openacc']
self.directive = directive

self.inline_members = inline_members
self.fix_scalars = fix_scalars
self.fix_sequence_association = fix_sequence_association

@classmethod
def check_routine_pragmas(cls, routine, directive):
Expand Down Expand Up @@ -293,8 +293,8 @@ def process_kernel(self, routine):
v_index = self.get_integer_variable(routine, name=self.horizontal.index)

# Transform arrays passed with scalar syntax to array syntax
if self.fix_scalars:
fix_scalar_syntax(routine)
if self.fix_sequence_association:
fix_sequence_association(routine)

# Perform full source-inlining for member subroutines if so requested
if self.inline_members:
Expand Down

0 comments on commit 64a959d

Please sign in to comment.