Skip to content
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 std::string_view in eckit_mpi #118

Merged
merged 1 commit into from
May 3, 2024

Conversation

wdeconinck
Copy link
Member

This PR changes const char* arguments into std::string_view, so that we can now downstream replace amongst others
eckit::mpi::setCommDefault( string.c_str() ) and eckit::mpi::comm( string.c_str() )
with
eckit::mpi::setCommDefault( string ) and eckit::mpi::comm( string ).

It should still be compatible with callers passing const char*.

@wdeconinck wdeconinck force-pushed the feature/eckit_mpi_with_string_view branch from 4e10ba5 to 92bc480 Compare April 24, 2024 12:35
Copy link
Member

@pmaciel pmaciel left a comment

Choose a reason for hiding this comment

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

Aside from my minor comment, I only add that there is the function MPICall (Parallel.cc, and two fwd declarations in ParallelGroup.cc and ParallelRequest.cc) which takes const char* which might by more consistently converted also to std::string_view. I'm only advancing this if it was missed, I have no specific opinion or preference here.

@@ -95,10 +95,10 @@ class Environment {
for (itr = communicators.begin(); itr != communicators.end(); ++itr) {
eckit::Log::error() << " " << (*itr).first << std::endl;
}
throw eckit::SeriousBug(std::string("No communicator called ") + name, Here());
throw eckit::SeriousBug(std::string("No communicator called ") + std::string(name), Here());
Copy link
Member

Choose a reason for hiding this comment

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

Being pedantic here, for even more terseness one can remove the first std::string construction (in more than one place I see)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that would still work. My nitpick comment is that I prefer braces '{}' for calling the constructor to make it immediately obvious that we are calling the constructor and not a free function. This used to be very helpful for not getting caught out by 'the most vexing parse' behaviour, but these days compilers would warn you about that anyway.

Otherwise, it looks good.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! We aim for perfection :) I have implemented all suggestions.

@wdeconinck wdeconinck force-pushed the feature/eckit_mpi_with_string_view branch from adb9f96 to 1f5a5af Compare May 3, 2024 15:56
@wdeconinck wdeconinck merged commit 527e118 into develop May 3, 2024
30 checks passed
@wdeconinck wdeconinck deleted the feature/eckit_mpi_with_string_view branch May 3, 2024 15:57
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