Skip to content

Conversation

@pcarruscag
Copy link
Member

Proposed Changes

Addresses the compilation time issue (#851) in the way discussed with @talbring in #824.
Plus, I think it is time to bite the bullet and cleanup CConfig, no more .inl, tabs replaced (but the comments still look ok-ish), methods made const when possible.
This will probably cause you issues, but the changes to these files are usually very linear and so, easy to re-apply.
There is no more CCreateMap function, in C++11 braced initialization can be used instead e.g.:
map<string, string> AverageGroupName = {{"BGS_RES", "bgs"},{"RMS_RES","rms"},{"MAX_RES", "max"}};

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with the '-Wall -Wextra -Wno-unused-parameter -Wno-empty-body' compiler flags).
  • My contribution is commented and consistent with SU2 style.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp) , if necessary.

@pcarruscag pcarruscag changed the title disable config map declarations when not needed to speedup compilation Faster compilation Jan 29, 2020
Comment on lines -177 to +153
static const map<string, AVERAGE_TYPE> Average_Map = CCreateMap<string, AVERAGE_TYPE>
("AREA", AVERAGE_AREA)
("MASSFLUX", AVERAGE_MASSFLUX);
static const MapType<string, AVERAGE_TYPE> Average_Map = {
MakePair("AREA", AVERAGE_AREA)
MakePair("MASSFLUX", AVERAGE_MASSFLUX)
};
Copy link
Member Author

Choose a reason for hiding this comment

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

This is what the map declaration semantics look like now, so that they can be switched on/off.
When map declarations are needed #define ENABLE_MAPS before including either config/option_structure.hpp, by default this is not default.
MakePair is a "do-nothing" macro when that flag is not defined, MapType is defined at the top as either std::map or a dummy empty class when the flag is not defined.

@talbring
Copy link
Member

Thanks @pcarruscag ! FYI: that makes compilation like 5 times faster on our system ...

@TobiKattmann
Copy link
Contributor

TobiKattmann commented Jan 29, 2020

Thanks @pcarruscag ! FYI: that makes compilation like 5 times faster on our system ...

Yeah, the speedup is ridiculous. On 28cores on our system an MPI build (no AD-stuff involved) takes ~30 seconds instead of 3min. 🐎 vs 🐌
Great job!

Copy link
Member

@talbring talbring left a comment

Choose a reason for hiding this comment

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

Maybe its a good thing to clean up config_structure now ... We can also think about renaming it (that should be tracked by git anyway).

@pcarruscag
Copy link
Member Author

I already did the spaces, the tabs, the inlines, what more is there?

@talbring
Copy link
Member

I already did the spaces, the tabs, the inlines, what more is there?

Just wanted to say that I think its good that you did that 👍

@pcarruscag
Copy link
Member Author

We could always look for unused methods amongst the thousand or so we have 🤣

@economon
Copy link
Member

Nice job on the compile speed up @pcarruscag 👍

@@ -174,34 +147,35 @@ enum AVERAGE_TYPE {
AVERAGE_AREA = 1, /*!< \brief Area-weighted average. */
Copy link
Member

Choose a reason for hiding this comment

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

While major changes are happening in this file, it could be a good time to finally remove the integer specifiers for each value in the enums, which aren't needed. Up to you if you have time

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm If we did not cast every enum to unsigned short in CConfig I would agree, and it should be doable with a script. But for debugging I find it useful to know what number to expect without having to count / print extra stuff.

Copy link
Contributor

@jayantmukho jayantmukho left a comment

Choose a reason for hiding this comment

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

Changes seem to be pretty straight forward. Got a speedup of ~3.8x for compilation with AD and pywrapper. (meson+ninja)

Since the config has been restructured, you could change the file name to CConfig.

@pcarruscag
Copy link
Member Author

Files renamed

Copy link
Member

@talbring talbring left a comment

Choose a reason for hiding this comment

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

Everything looks fine! Lets get that in asap. Thanks @pcarruscag once again ..

Copy link
Contributor

@TobiKattmann TobiKattmann left a comment

Choose a reason for hiding this comment

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

I have some very picky comments only related to comments and alignment so you might as well ditch them.
I would have preferred though to separate the CConfig refactor + and cleanup and the compile time stuff in different PR's to improve PR's readability.
But anyway, the compile time improvement is awesome and the cleanup goes beyond just stripping whitespaces but includes alignements, typo-fixes, the const-additions etc ... so thanks a lot!


void addStringOption(const string name, string & option_field, string default_value);

void addIntegerOption(const string name, int & option_field, int default_value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add documentation here, although there is a general explanation on top.
But it is not really the job of the 'refactorer' to sanitize everything, so you might as well ignore this comment ... and all my other comments 😄
As my brother tends to say: The 'good' shouldn't be the enemy of the 'better' ☮️

Copy link
Member Author

Choose a reason for hiding this comment

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

Most of the doxy stuff in these files only contribute to confusion, the methods explain themselves but then they have some copy pasted brief from other methods... I'll address some of your comments, thanks for looking through the stuff.


void addDoubleArrayOption(const string name, const int size, su2double * & option_field, su2double * default_value);

void addDoubleListOption(const string name, unsigned short & size, su2double * & option_field);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here again no documentation

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants