Example
The following provides simplified code snippets of the process, highlighting the key steps and sequence (excluding detailed error handling and platform initialization code).
// --- Server (pseudo-code) ---
HixlServerHandle server = NULL;
HixlServerDesc sdesc = {"0.0.0.0", 12345, &endpoint, 1};
HixlCSServerCreate(&sdesc, NULL, &server);
// Allocate and initialize the server memory (host or device). CommMem server_mem = { .addr = server_buf, .size = size, .type = COMM_MEM_TYPE_DEVICE };
MemHandle server_mem_h = NULL;
HixlCSServerRegMem(server, "server_mem", &server_mem, &server_mem_h);
HixlCSServerListen(server, 1024);
// Wait until the client initiates and completes the transmission (synchronization can be performed using TCP signaling).
// Deregister and destroy the memory.
HixlCSServerUnregMem(server, server_mem_h);
HixlCSServerDestroy(server);
// --- Client (pseudo-code) ---
HixlClientHandle client = NULL;
HixlClientDesc cdesc = {"server.ip", 12345, &local_ep, &remote_ep};
HixlCSClientCreate(&cdesc, NULL, &client);
// Allocate and register the local memory. CommMem client_mem = { .addr = client_buf, .size = size, .type = COMM_MEM_TYPE_DEVICE };
MemHandle client_mem_h = NULL;
HixlCSClientRegMem(client, "client_mem", &client_mem, &client_mem_h);
// Establish a link.
HixlCSClientConnect(client, 5000);
// Obtain the remote memory address (using mem_tag). CommMem *remote_list = NULL; char **tags = NULL; uint32_t num = 0;
HixlCSClientGetRemoteMem(client, &remote_list, &tags, &num, 2000);
// Construct the batch operation description. Example: varying block size.
std::vector<HixlOneSideOpDesc> ops = ...; // Fill in the local/remote address and length.
CompleteHandle ch;
HixlCSClientBatchPutAsync(client, ops.size(), ops.data(), &ch);
// Query until the operation is complete.
HixlCompleteStatus st;
do {
HixlCSClientQueryCompleteStatus(client, ch, &st);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
} while (st == HIXL_COMPLETE_STATUS_WAITING);
// Clean up.
HixlCSClientUnregMem(client, client_mem_h);
HixlCSClientDestroy(client);Parent topic: HIXL CS APIs