aclrtCreateStream

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product / Atlas A3 inference product

Atlas A2 training product / Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

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.

If the stream creation API is not explicitly called, 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. Default streams apply to simple apps with low complexity of interaction logic. However, in multithreaded programming, the execution result depends on the thread scheduling sequence. Explicit stream creation (recommended) applies to large-scale applications with complex interaction logic, improving application readability and maintainability.

Prototype

1
aclError aclrtCreateStream(aclrtStream *stream)

Parameters

Parameter

Input/Output

Description

stream

Output

Stream pointer. For details about the type definition, see aclrtStream.

Returns

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

Restrictions

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 350 Accelerator Card

Atlas A3 training product / Atlas A3 inference product

Atlas A2 training product / Atlas A2 inference product

1984

Atlas 200I/500 A2 inference product

512

Atlas inference product

1024

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

Atlas training product

2048

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

API Call Example

For the API call example, see Stream Creation and Destruction.