HcommWriteOnThread
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
x |
|
x |
For
Function
Writes data to the specified memory on a channel. It writes memory data of length len from src into the memory of the same length pointed to by dst. The API caller is the node where src resides. This API is asynchronous.
Prototype
1 | int32_t HcommWriteOnThread(ThreadHandle thread, ChannelHandle channel, void *dst, const void *src, uint64_t len) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
thread |
Input |
Communication thread handle, which is threads returned by the HcclThreadAcquire call. For details, see ThreadHandle. |
channel |
Input |
Communication channel handle, which is channels returned by the HcclChannelAcquire call. For details, see ChannelHandle. |
dst |
Output |
Destination memory address, which is obtained using HcclGetHcclBuffer or HcclChannelGetHcclBuffer. |
src |
Input |
Source memory address, which is obtained using HcclGetHcclBuffer or HcclChannelGetHcclBuffer. |
len |
Input |
Data length (in bytes). |
Returns
int32_t: 0 on success; else, failure.
Restrictions
None
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | // Allocate communication threads. CommEngine engine = CommEngine::COMM_ENGINE_CPU_TS; // Used by the Atlas A3 training product/Atlas A3 inference product CommEngine engine = CommEngine::COMM_ENGINE_AICPU_TS; // Used by the Atlas 350 Accelerator Card uint32_t threadNum = 1; uint32_t notifyNumPerThread = 1; ThreadHandle thread; HcclThreadAcquire(engine, threadNum, notifyNumPerThread, &thread); // Allocate communication channels. HcclChannelDesc channelDesc; HcclChannelDescInit(&channelDesc, channelNum); HcclComm comm; uint32_t channelNum = 1; ChannelHandle channel; HcclChannelAcquire(comm, engine, &channelDesc, channelNum, &channel); // Obtain the local communication memory information. void * localBuffer; uint64_t localBufferSize; HcclGetHcclBuffer(comm, &localBuffer, &localBufferSize); // Obtain the remote communication memory information. void * remoteBuffer; uint64_t remoteBufferSize; HcclChannelGetHcclBuffer(comm, channel, &remoteBuffer, &remoteBufferSize); uint64_t len = std::min(localBufferSize, remoteBufferSize); // Write the content in the local memory to the remote memory. HcommWriteOnThread(thread, channel, remoteBuffer, localBuffer, len); |