Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/lfric/eg11/helmholtz_solver_alg_mod.x90
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module helmholtz_solver_alg_mod

use field_mod, only : field_type
use operator_mod, only : operator_type
use constants_mod, only : r_def
use scaled_matrix_vector_kernel_mod, only: opt_scaled_matrix_vector_kernel_type

implicit none
Expand Down
3 changes: 1 addition & 2 deletions examples/lfric/eg4/solver_mod.x90
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module solver_mod
end type example_type

private
public :: solver_algorithm
public :: jacobi_solver_algorithm

contains

Expand Down Expand Up @@ -129,7 +129,6 @@ subroutine jacobi_solver_algorithm(lhs, rhs, mm, mesh, n_iter)

diagonal = field_type( vector_space = rhs_fs )
res = field_type( vector_space = rhs_fs )
res2 = field_type( vector_space = rhs_fs )

call invoke( mm_diagonal_kernel_type(diagonal, mm), &
X_divideby_Y(lhs, rhs, diagonal), &
Expand Down
2 changes: 2 additions & 0 deletions examples/lfric/eg6/alg.x90
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ contains
subroutine example(precond_option, mmd)

use precondition_mod, only : precondition
use constants_mod, only : r_def, i_def
use field_mod, only : field_type

implicit none

Expand Down
1 change: 1 addition & 0 deletions examples/lfric/eg7/alg.x90
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module alg
use field_mod, only : field_type
use operator_mod, only : operator_type
use columnwise_operator_mod, only : columnwise_operator_type
use constants_mod, only : r_def

contains

Expand Down
1 change: 1 addition & 0 deletions examples/lfric/eg8/helmholtz_solver_alg_mod.x90
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module helmholtz_solver_alg_mod

use field_mod, only: field_type
use constants_mod, only: i_def, r_def
use timestepping_config_mod, only: tau_t

type(field_type) :: hb_inv
type(field_type), private :: grad_p
Expand Down
3 changes: 3 additions & 0 deletions examples/lfric/eg9/advective_inc_alg_mod.x90
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ module advective_inc_alg_mod
use operator_mod, only: operator_type
use quadrature_xyoz_mod, only: quadrature_xyoz_type
use quadrature_rule_gaussian_mod, only: quadrature_rule_gaussian_type
use quadrature_face_mod, only: quadrature_face_type
use other, only: reference_element, chi_stencil_extent


! PsyKAl PSYClone kernels
use rtheta_bd_kernel_mod, only: rtheta_bd_kernel_type
Expand Down
8 changes: 6 additions & 2 deletions src/psyclone/core/symbolic_maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ def equal(exp1, exp2, identical_variables=None):
if exp1 is None or exp2 is None:
return exp1 == exp2

diff = SymbolicMaths._subtract(exp1, exp2,
identical_variables=identical_variables)
try:
diff = SymbolicMaths._subtract(
exp1, exp2, identical_variables=identical_variables)
except Exception:
return False

# For ranges all values (start, stop, step) must be equal, meaning
# each index of the difference must evaluate to 0:
if isinstance(diff, list):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@

from psyclone.core import SymbolicMaths
from psyclone.domain.common.algorithm import AlgorithmInvokeCall, KernelFunctor
from psyclone.errors import InternalError
from psyclone.errors import InternalError, GenerationError
from psyclone.psyGen import Transformation
from psyclone.psyir.nodes import (
Call, Routine, Literal, Reference, CodeBlock, UnaryOperation, Node)
Call, Routine, Literal, Reference, UnaryOperation, Node, CodeBlock,
StructureReference)
from psyclone.psyir.symbols import (ContainerSymbol,
ImportInterface, RoutineSymbol)
from psyclone.psyir.transformations import TransformationError
Expand Down Expand Up @@ -136,6 +137,9 @@ def _add_arg(arg, arguments):
break
else:
arguments.append(arg.copy())
elif isinstance(arg, Call) and isinstance(arg.routine,
StructureReference):
arguments.append(arg.copy())
elif isinstance(arg, CodeBlock):
arguments.append(arg.copy())
else:
Expand All @@ -146,9 +150,10 @@ def _add_arg(arg, arguments):
string = f"{string} is of type '{type(arg).__name__}'."
else:
string = f"but found '{type(arg).__name__}'."
raise TypeError(
raise GenerationError(
f"Expected Algorithm-layer kernel arguments to be "
f"a Literal, Reference or CodeBlock, {string}.")
f"a Literal, Reference, type-bound Call or a CodeBlock"
f" {string}.")

@staticmethod
def remove_imported_symbols(node):
Expand Down
12 changes: 11 additions & 1 deletion src/psyclone/domain/common/transformations/alg_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
'''
from psyclone.domain.common.transformations import RaisePSyIR2AlgTrans
from psyclone.psyGen import Transformation
from psyclone.psyir.nodes import Call, Routine, Container
from psyclone.psyir.nodes import Call, Routine, Container, CodeBlock
from psyclone.psyir.transformations import TransformationError
from psyclone.utils import transformation_documentation_wrapper

Expand Down Expand Up @@ -82,6 +82,16 @@ def validate(self, node, options=None, **kwargs):
f"should be the root of a PSyIR tree but this node has a "
f"parent.")

for cb in node.walk(CodeBlock):
if "invoke" in cb.get_symbol_names():
raise TransformationError(
f"Error in {self.name} transformation. The supplied code"
f"cannot be uplifted to an Algorithm layer because "
f"there is an unrecognised Fortran construct containing an"
f" invoke: {cb.debug_string()}\n You could attempt "
f"rewriting the algorithm file with the invoke outside "
f" this construct.")

def apply(self, node, options=None, **kwargs):
''' Apply transformation to the supplied PSyIR node.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ def get_arguments(self, node, options=None, check_args=False):
# The processed (lowered) argument list for any quadrature
# arguments.
quad_arguments = []
# The processed (lowered) argument list for any halo
# arguments.
halo_arguments = []

# pylint: disable=too-many-nested-blocks
for kern_call in node.arguments:
Expand Down Expand Up @@ -265,6 +268,13 @@ def get_arguments(self, node, options=None, check_args=False):
self._add_arg(quad_arg, quad_arguments)
arg_idx += 1

if "halo_cell_column" in kernel_metadata.operates_on:
# If a kernel operates_on the halo cells, it must have
# a final argument with the halo_depth
halo_arg = kern_call.children[arg_idx]
arg_idx += 1
self._add_arg(halo_arg, halo_arguments)

# Incorrect number of kernel functor arguments
if check_args and len(kern_call.children) != arg_idx:
raise GenerationError(
Expand All @@ -276,11 +286,12 @@ def get_arguments(self, node, options=None, check_args=False):
# expected in the processed (lowered) argument list. (We
# expect all scalar, field and operator arguments first, then
# all stencil arguments (separated into size arguments first
# followed by direction arguments) and finally all qr
# arguments).
# followed by direction arguments), then all qr arguments and
# finally all halo arguments.
arguments.extend(stencil_size_arguments)
arguments.extend(stencil_direction_arguments)
arguments.extend(quad_arguments)
arguments.extend(halo_arguments)

return arguments

Expand Down Expand Up @@ -332,7 +343,8 @@ def apply(self, node, options=None):
# TODO #898 SymbolTable.remove() does not support
# DataTypeSymbol so remove it manually.
# pylint: disable=protected-access
del table._symbols[sym.name]
if sym.name in table._symbols:
del table._symbols[sym.name]


__all__ = ['LFRicAlgInvoke2PSyCallTrans']
Loading
Loading