-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
RFC: Define wait(req) to use threadcall #452
Conversation
Couldn’t waitall be defined as a wait method that takes an array of requests, maybe with a flag argument for waitall vs waitany? |
errcode = @threadcall((:MPI_Wait, libmpi), Cint, | ||
(Ptr{MPI_Request}, Ptr{Status}), | ||
req, stat_ref) |
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.
One issue is that on 32-bit windows we need to use the stdcall
convention: this is usually handled by the @mpicall
/@mpichk
macros, but @threadcall
doesn't seem to support nonstandard calling conventions.
On the other hand, it passed tests so 🤷 ?
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.
(alternatively, we could disable this on 32-bit Windows, like we do the custom operator stuff)
It would be good to have this be configurable, I have to think a bit more
about this, but MPI implementation are free to not be threadsafe (or use
libraries under the hood that are not threadsafe, I suspect that half the
UCX builds are built without support for threads...)
…On Wed, Feb 24, 2021, 23:29 Simon Byrne ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/pointtopoint.jl
<#452 (comment)>:
> + errcode = @threadcall((:MPI_Wait, libmpi), Cint,
+ (Ptr{MPI_Request}, Ptr{Status}),
+ req, stat_ref)
(alternatively, we could disable this on 32-bit Windows, like we do the
custom operator stuff)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#452 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABDO2XUWEFAODNEL422JR3TAXG37ANCNFSM4YFNR2XA>
.
|
Nice to see this! Is this approach composable? In some situations, we need to wait for a precondition (Request 1) in order to start a non-bloking communication that will generate Request 2. It would be nice to be able to compose these two requests in a asynchronous Task (or whatever object) that waits for Request 1, starts the non-blocking communication and waits for Request 2. |
Yes, the user would be required to initialize using
Yes, you can do something like:
Alternatively, it might be better to just use Julia threading for this:
The main difference is that the first is blocking a libuv thread, the second is blocking a Julia thread. I'm not sure what other implications of this are. |
After further thought, I don't think this is a good idea. I think it would be better to define function Base.wait(req::MPI.Request)
while !MPI.Test(req)
yield()
end
end This should work, since
|
@simonbyrne thanks for the new idea. In my code I am finally doing something like t = @async begin
while !MPI.Test(req)
yield()
end
end and then one can consume task |
That's a good idea, would you mind opening a draft PR? |
Yes! I'll do that. |
Prompted by this discussion I tried to see if I could use
@threadcall
to wait on nonblocking MPI operations inside tasks.And it seems to work! I've defined this to be a method of
Base.wait
, in that it acts mostly the same way (i.e. will yield until it is complete). Obviously one problem is that it is limited by the size of the libuv thread pool, but I don't think that would be a big issue.If people are in favor, I can define analogous
waitany
/waitall
/waitsome
operations.cc: @giordano @stevengj @vchuravy @fverdugo