# loki.transformations.parallel.openmp_region

Sub-package with utilities to remove and manipulate parallel OpenMP regions.

Functions

`add_firstprivate_copies`(routine, fprivate_map) | Injects IFS-specific thread-local copies of named complex derived type objects in parallel regions.
`add_openmp_regions`(routine, dimension[, ...]) | Add the OpenMP directives for a parallel driver region with an outer block loop.
`remove_firstprivate_copies`(region, ...) | Removes an IFS-specific workaround, where complex derived-type objects are explicitly copied into a local copy of the object to avoid erroneous firstprivatisation in OpenMP loops.
`remove_openmp_regions`(routine[, ...]) | Remove any OpenMP parallel annotations (`!$omp parallel`).

remove_openmp_regions(routine, insert_loki_parallel=False)

  Remove any OpenMP parallel annotations (`!$omp parallel`).

  Optionally, this can replace `!$omp parallel` with `!$loki parallel` pragmas.

  Parameters:

    - routine (`Subroutine`) – The routine from which to strip all OpenMP annotations.

    - insert_loki_parallel (bool) – Flag for the optional insertion of ``!$loki parallel` pragmas

add_openmp_regions(routine, dimension, shared_variables=None, field_group_types=None)

  Add the OpenMP directives for a parallel driver region with an outer block loop.

  Parameters:

    - routine (`Subroutine`) – The routine to which to add OpenMP parallel regions.

    - dimension (`Dimension`) – The dimension object describing the block loop variables.

    - shared_variables (tuple of str) – Names of variables that should neither be private nor firstprivate

    - field_group_types (tuple of str) – Names of types designating “field groups”, which should be treated as firstprivate

remove_firstprivate_copies(region, fprivate_map, scope)

  Removes an IFS-specific workaround, where complex derived-type objects are explicitly copied into a local copy of the object to avoid erroneous firstprivatisation in OpenMP loops.

  Parameters:

    - region (tuple of `Node`) – The code region from which to remove firstprivate copies

    - fprivate_map (dict of (str, str)) – String mapping of local-to-global names for explicitly privatised objects

    - scope (`Scope`) – Scope to use for symbol susbtitution

add_firstprivate_copies(routine, fprivate_map)

  Injects IFS-specific thread-local copies of named complex derived type objects in parallel regions. This is to prevent issues with firstprivate variables in OpenMP loops.

  Parameters:

    - routine (`Subroutine`) – Subroutine in which to insert privatisation copies

    - fprivate_map (dict of (str, str)) – String mapping of local-to-global names for explicitly privatised objects