Skip to content

Commit 564f80d

Browse files
committed
pml_ucx: add option to use opal memhooks instead of ucx internal hooks
Signed-off-by: Yossi Itigin <yosefe@mellanox.com>
1 parent 2caf1bf commit 564f80d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

ompi/mca/pml/ucx/pml_ucx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct mca_pml_ucx_module {
4242
ompi_request_t completed_send_req;
4343
size_t request_size;
4444
int num_disconnect;
45+
bool opal_mem_hooks;
4546

4647
/* Converters pool */
4748
mca_pml_ucx_freelist_t convs;

ompi/mca/pml/ucx/pml_ucx_component.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
#include "pml_ucx.h"
1111

12+
#include "opal/memoryhooks/memory.h"
13+
#include "opal/mca/memory/base/base.h"
14+
15+
#include <ucm/api/ucm.h>
16+
1217

1318
static int mca_pml_ucx_component_register(void);
1419
static int mca_pml_ucx_component_open(void);
@@ -70,13 +75,39 @@ static int mca_pml_ucx_component_register(void)
7075
OPAL_INFO_LVL_3,
7176
MCA_BASE_VAR_SCOPE_LOCAL,
7277
&ompi_pml_ucx.num_disconnect);
78+
79+
ompi_pml_ucx.opal_mem_hooks = 0;
80+
(void) mca_base_component_var_register(&mca_pml_ucx_component.pmlm_version, "opal_mem_hooks",
81+
"Use OPAL memory hooks, instead of UCX internal memory hooks",
82+
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
83+
OPAL_INFO_LVL_3,
84+
MCA_BASE_VAR_SCOPE_LOCAL,
85+
&ompi_pml_ucx.opal_mem_hooks);
7386
return 0;
7487
}
7588

89+
static void mca_pml_ucx_mem_release_cb(void *buf, size_t length,
90+
void *cbdata, bool from_alloc)
91+
{
92+
ucm_vm_munmap(buf, length);
93+
}
94+
7695
static int mca_pml_ucx_component_open(void)
7796
{
7897
ompi_pml_ucx.output = opal_output_open(NULL);
7998
opal_output_set_verbosity(ompi_pml_ucx.output, ompi_pml_ucx.verbose);
99+
100+
/* Set memory hooks */
101+
if (ompi_pml_ucx.opal_mem_hooks &&
102+
(OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) ==
103+
((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) &
104+
opal_mem_hooks_support_level()))
105+
{
106+
PML_UCX_VERBOSE(1, "%s", "using OPAL memory hooks as external events");
107+
ucm_set_external_event(UCM_EVENT_VM_UNMAPPED);
108+
opal_mem_hooks_register_release(mca_pml_ucx_mem_release_cb, NULL);
109+
}
110+
80111
return mca_pml_ucx_open();
81112
}
82113

@@ -89,6 +120,7 @@ static int mca_pml_ucx_component_close(void)
89120
return rc;
90121
}
91122

123+
opal_mem_hooks_unregister_release(mca_pml_ucx_mem_release_cb);
92124
opal_output_close(ompi_pml_ucx.output);
93125
return 0;
94126
}

0 commit comments

Comments
 (0)