-
Notifications
You must be signed in to change notification settings - Fork 198
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
Use "Include What You Use" on WarpX #1947
Conversation
Cool! Can you please document the usage for IWYU again that did the code transformation? :) |
Ehm... I am transforming the code file by file, deciding which of the changes proposed by IWYU is to be accepted! IWYU sometimes proposes files which were never meant to be included directly. Or in some cases it suggests forward declarations. I don't think that we want many forward declarations, but maybe we could consider them in some places... |
I'm not done and there are still some bugs to fix, but the compilation seems a bit faster (maybe ~ 10%). Actually, most headers need additional includes if we want to follow the "include what you use principle". I think that the decrease of the compilation time is due to some forward declarations that I have added in WarpX.H. |
Forward declarations could be written in explicit I like When this PR is further advanced, we should present the technique in the dev meeting, so others are aware. |
It seems to work at last! |
Uhoh, the docs introduced an issue and now it conflicts :) Feel free to ping me on Slack once finished and we merge it in. |
@ax3l , it should be OK now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks a lot!
I'll push the last fixes directly.
Source/Utils/main.cpp
Outdated
@@ -0,0 +1,34 @@ | |||
#include "MsgLogger.H" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file and a.out
are accidentally committed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now removed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes! thanks! sorry...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
#ifdef WARPX_USE_PSATD | ||
# include "FieldSolver/SpectralSolver/SpectralSolver.H" | ||
#endif | ||
#ifdef WARPX_DIM_RZ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regression addressed in #2044 :)
In this rather large PR I have used the tool "Include What You Use" (
iwyu
, https://github.com/include-what-you-use/include-what-you-use ) to individuate missing or unnecessary#include
directives and possible forward declaration opportunities.Specifically, I have followed these policies:
No forward declarations of AMReX classes, except inUse the new forward declaration headers available in AMReX since PR AMReX/PICSAR: Weekly Update #2016 .WarpX.H
, since this header is included almost everywhere.MyClass.H
, don't include it inMyClass.cpp
, even ifiwyu
suggests to do so._fwd.H
files, according to @ax3l suggestion.Even if I have added many more
#include
directories than those that I have removed, this PR seems to reduce the compilation time of WarpX in CI.To further reduce the compilation time we may consider to add forward declarations of AMReX classes. ((this has been done).iwyu
shows that there are a lot of opportunities to seize)To use
iwyu
I just callccmake
from the build directory as follows:Then, I save the output of
make
in a log file (it takes a long time!):And finally I have a look at this rather huge log file, whose entries are like the following:
I used
iwyu
for a specific configuration (3D, MPI+OMP, QED, PSATD, EB, OPENMP all enabled). Then, I tried to fix all the bugs shown by CI tests.In a given header file
MyClass.H
, the include order is the following:In the corresponding
MyClass.cpp
file the only difference is that IMyClass.H
at the top.Warning : depends on AMReX-Codes/amrex@d7ff203