Skip to content

Global unused options#3367

Open
bendudson wants to merge 3 commits intonextfrom
global-unused-options
Open

Global unused options#3367
bendudson wants to merge 3 commits intonextfrom
global-unused-options

Conversation

@bendudson
Copy link
Copy Markdown
Contributor

Only throw exception on unused option if it's not used on any MPI rank.

Fixes issue #3366

Fails on two processors because options are not marked used.
Checks for options that are unused on all MPI ranks.
Not very efficient but this function isn't called often.
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Comment thread src/sys/options.cxx
/// Keys are serialised as a newline-separated string. Newlines are safe as a
/// separator because option keys use ':' as their only structural character.
std::set<std::string> getGlobalUnusedSet(std::vector<std::string> local_unused_keys) {
MPI_Comm comm = BoutComm::get();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "MPI_Comm" is directly included [misc-include-cleaner]

src/sys/options.cxx:27:

- #include <set>
+ #include <mpi.h>
+ #include <set>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is supposed to be ignored, but it turns out we've got duplicate misc-include-cleaner.IgnoreHeaders keys in .clang-tidy :(

Comment thread src/sys/options.cxx Outdated
Comment thread src/sys/options.cxx
Comment thread src/sys/options.cxx
Comment thread src/sys/options.cxx
Comment thread src/sys/options.cxx
Comment thread src/sys/options.cxx
Comment thread src/sys/options.cxx
dschwoerer
dschwoerer previously approved these changes Apr 29, 2026
Copy link
Copy Markdown
Contributor

@dschwoerer dschwoerer left a comment

Choose a reason for hiding this comment

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

Thanks @bendudson, that looks good!

It might be sufficient to use Gatherv rather then Allgatherv - but that is just a nitpick.
It would be sufficient to only check on node0, as that is the only one that writes it out anyway.

ZedThree
ZedThree previously approved these changes Apr 29, 2026
Copy link
Copy Markdown
Member

@ZedThree ZedThree left a comment

Choose a reason for hiding this comment

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

LGTM. There's a couple of bits that could use existing functions, but very minor

Comment thread src/sys/options.cxx
Comment on lines +1176 to +1179
std::vector<int> displs(nprocs, 0);
for (int i = 1; i < nprocs; ++i) {
displs[i] = displs[i - 1] + all_lens[i - 1];
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is std::partial_sum?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's close but displs should start with a zero. It might be exclusive_scan in C++17 https://en.cppreference.com/cpp/algorithm/exclusive_scan

Comment thread src/sys/options.cxx Outdated
Co-authored-by: Peter Hill <peter.hill@york.ac.uk>
@bendudson bendudson dismissed stale reviews from ZedThree and dschwoerer via 26f7cc4 April 29, 2026 16:32
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.

3 participants