Skip to content

Commit b47b1b9

Browse files
committed
btl/uct: add helper to enable an active message handler on a context
This commit adds a new helper (mca_btl_uct_context_enable_am_handler) which will enable an active message handler on the given context if it has not already been enabled. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
1 parent 88fb55b commit b47b1b9

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

opal/mca/btl/uct/btl_uct_device_context.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ mca_btl_uct_device_context_t *mca_btl_uct_context_create(mca_btl_uct_module_t *m
3737
*/
3838
void mca_btl_uct_context_destroy(mca_btl_uct_device_context_t *context);
3939

40+
/**
41+
* @brief Enable active messages on context if not already enabled
42+
*
43+
* @param[in] tl TL this context belongs to
44+
* @param[in] context Context to enable active messages on.
45+
*/
46+
void mca_btl_uct_context_enable_am_handler(mca_btl_uct_tl_t *tl,
47+
mca_btl_uct_device_context_t *context);
48+
4049
static inline bool mca_btl_uct_context_trylock(mca_btl_uct_device_context_t *context)
4150
{
4251
return OPAL_THREAD_TRYLOCK(&context->mutex);

opal/mca/btl/uct/btl_uct_tl.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,20 @@ static int mca_btl_uct_populate_tl_attr(mca_btl_uct_module_t *module, mca_btl_uc
321321
return OPAL_SUCCESS;
322322
}
323323

324+
void mca_btl_uct_context_enable_am_handler(mca_btl_uct_tl_t *tl,
325+
mca_btl_uct_device_context_t *context)
326+
{
327+
if (context->am_handler_installed) {
328+
return;
329+
}
330+
331+
BTL_VERBOSE(("installing AM handler for tl %s::%s context id %d",
332+
tl->uct_md->md_name, tl->uct_tl_name, context->context_id)); \
333+
uct_iface_set_am_handler(context->uct_iface, MCA_BTL_UCT_FRAG, mca_btl_uct_am_handler,
334+
context, MCA_BTL_UCT_CB_FLAG_SYNC);
335+
context->am_handler_installed = true;
336+
}
337+
324338
mca_btl_uct_device_context_t *mca_btl_uct_context_create(mca_btl_uct_module_t *module,
325339
mca_btl_uct_tl_t *tl, int context_id,
326340
bool enable_progress)
@@ -383,9 +397,7 @@ mca_btl_uct_device_context_t *mca_btl_uct_context_create(mca_btl_uct_module_t *m
383397
}
384398

385399
if (module != NULL && tl == module->am_tl) {
386-
BTL_VERBOSE(("installing AM handler for tl %p context id %d", (void *) tl, context_id));
387-
uct_iface_set_am_handler(context->uct_iface, MCA_BTL_UCT_FRAG, mca_btl_uct_am_handler,
388-
context, MCA_BTL_UCT_CB_FLAG_SYNC);
400+
mca_btl_uct_context_enable_am_handler(tl, context);
389401
}
390402

391403
if (enable_progress) {

opal/mca/btl/uct/btl_uct_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ struct mca_btl_uct_device_context_t {
177177
/** progress is enabled on this context */
178178
bool progress_enabled;
179179

180+
/** communication AM handler is installed */
181+
bool am_handler_installed;
182+
180183
/** context is in AM callback */
181184
volatile bool in_am_callback;
182185
};

0 commit comments

Comments
 (0)