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

Should discarding returned ucxx::Request be a valid use pattern? #268

Open
pentschev opened this issue Aug 14, 2024 · 2 comments
Open

Should discarding returned ucxx::Request be a valid use pattern? #268

pentschev opened this issue Aug 14, 2024 · 2 comments

Comments

@pentschev
Copy link
Member

In #267 we added a test that discards the return value of ucxx::Endpoint::tagSend/ucxx::Endpoint::tagRecv and rely solely on the value of the ucs_status_t object passed to the user callback. This turns out to be a valid use case because a reference to the resulting ucxx::Request will be stored by the owning ucxx::Endpoint object until completion, to prevent the very case where the callback completes and the ucxx::Request reference the user was supposed to own was accidentally dropped, leading to undefined behavior. Adding the test was done after we were inquired by a user whether this is a valid pattern or not.

We intentionally left any documentation updates out to prevent encouraging that usage pattern until we can decide whether this is a good idea or not. Relying solely on ucs_status_t passed to the user callback can be problematic to some requests such as ucxx::Endpoint::amRecv, since it requires that the user retrieve the resulting buffer from the returned ucxx::RequestAm, and if this is discarded the buffer is lost. For requests such as ucxx::Endpoint::amRecv, it might be worth studying whether we could pass the resulting buffer and any other attributes associated with it to the user callback, in that case we may be able to provide a safe pattern to always use the callback if the user doesn't want to keep a referencce to the returned ucxx::Request object.

@wence-
Copy link
Contributor

wence- commented Aug 21, 2024

I think no. In theory the user shouldn't be interacting directly with the ucs types, right? It only happens to work for this particular case of tagSend/tagRecv right now. But if we support it, it might preclude future changes in the API.

@pentschev
Copy link
Member Author

I think no. In theory the user shouldn't be interacting directly with the ucs types, right?

Yes and no, I see your point but getStatus currently returns ucs_status_t, which is the same we pass to the callback, so currently this is "the right way" for either the user callback and getStatus. Perhaps we should indeed think of a wrapper to ucs_status_t, I avoided that though because we don't extend it at the moment.

It only happens to work for this particular case of tagSend/tagRecv right now. But if we support it, it might preclude future changes in the API.

It only happens to work for tagSend/tagRecv because a user callback was not implemented for other request types, but we could (and perhaps should?) to ensure a consistent API. I'm not sure I follow which future changes in the API you're referring to, are you talking about UCXX or UCX API changes?

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

No branches or pull requests

2 participants