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

Convert p3_init from f90 to CXX #6845

Merged
merged 5 commits into from
Jan 8, 2025
Merged

Convert p3_init from f90 to CXX #6845

merged 5 commits into from
Jan 8, 2025

Conversation

jgfouca
Copy link
Member

@jgfouca jgfouca commented Dec 11, 2024

This removes the last f90 from P3.

Change list:

  • Move table read/write implementation to CXX in p3_init_impl.hpp
  • p3_init now returns a P3LookupTables object with all the views inside containing the tables.
  • Rename init_kokkos_tables to get_global_tables
  • Rename init_kokkos_ice_lookup_tables to get_global_ice_lookup_tables
  • Remove all f90 bridge code
  • Move p3_tables_setup to tests dir, cleans up top p3 directory
  • Fix p3_tables_setup implementation; it got broken in recent PRs but we didn't notice because it didn't get built by default
  • Remove P3GlobalForFortran test struct, just call p3_init!
  • Remove P3InitAP3Data test struct

Debatable change:
I really wanted to have P3LookupTables lookup_tables be static in p3_init so they would not have to be re-created on every p3_init call. Unfortunately, Kokkos does not allow static views to be active on program shutdown, since this occurs after Kokkos::finalize, so we would need add a p3_finalize method and ensure it was called at the end of p3. This seems burdensome and error prone, so I just decided to re-read all the tables every time p3_init is called.

There are some round-off level diffs in P3, so:
[non-BFB]

This removes the last f90 from P3.

Change list:
* Move table read/write implementation to CXX in p3_init_impl.hpp
* p3_init now returns a P3LookupTables object with all the views
  inside containing the tables.
* Rename init_kokkos_tables to get_global_tables
* Rename init_kokkos_ice_lookup_tables to get_global_ice_lookup_tables
* Remove all f90 bridge code
* p3_tables_setup is now built by default and ran when baseline gen
  is on. This gives us the ability to generate these tables through
  GH actions which will be needed for this PR.
* Move p3_tables_setup to tests dir, cleans up top p3 directory
* Fix p3_tables_setup implementation; it got broken in recent PRs
  but we didn't notice because it didn't get built by default
* Remove P3GlobalForFortran test struct, just call p3_init!
* Remove P3InitAP3Data test struct

Debatable change:
I really wanted to have `P3LookupTables lookup_tables` be static in
p3_init so they would not have to be re-created on every p3_init call.
Unfortunately, Kokkos does not allow static views to be active on program
shutdown, since this occurs after Kokkos::finalize, so we would need add
a p3_finalize method and ensure it was called at the end of p3. This
seems burdensome and error prone, so I just decided to re-read all the
tables every time p3_init is called.

[non-BFB]
@jgfouca
Copy link
Member Author

jgfouca commented Dec 11, 2024

Reviewers, please see "Debatable change" section in the description.

@jgfouca jgfouca added the EAMxx PRs focused on capabilities for EAMxx label Dec 11, 2024
Copy link

github-actions bot commented Dec 11, 2024

PR Preview Action v1.4.8
🚀 Deployed preview to https://E3SM-Project.github.io/E3SM/pr-preview/pr-6845/
on branch gh-pages at 2025-01-07 17:36 UTC

@jgfouca jgfouca added the non-BFB PR makes roundoff changes to answers. label Dec 11, 2024
Copy link
Contributor

@bartgol bartgol left a comment

Choose a reason for hiding this comment

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

NICE! I love PRs where the # of rm-ed lines is larger than the # of added lines...

I have a few suggestions, in case you want to take this a step further. Not blocking though.

As for the debatable change: I think leaving as is (init for every test) is fine. No need to add complexity just to make the tests a bit faster. Our tests are reasonably fast anyways, so unless they suddenly got slow, and need the speedup of a single read, I think it's fine.

Simplify io action using if constexpr.
Remove fortran module stuff from cmake
Remove fortran from comment
@bartgol
Copy link
Contributor

bartgol commented Dec 17, 2024

@jgfouca Before merging this, we should decide how to handle tables. Once merged, we will need to regenerate the tables, right? But old e3sm versions will still need the "old" f90-major tables. Replacing the old files with the new will cause folks running old code to get diffs. I think we should change the tables names, so that we can have both old and new tables on the server. Maybe we should add v0.1 and v1.0 at the end of names, or something like that.

@jgfouca
Copy link
Member Author

jgfouca commented Dec 17, 2024

@bartgol , crap, I did not think of that. Yes, this change probably requires a new table version...

@jgfouca
Copy link
Member Author

jgfouca commented Jan 6, 2025

@bartgol , I made the changes we discussed and uploaded the v2 dat8 and dat4 files to ANL.

@jgfouca
Copy link
Member Author

jgfouca commented Jan 8, 2025

I think all the fails are expected DIFFs, so I will go ahead and merge.

jgfouca added a commit that referenced this pull request Jan 8, 2025
This removes the last f90 from P3.

Change list:
1) Move table read/write implementation to CXX in p3_init_impl.hpp
2) p3_init now returns a P3LookupTables object with all the views inside containing the tables.
3) Rename init_kokkos_tables to get_global_tables
4) Rename init_kokkos_ice_lookup_tables to get_global_ice_lookup_tables
5) Remove all f90 bridge code
6) Move p3_tables_setup to tests dir, cleans up top p3 directory
7) Fix p3_tables_setup implementation; it got broken in recent PRs but we didn't notice because it didn't get built by default
8) Remove P3GlobalForFortran test struct, just call p3_init!
9) Remove P3InitAP3Data test struct

Debatable change:

I really wanted to have P3LookupTables lookup_tables
be static in p3_init so they would not have to be re-created on every
p3_init call. Unfortunately, Kokkos does not allow static views to be
active on program shutdown, since this occurs after Kokkos::finalize,
so we would need add a p3_finalize method and ensure it was called at
the end of p3. This seems burdensome and error prone, so I just
decided to re-read all the tables every time p3_init is called.

There are some round-off level diffs in P3, so:

[non-BFB]

* jgfouca/p3_cxx_init:
  GPU fixes: need to use host views for init stuff
  Update PAM submodule
  Change new table names to not conflict with older tables
  Github feedback
  Convert p3_init from f90 to CXX
@jgfouca jgfouca merged commit 03ab204 into master Jan 8, 2025
11 of 22 checks passed
@jgfouca jgfouca deleted the jgfouca/p3_cxx_init branch January 8, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EAMxx PRs focused on capabilities for EAMxx non-BFB PR makes roundoff changes to answers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants