HcommThreadAlloc

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product

x

Atlas training product

x

Function

Allocates communication threads. Currently, the AICPU+TS, host CPU+TS, and CCU communication engines are supported. For the AICPU+TS communication engine, the allocated communication threads can be used on the AICPU only after an additional kernel is delivered.

Prototype

1
HcommResult HcommThreadAlloc(CommEngine engine, uint32_t threadNum, uint32_t notifyNumPerThread, ThreadHandle* threads)

Parameters

Parameter

Input/Output

Description

engine

Input

Communication engine type.

For details, see CommEngine.

threadNum

Input

Number of communication threads. A maximum of 1,000 threads can be allocated each time this API is called.

notifyNumPerThread

Input

Number of synchronization resources (Notify) in each communication thread. A maximum of 64 Notifies per communication thread can be allocated each time this API is called.

threads

Output

Returned communication thread handles. An array of the ThreadHandle type with a size of threadNum needs to be passed.

For details, see ThreadHandle.

Returns

HcommResult: 0 on success; else, failure.

Restrictions

The thread allocated by this API call needs to be freed by HcommThreadFree. Before calling HcommThreadAlloc to allocate threads of the communication engine such as AICPU_TS or CPU_TS, you must call aclrtSetdevice to specify the device ID in the same thread.

Example

1
2
3
ThreadHandle thread[3];
// Allocate two streams, each with three Notifies.
HcommResult ret =  HcommThreadAlloc(COMM_ENGINE_AICPU_TS, 2, 3, thread);