cuda.core.Event#

class cuda.core.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({"timing_enabled": True})
e2 = Device().create_event({"timing_enabled": 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 a Stream object.

Methods

__init__(*args, **kwargs)#
close(self)#

Destroy the event.

Releases the event handle. The underlying CUDA event is destroyed when the last reference is released.

classmethod from_ipc_descriptor(
cls,
IPCEventDescriptor ipc_descriptor: IPCEventDescriptor,
) Event#

Import an event that was exported from another process.

sync(self)#

Synchronize until the event completes.

If the event was created with blocking_sync=True, the calling CPU thread blocks (yields) until the event has been completed by the device. Otherwise (the default) the CPU thread busy-waits until the event has completed.

Attributes

context#

Return the Context associated with this event.

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.

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).

ipc_descriptor#

Descriptor for sharing this event with other processes.

is_blocking_sync#

Return True if the event uses blocking synchronization (the CPU thread blocks on sync() instead of busy-waiting), otherwise False.

is_done#

Return True if all captured works have been completed, otherwise False.

is_ipc_enabled#

Return True if the event can be shared across process boundaries, otherwise False.

is_timing_enabled#

Return True if the event records timing data, otherwise False.