Skip to content

Commit f18d06a

Browse files
committed
UCP/API: add estimated bandwidth query to ucp_ep_query
Add UCP_EP_ATTR_FIELD_ESTIMATED_BW field to ucp_ep_attr_t that allows querying the estimated aggregate bandwidth (bytes/sec) for a given local/remote memory type pair on an endpoint. The caller sets local_mem_type and remote_mem_type and the implementation returns the sum of bandwidths across all data lanes whose memory domain supports the requested memory type. Closes #6254
1 parent 6dda7bd commit f18d06a

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

src/ucp/api/ucp.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4214,7 +4214,8 @@ enum ucp_ep_attr_field {
42144214
UCP_EP_ATTR_FIELD_LOCAL_SOCKADDR = UCS_BIT(1), /**< Sockaddr used by the endpoint */
42154215
UCP_EP_ATTR_FIELD_REMOTE_SOCKADDR = UCS_BIT(2), /**< Sockaddr the endpoint is connected to */
42164216
UCP_EP_ATTR_FIELD_TRANSPORTS = UCS_BIT(3), /**< Transport and device used by endpoint */
4217-
UCP_EP_ATTR_FIELD_USER_DATA = UCS_BIT(4) /**< User data associated with the endpoint */
4217+
UCP_EP_ATTR_FIELD_USER_DATA = UCS_BIT(4), /**< User data associated with the endpoint */
4218+
UCP_EP_ATTR_FIELD_ESTIMATED_BW = UCS_BIT(5) /**< Estimated bandwidth for a memory type pair */
42184219
};
42194220

42204221

@@ -4268,6 +4269,21 @@ typedef struct ucp_ep_attr {
42684269
* @ref ucp_ep_params_t::user_data.
42694270
*/
42704271
void *user_data;
4272+
4273+
/**
4274+
* Estimated bandwidth (in bytes/second) for a given pair of local and
4275+
* remote memory types. The caller sets @ref local_mem_type and
4276+
* @ref remote_mem_type before calling @ref ucp_ep_query, and the
4277+
* implementation fills in @ref bandwidth with the aggregate estimated
4278+
* bandwidth across the endpoint's data lanes that support the requested
4279+
* memory types.
4280+
*/
4281+
struct {
4282+
ucs_memory_type_t local_mem_type; /**< [in] Local memory type */
4283+
ucs_memory_type_t remote_mem_type; /**< [in] Remote memory type */
4284+
double bandwidth; /**< [out] Estimated bandwidth
4285+
(bytes/second) */
4286+
} estimated_bw;
42714287
} ucp_ep_attr_t;
42724288

42734289

src/ucp/core/ucp_ep.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3976,6 +3976,47 @@ ucs_status_t ucp_ep_query_sockaddr(ucp_ep_h ep, ucp_ep_attr_t *attr)
39763976
return UCS_OK;
39773977
}
39783978

3979+
static void ucp_ep_query_estimated_bw(ucp_ep_h ep, ucp_ep_attr_t *attr)
3980+
{
3981+
ucp_worker_h worker = ep->worker;
3982+
ucp_context_h context = worker->context;
3983+
ucp_ep_config_t *config = ucp_ep_config(ep);
3984+
ucs_memory_type_t local_mt = attr->estimated_bw.local_mem_type;
3985+
double total_bw = 0.0;
3986+
ucp_lane_index_t lane;
3987+
ucp_rsc_index_t rsc_index;
3988+
ucp_md_index_t md_index;
3989+
const uct_md_attr_v2_t *md_attr;
3990+
ucp_worker_iface_t *wiface;
3991+
3992+
for (lane = 0; lane < config->key.num_lanes; ++lane) {
3993+
if (lane == config->key.cm_lane) {
3994+
continue;
3995+
}
3996+
3997+
rsc_index = config->key.lanes[lane].rsc_index;
3998+
if (rsc_index == UCP_NULL_RESOURCE) {
3999+
continue;
4000+
}
4001+
4002+
md_index = config->md_index[lane];
4003+
md_attr = &context->tl_mds[md_index].attr;
4004+
4005+
/* Check if the lane's memory domain can register the requested local
4006+
* memory type. Host memory is always assumed to be supported. */
4007+
if ((local_mt != UCS_MEMORY_TYPE_HOST) &&
4008+
!(md_attr->reg_mem_types & UCS_BIT(local_mt)) &&
4009+
!(md_attr->access_mem_types & UCS_BIT(local_mt))) {
4010+
continue;
4011+
}
4012+
4013+
wiface = ucp_worker_iface(worker, rsc_index);
4014+
total_bw += ucp_wireup_iface_bw_distance(wiface);
4015+
}
4016+
4017+
attr->estimated_bw.bandwidth = total_bw;
4018+
}
4019+
39794020
ucs_status_t ucp_ep_query(ucp_ep_h ep, ucp_ep_attr_t *attr)
39804021
{
39814022
ucs_status_t status;
@@ -4007,6 +4048,10 @@ ucs_status_t ucp_ep_query(ucp_ep_h ep, ucp_ep_attr_t *attr)
40074048
attr->user_data = ep->flags & UCP_EP_FLAG_USER_DATA_PARAM ? ep->ext->user_data : NULL;
40084049
}
40094050

4051+
if (attr->field_mask & UCP_EP_ATTR_FIELD_ESTIMATED_BW) {
4052+
ucp_ep_query_estimated_bw(ep, attr);
4053+
}
4054+
40104055
return UCS_OK;
40114056
}
40124057

0 commit comments

Comments
 (0)