38 '''This module implements a class that manages all of the data references
39 that must be copied over to a GPU before executing the kernel. Ordering
40 of the parameters does not matter apart from where we have members of
41 derived types. In that case, the derived type itself must be specified
42 first before any members.
45 from psyclone
import psyGen
52 '''Kernel call arguments that need to be declared by OpenACC
53 directives. KernCallArgList only needs to be specialised
54 where modified, or additional, arguments are required.
55 Scalars are apparently not required but it is valid in
56 OpenACC to include them and requires less specialisation
61 '''Add cell-map to the list of required arrays.
63 :param var_accesses: optional VariablesAccessInfo instance to store
64 the information about variable accesses.
65 :type var_accesses: Optional[
66 :py:class:`psyclone.core.VariablesAccessInfo`]
69 cargs = psyGen.args_filter(self.
_kern_kern.args, arg_meshes=[
"gh_coarse"])
72 f
"An LFRic intergrid kernel should have only one coarse mesh "
73 f
"but '{self._kern.name}' has {len(cargs)}")
76 base_name =
"cell_map_" + carg.name
77 self.
appendappend(base_name)
82 '''Adds a cell argument to the argument list and if supplied stores
83 this access in var_accesses. Although normally just a scalar, the cell
84 argument may actually require a lookup from a colour map array. Either
85 way, this method adds the name of the variable to the argument list.
87 :param var_accesses: optional VariablesAccessInfo instance to store
88 the information about variable accesses.
89 :type var_accesses: Optional[
90 :py:class:`psyclone.core.VariablesAccessInfo`]
94 self.
appendappend(ref.symbol.name)
96 def stencil(self, arg, var_accesses=None):
97 '''Add general stencil information associated with the argument 'arg'
98 to the argument list. OpenACC requires the full dofmap to be
99 specified. If supplied it also stores this access in var_accesses.
101 :param arg: the meta-data description of the kernel argument with
102 which the stencil is associated.
103 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
104 :param var_accesses: optional VariablesAccessInfo instance to store
105 the information about variable accesses.
106 :type var_accesses: Optional[
107 :py:class:`psyclone.core.VariablesAccessInfo`]
113 var_name = LFRicStencils.dofmap_symbol(self.
_kern_kern.root.symbol_table,
115 self.
appendappend(var_name, var_accesses)
118 '''Add general 2D stencil information associated with the argument
119 'arg' to the argument list. OpenACC requires the full dofmap to be
120 specified. If supplied it also stores this access in var_accesses.This
121 method passes through to the stencil method.
123 :param arg: the meta-data description of the kernel
124 argument with which the stencil is associated.
125 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
126 :param var_accesses: optional VariablesAccessInfo instance to store
127 the information about variable accesses.
128 :type var_accesses: Optional[
129 :py:class:`psyclone.core.VariablesAccessInfo`]
135 '''Add stencil information to the argument list associated with the
136 argument 'arg' if the extent is unknown. If supplied it also stores
137 this access in var_accesses.
139 :param arg: the kernel argument with which the stencil is associated.
140 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
141 :param var_accesses: optional VariablesAccessInfo instance to store
142 the information about variable accesses.
143 :type var_accesses: Optional[
144 :py:class:`psyclone.core.VariablesAccessInfo`]
151 name = LFRicStencils.dofmap_size_symbol(self.
_kern_kern.root.symbol_table,
153 self.
appendappend(name, var_accesses)
156 '''Add 2D stencil information to the argument list associated with the
157 argument 'arg' if the extent is unknown. If supplied it also stores
158 this access in var_accesses. This method passes through to the
159 stencil_unknown_extent method.
161 :param arg: the kernel argument with which the stencil is associated.
162 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
163 :param var_accesses: optional VariablesAccessInfo instance to store
164 the information about variable accesses.
165 :type var_accesses: Optional[
166 :py:class:`psyclone.core.VariablesAccessInfo`]
172 '''Add the operator arguments if they have not already been
173 added. OpenACC requires the derived type and the dereferenced
174 data to be specified. If supplied it also stores this access in
177 :param arg: the meta-data description of the operator.
178 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
179 :param var_accesses: optional VariablesAccessInfo instance to store
180 the information about variable accesses.
181 :type var_accesses: Optional[
182 :py:class:`psyclone.core.VariablesAccessInfo`]
187 if arg.proxy_name_indexed
not in self.
arglistarglist:
188 self.
appendappend(arg.proxy_name_indexed, var_accesses)
193 '''Add compulsory arguments associated with this function space to
194 the list. OpenACC requires the full function-space map
195 to be specified. If supplied it also stores this access in
198 :param function_space: the function space for which the compulsory
200 :type function_space: :py:class:`psyclone.domain.lfric.FunctionSpace`
201 :param var_accesses: optional VariablesAccessInfo instance to store
202 the information about variable accesses.
203 :type var_accesses: Optional[
204 :py:class:`psyclone.core.VariablesAccessInfo`]
207 if self.
_kern_kern.iterates_over !=
"cell_column":
209 self.
appendappend(function_space.undf_name, var_accesses)
212 self.
appendappend(function_space.map_name, var_accesses)
215 '''Add arrays that need to be uploaded for inter-grid kernels.
216 These arrays contain the mapping between fine and coarse meshes.
218 :param function_space: the function space associated with the mesh.
219 :type function_space: :py:class:`psyclone.domain.lfric.FunctionSpace`
220 :param var_accesses: optional VariablesAccessInfo instance to store
221 the information about variable accesses.
222 :type var_accesses: Optional[
223 :py:class:`psyclone.core.VariablesAccessInfo`]
228 arg = self.
_kern_kern.arguments.get_arg_on_space(function_space)
229 if arg.mesh ==
"gh_fine":
231 map_name = function_space.map_name
232 self.
appendappend(map_name, var_accesses)
237 var_accesses=var_accesses)
239 def scalar(self, scalar_arg, var_accesses=None):
241 Override the default implementation as there's no need to specify
242 scalars for an OpenACC data region.
244 :param scalar_arg: the kernel argument.
245 :type scalar_arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
246 :param var_accesses: optional VariablesAccessInfo instance that
247 stores information about variable accesses.
248 :type var_accesses: Optional[
249 :py:class:`psyclone.core.VariablesAccessInfo`]
256 __all__ = [
"KernCallAccArgList"]
def append(self, var_name, var_accesses=None, var_access_name=None, mode=AccessType.READ, metadata_posn=None)
def cell_position(self, var_accesses=None)
def fs_compulsory_field(self, function_space, var_accesses=None)
def stencil(self, arg, var_accesses=None)
def stencil_unknown_extent(self, arg, var_accesses=None)
def scalar(self, scalar_arg, var_accesses=None)
def operator(self, arg, var_accesses=None)
def stencil_2d(self, arg, var_accesses=None)
def stencil_2d_unknown_extent(self, arg, var_accesses=None)
def fs_intergrid(self, function_space, var_accesses=None)
def stencil_unknown_extent(self, arg, var_accesses=None)
def stencil(self, arg, var_accesses=None)
def cell_map(self, var_accesses=None)
def fs_compulsory_field(self, function_space, var_accesses=None)
def cell_position(self, var_accesses=None)
def cell_ref_name(self, var_accesses=None)
def stencil_unknown_extent(self, arg, var_accesses=None)
def stencil(self, arg, var_accesses=None)
def fs_compulsory_field(self, function_space, var_accesses=None)
def cell_position(self, var_accesses=None)