-
Notifications
You must be signed in to change notification settings - Fork 8
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
autodiff and rsmpi #137
Comments
Is this something Enzyme core should understand, or what would be the fix here? |
Yeah I think we should be able to just mark Enzyme internally as understanding this as equivalent to MPI double everywhere. Is there a spec sheet for the ABI rust uses for MPI somewhere (probably @jedbrown)? |
The symbols like |
The double issue is that Enzyme is being conservative and thinking the global variable itself is active, somehwere. Rather than risk wrong answers, throwing an error. You can tell Enzyme to assume all globals are inactive: https://enzyme.mit.edu/getting_started/UsingEnzyme/#assume-inactivity-of-unmarked-globals but we should just mark this in the places listed above. |
bug2.ll.txt
The issue here is that we can't always see this when differentiating Enzyme, proof:
which gives the following error
Not sure how we can fix that in general? However, if we ignore my artificial autodiff testcase and focus on the real world one where we read from MPI_SUM, that reminds me of reading from an enzyme_const global, which enzyme already recognizes, so it should be doable to copy that in case that a load from a recognized ptr name dominates the call sites? |
You may be able to do something for MPI reductions which is similar to how we handle generic indirect function calls. Specifically we define the shadow of a function to be the corresponding data [e.g. a pointer to augmented forward and reverse functions], and then if it is an indirect function use the shadow for the relevant derivative code. This also would enable generic user defined ops which would be nice. Alternatively you could look at ways to inline/pass the info from caller to callee like we do already for aliasing/etc |
The first one is too far in the Enzyme core weeds, I have no clue how to write that code, so I'll leave it to someone else. If you have a link for the last option on where we do that already I might be able to copy that over for this case:
That should be good enough for this specific case. |
This is based on this rsmpi example. After checking out that branch, please run
Note that
RSMPI_DOUBLE
is defined inmpi-sys/src/rsmpi.c
asso that the value can be used by Rust FFI bindings.
Debug profile
I have a different error with the debug profile.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: