HcommThreadNotifyWaitOnThread

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

For Atlas A2 training product/Atlas A2 inference product, only the Atlas 800T A2 training server, Atlas 900 A2 PoD cluster basic unit, and Atlas 200T A2 Box16 heterogeneous subrack are supported.

Function

Waits for a synchronization signal. This API blocks and waits for the thread execution until the specified Notify is recorded.

Prototype

1
int32_t HcommThreadNotifyWaitOnThread(ThreadHandle thread, uint32_t notifyIdx, uint32_t timeout)

Parameters

Parameter

Input/Output

Description

thread

Input

Thread handle, which is threads returned by the HcclThreadAcquire call.

For details, see ThreadHandle.

notifyIdx

Input

Index of the Notify to be waited.

The value range is [0, notifyNumPerThread passed to the HcclThreadAcquire call].

timeout

Input

Timeout interval, in milliseconds.
  • 0: waits forever.
  • > 0: specific timeout interval.

Note: For the Atlas 350 Accelerator Card, the custom timeout function is not supported. The timeout interval is fixed at 1,080,000 ms.

Returns

int32_t: 0 on success; else, failure.

Restrictions

This API must be used in pair with HcommThreadNotifyRecordOnThread.

For the Atlas 350 Accelerator Card, this API can be called only on the device in AICPU_TS mode.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
HcclComm comm;
CommEngine engine = COMM_ENGINE_CPU_TS;
aclrtStream streams[2];
ThreadHandle threads[2];
// Allocate two streams, each with two Notify resources.
aclrtCreateStream(&streams[0]);
aclrtCreateStream(&streams[1]);
HcclResult result = HcclThreadAcquireWithStream(comm, engine, streams[0], 2, &threads[0]);
result = HcclThreadAcquireWithStream(comm, engine, streams[1], 2, &threads[1]);
uint32_t notifyIdx = 0;
// Send a synchronization signal.
HcommThreadNotifyRecordOnThread(threads[0], threads[1], notifyIdx);
uint32_t timeout = 1;
// Wait for a synchronization signal.
HcommThreadNotifyWaitOnThread(threads[1], notifyIdx, timeout);

On the Atlas 350 Accelerator Card, this function needs to be compiled and used on the device.

HcclComm comm;
CommEngine engine = COMM_ENGINE_AICPU_TS;
ThreadHandle threads[2];
uint32_t notifyNumPerThread = 2;
HcclThreadAcquire(comm, engine, 1, notifyNumPerThread, &threads[0]);
HcclThreadAcquire(comm, engine, 1, notifyNumPerThread, &threads[1]);

// Allocate other resources.
// Copy parameters and launch the kernel.

// Orchestrate algorithms on the device.
uint32_t notifyIdx = 0;
// Send a synchronization signal.
HcommThreadNotifyRecordOnThread(threads[0], threads[1], notifyIdx);
uint32_t timeout = 1;
// Wait for a synchronization signal.
HcommThreadNotifyWaitOnThread(threads[1], notifyIdx, timeout);