Function: create_stream
Applicability
|
Product |
Supported (√/x) |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function Usage
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 acl.rt.create_stream_with_config.
If the stream creation API is not explicitly called, each context has a default stream that is implicitly created with the acl.rt.set_device or acl.rt.create_context 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
- C Prototype
1aclError aclrtCreateStream(aclrtStream *stream)
- Python Function
1stream, ret = acl.rt.create_stream()
Parameter Description
None.
Return Value Description
|
Return Value |
Description |
|---|---|
|
stream |
Int, pointer address of the created context. |
|
ret |
Int, error code: 0 on success; else, failure. |
Restrictions
- Each context has a default stream that is implicitly created with the acl.rt.set_device or acl.rt.create_context 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 complexity 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 streams and the streams 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 Series Product Atlas A2 Training Series Product/Atlas 800I A2 Inference Product |
1,984 |
|
Atlas 200/500 A2 Inference Product |
512 |
|
Atlas Inference Series Product |
1,024 |
|
Atlas Training Series Product |
2,048
|