stfc / PSyclone

Domain-specific compiler and code transformation system for Finite Difference/Volume/Element Earth-system models in Fortran
BSD 3-Clause "New" or "Revised" License
102 stars 28 forks source link

[LFRic] Support for user-defined kernels that operate on DoFs #1351

Open TeranIvy opened 3 years ago

TeranIvy commented 3 years ago

Originally we had preliminary support for user-defined kernels that operate on DoFs. However, it produced incorrect code and we removed it until the need arises.

There are several LFRic PSyKAl-lite routines that could be removed with this support, hence this issue. Furthermore, it seems that we need to differentiate between operates_on = DOF and operates_on = DOF_COLUMN.

arporter commented 2 years ago

Following on from our chat in the telco this morning, it sounds as though the random-number initialisation functionality needed for PSyAD should also be a dof-wise kernel. In fact, for the simplest case it could just be a built-in? I guess it depends on what Ben's existing kernel code already does?

oakleybrunt commented 10 months ago

Proposed changes:

Allowed metadata types and access

  1. field (READ, WRITE, READWRITE)
  2. scalar (READ only)

LFRic Builtins metadata vs User defined kernels metadata

LFRic builtins use the LFRicKernelMetadata to store and validate their metadata. However, user-defined kernels use the newer LFRicKernMetadata, LFRicKern, and LFRicArgDescriptor to store and validate their metadata. This means that no checks are required to be added to LFRicKernelMetadata to validate user-defined kernels that operate on dofs since this isn't touched by LFRicKern.

Changes

No Change

  1. Fields are currently only allowed to be READ, WRITE, READWRITE, as defined in domain/lfric/lfric_arg_descriptor.py:
    # Test allowed accesses for fields
    field_disc_accesses = [AccessType.READ, AccessType.WRITE,
                       AcessType.READWRITE]
  2. Scalars also have the correct access types - only allowed to be READ as defined in domain/lfric/lfric_arg_descriptor.py:
    # Test allowed accesses for scalars (read_only or reduction)
    scalar_accesses = [AccessType.READ] + AccessType.get_valid_reduction_modes()
arporter commented 3 months ago

2556 only added the documentation, not the implementation.