4
4
* reserved.
5
5
* Copyright (c) Amazon.com, Inc. or its affiliates.
6
6
* All Rights reserved.
7
+ * Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights reserved.
8
+ *
7
9
* $COPYRIGHT$
8
10
*
9
11
* Additional copyrights may follow
@@ -110,19 +112,28 @@ struct opal_accelerator_stream_t {
110
112
void * stream ;
111
113
};
112
114
typedef 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
113
119
114
120
#define IPC_MAX_HANDLE_SIZE 64
115
121
struct opal_accelerator_ipc_handle_t {
122
+ opal_object_t super ;
116
123
size_t size ;
117
124
uint8_t handle [IPC_MAX_HANDLE_SIZE ];
125
+ void * dev_ptr ;
118
126
};
119
127
typedef struct opal_accelerator_ipc_handle_t opal_accelerator_ipc_handle_t ;
128
+ OBJ_CLASS_DECLARATION (opal_accelerator_ipc_handle_t );
120
129
121
130
struct opal_accelerator_ipc_event_handle_t {
131
+ opal_object_t super ;
122
132
size_t size ;
123
133
uint8_t handle [IPC_MAX_HANDLE_SIZE ];
124
134
};
125
135
typedef struct opal_accelerator_ipc_event_handle_t opal_accelerator_ipc_event_handle_t ;
136
+ OBJ_CLASS_DECLARATION (opal_accelerator_ipc_event_handle_t );
126
137
127
138
struct opal_accelerator_pci_attr_t {
128
139
uint16_t domain_id ;
@@ -132,7 +143,6 @@ struct opal_accelerator_pci_attr_t {
132
143
};
133
144
typedef struct opal_accelerator_pci_attr_t opal_accelerator_pci_attr_t ;
134
145
135
- OBJ_CLASS_DECLARATION (opal_accelerator_stream_t );
136
146
137
147
struct opal_accelerator_event_t {
138
148
opal_object_t super ;
@@ -180,14 +190,15 @@ typedef int (*opal_accelerator_base_module_create_stream_fn_t)(
180
190
* corresponding stream. This function will allocate memory for the object.
181
191
* To release the memory, call OBJ_RELEASE(*event);
182
192
*
183
- * @param[IN] dev_id Associated device for the event or
193
+ * @param[IN] dev_id Associated device for the event or
184
194
* 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
186
197
*
187
198
* @return OPAL_SUCCESS or error status on failure.
188
199
*/
189
200
typedef 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 );
191
202
192
203
/**
193
204
* 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)(
219
230
typedef int (* opal_accelerator_base_module_query_event_fn_t )(
220
231
int dev_id , opal_accelerator_event_t * event );
221
232
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
+
222
246
/**
223
247
* Copies memory asynchronously from src to dest. Memory of dest and src
224
248
* 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)(
342
366
*
343
367
* opal_accelerator_base_module_get_ipc_handle_fn_t()
344
368
* opal_accelerator_base_module_open_ipc_handle_fn_t()
369
+ * opal_accelerator_base_module_import_ipc_event_handle_fn_t()
345
370
* opal_accelerator_base_module_get_ipc_event_handle_fn_t()
346
371
* opal_accelerator_base_module_open_ipc_event_handle_fn_t()
372
+ * opal_accelerator_base_module_import_ipc_event_handle_fn_t()
347
373
*
348
374
* must be implemented.
349
375
*
@@ -354,6 +380,8 @@ typedef bool (*opal_accelerator_base_module_is_ipc_enabled_fn_t)(void);
354
380
355
381
/**
356
382
* 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.
357
385
*
358
386
* @param[IN] dev_id Associated device for the IPC memory handle or
359
387
* MCA_ACCELERATOR_NO_DEVICE_ID
@@ -366,31 +394,67 @@ typedef bool (*opal_accelerator_base_module_is_ipc_enabled_fn_t)(void);
366
394
typedef int (* opal_accelerator_base_module_get_ipc_handle_fn_t )(
367
395
int dev_id , void * dev_ptr , opal_accelerator_ipc_handle_t * handle );
368
396
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
+
369
414
/**
370
415
* Opens an IPC memory handle from another process and returns
371
416
* a device pointer usable in the local process.
372
417
*
373
418
* @param[IN] dev_id Associated device for the IPC memory handle or
374
419
* 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
376
421
* @param[OUT] dev_ptr Returned device pointer
377
422
*
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
379
426
*/
380
427
typedef int (* opal_accelerator_base_module_open_ipc_handle_fn_t )(
381
428
int dev_id , opal_accelerator_ipc_handle_t * handle , void * * dev_ptr );
382
429
383
430
/**
384
431
* 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.
385
434
*
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
388
437
*
389
438
* @return OPAL_SUCCESS or error status on failure
390
439
*/
391
440
typedef int (* opal_accelerator_base_module_get_ipc_event_handle_fn_t )(
392
441
opal_accelerator_event_t * event , opal_accelerator_ipc_event_handle_t * handle );
393
442
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
+
394
458
/**
395
459
* Opens an IPC event handle from another process opened by
396
460
* opal_accelerator_base_module_get_ipc_event_handle_fn_t.
@@ -490,6 +554,7 @@ typedef struct {
490
554
opal_accelerator_base_module_create_event_fn_t create_event ;
491
555
opal_accelerator_base_module_record_event_fn_t record_event ;
492
556
opal_accelerator_base_module_query_event_fn_t query_event ;
557
+ opal_accelerator_base_module_wait_event_fn_t wait_event ;
493
558
494
559
opal_accelerator_base_module_memcpy_async_fn_t mem_copy_async ;
495
560
opal_accelerator_base_module_memcpy_fn_t mem_copy ;
@@ -501,8 +566,10 @@ typedef struct {
501
566
502
567
opal_accelerator_base_module_is_ipc_enabled_fn_t is_ipc_enabled ;
503
568
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 ;
504
570
opal_accelerator_base_module_open_ipc_handle_fn_t open_ipc_handle ;
505
571
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 ;
506
573
opal_accelerator_base_module_open_ipc_event_handle_fn_t open_ipc_event_handle ;
507
574
508
575
opal_accelerator_base_module_host_register_fn_t host_register ;
0 commit comments