Skip to content

Commit

Permalink
#2725 Prevent Hoisting Arrays in NEMO subroutines with statement func…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
sergisiso committed Oct 2, 2024
1 parent f663f16 commit fb6a787
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/nemo/scripts/acc_kernels_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"bdytide_init", "bdy_init", "bdy_segs", "sbc_cpl_init",
"asm_inc_init", "dia_obs_init"] # Str handling, init routine


class ExcludeSettings():
'''
Class to hold settings on what to exclude from OpenACC KERNELS regions.
Expand Down
10 changes: 7 additions & 3 deletions examples/nemo/scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
"glob_sum_full", "ptr_sj", "ptr_sjk", "interp1", "interp2",
"interp3", "integ_spline"]

# Currently fparser has no way of distinguishing array accesses from statement
# functions, the following subroutines contains known statement functions
CONTAINS_STMT_FUNCTIONS = ["sbc_dcy"]

VERBOSE = False

Expand Down Expand Up @@ -233,9 +236,10 @@ def normalise_loops(
statements out of the loop nest.
'''

# TODO #1902: NEMO4 mpi_ini.f90 has a HoistLocalArraysTrans bug
if hoist_local_arrays and schedule.root.name != "mpp_ini.f90":
# Apply the HoistLocalArraysTrans when possible
if hoist_local_arrays and schedule.name not in CONTAINS_STMT_FUNCTIONS:
# Apply the HoistLocalArraysTrans when possible, it cannot be applied
# to files with statement functions because it will attempt to put the
# allocate avobe it, which is not valid Fortran.
try:
HoistLocalArraysTrans().apply(schedule)
except TransformationError:
Expand Down

0 comments on commit fb6a787

Please sign in to comment.