cuda.core.experimental._event.Event¶
- class cuda.core.experimental._event.Event(*args, **kwargs)¶
Represent 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
Event
is not supported due to ambiguity, and they should instead be created through aStream
object.Methods
- __init__()¶
- close()¶
Destroy the event.
- sync()¶
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
- property context: Context¶
Return the
Context
associated with this event.
- property device: Device¶
Return the
Device
singleton 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.
- property 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)
.
- property is_ipc_supported: bool¶
Return True if this event can be used as an interprocess event, otherwise False.