Skip to content

Commit

Permalink
#1554: DR: add new indexed reader
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Oct 19, 2021
1 parent 2d68a49 commit 83f885f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
35 changes: 31 additions & 4 deletions src/vt/datarep/dr.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Reader<T> DataReplicator::makeReader(DataRepIDType handle) {
"makeReader: handle_id={}\n",
handle
);
return Reader<T>{typename Reader<T>::READER_CONSTRUCT_TAG{}, handle};
return Reader<T>{handle};
}

template <typename T>
Expand Down Expand Up @@ -92,6 +92,23 @@ DR<T, typename ProxyType::IndexType> DataReplicator::makeIndexedHandle(
return DR<T, IndexType>{TagType{}, proxy_bits, index, tag};
}

template <typename T, typename ProxyType>
Reader<T, typename ProxyType::IndexType> DataReplicator::makeIndexedReader(
ProxyType proxy, TagType tag
) {
using IndexType = typename ProxyType::IndexType;

auto proxy_bits = proxy.getCollectionProxy();
auto index = proxy.getElementProxy().getIndex();
vt_debug_print(
normal, gen,
"makeIndexedReader: proxy={:x}, index={}, tag={}\n",
proxy_bits, index, tag
);

return Reader<T, IndexType>{proxy_bits, index, tag};
}

template <typename T, typename IndexT>
void DataReplicator::publishVersion(
detail::DR_Base<IndexT> dr_base, DataVersionType version, T&& data
Expand Down Expand Up @@ -195,13 +212,23 @@ bool DataReplicator::requestData(
"requestData: handle_id={} remote request\n", handle
);
waiting_[handle].push_back(reader);
auto tr = static_cast<Reader<T, IndexT>*>(reader);

using MsgType = detail::DataRequestMsg<T, IndexT>;
auto const this_node = theContext()->getNode();
auto msg = makeMessage<MsgType>(dr_base, this_node, version);
theLocMan()->dataRep->routeMsgHandler<MsgType, staticRequestHandler<T, IndexT>>(
handle, getHomeNode(handle), msg.get()
);
if (tr->isProxy()) {
// auto const proxy_bits = tr->getHandleID();
// auto const idx = tr->getIndex();
// auto lm = theLocMan()->getCollectionLM<IndexT>(proxy);
vtAssert(false, "Unimplemented");
return false;
} else {
auto lm = theLocMan()->dataRep.get();
lm->routeMsgHandler<MsgType, staticRequestHandler<T, IndexT>>(
handle, getHomeNode(handle), msg.get()
);
}
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/vt/datarep/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace vt { namespace datarep {

template <typename T, typename IndexT = int8_t>
struct Reader : detail::DR_Base<IndexT> {
Reader() = default;
explicit Reader(DataRepIDType in_handle)
: detail::DR_Base<IndexT>(in_handle)
{ }
Expand Down

0 comments on commit 83f885f

Please sign in to comment.