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++) {