static int pack_local_mkeys(opal_buffer_t *msg, int pe, int seg) { int i, n; sshmem_mkey_t *mkey; /* go over all transports and pack mkeys */ n = memheap_map->num_transports; opal_dss.pack(msg, &n, 1, OPAL_UINT32); MEMHEAP_VERBOSE(5, "found %d transports to %d", n, pe); for (i = 0; i < n; i++) { mkey = mca_memheap_base_get_mkey(mca_memheap_seg2base_va(seg), i); if (!mkey) { MEMHEAP_ERROR("seg#%d tr_id: %d failed to find local mkey", seg, i); return OSHMEM_ERROR; } opal_dss.pack(msg, &i, 1, OPAL_UINT32); opal_dss.pack(msg, &mkey->va_base, 1, OPAL_UINT64); if (0 == mkey->va_base) { opal_dss.pack(msg, &mkey->u.key, 1, OPAL_UINT64); } else { opal_dss.pack(msg, &mkey->len, 1, OPAL_UINT16); if (0 < mkey->len) { opal_dss.pack(msg, mkey->u.data, mkey->len, OPAL_BYTE); } } MEMHEAP_VERBOSE(5, "seg#%d tr_id: %d %s", seg, i, mca_spml_base_mkey2str(mkey)); } return OSHMEM_SUCCESS; }
static int do_mkey_req(opal_buffer_t *msg, int pe, int seg) { uint8_t msg_type; oshmem_proc_t *proc; int i, n, tr_id; mca_spml_mkey_t *mkey; msg_type = MEMHEAP_RKEY_RESP; opal_dss.pack(msg, &msg_type, 1, OPAL_UINT8); /* go over all transports to remote pe and pack mkeys */ n = oshmem_get_transport_count(pe); proc = oshmem_proc_group_find(oshmem_group_all, pe); opal_dss.pack(msg, &n, 1, OPAL_UINT32); MEMHEAP_VERBOSE(5, "found %d transports to %d", n, pe); for (i = 0; i < n; i++) { tr_id = proc->transport_ids[i]; mkey = mca_memheap_base_get_mkey(__seg2base_va(seg), tr_id); if (!mkey) { MEMHEAP_ERROR("seg#%d tr_id: %d failed to find local mkey", seg, tr_id); return OSHMEM_ERROR; } opal_dss.pack(msg, &tr_id, 1, OPAL_UINT32); opal_dss.pack(msg, &mkey->key, 1, OPAL_UINT64); opal_dss.pack(msg, &mkey->va_base, 1, OPAL_UINT64); if (NULL != MCA_SPML_CALL(get_remote_context_size)) { uint32_t context_size = (mkey->spml_context == NULL ) ? 0 : (uint32_t) MCA_SPML_CALL(get_remote_context_size(mkey->spml_context)); opal_dss.pack(msg, &context_size, 1, OPAL_UINT32); if (0 != context_size) { opal_dss.pack(msg, MCA_SPML_CALL(get_remote_context(mkey->spml_context)), context_size, OPAL_BYTE); } } MEMHEAP_VERBOSE(5, "seg#%d tr_id: %d key %llx base_va %p", seg, tr_id, (unsigned long long)mkey->key, mkey->va_base); } return OSHMEM_SUCCESS; }
/** * @param all_trs * 0 - pack mkeys for transports to given pe * 1 - pack mkeys for ALL possible transports. value of pe is ignored */ static int pack_local_mkeys(opal_buffer_t *msg, int pe, int seg, int all_trs) { oshmem_proc_t *proc; int i, n, tr_id; sshmem_mkey_t *mkey; /* go over all transports to remote pe and pack mkeys */ if (!all_trs) { n = oshmem_get_transport_count(pe); proc = oshmem_proc_group_find(oshmem_group_all, pe); } else { proc = NULL; n = memheap_map->num_transports; } opal_dss.pack(msg, &n, 1, OPAL_UINT32); MEMHEAP_VERBOSE(5, "found %d transports to %d", n, pe); for (i = 0; i < n; i++) { if (!all_trs) { tr_id = proc->transport_ids[i]; } else { tr_id = i; } mkey = mca_memheap_base_get_mkey(mca_memheap_seg2base_va(seg), tr_id); if (!mkey) { MEMHEAP_ERROR("seg#%d tr_id: %d failed to find local mkey", seg, tr_id); return OSHMEM_ERROR; } opal_dss.pack(msg, &tr_id, 1, OPAL_UINT32); opal_dss.pack(msg, &mkey->va_base, 1, OPAL_UINT64); if (0 == mkey->va_base) { opal_dss.pack(msg, &mkey->u.key, 1, OPAL_UINT64); } else { opal_dss.pack(msg, &mkey->len, 1, OPAL_UINT16); if (0 < mkey->len) { opal_dss.pack(msg, mkey->u.data, mkey->len, OPAL_BYTE); } } MEMHEAP_VERBOSE(5, "seg#%d tr_id: %d %s", seg, tr_id, mca_spml_base_mkey2str(mkey)); } return OSHMEM_SUCCESS; }