Function: create_stream
Applicability
|
Product |
Supported (√/x) |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function Usage
Creates a stream in the calling process or thread.
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, which is implicitly created with the call to acl.rt.set_device or acl.rt.create_context. You are advised to use acl.rt.create_stream 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.
Atlas 200I/500 A2 inference products - The hardware allows a maximum of 512 streams.
- If multiple default streams exist, only N streams can be explicitly created (N = 512 – Default number of streams – Number of streams for internal synchronization).
For example, if a default stream and a stream that performs internal synchronization already exist, only 510 streams can be explicitly created.
Atlas inference products - The hardware allows a maximum of 1024 streams.
- In standard form, if multiple default streams exist, only N streams can be explicitly created (N = 1024 – Default number of streams – Number of streams for internal synchronization).
For example, if a default stream and a stream that performs internal synchronization already exist, only 1022 streams can be explicitly created.
Atlas training products - The hardware allows a maximum of 2048 streams.
- If multiple default streams exist, only N streams can be explicitly created (N = 2048 – Default number of streams – Number of streams for internal synchronization).
For example, if a default stream and a stream that performs internal synchronization already exist, only 2046 streams can be explicitly created.
- In the multi-process scenario, if the total number of streams created at a time is close to 2048, streams may fail to be created. In this case, you are advised to perform the following operations:
Atlas A2 training products /Atlas A2 inference products - The hardware allows a maximum of 1984 streams.
- If multiple default streams exist, only N streams can be explicitly created (N = 1984 – Default number of streams – Number of streams for internal synchronization).
For example, if a default stream and a stream that performs internal synchronization already exist, only 2046 streams can be explicitly created.
-
- The hardware allows a maximum of 1984 streams.
- For example, if a default stream and a stream that performs internal synchronization already exist, only 2046 streams can be explicitly created.