-
Notifications
You must be signed in to change notification settings - Fork 90
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
Start to use more forward declarations #1464
base: next
Are you sure you want to change the base?
Conversation
This removes the requirement to include the interpolation header
In terms of optimising the compilation I've done a bit of timing which shows that including Just declaring these maps without initialising them in the header cuts the time from 0.8s to about 0.45s. It doesn't sound much but I think it could be a reasonable fraction saving across a full build (note configure+compile on travis takes about 10 minutes, with the tests then taking 2-7 minutes). |
#include <bout_types.hxx> | ||
#include <field2d.hxx> | ||
#include <field3d.hxx> | ||
#include <fieldperp.hxx> |
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'm confused about this... should we use <>
for system headers and ""
for BOUT++ headers?
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 tend to view <>
as being something provided by a library (including bout
) and ""
for local files. Or in other words <>
for things in an include path and ""
for things that aren't. This is just my interpretation though. I think ""
can search more places, but if this is an advantage or a disadvantage may be a matter of opinion.
( I should add ""
falls back to <>
if the first (implementation defined) search fails -- in practice I think that means most of our uses of ""
fall back to <>
anyway ).
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.
In practice, there is not much difference. The C standard says both are implementation defined, which the exception that ""
explicitly looks for a file and <>
for a header, which might not be a file.
-
For
""
, gcc searches the current directory first, then paths specified with-iquote
, then "a standard list of system paths" which includes those in-I
. -
For
<>
, gcc searches the system paths only (including those in-I
and-isystem
).
I don't think we use -I.
, so private headers do really need to be ""
, while the public ones can be <>
. Beyond that, I think it is a matter of opinion -- but it would be nice to be consistent! As a note, the gcc docs below say to use ""
for "your own program" and <>
for "system headers".
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.
One reason to prefer ""
for all BOUT++ headers: clang-format and include-what-you-use can group headers together, and it might be nice to separate the system headers from ours.
As we provide header guards for boutcomm we can avoid including mpi.h multiple times.
@johnomotani thanks, you're right -- I've now added the new files, thanks! |
I think it's now just missing |
throw BoutException("Unhandled direction encountered in getAllowedStaggerLoc"); | ||
} | ||
}; | ||
CELL_LOC getAllowedStaggerLoc(DIRECTION direction) const; |
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.
These three functions now can't be inlined -- but it doesn't look like they're used in any tight loops so presumably this isn't that bad
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.
Yes, this is one of the reasons I think this PR might be more for discussion/experimentation to decide on a policy. I'd prefer runtime performance over compilation performance but there may be places we can get both.
While we're tidying up, we should probably rename all the include guards as macros beginning with |
@@ -35,17 +35,29 @@ | |||
|
|||
class Solver; |
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.
We should be able to delete this
I used Also made all BOUT++ headers included with Any gain over this PR is in the noise, but it would at least be a consistent treatment of headers. At the cost of 2k+ lines changed! I'm in favour of merging this PR at least, it's about a 20% speedup of compile times on Travis |
For reference I've made a branch that just includes the changes to |
Is this one for tidying and merging, or closing? |
The tidying is likely going to be a nightmare so probably closing and rebasing. I did have a go last week, I'll check it still goes in cleanish. |
Work contributes towards resolving #1134
Alongside potential compilation speed improvements (that I've not observed yet), these changes (particularly once fully rolled out) should hopefully help make things a bit more flexible/easy to extend.