From 986ca000f8398a00be07ccaf1ab4f7a0c84e69d9 Mon Sep 17 00:00:00 2001 From: Alex Mikheev Date: Tue, 10 Jan 2017 14:21:36 +0200 Subject: [PATCH 1/2] oshmem: spml: add memory allocation hook The hook is called from memheap when memory range is going to be allocated by smalloc(), realloc() and others. ucx spml uses this hook to call ucp_mem_advise in order to speedup non blocking memory mapping. Signed-off-by: Alex Mikheev --- oshmem/mca/memheap/buddy/memheap_buddy.c | 2 +- .../mca/memheap/ptmalloc/memheap_ptmalloc.c | 3 ++ oshmem/mca/spml/base/base.h | 1 + oshmem/mca/spml/base/spml_base.c | 4 +++ oshmem/mca/spml/ikrit/spml_ikrit.c | 1 + oshmem/mca/spml/spml.h | 11 +++++++ oshmem/mca/spml/ucx/spml_ucx.c | 30 ++++++++++++++++++- oshmem/mca/spml/ucx/spml_ucx.h | 2 ++ oshmem/mca/spml/yoda/spml_yoda.c | 1 + 9 files changed, 53 insertions(+), 2 deletions(-) diff --git a/oshmem/mca/memheap/buddy/memheap_buddy.c b/oshmem/mca/memheap/buddy/memheap_buddy.c index c7715f4dd1..b3f4ca1df9 100644 --- a/oshmem/mca/memheap/buddy/memheap_buddy.c +++ b/oshmem/mca/memheap/buddy/memheap_buddy.c @@ -469,7 +469,7 @@ static int _do_alloc(uint32_t order, } *p_buff = (void*) addr; - /* no barrier because it is not required by spec! */ + MCA_SPML_CALL(memuse_hook(addr, 1<mem_h, ¶ms); + if (UCS_OK != status) { + SPML_ERROR("ucp_mem_advise failed addr %p len %llu", + addr, (unsigned long long)length); + } +} + sshmem_mkey_t *mca_spml_ucx_register(void* addr, size_t size, uint64_t shmid, diff --git a/oshmem/mca/spml/ucx/spml_ucx.h b/oshmem/mca/spml/ucx/spml_ucx.h index 4b248e026a..b524031d3f 100644 --- a/oshmem/mca/spml/ucx/spml_ucx.h +++ b/oshmem/mca/spml/ucx/spml_ucx.h @@ -108,6 +108,8 @@ extern sshmem_mkey_t *mca_spml_ucx_register(void* addr, int *count); extern int mca_spml_ucx_deregister(sshmem_mkey_t *mkeys); +extern void mca_spml_ucx_memuse_hook(void *addr, size_t length); + extern void mca_spml_ucx_rmkey_unpack(sshmem_mkey_t *mkey, uint32_t segno, int pe, int tr_id); extern void mca_spml_ucx_rmkey_free(sshmem_mkey_t *mkey); diff --git a/oshmem/mca/spml/yoda/spml_yoda.c b/oshmem/mca/spml/yoda/spml_yoda.c index 8e87c58df7..ebdceab8c9 100644 --- a/oshmem/mca/spml/yoda/spml_yoda.c +++ b/oshmem/mca/spml/yoda/spml_yoda.c @@ -65,6 +65,7 @@ mca_spml_yoda_module_t mca_spml_yoda = { mca_spml_yoda_fence, mca_spml_base_rmkey_unpack, mca_spml_base_rmkey_free, + mca_spml_base_memuse_hook, (void *)&mca_spml_yoda } From 9da9e6260dbd6578710bdeab41f6871834cad0d0 Mon Sep 17 00:00:00 2001 From: Alex Mikheev Date: Sun, 29 Jan 2017 10:28:24 +0200 Subject: [PATCH 2/2] oshmem: spml ucx: on error print ucx error string Signed-off-by: Alex Mikheev --- oshmem/mca/spml/ucx/spml_ucx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/oshmem/mca/spml/ucx/spml_ucx.c b/oshmem/mca/spml/ucx/spml_ucx.c index fbdc13f9f5..fc8b4bdc1f 100644 --- a/oshmem/mca/spml/ucx/spml_ucx.c +++ b/oshmem/mca/spml/ucx/spml_ucx.c @@ -289,7 +289,7 @@ int mca_spml_ucx_add_procs(ompi_proc_t** procs, size_t nprocs) &ep_params, &mca_spml_ucx.ucp_peers[i].ucp_conn); if (UCS_OK != err) { - SPML_ERROR("ucp_ep_create failed!!!\n"); + SPML_ERROR("ucp_ep_create failed: %s\n", ucs_status_string(err)); goto error2; } OSHMEM_PROC_DATA(procs[i])->num_transports = 1; @@ -372,7 +372,7 @@ void mca_spml_ucx_rmkey_unpack(sshmem_mkey_t *mkey, uint32_t segno, int pe, int mkey->u.data, &ucx_mkey->rkey); if (UCS_OK != err) { - SPML_ERROR("failed to unpack rkey"); + SPML_ERROR("failed to unpack rkey: %s", ucs_status_string(err)); goto error_fatal; } @@ -408,8 +408,8 @@ void mca_spml_ucx_memuse_hook(void *addr, size_t length) status = ucp_mem_advise(mca_spml_ucx.ucp_context, ucx_mkey->mem_h, ¶ms); if (UCS_OK != status) { - SPML_ERROR("ucp_mem_advise failed addr %p len %llu", - addr, (unsigned long long)length); + SPML_ERROR("ucp_mem_advise failed addr %p len %llu : %s", + addr, (unsigned long long)length, ucs_status_string(status)); } } @@ -568,7 +568,7 @@ int mca_spml_ucx_fence(void) err = ucp_worker_flush(mca_spml_ucx.ucp_worker); if (UCS_OK != err) { - SPML_ERROR("fence failed"); + SPML_ERROR("fence failed: %s", ucs_status_string(err)); oshmem_shmem_abort(-1); return OSHMEM_ERROR; } @@ -581,7 +581,7 @@ int mca_spml_ucx_quiet(void) err = ucp_worker_flush(mca_spml_ucx.ucp_worker); if (UCS_OK != err) { - SPML_ERROR("fence failed"); + SPML_ERROR("fence failed: %s", ucs_status_string(err)); oshmem_shmem_abort(-1); return OSHMEM_ERROR; }