38 '''This module implements a class that manages the argument for a kernel
39 call. It especially adds all implicitly required parameters.
40 It creates the argument in two formats: first as a list of strings, but also
41 as a list of PSyIR nodes. TODO #1930: the support for the string format
42 should be removed as we migrate to use PSyIR in LFRic.
45 from collections
import namedtuple
47 from psyclone
import psyGen
55 DataSymbol, DataTypeSymbol, UnresolvedType, ContainerSymbol,
56 ImportInterface, ScalarType)
66 '''Creates the argument list required to call kernel "kern" from the
67 PSy-layer and captures the positions of the following arguments in
68 the argument list: nlayers, number of quadrature points and number
69 of degrees of freedom. The ordering and type of arguments is
70 captured by the base class.
72 :param kern: The kernel that is being called.
73 :type kern: :py:class:`psyclone.domain.lfric.LFRicKern`
76 NdfInfo = namedtuple(
"NdfInfo", [
"position",
"function_space"])
78 def __init__(self, kern):
79 super().__init__(kern)
86 '''Returns the symbol for a user-defined type. If required, the
87 required import statements will all be generated.
89 :param str module_name: the name of the module from which the \
90 user-defined type must be imported.
91 :param str user_type: the name of the user-defined type.
92 :param str name: the name of the variable to be used in the Reference.
93 :param Optional[str] tag: tag to use for the variable, defaults to \
96 :return: the symbol that is used in the reference
97 :rtype: :py:class:`psyclone.psyir.symbols.Symbol`
104 sym = self.
_symtab_symtab.lookup_with_tag(tag)
113 module = self.
_symtab_symtab.lookup(module_name)
115 module = self.
_symtab_symtab.new_symbol(module_name,
116 symbol_type=ContainerSymbol)
119 mod_sym_tab = module.find_symbol_table(self.
_kern_kern)
123 user_type_symbol = mod_sym_tab.find_or_create(
125 symbol_type=DataTypeSymbol,
126 datatype=UnresolvedType(),
127 interface=ImportInterface(module))
130 sym = self.
_symtab_symtab.new_symbol(name, tag=tag,
131 symbol_type=DataSymbol,
132 datatype=user_type_symbol)
136 name, tag=None, overwrite_datatype=None):
138 '''Creates a reference to a variable of a user-defined type. If
139 required, the required import statements will all be generated.
141 :param str module_name: the name of the module from which the
142 user-defined type must be imported.
143 :param str user_type: the name of the user-defined type.
144 :param member_list: the members used hierarchically.
145 :type member_list: List[str]
146 :param str name: the name of the variable to be used in the Reference.
147 :param Optional[str] tag: tag to use for the variable, defaults to
149 :param overwrite_datatype: the datatype for the reference, which will
150 overwrite the value determined by analysing the corresponding
151 user defined type. This is useful when e.g. the module that
152 declares the structure cannot be accessed.
153 :type overwrite_datatype:
154 Optional[:py:class:`psyclone.psyir.symbols.DataType`]
156 :return: the symbol that is used in the reference
157 :rtype: :py:class:`psyclone.psyir.symbols.Symbol`
160 sym = self.
get_user_typeget_user_type(module_name, user_type, name, tag)
162 create(sym, member_list,
163 overwrite_datatype=overwrite_datatype))
167 '''Adds a cell argument to the argument list and if supplied stores
168 this access in var_accesses.
170 :param var_accesses: optional VariablesAccessInfo instance to store \
171 the information about variable accesses.
172 :type var_accesses: \
173 :py:class:`psyclone.core.VariablesAccessInfo`
176 cell_ref_name, ref = self.
cell_ref_namecell_ref_name(var_accesses)
178 self.
appendappend(cell_ref_name)
181 '''Add cell-map and related cell counts (for inter-grid kernels)
182 to the argument list. If supplied it also stores these accesses to the
185 :param var_accesses: optional VariablesAccessInfo instance to store \
186 the information about variable accesses.
187 :type var_accesses: \
188 :py:class:`psyclone.core.VariablesAccessInfo`
191 cargs = psyGen.args_filter(self.
_kern_kern.args, arg_meshes=[
"gh_coarse"])
193 fargs = psyGen.args_filter(self.
_kern_kern.args, arg_meshes=[
"gh_fine"])
195 base_name =
"cell_map_" + carg.name
198 cell_ref_name, cell_ref = self.
cell_ref_namecell_ref_name(var_accesses)
200 ScalarType.Intrinsic.INTEGER)
201 self.
appendappend(f
"{sym.name}(:,:,{cell_ref_name})",
202 var_accesses=var_accesses, var_access_name=sym.name)
205 base_name = f
"ncpc_{farg.name}_{carg.name}_x"
207 self.
appendappend(sym.name, var_accesses)
209 base_name = f
"ncpc_{farg.name}_{carg.name}_y"
211 self.
appendappend(sym.name, var_accesses)
213 base_name = f
"ncell_{farg.name}"
215 self.
appendappend(sym.name, var_accesses)
218 '''Add mesh height (nlayers) to the argument list and if supplied
219 stores this access in var_accesses.
221 :param var_accesses: optional VariablesAccessInfo instance to store \
222 the information about variable accesses.
223 :type var_accesses: \
224 :py:class:`psyclone.core.VariablesAccessInfo`
227 if self.
_kern_kern.iterates_over
not in [
"cell_column",
"domain"]:
230 self.
appendappend(nlayers_symbol.name, var_accesses)
233 def scalar(self, scalar_arg, var_accesses=None):
235 Add the necessary argument for a scalar quantity as well as an
236 appropriate Symbol to the SymbolTable.
238 :param scalar_arg: the scalar kernel argument.
239 :type scalar_arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
240 :param var_accesses: optional VariablesAccessInfo instance that \
241 stores information about variable accesses.
242 :type var_accesses: \
243 :py:class:`psyclone.core.VariablesAccessInfo`
246 super().
scalar(scalar_arg, var_accesses)
247 if scalar_arg.is_literal:
248 self.
psyir_appendpsyir_append(scalar_arg.psyir_expression())
250 sym = self.
_symtab_symtab.lookup(scalar_arg.name)
262 def _mesh_ncell2d(self, var_accesses=None):
263 '''Add the number of columns in the mesh to the argument list and if
264 supplied stores this access in var_accesses.
266 :param var_accesses: optional VariablesAccessInfo instance to store \
267 the information about variable accesses.
268 :type var_accesses: \
269 :py:class:`psyclone.core.VariablesAccessInfo`
273 self.
appendappend(sym.name, var_accesses)
275 def _mesh_ncell2d_no_halos(self, var_accesses=None):
276 '''Add the number of columns in the mesh (excluding those in the halo)
277 to the argument list and store this access in var_accesses (if
280 :param var_accesses: optional VariablesAccessInfo instance to store \
281 the information about variable accesses.
282 :type var_accesses: \
283 :py:class:`psyclone.core.VariablesAccessInfo`
287 self.
appendappend(ncell_symbol.name, var_accesses)
290 '''Add the CMA operator and associated scalars to the argument
291 list and optionally add them to the variable access
294 :param arg: the CMA operator argument.
295 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
296 :param var_accesses: optional VariablesAccessInfo instance to store \
297 the information about variable accesses.
298 :type var_accesses: \
299 :py:class:`psyclone.core.VariablesAccessInfo`
302 components = [
"matrix"]
306 if arg.function_space_to.orig_name != (arg.function_space_from.
308 components += DynCMAOperators.cma_diff_fs_params
310 components += DynCMAOperators.cma_same_fs_params
313 suffix = const.ARG_TYPE_SUFFIX_MAPPING[
"gh_columnwise_operator"]
315 for component
in components:
318 if component ==
"matrix":
323 sym = self.
_symtab_symtab.lookup_with_tag(f
"{arg.name}:{suffix}")
324 self.
psyir_appendpsyir_append(ArrayReference.create(sym, [
":",
":",
":"]))
327 name = self.
_symtab_symtab.lookup_with_tag(
328 f
"{arg.name}:{component}:{suffix}").name
329 mode = AccessType.READ
331 name, tag=f
"{arg.name}:{component}:{suffix}")
333 self.
appendappend(sym.name, var_accesses, mode=mode,
334 metadata_posn=arg.metadata_index)
337 '''Add the field vector associated with the argument 'argvect' to the
338 argument list. If supplied it also stores these accesses to the
341 :param argvect: the field vector to add.
342 :type argvect: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
343 :param var_accesses: optional VariablesAccessInfo instance to store \
344 the information about variable accesses.
345 :type var_accesses: \
346 :py:class:`psyclone.core.VariablesAccessInfo`
350 argvect.argument_type]
354 for idx
in range(1, argvect.vector_size + 1):
355 cmpt_sym = self.
_symtab_symtab.lookup_with_tag(
356 f
"{argvect.name}_{idx}:{suffix}")
359 self.
appendappend(text, metadata_posn=argvect.metadata_index)
361 if var_accesses
is not None:
363 var_accesses.add_access(
Signature(argvect.name), argvect.access,
366 def field(self, arg, var_accesses=None):
367 '''Add the field array associated with the argument 'arg' to the
368 argument list. If supplied it also stores this access in var_accesses.
370 :param arg: the field to be added.
371 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
372 :param var_accesses: optional VariablesAccessInfo instance to store
373 the information about variable accesses.
374 :type var_accesses: :py:class:`psyclone.core.VariablesAccessInfo`
378 suffix = const.ARG_TYPE_SUFFIX_MAPPING[arg.argument_type]
381 sym = self.
_symtab_symtab.lookup_with_tag(f
"{arg.name}:{suffix}")
383 self.
appendappend(sym.name, var_accesses, var_access_name=sym.name,
384 mode=arg.access, metadata_posn=arg.metadata_index)
389 '''Add stencil information to the argument list associated with the
390 argument 'arg' if the extent is unknown. If supplied it also stores
391 this access in var_accesses.
393 :param arg: the kernel argument with which the stencil is associated.
394 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
395 :param var_accesses: optional VariablesAccessInfo instance to store \
396 the information about variable accesses.
397 :type var_accesses: \
398 :py:class:`psyclone.core.VariablesAccessInfo`
405 var_sym = LFRicStencils.dofmap_size_symbol(self.
_symtab_symtab, arg)
406 cell_name, cell_ref = self.
cell_ref_namecell_ref_name(var_accesses)
408 ScalarType.Intrinsic.INTEGER,
410 self.
appendappend(f
"{var_sym.name}({cell_name})", var_accesses,
411 var_access_name=var_sym.name)
414 '''Add 2D stencil information to the argument list associated with the
415 argument 'arg' if the extent is unknown. If supplied it also stores
416 this access in var_accesses.
418 :param arg: the kernel argument with which the stencil is associated.
419 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
420 :param var_accesses: optional VariablesAccessInfo instance to store \
421 the information about variable accesses.
422 :type var_accesses: \
423 :py:class:`psyclone.core.VariablesAccessInfo`
430 var_sym = LFRicStencils.dofmap_size_symbol(self.
_symtab_symtab, arg)
431 cell_name, cell_ref = self.
cell_ref_namecell_ref_name(var_accesses)
433 ScalarType.Intrinsic.INTEGER,
435 name = f
"{var_sym.name}(:,{cell_name})"
436 self.
appendappend(name, var_accesses, var_access_name=var_sym.name)
439 '''Add the maximum branch extent for a 2D stencil associated with the
440 argument 'arg' to the argument list. If supplied it also stores this
443 :param arg: the kernel argument with which the stencil is associated.
444 :type arg: :py:class:`pclone.dynamo0p3.DynKernelArgument`
445 :param var_accesses: optional SingleVariableAccessInfo instance \
446 to store the information about variable accesses.
447 :type var_accesses: \
448 :py:class:`psyclone.core.SingleVariableAccessInfo`
458 unique_tag = LFRicStencils.stencil_unique_str(arg,
"length")
459 root_name = arg.name +
"_max_branch_length"
462 self.
appendappend(sym.name, var_accesses)
465 '''Add stencil information to the argument list associated with the
466 argument 'arg' if the direction is unknown (i.e. it's being supplied
467 in a variable). If supplied it also stores this access in
470 :param arg: the kernel argument with which the stencil is associated.
471 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
472 :param var_accesses: optional VariablesAccessInfo instance to store \
473 the information about variable accesses.
474 :type var_accesses: \
475 :py:class:`psyclone.core.VariablesAccessInfo`
479 name = arg.stencil.direction_arg.varname
480 tag = arg.stencil.direction_arg.text
482 self.
appendappend(name, var_accesses)
485 '''Add general stencil information associated with the argument 'arg'
486 to the argument list. If supplied it also stores this access in
489 :param arg: the meta-data description of the kernel \
490 argument with which the stencil is associated.
491 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
492 :param var_accesses: optional VariablesAccessInfo instance to store \
493 the information about variable accesses.
494 :type var_accesses: \
495 :py:class:`psyclone.core.VariablesAccessInfo`
502 var_sym = LFRicStencils.dofmap_symbol(self.
_symtab_symtab, arg)
503 cell_name, cell_ref = self.
cell_ref_namecell_ref_name(var_accesses)
505 ScalarType.Intrinsic.INTEGER,
507 self.
appendappend(f
"{var_sym.name}(:,:,{cell_name})", var_accesses,
508 var_access_name=var_sym.name)
511 '''Add general 2D stencil information associated with the argument
512 'arg' to the argument list. If supplied it also stores this access in
515 :param arg: the meta-data description of the kernel \
516 argument with which the stencil is associated.
517 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
518 :param var_accesses: optional VariablesAccessInfo instance to store \
519 the information about variable accesses.
520 :type var_accesses: \
521 :py:class:`psyclone.core.VariablesAccessInfo`
534 var_sym = LFRicStencils.dofmap_symbol(self.
_symtab_symtab, arg)
535 cell_name, cell_ref = self.
cell_ref_namecell_ref_name(var_accesses)
537 [
":",
":",
":", cell_ref],
538 ScalarType.Intrinsic.INTEGER,
540 name = f
"{var_sym.name}(:,:,:,{cell_name})"
541 self.
appendappend(name, var_accesses, var_access_name=var_sym.name)
544 '''Add the operator arguments to the argument list. If supplied it
545 also stores this access in var_accesses.
547 :param arg: the meta-data description of the operator.
548 :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
549 :param var_accesses: optional VariablesAccessInfo instance to store \
550 the information about variable accesses.
551 :type var_accesses: \
552 :py:class:`psyclone.core.VariablesAccessInfo`
558 if arg.data_type ==
"r_solver_operator_type":
559 op_name =
"r_solver_operator"
560 elif arg.data_type ==
"r_tran_operator_type":
561 op_name =
"r_tran_operator"
565 operator = const.DATA_TYPE_MAP[op_name]
567 operator[
"module"], operator[
"proxy_type"], [
"ncell_3d"],
568 arg.proxy_name_indexed,
569 overwrite_datatype=
LFRicTypes(
"LFRicIntegerScalarDataType")())
570 self.
appendappend(arg.proxy_name_indexed +
"%ncell_3d", var_accesses,
571 mode=AccessType.READ)
573 sym = self.
_symtab_symtab.lookup_with_tag(
574 f
"{arg.name}:{const.ARG_TYPE_SUFFIX_MAPPING[arg.argument_type]}")
577 self.
appendappend(sym.name, var_accesses,
578 mode=arg.access, metadata_posn=arg.metadata_index)
581 '''Add function-space related arguments common to LMA operators and
582 fields. If supplied it also stores this access in var_accesses.
584 :param function_space: the function space for which the related \
585 arguments common to LMA operators and fields are added.
586 :type function_space: :py:class:`psyclone.domain.lfric.FunctionSpace`
587 :param var_accesses: optional VariablesAccessInfo instance to store \
588 the information about variable accesses.
589 :type var_accesses: \
590 :py:class:`psyclone.core.VariablesAccessInfo`
593 if self.
_kern_kern.iterates_over
not in [
"cell_column",
"domain"]:
595 super().
fs_common(function_space, var_accesses)
597 KernCallArgList.NdfInfo(position=self.
num_argsnum_args,
598 function_space=function_space.orig_name))
601 '''Add compulsory arguments associated with this function space to
602 the list. If supplied it also stores this access in var_accesses.
604 :param function_space: the function space for which the compulsory \
606 :type function_space: :py:class:`psyclone.domain.lfric.FunctionSpace`
607 :param var_accesses: optional VariablesAccessInfo instance to store \
608 the information about variable accesses.
609 :type var_accesses: \
610 :py:class:`psyclone.core.VariablesAccessInfo`
614 self.
appendappend(sym.name, var_accesses)
616 map_name = function_space.map_name
617 if self.
_kern_kern.iterates_over ==
'domain':
621 ScalarType.Intrinsic.INTEGER)
622 self.
appendappend(sym.name, var_accesses, var_access_name=sym.name)
625 cell_name, cell_ref = self.
cell_ref_namecell_ref_name(var_accesses)
627 ScalarType.Intrinsic.INTEGER)
628 self.
appendappend(f
"{sym.name}(:,{cell_name})",
629 var_accesses, var_access_name=sym.name)
632 '''Add function-space related arguments for an intergrid kernel.
633 If supplied it also stores this access in var_accesses.
635 :param function_space: the function space for which to add arguments
636 :type function_space: :py:class:`psyclone.domain.lfric.FunctionSpace`
637 :param var_accesses: optional VariablesAccessInfo instance to store \
638 the information about variable accesses.
639 :type var_accesses: \
640 :py:class:`psyclone.core.VariablesAccessInfo`
645 arg = self.
_kern_kern.arguments.get_arg_on_space(function_space)
646 if arg.mesh ==
"gh_fine":
651 self.
appendappend(sym.name, var_accesses)
652 map_name = function_space.map_name
654 ScalarType.Intrinsic.INTEGER)
655 self.
appendappend(sym.name, var_accesses)
660 var_accesses=var_accesses)
662 def basis(self, function_space, var_accesses=None):
663 '''Add basis function information for this function space to the
664 argument list and optionally to the variable access information.
666 :param function_space: the function space for which the basis \
667 function is required.
668 :type function_space: :py:class:`psyclone.domain.lfric.FunctionSpace`
669 :param var_accesses: optional VariablesAccessInfo instance to store \
670 the information about variable accesses.
671 :type var_accesses: \
672 :py:class:`psyclone.core.VariablesAccessInfo`
675 for rule
in self.
_kern_kern.qr_rules.values():
676 basis_name = function_space.get_basis_name(qr_var=rule.psy_name)
678 ScalarType.Intrinsic.REAL)
679 self.
appendappend(sym.name, var_accesses)
681 if "gh_evaluator" in self.
_kern_kern.eval_shapes:
684 for fs_name
in self.
_kern_kern.eval_targets:
688 fspace = self.
_kern_kern.eval_targets[fs_name][0]
689 basis_name = function_space.get_basis_name(on_space=fspace)
691 ScalarType.Intrinsic.REAL)
692 self.
appendappend(sym.name, var_accesses)
695 '''Add differential basis information for the function space to the
696 argument list. If supplied it also stores this access in
699 :param function_space: the function space for which the differential \
700 basis functions are required.
701 :type function_space: :py:class:`psyclone.domain.lfric.FunctionSpace`
702 :param var_accesses: optional VariablesAccessInfo instance to store \
703 the information about variable accesses.
704 :type var_accesses: \
705 :py:class:`psyclone.core.VariablesAccessInfo`
708 for rule
in self.
_kern_kern.qr_rules.values():
709 diff_basis_name = function_space.get_diff_basis_name(
710 qr_var=rule.psy_name)
712 [
":",
":",
":",
":"],
713 ScalarType.Intrinsic.REAL)
714 self.
appendappend(sym.name, var_accesses)
716 if "gh_evaluator" in self.
_kern_kern.eval_shapes:
719 for fs_name
in self.
_kern_kern.eval_targets:
723 fspace = self.
_kern_kern.eval_targets[fs_name][0]
724 diff_basis_name = function_space.get_diff_basis_name(
728 ScalarType.Intrinsic.REAL)
729 self.
appendappend(sym.name, var_accesses)
732 '''Implement the boundary_dofs array fix for a field. If supplied it
733 also stores this access in var_accesses.
735 :param function_space: the function space for which boundary dofs \
737 :type function_space: :py:class:`psyclone.domain.lfric.FunctionSpace`
738 :param var_accesses: optional VariablesAccessInfo instance to store \
739 the information about variable accesses.
740 :type var_accesses: \
741 :py:class:`psyclone.core.VariablesAccessInfo`
743 :raises GenerationError: if the bcs kernel does not contain \
744 a field as argument (but e.g. an operator).
748 for fspace
in self.
_kern_kern.arguments.unique_fss:
749 if fspace.orig_name ==
"any_space_1":
751 farg = self.
_kern_kern.arguments.get_arg_on_space(fspace)
754 if not farg.is_field:
757 f
"Expected an argument of {const.VALID_FIELD_NAMES} type "
758 f
"from which to look-up boundary dofs for kernel "
759 f
"{self._kern.name} but got '{farg.argument_type}'")
761 base_name =
"boundary_dofs_" + farg.name
763 ScalarType.Intrinsic.INTEGER)
764 self.
appendappend(sym.name, var_accesses)
767 '''Supply necessary additional arguments for the kernel that
768 applies boundary conditions to a LMA operator. If supplied it
769 also stores this access in var_accesses.
771 :param function_space: unused, only for consistency with base class.
772 :type function_space: :py:class:`psyclone.dynamo3.FunctionSpace`
773 :param var_accesses: optional VariablesAccessInfo instance to store \
774 the information about variable accesses.
775 :type var_accesses: \
776 :py:class:`psyclone.core.VariablesAccessInfo`
781 op_arg = self.
_kern_kern.arguments.args[0]
782 base_name =
"boundary_dofs_" + op_arg.name
784 ScalarType.Intrinsic.INTEGER)
785 self.
appendappend(sym.name, var_accesses)
788 '''Provide the kernel arguments required for the mesh properties
789 specified in the kernel metadata. If supplied it also stores this
790 access in var_accesses.
792 :param var_accesses: optional VariablesAccessInfo instance to store \
793 the information about variable accesses.
794 :type var_accesses: \
795 :py:class:`psyclone.core.VariablesAccessInfo`
798 if self.
_kern_kern.mesh.properties:
802 self.
extendextend(LFRicMeshProperties(self.
_kern_kern).
803 kern_args(stub=
False, var_accesses=var_accesses,
804 kern_call_arg_list=self))
807 '''Add quadrature-related information to the kernel argument list.
808 Adds the necessary arguments to the argument list, and optionally
809 adds variable access information to the var_accesses object.
811 :param var_accesses: optional VariablesAccessInfo instance to store \
812 the information about variable accesses.
813 :type var_accesses: \
814 :py:class:`psyclone.core.VariablesAccessInfo`
818 supported_qr_shapes = [
"gh_quadrature_xyoz",
"gh_quadrature_edge",
819 "gh_quadrature_face"]
821 for shape, rule
in self.
_kern_kern.qr_rules.items():
822 if shape ==
"gh_quadrature_xyoz":
826 {
"horizontal": self.
num_argsnum_args + 1,
827 "vertical": self.
num_argsnum_args + 2})
828 self.
extendextend(rule.kernel_args, var_accesses)
829 elif shape ==
"gh_quadrature_edge":
832 self.
extendextend(rule.kernel_args, var_accesses)
833 elif shape ==
"gh_quadrature_face":
836 self.
extendextend(rule.kernel_args, var_accesses)
838 raise NotImplementedError(
839 f
"quad_rule: no support implemented for quadrature with a "
840 f
"shape of '{shape}'. Supported shapes are: "
841 f
"{supported_qr_shapes}.")
843 for arg
in rule.kernel_args:
848 generic_name = arg[:-len(rule.psy_name)-1]
849 if generic_name
in [
"np_xy",
"np_z",
"nfaces",
"np_xyz",
853 elif generic_name
in [
"weights_xy",
"weights_z"]:
857 ScalarType.Intrinsic.REAL)
858 elif generic_name
in [
"weights_xyz"]:
862 ScalarType.Intrinsic.REAL)
869 ''':returns: the position(s) in the argument list of the \
870 variable(s) that passes the number of layers. The generate \
871 method must be called first.
874 :raises InternalError: if the generate() method has not been called.
879 "KernCallArgList: the generate() method should be called "
880 "before the nlayers_positions() method")
885 ''':return: the positions in the argument list of the variables that \
886 pass the number of quadrature points. The number and type of \
887 these will change depending on the type of quadrature. A list \
888 of dictionaries is returned with the quadrature types \
889 being the keys to the dictionaries and their position in the \
890 argument list being the values. At the moment only XYoZ is \
891 supported (which has horizontal and vertical quadrature \
892 points). The generate method must be called first.
893 :rtype: [{str: int, ...}]
895 :raises InternalError: if the generate() method has not been \
901 "KernCallArgList: the generate() method should be called "
902 "before the nqp_positions() method")
907 ''':return: the position(s) in the argument list and the function \
908 space(s) associated with the variable(s) that pass(es) the \
909 number of degrees of freedom for the function space. The \
910 generate method must be called first.
911 :rtype: list of namedtuple (position=int, function_space=str).
913 :raises InternalError: if the generate() method has not been \
919 "KernCallArgList: the generate() method should be called "
920 "before the ndf_positions() method")
924 '''Utility routine which determines whether to return the cell value
925 or the colourmap lookup value. If supplied it also stores this access
928 :param var_accesses: optional VariablesAccessInfo instance to store \
929 the information about variable accesses.
930 :type var_accesses: \
931 :py:class:`psyclone.core.VariablesAccessInfo`
933 :returns: the Fortran code needed to access the current cell index.
934 :rtype: Tuple[str, py:class:`psyclone.psyir.nodes.Reference`]
937 cell_sym = self.
_symtab_symtab.find_or_create_integer_symbol(
938 "cell", tag=
"cell_loop_idx")
939 if self.
_kern_kern.is_coloured():
940 colour_sym = self.
_symtab_symtab.find_or_create_integer_symbol(
941 "colour", tag=
"colours_loop_idx")
942 if self.
_kern_kern.is_intergrid:
949 [Reference(colour_sym),
950 Reference(cell_sym)],
951 ScalarType.Intrinsic.INTEGER,
953 if var_accesses
is not None:
954 var_accesses.add_access(
Signature(colour_sym.name),
955 AccessType.READ, self.
_kern_kern)
956 var_accesses.add_access(
Signature(cell_sym.name),
957 AccessType.READ, self.
_kern_kern)
958 var_accesses.add_access(
Signature(array_ref.name),
960 self.
_kern_kern, [
"colour",
"cell"])
962 return (self.
_kern_kern.colourmap +
"(colour,cell)",
965 if var_accesses
is not None:
966 var_accesses.add_access(
Signature(
"cell"), AccessType.READ,
969 return (cell_sym.name, Reference(cell_sym))
974 __all__ = [
"KernCallArgList"]
def append_array_reference(self, array_name, indices, intrinsic_type, tag=None, symbol=None)
def append(self, var_name, var_accesses=None, var_access_name=None, mode=AccessType.READ, metadata_posn=None)
def psyir_append(self, node)
def fs_common(self, function_space, var_accesses=None)
def fs_compulsory_field(self, function_space, var_accesses=None)
def append_integer_reference(self, name, tag=None)
def extend(self, list_var_name, var_accesses=None, mode=AccessType.READ, list_metadata_posn=None)
def get_array_reference(self, array_name, indices, intrinsic_type, tag=None, symbol=None)
def field(self, arg, var_accesses=None)
def field_bcs_kernel(self, function_space, var_accesses=None)
def stencil_unknown_direction(self, arg, var_accesses=None)
def get_user_type(self, module_name, user_type, name, tag=None)
def stencil_2d_unknown_extent(self, arg, var_accesses=None)
def scalar(self, scalar_arg, var_accesses=None)
def quad_rule(self, var_accesses=None)
def cell_map(self, var_accesses=None)
def cell_ref_name(self, var_accesses=None)
def stencil_unknown_extent(self, arg, var_accesses=None)
def field_vector(self, argvect, var_accesses=None)
def fs_common(self, function_space, var_accesses=None)
def operator_bcs_kernel(self, function_space, var_accesses=None)
def mesh_properties(self, var_accesses=None)
def append_structure_reference(self, module_name, user_type, member_list, name, tag=None, overwrite_datatype=None)
def stencil(self, arg, var_accesses=None)
def basis(self, function_space, var_accesses=None)
def stencil_2d_max_extent(self, arg, var_accesses=None)
def diff_basis(self, function_space, var_accesses=None)
def fs_intergrid(self, function_space, var_accesses=None)
def cma_operator(self, arg, var_accesses=None)
def mesh_height(self, var_accesses=None)
def operator(self, arg, var_accesses=None)
def stencil_2d(self, arg, var_accesses=None)
def nlayers_positions(self)
def fs_compulsory_field(self, function_space, var_accesses=None)
def cell_position(self, var_accesses=None)