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

Transformations: SCCRawStackPipeline and SCC config-from-file #314

Merged
merged 8 commits into from
Jun 17, 2024

Conversation

mlange05
Copy link
Collaborator

@mlange05 mlange05 commented May 8, 2024

The main point of this PR is a re-base-and-replay of PR #201 by @rolfhm . It primarily rebases the main implementation of the TemporariesSCCRawStackTransformation over recent main and squashes the slightly convoluted commit history. I then added the necessary steps to integrate this with the recent addition of SCC "pipeline" classes and added a specific override that we need to integrate this with CLOUDSC regression testing. The latter is then implemented in the CLOUDSC companion PR (ecmwf-ifs/dwarf-p-cloudsc#86).

The small override option needed for CLOUDSC regression testing (driver_horizontal) comes from the horizontal variable name being different in the driver routine (NPROMA) to the kernel routines (KLON). As this new allocator does not remap the horizontal over the calls, I added a hard-override. The idea is to merge this now and then mop up the rest when we consolidate the loki.transformations.temporaries sub-package.

Due to the same reasoning this PR also does not change much in the implementation of the RawStackAllocator itself. The implementation is cleanly isolated and close the stack pool allocator, but there is some overlap where we could reduce redundancy by refactoring common sub-steps. However, I think this is beyond the scope of this PR.

And finally, @rolfhm could you please take a look and indicate here if you are happy with this and if this still works for you?

@mlange05 mlange05 requested a review from reuterbal May 8, 2024 15:24
Copy link

github-actions bot commented May 8, 2024

Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/314/index.html

@reuterbal reuterbal force-pushed the naml-sbrm-rawstack-transformation branch from 7009ea5 to 6fa205d Compare May 10, 2024 12:26
Copy link

codecov bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 99.43182% with 3 lines in your changes missing coverage. Please review.

Project coverage is 95.25%. Comparing base (5300280) to head (26bd8cd).
Report is 94 commits behind head on main.

Files Patch % Lines
loki/transformations/raw_stack_allocator.py 99.11% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #314      +/-   ##
==========================================
+ Coverage   95.11%   95.25%   +0.14%     
==========================================
  Files         165      170       +5     
  Lines       35065    36258    +1193     
==========================================
+ Hits        33351    34539    +1188     
- Misses       1714     1719       +5     
Flag Coverage Δ
lint_rules 96.39% <ø> (ø)
loki 95.23% <99.43%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

mlange05 added 3 commits May 10, 2024 15:11
The horizontal size does not get remapped via the call argument map.
When it has a different name in the driver, we get a wrong allocation,
so we add a manual ovefrride.
We're leaving the defaults in for the moment until the full hit comes.
@mlange05 mlange05 force-pushed the naml-sbrm-rawstack-transformation branch from 6fa205d to fd09b09 Compare May 10, 2024 15:11
Copy link
Collaborator

@reuterbal reuterbal left a comment

Choose a reason for hiding this comment

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

Many thanks for taking this over and apologies for the delay in reviewing. I've not gone in full detail through the transformation logic but the test seems reasonably comprehensive to bring this in. I've left a few comments where I noticed things that could be improved.


assignments = FindNodes(Assignment).visit(kernel3.body)

assert fgen(assignments[0].lhs).lower() == 'jd_zde1'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this really all be fgen(...).lower() == ...? Couldn't we use simple string-comparison for expressions here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The .rhs test with explicit kind-specifiers need the fgen, but otherwise this seems to work. Will do.

zde3 = pzz
zde3(1:nlon,1:klev) = pzz

!$acc iend data
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
!$acc iend data
!$acc end data

Comment on lines +239 to +244
basedir = gettempdir()/'test_pool_allocator_temporaries'
basedir.mkdir(exist_ok=True)
(basedir/'driver.F90').write_text(fcode_driver)
(basedir/'kernel1_mod.F90').write_text(fcode_kernel1)
(basedir/'kernel2_mod.F90').write_text(fcode_kernel2)
(basedir/'kernel3_mod.F90').write_text(fcode_kernel3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of gettempdir() it's better to use the tmp_dir fixture, which ensures clean-up at the end even in case of test failures, and saves the explicit rmtree.

else:
definitions = ()

scheduler = Scheduler(paths=[basedir], config=SchedulerConfig.from_dict(config), frontend=frontend,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should use xmods=[tmp_path] (if you're switching to that fixture) here. That ensures OMNI writes its xmod files to that tempdir path instead of the current working directory. That avoids littering the source tree and prevents name clashes with same program unit names in other tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As discussed offline: I tried, I failed, I'm giving up now. I vote we keep this for a separate "unfoo-OMNI" PR.

def __init__(
self, block_dim, horizontal, stack_name='STACK',
local_int_var_name_pattern='JD_{name}', directive=None,
key=None, driver_horizontal=None, **kwargs
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should likely drop the key argument here, as this can cause issues in pipelines, no?

The items corresponding to successor routines called from :data:`routine`
"""
successor_map = {
successor.ir.name.lower(): successor
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't that simply be

Suggested change
successor.ir.name.lower(): successor
successor.local_name: successor


Parameters
----------
routine : :any:'Subroutine
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
routine : :any:'Subroutine
routine : :any:`Subroutine`


Parameters
----------
routine : :any:'Subroutine
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
routine : :any:'Subroutine
routine : :any:`Subroutine`


Parameters
----------
routine : :any:'Subroutine
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
routine : :any:'Subroutine
routine : :any:`Subroutine`

@mlange05 mlange05 force-pushed the naml-sbrm-rawstack-transformation branch from e8da699 to 9ffaab9 Compare June 14, 2024 14:14
Copy link
Collaborator

@reuterbal reuterbal left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the comments. Pylint has found a new issue that's been overlooked and there's a few stray characters in the test, otherwise good to go!

@mlange05 mlange05 force-pushed the naml-sbrm-rawstack-transformation branch from b7314dd to b8dfc88 Compare June 14, 2024 15:10
@mlange05 mlange05 force-pushed the naml-sbrm-rawstack-transformation branch from b8dfc88 to 26bd8cd Compare June 17, 2024 12:22
@reuterbal reuterbal added the ready for merge This PR has been approved and is ready to be merged label Jun 17, 2024
@reuterbal reuterbal merged commit a39336b into main Jun 17, 2024
13 checks passed
@reuterbal reuterbal deleted the naml-sbrm-rawstack-transformation branch June 17, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for merge This PR has been approved and is ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants