Skip to content

Commit 3c3d489

Browse files
authored
UCP/API/DEVICE: Add signaling API (#10836)
1 parent b088951 commit 3c3d489

File tree

3 files changed

+124
-26
lines changed

3 files changed

+124
-26
lines changed

src/ucp/api/device/ucp_device_impl.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,29 @@ ucp_device_put_multi_partial(ucp_device_mem_list_handle_h mem_list,
241241

242242
/**
243243
* @ingroup UCP_DEVICE
244+
* @brief Read a counter value from memory.
244245
*
246+
* This function can be used on the receiving side to detect completion of a
247+
* data transfer.
248+
*
249+
* The counter memory area must be initialized with the host function
250+
* @ref ucp_device_counter_init.
251+
*
252+
* @tparam level Level of cooperation of the transfer.
253+
* @param [in] counter_ptr Counter memory area.
254+
*
255+
* @return value of the counter memory area, UINT64_MAX in case of error.
256+
*/
257+
template <ucp_device_level_t level = UCP_DEVICE_LEVEL_THREAD>
258+
UCS_F_DEVICE uint64_t
259+
ucp_device_counter_read(const void *counter_ptr)
260+
{
261+
return 0;
262+
}
263+
264+
265+
/**
266+
* @ingroup UCP_DEVICE
245267
* @brief Initialize a device request.
246268
*
247269
* @param [out] req Device request to initialize.

src/ucp/api/device/ucp_host.h

Lines changed: 92 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ BEGIN_C_DECLS
2828
* @ingroup UCP_DEVICE
2929
* @brief Memory descriptor list attributes field mask.
3030
*
31-
* The enumeration allows specifying which fields in @ref ucp_mem_list_elem are
32-
* present. It is used to enable backward compatibility support.
31+
* The enumeration allows specifying which fields in @ref
32+
* ucp_device_mem_list_elem are present.
33+
*
34+
* It is used to enable backward compatibility support.
3335
*/
34-
enum ucp_mem_list_elem_field {
35-
UCP_MEM_LIST_ELEM_FIELD_MEMH = UCS_BIT(0), /**< Source memory handle */
36-
UCP_MEM_LIST_ELEM_FIELD_RKEY = UCS_BIT(1) /**< Unpacked remote memory key */
36+
enum ucp_device_mem_list_elem_field {
37+
UCP_DEVICE_MEM_LIST_ELEM_FIELD_MEMH = UCS_BIT(0), /**< Source memory handle */
38+
UCP_DEVICE_MEM_LIST_ELEM_FIELD_RKEY = UCS_BIT(1) /**< Unpacked remote memory key */
3739
};
3840

3941

@@ -44,10 +46,10 @@ enum ucp_mem_list_elem_field {
4446
* This describes a pair of local and remote memory for which a memory operation
4547
* can later be performed multiple times, possibly with varying memory offsets.
4648
*/
47-
typedef struct ucp_mem_list_elem {
49+
typedef struct ucp_device_mem_list_elem {
4850
/**
4951
* Mask of valid fields in this structure, using bits from
50-
* @ref ucp_mem_list_elem_field.
52+
* @ref ucp_device_mem_list_elem_field.
5153
* Fields not specified in this mask will be ignored.
5254
* Provides ABI compatibility with respect to adding new fields.
5355
*/
@@ -62,17 +64,17 @@ typedef struct ucp_mem_list_elem {
6264
* Unpacked memory key for the remote memory endpoint.
6365
*/
6466
ucp_rkey_h rkey;
65-
} ucp_mem_list_elem_t;
67+
} ucp_device_mem_list_elem_t;
6668

6769

6870
/**
6971
* @ingroup UCP_DEVICE
7072
* @brief Memory descriptor list create parameters field mask.
7173
*
72-
* The enumeration allows specifying which fields in @ref ucp_mem_list_params_t
74+
* The enumeration allows specifying which fields in @ref ucp_device_mem_list_params_t
7375
* are presents. It is used to enable backward compatibility support.
7476
*/
75-
enum ucp_mem_list_params_field {
77+
enum ucp_device_mem_list_params_field {
7678
UCP_MEM_LIST_PARAMS_FIELD_ELEMENTS = UCS_BIT(0), /**< Elements array base address */
7779
UCP_MEM_LIST_PARAMS_FIELD_ELEMENT_SIZE = UCS_BIT(1), /**< Element size in bytes */
7880
UCP_MEM_LIST_PARAMS_FIELD_NUM_ELEMENTS = UCS_BIT(2) /**< Number of elements */
@@ -84,12 +86,12 @@ enum ucp_mem_list_params_field {
8486
* @brief Memory descriptor list create parameters.
8587
*
8688
* The structure defines the parameters that can be used to create a handle
87-
* with @ref ucp_mem_list_create.
89+
* with @ref ucp_device_mem_list_create.
8890
*/
89-
typedef struct ucp_mem_list_params {
91+
typedef struct ucp_device_mem_list_params {
9092
/**
9193
* Mask of valid fields in this structure, using bits from
92-
* @ref ucp_mem_list_params_field.
94+
* @ref ucp_device_mem_list_params_field.
9395
* Fields not specified in this mask will be ignored.
9496
* Provides ABI compatibility with respect to adding new fields.
9597
*/
@@ -108,8 +110,8 @@ typedef struct ucp_mem_list_params {
108110
/**
109111
* Base address of the array of descriptor elements.
110112
*/
111-
const ucp_mem_list_elem_t *elements;
112-
} ucp_mem_list_params_t;
113+
const ucp_device_mem_list_elem_t *elements;
114+
} ucp_device_mem_list_params_t;
113115

114116

115117
/**
@@ -126,12 +128,12 @@ typedef struct ucp_device_mem_list_handle *ucp_device_mem_list_handle_h;
126128
* @brief Memory descriptor list create function for batched RMA operations.
127129
*
128130
* This function creates and populates a descriptor list handle using parameters
129-
* inputs from @ref ucp_mem_list_params_t. This descriptor is created for
131+
* inputs from @ref ucp_device_mem_list_params_t. This descriptor is created for
130132
* the given remote endpoint. It can be used on a GPU using the corresponding
131133
* device functions.
132134
*
133135
* It can be used repeatedly, until finally released by calling @ref
134-
* ucp_mem_list_release.
136+
* ucp_device_mem_list_release.
135137
*
136138
* @param [in] ep Remote endpoint handle.
137139
* @param [in] params Parameters used to create the handle.
@@ -140,21 +142,89 @@ typedef struct ucp_device_mem_list_handle *ucp_device_mem_list_handle_h;
140142
* @return Error code as defined by @ref ucs_status_t.
141143
*/
142144
ucs_status_t
143-
ucp_mem_list_create(ucp_ep_h ep,
144-
const ucp_mem_list_params_t *params,
145-
ucp_device_mem_list_handle_h *handle);
145+
ucp_device_mem_list_create(ucp_ep_h ep,
146+
const ucp_device_mem_list_params_t *params,
147+
ucp_device_mem_list_handle_h *handle);
146148

147149

148150
/**
149151
* @ingroup UCP_DEVICE
150152
* @brief Release function for a descriptor list handle.
151153
*
152154
* This function releases the handle that was created using @ref
153-
* ucp_mem_list_create.
155+
* ucp_device_mem_list_create.
154156
*
155157
* @param [in] handle Created handle to release.
156158
*/
157-
void ucp_mem_list_release(ucp_device_mem_list_handle_h handle);
159+
void ucp_device_mem_list_release(ucp_device_mem_list_handle_h handle);
160+
161+
162+
/**
163+
* @ingroup UCP_DEVICE
164+
* @brief Signal init attributes field mask.
165+
*
166+
* The enumeration allows specifying which fields in @ref
167+
* ucp_device_counter_init_params_t are present. It is used to enable backward
168+
* compatibility support.
169+
*/
170+
enum ucp_device_counter_init_params_field {
171+
UCP_DEVICE_COUNTER_INIT_PARAMS_FIELD_MEM_TYPE = UCS_BIT(0), /**< Source memory handle */
172+
UCP_DEVICE_COUNTER_INIT_PARAMS_FIELD_MEMH = UCS_BIT(1) /**< Unpacked remote memory key */
173+
};
174+
175+
176+
/**
177+
* @ingroup UCP_DEVICE
178+
* @brief Parameters which can be used when calling @ref ucp_device_counter_init.
179+
*/
180+
typedef struct ucp_device_counter_init_params {
181+
/**
182+
* Mask of valid fields in this structure, using bits from
183+
* @ref ucp_device_counter_init_params_field.
184+
* Fields not specified in this mask will be ignored.
185+
* Provides ABI compatibility with respect to adding new fields.
186+
*/
187+
uint64_t field_mask;
188+
189+
/**
190+
* Optional memory type for the given @a counter memory area.
191+
*/
192+
ucs_memory_type_t mem_type;
193+
194+
/**
195+
* Optional memory registration handle for the given @a counter memory area.
196+
*/
197+
ucp_mem_h memh;
198+
} ucp_device_counter_init_params_t;
199+
200+
201+
/**
202+
* @ingroup UCP_DEVICE
203+
* @brief Initialize the contents of a counter memory area.
204+
*
205+
* This host routine is called by the receive side to set up the memory area for
206+
* signaling with a counter. A remote sender can then use the provided rkey to
207+
* notify when the data has been successfully sent.
208+
*
209+
* The receive side can poll for completion on this counter using the device
210+
* function @ref ucp_device_counter_read.
211+
*
212+
* The memory type or memory handle from params, might be used to help setting
213+
* the contents of the counting area.
214+
*
215+
* @param [in] context Context to use when initializing a counter area.
216+
* @param [in] params Parameters used to initialize the counter area.
217+
* @param [in] counter_ptr Address of the counting area.
218+
*
219+
* @return Error code as defined by @ref ucs_status_t.
220+
*/
221+
static UCS_F_ALWAYS_INLINE ucs_status_t
222+
ucp_device_counter_init(ucp_context_h context,
223+
const ucp_device_counter_init_params_t *params,
224+
void *counter_ptr) {
225+
/* TODO: actual Implementation will not be in headers */
226+
return UCS_ERR_NOT_IMPLEMENTED;
227+
}
158228

159229
END_C_DECLS
160230

src/ucp/api/ucp.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,11 @@ enum ucp_lib_attr_field {
430430
* present. It is used to enable backward compatibility support.
431431
*/
432432
enum ucp_context_attr_field {
433-
UCP_ATTR_FIELD_REQUEST_SIZE = UCS_BIT(0), /**< UCP request size */
434-
UCP_ATTR_FIELD_THREAD_MODE = UCS_BIT(1), /**< UCP context thread flag */
435-
UCP_ATTR_FIELD_MEMORY_TYPES = UCS_BIT(2), /**< UCP supported memory types */
436-
UCP_ATTR_FIELD_NAME = UCS_BIT(3) /**< UCP context name */
433+
UCP_ATTR_FIELD_REQUEST_SIZE = UCS_BIT(0), /**< UCP request size */
434+
UCP_ATTR_FIELD_THREAD_MODE = UCS_BIT(1), /**< UCP context thread flag */
435+
UCP_ATTR_FIELD_MEMORY_TYPES = UCS_BIT(2), /**< UCP supported memory types */
436+
UCP_ATTR_FIELD_NAME = UCS_BIT(3), /**< UCP context name */
437+
UCP_ATTR_FIELD_DEVICE_COUNTER_SIZE = UCS_BIT(4) /**< UCP Device API counter size */
437438
};
438439

439440

@@ -1208,6 +1209,11 @@ typedef struct ucp_context_attr {
12081209
* Tracing and analysis tools can use name to identify this UCX context.
12091210
*/
12101211
char name[UCP_ENTITY_NAME_MAX];
1212+
1213+
/**
1214+
* Size usable to allocate a counter memory for UCP Device API usage.
1215+
*/
1216+
size_t device_counter_size;
12111217
} ucp_context_attr_t;
12121218

12131219

0 commit comments

Comments
 (0)