PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

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

Open TeranIvy opened this issue 4 years ago • 3 comments

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.

TeranIvy avatar Jul 20 '21 13:07 TeranIvy

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?

arporter avatar Jan 24 '22 09:01 arporter

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

  • [x] 1. Add 'dof' to the list of USER_KERNEL_ITERATION_SPACES in LFRic Constants
  • [x] 2. Edit LFRicKernCallFactory to check if iterates_over is equal to dof and modify loop_type to equal dof. This will then be picked up by LFRicLoop and set the iterator tag to df.
  • [x] 3. operates_on = 'dof' is used by Builtins validating their metadata through LFRicKernelMetadata. Should just add a one line conditional to LFRicKern to check if self.name is the name of a builtin. This should add a little bit of protection.

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]
  1. 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()

oakleybrunt avatar Oct 20 '23 15:10 oakleybrunt

#2556 only added the documentation, not the implementation.

arporter avatar May 13 '24 15:05 arporter

Completed via #2711 and #2712.

TeranIvy avatar Dec 03 '24 14:12 TeranIvy