24
24
*/
25
25
typedef struct ucp_device_request {
26
26
uct_device_completion_t comp;
27
+ ucs_status_t status;
27
28
uct_device_ep_h device_ep;
28
29
unsigned channel_id;
29
30
} ucp_device_request_t ;
@@ -52,9 +53,6 @@ UCS_F_DEVICE void ucp_device_request_init(uct_device_ep_t *device_ep,
52
53
if (req != nullptr ) {
53
54
comp = &req->comp ;
54
55
req->device_ep = device_ep;
55
- uct_device_completion_init (comp);
56
- /* TODO: Handle multiple device posts with same req? */
57
- ++comp->count ;
58
56
} else {
59
57
comp = nullptr ;
60
58
}
@@ -64,16 +62,20 @@ UCS_F_DEVICE void ucp_device_request_init(uct_device_ep_t *device_ep,
64
62
/* *
65
63
* Macro for device put operations with retry logic
66
64
*/
67
- #define UCP_DEVICE_SEND_BLOCKING (_level, _uct_device_ep_send, _device_ep, ...) \
65
+ #define UCP_DEVICE_SEND_BLOCKING (_level, _uct_device_ep_send, _device_ep, \
66
+ _req, ...) \
68
67
({ \
69
68
ucs_status_t _status; \
70
69
do { \
71
70
_status = _uct_device_ep_send<_level>(_device_ep, __VA_ARGS__); \
72
71
if (_status != UCS_ERR_NO_RESOURCE) { \
73
72
break ; \
74
73
} \
75
- _status = uct_device_ep_progress<_level>(_device_ep); \
76
- } while (!UCS_STATUS_IS_ERR (_status)); \
74
+ uct_device_ep_progress<_level>(_device_ep); \
75
+ } while (1 ); \
76
+ if (_req != nullptr ) { \
77
+ _req->status = _status; \
78
+ } \
77
79
_status; \
78
80
})
79
81
@@ -154,10 +156,9 @@ UCS_F_DEVICE ucs_status_t ucp_device_put_single(
154
156
return status;
155
157
}
156
158
157
- status = UCP_DEVICE_SEND_BLOCKING (level, uct_device_ep_put_single,
158
- device_ep, uct_elem, address,
159
- remote_address, length, flags, comp);
160
- return status;
159
+ return UCP_DEVICE_SEND_BLOCKING (level, uct_device_ep_put_single, device_ep,
160
+ req, uct_elem, address, remote_address,
161
+ length, flags, comp);
161
162
}
162
163
163
164
@@ -209,8 +210,8 @@ UCS_F_DEVICE ucs_status_t ucp_device_counter_inc(
209
210
}
210
211
211
212
return UCP_DEVICE_SEND_BLOCKING (level, uct_device_ep_atomic_add, device_ep,
212
- uct_elem, inc_value, remote_address, flags ,
213
- comp);
213
+ req, uct_elem, inc_value, remote_address,
214
+ flags, comp);
214
215
}
215
216
216
217
@@ -266,8 +267,9 @@ UCS_F_DEVICE ucs_status_t ucp_device_put_multi(
266
267
}
267
268
268
269
return UCP_DEVICE_SEND_BLOCKING (level, uct_device_ep_put_multi, device_ep,
269
- uct_mem_list, mem_list_h->mem_list_length ,
270
- addresses, remote_addresses, lengths,
270
+ req, uct_mem_list,
271
+ mem_list_h->mem_list_length , addresses,
272
+ remote_addresses, lengths,
271
273
counter_inc_value, counter_remote_address,
272
274
flags, comp);
273
275
}
@@ -346,11 +348,12 @@ UCS_F_DEVICE ucs_status_t ucp_device_put_multi_partial(
346
348
}
347
349
348
350
return UCP_DEVICE_SEND_BLOCKING (level, uct_device_ep_put_multi_partial,
349
- device_ep, uct_mem_list, mem_list_indices,
350
- mem_list_count, addresses, remote_addresses,
351
- local_offsets, remote_offsets, lengths,
352
- counter_index, counter_inc_value,
353
- counter_remote_address, flags, comp);
351
+ device_ep, req, uct_mem_list,
352
+ mem_list_indices, mem_list_count, addresses,
353
+ remote_addresses, local_offsets,
354
+ remote_offsets, lengths, counter_index,
355
+ counter_inc_value, counter_remote_address,
356
+ flags, comp);
354
357
}
355
358
356
359
@@ -417,19 +420,14 @@ UCS_F_DEVICE void ucp_device_counter_write(void *counter_ptr, uint64_t value)
417
420
template <ucs_device_level_t level = UCS_DEVICE_LEVEL_THREAD>
418
421
UCS_F_DEVICE ucs_status_t ucp_device_progress_req (ucp_device_request_t *req)
419
422
{
420
- ucs_status_t status;
421
-
422
- if (ucs_likely (req->comp .count == 0 )) {
423
- return req->comp .status ;
424
- }
425
-
426
- status = uct_device_ep_progress<level>(req->device_ep );
427
- if (status != UCS_OK) {
428
- return status;
423
+ if (ucs_likely (req->status != UCS_INPROGRESS)) {
424
+ return req->status ;
429
425
}
430
426
431
- return (ucs_likely (req->comp .count == 0 )) ? req->comp .status :
432
- UCS_INPROGRESS;
427
+ uct_device_ep_progress<level>(req->device_ep );
428
+ req->status = uct_device_ep_check_completion<level>(req->device_ep ,
429
+ &req->comp );
430
+ return req->status ;
433
431
}
434
432
435
433
#endif /* UCP_DEVICE_IMPL_H */
0 commit comments