Skip to main content

Mojo struct

DeviceEvent

struct DeviceEvent

Represents a GPU event for synchronization between streams.

A DeviceEvent allows for fine-grained synchronization between different GPU streams. Events can be recorded in one stream and waited for in another, enabling efficient coordination of asynchronous GPU operations.

Example:

from std.gpu.host import DeviceContext

var ctx = DeviceContext()

var default_stream = ctx.stream()
var new_stream = ctx.create_stream()

# Create event in default_stream
var event = ctx.create_event()

# Wait for the event in new_stream
new_stream.enqueue_wait_for(event)

# Stream 2 can continue
default_stream.record_event(event)

Implemented traits​

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable

Methods​

__del__​

__del__(deinit self)

Releases resources associated with this event.

synchronize​

synchronize(self)

Blocks the calling CPU thread until this event completes.

This function waits until the event has been recorded and all operations before the event in the stream have completed.

Raises:

If synchronization fails.

Was this page helpful?