MCPcopy Create free account
hub / github.com/ModelEngine-Group/flexai / ReceiveData

Function ReceiveData

GPU-Virtual-Service/gpu-remoting/include/ucpUtil.h:283–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283static ucs_status_t ReceiveData(ucp_dt_iov_t* iov, size_t* iovCnt, void* dataBuffer, uint64_t amID, ucp_worker_h* dataWorker, ucs_memory_type_t memType, bool* isClosed) {
284 // iovCnt is set by ActiveMessageRecvCallback
285 const char* myName = "ReceiveData";
286 ucs_status_t status = UCS_OK;
287 ActiveMessageDesc_t am_request_ctx = { .complete = 0, .is_rndv = 0, .mem_type = memType, .desc = NULL,
288 .iov = iov, .iov_num = 0, .recv_buf = dataBuffer, .recv_length = 0};
289 Request_t recv_request_ctx = {.type = 1, .complete = 0};
290
291 ucp_am_handler_param_t param1;
292 param1.field_mask = UCP_AM_HANDLER_PARAM_FIELD_ID |
293 UCP_AM_HANDLER_PARAM_FIELD_CB |
294 UCP_AM_HANDLER_PARAM_FIELD_ARG;
295 param1.id = amID; // todo: TEST_AM_ID
296 param1.cb = ActiveMessageRecvCallback;
297 param1.arg = &am_request_ctx;
298 status = ucp_worker_set_am_recv_handler(*dataWorker, &param1);
299 if (status != UCS_OK) {
300 tool::Logging(LOG_ERROR, myName, "failed to set am handler.\n");
301 return status;
302 }
303
304 tool::Logging(LOG_COMM, myName, "waiting for the client to send a message.\n");
305 while (!am_request_ctx.complete) { // waiting ActiveMessageRecvCallback() to be invoked
306 if (isClosed != NULL && *isClosed) {
307 tool::Logging(LOG_ERROR, myName, "the connection has been closed.\n");
308 return UCS_ERR_CONNECTION_RESET;
309 }
310 ucp_worker_progress(*dataWorker);
311 }
312
313 *iovCnt = am_request_ctx.iov_num;
314 size_t msg_length = am_request_ctx.recv_length;
315 if (!am_request_ctx.is_rndv) {
316 tool::Logging(LOG_COMM, myName, "Eager request has arrived\n");
317 }
318 else {
319 tool::Logging(LOG_COMM, myName, "Rendezvous request has arrived\n");
320
321 ucp_request_param_t param2;
322 param2.op_attr_mask = UCP_OP_ATTR_FIELD_CALLBACK |
323 UCP_OP_ATTR_FIELD_DATATYPE |
324 UCP_OP_ATTR_FIELD_USER_DATA|
325 UCP_OP_ATTR_FIELD_MEMORY_TYPE;
326 param2.op_attr_mask |= UCP_OP_ATTR_FLAG_NO_IMM_CMPL;
327 // param2.datatype = (*iovCnt == 1) ? ucp_dt_make_contig(1) : UCP_DATATYPE_IOV;
328 param2.datatype = ucp_dt_make_contig(1);
329 param2.user_data = &recv_request_ctx;
330 param2.cb.recv_am = (ucp_am_recv_data_nbx_callback_t)RecvCallBack;
331 param2.memory_type = memType;
332 Request_t* rndv_request = (Request_t*)ucp_am_recv_data_nbx(*dataWorker,
333 am_request_ctx.desc,
334 am_request_ctx.recv_buf, am_request_ctx.recv_length, //recv data
335 &param2);
336
337 status = Wait(rndv_request, &recv_request_ctx, dataWorker);
338 if (status != UCS_OK) {
339 tool::Logging(LOG_ERROR, myName, "ucp_am_recv_data_nbx failed: %s\n", ucs_status_string(status));
340 }

Callers

nothing calls this directly

Calls 2

LoggingFunction · 0.85
WaitFunction · 0.85

Tested by

no test coverage detected