sshmem_mkey_t *mca_memheap_base_get_mkey(void* va, int tr_id) { map_segment_t *s; s = __find_va(va); return ((s && MAP_SEGMENT_IS_VALID(s)) ? &s->mkeys[tr_id] : NULL ); }
mca_spml_mkey_t *mca_memheap_base_get_mkey(void* va, int tr_id) { map_segment_t *s; s = __find_va(va); return ((s && s->is_active) ? &s->mkeys[tr_id] : NULL ); }
uint64_t mca_memheap_base_find_offset(int pe, int tr_id, void* va, void* rva) { map_segment_t *s; s = __find_va(va); return ((s && MAP_SEGMENT_IS_VALID(s)) ? ((uintptr_t)rva - (uintptr_t)(s->mkeys_cache[pe][tr_id].va_base)) : 0); }
uint64_t mca_memheap_base_find_offset(int pe, int tr_id, void* va, void* rva) { map_segment_t *s; s = __find_va(va); return ((s && s->is_active) ? (rva - s->mkeys_cache[pe][tr_id].va_base) : 0); }
sshmem_mkey_t * mca_memheap_base_get_cached_mkey(int pe, void* va, int btl_id, void** rva) { map_segment_t *s; int rc; sshmem_mkey_t *mkey; MEMHEAP_VERBOSE_FASTPATH(10, "rkey: pe=%d va=%p", pe, va); s = __find_va(va); if (NULL == s) return NULL ; if (!MAP_SEGMENT_IS_VALID(s)) return NULL ; if (pe == oshmem_my_proc_id()) { *rva = va; MEMHEAP_VERBOSE_FASTPATH(10, "rkey: pe=%d va=%p -> (local) %lx %p", pe, va, s->mkeys[btl_id].u.key, *rva); return &s->mkeys[btl_id]; } if (OPAL_LIKELY(s->mkeys_cache[pe])) { mkey = &s->mkeys_cache[pe][btl_id]; *rva = va2rva(va, s->seg_base_addr, mkey->va_base); MEMHEAP_VERBOSE_FASTPATH(10, "rkey: pe=%d va=%p -> (cached) %lx %p", pe, (void *)va, mkey->u.key, (void *)*rva); return mkey; } s->mkeys_cache[pe] = (sshmem_mkey_t *) calloc(memheap_map->num_transports, sizeof(sshmem_mkey_t)); if (!s->mkeys_cache[pe]) return NULL ; rc = memheap_oob_get_mkeys(pe, s - memheap_map->mem_segs, s->mkeys_cache[pe]); if (OSHMEM_SUCCESS != rc) return NULL ; mkey = &s->mkeys_cache[pe][btl_id]; *rva = va2rva(va, s->seg_base_addr, mkey->va_base); MEMHEAP_VERBOSE_FASTPATH(5, "rkey: pe=%d va=%p -> (remote lookup) %lx %p", pe, (void *)va, mkey->u.key, (void *)*rva); return mkey; }
uint64_t mca_memheap_base_find_offset(int pe, int tr_id, void* va, void* rva) { map_segment_t *s; int my_pe = oshmem_my_proc_id(); s = __find_va(va); if (my_pe == pe) { return (uintptr_t)va - (uintptr_t)s->seg_base_addr; } else { return ((s && MAP_SEGMENT_IS_VALID(s)) ? ((uintptr_t)rva - (uintptr_t)(s->mkeys_cache[pe][tr_id].va_base)) : 0); } }
int mca_memheap_base_detect_addr_type(void* va) { int addr_type = ADDR_INVALID; map_segment_t *s; s = __find_va(va); if (s) { if (s->type == MAP_SEGMENT_STATIC) { addr_type = ADDR_STATIC; } else if ((uintptr_t)va >= (uintptr_t) s->seg_base_addr && (uintptr_t)va < (uintptr_t) ((uintptr_t)s->seg_base_addr + mca_memheap.memheap_size)) { addr_type = ADDR_USER; } else { assert( (uintptr_t)va >= (uintptr_t) ((uintptr_t)s->seg_base_addr + mca_memheap.memheap_size) && (uintptr_t)va < (uintptr_t)s->end); addr_type = ADDR_PRIVATE; } } return addr_type; }
int mca_memheap_base_is_symmetric_addr(const void* va) { return (__find_va(va) ? 1 : 0); }