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

Adding testRecv and testSend for unbounded_buffer #324

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions gloo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ list(APPEND GLOO_HDRS
"${CMAKE_CURRENT_SOURCE_DIR}/broadcast_one_to_all.h"
"${CMAKE_CURRENT_SOURCE_DIR}/context.h"
"${CMAKE_CURRENT_SOURCE_DIR}/gather.h"
"${CMAKE_CURRENT_SOURCE_DIR}/gatherv.h"
"${CMAKE_CURRENT_SOURCE_DIR}/math.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pairwise_exchange.h"
"${CMAKE_CURRENT_SOURCE_DIR}/reduce.h"
Expand Down
6 changes: 6 additions & 0 deletions gloo/transport/tcp/unbound_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ void UnboundBuffer::throwIfException() {
std::rethrow_exception(ex_);
}
}
bool UnboundBuffer::testRecv() {
return recvCompletions_ != 0;
}
bool UnboundBuffer::testSend() {
return sendCompletions_ != 0;
}

} // namespace tcp
} // namespace transport
Expand Down
3 changes: 3 additions & 0 deletions gloo/transport/tcp/unbound_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class UnboundBuffer : public ::gloo::transport::UnboundBuffer {
void handleRecvCompletion(int rank);
void handleSendCompletion(int rank);

bool testRecv() override;
bool testSend() override;

protected:
std::shared_ptr<Context> context_;

Expand Down
7 changes: 7 additions & 0 deletions gloo/transport/unbound_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
* LICENSE file in the root directory of this source tree.
*/

#include <cstdlib>
#include "gloo/transport/unbound_buffer.h"

namespace gloo {
namespace transport {

// Have to provide implementation for pure virtual destructor.
UnboundBuffer::~UnboundBuffer() {}
bool UnboundBuffer::testRecv() {
abort();
}
bool UnboundBuffer::testSend() {
abort();
}

} // namespace transport
} // namespace gloo
8 changes: 8 additions & 0 deletions gloo/transport/unbound_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ class UnboundBuffer {
uint64_t slot,
size_t offset = 0,
size_t nbytes = kUnspecifiedByteCount) = 0;

// Tests if a reception is possibly complete. Only valid if called after
// `recv` and before `waitRecv`
virtual bool testRecv();

// Tests if a sending is possibly complete. Only valid if called after
// `send` and before `waitSend`
virtual bool testSend();
};

} // namespace transport
Expand Down