Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion oshmem/mca/memheap/buddy/memheap_buddy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(*p_buff, 1ULL<<order));
return OSHMEM_SUCCESS;

alloc_error: _buddy_free(&memheap_buddy, offset, order, heap);
Expand Down
3 changes: 3 additions & 0 deletions oshmem/mca/memheap/ptmalloc/memheap_ptmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ int mca_memheap_ptmalloc_alloc(size_t size, void** p_buff)
if (NULL == *p_buff)
return OSHMEM_ERROR;

MCA_SPML_CALL(memuse_hook(*p_buff, size));
return OSHMEM_SUCCESS;
}

Expand Down Expand Up @@ -113,6 +114,7 @@ int mca_memheap_ptmalloc_align(size_t align, size_t size, void **p_buff)
if (NULL == *p_buff)
return OSHMEM_ERROR;

MCA_SPML_CALL(memuse_hook(*p_buff, size));
return OSHMEM_SUCCESS;
}

Expand All @@ -132,6 +134,7 @@ int mca_memheap_ptmalloc_realloc(size_t new_size,
if (!*p_new_buff)
return OSHMEM_ERR_OUT_OF_RESOURCE;

MCA_SPML_CALL(memuse_hook(*p_new_buff, new_size));
return OSHMEM_SUCCESS;
}

Expand Down
1 change: 1 addition & 0 deletions oshmem/mca/spml/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ OSHMEM_DECLSPEC int mca_spml_base_get_nb(void *dst_addr,
int src,
void **handle);

OSHMEM_DECLSPEC void mca_spml_base_memuse_hook(void *addr, size_t length);
/*
* MCA framework
*/
Expand Down
4 changes: 4 additions & 0 deletions oshmem/mca/spml/base/spml_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,7 @@ int mca_spml_base_get_nb(void *dst_addr, size_t size,
{
return OSHMEM_ERROR;
}

void mca_spml_base_memuse_hook(void *addr, size_t length)
{
}
1 change: 1 addition & 0 deletions oshmem/mca/spml/ikrit/spml_ikrit.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ mca_spml_ikrit_t mca_spml_ikrit = {
mca_spml_ikrit_fence,
mca_spml_ikrit_cache_mkeys,
mca_spml_base_rmkey_free,
mca_spml_base_memuse_hook,

(void*)&mca_spml_ikrit
}
Expand Down
11 changes: 11 additions & 0 deletions oshmem/mca/spml/spml.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ typedef int (*mca_spml_base_module_fence_fn_t)(void);
*/
typedef int (*mca_spml_base_module_wait_nb_fn_t)(void *);

/**
* Called by memheap when memory is allocated by shmalloc(),
* shcalloc(), shmemalign() or shrealloc()
*
* @param addr base address of the registered buffer.
* @param size the size of the buffer to be registered.
*/
typedef void (*mca_spml_base_module_memuse_hook_fn_t)(void *, size_t);

/**
* SPML instance.
*/
Expand Down Expand Up @@ -304,6 +313,8 @@ struct mca_spml_base_module_1_0_0_t {

mca_spml_base_module_mkey_unpack_fn_t spml_rmkey_unpack;
mca_spml_base_module_mkey_free_fn_t spml_rmkey_free;

mca_spml_base_module_memuse_hook_fn_t spml_memuse_hook;
void *self;
};

Expand Down
39 changes: 34 additions & 5 deletions oshmem/mca/spml/ucx/spml_ucx.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#define SPML_UCX_PUT_DEBUG 0
#endif


mca_spml_ucx_t mca_spml_ucx = {
{
/* Init mca_spml_base_module_t */
Expand All @@ -65,6 +64,7 @@ mca_spml_ucx_t mca_spml_ucx = {
every spml */
mca_spml_ucx_rmkey_unpack,
mca_spml_ucx_rmkey_free,
mca_spml_ucx_memuse_hook,
(void*)&mca_spml_ucx
},

Expand Down Expand Up @@ -288,7 +288,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", ucs_status_string(err));
goto error2;
}
OSHMEM_PROC_DATA(procs[i])->num_transports = 1;
Expand Down Expand Up @@ -371,7 +371,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;
}

Expand All @@ -384,6 +384,35 @@ void mca_spml_ucx_rmkey_unpack(sshmem_mkey_t *mkey, uint32_t segno, int pe, int
return;
}

void mca_spml_ucx_memuse_hook(void *addr, size_t length)
{
int my_pe;
spml_ucx_mkey_t *ucx_mkey;
ucp_mem_advise_params_t params;
ucs_status_t status;

if (!(mca_spml_ucx.heap_reg_nb && memheap_is_va_in_segment(addr, HEAP_SEG_INDEX))) {
return;
}

my_pe = oshmem_my_proc_id();
ucx_mkey = &mca_spml_ucx.ucp_peers[my_pe].mkeys[HEAP_SEG_INDEX].key;

params.field_mask = UCP_MEM_ADVISE_PARAM_FIELD_ADDRESS |
UCP_MEM_ADVISE_PARAM_FIELD_LENGTH |
UCP_MEM_ADVISE_PARAM_FIELD_ADVICE;

params.address = addr;
params.length = length;
params.advice = UCP_MADV_WILLNEED;

status = ucp_mem_advise(mca_spml_ucx.ucp_context, ucx_mkey->mem_h, &params);
if (UCS_OK != status) {
SPML_ERROR("ucp_mem_advise failed addr %p len %llu : %s",
addr, (unsigned long long)length, ucs_status_string(status));
}
}

sshmem_mkey_t *mca_spml_ucx_register(void* addr,
size_t size,
uint64_t shmid,
Expand Down Expand Up @@ -539,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;
}
Expand All @@ -552,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;
}
Expand Down
2 changes: 2 additions & 0 deletions oshmem/mca/spml/ucx/spml_ucx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions oshmem/mca/spml/yoda/spml_yoda.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down