aclrtCreateStream
Applicable Products
|
Product |
Supported |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function
Creates a stream.
This API does not allow for setting 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. The default stream is suitable for simple applications without complex interaction logic. However, in multi-thread 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, explicitly created streams are recommended.
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) 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.
- For the
Ascend 950PR /Ascend 950DT ,Atlas A3 training products /Atlas A3 inference products ,Atlas A2 training products /Atlas A2 inference products , the maximum number of streams is 1,984. - For the
Atlas 200I/500 A2 inference products , the maximum number of streams is 512. - For the
Atlas inference products , the maximum number of streams is 1,024. - For the
Atlas training products , the maximum number of streams is 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 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.