aclrtCreateStreamWithConfig
Applicable Products
|
Product |
Supported |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function
Creates a stream in the current process or thread.
Prototype
1
|
aclError aclrtCreateStreamWithConfig(aclrtStream *stream, uint32_t priority, uint32_t flag) |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
stream |
Output |
Stream pointer. For details about the type definition, see aclrtStream. |
|
priority |
Input |
Priority. The value range is [0, 7]. A maximum of eight priorities are available. A smaller value indicates a higher priority. 0 indicates the highest priority and 7 indicates the lowest priority. If a value is out of the range, it is changed to the nearest boundary value. |
|
flag |
Input |
Flag of the stream pointer. For details about the value of flag, see "flag Values." |
flag Values
flag can be set to the macros below. Set one or combine multiple using the bitwise OR operator (|), for example, ACL_STREAM_FAST_LAUNCH | ACL_STREAM_FAST_SYNC. If a macro that does not support bitwise OR is specified, the API returns an error. If other values are specified, the created stream is equivalent to a stream created by the aclrtCreateStream API.
- ACL_STREAM_FAST_LAUNCH: creates a stream that features fast task launching.
In ACL_STREAM_FAST_LAUNCH mode, internal system resources are pre-allocated when the stream is created. Therefore, the stream creation duration is longer but the task launching duration is shorter. If a stream is created once and used multiple times, the total duration will be shorter. However, pre-allocation for internal resources during stream creation increases memory consumption. By contrast, if you create a stream by calling aclrtCreateStream, internal system resources are allocated only when the stream is used. As a result, the task launching duration is longer.
#define ACL_STREAM_FAST_LAUNCH 0x00000001U
- ACL_STREAM_FAST_SYNC: creates a stream that blocks the current thread and queries the task execution status to return a result upon task completion after you call aclrtSynchronizeStream.
In ACL_STREAM_FAST_SYNC mode, stream creation takes less time compared with using the aclrtCreateStream API. However, the query operation increases the CPU performance consumption. If you create a stream by calling aclrtCreateStream, after you call aclrtSynchronizeStream, the stream waits for the notification indicating that the task execution on the device is complete, which is time-consuming.
#define ACL_STREAM_FAST_SYNC 0x00000002U
- ACL_STREAM_PERSISTENT: creates a stream where tasks are not executed right away or deleted immediately after execution. Resources for these tasks are destroyed only when the stream itself is destroyed. The stream created in this mode is bound to a model and applies to model building scenarios. For details about the APIs related to model building, see aclmdlRIBindStream.
#define ACL_STREAM_PERSISTENT 0x00000004U
- ACL_STREAM_HUGE: creates a stream that can hold more tasks than streams created with other flags.
In the current version, this flag does not take effect.
#define ACL_STREAM_HUGE 0x00000008U
- ACL_STREAM_CPU_SCHEDULE: creates a stream that carries AI CPU scheduling tasks in queue-based model inference scenarios. This flag is reserved.
#define ACL_STREAM_CPU_SCHEDULE 0x00000010U
- ACL_STREAM_DEVICE_USE_ONLY: creates a stream that is restricted to device-side calls.
#define ACL_STREAM_DEVICE_USE_ONLY 0x00000020U
The following product models support ACL_STREAM_DEVICE_USE_ONLY:
Ascend 950PR /Ascend 950DT Atlas A3 training products /Atlas A3 inference products Atlas A2 training products /Atlas A2 inference products Atlas inference products
Returns
0 on success; otherwise, failure. For details, see aclError.