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

Test tag user callback with discarded return #267

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions cpp/tests/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,49 @@ TEST_P(RequestTest, TagUserCallback)

for (const auto request : requests)
ASSERT_THAT(request->getStatus(), UCS_OK);
for (const auto status : requestStatus)
ASSERT_THAT(status, UCS_OK);

// Assert data correctness
ASSERT_THAT(_recv[0], ContainerEq(_send[0]));
}

TEST_P(RequestTest, TagUserCallbackDiscardReturn)
{
allocate();

std::vector<ucs_status_t> requestStatus(2, UCS_INPROGRESS);

auto checkStatus = [&requestStatus](ucs_status_t status, ::ucxx::RequestCallbackUserData data) {
auto idx = *std::static_pointer_cast<size_t>(data);
requestStatus[idx] = status;
};

auto checkCompletion = [&requestStatus, this]() {
std::vector<size_t> completed(2, 0);
while (std::accumulate(completed.begin(), completed.end(), 0) != 2) {
_progressWorker();
std::transform(
requestStatus.begin(), requestStatus.end(), completed.begin(), [](ucs_status_t status) {
return status == UCS_INPROGRESS ? 0 : 1;
});
}
};

auto sendIndex = std::make_shared<size_t>(0u);
auto recvIndex = std::make_shared<size_t>(1u);

// Submit and wait for transfers to complete
std::ignore =
_ep->tagSend(_sendPtr[0], _messageSize, ucxx::Tag{0}, false, checkStatus, sendIndex);
std::ignore = _ep->tagRecv(
_recvPtr[0], _messageSize, ucxx::Tag{0}, ucxx::TagMaskFull, false, checkStatus, recvIndex);
checkCompletion();

copyResults();

for (const auto status : requestStatus)
ASSERT_THAT(status, UCS_OK);

// Assert data correctness
ASSERT_THAT(_recv[0], ContainerEq(_send[0]));
Expand Down