|
24 | 24 | */ |
25 | 25 | typedef struct ucp_device_request { |
26 | 26 | uct_device_completion_t comp; |
| 27 | + uct_device_ep_h device_ep; |
27 | 28 | } ucp_device_request_t; |
28 | 29 |
|
29 | 30 |
|
30 | 31 | /** |
31 | 32 | * @ingroup UCP_DEVICE |
32 | 33 | * @brief Cooperation level when calling device functions. |
| 34 | + * |
| 35 | + * Must map exactly @ref uct_device_level_t. |
33 | 36 | */ |
34 | 37 | typedef enum { |
35 | 38 | UCP_DEVICE_LEVEL_THREAD = 0, |
@@ -76,14 +79,31 @@ typedef enum { |
76 | 79 | * |
77 | 80 | * @return Error code as defined by @ref ucs_status_t |
78 | 81 | */ |
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) |
85 | 87 | { |
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); |
87 | 107 | } |
88 | 108 |
|
89 | 109 |
|
@@ -294,12 +314,14 @@ template <ucp_device_level_t level = UCP_DEVICE_LEVEL_THREAD> |
294 | 314 | UCS_F_DEVICE ucs_status_t |
295 | 315 | ucp_device_progress_req(ucp_device_request_t *req) |
296 | 316 | { |
| 317 | + ucs_status_t status; |
| 318 | + |
297 | 319 | if (ucs_likely(req->comp.count == 0)) { |
298 | 320 | return req->comp.status; |
299 | 321 | } |
300 | 322 |
|
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); |
303 | 325 | } |
304 | 326 |
|
305 | 327 | #endif /* UCP_DEVICE_IMPL_H */ |
0 commit comments