Commit 94fdc267 authored by Matthieu Dorier's avatar Matthieu Dorier

added more utility function for bulk

parent 0b8767b7
......@@ -53,6 +53,10 @@ private:
~bulk_segment() = default;
resolved_bulk on(const endpoint& ep) const;
std::size_t operator>>(const resolved_bulk& b) const;
std::size_t operator<<(const resolved_bulk& b) const;
};
public:
......@@ -113,10 +117,16 @@ public:
return m_bulk == HG_BULK_NULL;
}
resolved_bulk on(const endpoint& ep) const;
bulk_segment select(std::size_t offset, std::size_t size) const;
bulk_segment operator()(std::size_t offset, std::size_t size) const;
std::size_t operator>>(const resolved_bulk& b) const;
std::size_t operator<<(const resolved_bulk& b) const;
template<typename A>
void save(A& ar) {
hg_size_t s = margo_bulk_get_serialize_size(m_bulk, HG_TRUE);
......
......@@ -20,4 +20,23 @@ resolved_bulk bulk::bulk_segment::on(const endpoint& ep) const {
return resolved_bulk(*this, ep);
}
resolved_bulk bulk::on(const endpoint& ep) const {
return resolved_bulk(*this, ep);
}
std::size_t bulk::bulk_segment::operator>>(const resolved_bulk& b) const {
return b << *this;
}
std::size_t bulk::bulk_segment::operator<<(const resolved_bulk& b) const {
return b >> *this;
}
std::size_t bulk::operator>>(const resolved_bulk& b) const {
return b << (this->select(0,size()));
}
std::size_t bulk::operator<<(const resolved_bulk& b) const {
return b >> (this->select(0,size()));
}
}
......@@ -9,8 +9,7 @@
namespace thallium {
std::size_t resolved_bulk::operator>>(const bulk::bulk_segment& dest) const {
// TODO check that dest is local
// TODO check that the requested sizes are ok
margo_instance_id mid = m_segment.m_bulk.m_engine->m_mid;
hg_bulk_op_t op = HG_BULK_PULL;
hg_addr_t origin_addr = m_endpoint.m_addr;
......@@ -20,6 +19,8 @@ std::size_t resolved_bulk::operator>>(const bulk::bulk_segment& dest) const {
size_t local_offset = dest.m_offset;
size_t size = dest.m_size;
if(size > m_segment.m_size) size = m_segment.m_size;
hg_return_t ret = margo_bulk_transfer(mid, op,
origin_addr, origin_handle, origin_offset,
local_handle, local_offset, size);
......@@ -29,9 +30,6 @@ std::size_t resolved_bulk::operator>>(const bulk::bulk_segment& dest) const {
std::size_t resolved_bulk::operator<<(const bulk::bulk_segment& src) const {
// TODO check that src is local
// TODO check that requested sizes or ok
margo_instance_id mid = m_segment.m_bulk.m_engine->m_mid;
hg_bulk_op_t op = HG_BULK_PUSH;
hg_addr_t origin_addr = m_endpoint.m_addr;
......@@ -41,6 +39,8 @@ std::size_t resolved_bulk::operator<<(const bulk::bulk_segment& src) const {
size_t local_offset = src.m_offset;
size_t size = src.m_size;
if(size > m_segment.m_size) size = m_segment.m_size;
hg_return_t ret = margo_bulk_transfer(mid, op,
origin_addr, origin_handle, origin_offset,
local_handle, local_offset, size);
......
......@@ -21,7 +21,7 @@ int server() {
seg[0].first = (void*)(&v[0]);
seg[0].second = v.size();
tl::bulk local = margo.expose(seg, tl::bulk_mode::write_only);
b(1,5).on(ep) >> local(0,5);
b(1,5).on(ep) >> local;
std::cout << "Server received bulk: ";
for(auto c : v) std::cout << c;
std::cout << std::endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment