Skip to content

Commit

Permalink
changed from byte[] to vector on recv side to mirror sends
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-dozier committed Jun 10, 2024
1 parent 6a6f4ae commit 6ae32e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/ygm/comm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class comm {

void flush_to_capacity();

void post_new_irecv(std::shared_ptr<std::byte[]> &recv_buffer);
void post_new_irecv(std::shared_ptr<std::vector<std::byte>> &recv_buffer);

template <typename Lambda, typename... PackArgs>
size_t pack_lambda(std::vector<std::byte> &packed, Lambda l,
Expand All @@ -189,7 +189,7 @@ class comm {
void queue_message_bytes(const std::vector<std::byte> &packed,
const int dest);

void handle_next_receive(std::shared_ptr<std::byte[]> buffer,
void handle_next_receive(std::shared_ptr<std::vector<std::byte>> buffer,
const size_t buffer_size);

bool process_receive_queue();
Expand Down
14 changes: 7 additions & 7 deletions include/ygm/detail/comm.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
namespace ygm {

struct comm::mpi_irecv_request {
std::shared_ptr<std::byte[]> buffer;
MPI_Request request;
std::shared_ptr<std::vector<std::byte>> buffer;
MPI_Request request;
};

struct comm::mpi_isend_request {
Expand Down Expand Up @@ -55,7 +55,7 @@ inline void comm::comm_setup(MPI_Comm c) {
}

for (size_t i = 0; i < config.num_irecvs; ++i) {
std::shared_ptr<std::byte[]> recv_buffer{new std::byte[config.irecv_size]};
std::shared_ptr<std::vector<std::byte>> recv_buffer{new std::vector<std::byte>(config.irecv_size)};
post_new_irecv(recv_buffer);
}
}
Expand Down Expand Up @@ -626,12 +626,12 @@ inline void comm::flush_to_capacity() {
}
}

inline void comm::post_new_irecv(std::shared_ptr<std::byte[]> &recv_buffer) {
inline void comm::post_new_irecv(std::shared_ptr<std::vector<std::byte>> &recv_buffer) {
mpi_irecv_request recv_req;
recv_req.buffer = recv_buffer;

//::madvise(recv_req.buffer.get(), config.irecv_size, MADV_DONTNEED);
ASSERT_MPI(MPI_Irecv(recv_req.buffer.get(), config.irecv_size, MPI_BYTE,
ASSERT_MPI(MPI_Irecv(recv_req.buffer.get()->data(), config.irecv_size, MPI_BYTE,
MPI_ANY_SOURCE, MPI_ANY_TAG, m_comm_async,
&(recv_req.request)));
m_recv_queue.push_back(recv_req);
Expand Down Expand Up @@ -862,9 +862,9 @@ inline void comm::queue_message_bytes(const std::vector<std::byte> &packed,
m_send_buffer_bytes += packed.size();
}

inline void comm::handle_next_receive(std::shared_ptr<std::byte[]> buffer,
inline void comm::handle_next_receive(std::shared_ptr<std::vector<std::byte>> buffer,
const size_t buffer_size) {
cereal::YGMInputArchive iarchive(buffer.get(), buffer_size);
cereal::YGMInputArchive iarchive(buffer.get()->data(), buffer_size);
while (!iarchive.empty()) {
if (config.routing != detail::routing_type::NONE) {
header_t h;
Expand Down

0 comments on commit 6ae32e0

Please sign in to comment.