From efea62feb259c7c32e017720166b3ad6cf4522ed Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 14 Nov 2024 05:05:10 +0000 Subject: [PATCH] Parallel: Rename to `add/remove_firstprivate_copies` This is to shorten the method names and bring them in line with the naming convention of the sub-package. --- loki/transformations/parallel/openmp_region.py | 7 +++---- .../parallel/tests/test_openmp_region.py | 15 +++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/loki/transformations/parallel/openmp_region.py b/loki/transformations/parallel/openmp_region.py index 4233b096e..d3a50f996 100644 --- a/loki/transformations/parallel/openmp_region.py +++ b/loki/transformations/parallel/openmp_region.py @@ -22,8 +22,7 @@ __all__ = [ 'remove_openmp_regions', 'add_openmp_regions', - 'remove_explicit_firstprivatisation', - 'create_explicit_firstprivatisation' + 'remove_firstprivate_copies', 'add_firstprivate_copies' ] @@ -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 @@ -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 diff --git a/loki/transformations/parallel/tests/test_openmp_region.py b/loki/transformations/parallel/tests/test_openmp_region.py index ede1490e9..e9a05705b 100644 --- a/loki/transformations/parallel/tests/test_openmp_region.py +++ b/loki/transformations/parallel/tests/test_openmp_region.py @@ -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 ) @@ -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) @@ -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 ) @@ -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 = """ @@ -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 )