Skip to content

Conversation

@ykempf
Copy link
Contributor

@ykempf ykempf commented Sep 24, 2025

No description provided.

@ykempf ykempf force-pushed the precommitTest branch 9 times, most recently from d4375f9 to 9a527f2 Compare September 25, 2025 08:29
Copy link
Contributor

@ursg ursg left a comment

Choose a reason for hiding this comment

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

I only took some picks of files here and there (and did not scroll through 280 files in 10 minutes!). There are definitely some clang-format options that still need tuning.

uint thread_id = 0;

public:
void syncDeviceData(void) { CHK_ERR(cudaMemcpyAsync(d_ptr, ptr, bytes, cudaMemcpyHostToDevice, gpuStreamList[thread_id])); }
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like that these have been compressed to one-liners now. I wonder what clang-format option would help there?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess AllowShortFunctionsOnASingleLine=Empty would be a reasonable setting for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +173 to +174
void setDipoleField(const FieldFunction& dipole) { dipoleField = dipole; };
void setConstantBackgroundField(const std::array<Real, 3> B) { BGB = B; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, too: The threshold for single-lining simple functions is too small, IMHO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines -206 to +203
void solve(
int & iteration,
int & nRestarts,
Real & residual,
Real & minPotentialN,
Real & maxPotentialN,
Real & minPotentialS,
Real & maxPotentialS
);
void solveInternal(
int & iteration,
int & nRestarts,
Real & residual,
Real & minPotentialN,
Real & maxPotentialN,
Real & minPotentialS,
Real & maxPotentialS
);
void initSolver(bool zeroOut = true); /*!< Initialize the CG solver */
iSolverReal Atimes(uint nodeIndex, int parameter, bool transpose = false); /*!< Evaluate neighbour nodes' coupled parameter */
Real Asolve(uint nodeIndex, int parameter, bool transpose = false); /*!< Evaluate own parameter value */
void solve(int& iteration, int& nRestarts, Real& residual, Real& minPotentialN, Real& maxPotentialN, Real& minPotentialS, Real& maxPotentialS);
void solveInternal(int& iteration, int& nRestarts, Real& residual, Real& minPotentialN, Real& maxPotentialN, Real& minPotentialS, Real& maxPotentialS);
Copy link
Contributor

Choose a reason for hiding this comment

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

These, too, are less readable now than before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a consequence of having too permissive line width, I'm assuming it's only going to split calls and definitions if they don't fit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This and the below are better imho if forcing them to just have one per line in a blanket fashion. Having variably one or more per line is just going to confuse people.

Copy link
Contributor

@lkotipal lkotipal Sep 25, 2025

Choose a reason for hiding this comment

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

Yeah BPPS_AlwaysOnePerLine is probably fine if not ideal imo. I don't think I agree about it being case-by-case being bad, like 1-3 param functions can be single-line. How does the formatting look with a lower line width?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, this turned out to be absolutely awful as it applies the same rule to template parameters which we absolutely do not want one per line, ever. So we'll have to live with BPPS_OnePerLine which will occasionally result in these one-liners (we'd have to tone down line width to address that)

Comment on lines 206 to 208
void mapDownBoundaryData(FsGrid<std::array<Real, fsgrids::bfield::N_BFIELD>, FS_STENCIL_WIDTH>& perBGrid, FsGrid<std::array<Real, fsgrids::dperb::N_DPERB>, FS_STENCIL_WIDTH>& dPerBGrid,
FsGrid<std::array<Real, fsgrids::moments::N_MOMENTS>, FS_STENCIL_WIDTH>& momentsGrid, FsGrid<std::array<Real, fsgrids::volfields::N_VOL>, FS_STENCIL_WIDTH>& volGrid,
FsGrid<fsgrids::technical, FS_STENCIL_WIDTH>& technicalGrid);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wasn't this exactly what the BinPackArguments option was supposed to prevent? Or is this now only affecting arguments in the function definition, and is separately handled for declarations?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, it is BinPackArguments (which are the actual values supplied in a function invocation) vs. BinPackParameters (which is the parameter list in the function definition and/or declaration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

There is also "ExperimentalAutoDetectBinPacking", but I have no idea what it does.

Comment on lines 47 to 48
for (auto& c : lowercase)
c = tolower(c);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should definitely have curlies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

The formatting of all these datareducers, that I had been quite vocal about in the fsgrid PR, now actually looks pretty nice!

@ursg
Copy link
Contributor

ursg commented Sep 25, 2025

scrolling through the config reference, i see ForEachMacros, that tells clang-format which custom macros should be treated as for loops. Our arch looping mechanisms are candidates for that.

@ykempf
Copy link
Contributor Author

ykempf commented Sep 25, 2025

In other news, we have a successful pair of TP runs! 🎉

@ykempf ykempf force-pushed the precommitTest branch 9 times, most recently from d1bef79 to 573af76 Compare September 25, 2025 13:09
iowrite.h Outdated
Comment on lines 44 to 95
bool writeGrid(
dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid,
FsGrid< std::array<Real, fsgrids::bfield::N_BFIELD>, FS_STENCIL_WIDTH> & perBGrid,
FsGrid< std::array<Real, fsgrids::efield::N_EFIELD>, FS_STENCIL_WIDTH> & EGrid,
FsGrid< std::array<Real, fsgrids::ehall::N_EHALL>, FS_STENCIL_WIDTH> & EHallGrid,
FsGrid< std::array<Real, fsgrids::egradpe::N_EGRADPE>, FS_STENCIL_WIDTH> & EGradPeGrid,
FsGrid< std::array<Real, fsgrids::moments::N_MOMENTS>, FS_STENCIL_WIDTH> & momentsGrid,
FsGrid< std::array<Real, fsgrids::dperb::N_DPERB>, FS_STENCIL_WIDTH> & dPerBGrid,
FsGrid< std::array<Real, fsgrids::dmoments::N_DMOMENTS>, FS_STENCIL_WIDTH> & dMomentsGrid,
FsGrid< std::array<Real, fsgrids::bgbfield::N_BGB>, FS_STENCIL_WIDTH> & BgBGrid,
FsGrid< std::array<Real, fsgrids::volfields::N_VOL>, FS_STENCIL_WIDTH> & volGrid,
FsGrid< fsgrids::technical, FS_STENCIL_WIDTH> & technicalGrid,
dccrg::Dccrg<
SpatialCell,
dccrg::Cartesian_Geometry>& mpiGrid,
FsGrid<
std::array<
Real,
fsgrids::bfield::N_BFIELD>,
FS_STENCIL_WIDTH>& perBGrid,
FsGrid<
std::array<
Real,
fsgrids::efield::N_EFIELD>,
FS_STENCIL_WIDTH>& EGrid,
FsGrid<
std::array<
Real,
fsgrids::ehall::N_EHALL>,
FS_STENCIL_WIDTH>& EHallGrid,
FsGrid<
std::array<
Real,
fsgrids::egradpe::N_EGRADPE>,
FS_STENCIL_WIDTH>& EGradPeGrid,
FsGrid<
std::array<
Real,
fsgrids::moments::N_MOMENTS>,
FS_STENCIL_WIDTH>& momentsGrid,
FsGrid<
std::array<
Real,
fsgrids::dperb::N_DPERB>,
FS_STENCIL_WIDTH>& dPerBGrid,
FsGrid<
std::array<
Real,
fsgrids::dmoments::N_DMOMENTS>,
FS_STENCIL_WIDTH>& dMomentsGrid,
FsGrid<
std::array<
Real,
fsgrids::bgbfield::N_BGB>,
FS_STENCIL_WIDTH>& BgBGrid,
FsGrid<
std::array<
Real,
fsgrids::volfields::N_VOL>,
FS_STENCIL_WIDTH>& volGrid,
FsGrid<
fsgrids::technical,
FS_STENCIL_WIDTH>& technicalGrid,
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh my god bruh

Copy link
Member

Choose a reason for hiding this comment

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

Tbh this particular mess could do with a proper fsgrids wrapper anyhow.

ursg and others added 7 commits October 29, 2025 13:51
Actually include clang-format 22 in CI step

(Re-)Enable clang-format in precommit config

Actually run on push to precommitTest

Fix precommit action yml file

Fix precommit ci apt installation commands

Also install python in precommit CI

try to get precommit to actually find git

Make sure precommit runs in the correct directory

Try to debug why git is not found in precommit CI

See if including npm or nodejs help widg precommit artefact upload

Don't actually run clang-format (but everything else)

Make sure precommit ci step has the right name

Re-enable clang-format

Actually add push permissions to the precommit workflow

Also ignore .DAT files and any line with a # in it.

Actually, *don't* bin pack argument

Update some precommit hook versions

Run precommit CI on push to any branch (thus: permission!)

Actually have pull-request, not push permissions for precommit

A random one-character commit that introduces a whitespace error.

Remove the whitespace error again.

Fix order of filter.

swap order because why not?

Whyyyy?

Add back precommitTest to change the PR target branch again.

No branch specification, run that on any PR.

Another unimportant small change

More trivial and pointless change

Add a poem about neutrinos.
common.h Outdated
Comment on lines 41 to 43
#define CHECK_FLOAT(x) \
{ \
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a weird way to reformat this. It seems to identify the "{}" here as an empty code block, but this totally breaks the ideomatic use of {} to signify an empty piece of code.

Also, why does it even touch this line, if the regex forbids it from touching anything with a # in it?

@ursg
Copy link
Contributor

ursg commented Oct 29, 2025

To sum up our findings of today:
a) By and large, the formatting is now looking good.
b) We manually disabled clang-format for some code blocks that are semantically grouped for ease of understanding
c) In principle, we are now happy and would merge it, but it looks like we are triggering a clang-format bug with our regex-ignoring of pragmas: many (all?) comment lines preceding a pragma are alternatingly moved to column one and back to their proper indentation on every even-odd run of clang-format.

Do we have a workaround for that?

@ursg
Copy link
Contributor

ursg commented Oct 30, 2025

So your solution is to have a "#" in every comment in front of an omp pragma, hence clang-format ignoring it?
And if we forget that in the future, precommit will hapilly mess up our code again?

"No sir, I don't like it."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants