HcommReadOnThread

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

Reads data from the specified memory on a channel. It reads memory data of length len from src and writes it into dst. The API caller is the node where dst resides. This API is asynchronous.

Prototype

1
int32_t HcommReadOnThread(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.
uint32_t channelNum = 1;
HcclChannelDesc channelDesc;
HcclChannelDescInit(&channelDesc, channelNum);
HcclComm comm;
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);

// Read the content of the remote memory to the local memory.
HcommReadOnThread(thread, channel, localBuffer, remoteBuffer, len);