Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(closes #1010, #1910, #719, #798, #1648) Generate PSy-layers and Kernel Subs using PSyIR lowering (instead of gen_code/f2pygen) #2834

Open
wants to merge 154 commits into
base: master
Choose a base branch
from

Conversation

sergisiso
Copy link
Collaborator

No description provided.

sergisiso added 30 commits April 9, 2024 13:47
…rsor on invokes declarations and initialisations
@sergisiso
Copy link
Collaborator Author

@TeranIvy @hiker I merged the latest changes to this branch (split elements order and partially written extraction field), and is now passing all our compilation and integration tests. It would be great if you could check it with the LFRic tests (@TeranIvy ) and additional extraction test (@hiker ) and let me know if there is any problem that was not reported by our CI.

  • I am aware of the colourmap symbol missing in the extraction, but let me know if anything else is missing

@sergisiso
Copy link
Collaborator Author

@arporter Addressed the comments and brought to master, this is ready for another review.

@TeranIvy Let us know if there is any problems with your MO LFRic tests

@TeranIvy
Copy link
Collaborator

@arporter Addressed the comments and brought to master, this is ready for another review.

@TeranIvy Let us know if there is any problems with your MO LFRic tests

Hi @sergisiso, I installed the PSyclone test environment from your branch and ran comprehensive Rose stem tests (--group=all). The outcome is below.

The failures in LFRic Atmosphere, Coupled and UM Physics Interface seem to be failures to find/create a symbol (error report below).

Error, unexpected exception, please report to the authors:
Traceback (most recent call last):
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 965, in lookup
    symbol = self.get_symbols(scope_limit)[self._normalize(name)]
KeyError: 'height_wth_max_branch_length'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 417, in find_or_create
    symbol = self.lookup(name)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 993, in lookup
    f"Table.") from err
KeyError: "Could not find 'height_wth_max_branch_length' in the Symbol Table."

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/backend/visitor.py", line 203, in __call__
    lowered_node = node_copy.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/nodes/node.py", line 1481, in lower_to_language_level
    child.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/nodes/node.py", line 1481, in lower_to_language_level
    child.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/domain/lfric/lfric_loop.py", line 182, in lower_to_language_level
    child.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyGen.py", line 1513, in lower_to_language_level
    call_node = Call.create(rsymbol, self.arguments.psyir_expressions())
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/dynamo0p3.py", line 5325, in psyir_expressions
    create_arg_list.generate()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/domain/lfric/arg_ordering.py", line 433, in generate
    arg, var_accesses=var_accesses)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/domain/lfric/kern_call_arg_list.py", line 506, in stencil_2d_max_extent
    sym = self.append_integer_reference(root_name, tag=unique_tag)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/domain/lfric/arg_ordering.py", line 207, in append_integer_reference
    datatype=LFRicTypes("LFRicIntegerScalarDataType")())
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 430, in find_or_create
    return self.new_symbol(name, **new_symbol_args)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 400, in new_symbol
    self.add(symbol, tag)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 580, in add
    f"This symbol table, or an outer scope ancestor symbol "
KeyError: "This symbol table, or an outer scope ancestor symbol table, already contains the tag 'lengthwthetacross2dsten_size' for the symbol 'exner_wth_max_branch_length', so it can not be associated with symbol 'height_wth_max_branch_length'."

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/generator.py", line 583, in main
    kern_naming=args.kernel_renaming)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/generator.py", line 403, in generate
    return alg_gen, psy.gen
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyGen.py", line 294, in gen
    result = fortran_writer(new_container)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/backend/visitor.py", line 209, in __call__
    ) from err
psyclone.psyir.backend.visitor.VisitorError: Visitor Error: Failed to lower 'Container[pmsl_alg_mod_psy]

Failure in NG Arch job is similar to the above ones (same variable not in symbol table but manifests in another algorithm call, see below.

psyclone.psyir.backend.visitor.VisitorError: Visitor Error: Failed to lower 'Container[pmsl_alg_mod_psy]

The failures in LFRic JEDI and Adjoint tests builds return a different error which is not so obvious to debug.

make[3]: *** [cylc-run/r7568_split_element_patches/run2/share/source/apps/science/adjoint/build/post_patch.mk:126: /var/spool/jtmp/9533117.xcf00.e7RwQY/intel_fast-debug-64bit/r7568_split_element_patches/run2/jedi_lfric_tests/integration-tests/integration-tests/algorithm/core_dynamics/atlt_sample_eos_pressure_alg_mod.X90] Error 1
make[2]: *** [cylc-run/r7568_split_element_patches/run2/share/source/apps/science/adjoint/build/import.mk:15: import-adjoint] Error 2
make[1]: *** [cylc-run/r7568_split_element_patches/run2/share/source/core/infrastructure/build/lfric.mk:266: cylc-run/r7568_split_element_patches/run2/share/source/apps/science/adjoint/import] Error 2
make[1]: *** Waiting for unfinished jobs....

GungHo model failure is due to declarations of unused variables (seems to be MO issue).

algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:191:38:

  191 |     integer(kind=i_def) :: loop1_start
      |                                      1
Error: Unused variable 'loop1_start' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:192:37:

  192 |     integer(kind=i_def) :: loop1_stop
      |                                     1
Error: Unused variable 'loop1_stop' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:193:38:

  193 |     integer(kind=i_def) :: loop2_start
      |                                      1
Error: Unused variable 'loop2_start' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:194:37:

  194 |     integer(kind=i_def) :: loop2_stop
      |                                     1
Error: Unused variable 'loop2_stop' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:195:38:

  195 |     integer(kind=i_def) :: loop3_start
      |                                      1
Error: Unused variable 'loop3_start' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:196:37:

  196 |     integer(kind=i_def) :: loop3_stop
      |                                     1
Error: Unused variable 'loop3_stop' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:128:38:

  128 |     integer(kind=i_def) :: loop1_start
      |                                      1
Error: Unused variable 'loop1_start' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:129:37:

  129 |     integer(kind=i_def) :: loop1_stop
      |                                     1
Error: Unused variable 'loop1_stop' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:130:38:

  130 |     integer(kind=i_def) :: loop2_start
      |                                      1
Error: Unused variable 'loop2_start' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:131:37:

  131 |     integer(kind=i_def) :: loop2_stop
      |                                     1
Error: Unused variable 'loop2_stop' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:27:38:

   27 |     integer(kind=i_def) :: loop1_start
      |                                      1
Error: Unused variable 'loop1_start' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:28:37:

   28 |     integer(kind=i_def) :: loop1_stop
      |                                     1
Error: Unused variable 'loop1_stop' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:29:38:

   29 |     integer(kind=i_def) :: loop2_start
      |                                      1
Error: Unused variable 'loop2_start' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:30:37:

   30 |     integer(kind=i_def) :: loop2_stop
      |                                     1
Error: Unused variable 'loop2_stop' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:31:38:

   31 |     integer(kind=i_def) :: loop3_start
      |                                      1
Error: Unused variable 'loop3_start' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:32:37:

   32 |     integer(kind=i_def) :: loop3_stop
      |                                     1
Error: Unused variable 'loop3_stop' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:33:38:

   33 |     integer(kind=i_def) :: loop4_start
      |                                      1
Error: Unused variable 'loop4_start' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:34:37:

   34 |     integer(kind=i_def) :: loop4_stop
      |                                     1
Error: Unused variable 'loop4_stop' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:35:38:

   35 |     integer(kind=i_def) :: loop5_start
      |                                      1
Error: Unused variable 'loop5_start' declared at (1) [-Werror=unused-variable]
algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90:36:37:

   36 |     integer(kind=i_def) :: loop5_stop
      |                                     1
Error: Unused variable 'loop5_stop' declared at (1) [-Werror=unused-variable]
Compiled algorithm/transport/control/gungho_transport_control_alg_mod_psy.f90: Wallclock=0:00.96, Highwater=72844KiB
f951: some warnings being treated as errors
Compiled algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.f90: Wallclock=0:00.50, Highwater=42976KiB
make[1]: *** [algorithm/transport/ffsl/ffsl_advective_updates_alg_mod_psy.o] Error 1
make[1]: *** Waiting for unfinished jobs....
Compiled algorithm/transport/common/flux_precomputations_mod_psy.f90: Wallclock=0:03.58, Highwater=211560KiB
Compiled algorithm/runtime_constants/transport_constants_mod_psy.f90: Wallclock=0:04.67, Highwater=157252KiB
Compiled algorithm/transport/ffsl/ffsl_vert_alg_mod_psy.f90: Wallclock=0:00.78, Highwater=72044KiB
Compiled algorithm/transport/common/end_of_transport_step_alg_mod_psy.f90: Wallclock=0:02.47, Highwater=179656KiB
Compiled algorithm/transport/ffsl/ffsl_hori_alg_mod_psy.f90: Wallclock=0:03.36, Highwater=204804KiB
make: *** [build] Error 2

@sergisiso
Copy link
Collaborator Author

The issue with gungho is that lfric_apps uses a different script just for algorithm/transport/ffsl/ffsl_advective_updates_alg_mod.py
https://code.metoffice.gov.uk/trac/lfric_apps/browser/main/trunk/applications/gungho_model/optimisation/meto-xc40/algorithm/transport/ffsl/ffsl_advective_updates_alg_mod.py?rev=7786 this script fuses loops and leaves leftover PSyIR symbols that are not used anymore. I will update the fusetrans to clean up those symbols.

@TeranIvy
Copy link
Collaborator

TeranIvy commented Feb 26, 2025

Retested LFRic Core and Apps with PSyclone test environments. This time I created branches for testing, and merged Josh's changes for move to PSyclone 3.1.0 to the Apps branch to prevent PSyAD failures. The branches are below (up to the respective trunks this morning).

Core tests are all fine. However, there are still failures in Apps tests. Some ngarch, lfric_atm, lfric_coupled and um_physics tests fail with Symbol errors, e.g.

Traceback (most recent call last):
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 970, in lookup
    symbol = self.get_symbols(scope_limit)[self._normalize(name)]
KeyError: 'height_wth_max_branch_length'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 422, in find_or_create
    symbol = self.lookup(name)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 998, in lookup
    f"Table.") from err
KeyError: "Could not find 'height_wth_max_branch_length' in the Symbol Table."

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/backend/visitor.py", line 203, in __call__
    lowered_node = node_copy.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/nodes/node.py", line 1481, in lower_to_language_level
    child.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/nodes/node.py", line 1481, in lower_to_language_level
    child.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/nodes/omp_directives.py", line 1346, in lower_to_language_level
    child.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/nodes/node.py", line 1481, in lower_to_language_level
    child.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/nodes/omp_directives.py", line 1992, in lower_to_language_level
    return super().lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/nodes/node.py", line 1481, in lower_to_language_level
    child.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/nodes/node.py", line 1481, in lower_to_language_level
    child.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/domain/lfric/lfric_loop.py", line 182, in lower_to_language_level
    child.lower_to_language_level()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyGen.py", line 1513, in lower_to_language_level
    call_node = Call.create(rsymbol, self.arguments.psyir_expressions())
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/dynamo0p3.py", line 5325, in psyir_expressions
    create_arg_list.generate()
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/domain/lfric/arg_ordering.py", line 441, in generate
    arg, var_accesses=var_accesses)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/domain/lfric/kern_call_arg_list.py", line 506, in stencil_2d_max_extent
    sym = self.append_integer_reference(root_name, tag=unique_tag)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/domain/lfric/arg_ordering.py", line 215, in append_integer_reference
    datatype=LFRicTypes("LFRicIntegerScalarDataType")())
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 435, in find_or_create
    return self.new_symbol(name, **new_symbol_args)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 405, in new_symbol
    self.add(symbol, tag)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/symbols/symbol_table.py", line 585, in add
    f"This symbol table, or an outer scope ancestor symbol "
KeyError: "This symbol table, or an outer scope ancestor symbol table, already contains the tag 'lengthwthetacross2dsten_size' for the symbol 'exner_wth_max_branch_length', so it can not be associated with symbol 'height_wth_max_branch_length'."

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/generator.py", line 583, in main
    kern_naming=args.kernel_renaming)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/generator.py", line 403, in generate
    return alg_gen, psy.gen
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyGen.py", line 294, in gen
    result = fortran_writer(new_container)
  File "/project/extrasoftware/packages.rhel7/psyclone/test/python/3.7.0/lib/python3.7/site-packages/psyclone/psyir/backend/visitor.py", line 209, in __call__
    ) from err
psyclone.psyir.backend.visitor.VisitorError: Visitor Error: Failed to lower 'Container[pmsl_alg_mod_psy]
'. Note that some nodes need to be lowered from an ancestor in order to properly apply their in-tree modifications. Original error was '"This symbol table, or an outer scope ancestor symbol table, already contains the tag 'lengthwthetacross2dsten_size' for the symbol 'exner_wth_max_branch_length', so it can not be associated with symbol 'height_wth_max_branch_length'."'.
make[1]: ***

JEDI and Adjoint tests throw errors that are not obvious but seem to go back to the certain algorithms:

make[2]: *** [cylc-run/r7723_TestPSyclone3.1.0/run4/share/source/apps/science/adjoint/build/post_patch.mk:126: /var/spool/jtmp/9750284.xcf00.bTmIfR/intel_full-debug-64bit/r7723_TestPSyclone3.1.0/run4/adjoint_tests/algorithm/transport/mol/atlt_poly1d_vert_adv_alg_mod.X90] Error 1

and

make[2]: *** [cylc-run/r7723_TestPSyclone3.1.0/run4/share/source/apps/science/adjoint/build/post_patch.mk:126: /var/spool/jtmp/9750287.xcf00.kel0oQ/intel_fast-debug-64bit/r7723_TestPSyclone3.1.0/run4/jedi_lfric_tests/jedi_lfric_tests/algorithm/transport/common/atlt_vorticity_advection_alg_mod.X90] Error 1

and

make[2]: *** [/var/tmp/ikavcic-3573222/gnu_fast-debug-64bit/r7723_TestPSyclone3.1.0/run4/adjoint_tests/algorithm/core_dynamics/atlt_sample_eos_pressure_alg_mod.X90] Error 1

Copy link
Member

@arporter arporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small things to tidy and we need to decide what we're going to do about the kernel extraction.

else:
# If it has a tag, first try to look up for it
try:
sym = self._symtab.lookup_with_tag("tag")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably you meant tag without the quotes? That might then fix the coverage issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, that's embarrassing, that also fixes the first issue reported by @TeranIvy

"call.*"
"end.*"
r"CALL (?P=profile2) % PostEnd")
code = fortran_writer(invoke.schedule)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment here needs updating now we don't remove all new lines or use a regex.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups deleted

# with '-Werror=unused-variable'
routine = node1.ancestor(Routine)
if routine:
remaining_syms = [r.symbol for r in routine.walk(Reference)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure whether it would be better here to use:

    vai = VariablesAccessInfo(routine)
    all_names = [sig.var_name for sig in vai.all_signatures]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am slightly nervous that Signatures still operate on strings and can't differentiate between symbols with the same name in different scopes, but I think is the right thing to do here, so I updated to it.

if routine:
remaining_syms = [r.symbol for r in routine.walk(Reference)]
del_syms = [r.symbol for r in node2.start_expr.walk(Reference) +
node2.stop_expr.walk(Reference)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, we should allow for step too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -198,6 +198,21 @@ def apply(self, node1, node2, options=None):
# Add loop contents of node2 to node1
node1.loop_body.children.extend(node2.loop_body.pop_all_children())

# We need to remove all leftover references because lfric is compiled
# with '-Werror=unused-variable'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add: ". Since we have fused loops, we only need to look at the symbols appearing in the loop control of the second loop."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -38,7 +38,8 @@
from psyclone.configuration import Config
from psyclone.psyir.nodes import (
OMPDoDirective, OMPLoopDirective, OMPParallelDoDirective,
OMPTeamsDistributeParallelDoDirective, OMPScheduleClause)
OMPTeamsLoopDirective, OMPTeamsDistributeParallelDoDirective,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted

"""diff_basis_w2_qr)
CALL extract_psy_data%PreDeclareVariable("e", e)
CALL extract_psy_data%PreDeclareVariable("istp", istp)
CALL extract_psy_data%PreDeclareVariable("last_edge_cell_all_colours", \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the minor matter that various LFRic rose-stem tests are failing, I think this is the last remaining thing to resolve. @hiker have you had time to see how much work it is likely to be?

@sergisiso
Copy link
Collaborator Author

@TeranIvy Can you try again. I have been able to run them locally and now this are fixed: "> Some ngarch, lfric_atm, lfric_coupled and um_physics tests fail with Symbol errors",

The adjoint and jedi failures are when applying lfric_apps/science/adjoint/build/post_patch.mk. The problem is that LFRic Apps has patches applied to psyclone output code, since the output style has changed, some of the patches in lfric_apps/science/adjoint/patches/* will need to be re-done.

@TeranIvy
Copy link
Collaborator

TeranIvy commented Feb 27, 2025

@TeranIvy Can you try again. I have been able to run them locally and now this are fixed: "> Some ngarch, lfric_atm, lfric_coupled and um_physics tests fail with Symbol errors",

The adjoint and jedi failures are when applying lfric_apps/science/adjoint/build/post_patch.mk. The problem is that LFRic Apps has patches applied to psyclone output code, since the output style has changed, some of the patches in lfric_apps/science/adjoint/patches/* will need to be re-done.

@sergisiso, thanks for fixig the issues! I retested both Core and Apps branches after bringing them up to heads of respective trunks.

  • Core is fine.
  • There are only Adjoint tests and JEDI-LFRic tests failures in Apps now, which as you said are probably due to different code generation style. (Another non-backward compatible release, methinks, but we don't need to worry about this now.)

I think this is fine from our side.

@sergisiso
Copy link
Collaborator Author

@arporter I addressed your latest comments, fixed the rose-stem test issues (I have all* lfric apps running locally now I will add these to the integration tests but in a different PR), brought to master and improved the coverage. This is ready for another review.

*all apps but the adjoint patches. @arporter @TeranIvy Relying on the exact output of psyclone will always be very brittle, I don't think we should be doing backwards-compatibility guarantees on this but the number of patches in that folder is big. I know there is a PSyAD issues github project, but do we know if there is a set of issues that cause the need for most of the patches?

@arporter
Copy link
Member

*all apps but the adjoint patches. @arporter @TeranIvy Relying on the exact output of psyclone will always be very brittle, I don't think we should be doing backwards-compatibility guarantees on this but the number of patches in that folder is big. I know there is a PSyAD issues github project, but do we know if there is a set of issues that cause the need for most of the patches?

This is a question for @DrTVockerodtMO really.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LFRic Issue relates to the LFRic domain ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants