aclrtCreateStreamWithConfig

Description

Creates a stream in the calling process or thread.

For the Atlas 200/300/500 Inference Product, this API functions equivalently to aclrtCreateStream.

For the Atlas Training Series Product, compared with aclrtCreateStream, this API can create a stream that features fast task launching. However, it consumes more memory or CPU resources.

Prototype

aclError aclrtCreateStreamWithConfig(aclrtStream *stream, uint32_t priority, uint32_t flag)

Parameters

Parameter

Input/Output

Description

stream

Output

Stream pointer.

priority

Input

Priority.

For the Atlas 200/300/500 Inference Product, this parameter is reserved and fixed at 0.

For the Atlas Training Series Product, this parameter is reserved and fixed at 0.

flag

Input

Flag of the stream pointer.

Value range:

  • ACL_STREAM_FAST_LAUNCH: creates a stream that features fast task launching.

    In ACL_STREAM_FAST_LAUNCH mode, the internal system resources are pre-allocated when the stream is created. Therefore, the stream creation duration is prolonged but the task launching duration is shortened. If a stream is created once and used for multiple times, the total duration will be shortened. However, pre-allocation for internal resources during stream creation increases memory consumption. By contrast, if you create a stream by calling aclrtCreateStream, the internal system resources are allocated only when the stream is used. As a result, the task launching duration is prolonged.

  • 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, the total duration is shortened. However, the query operation increases the CPU performance consumption. By contrast, 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.

NOTE:

If this parameter is set to a value beyond the value range, the stream created by this API is equivalent to that created by aclrtCreateStream.

Returns

The value 0 indicates success, and other values indicate failure. For details, see aclError.