aclrtCreateStream

Applicability

Product

Supported

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Description

Creates a stream.

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 aclrtCreateStreamWithConfig.

Prototype

aclError aclrtCreateStream(aclrtStream *stream)

Parameters

Parameter

Input/Output

Description

stream

Output

Stream pointer.

Returns

0 on success; else, failure. For details, see aclError.

Restrictions

  • Each context has a default stream that is implicitly created with the aclrtSetDevice or aclrtCreateContext call. The priority of the default stream cannot be set, and it is assigned the highest priority. You are advised to use aclrtCreateStream to explicitly create a stream.
    • Implicit stream creation: applies to simple apps with low complicity of interaction logic. However, in multithreaded programming, the execution result depends on the thread scheduling sequence.
    • (Recommended) Explicit stream creation: applies to large apps with complex interaction logic, offering better app readability and maintainability.
  • The maximum number of streams supported by hardware varies depending on the hardware model. If multiple streams (including the default stream and the stream for internal synchronization) exist, only N streams can be explicitly created, where N = Maximum number of streams – Number of existing streams. For example, if the maximum number of streams is 1,024 and there are already two streams, you can only call this API to explicitly create 1,022 streams.

    Model

    Maximum Number of Streams

    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:

    • Clear redundant streams.
    • Adjust the code logic to create streams in batches. For instance, create a certain number of streams in the first batch, then create some more in the second batch, and continue this process until the total number of streams approaches 2,048.

See Also

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