From d1723355d31e7a625daabf6a64cd2084a5d76c6a Mon Sep 17 00:00:00 2001 From: Alex Mikheev Date: Mon, 21 Nov 2016 16:09:17 +0200 Subject: [PATCH] oshmem: memheap: removes find_offset Reasons for removal are: - the function is only used by the shmem_lock code - only a subset of the function is used by the shmem_lock - for the general case the function is not correct Signed-off-by: Alex Mikheev --- oshmem/mca/memheap/base/base.h | 4 ---- oshmem/mca/memheap/base/memheap_base_mkey.c | 17 ----------------- oshmem/mca/memheap/buddy/memheap_buddy.c | 1 - oshmem/mca/memheap/memheap.h | 5 ----- oshmem/mca/memheap/ptmalloc/memheap_ptmalloc.c | 1 - oshmem/shmem/c/shmem_lock.c | 13 +++++++++++-- 6 files changed, 11 insertions(+), 30 deletions(-) diff --git a/oshmem/mca/memheap/base/base.h b/oshmem/mca/memheap/base/base.h index c82e03da5a..909a39a293 100644 --- a/oshmem/mca/memheap/base/base.h +++ b/oshmem/mca/memheap/base/base.h @@ -69,10 +69,6 @@ int mca_memheap_base_dereg(mca_memheap_map_t *); int memheap_oob_init(mca_memheap_map_t *); void memheap_oob_destruct(void); -OSHMEM_DECLSPEC uint64_t mca_memheap_base_find_offset(int pe, - int tr_id, - void* va, - void* rva); OSHMEM_DECLSPEC int mca_memheap_base_is_symmetric_addr(const void* va); OSHMEM_DECLSPEC sshmem_mkey_t *mca_memheap_base_get_mkey(void* va, int tr_id); diff --git a/oshmem/mca/memheap/base/memheap_base_mkey.c b/oshmem/mca/memheap/base/memheap_base_mkey.c index 563fcd0bb9..a2e21f1a5b 100644 --- a/oshmem/mca/memheap/base/memheap_base_mkey.c +++ b/oshmem/mca/memheap/base/memheap_base_mkey.c @@ -714,23 +714,6 @@ sshmem_mkey_t *mca_memheap_base_get_mkey(void* va, int tr_id) return ((s && MAP_SEGMENT_IS_VALID(s)) ? &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; - int my_pe = oshmem_my_proc_id(); - - s = memheap_find_va(va); - - if (my_pe == pe) { - return (uintptr_t)va - (uintptr_t)s->super.va_base; - } - 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_is_symmetric_addr(const void* va) { diff --git a/oshmem/mca/memheap/buddy/memheap_buddy.c b/oshmem/mca/memheap/buddy/memheap_buddy.c index a44efc8c8a..c7715f4dd1 100644 --- a/oshmem/mca/memheap/buddy/memheap_buddy.c +++ b/oshmem/mca/memheap/buddy/memheap_buddy.c @@ -34,7 +34,6 @@ mca_memheap_buddy_module_t memheap_buddy = { mca_memheap_buddy_private_free, mca_memheap_base_get_mkey, - mca_memheap_base_find_offset, mca_memheap_base_is_symmetric_addr, mca_memheap_modex_recv_all, diff --git a/oshmem/mca/memheap/memheap.h b/oshmem/mca/memheap/memheap.h index d198eb0ebe..bbf013913a 100644 --- a/oshmem/mca/memheap/memheap.h +++ b/oshmem/mca/memheap/memheap.h @@ -59,10 +59,6 @@ typedef int (*mca_memheap_base_module_free_fn_t)(void*); /** * Service functions */ -typedef uint64_t (*mca_memheap_base_module_find_offset_fn_t)(int pe, - int tr_id, - void* va, - void* rva); typedef sshmem_mkey_t * (*mca_memheap_base_module_get_local_mkey_fn_t)(void* va, int transport_id); @@ -109,7 +105,6 @@ struct mca_memheap_base_module_t { mca_memheap_base_module_free_fn_t memheap_private_free; mca_memheap_base_module_get_local_mkey_fn_t memheap_get_local_mkey; - mca_memheap_base_module_find_offset_fn_t memheap_find_offset; mca_memheap_base_is_memheap_addr_fn_t memheap_is_symmetric_addr; mca_memheap_base_mkey_exchange_fn_t memheap_get_all_mkeys; diff --git a/oshmem/mca/memheap/ptmalloc/memheap_ptmalloc.c b/oshmem/mca/memheap/ptmalloc/memheap_ptmalloc.c index 0a993eaddc..e416f66bc5 100644 --- a/oshmem/mca/memheap/ptmalloc/memheap_ptmalloc.c +++ b/oshmem/mca/memheap/ptmalloc/memheap_ptmalloc.c @@ -32,7 +32,6 @@ mca_memheap_ptmalloc_module_t memheap_ptmalloc = { mca_memheap_ptmalloc_free, mca_memheap_base_get_mkey, - mca_memheap_base_find_offset, mca_memheap_base_is_symmetric_addr, mca_memheap_modex_recv_all, diff --git a/oshmem/shmem/c/shmem_lock.c b/oshmem/shmem/c/shmem_lock.c index e7b7d81548..ec2333e494 100644 --- a/oshmem/shmem/c/shmem_lock.c +++ b/oshmem/shmem/c/shmem_lock.c @@ -25,6 +25,7 @@ #include "oshmem/shmem/shmem_api_logger.h" #include "oshmem/shmem/shmem_lock.h" #include "oshmem/mca/memheap/memheap.h" +#include "oshmem/mca/memheap/base/base.h" #include "oshmem/mca/atomic/atomic.h" #define OPAL_BITWISE_SIZEOF_LONG (SIZEOF_LONG * 8) @@ -170,8 +171,16 @@ int shmem_lock_finalize() static int shmem_lock_get_server(void *lock) { - uint64_t offset = MCA_MEMHEAP_CALL(find_offset(shmem_my_pe(), 0, lock, lock)); - return (offset / 8) % shmem_n_pes(); + map_segment_t *s; + + s = memheap_find_va(lock); + if (NULL == s) { + SHMEM_API_ERROR("PE#%i lock %p is not a shared variable", shmem_my_pe(), lock); + oshmem_shmem_abort(-1); + return 0; + } + + return ((int)((uintptr_t)lock - (uintptr_t)s->super.va_base)/8) % shmem_n_pes(); } static uint64_t get_lock_value(const void *lock, int lock_size)