From 447a129065a9816e572feb099467bc4db75bf3d1 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Wed, 13 Mar 2024 15:24:00 +0100 Subject: [PATCH 01/23] #2063: Update char* to std::byte* in pool_header --- src/vt/pool/header/pool_header.cc | 10 +++---- src/vt/pool/header/pool_header.h | 12 ++++----- src/vt/pool/pool.cc | 26 +++++++++---------- .../static_sized/memory_pool_equal.impl.h | 4 +-- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/vt/pool/header/pool_header.cc b/src/vt/pool/header/pool_header.cc index fd0ff7cdf6..cdc249ec7c 100644 --- a/src/vt/pool/header/pool_header.cc +++ b/src/vt/pool/header/pool_header.cc @@ -47,8 +47,8 @@ namespace vt { namespace pool { -/*static*/ char* HeaderManager::setHeader( - size_t const& num_bytes, size_t const& oversize, char* buffer +/*static*/ std::byte* HeaderManager::setHeader( + size_t const& num_bytes, size_t const& oversize, std::byte* buffer ) { AllocView view; view.buffer = buffer; @@ -58,19 +58,19 @@ namespace vt { namespace pool { return buf_start; } -/*static*/ size_t HeaderManager::getHeaderBytes(char* buffer) { +/*static*/ size_t HeaderManager::getHeaderBytes(std::byte* buffer) { AllocView view; view.buffer = buffer - sizeof(Header); return view.layout->prealloc.alloc_size; } -/*static*/ size_t HeaderManager::getHeaderOversizeBytes(char* buffer) { +/*static*/ size_t HeaderManager::getHeaderOversizeBytes(std::byte* buffer) { AllocView view; view.buffer = buffer - sizeof(Header); return view.layout->prealloc.oversize; } -/*static*/ char* HeaderManager::getHeaderPtr(char* buffer) { +/*static*/ std::byte* HeaderManager::getHeaderPtr(std::byte* buffer) { return buffer - sizeof(Header); } diff --git a/src/vt/pool/header/pool_header.h b/src/vt/pool/header/pool_header.h index fbba10a23f..d5d6006081 100644 --- a/src/vt/pool/header/pool_header.h +++ b/src/vt/pool/header/pool_header.h @@ -59,16 +59,16 @@ struct AllocLayout { union AllocView { AllocLayout* layout; - char* buffer; + std::byte* buffer; }; struct HeaderManager { - static char* setHeader( - size_t const& num_bytes, size_t const& oversize, char* buffer + static std::byte* setHeader( + size_t const& num_bytes, size_t const& oversize, std::byte* buffer ); - static size_t getHeaderBytes(char* buffer); - static size_t getHeaderOversizeBytes(char* buffer); - static char* getHeaderPtr(char* buffer); + static size_t getHeaderBytes(std::byte* buffer); + static size_t getHeaderOversizeBytes(std::byte* buffer); + static std::byte* getHeaderPtr(std::byte* buffer); }; }} /* end namespace vt::pool */ diff --git a/src/vt/pool/pool.cc b/src/vt/pool/pool.cc index 98a6c7aaa7..9d5d99277a 100644 --- a/src/vt/pool/pool.cc +++ b/src/vt/pool/pool.cc @@ -90,9 +90,9 @@ void* Pool::tryPooledAlloc(size_t const& num_bytes, size_t const& oversize) { } bool Pool::tryPooledDealloc(void* const buf) { - auto buf_char = static_cast(buf); - auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf_char); - auto const& oversize = HeaderManagerType::getHeaderOversizeBytes(buf_char); + auto buf_byte = reinterpret_cast(buf); + auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf_byte); + auto const& oversize = HeaderManagerType::getHeaderOversizeBytes(buf_byte); ePoolSize const pool_type = getPoolType(actual_alloc_size, oversize); if (pool_type != ePoolSize::Malloc) { @@ -147,7 +147,7 @@ void Pool::poolDealloc(void* const buf, ePoolSize const pool_type) { void* Pool::defaultAlloc(size_t const& num_bytes, size_t const& oversize) { auto alloc_buf = std::malloc(num_bytes + oversize + sizeof(HeaderType)); return HeaderManagerType::setHeader( - num_bytes, oversize, static_cast(alloc_buf) + num_bytes, oversize, reinterpret_cast(alloc_buf) ); } @@ -178,9 +178,9 @@ void* Pool::alloc(size_t const& num_bytes, size_t oversize) { } void Pool::dealloc(void* const buf) { - auto buf_char = static_cast(buf); - auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf_char); - auto const& ptr_actual = HeaderManagerType::getHeaderPtr(buf_char); + auto buf_byte = reinterpret_cast(buf); + auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf_byte); + auto const& ptr_actual = HeaderManagerType::getHeaderPtr(buf_byte); vt_debug_print( normal, pool, @@ -201,9 +201,9 @@ void Pool::dealloc(void* const buf) { Pool::SizeType Pool::remainingSize(void* const buf) const { #if vt_check_enabled(memory_pool) - auto buf_char = static_cast(buf); - auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf_char); - auto const& oversize = HeaderManagerType::getHeaderOversizeBytes(buf_char); + auto buf_byte = reinterpret_cast(buf); + auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf_byte); + auto const& oversize = HeaderManagerType::getHeaderOversizeBytes(buf_byte); ePoolSize const pool_type = getPoolType(actual_alloc_size, oversize); @@ -220,8 +220,8 @@ Pool::SizeType Pool::remainingSize(void* const buf) const { } Pool::SizeType Pool::allocatedSize(void* const buf) const { - auto buf_char = static_cast(buf); - return HeaderManagerType::getHeaderBytes(buf_char) + HeaderManagerType::getHeaderOversizeBytes(buf_char); + auto buf_byte = reinterpret_cast(buf); + return HeaderManagerType::getHeaderBytes(buf_byte) + HeaderManagerType::getHeaderOversizeBytes(buf_byte); } bool @@ -231,7 +231,7 @@ Pool::tryGrowAllocation(void* buf, size_t grow_amount) { if ( remainingSize(buf) < grow_amount ) return false; - auto *header = reinterpret_cast(HeaderManagerType::getHeaderPtr(reinterpret_cast(buf))); + auto *header = reinterpret_cast(HeaderManagerType::getHeaderPtr(reinterpret_cast(buf))); header->alloc_size += grow_amount; return true; } diff --git a/src/vt/pool/static_sized/memory_pool_equal.impl.h b/src/vt/pool/static_sized/memory_pool_equal.impl.h index 47979cf821..8e19c2838c 100644 --- a/src/vt/pool/static_sized/memory_pool_equal.impl.h +++ b/src/vt/pool/static_sized/memory_pool_equal.impl.h @@ -98,7 +98,7 @@ void* MemoryPoolEqual::alloc( void* ptr_ret = ptr; if (use_header) { ptr_ret = HeaderManagerType::setHeader( - sz, oversize, static_cast(ptr) + sz, oversize, reinterpret_cast(ptr) ); } @@ -124,7 +124,7 @@ void MemoryPoolEqual::dealloc(void* const t) { cur_slot_ - 1 >= 0, "Must be greater than zero" ); - auto t_char = static_cast(t); + auto t_char = reinterpret_cast(t); void* ptr_actual = t; if (use_header) { ptr_actual = HeaderManagerType::getHeaderPtr(t_char); From d7b1423ca64574b05d8ba85c247416f784edd4c2 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Wed, 13 Mar 2024 15:54:02 +0100 Subject: [PATCH 02/23] #2063: Update char* to std::byte* in ActiveMessenger objects --- src/vt/messaging/active.cc | 12 ++++++------ src/vt/messaging/active.h | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index a0eca38400..4185fa87af 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -300,7 +300,7 @@ struct MultiMsg : vt::Message { } void ActiveMessenger::handleChunkedMultiMsg(MultiMsg* msg) { - auto buf = static_cast(thePool()->alloc(msg->getSize())); + auto buf = reinterpret_cast(thePool()->alloc(msg->getSize())); auto const size = msg->getSize(); auto const info = msg->getInfo(); @@ -730,7 +730,7 @@ bool ActiveMessenger::recvDataMsgBuffer( std::forward_as_tuple(tag), std::forward_as_tuple( PendingRecvType{ - nchunks, user_buf, next, dealloc_user_buf, node, priority, + nchunks, reinterpret_cast(user_buf), next, dealloc_user_buf, node, priority, is_user_buf } ) @@ -801,7 +801,7 @@ void ActiveMessenger::recvDataDirect( } InProgressDataIRecv recv{ - cbuf, len, from, std::move(reqs), is_user_buf ? buf : nullptr, dealloc, + reinterpret_cast(cbuf), len, from, std::move(reqs), is_user_buf ? reinterpret_cast(buf) : nullptr, dealloc, next, prio }; @@ -838,7 +838,7 @@ void ActiveMessenger::finishPendingDataMsgAsyncRecv(InProgressDataIRecv* irecv) vt_debug_print( normal, active, "finishPendingDataMsgAsyncRecv: continuation user_buf={}, buf={}\n", - user_buf, buf + reinterpret_cast(user_buf), reinterpret_cast(buf) ); if (user_buf == nullptr) { @@ -1032,7 +1032,7 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() { #endif } - InProgressIRecv recv_holder{buf, num_probe_bytes, sender, req}; + InProgressIRecv recv_holder{reinterpret_cast(buf), num_probe_bytes, sender, req}; int num_mpi_tests = 0; auto done = recv_holder.test(num_mpi_tests); @@ -1051,7 +1051,7 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() { } void ActiveMessenger::finishPendingActiveMsgAsyncRecv(InProgressIRecv* irecv) { - char* buf = irecv->buf; + char* buf = reinterpret_cast(irecv->buf); auto num_probe_bytes = irecv->probe_bytes; auto sender = irecv->sender; diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index ca0c9b30d1..af0f1c4296 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -118,7 +118,7 @@ static constexpr MsgSizeType const max_pack_direct_size = 512; */ struct PendingRecv { int nchunks = 0; - void* user_buf = nullptr; + std::byte* user_buf = nullptr; ContinuationDeleterType cont = nullptr; ActionType dealloc_user_buf = nullptr; NodeType sender = uninitialized_destination; @@ -126,7 +126,7 @@ struct PendingRecv { bool is_user_buf = false; PendingRecv( - int in_nchunks, void* in_user_buf, ContinuationDeleterType in_cont, + int in_nchunks, std::byte* in_user_buf, ContinuationDeleterType in_cont, ActionType in_dealloc_user_buf, NodeType node, PriorityType in_priority, bool in_is_user_buf ) : nchunks(in_nchunks), user_buf(in_user_buf), cont(in_cont), @@ -153,7 +153,7 @@ struct PendingRecv { */ struct InProgressBase { InProgressBase( - char* in_buf, MsgSizeType in_probe_bytes, NodeType in_sender + std::byte* in_buf, MsgSizeType in_probe_bytes, NodeType in_sender ) : buf(in_buf), probe_bytes(in_probe_bytes), sender(in_sender), valid(true) { } @@ -166,7 +166,7 @@ struct InProgressBase { | valid; } - char* buf = nullptr; + std::byte* buf = nullptr; MsgSizeType probe_bytes = 0; NodeType sender = uninitialized_destination; bool valid = false; @@ -180,7 +180,7 @@ struct InProgressBase { struct InProgressIRecv : InProgressBase { InProgressIRecv( - char* in_buf, MsgSizeType in_probe_bytes, NodeType in_sender, + std::byte* in_buf, MsgSizeType in_probe_bytes, NodeType in_sender, MPI_Request in_req = MPI_REQUEST_NULL ) : InProgressBase(in_buf, in_probe_bytes, in_sender), req(in_req) @@ -207,8 +207,8 @@ struct InProgressIRecv : InProgressBase { */ struct InProgressDataIRecv : InProgressBase { InProgressDataIRecv( - char* in_buf, MsgSizeType in_probe_bytes, NodeType in_sender, - std::vector in_reqs, void* const in_user_buf, + std::byte* in_buf, MsgSizeType in_probe_bytes, NodeType in_sender, + std::vector in_reqs, std::byte* const in_user_buf, ActionType in_dealloc_user_buf, ContinuationDeleterType in_next, PriorityType in_priority @@ -244,7 +244,7 @@ struct InProgressDataIRecv : InProgressBase { | reqs; } - void* user_buf = nullptr; + std::byte* user_buf = nullptr; ActionType dealloc_user_buf = nullptr; ContinuationDeleterType next = nullptr; PriorityType priority = no_priority; From 58d3f53784f45411ffe0be6b6b0e0d6c5cb6ffb3 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Wed, 13 Mar 2024 16:13:48 +0100 Subject: [PATCH 03/23] #2063: Update void* to std::byte* in ActiveMessenger --- src/vt/messaging/active.cc | 24 ++++++++++++------------ src/vt/messaging/active.h | 8 ++++---- src/vt/rdma/rdma.cc | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index 4185fa87af..6fd8fd3f87 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -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, @@ -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(put_ptr), put_size); } else { auto const& env_tag = envelopeGetPutTag(msg->env); auto const& ret = sendData( @@ -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 ) { @@ -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 ) { @@ -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(thePool()->alloc(num_probe_bytes)) : - static_cast(user_buf); + std::byte* buf = user_buf == nullptr ? + reinterpret_cast(thePool()->alloc(num_probe_bytes)) : + user_buf; NodeType const sender = stat.MPI_SOURCE; @@ -730,7 +730,7 @@ bool ActiveMessenger::recvDataMsgBuffer( std::forward_as_tuple(tag), std::forward_as_tuple( PendingRecvType{ - nchunks, reinterpret_cast(user_buf), next, dealloc_user_buf, node, priority, + nchunks, user_buf, next, dealloc_user_buf, node, priority, is_user_buf } ) @@ -743,7 +743,7 @@ void ActiveMessenger::recvDataDirect( int nchunks, TagType const tag, NodeType const from, MsgSizeType len, ContinuationDeleterType next ) { - char* buf = static_cast(thePool()->alloc(len)); + std::byte* buf = reinterpret_cast(thePool()->alloc(len)); recvDataDirect( nchunks, buf, tag, from, len, default_priority, nullptr, next, false @@ -751,7 +751,7 @@ void ActiveMessenger::recvDataDirect( } 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 ) { @@ -760,7 +760,7 @@ void ActiveMessenger::recvDataDirect( std::vector reqs; reqs.resize(nchunks); - char* cbuf = static_cast(buf); + char* cbuf = reinterpret_cast(buf); MsgSizeType remainder = len; auto const max_per_send = theConfig()->vt_max_mpi_send_size; for (int i = 0; i < nchunks; i++) { @@ -801,7 +801,7 @@ void ActiveMessenger::recvDataDirect( } InProgressDataIRecv recv{ - reinterpret_cast(cbuf), len, from, std::move(reqs), is_user_buf ? reinterpret_cast(buf) : nullptr, dealloc, + reinterpret_cast(cbuf), len, from, std::move(reqs), is_user_buf ? buf : nullptr, dealloc, next, prio }; diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index af0f1c4296..7dc06d164c 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -1235,7 +1235,7 @@ struct ActiveMessenger : runtime::component::PollableComponent * \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 ); /** @@ -1335,7 +1335,7 @@ struct ActiveMessenger : runtime::component::PollableComponent * \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 @@ -1357,7 +1357,7 @@ struct ActiveMessenger : runtime::component::PollableComponent * \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 @@ -1377,7 +1377,7 @@ struct ActiveMessenger : runtime::component::PollableComponent * \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 ); diff --git a/src/vt/rdma/rdma.cc b/src/vt/rdma/rdma.cc index d5ad0924da..d6d79596bc 100644 --- a/src/vt/rdma/rdma.cc +++ b/src/vt/rdma/rdma.cc @@ -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(get_ptr), msg->mpi_tag_to_recv, msg->send_back, true, [get_ptr_action]{ vt_debug_print( normal, rdma, @@ -241,7 +241,7 @@ RDMAManager::RDMAManager() msg->offset != no_byte ? static_cast(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(put_ptr_offset), recv_tag, recv_node, true, []{}, [=](RDMA_GetType ptr, ActionType deleter){ vt_debug_print( normal, rdma, From 0b82273f2a450aa16668a2365c2a5d333ffc540b Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Wed, 13 Mar 2024 16:39:43 +0100 Subject: [PATCH 04/23] #2063: Update void* to std::byte* in Pool --- src/vt/collective/scatter/scatter.cc | 2 +- src/vt/collective/scatter/scatter.impl.h | 2 +- src/vt/messaging/active.cc | 6 +-- src/vt/messaging/message/message.h | 2 +- src/vt/messaging/message/smart_ptr.h | 2 +- src/vt/pool/pool.cc | 58 +++++++++++------------- src/vt/pool/pool.h | 22 ++++----- tests/unit/pool/test_pool.cc | 6 +-- 8 files changed, 48 insertions(+), 52 deletions(-) diff --git a/src/vt/collective/scatter/scatter.cc b/src/vt/collective/scatter/scatter.cc index 1d9ee9dde0..280d429660 100644 --- a/src/vt/collective/scatter/scatter.cc +++ b/src/vt/collective/scatter/scatter.cc @@ -100,7 +100,7 @@ void Scatter::scatterIn(ScatterMsg* msg) { child, num_children, child_bytes_size ); auto const child_remaining_size = - thePool()->remainingSize(reinterpret_cast(child_msg.get())); + thePool()->remainingSize(reinterpret_cast(child_msg.get())); child_msg->user_han = user_handler; auto ptr = reinterpret_cast(child_msg.get()) + sizeof(ScatterMsg); vt_debug_print( diff --git a/src/vt/collective/scatter/scatter.impl.h b/src/vt/collective/scatter/scatter.impl.h index 8423d08177..7d1fb7d896 100644 --- a/src/vt/collective/scatter/scatter.impl.h +++ b/src/vt/collective/scatter/scatter.impl.h @@ -68,7 +68,7 @@ void Scatter::scatter( auto ptr = reinterpret_cast(scatter_msg.get()) + sizeof(ScatterMsg); #if vt_check_enabled(memory_pool) auto remaining_size = - thePool()->remainingSize(reinterpret_cast(scatter_msg.get())); + thePool()->remainingSize(reinterpret_cast(scatter_msg.get())); vtAssertInfo( remaining_size >= combined_size, "Remaining size must be sufficient", total_size, combined_size, remaining_size, elm_size diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index 6fd8fd3f87..4cc9bcd7f3 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -192,7 +192,7 @@ MsgSizeType ActiveMessenger::packMsg( size, ptr_bytes, print_ptr(ptr) ); - auto const can_grow = thePool()->tryGrowAllocation(msg, ptr_bytes); + auto const can_grow = thePool()->tryGrowAllocation(reinterpret_cast(msg), ptr_bytes); // Typically this should be checked by the caller in advance vtAssert(can_grow, "not enough space to pack message" ); @@ -236,7 +236,7 @@ EventType ActiveMessenger::sendMsgBytesWithPut( auto const& put_ptr = envelopeGetPutPtr(msg->env); auto const& put_size = envelopeGetPutSize(msg->env); bool const& memory_pool_active = thePool()->active_env(); - auto const& rem_size = thePool()->remainingSize(msg); + auto const& rem_size = thePool()->remainingSize(reinterpret_cast(msg)); /* * Directly pack if the pool is active (which means it may have * overallocated and the remaining size of the (envelope) buffer is @@ -998,7 +998,7 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() { if (flag == 1) { MPI_Get_count(&stat, MPI_BYTE, &num_probe_bytes); - char* buf = static_cast(thePool()->alloc(num_probe_bytes)); + char* buf = reinterpret_cast(thePool()->alloc(num_probe_bytes)); NodeType const sender = stat.MPI_SOURCE; diff --git a/src/vt/messaging/message/message.h b/src/vt/messaging/message/message.h index 86597fabc5..63cac620f9 100644 --- a/src/vt/messaging/message/message.h +++ b/src/vt/messaging/message/message.h @@ -154,7 +154,7 @@ struct ActiveMsg : BaseMsg { "Message::delete of ptr={}\n", print_ptr(ptr) ); - return thePool()->dealloc(ptr); + return thePool()->dealloc(reinterpret_cast(ptr)); } /** diff --git a/src/vt/messaging/message/smart_ptr.h b/src/vt/messaging/message/smart_ptr.h index b7d69eabf9..a3f9186244 100644 --- a/src/vt/messaging/message/smart_ptr.h +++ b/src/vt/messaging/message/smart_ptr.h @@ -211,7 +211,7 @@ struct MsgSharedPtr final { // Obtain the size of the message from the block allocated by the // memory pool allocator - return thePool()->allocatedSize(ptr_); + return thePool()->allocatedSize(reinterpret_cast(ptr_)); } /** diff --git a/src/vt/pool/pool.cc b/src/vt/pool/pool.cc index 9d5d99277a..3b20a7949d 100644 --- a/src/vt/pool/pool.cc +++ b/src/vt/pool/pool.cc @@ -79,7 +79,7 @@ Pool::ePoolSize Pool::getPoolType( } } -void* Pool::tryPooledAlloc(size_t const& num_bytes, size_t const& oversize) { +std::byte* Pool::tryPooledAlloc(size_t const& num_bytes, size_t const& oversize) { ePoolSize const pool_type = getPoolType(num_bytes, oversize); if (pool_type != ePoolSize::Malloc) { @@ -89,10 +89,9 @@ void* Pool::tryPooledAlloc(size_t const& num_bytes, size_t const& oversize) { } } -bool Pool::tryPooledDealloc(void* const buf) { - auto buf_byte = reinterpret_cast(buf); - auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf_byte); - auto const& oversize = HeaderManagerType::getHeaderOversizeBytes(buf_byte); +bool Pool::tryPooledDealloc(std::byte* const buf) { + auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf); + auto const& oversize = HeaderManagerType::getHeaderOversizeBytes(buf); ePoolSize const pool_type = getPoolType(actual_alloc_size, oversize); if (pool_type != ePoolSize::Malloc) { @@ -103,23 +102,23 @@ bool Pool::tryPooledDealloc(void* const buf) { } } -void* Pool::pooledAlloc( +std::byte* Pool::pooledAlloc( size_t const& num_bytes, size_t const& oversize, ePoolSize const pool_type ) { - void* ret = nullptr; + std::byte* ret = nullptr; vt_debug_print( normal, pool, "Pool::pooled_alloc of size={}, type={}, ret={}\n", - num_bytes, print_pool_type(pool_type), ret + num_bytes, print_pool_type(pool_type), print_ptr(ret) ); if (pool_type == ePoolSize::Small) { auto pool = small_msg.get(); - ret = pool->alloc(num_bytes, oversize); + ret = reinterpret_cast(pool->alloc(num_bytes, oversize)); } else if (pool_type == ePoolSize::Medium) { auto pool = medium_msg.get(); - ret = pool->alloc(num_bytes, oversize); + ret = reinterpret_cast(pool->alloc(num_bytes, oversize)); } else { vtAssert(0, "Pool must be valid"); ret = nullptr; @@ -128,7 +127,7 @@ void* Pool::pooledAlloc( return ret; } -void Pool::poolDealloc(void* const buf, ePoolSize const pool_type) { +void Pool::poolDealloc(std::byte* const buf, ePoolSize const pool_type) { vt_debug_print( normal, pool, "Pool::pooled_dealloc of ptr={}, type={}\n", @@ -144,19 +143,19 @@ void Pool::poolDealloc(void* const buf, ePoolSize const pool_type) { } } -void* Pool::defaultAlloc(size_t const& num_bytes, size_t const& oversize) { +std::byte* Pool::defaultAlloc(size_t const& num_bytes, size_t const& oversize) { auto alloc_buf = std::malloc(num_bytes + oversize + sizeof(HeaderType)); return HeaderManagerType::setHeader( num_bytes, oversize, reinterpret_cast(alloc_buf) ); } -void Pool::defaultDealloc(void* const ptr) { - std::free(ptr); +void Pool::defaultDealloc(std::byte* const ptr) { + std::free(reinterpret_cast(ptr)); } -void* Pool::alloc(size_t const& num_bytes, size_t oversize) { - void* ret = nullptr; +std::byte* Pool::alloc(size_t const& num_bytes, size_t oversize) { + std::byte* ret = nullptr; #if vt_check_enabled(memory_pool) ret = tryPooledAlloc(num_bytes, oversize); @@ -171,21 +170,20 @@ void* Pool::alloc(size_t const& num_bytes, size_t oversize) { vt_debug_print( normal, pool, "Pool::alloc of size={}, ret={}\n", - num_bytes, ret + num_bytes, print_ptr(ret) ); return ret; } -void Pool::dealloc(void* const buf) { - auto buf_byte = reinterpret_cast(buf); - auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf_byte); - auto const& ptr_actual = HeaderManagerType::getHeaderPtr(buf_byte); +void Pool::dealloc(std::byte* const buf) { + auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf); + auto const& ptr_actual = HeaderManagerType::getHeaderPtr(buf); vt_debug_print( normal, pool, "Pool::dealloc of buf={}, alloc_size={}, ptr={}\n", - buf, actual_alloc_size, print_ptr(ptr_actual) + print_ptr(buf), actual_alloc_size, print_ptr(ptr_actual) ); bool success = false; @@ -199,11 +197,10 @@ void Pool::dealloc(void* const buf) { } } -Pool::SizeType Pool::remainingSize(void* const buf) const { +Pool::SizeType Pool::remainingSize(std::byte* const buf) const { #if vt_check_enabled(memory_pool) - auto buf_byte = reinterpret_cast(buf); - auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf_byte); - auto const& oversize = HeaderManagerType::getHeaderOversizeBytes(buf_byte); + auto const& actual_alloc_size = HeaderManagerType::getHeaderBytes(buf); + auto const& oversize = HeaderManagerType::getHeaderOversizeBytes(buf); ePoolSize const pool_type = getPoolType(actual_alloc_size, oversize); @@ -219,19 +216,18 @@ Pool::SizeType Pool::remainingSize(void* const buf) const { #endif } -Pool::SizeType Pool::allocatedSize(void* const buf) const { - auto buf_byte = reinterpret_cast(buf); - return HeaderManagerType::getHeaderBytes(buf_byte) + HeaderManagerType::getHeaderOversizeBytes(buf_byte); +Pool::SizeType Pool::allocatedSize(std::byte* const buf) const { + return HeaderManagerType::getHeaderBytes(buf) + HeaderManagerType::getHeaderOversizeBytes(buf); } bool -Pool::tryGrowAllocation(void* buf, size_t grow_amount) { +Pool::tryGrowAllocation(std::byte* buf, size_t grow_amount) { // For non-pooled alloc, this condition will always be true // since remainingSize(buf) would be 0 if ( remainingSize(buf) < grow_amount ) return false; - auto *header = reinterpret_cast(HeaderManagerType::getHeaderPtr(reinterpret_cast(buf))); + auto *header = reinterpret_cast(HeaderManagerType::getHeaderPtr(buf)); header->alloc_size += grow_amount; return true; } diff --git a/src/vt/pool/pool.h b/src/vt/pool/pool.h index 3983bedf43..ab3f8268f1 100644 --- a/src/vt/pool/pool.h +++ b/src/vt/pool/pool.h @@ -99,14 +99,14 @@ struct Pool : runtime::component::Component { * * \return pointer to new allocation */ - void* alloc(size_t const& num_bytes, size_t oversize = 0); + std::byte* alloc(size_t const& num_bytes, size_t oversize = 0); /** * \brief De-allocate a pool-allocated buffer * * \param[in] buf the buffer to deallocate */ - void dealloc(void* const buf); + void dealloc(std::byte* const buf); /** * \internal \brief Decided which pool bucket to target based on size @@ -130,7 +130,7 @@ struct Pool : runtime::component::Component { * * \return number of extra bytes */ - SizeType remainingSize(void* const buf) const; + SizeType remainingSize(std::byte* const buf) const; /** * \internal \brief Get total allocated bytes for a pool allocation @@ -141,7 +141,7 @@ struct Pool : runtime::component::Component { * * \return the total number of allocated bytes */ - SizeType allocatedSize(void* const buf) const; + SizeType allocatedSize(std::byte* const buf) const; /** * \internal \brief Attempt to increase the size of an allocation without reallocating @@ -157,7 +157,7 @@ struct Pool : runtime::component::Component { * \return false if the grow_amount is too large for the allocated block, true if the operation * succeeded */ - bool tryGrowAllocation(void* const buf, size_t grow_amount); + bool tryGrowAllocation(std::byte* const buf, size_t grow_amount); /** * \brief Whether the pool is enabled at compile-time @@ -190,7 +190,7 @@ struct Pool : runtime::component::Component { * * \return a pointer to memory if succeeds */ - void* tryPooledAlloc(size_t const& num_bytes, size_t const& oversize); + std::byte* tryPooledAlloc(size_t const& num_bytes, size_t const& oversize); /** * \internal \brief Attempt to de-allocate a buffer @@ -199,7 +199,7 @@ struct Pool : runtime::component::Component { * * \return whether it succeeded or wasn't allocated by the pool */ - bool tryPooledDealloc(void* const buf); + bool tryPooledDealloc(std::byte* const buf); /** * \internal \brief Allocate memory from a specific pool @@ -210,7 +210,7 @@ struct Pool : runtime::component::Component { * * \return the buffer allocated */ - void* pooledAlloc( + std::byte* pooledAlloc( size_t const& num_bytes, size_t const& oversize, ePoolSize const pool_type ); @@ -220,7 +220,7 @@ struct Pool : runtime::component::Component { * \param[in] buf the buffer * \param[in] pool_type which pool to target */ - void poolDealloc(void* const buf, ePoolSize const pool_type); + void poolDealloc(std::byte* const buf, ePoolSize const pool_type); /** * \internal \brief Allocate from standard allocator @@ -230,14 +230,14 @@ struct Pool : runtime::component::Component { * * \return the allocated buffer */ - void* defaultAlloc(size_t const& num_bytes, size_t const& oversize); + std::byte* defaultAlloc(size_t const& num_bytes, size_t const& oversize); /** * \internal \brief De-allocate from standard allocator * * \param[in] ptr buffer to deallocate */ - void defaultDealloc(void* const ptr); + void defaultDealloc(std::byte* const ptr); private: using MemPoolSType = MemoryPoolPtrType; diff --git a/tests/unit/pool/test_pool.cc b/tests/unit/pool/test_pool.cc index f15fbadff7..81aaadebbd 100644 --- a/tests/unit/pool/test_pool.cc +++ b/tests/unit/pool/test_pool.cc @@ -107,12 +107,12 @@ TEST_F(TestPool, pool_alloc) { std::unique_ptr testPool = std::make_unique(); for (size_t cur_bytes = 1; cur_bytes < max_bytes; cur_bytes *= 2) { - void* ptr = testPool->alloc(cur_bytes); - std::memset(ptr, init_val, cur_bytes); + std::byte* ptr = testPool->alloc(cur_bytes); + std::memset(reinterpret_cast(ptr), init_val, cur_bytes); //fmt::print("alloc {} bytes, ptr={}\n", cur_bytes, ptr); EXPECT_NE(ptr, nullptr); for (size_t i = 0; i < cur_bytes; i++) { - EXPECT_EQ(static_cast(ptr)[i], init_val); + EXPECT_EQ(reinterpret_cast(ptr)[i], init_val); } testPool->dealloc(ptr); } From eca26b5ae4813cc322d3a31a076b469b708d4cf3 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Thu, 14 Mar 2024 11:12:29 +0100 Subject: [PATCH 05/23] #2063: Update void* to std::byte* in MemoryPool --- src/vt/pool/pool.cc | 4 ++-- src/vt/pool/static_sized/memory_pool_equal.h | 6 +++--- .../pool/static_sized/memory_pool_equal.impl.h | 16 ++++++++-------- src/vt/runnable/runnable.cc | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/vt/pool/pool.cc b/src/vt/pool/pool.cc index 3b20a7949d..45beebab71 100644 --- a/src/vt/pool/pool.cc +++ b/src/vt/pool/pool.cc @@ -115,10 +115,10 @@ std::byte* Pool::pooledAlloc( if (pool_type == ePoolSize::Small) { auto pool = small_msg.get(); - ret = reinterpret_cast(pool->alloc(num_bytes, oversize)); + ret = pool->alloc(num_bytes, oversize); } else if (pool_type == ePoolSize::Medium) { auto pool = medium_msg.get(); - ret = reinterpret_cast(pool->alloc(num_bytes, oversize)); + ret = pool->alloc(num_bytes, oversize); } else { vtAssert(0, "Pool must be valid"); ret = nullptr; diff --git a/src/vt/pool/static_sized/memory_pool_equal.h b/src/vt/pool/static_sized/memory_pool_equal.h index 8fa59862f9..d299f824b9 100644 --- a/src/vt/pool/static_sized/memory_pool_equal.h +++ b/src/vt/pool/static_sized/memory_pool_equal.h @@ -76,7 +76,7 @@ static constexpr size_t const memory_size_medium = */ template struct MemoryPoolEqual { - using ContainerType = std::vector; + using ContainerType = std::vector; using SlotType = int64_t; using HeaderType = Header; using HeaderManagerType = HeaderManager; @@ -92,8 +92,8 @@ struct MemoryPoolEqual { virtual ~MemoryPoolEqual(); - void* alloc(size_t const& sz, size_t const& oversize); - void dealloc(void* const t); + std::byte* alloc(size_t const& sz, size_t const& oversize); + void dealloc(std::byte* const t); void resizePool(); SlotType getNumBytes(); diff --git a/src/vt/pool/static_sized/memory_pool_equal.impl.h b/src/vt/pool/static_sized/memory_pool_equal.impl.h index 8e19c2838c..858aeed7dc 100644 --- a/src/vt/pool/static_sized/memory_pool_equal.impl.h +++ b/src/vt/pool/static_sized/memory_pool_equal.impl.h @@ -81,7 +81,7 @@ template } template -void* MemoryPoolEqual::alloc( +std::byte* MemoryPoolEqual::alloc( size_t const& sz, size_t const& oversize ) { if (static_cast(cur_slot_ + 1) >= holder_.size()) { @@ -94,8 +94,8 @@ void* MemoryPoolEqual::alloc( ); auto const& slot = cur_slot_; - void* const ptr = holder_[slot]; - void* ptr_ret = ptr; + std::byte* const ptr = holder_[slot]; + std::byte* ptr_ret = ptr; if (use_header) { ptr_ret = HeaderManagerType::setHeader( sz, oversize, reinterpret_cast(ptr) @@ -105,7 +105,7 @@ void* MemoryPoolEqual::alloc( vt_debug_print( normal, pool, "alloc: ptr={}, ptr_ret={} cur_slot={}, sz={}, oversize={}\n", - ptr, ptr_ret, cur_slot_, sz, oversize + print_ptr(ptr), print_ptr(ptr_ret), cur_slot_, sz, oversize ); cur_slot_++; @@ -114,10 +114,10 @@ void* MemoryPoolEqual::alloc( } template -void MemoryPoolEqual::dealloc(void* const t) { +void MemoryPoolEqual::dealloc(std::byte* const t) { vt_debug_print( normal, pool, - "dealloc t={}, cur_slot={}\n", t, cur_slot_ + "dealloc t={}, cur_slot={}\n", print_ptr(t), cur_slot_ ); vtAssert( @@ -125,7 +125,7 @@ void MemoryPoolEqual::dealloc(void* const t) { ); auto t_char = reinterpret_cast(t); - void* ptr_actual = t; + std::byte* ptr_actual = t; if (use_header) { ptr_actual = HeaderManagerType::getHeaderPtr(t_char); } @@ -141,7 +141,7 @@ void MemoryPoolEqual::resizePool() { holder_.resize(new_size); for (auto i = cur_size; i < new_size; i++) { - holder_[i] = static_cast(malloc(use_header ? num_full_bytes_ : num_bytes_t)); + holder_[i] = reinterpret_cast(malloc(use_header ? num_full_bytes_ : num_bytes_t)); } } diff --git a/src/vt/runnable/runnable.cc b/src/vt/runnable/runnable.cc index b260b46962..ff0ba9fef3 100644 --- a/src/vt/runnable/runnable.cc +++ b/src/vt/runnable/runnable.cc @@ -255,7 +255,7 @@ void RunnableNew::send(elm::ElementIDStruct elm, MsgSizeType bytes) { } /*static*/ void RunnableNew::operator delete(void* ptr) { - RunnableNewAlloc::runnable->dealloc(ptr); + RunnableNewAlloc::runnable->dealloc(reinterpret_cast(ptr)); } /*static*/ From d50b1a234bb34afade0169f2e2504ea4e787d83e Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Thu, 14 Mar 2024 11:27:54 +0100 Subject: [PATCH 06/23] #2063: Remove unnecessary casts --- src/vt/messaging/active.cc | 2 +- src/vt/pool/static_sized/memory_pool_equal.impl.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index 4cc9bcd7f3..c00ef8acf7 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -838,7 +838,7 @@ void ActiveMessenger::finishPendingDataMsgAsyncRecv(InProgressDataIRecv* irecv) vt_debug_print( normal, active, "finishPendingDataMsgAsyncRecv: continuation user_buf={}, buf={}\n", - reinterpret_cast(user_buf), reinterpret_cast(buf) + print_ptr(user_buf), print_ptr(buf) ); if (user_buf == nullptr) { diff --git a/src/vt/pool/static_sized/memory_pool_equal.impl.h b/src/vt/pool/static_sized/memory_pool_equal.impl.h index 858aeed7dc..aee8f259ba 100644 --- a/src/vt/pool/static_sized/memory_pool_equal.impl.h +++ b/src/vt/pool/static_sized/memory_pool_equal.impl.h @@ -98,7 +98,7 @@ std::byte* MemoryPoolEqual::alloc( std::byte* ptr_ret = ptr; if (use_header) { ptr_ret = HeaderManagerType::setHeader( - sz, oversize, reinterpret_cast(ptr) + sz, oversize, ptr ); } @@ -124,10 +124,9 @@ void MemoryPoolEqual::dealloc(std::byte* const t) { cur_slot_ - 1 >= 0, "Must be greater than zero" ); - auto t_char = reinterpret_cast(t); std::byte* ptr_actual = t; if (use_header) { - ptr_actual = HeaderManagerType::getHeaderPtr(t_char); + ptr_actual = HeaderManagerType::getHeaderPtr(t); } holder_[--cur_slot_] = ptr_actual; From c9f646e4f34815b6afa6d4e39d5d1a63c2450272 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Thu, 14 Mar 2024 14:11:56 +0100 Subject: [PATCH 07/23] #2063: Update RDMA_PtrType to std::byte* --- examples/rdma/rdma_simple_get.cc | 2 +- examples/rdma/rdma_simple_put.cc | 4 +-- src/vt/configs/types/types_rdma.h | 2 +- src/vt/messaging/active.cc | 10 +++--- src/vt/messaging/active.h | 4 +-- src/vt/rdma/channel/rdma_channel.cc | 4 +-- src/vt/rdma/collection/rdma_collection.cc | 2 +- src/vt/rdma/rdma.cc | 36 +++++++++---------- src/vt/rdma/rdma.h | 6 ++-- src/vt/rdma/state/rdma_state.cc | 4 +-- .../messaging/serialized_messenger.impl.h | 5 +-- 11 files changed, 40 insertions(+), 39 deletions(-) diff --git a/examples/rdma/rdma_simple_get.cc b/examples/rdma/rdma_simple_get.cc index 79d92ceb07..77d60accf9 100644 --- a/examples/rdma/rdma_simple_get.cc +++ b/examples/rdma/rdma_simple_get.cc @@ -86,7 +86,7 @@ static vt::RDMA_GetType test_get_fn( this_node, num_bytes, tag ); return vt::RDMA_GetType{ - my_data.get() + tag, num_bytes == vt::no_byte ? sizeof(double)*10 : num_bytes + reinterpret_cast(my_data.get() + tag), num_bytes == vt::no_byte ? sizeof(double)*10 : num_bytes }; } diff --git a/examples/rdma/rdma_simple_put.cc b/examples/rdma/rdma_simple_put.cc index b9f24bb036..e59e6d37fb 100644 --- a/examples/rdma/rdma_simple_put.cc +++ b/examples/rdma/rdma_simple_put.cc @@ -81,7 +81,7 @@ static void put_data_fn(HandleMsg* msg) { } vt::theRDMA()->putData( - handle, local_data, sizeof(double)*local_data_len, + handle, reinterpret_cast(local_data), sizeof(double)*local_data_len, (this_node-1)*local_data_len, vt::no_tag, vt::rdma::rdma_default_byte_size, [=]{ delete [] local_data; @@ -111,7 +111,7 @@ static void put_handler_fn( for (decltype(count) i = 0; i < count; i++) { ::fmt::print( "{}: put_handler_fn: data[{}] = {}\n", - this_node, i, static_cast(in_ptr)[i] + this_node, i, reinterpret_cast(in_ptr)[i] ); } diff --git a/src/vt/configs/types/types_rdma.h b/src/vt/configs/types/types_rdma.h index 91383a153a..8164fc38a1 100644 --- a/src/vt/configs/types/types_rdma.h +++ b/src/vt/configs/types/types_rdma.h @@ -52,7 +52,7 @@ namespace vt { -using RDMA_PtrType = void *; +using RDMA_PtrType = std::byte *; using RDMA_ElmType = uint64_t; using RDMA_BlockType = int64_t; using RDMA_HandleType = int64_t; diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index c00ef8acf7..a7c227b08d 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -264,7 +264,7 @@ EventType ActiveMessenger::sendMsgBytesWithPut( } else { auto const& env_tag = envelopeGetPutTag(msg->env); auto const& ret = sendData( - PtrLenPairType{put_ptr,put_size}, dest, env_tag + PtrLenPairType{reinterpret_cast(put_ptr),put_size}, dest, env_tag ); auto const& ret_tag = ret.getTag(); if (ret_tag != env_tag) { @@ -376,7 +376,7 @@ EventType ActiveMessenger::sendMsgMPI( auto tag = allocateNewTag(); // Send the actual data in multiple chunks - PtrLenPairType tup = std::make_tuple(untyped_msg, msg_size); + PtrLenPairType tup = std::make_tuple(reinterpret_cast(untyped_msg), msg_size); SendInfo info = sendData(tup, dest, tag); auto event_id = info.getEvent(); @@ -539,7 +539,7 @@ SendInfo ActiveMessenger::sendData( vt_debug_print( terse, active, "sendData: ptr={}, num_bytes={} dest={}, tag={}, send_tag={}\n", - data_ptr, num_bytes, dest, tag, send_tag + print_ptr(data_ptr), num_bytes, dest, tag, send_tag ); vtAbortIf( @@ -564,7 +564,7 @@ SendInfo ActiveMessenger::sendData( std::tuple ActiveMessenger::sendDataMPI( PtrLenPairType const& payload, NodeType const& dest, TagType const& tag ) { - auto ptr = static_cast(std::get<0>(payload)); + auto ptr = reinterpret_cast(std::get<0>(payload)); auto remainder = std::get<1>(payload); int num_sends = 0; std::vector events; @@ -743,7 +743,7 @@ void ActiveMessenger::recvDataDirect( int nchunks, TagType const tag, NodeType const from, MsgSizeType len, ContinuationDeleterType next ) { - std::byte* buf = reinterpret_cast(thePool()->alloc(len)); + std::byte* buf = thePool()->alloc(len); recvDataDirect( nchunks, buf, tag, from, len, default_priority, nullptr, next, false diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index 7dc06d164c..554b89b12a 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -80,8 +80,8 @@ namespace vt { -/// A pair of a void* and number of bytes (length) for sending data -using PtrLenPairType = std::tuple; +/// A pair of a std::byte* and number of bytes (length) for sending data +using PtrLenPairType = std::tuple; /// A continuation function with an allocated pointer with a deleter function using ContinuationDeleterType = diff --git a/src/vt/rdma/channel/rdma_channel.cc b/src/vt/rdma/channel/rdma_channel.cc index 79fb0504aa..63b41bfdcc 100644 --- a/src/vt/rdma/channel/rdma_channel.cc +++ b/src/vt/rdma/channel/rdma_channel.cc @@ -81,7 +81,7 @@ Channel::Channel( normal, rdma_channel, "channel: construct: target={}, non_target={}, my_node={}, han={}, " "ptr={}, bytes={}, is_target={}\n", - target_, non_target_, my_node, rdma_handle_, ptr_, num_bytes_, + target_, non_target_, my_node, rdma_handle_, print_ptr(ptr_), num_bytes_, print_bool(is_target_) ); } @@ -246,7 +246,7 @@ Channel::writeDataToChannel( normal, rdma_channel, "writeDataToChannel: target={}, ptr={}, ptr_num_bytes={}, " "num_bytes={}, op_type={}, offset={}, locked_={}\n", - target_, ptr, ptr_num_bytes, num_bytes_, PRINT_RDMA_OP_TYPE(op_type_), + target_, print_ptr(ptr), ptr_num_bytes, num_bytes_, PRINT_RDMA_OP_TYPE(op_type_), offset, locked_ ); diff --git a/src/vt/rdma/collection/rdma_collection.cc b/src/vt/rdma/collection/rdma_collection.cc index c8565a1b9a..c68120c6e8 100644 --- a/src/vt/rdma/collection/rdma_collection.cc +++ b/src/vt/rdma/collection/rdma_collection.cc @@ -61,7 +61,7 @@ namespace vt { namespace rdma { auto const& elm_size = sizeof(void*); auto const& num_bytes = elm_size * num_elms; - void* ptr = nullptr; + std::byte* ptr = nullptr; auto const& han = rdma->registerNewRdmaHandler(false, ptr, num_bytes, true); auto iter = rdma->holder_.find(han); diff --git a/src/vt/rdma/rdma.cc b/src/vt/rdma/rdma.cc index d6d79596bc..d1859dbd12 100644 --- a/src/vt/rdma/rdma.cc +++ b/src/vt/rdma/rdma.cc @@ -120,7 +120,7 @@ RDMAManager::RDMAManager() normal, rdma, "getRecvMsg: op={}, tag={}, bytes={}, get_ptr={}, " "mpi_tag={}, send_back={}\n", - msg->op_id, msg_tag, msg->num_bytes, get_ptr, + msg->op_id, msg_tag, msg->num_bytes, print_ptr(get_ptr), msg->mpi_tag_to_recv, msg->send_back ); @@ -180,7 +180,7 @@ RDMAManager::RDMAManager() if (direct) { auto data_ptr = reinterpret_cast(msg) + sizeof(PutMessage); theRDMA()->triggerPutRecvData( - msg->rdma_handle, msg_tag, data_ptr, msg->num_bytes, msg->offset, [=]{ + msg->rdma_handle, msg_tag, reinterpret_cast(data_ptr), msg->num_bytes, msg->offset, [=]{ vt_debug_print( normal, rdma, "put_data: after put trigger: send_back={}\n", send_back @@ -206,7 +206,7 @@ RDMAManager::RDMAManager() normal, rdma, "putRecvMsg: recv_node={}, send_back={}, bytes={}, recv_tag={}, " "put_ptr={}\n", - recv_node, send_back, msg->num_bytes, msg->mpi_tag_to_recv, put_ptr + recv_node, send_back, msg->num_bytes, msg->mpi_tag_to_recv, print_ptr(put_ptr) ); if (put_ptr == nullptr) { @@ -238,7 +238,7 @@ RDMAManager::RDMAManager() }); } else { auto const& put_ptr_offset = - msg->offset != no_byte ? static_cast(put_ptr) + msg->offset : put_ptr; + msg->offset != no_byte ? reinterpret_cast(put_ptr) + msg->offset : reinterpret_cast(put_ptr); // do a direct recv into the user buffer theMsg()->recvDataMsgBuffer( msg->nchunks, reinterpret_cast(put_ptr_offset), recv_tag, recv_node, true, []{}, @@ -677,7 +677,7 @@ void RDMAManager::putData( normal, rdma, "putData: sending direct: put_node={}, ptr={}, num_bytes={}, " "offset={}\n", - put_node, ptr, num_bytes, offset + put_node, print_ptr(ptr), num_bytes, offset ); } else { @@ -701,7 +701,7 @@ void RDMAManager::putData( normal, rdma, "putData: recvData before: put_node={}, ptr={}, num_bytes={}, " "send_tag={}, offset={}\n", - put_node, ptr, num_bytes, msg->mpi_tag_to_recv, offset + put_node, print_ptr(ptr), num_bytes, msg->mpi_tag_to_recv, offset ); auto msg_send = promoteMsg(msg.get()); // msg in payload fn @@ -713,7 +713,7 @@ void RDMAManager::putData( normal, rdma, "putData: recvData after: put_node={}, ptr={}, num_bytes={}, " "send_tag={}, offset={}\n", - put_node, ptr, num_bytes, msg->mpi_tag_to_recv, offset + put_node, print_ptr(ptr), num_bytes, msg->mpi_tag_to_recv, offset ); } @@ -729,7 +729,7 @@ void RDMAManager::putData( vt_debug_print( normal, rdma, "putData: local: put_node={}, ptr={}, num_bytes={}, offset={}\n", - put_node, ptr, num_bytes, offset + put_node, print_ptr(ptr), num_bytes, offset ); theRDMA()->triggerPutRecvData( han, tag, ptr, num_bytes, offset, [=](){ @@ -756,7 +756,7 @@ void RDMAManager::putRegionTypeless( vt_debug_print( normal, rdma, "putRegionTypeless: han={}, ptr={}, region={}\n", - han,ptr,region.regionToBuf().c_str() + han,print_ptr(ptr),region.regionToBuf().c_str() ); auto holder_iter = holder_.find(han); @@ -780,7 +780,7 @@ void RDMAManager::putRegionTypeless( auto const& elm_size = region.elm_size; auto const& rlo = region.lo; auto const& roffset = lo - rlo; - auto const& ptr_offset = static_cast(ptr) + (roffset * elm_size); + auto const& ptr_offset = reinterpret_cast(ptr) + (roffset * elm_size); auto const& block_offset = (lo - blk_lo) * elm_size; vt_debug_print( @@ -794,7 +794,7 @@ void RDMAManager::putRegionTypeless( remote_action->addDep(); putData( - han, ptr_offset, (hi-lo)*elm_size, block_offset, no_tag, elm_size, + han, reinterpret_cast(ptr_offset), (hi-lo)*elm_size, block_offset, no_tag, elm_size, [=]{ remote_action->release(); }, node ); }); @@ -817,7 +817,7 @@ void RDMAManager::getRegionTypeless( vt_debug_print( normal, rdma, "getRegionTypeless: han={}, ptr={}, region={}\n", - han,ptr,region.regionToBuf().c_str() + han,print_ptr(ptr),region.regionToBuf().c_str() ); auto holder_iter = holder_.find(han); @@ -842,7 +842,7 @@ void RDMAManager::getRegionTypeless( auto const& elm_size = region.elm_size; auto const& rlo = region.lo; auto const& roffset = lo - rlo; - auto const& ptr_offset = static_cast(ptr) + (roffset * elm_size); + auto const& ptr_offset = reinterpret_cast(ptr) + (roffset * elm_size); auto const& block_offset = (lo - blk_lo) * elm_size; vt_debug_print( @@ -855,7 +855,7 @@ void RDMAManager::getRegionTypeless( action->addDep(); getDataIntoBuf( - han, ptr_offset, (hi-lo)*elm_size, block_offset, no_tag, [=]{ + han, reinterpret_cast(ptr_offset), (hi-lo)*elm_size, block_offset, no_tag, [=]{ auto const& my_node = theContext()->getNode(); vt_debug_print( normal, rdma, @@ -883,7 +883,7 @@ void RDMAManager::putDataIntoBufCollective( vt_debug_print( normal, rdma, "putDataIntoBufCollective: han={}, ptr={}, bytes={}, offset={}\n", - han,ptr,num_bytes,offset + han,print_ptr(ptr),num_bytes,offset ); auto const& a_offset = offset == no_offset ? 0 : offset; @@ -901,7 +901,7 @@ void RDMAManager::getDataIntoBufCollective( vt_debug_print( normal, rdma, "getDataIntoBufCollective: han={}, ptr={}, bytes={}, offset={}\n", - han,ptr,num_bytes,offset + han,print_ptr(ptr),num_bytes,offset ); auto const& a_offset = offset == no_offset ? 0 : offset; @@ -976,7 +976,7 @@ void RDMAManager::getDataIntoBuf( } else { vt_debug_print( normal, rdma, - "getData: local direct into buf, ptr={}\n", ptr + "getData: local direct into buf, ptr={}\n", print_ptr(ptr) ); theRDMA()->requestGetData( nullptr, false, han, tag, num_bytes, offset, true, ptr, this_node, @@ -1147,7 +1147,7 @@ void RDMAManager::createDirectChannelFinish( normal, rdma_channel, "createDirectChannelFinish: han={}, is_target={}, state ptr={}, " "bytes={}, target={}, non_target={}\n", - han, print_bool(is_target), target_ptr, target_num_bytes, target, + han, print_bool(is_target), print_ptr(target_ptr), target_num_bytes, target, non_target ); } diff --git a/src/vt/rdma/rdma.h b/src/vt/rdma/rdma.h index d7930f2468..eef08c840c 100644 --- a/src/vt/rdma/rdma.h +++ b/src/vt/rdma/rdma.h @@ -142,7 +142,7 @@ struct RDMAManager : runtime::component::Component { ByteType const num_bytes = num_elems == no_byte ? no_byte : sizeof(T)*num_elems; ByteType const byte_offset = offset == no_byte ? 0 : sizeof(T)*offset; return putData( - rdma_handle, static_cast(ptr), num_bytes, byte_offset, tag, + rdma_handle, reinterpret_cast(ptr), num_bytes, byte_offset, tag, sizeof(T), action_after_put ); } @@ -327,7 +327,7 @@ struct RDMAManager : runtime::component::Component { ByteType const byte_offset = elm_offset == no_byte ? 0 : sizeof(T)*elm_offset; return getDataIntoBuf( - rdma_handle, static_cast(ptr), num_bytes, byte_offset, tag, + rdma_handle, reinterpret_cast(ptr), num_bytes, byte_offset, tag, next_action, sizeof(T) ); } @@ -391,7 +391,7 @@ struct RDMAManager : runtime::component::Component { print_ptr(ptr), num_bytes ); return registerNewRdmaHandler( - true, static_cast(ptr), num_bytes + true, reinterpret_cast(ptr), num_bytes ); } diff --git a/src/vt/rdma/state/rdma_state.cc b/src/vt/rdma/state/rdma_state.cc index bd8190d48b..a08fd751a3 100644 --- a/src/vt/rdma/state/rdma_state.cc +++ b/src/vt/rdma/state/rdma_state.cc @@ -194,7 +194,7 @@ bool State::testReadyPutData(TagType const& tag) { ); return RDMA_GetType{ - static_cast(state.ptr) + req_offset, + state.ptr + req_offset, req_num_bytes == no_byte ? state.num_bytes : req_num_bytes }; } @@ -216,7 +216,7 @@ bool State::testReadyPutData(TagType const& tag) { "To use default handler ptr, bytes must be set" ); - std::memcpy(static_cast(state.ptr) + req_offset, in_ptr, req_num_bytes); + std::memcpy(reinterpret_cast(state.ptr) + req_offset, in_ptr, req_num_bytes); } void State::getData( diff --git a/src/vt/serialization/messaging/serialized_messenger.impl.h b/src/vt/serialization/messaging/serialized_messenger.impl.h index 5b9c296ae0..a924ddcf6d 100644 --- a/src/vt/serialization/messaging/serialized_messenger.impl.h +++ b/src/vt/serialization/messaging/serialized_messenger.impl.h @@ -351,7 +351,7 @@ template ptr_size = size; if (size > serialized_msg_eager_size) { - ptr = static_cast(std::malloc(size)); + ptr = reinterpret_cast(std::malloc(size)); return ptr; } else { payload_msg = makeMessage>( @@ -392,7 +392,8 @@ template if (node != dest) { auto sys_msg = makeMessage>(); auto send_serialized = [=](Active::SendFnType send){ - auto ret = send(RDMA_GetType{ptr, ptr_size}, dest, no_tag); + auto void_ptr = reinterpret_cast(ptr); + auto ret = send(RDMA_GetType{void_ptr, ptr_size}, dest, no_tag); EventType event = ret.getEvent(); theEvent()->attachAction(event, [=]{ std::free(ptr); }); sys_msg->data_recv_tag = ret.getTag(); From 7ef97cb226631ebaad0a015594cada2fd96ce572 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Thu, 14 Mar 2024 16:17:46 +0100 Subject: [PATCH 08/23] #2063: Update void* to std::byte* in Payload Envelope --- src/vt/group/msg/group_msg.h | 4 ++-- src/vt/messaging/active.cc | 2 +- src/vt/messaging/envelope/payload_envelope.h | 6 +++--- src/vt/messaging/message/put_message.h | 4 ++-- tests/unit/active/test_active_bcast_put.cc | 4 ++-- tests/unit/active/test_active_send.cc | 8 ++++---- tests/unit/active/test_active_send_put.cc | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/vt/group/msg/group_msg.h b/src/vt/group/msg/group_msg.h index a9a3fde167..e01740a1ba 100644 --- a/src/vt/group/msg/group_msg.h +++ b/src/vt/group/msg/group_msg.h @@ -129,13 +129,13 @@ struct GroupListMsg : GroupInfoMsg> { ) { setPut( - in_range->getBound(), + reinterpret_cast(in_range->getBound()), in_range->getSize() * sizeof(RangeType::BoundType) ); } RangeType getRange() { - auto const& ptr = static_cast(getPut()); + auto const& ptr = reinterpret_cast(getPut()); return region::ShallowList(ptr, getCount()); } }; diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index a7c227b08d..0215cc4a25 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -1100,7 +1100,7 @@ void ActiveMessenger::finishPendingActiveMsgAsyncRecv(InProgressIRecv* irecv) { ); } - envelopeSetPutPtrOnly(msg->env, put_ptr); + envelopeSetPutPtrOnly(msg->env, reinterpret_cast(put_ptr)); put_finished = true; } else { /*bool const put_delivered = */recvDataMsg( diff --git a/src/vt/messaging/envelope/payload_envelope.h b/src/vt/messaging/envelope/payload_envelope.h index fc2b10b11b..48e3b71bee 100644 --- a/src/vt/messaging/envelope/payload_envelope.h +++ b/src/vt/messaging/envelope/payload_envelope.h @@ -50,8 +50,8 @@ namespace vt { /** \file */ -using PutPtrType = void*; -using PutPtrConstType = void const*; +using PutPtrType = std::byte*; +using PutPtrConstType = std::byte const*; using PutEnvSizeType = size_t; using PutUnderEnvelopeT = EpochTagEnvelope; @@ -64,7 +64,7 @@ using PutUnderEnvelopeT = EpochTagEnvelope; template struct PutEnvelope { using isByteCopyable = std::true_type; - using PtrType = void*; + using PtrType = std::byte*; using EnvSizeType = SizeT; using UnderEnvelopeT = EnvelopeT; diff --git a/src/vt/messaging/message/put_message.h b/src/vt/messaging/message/put_message.h index a085448cce..ea1f98cad4 100644 --- a/src/vt/messaging/message/put_message.h +++ b/src/vt/messaging/message/put_message.h @@ -52,10 +52,10 @@ namespace vt { namespace messaging { template struct PutMessageComponent : MessageT { - void setPut(void const* const ptr, size_t const size) { + void setPut(std::byte const* const ptr, size_t const size) { envelopeSetPutPtr(MessageT::env, ptr, size); } - void* getPut() { + std::byte* getPut() { return envelopeGetPutPtr(MessageT::env); } size_t getPutSize() { diff --git a/tests/unit/active/test_active_bcast_put.cc b/tests/unit/active/test_active_bcast_put.cc index 046eb1f0cf..c14a2661e0 100644 --- a/tests/unit/active/test_active_bcast_put.cc +++ b/tests/unit/active/test_active_bcast_put.cc @@ -82,7 +82,7 @@ struct TestActiveBroadcastPut : TestParameterHarnessNode { fmt::print("{}: test_handler: cnt={}\n", this_node, handler_count); #endif - auto const ptr = static_cast(msg->getPut()); + auto const ptr = reinterpret_cast(msg->getPut()); auto const size = msg->getPutSize(); #if DEBUG_TEST_HARNESS_PRINT || 1 @@ -126,7 +126,7 @@ TEST_P(TestActiveBroadcastPut, test_type_safe_active_fn_bcast2) { if (my_node == root) { for (int i = 0; i < num_msg_sent; i++) { auto msg = makeMessage(); - msg->setPut(put_payload.data(), put_size * sizeof(int)); + msg->setPut(reinterpret_cast(put_payload.data()), put_size * sizeof(int)); theMsg()->broadcastMsg(msg); } } diff --git a/tests/unit/active/test_active_send.cc b/tests/unit/active/test_active_send.cc index 5d6367b430..7bc04977f4 100644 --- a/tests/unit/active/test_active_send.cc +++ b/tests/unit/active/test_active_send.cc @@ -94,7 +94,7 @@ struct TestActiveSend : TestParallelHarness { } static void test_handler_small_put(PutTestMessage* msg) { - auto ptr = static_cast(msg->getPut()); + auto ptr = reinterpret_cast(msg->getPut()); auto size = msg->getPutSize(); #if DEBUG_TEST_HARNESS_PRINT auto const& this_node = theContext()->getNode(); @@ -109,7 +109,7 @@ struct TestActiveSend : TestParallelHarness { } static void test_handler_large_put(PutTestMessage* msg) { - auto ptr = static_cast(msg->getPut()); + auto ptr = reinterpret_cast(msg->getPut()); auto size = msg->getPutSize(); #if DEBUG_TEST_HARNESS_PRINT auto const& this_node = theContext()->getNode(); @@ -190,7 +190,7 @@ TEST_F(TestActiveSend, test_type_safe_active_fn_send_small_put) { if (my_node == from_node) { for (int i = 0; i < num_msg_sent; i++) { auto msg = makeMessage(); - msg->setPut(test_vec.data(), sizeof(int)*test_vec.size()); + msg->setPut(reinterpret_cast(test_vec.data()), sizeof(int)*test_vec.size()); #if DEBUG_TEST_HARNESS_PRINT fmt::print("{}: sendMsg: (put) i={}\n", my_node, i); #endif @@ -215,7 +215,7 @@ TEST_F(TestActiveSend, test_type_safe_active_fn_send_large_put) { if (my_node == from_node) { for (int i = 0; i < num_msg_sent; i++) { auto msg = makeMessage(); - msg->setPut(test_vec_2.data(), sizeof(int)*test_vec_2.size()); + msg->setPut(reinterpret_cast(test_vec_2.data()), sizeof(int)*test_vec_2.size()); #if DEBUG_TEST_HARNESS_PRINT fmt::print("{}: sendMsg: (put) i={}\n", my_node, i); #endif diff --git a/tests/unit/active/test_active_send_put.cc b/tests/unit/active/test_active_send_put.cc index ba2c52551f..1345d69cde 100644 --- a/tests/unit/active/test_active_send_put.cc +++ b/tests/unit/active/test_active_send_put.cc @@ -71,7 +71,7 @@ struct TestActiveSendPut : TestParameterHarnessNode { } static void test_handler(PutTestMessage* msg) { - auto ptr = static_cast(msg->getPut()); + auto ptr = reinterpret_cast(msg->getPut()); auto size = msg->getPutSize(); #if DEBUG_TEST_HARNESS_PRINT auto const& this_node = theContext()->getNode(); @@ -109,7 +109,7 @@ TEST_P(TestActiveSendPut, test_active_fn_send_put_param) { auto msg = makeMessage( static_cast(test_vec_2.size()) ); - msg->setPut(test_vec_2.data(), sizeof(int)*test_vec_2.size()); + msg->setPut(reinterpret_cast(test_vec_2.data()), sizeof(int)*test_vec_2.size()); #if DEBUG_TEST_HARNESS_PRINT fmt::print("{}: sendMsg: (put) i={}\n", my_node, i); #endif From 06c49335b440d3665a068a114498b28d554be4fc Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Fri, 15 Mar 2024 12:23:59 +0100 Subject: [PATCH 09/23] #2063: Update void* to std::byte* in smart_ptr --- src/vt/messaging/message/smart_ptr.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vt/messaging/message/smart_ptr.h b/src/vt/messaging/message/smart_ptr.h index a3f9186244..4cd31ab46d 100644 --- a/src/vt/messaging/message/smart_ptr.h +++ b/src/vt/messaging/message/smart_ptr.h @@ -82,15 +82,15 @@ namespace vt { namespace messaging { struct MsgPtrImplBase { /// Invoke messageDeref on the appropriate type. /// (Ensure a valid delete-expression on virtual message types.) - virtual void messageDeref(void* msg_ptr) = 0; + virtual void messageDeref(std::byte* msg_ptr) = 0; virtual ~MsgPtrImplBase() {} }; template struct MsgPtrImplTyped : MsgPtrImplBase { - virtual void messageDeref(void* msg_ptr) { + virtual void messageDeref(std::byte* msg_ptr) { // N.B. messageDeref invokes delete-expr T. - vt::messageDeref(static_cast(msg_ptr)); + vt::messageDeref(reinterpret_cast(msg_ptr)); } }; @@ -280,7 +280,7 @@ struct MsgSharedPtr final { T* msgPtr = get(); - impl_->messageDeref(msgPtr); + impl_->messageDeref(reinterpret_cast(msgPtr)); ptr_ = nullptr; } From a635b6a85e8376a40cf5e75c3acd00b9b6574b3e Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Fri, 15 Mar 2024 12:44:17 +0100 Subject: [PATCH 10/23] #2063: Update void* to std::byte* in PipeState --- src/vt/pipe/pipe_manager_base.impl.h | 2 +- src/vt/pipe/state/pipe_state.cc | 2 +- src/vt/pipe/state/pipe_state.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vt/pipe/pipe_manager_base.impl.h b/src/vt/pipe/pipe_manager_base.impl.h index 05e55d23d5..402d4b042a 100644 --- a/src/vt/pipe/pipe_manager_base.impl.h +++ b/src/vt/pipe/pipe_manager_base.impl.h @@ -103,7 +103,7 @@ void PipeManagerBase::triggerPipeUnknown(PipeType const& pipe, MsgT* msg) { pipe, print_ptr(msg) ); - iter->second.dispatch(msg); + iter->second.dispatch(reinterpret_cast(msg)); } template diff --git a/src/vt/pipe/state/pipe_state.cc b/src/vt/pipe/state/pipe_state.cc index 177e6449d8..816c77c46a 100644 --- a/src/vt/pipe/state/pipe_state.cc +++ b/src/vt/pipe/state/pipe_state.cc @@ -94,7 +94,7 @@ void PipeState::setDispatch(DispatchFuncType in_dispatch) { dispatch_ = in_dispatch; } -void PipeState::dispatch(void* ptr) { +void PipeState::dispatch(std::byte* ptr) { vtAssert(dispatch_ != nullptr, "Dispatch function must be available"); dispatch_(ptr); } diff --git a/src/vt/pipe/state/pipe_state.h b/src/vt/pipe/state/pipe_state.h index 9e8d1c53ed..393576b10a 100644 --- a/src/vt/pipe/state/pipe_state.h +++ b/src/vt/pipe/state/pipe_state.h @@ -52,7 +52,7 @@ namespace vt { namespace pipe { struct PipeState { - using DispatchFuncType = std::function; + using DispatchFuncType = std::function; PipeState( PipeType const& in_pipe, PipeRefType const& in_signals, PipeRefType const& in_lis, @@ -72,7 +72,7 @@ struct PipeState { bool hasDispatch() const; void setDispatch(DispatchFuncType in_dispatch); - void dispatch(void* ptr); + void dispatch(std::byte* ptr); private: bool automatic_ = false; From 70cc8390d74f83988536a62c6b7a401b828fa29e Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Fri, 15 Mar 2024 13:21:57 +0100 Subject: [PATCH 11/23] #2063: Update RDMA_RecvType to accept std::byte* --- src/vt/rdma/rdma_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vt/rdma/rdma_common.h b/src/vt/rdma/rdma_common.h index e79685830b..9e049c075c 100644 --- a/src/vt/rdma/rdma_common.h +++ b/src/vt/rdma/rdma_common.h @@ -104,7 +104,7 @@ using ActiveGetFunctionType = RDMA_GetType(*)(BaseMessage*, ByteType, ByteType, using ActivePutFunctionType = void(*)(BaseMessage*, RDMA_PtrType, ByteType, ByteType, TagType, bool); using RDMA_PtrContinuationType = std::function; -using RDMA_RecvType = std::function; +using RDMA_RecvType = std::function; using RDMA_NumElemsType = int64_t; using RDMA_BlockElmRangeType = std::tuple; From 2ba3922ef46825d1edf799d85ef72fe5df6627d9 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Fri, 15 Mar 2024 14:50:07 +0100 Subject: [PATCH 12/23] #2063: Update void* to std::byte* in Holder struct --- src/vt/objgroup/holder/holder.h | 2 +- src/vt/objgroup/holder/holder_base.h | 4 ++-- src/vt/objgroup/holder/holder_basic.h | 2 +- src/vt/objgroup/manager.impl.h | 2 +- src/vt/objgroup/manager.static.h | 2 +- src/vt/objgroup/proxy/proxy_objgroup.impl.h | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/vt/objgroup/holder/holder.h b/src/vt/objgroup/holder/holder.h index 1ebfc6a91e..95d911c7f4 100644 --- a/src/vt/objgroup/holder/holder.h +++ b/src/vt/objgroup/holder/holder.h @@ -63,7 +63,7 @@ struct Holder final : HolderObjBase { public: ObjT* get() override { return obj_.get(); } bool exists() override { return obj_ != nullptr; } - void* getPtr() override { return obj_.get(); } + std::byte* getPtr() override { return reinterpret_cast(obj_.get()); } template void reset(Args&&... args) { diff --git a/src/vt/objgroup/holder/holder_base.h b/src/vt/objgroup/holder/holder_base.h index e1218e06e5..0cd9f6439b 100644 --- a/src/vt/objgroup/holder/holder_base.h +++ b/src/vt/objgroup/holder/holder_base.h @@ -57,7 +57,7 @@ struct HolderBase { virtual ~HolderBase() = default; virtual bool exists() = 0; - virtual void* getPtr() = 0; + virtual std::byte* getPtr() = 0; template void serialize(Serializer& s) { @@ -78,7 +78,7 @@ template struct HolderObjBase : HolderBase { virtual ~HolderObjBase() = default; virtual ObjT* get() = 0; - virtual void* getPtr() = 0; + virtual std::byte* getPtr() = 0; }; }}} /* end namespace vt::objgroup::holder */ diff --git a/src/vt/objgroup/holder/holder_basic.h b/src/vt/objgroup/holder/holder_basic.h index ca2f73c033..d752843e5b 100644 --- a/src/vt/objgroup/holder/holder_basic.h +++ b/src/vt/objgroup/holder/holder_basic.h @@ -61,7 +61,7 @@ struct HolderBasic final : HolderObjBase { public: ObjT* get() override { return obj_; } bool exists() override { return obj_ != nullptr; } - void* getPtr() override { return obj_; } + std::byte* getPtr() override { return reinterpret_cast(obj_); } template void reset(Args&&... args) { diff --git a/src/vt/objgroup/manager.impl.h b/src/vt/objgroup/manager.impl.h index d2792525ad..ebb11839ac 100644 --- a/src/vt/objgroup/manager.impl.h +++ b/src/vt/objgroup/manager.impl.h @@ -288,7 +288,7 @@ ObjT* ObjGroupManager::get(ProxyElmType proxy) { auto iter = objs_.find(proxy_bits); vtAssert(iter != objs_.end(), "Obj must exist on this node"); HolderBaseType* holder = iter->second.get(); - return static_cast(holder->getPtr()); + return reinterpret_cast(holder->getPtr()); } template diff --git a/src/vt/objgroup/manager.static.h b/src/vt/objgroup/manager.static.h index ac24a78aec..9f3b490697 100644 --- a/src/vt/objgroup/manager.static.h +++ b/src/vt/objgroup/manager.static.h @@ -96,7 +96,7 @@ decltype(auto) invoke( return runnable::makeRunnableVoid(false, han, this_node) .withObjGroup(elm) .withLBData(lb_data, elm_id) - .runLambda(f, static_cast(elm), msg.get()); + .runLambda(f, reinterpret_cast(elm), msg.get()); } template diff --git a/src/vt/objgroup/proxy/proxy_objgroup.impl.h b/src/vt/objgroup/proxy/proxy_objgroup.impl.h index 7a3448de28..f594ae6abe 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup.impl.h +++ b/src/vt/objgroup/proxy/proxy_objgroup.impl.h @@ -279,7 +279,7 @@ typename Proxy::PendingSendType Proxy::reduce(MsgPtrT inmsg, ReduceS template ObjT* Proxy::get() const { auto proxy = Proxy(*this); - return theObjGroup()->get(proxy); + return reinterpret_cast(theObjGroup()->get(proxy)); } template From c492dd8f8f9d4b0d86df41a08f1db1c203dc509c Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Tue, 19 Mar 2024 12:48:50 +0100 Subject: [PATCH 13/23] #2063: Update void* to std::byte* in runnable --- src/vt/collective/scatter/scatter.cc | 2 +- src/vt/registry/auto/auto_registry_common.h | 12 ++++++------ src/vt/runnable/make_runnable.h | 2 +- src/vt/runnable/runnable.cc | 8 ++++---- src/vt/runnable/runnable.h | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/vt/collective/scatter/scatter.cc b/src/vt/collective/scatter/scatter.cc index 280d429660..2ebf6eef6d 100644 --- a/src/vt/collective/scatter/scatter.cc +++ b/src/vt/collective/scatter/scatter.cc @@ -118,7 +118,7 @@ void Scatter::scatterIn(ScatterMsg* msg) { }); auto const& active_fn = auto_registry::getScatterAutoHandler(user_handler); - active_fn->dispatch(in_base_ptr, nullptr); + active_fn->dispatch(reinterpret_cast(in_base_ptr), nullptr); } /*static*/ void Scatter::scatterHandler(ScatterMsg* msg) { diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index c7a3c4cdf3..a7b405f7ef 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -71,7 +71,7 @@ struct SentinelObject {}; struct BaseHandlersDispatcher { virtual ~BaseHandlersDispatcher() = default; - virtual void dispatch(messaging::BaseMsg* msg, void* object) const = 0; + virtual void dispatch(messaging::BaseMsg* msg, std::byte* object) const = 0; }; template @@ -100,11 +100,11 @@ struct HandlersDispatcher final : BaseHandlersDispatcher { detection::is_detected_convertible; public: - void dispatch(messaging::BaseMsg* base_msg, void* object) const override { + void dispatch(messaging::BaseMsg* base_msg, std::byte* object) const override { using T = HandlerT; [[maybe_unused]] auto msg = static_cast(base_msg); - [[maybe_unused]] auto elm = static_cast(object); + [[maybe_unused]] auto elm = reinterpret_cast(object); if constexpr (std::is_same_v) { fp(); @@ -183,7 +183,7 @@ struct MapsDispatcher final : BaseMapsDispatcher { struct BaseScatterDispatcher { virtual ~BaseScatterDispatcher() = default; - virtual void dispatch(void* msg, void* object) const = 0; + virtual void dispatch(std::byte* msg, std::byte* object) const = 0; }; template @@ -191,11 +191,11 @@ struct ScatterDispatcher final : BaseScatterDispatcher { explicit ScatterDispatcher(HandlerT in_fn_ptr) : fp(in_fn_ptr) {} public: - void dispatch(void* msg, void*) const override { + void dispatch(std::byte* msg, std::byte*) const override { using T = HandlerT; if constexpr (std::is_same_v*>) { - fp(static_cast(msg)); + fp(reinterpret_cast(msg)); } else { vtAbort("Invalid function type for scatter handler"); } diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index e3b713b83e..382c6eda03 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -167,7 +167,7 @@ struct RunnableMaker { RunnableMaker&& withObjGroup(ElmT* elm) { set_handler_ = true; if (handler_ != uninitialized_handler) { - impl_->setupHandlerObjGroup(elm, handler_); + impl_->setupHandlerObjGroup(reinterpret_cast(elm), handler_); } return std::move(*this); } diff --git a/src/vt/runnable/runnable.cc b/src/vt/runnable/runnable.cc index ff0ba9fef3..778d8e1fac 100644 --- a/src/vt/runnable/runnable.cc +++ b/src/vt/runnable/runnable.cc @@ -79,7 +79,7 @@ void RunnableNew::setupHandler(HandlerType handler) { } } -void RunnableNew::setupHandlerObjGroup(void* obj, HandlerType handler) { +void RunnableNew::setupHandlerObjGroup(std::byte* obj, HandlerType handler) { f_.func_ = auto_registry::getAutoHandlerObjGroup(handler).get(); obj_ = obj; } @@ -91,14 +91,14 @@ void RunnableNew::setupHandlerElement( f_.func_ = member ? auto_registry::getAutoHandlerCollectionMem(handler).get() : auto_registry::getAutoHandlerCollection(handler).get(); - obj_ = elm; + obj_ = reinterpret_cast(elm); } void RunnableNew::setupHandlerElement( vrt::VirtualContext* elm, HandlerType handler ) { f_.func_ = auto_registry::getAutoHandlerVC(handler).get(); - obj_ = elm; + obj_ = reinterpret_cast(elm); } void RunnableNew::run() { @@ -165,7 +165,7 @@ void RunnableNew::run() { #endif if (is_scatter_) { - f_.func_scat_->dispatch(msg_ == nullptr ? nullptr : msg_.get(), obj_); + f_.func_scat_->dispatch(msg_ == nullptr ? nullptr : reinterpret_cast(msg_.get()), obj_); } else { f_.func_->dispatch(msg_ == nullptr ? nullptr : msg_.get(), obj_); } diff --git a/src/vt/runnable/runnable.h b/src/vt/runnable/runnable.h index 3151a4fe43..a4cc408080 100644 --- a/src/vt/runnable/runnable.h +++ b/src/vt/runnable/runnable.h @@ -202,7 +202,7 @@ struct RunnableNew { * \param[in] elm the object pointer * \param[in] handler the handler ID bits */ - void setupHandlerObjGroup(void* obj, HandlerType handler); + void setupHandlerObjGroup(std::byte* obj, HandlerType handler); /** * \brief Set up a handler to run on an non-collection object @@ -356,7 +356,7 @@ struct RunnableNew { private: detail::Contexts contexts_; /**< The contexts */ MsgSharedPtr msg_ = nullptr; /**< The associated message */ - void* obj_ = nullptr; /**< Object pointer */ + std::byte* obj_ = nullptr; /**< Object pointer */ union { DispatcherType func_; DispatcherScatterType func_scat_; From 10835a8510e47c0ae087f66e66d16c4515f02ad0 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Tue, 19 Mar 2024 13:42:16 +0100 Subject: [PATCH 14/23] #2063: Update void* to std::byte* in ObjGroupManager --- src/vt/objgroup/manager.cc | 2 +- src/vt/objgroup/manager.h | 4 ++-- src/vt/objgroup/manager.impl.h | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/vt/objgroup/manager.cc b/src/vt/objgroup/manager.cc index 18888093dc..448de0d794 100644 --- a/src/vt/objgroup/manager.cc +++ b/src/vt/objgroup/manager.cc @@ -84,7 +84,7 @@ ObjGroupProxyType ObjGroupManager::getProxy(ObjGroupProxyType proxy) { } ObjGroupProxyType ObjGroupManager::makeCollectiveImpl( - std::string const& label, HolderBasePtrType base, void* obj_ptr + std::string const& label, HolderBasePtrType base, std::byte* obj_ptr ) { auto const id = cur_obj_id_++; auto const node = theContext()->getNode(); diff --git a/src/vt/objgroup/manager.h b/src/vt/objgroup/manager.h index 0080182e5e..8d144dc14c 100644 --- a/src/vt/objgroup/manager.h +++ b/src/vt/objgroup/manager.h @@ -446,7 +446,7 @@ struct ObjGroupManager : runtime::component::Component { * \return a new untyped proxy */ ObjGroupProxyType makeCollectiveImpl( - std::string const& label, HolderBasePtrType b, void* obj_ptr + std::string const& label, HolderBasePtrType b, std::byte* obj_ptr ); /** @@ -496,7 +496,7 @@ struct ObjGroupManager : runtime::component::Component { /// Type-erased pointers to the objects held on this node std::unordered_map objs_; /// Reverse lookup map from an object pointer to the proxy - std::unordered_map obj_to_proxy_; + std::unordered_map obj_to_proxy_; /// Messages that are pending creation for delivery std::unordered_map> pending_; /// Map of object groups' labels diff --git a/src/vt/objgroup/manager.impl.h b/src/vt/objgroup/manager.impl.h index ebb11839ac..ff24ee549c 100644 --- a/src/vt/objgroup/manager.impl.h +++ b/src/vt/objgroup/manager.impl.h @@ -103,7 +103,7 @@ ObjGroupManager::makeCollective(std::unique_ptr obj, std::string const& la template ObjGroupManager::ProxyType ObjGroupManager::makeCollectiveObj(std::string const& label, ObjT* obj, HolderBasePtrType holder) { - auto const obj_ptr = reinterpret_cast(obj); + auto const obj_ptr = reinterpret_cast(obj); auto const proxy = makeCollectiveImpl(label, std::move(holder), obj_ptr); auto iter = objs_.find(proxy); vtAssert(iter != objs_.end(), "Obj must exist on this node"); @@ -301,14 +301,14 @@ void ObjGroupManager::update(ProxyElmType proxy, Args&&... args) { HolderBaseType* holder = iter->second.get(); auto obj_holder = static_cast*>(holder); - auto const cur_obj_ptr = obj_holder->get(); + auto const cur_obj_ptr = reinterpret_cast(obj_holder->get()); auto map_iter = obj_to_proxy_.find(cur_obj_ptr); vtAssert(map_iter != obj_to_proxy_.end(), "Object pointer must exist in map"); obj_to_proxy_.erase(map_iter); obj_holder->reset(std::forward(args)...); - auto const new_obj_ptr = obj_holder->get(); + auto const new_obj_ptr = reinterpret_cast(obj_holder->get()); obj_to_proxy_[new_obj_ptr] = proxy_bits; } @@ -321,7 +321,7 @@ void ObjGroupManager::update(ProxyType proxy, Args&&... args) { template typename ObjGroupManager::ProxyType ObjGroupManager::getProxy(ObjT* obj) { - auto map_iter = obj_to_proxy_.find(obj); + auto map_iter = obj_to_proxy_.find(reinterpret_cast(obj)); vtAssert(map_iter != obj_to_proxy_.end(), "Object pointer does not exist"); return ProxyType(map_iter->second); } From 5670b01f07d62f9cbbf57768a885a3b0f9ddb2fb Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Tue, 19 Mar 2024 14:12:11 +0100 Subject: [PATCH 15/23] #2063: Update void* to std::byte* in DispatchCollection --- .../callback/proxy_bcast/callback_proxy_bcast_tl.impl.h | 2 +- src/vt/vrt/collection/dispatch/dispatch.h | 8 ++++---- src/vt/vrt/collection/dispatch/dispatch.impl.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/vt/pipe/callback/proxy_bcast/callback_proxy_bcast_tl.impl.h b/src/vt/pipe/callback/proxy_bcast/callback_proxy_bcast_tl.impl.h index f4a939693d..4d30b5eb35 100644 --- a/src/vt/pipe/callback/proxy_bcast/callback_proxy_bcast_tl.impl.h +++ b/src/vt/pipe/callback/proxy_bcast/callback_proxy_bcast_tl.impl.h @@ -106,7 +106,7 @@ void CallbackProxyBcastDirect::trigger(MsgT* msg, PipeType const& pipe) { auto dispatcher = vrt::collection::getDispatcher(vrt_dispatch_han_); auto const& proxy = proxy_; - dispatcher->broadcast(proxy, msg, handler_); + dispatcher->broadcast(proxy, reinterpret_cast(msg), handler_); } }}} /* end namespace vt::pipe::callback */ diff --git a/src/vt/vrt/collection/dispatch/dispatch.h b/src/vt/vrt/collection/dispatch/dispatch.h index 6ceba3c7e6..4ba527204d 100644 --- a/src/vt/vrt/collection/dispatch/dispatch.h +++ b/src/vt/vrt/collection/dispatch/dispatch.h @@ -61,9 +61,9 @@ struct DispatchCollectionBase { virtual ~DispatchCollectionBase() {} virtual void - broadcast(VirtualProxyType proxy, void* msg, HandlerType han) = 0; + broadcast(VirtualProxyType proxy, std::byte* msg, HandlerType han) = 0; virtual void - send(VirtualProxyType proxy, void* idx, void* msg, HandlerType han) = 0; + send(VirtualProxyType proxy, std::byte* idx, std::byte* msg, HandlerType han) = 0; template VirtualProxyType getDefaultProxy() const; @@ -83,9 +83,9 @@ struct DispatchCollectionBase { template struct DispatchCollection final : DispatchCollectionBase { private: - void broadcast(VirtualProxyType proxy, void* msg, HandlerType han) override; + void broadcast(VirtualProxyType proxy, std::byte* msg, HandlerType han) override; void send( - VirtualProxyType proxy, void* idx, void* msg, HandlerType han + VirtualProxyType proxy, std::byte* idx, std::byte* msg, HandlerType han ) override; }; diff --git a/src/vt/vrt/collection/dispatch/dispatch.impl.h b/src/vt/vrt/collection/dispatch/dispatch.impl.h index a794e84ccc..03efe0e806 100644 --- a/src/vt/vrt/collection/dispatch/dispatch.impl.h +++ b/src/vt/vrt/collection/dispatch/dispatch.impl.h @@ -56,7 +56,7 @@ namespace vt { namespace vrt { namespace collection { template void DispatchCollection::broadcast( - VirtualProxyType proxy, void* msg, HandlerType han + VirtualProxyType proxy, std::byte* msg, HandlerType han ) { using IdxT = typename ColT::IndexType; auto const msg_typed = reinterpret_cast(msg); @@ -68,7 +68,7 @@ void DispatchCollection::broadcast( template void DispatchCollection::send( - VirtualProxyType proxy, void* idx, void* msg, HandlerType han + VirtualProxyType proxy, std::byte* idx, std::byte* msg, HandlerType han ) { using IdxT = typename ColT::IndexType; auto const msg_typed = reinterpret_cast(msg); From 230c42542b932d0875de261f02b95f25f647e7a7 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Tue, 19 Mar 2024 15:36:28 +0100 Subject: [PATCH 16/23] #2063: Update void* to std::byte* in scatter --- src/vt/collective/scatter/scatter.cc | 2 +- src/vt/collective/scatter/scatter.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vt/collective/scatter/scatter.cc b/src/vt/collective/scatter/scatter.cc index 2ebf6eef6d..039e374f68 100644 --- a/src/vt/collective/scatter/scatter.cc +++ b/src/vt/collective/scatter/scatter.cc @@ -64,7 +64,7 @@ char* Scatter::applyScatterRecur( "Scatter::applyScatterRecur: elm_size={}, ptr={}, node={}\n", elm_size, print_ptr(ptr), node ); - data_fn(node, reinterpret_cast(cur_ptr)); + data_fn(node, reinterpret_cast(cur_ptr)); cur_ptr += elm_size; for (auto&& child : children) { vt_debug_print( diff --git a/src/vt/collective/scatter/scatter.h b/src/vt/collective/scatter/scatter.h index 291527211b..f93ff7ec1c 100644 --- a/src/vt/collective/scatter/scatter.h +++ b/src/vt/collective/scatter/scatter.h @@ -66,7 +66,7 @@ namespace vt { namespace collective { namespace scatter { */ struct Scatter : virtual collective::tree::Tree { using FuncSizeType = std::function; - using FuncDataType = std::function; + using FuncDataType = std::function; /** * \internal \brief Construct a scatter manager From f5757c2f657cef2c4a39bb25aedb5c915fa1cdeb Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Tue, 19 Mar 2024 15:57:57 +0100 Subject: [PATCH 17/23] #2063: Update void* to std::byte* in collection --- src/vt/context/runnable_context/collection.h | 4 ++-- src/vt/context/runnable_context/collection.impl.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vt/context/runnable_context/collection.h b/src/vt/context/runnable_context/collection.h index 8b1abd67ae..dcee9d1bc2 100644 --- a/src/vt/context/runnable_context/collection.h +++ b/src/vt/context/runnable_context/collection.h @@ -87,9 +87,9 @@ struct Collection { void resume(); private: - std::function set_; /**< Set context function */ + std::function set_; /**< Set context function */ std::function clear_; /**< Clear context function */ - void* elm_ = nullptr; /**< The element (untyped) */ + std::byte* elm_ = nullptr; /**< The element (untyped) */ }; }} /* end namespace vt::ctx */ diff --git a/src/vt/context/runnable_context/collection.impl.h b/src/vt/context/runnable_context/collection.impl.h index 403cc960f8..ebb8daccb9 100644 --- a/src/vt/context/runnable_context/collection.impl.h +++ b/src/vt/context/runnable_context/collection.impl.h @@ -54,9 +54,9 @@ template /*explicit*/ Collection::Collection( vrt::collection::Indexable* elm ) { - elm_ = elm; - set_ = [](void* in_elm){ - auto e = static_cast*>(in_elm); + elm_ = reinterpret_cast(elm); + set_ = [](std::byte* in_elm){ + auto e = reinterpret_cast*>(in_elm); auto& idx_ = e->getIndex(); auto proxy_ = e->getProxy(); vrt::collection::CollectionContextHolder::set(&idx_, proxy_); From ad45159e976ce9ad61e42220ff10a3c5b589cf9a Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Tue, 19 Mar 2024 16:03:30 +0100 Subject: [PATCH 18/23] #2063: Update void* to std::byte* in HolderUser --- src/vt/objgroup/holder/holder_user.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vt/objgroup/holder/holder_user.h b/src/vt/objgroup/holder/holder_user.h index fd5163c1c0..81f8546064 100644 --- a/src/vt/objgroup/holder/holder_user.h +++ b/src/vt/objgroup/holder/holder_user.h @@ -61,7 +61,7 @@ struct HolderUser final : HolderObjBase { public: ObjT* get() override { return *obj_; } bool exists() override { return obj_ != nullptr; } - void* getPtr() override { return *obj_; } + std::byte* getPtr() override { return reinterpret_cast(*obj_); } template void reset(Args&&... args) { From c20de237c530e13bb2e40af3e56279f84303de66 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Tue, 19 Mar 2024 16:08:22 +0100 Subject: [PATCH 19/23] #2063: Update void* in pipe manager --- src/vt/pipe/pipe_manager_base.cc | 2 +- src/vt/pipe/pipe_manager_base.impl.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vt/pipe/pipe_manager_base.cc b/src/vt/pipe/pipe_manager_base.cc index c302ae3bd8..e0a754912e 100644 --- a/src/vt/pipe/pipe_manager_base.cc +++ b/src/vt/pipe/pipe_manager_base.cc @@ -110,7 +110,7 @@ PipeType PipeManagerBase::makeCallbackFuncVoid( bool const& send_back = false; auto const& pipe_id = makePipeID(persist,send_back); - auto dispatch_fn = [pipe_id](void*) { + auto dispatch_fn = [pipe_id](std::byte*) { signal_holder_.deliverAll(pipe_id,nullptr); }; DispatchFuncType dfn = nullptr; diff --git a/src/vt/pipe/pipe_manager_base.impl.h b/src/vt/pipe/pipe_manager_base.impl.h index 402d4b042a..eee5f91835 100644 --- a/src/vt/pipe/pipe_manager_base.impl.h +++ b/src/vt/pipe/pipe_manager_base.impl.h @@ -147,7 +147,7 @@ PipeType PipeManagerBase::makeCallbackAny( * Create a dispatch function so any inputs can be dispatched without any * type information on the sending side */ - auto dispatch_fn = [pipe_id](void* input) { + auto dispatch_fn = [pipe_id](std::byte* input) { auto data = reinterpret_cast(input); signal_holder_.deliverAll(pipe_id,data); }; @@ -191,7 +191,7 @@ void PipeManagerBase::addListenerAny(PipeType const& pipe, ListenerT&& fn) { vtAssert(iter != pipe_state_.end(), "Pipe state must exist"); auto& state = iter->second; if (!state.hasDispatch()) { - auto fn2 = [pipe](void* input) { + auto fn2 = [pipe](std::byte* input) { auto data = reinterpret_cast(input); signal_holder_.deliverAll(pipe,data); }; From 5c1e2e977ef4ed2016372872a1b47993eeae063e Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Tue, 19 Mar 2024 16:32:25 +0100 Subject: [PATCH 20/23] #2063: Update void* to std::byte* --- src/vt/messaging/active.cc | 6 +++--- src/vt/pipe/callback/cb_union/cb_raw_base.h | 4 ++-- src/vt/vrt/collection/balance/greedylb/greedylb.cc | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index 0215cc4a25..4ac14777d3 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -255,16 +255,16 @@ EventType ActiveMessenger::sendMsgBytesWithPut( verbose, active, "sendMsgBytesWithPut: (put) put_ptr={}, size:[msg={},put={},rem={}]," "dest={}, max_pack_size={}, direct_buf_pack={}\n", - put_ptr, base.size(), put_size, rem_size, dest, max_pack_direct_size, + print_ptr(put_ptr), base.size(), put_size, rem_size, dest, max_pack_direct_size, print_bool(direct_buf_pack) ); } if (direct_buf_pack) { - new_msg_size = packMsg(msg, base.size(), reinterpret_cast(put_ptr), put_size); + new_msg_size = packMsg(msg, base.size(), put_ptr, put_size); } else { auto const& env_tag = envelopeGetPutTag(msg->env); auto const& ret = sendData( - PtrLenPairType{reinterpret_cast(put_ptr),put_size}, dest, env_tag + PtrLenPairType{put_ptr,put_size}, dest, env_tag ); auto const& ret_tag = ret.getTag(); if (ret_tag != env_tag) { diff --git a/src/vt/pipe/callback/cb_union/cb_raw_base.h b/src/vt/pipe/callback/cb_union/cb_raw_base.h index b0a337453d..05be09b89d 100644 --- a/src/vt/pipe/callback/cb_union/cb_raw_base.h +++ b/src/vt/pipe/callback/cb_union/cb_raw_base.h @@ -103,7 +103,7 @@ struct CallbackRawBaseSingle { CallbackRawBaseSingle( RawSendColDirTagType, PipeType const& in_pipe, HandlerType const in_handler, AutoHandlerType const in_vrt_handler, - void* index_bits + std::byte* index_bits ); CallbackRawBaseSingle( RawBcastObjGrpTagType, PipeType in_pipe, HandlerType in_handler, @@ -198,7 +198,7 @@ struct CallbackTyped : CallbackRawBaseSingle { CallbackTyped( RawSendColDirTagType, PipeType const& in_pipe, HandlerType const in_handler, AutoHandlerType const in_vrt_handler, - void* index_bits + std::byte* index_bits ) : CallbackRawBaseSingle( RawSendColDirTag,in_pipe,in_handler,in_vrt_handler,index_bits ) diff --git a/src/vt/vrt/collection/balance/greedylb/greedylb.cc b/src/vt/vrt/collection/balance/greedylb/greedylb.cc index a53d11b949..c82b6f818b 100644 --- a/src/vt/vrt/collection/balance/greedylb/greedylb.cc +++ b/src/vt/vrt/collection/balance/greedylb/greedylb.cc @@ -363,7 +363,7 @@ void GreedyLB::transferObjs(std::vector&& in_load) { max_recs, max_bytes ); theCollective()->scatter( - max_bytes*load.size(),max_bytes,nullptr,[&](NodeType node, void* ptr){ + max_bytes*load.size(),max_bytes,nullptr,[&](NodeType node, std::byte* ptr){ auto ptr_out = reinterpret_cast(ptr); auto const& proc = node_transfer[node]; auto const& rec_size = proc.size(); From 5207a52902b06804fd28738adbf7ee6bf45df411 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Fri, 22 Mar 2024 12:38:01 +0100 Subject: [PATCH 21/23] #2063: Update char* to std::byte* in Scatter --- src/vt/collective/scatter/scatter.cc | 8 ++++---- src/vt/collective/scatter/scatter.h | 4 ++-- src/vt/collective/scatter/scatter.impl.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/vt/collective/scatter/scatter.cc b/src/vt/collective/scatter/scatter.cc index 039e374f68..a5813a4397 100644 --- a/src/vt/collective/scatter/scatter.cc +++ b/src/vt/collective/scatter/scatter.cc @@ -52,19 +52,19 @@ Scatter::Scatter() : tree::Tree(tree::tree_cons_tag_t) { } -char* Scatter::applyScatterRecur( - NodeType node, char* ptr, std::size_t elm_size, FuncSizeType size_fn, +std::byte* Scatter::applyScatterRecur( + NodeType node, std::byte* ptr, std::size_t elm_size, FuncSizeType size_fn, FuncDataType data_fn ) { // pre-order k-ary tree traversal for data layout auto children = Tree::getChildren(node); - char* cur_ptr = ptr; + auto cur_ptr = ptr; vt_debug_print( normal, scatter, "Scatter::applyScatterRecur: elm_size={}, ptr={}, node={}\n", elm_size, print_ptr(ptr), node ); - data_fn(node, reinterpret_cast(cur_ptr)); + data_fn(node, cur_ptr); cur_ptr += elm_size; for (auto&& child : children) { vt_debug_print( diff --git a/src/vt/collective/scatter/scatter.h b/src/vt/collective/scatter/scatter.h index f93ff7ec1c..fb4d1cd11e 100644 --- a/src/vt/collective/scatter/scatter.h +++ b/src/vt/collective/scatter/scatter.h @@ -130,8 +130,8 @@ struct Scatter : virtual collective::tree::Tree { * * \return incremented point after scatter is complete */ - char* applyScatterRecur( - NodeType node, char* ptr, std::size_t elm_size, FuncSizeType size_fn, + std::byte* applyScatterRecur( + NodeType node, std::byte* ptr, std::size_t elm_size, FuncSizeType size_fn, FuncDataType data_fn ); diff --git a/src/vt/collective/scatter/scatter.impl.h b/src/vt/collective/scatter/scatter.impl.h index 7d1fb7d896..20b9c690c3 100644 --- a/src/vt/collective/scatter/scatter.impl.h +++ b/src/vt/collective/scatter/scatter.impl.h @@ -84,11 +84,11 @@ void Scatter::scatter( print_ptr(ptr), remaining_size ); auto const& root_node = 0; - auto nptr = applyScatterRecur(root_node, ptr, elm_size, size_fn, data_fn); + auto nptr = applyScatterRecur(root_node, reinterpret_cast(ptr), elm_size, size_fn, data_fn); vt_debug_print( - verbose, scatter, "Scatter::scatter: incremented size={}\n", nptr - ptr + verbose, scatter, "Scatter::scatter: incremented size={}\n", nptr - reinterpret_cast(ptr) ); - vtAssert(nptr == ptr + combined_size, "nptr must match size"); + vtAssert(nptr == reinterpret_cast(ptr + combined_size), "nptr must match size"); auto const& handler = auto_registry::makeScatterHandler(); auto const& this_node = theContext()->getNode(); scatter_msg->user_han = handler; From 2f0d87cb812fdcd3f77d4f6f70ca9259d46bbeb4 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Fri, 22 Mar 2024 13:14:06 +0100 Subject: [PATCH 22/23] #2063: Update void* to std::byte* in auto registry --- src/vt/registry/auto/auto_registry_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vt/registry/auto/auto_registry_impl.h b/src/vt/registry/auto/auto_registry_impl.h index a36a133697..fb33045221 100644 --- a/src/vt/registry/auto/auto_registry_impl.h +++ b/src/vt/registry/auto/auto_registry_impl.h @@ -130,7 +130,7 @@ inline HandlerType makeScatterHandler() { using AdapterT = FunctorAdapter, f, MessageT>; using ContainerType = ScatterContainerType; using RegInfoType = AutoRegInfoType; - using FuncType = void (*)(void*); + using FuncType = void (*)(std::byte*); using RunType = RunnableGen; constexpr bool is_auto = true; From 463661b7ea9f7f959abd0f788e6dfe8e829b2d75 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Fri, 22 Mar 2024 15:57:01 +0100 Subject: [PATCH 23/23] #2063: Clean up casts --- src/vt/collective/scatter/scatter.impl.h | 8 ++++---- src/vt/messaging/active.cc | 20 +++++++++---------- src/vt/pool/pool.cc | 2 +- src/vt/rdma/rdma.cc | 18 ++++++++--------- src/vt/rdma/state/rdma_state.cc | 2 +- .../messaging/serialized_messenger.impl.h | 4 ++-- tests/unit/pool/test_pool.cc | 2 +- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/vt/collective/scatter/scatter.impl.h b/src/vt/collective/scatter/scatter.impl.h index 20b9c690c3..ac827d21c6 100644 --- a/src/vt/collective/scatter/scatter.impl.h +++ b/src/vt/collective/scatter/scatter.impl.h @@ -65,7 +65,7 @@ void Scatter::scatter( auto scatter_msg = makeMessageSz(combined_size, combined_size, elm_size); vtAssert(total_size == combined_size, "Sizes must be consistent"); - auto ptr = reinterpret_cast(scatter_msg.get()) + sizeof(ScatterMsg); + auto ptr = reinterpret_cast(scatter_msg.get()) + sizeof(ScatterMsg); #if vt_check_enabled(memory_pool) auto remaining_size = thePool()->remainingSize(reinterpret_cast(scatter_msg.get())); @@ -84,11 +84,11 @@ void Scatter::scatter( print_ptr(ptr), remaining_size ); auto const& root_node = 0; - auto nptr = applyScatterRecur(root_node, reinterpret_cast(ptr), elm_size, size_fn, data_fn); + auto nptr = applyScatterRecur(root_node, ptr, elm_size, size_fn, data_fn); vt_debug_print( - verbose, scatter, "Scatter::scatter: incremented size={}\n", nptr - reinterpret_cast(ptr) + verbose, scatter, "Scatter::scatter: incremented size={}\n", nptr - ptr ); - vtAssert(nptr == reinterpret_cast(ptr + combined_size), "nptr must match size"); + vtAssert(nptr == ptr + combined_size, "nptr must match size"); auto const& handler = auto_registry::makeScatterHandler(); auto const& this_node = theContext()->getNode(); scatter_msg->user_han = handler; diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index 4ac14777d3..32e6f32f8c 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -300,7 +300,7 @@ struct MultiMsg : vt::Message { } void ActiveMessenger::handleChunkedMultiMsg(MultiMsg* msg) { - auto buf = reinterpret_cast(thePool()->alloc(msg->getSize())); + auto buf = thePool()->alloc(msg->getSize()); auto const size = msg->getSize(); auto const info = msg->getInfo(); @@ -703,7 +703,7 @@ bool ActiveMessenger::recvDataMsgBuffer( MPI_Get_count(&stat, MPI_BYTE, &num_probe_bytes); std::byte* buf = user_buf == nullptr ? - reinterpret_cast(thePool()->alloc(num_probe_bytes)) : + thePool()->alloc(num_probe_bytes) : user_buf; NodeType const sender = stat.MPI_SOURCE; @@ -760,7 +760,7 @@ void ActiveMessenger::recvDataDirect( std::vector reqs; reqs.resize(nchunks); - char* cbuf = reinterpret_cast(buf); + std::byte* cbuf = buf; MsgSizeType remainder = len; auto const max_per_send = theConfig()->vt_max_mpi_send_size; for (int i = 0; i < nchunks; i++) { @@ -801,7 +801,7 @@ void ActiveMessenger::recvDataDirect( } InProgressDataIRecv recv{ - reinterpret_cast(cbuf), len, from, std::move(reqs), is_user_buf ? buf : nullptr, dealloc, + cbuf, len, from, std::move(reqs), is_user_buf ? buf : nullptr, dealloc, next, prio }; @@ -998,7 +998,7 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() { if (flag == 1) { MPI_Get_count(&stat, MPI_BYTE, &num_probe_bytes); - char* buf = reinterpret_cast(thePool()->alloc(num_probe_bytes)); + std::byte* buf = thePool()->alloc(num_probe_bytes); NodeType const sender = stat.MPI_SOURCE; @@ -1032,7 +1032,7 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() { #endif } - InProgressIRecv recv_holder{reinterpret_cast(buf), num_probe_bytes, sender, req}; + InProgressIRecv recv_holder{buf, num_probe_bytes, sender, req}; int num_mpi_tests = 0; auto done = recv_holder.test(num_mpi_tests); @@ -1051,7 +1051,7 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() { } void ActiveMessenger::finishPendingActiveMsgAsyncRecv(InProgressIRecv* irecv) { - char* buf = reinterpret_cast(irecv->buf); + std::byte* buf = irecv->buf; auto num_probe_bytes = irecv->probe_bytes; auto sender = irecv->sender; @@ -1089,18 +1089,18 @@ void ActiveMessenger::finishPendingActiveMsgAsyncRecv(InProgressIRecv* irecv) { if (put_tag == PutPackedTag) { auto const put_size = envelopeGetPutSize(msg->env); auto const msg_size = num_probe_bytes - put_size; - char* put_ptr = buf + msg_size; + std::byte* put_ptr = buf + msg_size; if (!is_term || vt_check_enabled(print_term_msgs)) { vt_debug_print( verbose, active, "finishPendingActiveMsgAsyncRecv: packed put: ptr={}, msg_size={}, " "put_size={}\n", - put_ptr, msg_size, put_size + print_ptr(put_ptr), msg_size, put_size ); } - envelopeSetPutPtrOnly(msg->env, reinterpret_cast(put_ptr)); + envelopeSetPutPtrOnly(msg->env, put_ptr); put_finished = true; } else { /*bool const put_delivered = */recvDataMsg( diff --git a/src/vt/pool/pool.cc b/src/vt/pool/pool.cc index 45beebab71..5a9603273f 100644 --- a/src/vt/pool/pool.cc +++ b/src/vt/pool/pool.cc @@ -151,7 +151,7 @@ std::byte* Pool::defaultAlloc(size_t const& num_bytes, size_t const& oversize) { } void Pool::defaultDealloc(std::byte* const ptr) { - std::free(reinterpret_cast(ptr)); + std::free(ptr); } std::byte* Pool::alloc(size_t const& num_bytes, size_t oversize) { diff --git a/src/vt/rdma/rdma.cc b/src/vt/rdma/rdma.cc index d1859dbd12..3caaaa4396 100644 --- a/src/vt/rdma/rdma.cc +++ b/src/vt/rdma/rdma.cc @@ -135,7 +135,7 @@ RDMAManager::RDMAManager() ); } else { theMsg()->recvDataMsgBuffer( - msg->nchunks, reinterpret_cast(get_ptr), msg->mpi_tag_to_recv, msg->send_back, true, + msg->nchunks, get_ptr, msg->mpi_tag_to_recv, msg->send_back, true, [get_ptr_action]{ vt_debug_print( normal, rdma, @@ -178,9 +178,9 @@ RDMAManager::RDMAManager() ); if (direct) { - auto data_ptr = reinterpret_cast(msg) + sizeof(PutMessage); + auto data_ptr = reinterpret_cast(msg) + sizeof(PutMessage); theRDMA()->triggerPutRecvData( - msg->rdma_handle, msg_tag, reinterpret_cast(data_ptr), msg->num_bytes, msg->offset, [=]{ + msg->rdma_handle, msg_tag, data_ptr, msg->num_bytes, msg->offset, [=]{ vt_debug_print( normal, rdma, "put_data: after put trigger: send_back={}\n", send_back @@ -238,10 +238,10 @@ RDMAManager::RDMAManager() }); } else { auto const& put_ptr_offset = - msg->offset != no_byte ? reinterpret_cast(put_ptr) + msg->offset : reinterpret_cast(put_ptr); + msg->offset != no_byte ? put_ptr + msg->offset : put_ptr; // do a direct recv into the user buffer theMsg()->recvDataMsgBuffer( - msg->nchunks, reinterpret_cast(put_ptr_offset), recv_tag, recv_node, true, []{}, + msg->nchunks, put_ptr_offset, recv_tag, recv_node, true, []{}, [=](RDMA_GetType ptr, ActionType deleter){ vt_debug_print( normal, rdma, @@ -780,7 +780,7 @@ void RDMAManager::putRegionTypeless( auto const& elm_size = region.elm_size; auto const& rlo = region.lo; auto const& roffset = lo - rlo; - auto const& ptr_offset = reinterpret_cast(ptr) + (roffset * elm_size); + auto const& ptr_offset = ptr + (roffset * elm_size); auto const& block_offset = (lo - blk_lo) * elm_size; vt_debug_print( @@ -794,7 +794,7 @@ void RDMAManager::putRegionTypeless( remote_action->addDep(); putData( - han, reinterpret_cast(ptr_offset), (hi-lo)*elm_size, block_offset, no_tag, elm_size, + han, ptr_offset, (hi-lo)*elm_size, block_offset, no_tag, elm_size, [=]{ remote_action->release(); }, node ); }); @@ -842,7 +842,7 @@ void RDMAManager::getRegionTypeless( auto const& elm_size = region.elm_size; auto const& rlo = region.lo; auto const& roffset = lo - rlo; - auto const& ptr_offset = reinterpret_cast(ptr) + (roffset * elm_size); + auto const& ptr_offset = ptr + (roffset * elm_size); auto const& block_offset = (lo - blk_lo) * elm_size; vt_debug_print( @@ -855,7 +855,7 @@ void RDMAManager::getRegionTypeless( action->addDep(); getDataIntoBuf( - han, reinterpret_cast(ptr_offset), (hi-lo)*elm_size, block_offset, no_tag, [=]{ + han, ptr_offset, (hi-lo)*elm_size, block_offset, no_tag, [=]{ auto const& my_node = theContext()->getNode(); vt_debug_print( normal, rdma, diff --git a/src/vt/rdma/state/rdma_state.cc b/src/vt/rdma/state/rdma_state.cc index a08fd751a3..21e920850f 100644 --- a/src/vt/rdma/state/rdma_state.cc +++ b/src/vt/rdma/state/rdma_state.cc @@ -216,7 +216,7 @@ bool State::testReadyPutData(TagType const& tag) { "To use default handler ptr, bytes must be set" ); - std::memcpy(reinterpret_cast(state.ptr) + req_offset, in_ptr, req_num_bytes); + std::memcpy(state.ptr + req_offset, in_ptr, req_num_bytes); } void State::getData( diff --git a/src/vt/serialization/messaging/serialized_messenger.impl.h b/src/vt/serialization/messaging/serialized_messenger.impl.h index a924ddcf6d..250cb4657a 100644 --- a/src/vt/serialization/messaging/serialized_messenger.impl.h +++ b/src/vt/serialization/messaging/serialized_messenger.impl.h @@ -392,8 +392,8 @@ template if (node != dest) { auto sys_msg = makeMessage>(); auto send_serialized = [=](Active::SendFnType send){ - auto void_ptr = reinterpret_cast(ptr); - auto ret = send(RDMA_GetType{void_ptr, ptr_size}, dest, no_tag); + auto byte_ptr = reinterpret_cast(ptr); + auto ret = send(RDMA_GetType{byte_ptr, ptr_size}, dest, no_tag); EventType event = ret.getEvent(); theEvent()->attachAction(event, [=]{ std::free(ptr); }); sys_msg->data_recv_tag = ret.getTag(); diff --git a/tests/unit/pool/test_pool.cc b/tests/unit/pool/test_pool.cc index 81aaadebbd..09c379fb38 100644 --- a/tests/unit/pool/test_pool.cc +++ b/tests/unit/pool/test_pool.cc @@ -108,7 +108,7 @@ TEST_F(TestPool, pool_alloc) { for (size_t cur_bytes = 1; cur_bytes < max_bytes; cur_bytes *= 2) { std::byte* ptr = testPool->alloc(cur_bytes); - std::memset(reinterpret_cast(ptr), init_val, cur_bytes); + std::memset(ptr, init_val, cur_bytes); //fmt::print("alloc {} bytes, ptr={}\n", cur_bytes, ptr); EXPECT_NE(ptr, nullptr); for (size_t i = 0; i < cur_bytes; i++) {