Skip to content

Commit 481340f

Browse files
authored
UCP/DEVICE: Add lane selection and populate allocated handle (#10858)
1 parent d8ea53e commit 481340f

File tree

20 files changed

+577
-183
lines changed

20 files changed

+577
-183
lines changed

src/ucp/api/device/ucp_device_impl.h

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@
2424
*/
2525
typedef struct ucp_device_request {
2626
uct_device_completion_t comp;
27+
uct_device_ep_h device_ep;
2728
} ucp_device_request_t;
2829

2930

3031
/**
3132
* @ingroup UCP_DEVICE
3233
* @brief Cooperation level when calling device functions.
34+
*
35+
* Must map exactly @ref uct_device_level_t.
3336
*/
3437
typedef enum {
3538
UCP_DEVICE_LEVEL_THREAD = 0,
@@ -76,14 +79,31 @@ typedef enum {
7679
*
7780
* @return Error code as defined by @ref ucs_status_t
7881
*/
79-
template <ucp_device_level_t level = UCP_DEVICE_LEVEL_THREAD>
80-
UCS_F_DEVICE ucs_status_t
81-
ucp_device_put_single(ucp_device_mem_list_handle_h mem_list,
82-
unsigned mem_list_index,
83-
const void *address, uint64_t remote_address,
84-
size_t length, uint64_t flags, ucp_device_request_t *req)
82+
template<ucp_device_level_t level = UCP_DEVICE_LEVEL_THREAD>
83+
UCS_F_DEVICE ucs_status_t ucp_device_put_single(
84+
ucp_device_mem_list_handle_h handle, unsigned mem_list_index,
85+
const void *address, uint64_t remote_address, size_t length,
86+
uint64_t flags, ucp_device_request_t *req)
8587
{
86-
return UCS_ERR_NOT_IMPLEMENTED;
88+
unsigned lane = 0;
89+
const uct_device_mem_element_t *uct_elem;
90+
size_t elem_offset;
91+
92+
if ((handle->version != UCP_DEVICE_MEM_LIST_VERSION_V1) ||
93+
(handle->num_uct_eps == 0) ||
94+
(mem_list_index >= handle->mem_list_length) || (flags != 0)) {
95+
return UCS_ERR_INVALID_PARAM;
96+
}
97+
98+
elem_offset = mem_list_index * handle->uct_mem_element_size[lane];
99+
uct_elem = (uct_device_mem_element_t *)
100+
UCS_PTR_BYTE_OFFSET(handle, sizeof(*handle) + elem_offset);
101+
102+
req->device_ep = handle->uct_device_eps[lane];
103+
req->comp.count = 1; /* TODO: Handle multiple device posts with same req? */
104+
return uct_device_ep_put_single<(uct_device_level_t)level>(
105+
req->device_ep, uct_elem, address, remote_address, length,
106+
UCT_DEVICE_FLAG_NODELAY, &req->comp);
87107
}
88108

89109

@@ -294,12 +314,14 @@ template <ucp_device_level_t level = UCP_DEVICE_LEVEL_THREAD>
294314
UCS_F_DEVICE ucs_status_t
295315
ucp_device_progress_req(ucp_device_request_t *req)
296316
{
317+
ucs_status_t status;
318+
297319
if (ucs_likely(req->comp.count == 0)) {
298320
return req->comp.status;
299321
}
300322

301-
/* TODO call uct progress function */
302-
return UCS_ERR_NOT_IMPLEMENTED;
323+
status = uct_device_ep_progress<(uct_device_level_t)level>(req->device_ep);
324+
return (status != UCS_OK ? status : UCS_INPROGRESS);
303325
}
304326

305327
#endif /* UCP_DEVICE_IMPL_H */

src/ucp/api/device/ucp_device_types.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ typedef struct ucp_device_mem_list_handle {
5555
*/
5656
uct_device_ep_h uct_device_eps[UCP_DEVICE_MEM_LIST_MAX_EPS];
5757

58-
/* (mem_list_length * num_uct_eps) uct_device_mem_element objects will
59-
follow this structure. The size of each element is according to the
60-
selected transport. */
58+
/**
59+
* Size of a given UCT memory element object for each UCT.
60+
*/
61+
uint16_t uct_mem_element_size[UCP_DEVICE_MEM_LIST_MAX_EPS];
62+
63+
/**
64+
* For each @ref num_uct_eps UCT endpoints, a list of @ref
65+
* uct_device_mem_element objects.
66+
*/
6167
} ucp_device_mem_list_handle_t;
6268

6369
#endif /* UCP_DEVICE_TYPES_H */

0 commit comments

Comments
 (0)