warp.Stream#

class warp.Stream(*args, **kwargs)[source]#
__init__(device=None, priority=0, **kwargs)[source]#

Initialize the stream on a device with an optional specified priority.

Parameters:
  • device (Device | str | None) – The CUDA device on which this stream will be created.

  • priority (int) – An optional integer specifying the requested stream priority. Can be -1 (high priority) or 0 (low/default priority). Values outside this range will be clamped.

  • cuda_stream (int) – A optional external stream handle passed as an integer. The caller is responsible for ensuring that the external stream does not get destroyed while it is referenced by this object.

Raises:
  • RuntimeError – If function is called before Warp has completed initialization with a device that is not an instance of Device.

  • RuntimeErrordevice is not a CUDA Device.

  • RuntimeError – The stream could not be created on the device.

  • TypeError – The requested stream priority is not an integer.

Methods

__init__([device, priority])

Initialize the stream on a device with an optional specified priority.

record_event([event, external])

Record an event onto the stream.

wait_event(event[, external])

Makes all future work in this stream wait until event has completed.

wait_stream(other_stream[, event, external])

Records an event on other_stream and makes this stream wait on it.

Attributes

cached_event

is_capturing

A boolean indicating whether a graph capture is currently ongoing on this stream.

is_complete

A boolean indicating whether all work on the stream has completed.

priority

An integer representing the priority of the stream.

property cached_event: Event[source]#
record_event(event=None, external=False)[source]#

Record an event onto the stream.

Parameters:
  • event (Event | None) – A warp.Event instance to be recorded onto the stream. If not provided, an Event on the same device will be created.

  • external (bool) – Whether this is an external event during graph capture. This argument has no effect outside of graph capture.

Raises:

RuntimeError – The provided Event is from a different device than the recording stream.

Return type:

Event

wait_event(event, external=False)[source]#

Makes all future work in this stream wait until event has completed.

This function does not block the host thread.

Parameters:
  • event (Event) – Event instance to wait for.

  • external (bool) – Whether this is an external event during graph capture. This argument has no effect outside of graph capture.

wait_stream(other_stream, event=None, external=False)[source]#

Records an event on other_stream and makes this stream wait on it.

All work added to this stream after this function has been called will delay their execution until all preceding commands in other_stream have completed.

This function does not block the host thread.

Parameters:
  • other_stream (Stream) – The stream on which the calling stream will wait for previously issued commands to complete before executing subsequent commands.

  • event (Event | None) – An optional Event instance that will be used to record an event onto other_stream. If None, an internally managed Event instance will be used.

  • external (bool) – Whether this is an external event during graph capture. This argument has no effect outside of graph capture.

property is_complete: bool[source]#

A boolean indicating whether all work on the stream has completed.

This property may not be accessed during a graph capture on any stream.

property is_capturing: bool[source]#

A boolean indicating whether a graph capture is currently ongoing on this stream.

property priority: int[source]#

An integer representing the priority of the stream.