Function: create_stream

Applicable Products

Product

Supported (√/x)

Ascend 950PR / Ascend 950DT

√

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

√

Description

Creates a stream in the calling process or thread.

This API does not allow for adjusting the stream priority. By default, streams are assigned the highest priority if none is specified. For details about how to set the priority when creating a stream, see the acl.rt.create_stream_with_config API.

If the stream creation API is not explicitly called, each context corresponds to a default stream. The default stream is implicitly created by calling the acl.rt.set_device or acl.rt.create_context API. The priority of the default stream cannot be set and is the highest priority. The default stream is suitable for simple applications without complex interaction logic. However, in multithreaded programming, the execution result depends on the thread scheduling sequence. Explicitly created streams are suitable for large-scale applications with complex interaction logic to improve program readability and maintainability. Therefore, explicit streams are recommended.

Prototype

Parameters

None

Return Values

Return Value

Description

stream

Int, pointer address of the created context.

ret

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

Restrictions

Model

Maximum Number of Streams

Ascend 950PR / Ascend 950DT

1,984

Atlas A3 training products / Atlas A3 inference products

1,984

Atlas A2 training products / Atlas A2 inference products

1,984

Atlas 200I/500 A2 inference products

512

Atlas inference products

1,024

In the Ascend EP form, there is a stream for internal synchronization.

Atlas training products

2,048

In the multi-process scenario, if the total number of streams created at a time is close to 2,048, streams may fail to be created. In this case, you are advised to perform the following operations:
  1. Clear redundant streams.
  2. Adjust the code logic to create streams in batches.

    For example, create some streams in the first batch, then the second batch, and so on until the total number of streams is close to 2,048.

Reference

For details about the API call sequence and examples, see Runtime Resource Allocation and Deallocation.