Skip to content

Commit bf61961

Browse files
committed
oshmem: code review fixes
Signed-off-by: Alex Mikheev <[email protected]>
1 parent f133d9b commit bf61961

File tree

3 files changed

+22
-49
lines changed

3 files changed

+22
-49
lines changed

oshmem/mca/memheap/base/base.h

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,24 +162,22 @@ extern int mca_memheap_seg_cmp(const void *k, const void *v);
162162

163163
extern mca_memheap_map_t* memheap_map;
164164

165-
static inline int map_segment_is_va_in(map_base_segment_t *s, const void *va)
165+
static inline int map_segment_is_va_in(map_base_segment_t *s, void *va)
166166
{
167-
return ((uintptr_t)va >= (uintptr_t)s->va_base &&
168-
(uintptr_t)va < (uintptr_t)s->va_end);
167+
return (va >= s->va_base && va < s->va_end);
169168
}
170169

171-
static inline map_segment_t *memheap_find_seg(const int segno)
170+
static inline map_segment_t *memheap_find_seg(int segno)
172171
{
173172
return &mca_memheap_base_map.mem_segs[segno];
174173
}
175174

176-
static inline int memheap_is_va_in_segment(const void *va, const int segno)
175+
static inline int memheap_is_va_in_segment(void *va, int segno)
177176
{
178-
179177
return map_segment_is_va_in(&memheap_find_seg(segno)->super, va);
180178
}
181179

182-
static inline int memheap_find_segnum(const void *va)
180+
static inline int memheap_find_segnum(void *va)
183181
{
184182
if (OPAL_LIKELY(memheap_is_va_in_segment(va, SYMB_SEG_INDEX))) {
185183
return SYMB_SEG_INDEX;
@@ -189,19 +187,19 @@ static inline int memheap_find_segnum(const void *va)
189187
return MEMHEAP_SEG_INVALID;
190188
}
191189

192-
static inline void* memheap_va2rva(const void* va, const void* local_base, const void* remote_base)
190+
static inline void* memheap_va2rva(void* va, void* local_base, void* remote_base)
193191
{
194192
return (void*) (remote_base > local_base ?
195193
(uintptr_t)va + ((uintptr_t)remote_base - (uintptr_t)local_base) :
196194
(uintptr_t)va - ((uintptr_t)local_base - (uintptr_t)remote_base));
197195
}
198196

199-
static inline void *map_segment_va2rva(mkey_segment_t *seg, const void *va)
197+
static inline void *map_segment_va2rva(mkey_segment_t *seg, void *va)
200198
{
201199
return memheap_va2rva(va, seg->super.va_base, seg->rva_base);
202200
}
203201

204-
static inline map_base_segment_t *map_segment_find_va(map_base_segment_t *segs, size_t elem_size, const void *va)
202+
static inline map_base_segment_t *map_segment_find_va(map_base_segment_t *segs, size_t elem_size, void *va)
205203
{
206204
map_base_segment_t *rseg;
207205

@@ -220,8 +218,7 @@ static inline map_base_segment_t *map_segment_find_va(map_base_segment_t *segs,
220218

221219
void mkey_segment_init(mkey_segment_t *seg, sshmem_mkey_t *mkey, uint32_t segno);
222220

223-
224-
static inline map_segment_t *memheap_find_va(const void* va)
221+
static inline map_segment_t *memheap_find_va(void* va)
225222
{
226223
map_segment_t *s;
227224

@@ -296,7 +293,6 @@ static inline void* mca_memheap_seg2base_va(int seg)
296293
return memheap_map->mem_segs[seg].super.va_base;
297294
}
298295

299-
300296
END_C_DECLS
301297

302298
#endif /* MCA_MEMHEAP_BASE_H */

oshmem/mca/memheap/base/memheap_base_mkey.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,21 @@ int mca_memheap_seg_cmp(const void *k, const void *v)
8585

8686
static int pack_local_mkeys(opal_buffer_t *msg, int pe, int seg)
8787
{
88-
int i, n, tr_id;
88+
int i, n;
8989
sshmem_mkey_t *mkey;
9090

9191
/* go over all transports and pack mkeys */
9292
n = memheap_map->num_transports;
9393
opal_dss.pack(msg, &n, 1, OPAL_UINT32);
9494
MEMHEAP_VERBOSE(5, "found %d transports to %d", n, pe);
9595
for (i = 0; i < n; i++) {
96-
tr_id = i;
97-
mkey = mca_memheap_base_get_mkey(mca_memheap_seg2base_va(seg), tr_id);
96+
mkey = mca_memheap_base_get_mkey(mca_memheap_seg2base_va(seg), i);
9897
if (!mkey) {
9998
MEMHEAP_ERROR("seg#%d tr_id: %d failed to find local mkey",
100-
seg, tr_id);
99+
seg, i);
101100
return OSHMEM_ERROR;
102101
}
103-
opal_dss.pack(msg, &tr_id, 1, OPAL_UINT32);
102+
opal_dss.pack(msg, &i, 1, OPAL_UINT32);
104103
opal_dss.pack(msg, &mkey->va_base, 1, OPAL_UINT64);
105104
if (0 == mkey->va_base) {
106105
opal_dss.pack(msg, &mkey->u.key, 1, OPAL_UINT64);
@@ -112,7 +111,7 @@ static int pack_local_mkeys(opal_buffer_t *msg, int pe, int seg)
112111
}
113112
MEMHEAP_VERBOSE(5,
114113
"seg#%d tr_id: %d %s",
115-
seg, tr_id, mca_spml_base_mkey2str(mkey));
114+
seg, i, mca_spml_base_mkey2str(mkey));
116115
}
117116
return OSHMEM_SUCCESS;
118117
}
@@ -470,13 +469,6 @@ static int memheap_oob_get_mkeys(int pe, uint32_t seg, sshmem_mkey_t *mkeys)
470469
pe,
471470
i,
472471
mca_spml_base_mkey2str(&mkeys[i]));
473-
int my_pe = oshmem_my_proc_id();
474-
if (my_pe == 0)
475-
printf(
476-
"MKEY CALCULATED BY LOCAL SPML: pe: %d tr_id: %d %s\n",
477-
pe,
478-
i,
479-
mca_spml_base_mkey2str(&mkeys[i]));
480472
}
481473
return OSHMEM_SUCCESS;
482474
}
@@ -742,7 +734,7 @@ uint64_t mca_memheap_base_find_offset(int pe,
742734

743735
int mca_memheap_base_is_symmetric_addr(const void* va)
744736
{
745-
return (memheap_find_va(va) ? 1 : 0);
737+
return (memheap_find_va((void *)va) ? 1 : 0);
746738
}
747739

748740
int mca_memheap_base_detect_addr_type(void* va)

oshmem/mca/spml/ikrit/spml_ikrit.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ sshmem_mkey_t *mca_spml_ikrit_register(void* addr,
491491
}
492492
SPML_VERBOSE(5,
493493
"rank %d ptl %d addr %p size %llu %s",
494-
my_rank, i, addr, (unsigned long long)size,
494+
my_rank, i, addr, (unsigned long long)size,
495495
mca_spml_base_mkey2str(&mkeys[i]));
496496

497497
mca_spml_ikrit_cache_mkeys(&mkeys[i], memheap_find_segnum(addr), my_rank, i);
@@ -687,12 +687,11 @@ static inline int mca_spml_ikrit_get_async(void *src_addr,
687687

688688
get_req = alloc_get_req();
689689

690-
if (OSHMEM_SUCCESS
691-
!= mca_spml_ikrit_get_helper(&get_req->mxm_req,
692-
src_addr,
693-
size,
694-
dst_addr,
695-
src)) {
690+
if (OSHMEM_SUCCESS != mca_spml_ikrit_get_helper(&get_req->mxm_req,
691+
src_addr,
692+
size,
693+
dst_addr,
694+
src)) {
696695
oshmem_shmem_abort(-1);
697696
return OSHMEM_ERROR;
698697
}
@@ -818,16 +817,6 @@ static inline int mca_spml_ikrit_put_internal(void* dst_addr,
818817
put_req->mxm_req.base.mq = mca_spml_ikrit.mxm_mq;
819818
/* request immediate responce if we are getting low on send buffers. We only get responce from remote on ack timeout.
820819
* Also request explicit ack once in a while */
821-
#if 0
822-
put_req->mxm_req.opcode = MXM_REQ_OP_PUT;
823-
if (mca_spml_ikrit.free_list_max - mca_spml_ikrit.n_active_puts <= SPML_IKRIT_PUT_LOW_WATER ||
824-
(mca_spml_ikrit.mxm_peers[dst]->n_active_puts + 1) % SPML_IKRIT_PACKETS_PER_SYNC == 0) {
825-
put_req->mxm_req.base.flags = MXM_REQ_FLAG_SEND_SYNC;
826-
need_progress = 1;
827-
} else {
828-
put_req->mxm_req.base.flags = MXM_REQ_FLAG_SEND_LAZY|MXM_REQ_FLAG_SEND_SYNC;
829-
}
830-
#endif
831820
put_req->mxm_req.flags = 0;
832821
if (mca_spml_ikrit.free_list_max - mca_spml_ikrit.n_active_puts <= SPML_IKRIT_PUT_LOW_WATER ||
833822
(int)opal_list_get_size(&mca_spml_ikrit.active_peers) > mca_spml_ikrit.unsync_conn_max ||
@@ -1007,11 +996,7 @@ int mca_spml_ikrit_fence(void)
1007996
mca_spml_ikrit_mxm_fence(peer - mca_spml_ikrit.mxm_peers);
1008997
}
1009998

1010-
while (0 < mca_spml_ikrit.n_mxm_fences) {
1011-
opal_progress();
1012-
}
1013-
1014-
while (0 < mca_spml_ikrit.n_active_gets) {
999+
while (0 < mca_spml_ikrit.n_mxm_fences || 0 < mca_spml_ikrit.n_active_gets) {
10151000
opal_progress();
10161001
}
10171002

0 commit comments

Comments
 (0)