psyclone.psyad.domain.common.adjoint_utils

Provides various utilities in support of the PSyAD adjoint functionality.

Functions

psyclone.psyad.domain.common.adjoint_utils.create_adjoint_name(tl_name, table=None)

Create an adjoint name from the supplied tangent linear name. This is done by stripping the TL_NAME_PREFIX from the name if it exists and then adding the ADJOINT_NAME_PREFIX. The adjoint name is also lower-cased. If a symbol table is supplied, then this routine also ensures that the new name is not present in that table.

Parameters:
Returns:

the adjoint name.

Return type:

str

psyclone.psyad.domain.common.adjoint_utils.create_real_comparison(sym_table, kernel, var1, var2)

Creates PSyIR that checks the values held by Symbols var1 and var2 for equality, allowing for machine precision and writes the success or failure of the checks to stdout.

Parameters:
Returns:

the PSyIR nodes that perform the check and write its success or failure to stdout.

Return type:

List[psyclone.psyir.nodes.Node]

psyclone.psyad.domain.common.adjoint_utils._common_write(sym_table, kernel, var1, var2)

Creates PSyIR that writes whether the precision test passed or failed to stdout.

Parameters:
Returns:

PSyIR nodes that write out test success or failure to stdout.

Return type:

List[psyclone.psyir.nodes.Node]

psyclone.psyad.domain.common.adjoint_utils.find_container(psyir)

Finds the first Container in the supplied PSyIR that is not a FileContainer. Also validates that the PSyIR contains at most one FileContainer which, if present, contains a Container.

Parameters:

psyir (psyclone.psyir.nodes.Node) – the PSyIR to search for a Container.

Returns:

the first Container that is not a FileContainer or None if there is none.

Return type:

psyclone.psyir.nodes.Container or NoneType

Raises:
  • InternalError – if there are two Containers and the second is a FileContainer.

  • NotImplementedError – if there are two Containers and the first is not a FileContainer.

  • NotImplementedError – if there are more than two Containers.