Skip to content

Commit

Permalink
Use the status of first failing request in ucxx::RequestTagMulti
Browse files Browse the repository at this point in the history
The status of `ucxx::RequestTagMulti` was until now always
`UCS_INPROGRESS` or `UCS_OK` after completing. This is not right but
there is no good way to combine the statuses of all underlying
requests. Therefore we now set the status of the first failing request
as the final status instead of `UCS_OK` if at least one of the requests
failed. The user can still check each underlying's request status if
granular information is required.
  • Loading branch information
pentschev committed Jul 28, 2023
1 parent ad9cc9b commit 63d97f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion cpp/include/ucxx/request_tag_multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ class RequestTagMulti : public Request {
*
* When this method is called, the request that completed will be pushed into a container
* which will be later used to evaluate if all frames completed and set the final status
* of the multi-transfer request and the Python future, if enabled.
* of the multi-transfer request and the Python future, if enabled. The final status is
* either `UCS_OK` if all underlying requests completed successfully, otherwise it will
* contain the status of the first failing request, for granular information the user
* may still verify each of the underlying requests individually.
*
* @param[in] status the status of the request being completed.
* @param[in] request the `ucxx::BufferRequest` object containing a single tag .
Expand Down
13 changes: 11 additions & 2 deletions cpp/src/request_tag_multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,17 @@ void RequestTagMulti::markCompleted(ucs_status_t status, RequestCallbackUserData
++_completedRequests;

if (_completedRequests == _totalFrames) {
// TODO: Actually handle errors
setStatus(UCS_OK);
auto s = UCS_OK;

// Get the first non-UCS_OK status and set that as complete status
for (const auto& br : _bufferRequests) {
if (br->request) {
s = br->request->getStatus();
if (s != UCS_OK) break;
}
}

setStatus(s);
}

ucxx_trace_req("RequestTagMulti::markCompleted request: %p, tag: %lx, completed: %lu/%lu",
Expand Down

0 comments on commit 63d97f5

Please sign in to comment.