Function: create_stream_with_config

C Prototype

aclError aclrtCreateStreamWithConfig(aclrtStream *stream, uint32_t priority, uint32_t flag)

Python Function

stream, ret = acl.rt.create_stream_with_config(priority, flag)

Function Usage

Creates a stream in the calling process or thread.

For the Atlas Training Series Product, compared with acl.rt.create_stream, this API can create a stream that features fast task launching. However, it consumes more memory or CPU resources.

For the Atlas 200/300/500 Inference Product, this API functions equivalently to acl.rt.create_stream.

Input Description

priority: int, priority.

For the Atlas 200/300/500 Inference Product, this parameter is reserved and fixed at 0.

For the Atlas Training Series Product, this parameter is reserved and fixed at 0.

flag: int, flag of a stream.

Values:

  • ACL_STREAM_FAST_LAUNCH = 1: creates a stream that features fast task launching.

    In ACL_STREAM_FAST_LAUNCH mode, the internal system resources are pre-allocated when the stream is created. Therefore, the stream creation duration is prolonged but the task launching duration is shortened. If a stream is created once and used for multiple times, the total duration will be shortened. However, pre-allocation for internal resources during stream creation increases memory consumption. By contrast, if you create a stream by calling acl.rt.create_stream, the internal system resources are allocated only when the stream is used. As a result, the task launching duration is prolonged.

  • ACL_STREAM_FAST_SYNC = 2: creates a stream that blocks the current thread and queries the task execution status to return a result upon task completion after you call acl.rt.synchronize_stream.

    In ACL_STREAM_FAST_SYNC mode, the total duration is shortened. However, the query operation increases the CPU performance consumption. By contrast, if you create a stream by calling acl.rt.create_stream, after you call acl.rt.synchronize_stream, the stream waits for the notification indicating that the task execution on the device is complete, which is time-consuming.

    NOTE:

    If this parameter is set to a value beyond the value range, the stream created by this API is equivalent to that created by acl.rt.create_stream.

Return Value

stream: int, stream object pointer address.

ret: int, error code.