Skip to content

Commit

Permalink
Parallel: Rename to add/remove_firstprivate_copies
Browse files Browse the repository at this point in the history
This is to shorten the method names and bring them in line with the
naming convention of the sub-package.
  • Loading branch information
mlange05 committed Nov 14, 2024
1 parent a3b85d2 commit efea62f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
7 changes: 3 additions & 4 deletions loki/transformations/parallel/openmp_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

__all__ = [
'remove_openmp_regions', 'add_openmp_regions',
'remove_explicit_firstprivatisation',
'create_explicit_firstprivatisation'
'remove_firstprivate_copies', 'add_firstprivate_copies'
]


Expand Down Expand Up @@ -195,7 +194,7 @@ def add_openmp_regions(
)


def remove_explicit_firstprivatisation(region, fprivate_map, scope):
def 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
Expand Down Expand Up @@ -231,7 +230,7 @@ def visit_Assignment(self, assign, **kwargs): # pylint: disable=unused-argument
return SubstituteStringExpressions(fprivate_map, scope=scope).visit(region)


def create_explicit_firstprivatisation(routine, fprivate_map):
def 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
Expand Down
15 changes: 7 additions & 8 deletions loki/transformations/parallel/tests/test_openmp_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

from loki.transformations.parallel import (
remove_openmp_regions, add_openmp_regions,
remove_explicit_firstprivatisation,
create_explicit_firstprivatisation
remove_firstprivate_copies, add_firstprivate_copies
)


Expand Down Expand Up @@ -195,9 +194,9 @@ def test_add_openmp_regions(tmp_path, frontend):
@pytest.mark.parametrize('frontend', available_frontends(
skip=[(OMNI, 'OMNI needs full type definitions for derived types')]
))
def test_remove_explicit_firstprivatisation(frontend):
def test_remove_firstprivate_copies(frontend):
"""
A simple test for :any:`remove_explicit_firstprivatisation`
A simple test for :any:`remove_firstprivate_copies`
"""
fcode = """
subroutine test_add_openmp_loop(ydgeom, state, arr)
Expand Down Expand Up @@ -243,7 +242,7 @@ def test_remove_explicit_firstprivatisation(frontend):
assert len(FindNodes(ir.Loop).visit(routine.body)) == 1

# Remove the explicit copy of `ydstate = state` and adjust symbols
routine.body = remove_explicit_firstprivatisation(
routine.body = remove_firstprivate_copies(
region=routine.body, fprivate_map=fprivate_map, scope=routine
)

Expand All @@ -263,9 +262,9 @@ def test_remove_explicit_firstprivatisation(frontend):
@pytest.mark.parametrize('frontend', available_frontends(
skip=[(OMNI, 'OMNI needs full type definitions for derived types')]
))
def test_create_explicit_firstprivatisation(tmp_path, frontend):
def test_add_firstprivate_copies(tmp_path, frontend):
"""
A simple test for :any:`create_explicit_firstprivatisation`
A simple test for :any:`add_firstprivate_copies`
"""

fcode = """
Expand Down Expand Up @@ -315,7 +314,7 @@ def test_create_explicit_firstprivatisation(tmp_path, frontend):
assert len(FindNodes(ir.Loop).visit(routine.body)) == 2

# Put the explicit firstprivate copies back in
create_explicit_firstprivatisation(
add_firstprivate_copies(
routine=routine, fprivate_map=fprivate_map
)

Expand Down

0 comments on commit efea62f

Please sign in to comment.