Skip to content

Commit ca8f86e

Browse files
committed
Clearer registered slot backend + remember also local slots
1 parent 08f30ca commit ca8f86e

File tree

2 files changed

+45
-21
lines changed

2 files changed

+45
-21
lines changed

include/graphblas/bsp/rdma.hpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace grb {
7373
lpf_rc = lpf_rc ? lpf_rc : lpf_sync( data.context, LPF_SYNC_DEFAULT );
7474

7575
data.signalMemslotTaken();
76-
data.registered_slots.insert({ buf, std::make_pair( size, memslot ) });
76+
data.registered_slots.insert({ buf, grb::internal::registered_slot(buf, memslot, size, true ) });
7777
data.global_memslots.insert({ memslot, buf });
7878

7979
if( lpf_rc == LPF_SUCCESS ) {
@@ -105,7 +105,7 @@ namespace grb {
105105
const auto it0 = data.registered_slots.find( buf );
106106
assert( it0 != data.registered_slots.end() );
107107

108-
memslot = it0->second.second;
108+
memslot = it0->second.slot;
109109
data.registered_slots.erase( it0 );
110110

111111
const auto it1 = data.global_memslots.find( memslot );
@@ -163,18 +163,20 @@ namespace grb {
163163
{
164164
const auto it = data.registered_slots.find( src );
165165
assert( it != data.registered_slots.end() );
166-
assert( it->second.first >= size );
167-
src_memslot = it->second.second;
166+
assert( it->second.size >= size );
167+
assert( it->second.global );
168+
src_memslot = it->second.slot;
168169
}
169170

170171
const auto it = data.registered_slots.find( dst );
171172
if( it == data.registered_slots.end() ){
172173
lpf_rc = lpf_rc ? lpf_rc : lpf_register_local( data.context, const_cast< void* >( dst ), size, &dst_memslot );
173174
data.signalMemslotTaken();
175+
data.registered_slots.insert({dst, grb::internal::registered_slot( dst, dst_memslot, size, false )});
174176
} else {
175-
assert( it->first == dst );
176-
assert( it->second.first >= size );
177-
dst_memslot = it->second.second;
177+
assert( it->second.buf == dst );
178+
assert( it->second.size >= size );
179+
dst_memslot = it->second.slot;
178180
}
179181

180182
lpf_rc = lpf_rc ? lpf_rc : lpf_get( data.context, src_pid, src_memslot , 0, dst_memslot, 0, size, lpf_attr );
@@ -229,18 +231,21 @@ namespace grb {
229231
{
230232
const auto it = data.registered_slots.find( dst );
231233
assert( it != data.registered_slots.end() );
232-
assert( it->second.first >= size );
233-
dst_memslot = it->second.second;
234+
assert( it->second.buf == dst );
235+
assert( it->second.size >= size );
236+
assert( it->second.global );
237+
dst_memslot = it->second.slot;
234238
}
235239

236240
const auto it = data.registered_slots.find( src );
237241
if( it == data.registered_slots.end() ){
238242
lpf_rc = lpf_rc ? lpf_rc : lpf_register_local( data.context, const_cast< void* >( src ), size, &src_memslot );
239243
data.signalMemslotTaken();
244+
data.registered_slots.insert({src, grb::internal::registered_slot( src, src_memslot, size, false )});
240245
} else {
241-
assert( it->first == src );
242-
assert( it->second.first >= size ); // is there enough space?
243-
src_memslot = it->second.second;
246+
assert( it->second.buf == src );
247+
assert( it->second.size >= size ); // is there enough space?
248+
src_memslot = it->second.slot;
244249
}
245250

246251
lpf_rc = lpf_rc ? lpf_rc : lpf_put( data.context, src_memslot, 0, dst_pid, dst_memslot, 0, size, lpf_attr );

include/graphblas/bsp1d/init.hpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ namespace grb {
5656
size_t size;
5757

5858
get_request(
59-
lpf_pid_t src_pid,
60-
lpf_memslot_t src,
61-
size_t src_offset,
59+
const lpf_pid_t src_pid,
60+
const lpf_memslot_t src,
61+
const size_t src_offset,
6262
const void * dst,
63-
size_t size
63+
const size_t size
6464
)
6565
: src_pid(src_pid)
6666
, src(src)
@@ -80,10 +80,10 @@ namespace grb {
8080

8181
put_request(
8282
const void * src,
83-
lpf_pid_t dst_pid,
84-
lpf_memslot_t dst,
85-
size_t dst_offset,
86-
size_t size
83+
const lpf_pid_t dst_pid,
84+
const lpf_memslot_t dst,
85+
const size_t dst_offset,
86+
const size_t size
8787
)
8888
: src(src)
8989
, dst_pid(dst_pid)
@@ -93,6 +93,25 @@ namespace grb {
9393
{}
9494
};
9595

96+
struct registered_slot {
97+
const void * buf;
98+
lpf_memslot_t slot;
99+
size_t size;
100+
bool global;
101+
102+
registered_slot(
103+
const void * buf,
104+
const lpf_memslot_t slot,
105+
const size_t size,
106+
const bool global
107+
)
108+
: buf(buf)
109+
, slot(slot)
110+
, size(size)
111+
, global(global)
112+
{}
113+
};
114+
96115
/**
97116
* These are all user process local data elements required to successfully
98117
* execute parallel ALP calls.
@@ -223,7 +242,7 @@ namespace grb {
223242
utils::DMapper< uintptr_t > mapper;
224243

225244
/** Map of globally registered addresses. */
226-
std::map< const void* , std::pair< const size_t, const lpf_memslot_t > > registered_slots;
245+
std::map< const void* , registered_slot > registered_slots;
227246

228247
/** Map of registered memory slots to their address. */
229248
std::map< const lpf_memslot_t , const void* > global_memslots;

0 commit comments

Comments
 (0)