-
Notifications
You must be signed in to change notification settings - Fork 52
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
Support for #[derive(Equivalence)] to allow Rust structs to be sent directly over MPI #52
Conversation
This commit adds support for the MS-MPI implementation, primarily targeting Windows. I add some code to discover for MS-MPI that only run on Windows, and moved the other MPI probing to a separate probe function for Unix. I inject an msmpi cfg into both mpi-sys and rsmpi. This may be useful to either surface msmpi specifically functionality or, like I do in this commit, to disable certain features that are missing from MS-MPI. I noticed two issues when building with the MS-MPI headers: 1. MPI_Comm_create_group was missing. 2. Bindgen does not seem to pick up the MPI_User_function definition For both of these issues, I just removed the APIs that called these functions when using MS-MPI. This may not be the best method. I also disabled portions of any tests that rely on these functionalities. I recommend building without default features on Windows since libffi is not available by default. I also swapped the gcc crate with cc, as that seems to be the stable version of gcc.
Currently only supports simple structures of separate, scalar fields
…quivalent_datatype()
- Adds dup() for all implementations of Datatype trait - Adds as_ref() to get a DatatypeRef from any Datatype - Adds example of dup()
- Adds new types: UncommittedUserDatatype + UncommittedDatatypeRef - same constructors as UserDatatype and DatatypeRef - UncommittedUserDatatype::commit consumes the old value to produce a UserDatatype - structured constructor takes a slice that can be passed directly to underlying MPI_Type_create_struct call without copy - Adds UncommittedDatatype trait - Implemented for UncommittedUserDatatype, UncommittedDatatypeRef, UserDatatype, and DatatypeRef - Supports capability for duplicating the datatype - New generic trait: FromRaw - Provides fixed way for constructing an mpi::Foo from a MPI_Foo - Implemented for all the Datatype types - New generic trait: MatchesRaw - Marker trait that indicates it's representationally safe to treat a slice of Foo as a slice of Foo::Raw - Implemented for all of the Datatype types - Adds a complex_datatype test that constructs a UserDatatype from multiple UncommittedUserDatatype values -
This also marks it as unsafe since, with some implementations, it may be possible to create an mpi::ffi::MPI_Comm safely that is invalid.
This is great feature that I'd love to use right now! Is there any timeline for when this can be merged? |
Oh, I was originally hoping for a review... I should probably just update it and merge it. |
Wow this is really helpful and can reduce boilerplate! Looking forward to seeing it merged :) |
Haha, ok, I've been convinced, let me get this done... |
I was working on this last night - mainly the issue is that the diff was a little gnarly. However, I did run into another issue of significance - the There's discussion of this issue in the Of note, there's an implicit promise that even though the code in So there are two options:
Any thoughts? |
I would suggest deferring to the |
Can't be merged until Gilnaa/memoffset#48 is merged and a new release of memoffset is cut. |
- Initializes datatype for derive(Equivalence) once per-process - Fixes a possible race condition in mpi::initialize allowing for multiple threads to initialize MPI - mpi::initialize now keeps bookkeeping on which thread initialized MPI - equivalent_datatype panics for derive(Equivalence) if the MPI library isn't currently initialized - Add tests to check that the code panics when expected
@adamreichold Look good? |
I admittedly did not have time yet to look over your latest changes. Could you give me until the middle of the week? I think I will be able to schedule a more comprehensive review until then. |
@AndrewGaspar Besides the cosmetic question of whether to use examples or tests, this looks good to me now. |
NOTE: This PR should be merged after #49 and #51.
This adds a crate that provides a custom derive for
Equivalence
, allowing a user to mark a complex struct with#[derive(Equivalence)]
to be able to safely send that type via MPI without having to manually serialize the data.E.g.
This should work with any
struct
in Rust that is composed of fundamental types (or arrays of fundamental types) that implementEquivalence
. I believe I've tested all forms of structs (with named fields, unnamed fields, and no fields).