From 8b26d8ca82180be49ecf924c273a8663ae8a5fd9 Mon Sep 17 00:00:00 2001 From: Jianxin Xiong Date: Thu, 29 Aug 2024 09:42:01 -0700 Subject: [PATCH] prov/ucx: Support FI_OPT_CUDA_API_PERMITTED in fi_setopt() This is required for providers that support FI_HMEM. Signed-off-by: Jianxin Xiong --- prov/ucx/src/ucx_ep.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/prov/ucx/src/ucx_ep.c b/prov/ucx/src/ucx_ep.c index 35383085168..1bf04d20a6a 100644 --- a/prov/ucx/src/ucx_ep.c +++ b/prov/ucx/src/ucx_ep.c @@ -102,13 +102,29 @@ static int ucx_ep_setopt(fid_t fid, int level, int optname, { struct ucx_ep *ep; - if (level == FI_OPT_ENDPOINT && - optname == FI_OPT_MIN_MULTI_RECV && - optlen >= sizeof(size_t)) { + if (level != FI_OPT_ENDPOINT) + return -FI_ENOPROTOOPT; + + if (optname == FI_OPT_MIN_MULTI_RECV && optlen >= sizeof(size_t)) { ep = container_of(fid, struct ucx_ep, ep.ep_fid.fid); ep->ep_opts.mrecv_min_size = *(size_t*)optval; return FI_SUCCESS; } + + if (optname == FI_OPT_CUDA_API_PERMITTED) { + if (!hmem_ops[FI_HMEM_CUDA].initialized) { + FI_WARN(&ucx_prov, FI_LOG_EP_CTRL, + "Cannot set CUDA API permitted when" + "CUDA library or CUDA device is not available\n"); + return -FI_EINVAL; + } + + /* our HMEM support does not make calls to CUDA API, + * therefore we can accept any option for FI_OPT_CUDA_API_PERMITTED. + */ + return FI_SUCCESS; + } + return -FI_ENOPROTOOPT; }