AllocMutexID (ISASI)

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

x

Atlas A2 training product/Atlas A2 inference product

x

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Obtains and occupies a mutex ID from the framework. It is used together with ReleaseMutexID. It manages the obtaining and release of mutex IDs. An obtained mutex ID can be passed to the Mutex::Lock/Unlock API. In this case, Mutex::Lock/Unlock can be used together with other APIs such as TQue.

Prototype

1
__aicore__ inline MutexID AllocMutexID()

Parameters

None

Returns

Mutex ID. Each ID indicates a mutex lock. The type is defined as follows:

1
using MutexID = uint8_t;

Constraints

The number of mutex IDs is limited. After using a mutex ID, call ReleaseMutexID immediately to release it, preventing mutex ID exhaustion.

Example

1
2
3
4
5
6
7
8
MutexID id = AllocMutexID();
Mutex::Lock<PIPE_MTE2>(id);
DataCopy(local, gm, 1024);
Mutex::Unlock<<PIPE_MTE2>(id);
Mutex::Lock<PIPE_V>(id);
Adds(local, local, 1, 1024);
Mutex::Unlock<PIPE_V>(id);
ReleaseMutexID(id);