Skip to content

Commit

Permalink
#2063: Update void* to std::byte* in runnable
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable authored and cwschilly committed Sep 20, 2024
1 parent e50d919 commit 07a54f6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/vt/collective/scatter/scatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::byte*>(in_base_ptr), nullptr);
}

/*static*/ void Scatter::scatterHandler(ScatterMsg* msg) {
Expand Down
12 changes: 6 additions & 6 deletions src/vt/registry/auto/auto_registry_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename MsgT, typename HandlerT, typename ObjT>
Expand Down Expand Up @@ -100,11 +100,11 @@ struct HandlersDispatcher final : BaseHandlersDispatcher {
detection::is_detected_convertible<std::true_type, ColTrait, U>;

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<MsgT*>(base_msg);
[[maybe_unused]] auto elm = static_cast<ObjT*>(object);
[[maybe_unused]] auto elm = reinterpret_cast<ObjT*>(object);

if constexpr (std::is_same_v<T, ActiveVoidFnType*>) {
fp();
Expand Down Expand Up @@ -183,19 +183,19 @@ 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 <typename MsgT, typename HandlerT, typename ObjT>
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<T, ActiveTypedFnType<MsgT>*>) {
fp(static_cast<MsgT*>(msg));
fp(reinterpret_cast<MsgT*>(msg));
} else {
vtAbort("Invalid function type for scatter handler");
}
Expand Down
2 changes: 1 addition & 1 deletion src/vt/runnable/make_runnable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::byte*>(elm), handler_);
}
return std::move(*this);
}
Expand Down
8 changes: 4 additions & 4 deletions src/vt/runnable/runnable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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<std::byte*>(elm);
}

void RunnableNew::setupHandlerElement(
vrt::VirtualContext* elm, HandlerType handler
) {
f_.func_ = auto_registry::getAutoHandlerVC(handler).get();
obj_ = elm;
obj_ = reinterpret_cast<std::byte*>(elm);
}

void RunnableNew::run() {
Expand Down Expand Up @@ -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<std::byte*>(msg_.get()), obj_);
} else {
f_.func_->dispatch(msg_ == nullptr ? nullptr : msg_.get(), obj_);
}
Expand Down
4 changes: 2 additions & 2 deletions src/vt/runnable/runnable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -356,7 +356,7 @@ struct RunnableNew {
private:
detail::Contexts contexts_; /**< The contexts */
MsgSharedPtr<BaseMsgType> msg_ = nullptr; /**< The associated message */
void* obj_ = nullptr; /**< Object pointer */
std::byte* obj_ = nullptr; /**< Object pointer */
union {
DispatcherType func_;
DispatcherScatterType func_scat_;
Expand Down

0 comments on commit 07a54f6

Please sign in to comment.