Skip to content

Commit 659ec9d

Browse files
committed
opal/accelerator: Add IPC APIs
Signed-off-by: William Zhang <[email protected]>
1 parent dae7c52 commit 659ec9d

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

opal/mca/accelerator/accelerator.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,71 @@ typedef int (*opal_accelerator_base_module_mem_release_fn_t)(
309309
typedef int (*opal_accelerator_base_module_get_address_range_fn_t)(
310310
int dev_id, const void *ptr, void **base, size_t *size);
311311

312+
/**
313+
* Queries whether the device supports Inter Process Communication
314+
* or not. If true, the functions:
315+
*
316+
* opal_accelerator_base_module_get_ipc_handle_size_fn_t()
317+
* opal_accelerator_base_module_get_ipc_handle_fn_t()
318+
* opal_accelerator_base_module_open_ipc_handle_fn_t()
319+
* opal_accelerator_base_module_close_ipc_handle_fn_t()
320+
*
321+
* must be implemented.
322+
*
323+
* @return true IPC supported
324+
* @return false IPC not supported
325+
*/
326+
typedef bool (*opal_accelerator_base_module_is_ipc_enabled_fn_t)(void);
327+
328+
/**
329+
* Returns the size of the Inter Process Communication memory handle
330+
*
331+
* @return size_t Size of the IPC memory handle
332+
*/
333+
typedef size_t (*opal_accelerator_base_module_get_ipc_handle_size_fn_t)(void);
334+
335+
/**
336+
* Gets an interprocess memory handle for an existing device memory allocation.
337+
*
338+
* @param[IN] dev_id Associated device for the IPC memory handle or
339+
* MCA_ACCELERATOR_NO_DEVICE_ID
340+
* @param[IN] dev_ptr Base pointer to previously allocated device
341+
* memory
342+
* @param[OUT] handle Pointer to user allocated mem handle to return
343+
* the memory handle in.
344+
*
345+
* @return OPAL_SUCCESS or error status on failure
346+
*
347+
*/
348+
typedef int (*opal_accelerator_base_module_get_ipc_handle_fn_t)(
349+
int dev_id, void *dev_ptr, void **handle);
350+
351+
/**
352+
* Opens an interprocess memory handle from another process and returns
353+
* a device pointer usable in the local process.
354+
*
355+
* @param[IN] dev_id Associated device for the IPC memory handle or
356+
* MCA_ACCELERATOR_NO_DEVICE_ID
357+
* @param[IN] handle IPC memory handle from another process
358+
* @param[IN] dev_id Device ID associated with the IPC memory handle
359+
* @param[OUT] dev_ptr Returned device pointer
360+
*
361+
* @return OPAL_SUCCESS or error status on failure
362+
*/
363+
typedef int (*opal_accelerator_base_module_open_ipc_handle_fn_t)(
364+
int dev_id, void *handle, void **dev_ptr);
365+
366+
/**
367+
* Closes memory mapped with opal_accelerator_base_module_open_ipc_handle_fn_t().
368+
*
369+
* @param[IN] dev_id Associated device for the IPC memory handle or
370+
* MCA_ACCELERATOR_NO_DEVICE_ID
371+
* @param[IN] dev_ptr IPC device pointer returned from
372+
* opal_accelerator_base_module_open_ipc_handle_fn_t()
373+
*/
374+
typedef int (*opal_accelerator_base_module_close_ipc_handle_fn_t)(
375+
int dev_id, void *dev_ptr);
376+
312377
/**
313378
* Page-locks the memory range specified by ptr and size
314379
*
@@ -394,6 +459,12 @@ typedef struct {
394459
opal_accelerator_base_module_mem_release_fn_t mem_release;
395460
opal_accelerator_base_module_get_address_range_fn_t get_address_range;
396461

462+
opal_accelerator_base_module_is_ipc_enabled_fn_t is_ipc_enabled;
463+
opal_accelerator_base_module_get_ipc_handle_size_fn_t get_ipc_handle_size;
464+
opal_accelerator_base_module_get_ipc_handle_fn_t get_ipc_handle;
465+
opal_accelerator_base_module_open_ipc_handle_fn_t open_ipc_handle;
466+
opal_accelerator_base_module_close_ipc_handle_fn_t close_ipc_handle;
467+
397468
opal_accelerator_base_module_host_register_fn_t host_register;
398469
opal_accelerator_base_module_host_unregister_fn_t host_unregister;
399470

0 commit comments

Comments
 (0)