From 0a5b846853dbc3443752a6676ba8c35238f073db Mon Sep 17 00:00:00 2001 From: chenyidu Date: Thu, 6 May 2021 22:38:08 +0800 Subject: [PATCH] UCP/AM: Adjust max_short for UCP_AM_SEND_REPLY --- NEWS | 1 + src/ucp/core/ucp_am.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 55c05147a2d..88266c82ad9 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ * Fixes in RPM dependency on libibverbs * Fixes in ABI backward compatibility for active message protocol * Add support for DC full-handshake mode (off by default). +* Fixes in Active Messages short reply protocol. ## 1.10.0 (March 9, 2021) ### Features: diff --git a/src/ucp/core/ucp_am.c b/src/ucp/core/ucp_am.c index dfbf0963c39..6e304559420 100644 --- a/src/ucp/core/ucp_am.c +++ b/src/ucp/core/ucp_am.c @@ -1,6 +1,7 @@ /** * Copyright (C) Los Alamos National Security, LLC. 2019 ALL RIGHTS RESERVED. * Copyright (C) Mellanox Technologies Ltd. 2019. ALL RIGHTS RESERVED. +* Copyright (C) Huawei Technologies Co., Ltd. 2021. ALL RIGHTS RESERVED. * * See file LICENSE for terms. */ @@ -23,9 +24,6 @@ #include -#define UCP_AM_SHORT_REPLY_MAX_SIZE (UCS_ALLOCA_MAX_SIZE - \ - sizeof(ucs_ptr_map_key_t)) - UCS_ARRAY_IMPL(ucp_am_cbs, unsigned, ucp_am_entry_t, static) ucs_status_t ucp_am_init(ucp_worker_h worker) @@ -899,6 +897,13 @@ ucp_am_send_req(ucp_request_t *req, size_t count, return req + 1; } +static UCS_F_ALWAYS_INLINE ssize_t +ucp_am_get_short_max_reply(ucp_ep_h ep) +{ + return ucs_min(ucp_ep_config(ep)->am_u.max_eager_short, + UCS_ALLOCA_MAX_SIZE) - sizeof(ucs_ptr_map_key_t); +} + static UCS_F_ALWAYS_INLINE ucs_status_t ucp_am_try_send_short(ucp_ep_h ep, uint16_t id, uint32_t flags, const void *header, size_t header_length, @@ -914,7 +919,7 @@ ucp_am_try_send_short(ucp_ep_h ep, uint16_t id, uint32_t flags, if (!(flags & UCP_AM_SEND_REPLY)) { return ucp_am_send_short(ep, id, flags, header, header_length, buffer, length); - } else if ((length + header_length) < UCP_AM_SHORT_REPLY_MAX_SIZE) { + } else if ((length + header_length) < ucp_am_get_short_max_reply(ep)) { return ucp_am_send_short_reply(ep, id, flags, header, header_length, buffer, length); } @@ -984,8 +989,7 @@ UCS_PROFILE_FUNC(ucs_status_ptr_t, ucp_am_send_nbx, if (flags & UCP_AM_SEND_REPLY) { ret = ucp_am_send_req(req, count, &ucp_ep_config(ep)->am, param, ucp_ep_config(ep)->am_u.reply_proto, - ucs_min(ucp_ep_config(ep)->am_u.max_eager_short, - UCP_AM_SHORT_REPLY_MAX_SIZE), flags); + ucp_am_get_short_max_reply(ep), flags); } else { ret = ucp_am_send_req(req, count, &ucp_ep_config(ep)->am, param, ucp_ep_config(ep)->am_u.proto,