Skip to content

Commit

Permalink
#2063: Update void* to std::byte* in ActiveMessenger
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable authored and cwschilly committed Sep 20, 2024
1 parent 4600cbc commit 238c00d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions src/vt/messaging/active.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ trace::TraceEventIDType ActiveMessenger::makeTraceCreationSend(
}

MsgSizeType ActiveMessenger::packMsg(
MessageType* msg, MsgSizeType size, void* ptr, MsgSizeType ptr_bytes
MessageType* msg, MsgSizeType size, std::byte* ptr, MsgSizeType ptr_bytes
) {
vt_debug_print(
verbose, active,
Expand Down Expand Up @@ -260,7 +260,7 @@ EventType ActiveMessenger::sendMsgBytesWithPut(
);
}
if (direct_buf_pack) {
new_msg_size = packMsg(msg, base.size(), put_ptr, put_size);
new_msg_size = packMsg(msg, base.size(), reinterpret_cast<std::byte*>(put_ptr), put_size);
} else {
auto const& env_tag = envelopeGetPutTag(msg->env);
auto const& ret = sendData(
Expand Down Expand Up @@ -670,7 +670,7 @@ bool ActiveMessenger::tryProcessDataMsgRecv() {
}

bool ActiveMessenger::recvDataMsgBuffer(
int nchunks, void* const user_buf, TagType const& tag,
int nchunks, std::byte* const user_buf, TagType const& tag,
NodeType const& node, bool const& enqueue, ActionType dealloc,
ContinuationDeleterType next, bool is_user_buf
) {
Expand All @@ -681,7 +681,7 @@ bool ActiveMessenger::recvDataMsgBuffer(
}

bool ActiveMessenger::recvDataMsgBuffer(
int nchunks, void* const user_buf, PriorityType priority, TagType const& tag,
int nchunks, std::byte* const user_buf, PriorityType priority, TagType const& tag,
NodeType const& node, bool const& enqueue, ActionType dealloc_user_buf,
ContinuationDeleterType next, bool is_user_buf
) {
Expand All @@ -702,9 +702,9 @@ bool ActiveMessenger::recvDataMsgBuffer(
if (flag == 1) {
MPI_Get_count(&stat, MPI_BYTE, &num_probe_bytes);

char* buf = user_buf == nullptr ?
static_cast<char*>(thePool()->alloc(num_probe_bytes)) :
static_cast<char*>(user_buf);
std::byte* buf = user_buf == nullptr ?
reinterpret_cast<std::byte*>(thePool()->alloc(num_probe_bytes)) :
user_buf;

NodeType const sender = stat.MPI_SOURCE;

Expand All @@ -730,7 +730,7 @@ bool ActiveMessenger::recvDataMsgBuffer(
std::forward_as_tuple(tag),
std::forward_as_tuple(
PendingRecvType{
nchunks, reinterpret_cast<std::byte*>(user_buf), next, dealloc_user_buf, node, priority,
nchunks, user_buf, next, dealloc_user_buf, node, priority,
is_user_buf
}
)
Expand All @@ -743,15 +743,15 @@ void ActiveMessenger::recvDataDirect(
int nchunks, TagType const tag, NodeType const from, MsgSizeType len,
ContinuationDeleterType next
) {
char* buf = static_cast<char*>(thePool()->alloc(len));
std::byte* buf = reinterpret_cast<std::byte*>(thePool()->alloc(len));

recvDataDirect(
nchunks, buf, tag, from, len, default_priority, nullptr, next, false
);
}

void ActiveMessenger::recvDataDirect(
int nchunks, void* const buf, TagType const tag, NodeType const from,
int nchunks, std::byte* const buf, TagType const tag, NodeType const from,
MsgSizeType len, PriorityType prio, ActionType dealloc,
ContinuationDeleterType next, bool is_user_buf
) {
Expand All @@ -760,7 +760,7 @@ void ActiveMessenger::recvDataDirect(
std::vector<MPI_Request> reqs;
reqs.resize(nchunks);

char* cbuf = static_cast<char*>(buf);
char* cbuf = reinterpret_cast<char*>(buf);
MsgSizeType remainder = len;
auto const max_per_send = theConfig()->vt_max_mpi_send_size;
for (int i = 0; i < nchunks; i++) {
Expand Down Expand Up @@ -801,7 +801,7 @@ void ActiveMessenger::recvDataDirect(
}

InProgressDataIRecv recv{
reinterpret_cast<std::byte*>(cbuf), len, from, std::move(reqs), is_user_buf ? reinterpret_cast<std::byte*>(buf) : nullptr, dealloc,
reinterpret_cast<std::byte*>(cbuf), len, from, std::move(reqs), is_user_buf ? buf : nullptr, dealloc,
next, prio
};

Expand Down
8 changes: 4 additions & 4 deletions src/vt/messaging/active.h
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
* \return the new size of the message
*/
MsgSizeType packMsg(
MessageType* msg, MsgSizeType size, void* ptr, MsgSizeType ptr_bytes
MessageType* msg, MsgSizeType size, std::byte* ptr, MsgSizeType ptr_bytes
);

/**
Expand Down Expand Up @@ -1335,7 +1335,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
* \return whether the data is ready or pending
*/
bool recvDataMsgBuffer(
int nchunks, void* const user_buf, PriorityType priority, TagType const& tag,
int nchunks, std::byte* const user_buf, PriorityType priority, TagType const& tag,
NodeType const& node = uninitialized_destination, bool const& enqueue = true,
ActionType dealloc_user_buf = nullptr,
ContinuationDeleterType next = nullptr, bool is_user_buf = false
Expand All @@ -1357,7 +1357,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
* \return whether the data is ready or pending
*/
bool recvDataMsgBuffer(
int nchunks, void* const user_buf, TagType const& tag,
int nchunks, std::byte* const user_buf, TagType const& tag,
NodeType const& node = uninitialized_destination, bool const& enqueue = true,
ActionType dealloc_user_buf = nullptr,
ContinuationDeleterType next = nullptr, bool is_user_buf = false
Expand All @@ -1377,7 +1377,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
* \param[in] is_user_buf is a user buffer that require user deallocation
*/
void recvDataDirect(
int nchunks, void* const buf, TagType const tag, NodeType const from,
int nchunks, std::byte* const buf, TagType const tag, NodeType const from,
MsgSizeType len, PriorityType prio, ActionType dealloc = nullptr,
ContinuationDeleterType next = nullptr, bool is_user_buf = false
);
Expand Down
4 changes: 2 additions & 2 deletions src/vt/rdma/rdma.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ RDMAManager::RDMAManager()
);
} else {
theMsg()->recvDataMsgBuffer(
msg->nchunks, get_ptr, msg->mpi_tag_to_recv, msg->send_back, true,
msg->nchunks, reinterpret_cast<std::byte*>(get_ptr), msg->mpi_tag_to_recv, msg->send_back, true,
[get_ptr_action]{
vt_debug_print(
normal, rdma,
Expand Down Expand Up @@ -241,7 +241,7 @@ RDMAManager::RDMAManager()
msg->offset != no_byte ? static_cast<char*>(put_ptr) + msg->offset : put_ptr;
// do a direct recv into the user buffer
theMsg()->recvDataMsgBuffer(
msg->nchunks, put_ptr_offset, recv_tag, recv_node, true, []{},
msg->nchunks, reinterpret_cast<std::byte*>(put_ptr_offset), recv_tag, recv_node, true, []{},
[=](RDMA_GetType ptr, ActionType deleter){
vt_debug_print(
normal, rdma,
Expand Down

0 comments on commit 238c00d

Please sign in to comment.