HcommThreadNotifyRecordOnThread
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
x |
|
x |
For
Function
Sends a synchronization signal to other threads, which is primarily used for synchronization between multiple threads.
Prototype
1 | int32_t HcommThreadNotifyRecordOnThread(ThreadHandle thread, ThreadHandle dstThread, uint32_t dstNotifyIdx) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
thread |
Input |
Communication thread handle, which is threads returned by the HcclThreadAcquire call. For details, see ThreadHandle. |
dstThread |
Input |
Destination communication thread handle, which is threads returned by the HcclThreadAcquire call. For details, see ThreadHandle. |
dstNotifyIdx |
Input |
Destination Notify index. The value range is [0, notifyNumPerThread passed to the HcclThreadAcquire call]. |
Returns
int32_t: 0 on success; else, failure.
Restrictions
This API must be used in pair with HcommThreadNotifyWaitOnThread.
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);