Event#
- class torch.xpu.streams.Event(enable_timing=False, blocking=False, interprocess=False)[source]#
Wrapper around a XPU event.
XPU events are synchronization markers that can be used to monitor the device’s progress, and to synchronize XPU streams.
The underlying XPU events are lazily initialized when the event is first recorded. After creation, only streams on the same device may record the event. However, streams on any device can wait on the event.
- Parameters:
- elapsed_time(end_event)[source]#
Return the time elapsed.
Time reported in milliseconds after the event was recorded and before the end_event was recorded.
- Parameters:
end_event (Event) – the end event.
- classmethod from_ipc_handle(device, ipc_handle)[source]#
Reconstruct an event from an IPC handle on the given device.
- Parameters:
device (torch.device, int, or str) – the device on which to open the handle.
ipc_handle (bytes) – the IPC handle returned by
ipc_handle().
- Returns:
an event reconstructed from the IPC handle.
- Return type:
- ipc_handle()[source]#
Return an IPC handle of this event.
The event must have been constructed with
interprocess=True. If not yet recorded, the event is eagerly initialized on the current device.Note
The event reconstructed with
from_ipc_handle()cannot be re-exported viaipc_handle().- Returns:
- an opaque byte string that can be passed to
from_ipc_handle() in another process to reconstruct this event.
- an opaque byte string that can be passed to
- Return type:
- query()[source]#
Check if all work currently captured by event has completed.
- Returns:
A boolean indicating if all work currently captured by event has completed.
- Return type:
- record(stream=None)[source]#
Record the event in a given stream.
- Parameters:
stream (Stream, torch.Stream, optional) – Uses
torch.xpu.current_stream()if no stream is specified. The stream’s device must match the event’s device.
- synchronize()[source]#
Wait for the event to complete.
Waits until the completion of all work currently captured in this event. This prevents the CPU thread from proceeding until the event completes.
- wait(stream=None)[source]#
Make all future work submitted to the given stream wait for this event.
- Parameters:
stream (Stream, torch.Stream, optional) – Uses
torch.xpu.current_stream()if no stream is specified.