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

EAMxx: Formats all MAM4xx interfaces using Clang #7036

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

singhbalwinder
Copy link
Contributor

@singhbalwinder singhbalwinder commented Feb 20, 2025

There are no code changes in the PR except for formatting.

[BFB]

@singhbalwinder singhbalwinder added EAMxx PRs focused on capabilities for EAMxx MAM4xx MAM4xx related changes code cleanup labels Feb 20, 2025
@mahf708 mahf708 added the BFB PR leaves answers BFB label Feb 20, 2025
Copy link
Contributor

@mahf708 mahf708 left a comment

Choose a reason for hiding this comment

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

wanna add an automated workflow check to ensure the whole of eamxx can follow your clang format ;) ;)

or maybe @mjschmidt271 / @mjs271 (which one is it 👀) might be interested in forcing a formatter?

@singhbalwinder
Copy link
Contributor Author

As you might know, we have it in our workflow in MAM4xx repo (I think it was @jeff-cohere's idea). It has been very helpful to keep a consistent formatting. I like the idea of having it for the whole EAMxx, but we must decide that as a group.

@mjschmidt271
Copy link
Contributor

@mahf708 - I'd very much be up for looking into this! Dev meeting agenda has been packed lately, but maybe we can throw it to the group tomorrow.

And, as of a few weeks ago, trying to make @mjschmidt271 my work-only account... though having varying levels of success so far 🙃

@mahf708
Copy link
Contributor

mahf708 commented Feb 20, 2025

I could propose something like master...mahf708/eamxx/clang-format (branch https://github.com/E3SM-Project/E3SM/tree/mahf708/eamxx/clang-format), potentially with better hardening of the workflow. Keep in mind we will want to consult with the omega developers as well as infrastructure (this is not an eamxx only change)

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.

This is your parametrization, so you can format as you want. As for eamxx formatting, I think we should discuss a bit more. I don't think dev call is needed. Most folks don't care. We can just have a slack thread.

w0(icol, kk) = 0;
rho(icol, kk) = -999.0;
});
Kokkos::parallel_for(Kokkos::TeamVectorRange(team, 0u, top_lev),
Copy link
Contributor

Choose a reason for hiding this comment

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

It's interesting that the formatter removes the linebreak here (after parallel_for(), but doesn't do the same in this same file, below...

rho(icol, kk) = -999.0;
});
Kokkos::parallel_for(Kokkos::TeamVectorRange(team, 0u, top_lev),
[&](int kk) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be a can of worms, since it involves personal preferences, so feel free to ignore.

How do you feel about the indenting here? The lambda gets indented a lot, which can be problematic in cases where the lines are not as short as in this case... Imho, it looks better when it's done like it was before. Or, even better, like this

auto f = [&](int kk) {
  ...
};
auto tvr = Kokkos::TeamVectorRange(team,0,top_lev);
Kokkos::parallel_for (tvf,f);

(but this is not something that a general-puprose formatter can easily do)...

Copy link
Contributor

@jeff-cohere jeff-cohere Feb 20, 2025

Choose a reason for hiding this comment

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

If you're going to discuss formatting specifics (which we didn't when developing mam4xx), it's helpful to take a look at the (version-dependent) clang-format options that control said specifics.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd personally take the same route @jeff-cohere and company took, just rely on some sane defaults, and then people can work around them in their code if the result ends up ugly (like @bartgol illustrates above)

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to add my 2 cents on this, having worked with our clang-format requirement for MAM4xx PRs for a few years now. I can't say I always love the way it makes my code look, but the consistency across the entire project pays dividends on readability since it eliminates idiosyncratic style choices that can provide a constant source of very tiny friction on development.

Also, at this point, I've pretty much internalized and adopted the style so that most times there's little if any intervention by the autoformatter--which is to say, you do get used to it 🙂

@singhbalwinder
Copy link
Contributor Author

Thank you all for your input (we also had a discussion on Slack about it in the Infrastructure group channel). At this point, my preference is to merge it (after I resolve the conflict) as is. We can revisit the format issue after we make a project-wide decision.

@mahf708 mahf708 changed the title EAMxx:Formats all MAM4xx interfaces using Clang EAMxx: Formats all MAM4xx interfaces using Clang Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BFB PR leaves answers BFB code cleanup EAMxx PRs focused on capabilities for EAMxx MAM4xx MAM4xx related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants