cuda.core.experimental.Event#
- class cuda.core.experimental.Event(*args, **kwargs)#
Bases:
objectRepresent a record at a specific point of execution within a CUDA stream.
Applications can asynchronously record events at any point in the program. An event keeps a record of all previous work within the last recorded stream.
Events can be used to monitor device’s progress, query completion of work up to event’s record, help establish dependencies between GPU work submissions, and record the elapsed time (in milliseconds) on GPU:
# To create events and record the timing: s = Device().create_stream() e1 = Device().create_event({"enable_timing": True}) e2 = Device().create_event({"enable_timing": True}) s.record(e1) # ... run some GPU works ... s.record(e2) e2.sync() print(f"time = {e2 - e1} milliseconds")
Directly creating an
Eventis not supported due to ambiguity, and they should instead be created through aStreamobject.Methods
- __init__(*args, **kwargs)#
- close(self)#
Destroy the event.
- classmethod from_ipc_descriptor(
- cls,
- IPCEventDescriptor ipc_descriptor: IPCEventDescriptor,
Import an event that was exported from another process.
- get_ipc_descriptor(self) IPCEventDescriptor#
Export an event allocated for sharing between processes.
- sync(self)#
Synchronize until the event completes.
If the event was created with busy_waited_sync, then the calling CPU thread will block until the event has been completed by the device. Otherwise the CPU thread will busy-wait until the event has been completed.
Attributes
- close(self)#
Destroy the event.
- context#
Context
Return the
Contextassociated with this event.- Type:
Event.context
- device#
Device
Return the
Devicesingleton associated with this event.Note
The current context on the device may differ from this event’s context. This case occurs when a different CUDA context is set current after a event is created.
- Type:
Event.device
- classmethod from_ipc_descriptor(
- cls,
- IPCEventDescriptor ipc_descriptor: IPCEventDescriptor,
Import an event that was exported from another process.
- get_ipc_descriptor(self) IPCEventDescriptor#
Export an event allocated for sharing between processes.
- handle#
cuda.bindings.driver.CUevent
Return the underlying CUevent object.
Caution
This handle is a Python object. To get the memory address of the underlying C handle, call
int(Event.handle).- Type:
Event.handle
- is_done#
bool
Return True if all captured works have been completed, otherwise False.
- Type:
Event.is_done
- is_ipc_enabled#
bool
Return True if the event can be shared across process boundaries, otherwise False.
- Type:
Event.is_ipc_enabled
- is_sync_busy_waited#
bool
Return True if the event synchronization would keep the CPU busy-waiting, otherwise False.
- Type:
Event.is_sync_busy_waited
- is_timing_disabled#
bool
Return True if the event does not record timing data, otherwise False.
- Type:
Event.is_timing_disabled
- sync(self)#
Synchronize until the event completes.
If the event was created with busy_waited_sync, then the calling CPU thread will block until the event has been completed by the device. Otherwise the CPU thread will busy-wait until the event has been completed.