44 * reserved.
55 * Copyright (c) Amazon.com, Inc. or its affiliates.
66 * All Rights reserved.
7+ * Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights reserved.
8+ *
79 * $COPYRIGHT$
810 *
911 * Additional copyrights may follow
@@ -110,19 +112,28 @@ struct opal_accelerator_stream_t {
110112 void * stream ;
111113};
112114typedef struct opal_accelerator_stream_t opal_accelerator_stream_t ;
115+ OBJ_CLASS_DECLARATION (opal_accelerator_stream_t );
116+
117+ /* Constant indicating the default/zero stream */
118+ #define MCA_ACCELERATOR_STREAM_DEFAULT (opal_accelerator_stream_t *)0x00000002
113119
114120#define IPC_MAX_HANDLE_SIZE 64
115121struct opal_accelerator_ipc_handle_t {
122+ opal_object_t super ;
116123 size_t size ;
117124 uint8_t handle [IPC_MAX_HANDLE_SIZE ];
125+ void * dev_ptr ;
118126};
119127typedef struct opal_accelerator_ipc_handle_t opal_accelerator_ipc_handle_t ;
128+ OBJ_CLASS_DECLARATION (opal_accelerator_ipc_handle_t );
120129
121130struct opal_accelerator_ipc_event_handle_t {
131+ opal_object_t super ;
122132 size_t size ;
123133 uint8_t handle [IPC_MAX_HANDLE_SIZE ];
124134};
125135typedef struct opal_accelerator_ipc_event_handle_t opal_accelerator_ipc_event_handle_t ;
136+ OBJ_CLASS_DECLARATION (opal_accelerator_ipc_event_handle_t );
126137
127138struct opal_accelerator_pci_attr_t {
128139 uint16_t domain_id ;
@@ -132,7 +143,6 @@ struct opal_accelerator_pci_attr_t {
132143};
133144typedef struct opal_accelerator_pci_attr_t opal_accelerator_pci_attr_t ;
134145
135- OBJ_CLASS_DECLARATION (opal_accelerator_stream_t );
136146
137147struct opal_accelerator_event_t {
138148 opal_object_t super ;
@@ -180,14 +190,15 @@ typedef int (*opal_accelerator_base_module_create_stream_fn_t)(
180190 * corresponding stream. This function will allocate memory for the object.
181191 * To release the memory, call OBJ_RELEASE(*event);
182192 *
183- * @param[IN] dev_id Associated device for the event or
193+ * @param[IN] dev_id Associated device for the event or
184194 * MCA_ACCELERATOR_NO_DEVICE_ID
185- * @param[IN] event Event to create
195+ * @param[OUT] event Event to create
196+ * @param[IN] enable_ipc support inter-process tracking of the event
186197 *
187198 * @return OPAL_SUCCESS or error status on failure.
188199 */
189200typedef int (* opal_accelerator_base_module_create_event_fn_t )(
190- int dev_id , opal_accelerator_event_t * * event );
201+ int dev_id , opal_accelerator_event_t * * event , bool enable_ipc );
191202
192203/**
193204 * Records an event on a stream. An event recorded on the stream is
@@ -219,6 +230,19 @@ typedef int (*opal_accelerator_base_module_record_event_fn_t)(
219230typedef int (* opal_accelerator_base_module_query_event_fn_t )(
220231 int dev_id , opal_accelerator_event_t * event );
221232
233+ /**
234+ * Make a stream wait on an event
235+ *
236+ * @param[IN] dev_id Associated device for the event or
237+ * MCA_ACCELERATOR_NO_DEVICE_ID
238+ * @param[IN] event Event to wait on
239+ * @param[IN] stream Stream to wait
240+ *
241+ * @return OPAL_SUCCESS or error status on failure
242+ */
243+ typedef int (* opal_accelerator_base_module_wait_event_fn_t )(
244+ int dev_id , opal_accelerator_event_t * event , opal_accelerator_stream_t * stream );
245+
222246/**
223247 * Copies memory asynchronously from src to dest. Memory of dest and src
224248 * may not overlap. Optionally can specify the transfer type to
@@ -342,8 +366,10 @@ typedef int (*opal_accelerator_base_module_get_address_range_fn_t)(
342366 *
343367 * opal_accelerator_base_module_get_ipc_handle_fn_t()
344368 * opal_accelerator_base_module_open_ipc_handle_fn_t()
369+ * opal_accelerator_base_module_import_ipc_event_handle_fn_t()
345370 * opal_accelerator_base_module_get_ipc_event_handle_fn_t()
346371 * opal_accelerator_base_module_open_ipc_event_handle_fn_t()
372+ * opal_accelerator_base_module_import_ipc_event_handle_fn_t()
347373 *
348374 * must be implemented.
349375 *
@@ -354,6 +380,8 @@ typedef bool (*opal_accelerator_base_module_is_ipc_enabled_fn_t)(void);
354380
355381/**
356382 * Gets an IPC memory handle for an existing device memory allocation.
383+ * This interface assumes that the object has been declared statically,
384+ * hence one has to call OBJ_DESTRUCT(handle) on it.
357385 *
358386 * @param[IN] dev_id Associated device for the IPC memory handle or
359387 * MCA_ACCELERATOR_NO_DEVICE_ID
@@ -366,31 +394,67 @@ typedef bool (*opal_accelerator_base_module_is_ipc_enabled_fn_t)(void);
366394typedef int (* opal_accelerator_base_module_get_ipc_handle_fn_t )(
367395 int dev_id , void * dev_ptr , opal_accelerator_ipc_handle_t * handle );
368396
397+ /**
398+ * Creates an opal_accelerator_ipc_handle object given the 64byte IPC handle,
399+ * which was created using module_get_ipc_handle_fn on another process.
400+ * This interface assumes that the object has been declared statically,
401+ * hence one has to call OBJ_DESTRUCT(handle) on it.
402+ *
403+ * @param[IN] dev_id Associated device for the IPC memory handle or
404+ * MCA_ACCELERATOR_NO_DEVICE_ID
405+ * @param[IN] ipc_handle 64 byte IPC handle transfered from another process
406+ * @param[OUT] handle Pointer to IPC handle object
407+ *
408+ * @return OPAL_SUCCESS or error status on failure
409+ *
410+ */
411+ typedef int (* opal_accelerator_base_module_import_ipc_handle_fn_t )(
412+ int dev_id , uint8_t ipc_handle [IPC_MAX_HANDLE_SIZE ], opal_accelerator_ipc_handle_t * handle );
413+
369414/**
370415 * Opens an IPC memory handle from another process and returns
371416 * a device pointer usable in the local process.
372417 *
373418 * @param[IN] dev_id Associated device for the IPC memory handle or
374419 * MCA_ACCELERATOR_NO_DEVICE_ID
375- * @param[IN] handle IPC handle object from another process
420+ * @param[IN] handle IPC handle created using the module_create_ipc_handle_fn
376421 * @param[OUT] dev_ptr Returned device pointer
377422 *
378- * @return OPAL_SUCCESS or error status on failure
423+ * @return OPAL_SUCCESS on success,
424+ * OPAL_ERR_WOULD_BLOCK if the memory region is already mapped
425+ * or error status on other failures
379426 */
380427typedef int (* opal_accelerator_base_module_open_ipc_handle_fn_t )(
381428 int dev_id , opal_accelerator_ipc_handle_t * handle , void * * dev_ptr );
382429
383430/**
384431 * Gets an IPC event handle for an event created by opal_accelerator_base_module_create_event_fn_t.
432+ * This interface assumes that the object has been declared statically,
433+ * hence one has to call OBJ_DESTRUCT(handle) on it.
385434 *
386- * @param[IN] event Event created previously
387- * @param[OUT ] handle Pointer to IPC event handle object
435+ * @param[IN] event Event created previously
436+ * @param[IN ] handle Pointer to IPC event handle object
388437 *
389438 * @return OPAL_SUCCESS or error status on failure
390439 */
391440typedef int (* opal_accelerator_base_module_get_ipc_event_handle_fn_t )(
392441 opal_accelerator_event_t * event , opal_accelerator_ipc_event_handle_t * handle );
393442
443+ /**
444+ * Creates an opal_accelerator_ipc_event_handle object using the 64 byte IPC event handle
445+ * which was created using module_get_ipc_event_handle_fn on another process.
446+ * This interface assumes that the object has been declared statically,
447+ * hence one has to call OBJ_DESTRUCT(handle) on it.
448+ *
449+ * @param[IN] event Event created previously
450+ * @param[IN] ipc_handle 64 byte IPC handle object
451+ * @param[OUT] handle Pointer to IPC event handle object
452+ *
453+ * @return OPAL_SUCCESS or error status on failure
454+ */
455+ typedef int (* opal_accelerator_base_module_import_ipc_event_handle_fn_t )(
456+ uint8_t ipc_handle [IPC_MAX_HANDLE_SIZE ], opal_accelerator_ipc_event_handle_t * handle );
457+
394458/**
395459 * Opens an IPC event handle from another process opened by
396460 * opal_accelerator_base_module_get_ipc_event_handle_fn_t.
@@ -490,6 +554,7 @@ typedef struct {
490554 opal_accelerator_base_module_create_event_fn_t create_event ;
491555 opal_accelerator_base_module_record_event_fn_t record_event ;
492556 opal_accelerator_base_module_query_event_fn_t query_event ;
557+ opal_accelerator_base_module_wait_event_fn_t wait_event ;
493558
494559 opal_accelerator_base_module_memcpy_async_fn_t mem_copy_async ;
495560 opal_accelerator_base_module_memcpy_fn_t mem_copy ;
@@ -501,8 +566,10 @@ typedef struct {
501566
502567 opal_accelerator_base_module_is_ipc_enabled_fn_t is_ipc_enabled ;
503568 opal_accelerator_base_module_get_ipc_handle_fn_t get_ipc_handle ;
569+ opal_accelerator_base_module_import_ipc_handle_fn_t import_ipc_handle ;
504570 opal_accelerator_base_module_open_ipc_handle_fn_t open_ipc_handle ;
505571 opal_accelerator_base_module_get_ipc_event_handle_fn_t get_ipc_event_handle ;
572+ opal_accelerator_base_module_import_ipc_event_handle_fn_t import_ipc_event_handle ;
506573 opal_accelerator_base_module_open_ipc_event_handle_fn_t open_ipc_event_handle ;
507574
508575 opal_accelerator_base_module_host_register_fn_t host_register ;
0 commit comments