dpctl.memory.IPCMemoryHandle

class dpctl.memory.IPCMemoryHandle

Wrapper around a SYCL IPC memory handle.

Instances are created by passing a MemoryUSMDevice to the constructor. The resulting object exposes to_bytes() which returns an opaque bytes payload suitable for inter-process transport (e.g. via pickle, ZMQ, shared-memory).

On the receiving side, call IPCMemoryHandle.open() with the payload and a target device to obtain a MemoryIPCDevice backed by the IPC-mapped memory.

Parameters:

usm_memory (MemoryUSMDevice) – USM device memory object whose pointer to export.

Raises:
  • TypeError – If usm_memory is not a MemoryUSMDevice instance.

  • RuntimeError – If IPC memory is not supported or the handle export fails.

Examples

Sender process:

from dpctl.memory import MemoryUSMDevice, IPCMemoryHandle
mem = MemoryUSMDevice(4096)
handle = IPCMemoryHandle(mem)
raw = handle.to_bytes()  # send to another process

Receiver process:

from dpctl.memory import IPCMemoryHandle
mapped_mem = IPCMemoryHandle.open(raw, device, nbytes=4096)
# ... use mapped_mem ...
IPCMemoryHandle.close_mapping(mapped_mem)

Methods

close()

Mark this handle object as closed.

close_mapping(usm_memory)

Explicitly close an IPC mapping.

is_available()

Return whether IPC memory support is available in this build.

open(handle_bytes, device, nbytes)

Open an IPC handle in this process.

to_bytes()

Return the raw IPC handle data as bytes.