-
Notifications
You must be signed in to change notification settings - Fork 51
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
Remove type-distinction between system-communicators and user-communicators #155
Conversation
- migrated topology-related code from UserCommunicator into the common enum, so both communicator variants can now call those functions. Spec indicates that this is legal - refactored CartesianCommunicator to accept both World- and UserCommunicator, which is legal by spec, I don't know why this wasn't possible before - since WorldCommunicator is no longer Copy, code that moved a reference to SystemCommunicator must now explicitly refer to IntraCommunicator::WorldCommunicator (see immediate_multiple_test.rs)
Thanks! The /// A system-defined inter-communicator
pub type SystemInterCommunicator = InterCommunicator<SystemCommunicatorHandle>;
/// A user-defined inter-communicator
pub type UserInterCommunicator = InterCommunicator<UserCommunicatorHandle>; Looks like we have some CI failures. |
The reason why the separate handles exist is the same why I don't quite understand if Drop-semantics are important here: Intuitively I wouldn't even unify the two handles into a common
I was bitten by |
…num. - SysHandles are no longer Copy&Clone, but they no longer hold state
So I figured out why the split in As far as I can tell, the split in |
…torHandle and simplified InterCommunicator type * removed CommunicatorHandle trait * removed [User|System]InterCommunicator types in favor of InterCommunicator * added self_comm() function to SimpleCommunicator type * added inter-comm check to constructor of intercomm handles instead of constructor of intercomms to save on MPI-calls. * added unchecked inter-comm handle constructor as all callers of inter-comm constructors would unwrap the optional anyway
I have implemented an enum The latter still use simple communicators in their constructor (as before), I don't know if that is how it is supposed to be, because it seems weird to have this back-and-forth between the types going on. I need some feedback on that. The Handle type is still public, I don't know if we should hide it completely. At the moment hiding it is weird, because there is the public trait |
Cool, I'll check it out as time allows. I think of |
Nope. At the moment |
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.
Thanks for your work here and sorry for my slow review. Would it be a lot to ask for an example showing something that can be done in the new model that couldn't be done before?
I suspect the new version can compile a little faster/smaller due to fewer variants to monomorphize, though even that is hard to measure. I find it a bit more intuitive, but it seems to be almost exactly the same amount of code. Unfortunately, we can still hardly use &dyn Communicator
because most methods require Self: Sized
. I'm not sure how to gracefully get us out of that bind.
Co-authored-by: Jed Brown <jed@jedbrown.org>
About the example what can be done in the new model: I then changed my approach to your suggestion of at least encapsulating the handle correctly, which further disconnected this PR from its initial attempt to make it easier to support different communicators for higher-level routines: Now the distinction between Intra-, Inter- and topological communicators still exists publicly, only the handle is nicely modelled. I am still hoping this will simplify the solution for #148 (see below), but from the outside, this PR doesn't improve the API that much, sadly. About all the safety-related stuff: I tried to not create more mess than was already present, but some functions were and are not marked unsafe that really should be (then again, at least some collective communication functions are unsound but not marked unsafe either). I opened #157 and linked a commit that builds upon this PR to fix the issue with |
- renamed checked from_raw functions to try_from_raw - removed from_handle functions for inter-comms, as those can as well be replaced with from_raw functions - added more safety documentation
Is this still desired? |
Sorry, I got swamped with end-of-semester stuff. I'll be able to put more attention toward this next week. |
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.
Thanks. Sorry about losing track of this. Pipeline is running now.
…cators (rsmpi#155) * Unified SystemCommunicator and UserCommunicator into common enum - migrated topology-related code from UserCommunicator into the common enum, so both communicator variants can now call those functions. Spec indicates that this is legal - refactored CartesianCommunicator to accept both World- and UserCommunicator, which is legal by spec, I don't know why this wasn't possible before - since WorldCommunicator is no longer Copy, code that moved a reference to SystemCommunicator must now explicitly refer to IntraCommunicator::WorldCommunicator (see immediate_multiple_test.rs) * Added SelfCommunicator into SimpleCommunicator for easy access * cargo fmt * refactored optional code that was untested in msmpi * SimpleCommunicator is no longer Clone, as that violates RAII logic * merged SystemCommunicatorHandle and UserCommunicatorHandle into one enum. - SysHandles are no longer Copy&Clone, but they no longer hold state * merged SimpleCommunicator and SimpleCommunicatorHandle into CommunicatorHandle and simplified InterCommunicator type * removed CommunicatorHandle trait * removed [User|System]InterCommunicator types in favor of InterCommunicator * added self_comm() function to SimpleCommunicator type * added inter-comm check to constructor of intercomm handles instead of constructor of intercomms to save on MPI-calls. * added unchecked inter-comm handle constructor as all callers of inter-comm constructors would unwrap the optional anyway * made constructors public again, since handles are public too atm * downgraded handle-enum visibility to pub(crate) * implemented FromRaw for SimpleCommunicator and InterCommunicator * implemented FromRaw for CartesianCommunicator * Better explanation of empty drop logic Co-authored-by: Jed Brown <jed@jedbrown.org> * example recommendation: &impl Communicator vs SimpleCommunicator * Cleaned up unsafe from_raw functions - renamed checked from_raw functions to try_from_raw - removed from_handle functions for inter-comms, as those can as well be replaced with from_raw functions - added more safety documentation * Mild cleaning --------- Co-authored-by: Jed Brown <jed@jedbrown.org>
As outlined in #148, it is very unintuitive to split the Communicator interface in
SystemCommunicator
andUserCommunicator
.I drafted a PR to unify both into one common
enum SimpleCommunicator
:free
on it when theirUserCommunicator
dropsThings missing from this draft:
There is another weird split in the code-base: InterCommunicators use
SystemCommunicatorHandle
andUserCommunicatorHandle
, even though those handle structs do the exact same as their communicator-counterparts (at least as far as I can tell).Since I have never worked with InterCommunicators before though, and there are neither integration-tests nor examples for them, I didn't migrate them to use
SimpleCommunicator
yet, as I wanted to get some feedback on their purpose.All examples and tests are green, but I am not very familiar with the codebase yet, so somebody should scrutinize this.