Function: create_stream_with_config

Applicability

Product

Supported (√/x)

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

Function Usage

Creates a stream in the calling process or thread.

For the Atlas inference products, 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 training products, 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 A2 training products/Atlas A2 inference products, 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 200I/500 A2 inference products, this API functions equivalently to acl.rt.create_stream.

For the Atlas A3 training products/Atlas A3 inference products, 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.

Prototype

  • C Prototype
    1
    aclError aclrtCreateStreamWithConfig(aclrtStream *stream, uint32_t priority, uint32_t flag)
    
  • Python Function
    1
    stream, ret = acl.rt.create_stream_with_config(priority,flag)
    

Parameter Description

Parameter

Description

priority

priority: int, priority.

For the Atlas training products, this parameter is reserved and fixed at 0.

For the Atlas A2 training products/Atlas A2 inference products, this parameter is reserved and fixed at 0.

For the Atlas 200I/500 A2 inference products, this parameter is reserved and fixed at 0.

For the Atlas inference products, the value range of this parameter is [0, 7]. A maximum of eight priorities are supported. A smaller value indicates a higher priority. The value 0 indicates the highest priority and the value 7 indicates the lowest priority. If this parameter is set to a value beyond the value range, an error is returned.

flag

Int, flag of the stream.

Value range:

  • 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 Description

Return Value

Description

stream

Int, stream object pointer address.

ret

Int, error code: 0 on success; else, failure.