@@ -1363,8 +1363,53 @@ flagcxResult_t flagcxAlltoAllv(const void *sendbuff, size_t *sendcounts,
13631363 comm->homo_comm , stream);
13641364 } else {
13651365 if (use_host_comm ()) {
1366- // TODO: to be implemented
1367- return flagcxNotSupported;
1366+ uint64_t timers[TIMERS_COLL_COUNT ] = {0 };
1367+ timers[TIMER_COLL_TOTAL ] = clockNano ();
1368+ void *buff_in;
1369+ void *buff_out;
1370+
1371+ // Calculate max possible size needed for send and receive buffers
1372+ size_t max_send_size = 0 , max_recv_size = 0 , send_size = 0 , recv_size = 0 ;
1373+ for (int i = 0 ; i < comm->nranks ; i++) {
1374+ send_size = (sendcounts[i] + sdispls[i]) * getFlagcxDataTypeSize (datatype);
1375+ recv_size = (recvcounts[i] + rdispls[i]) * getFlagcxDataTypeSize (datatype);
1376+ if (send_size > max_send_size) max_send_size = send_size;
1377+ if (recv_size > max_recv_size) max_recv_size = recv_size;
1378+ }
1379+ timers[TIMER_COLL_ALLOC ] = clockNano ();
1380+ deviceAdaptor->deviceMalloc (&buff_in, max_send_size, flagcxMemHost, NULL );
1381+ deviceAdaptor->deviceMalloc (&buff_out, max_recv_size, flagcxMemHost, NULL );
1382+ timers[TIMER_COLL_ALLOC ] = clockNano () - timers[TIMER_COLL_ALLOC ];
1383+
1384+ timers[TIMER_COLL_MEM_D2H ] = clockNano ();
1385+ deviceAdaptor->deviceMemcpy (buff_in, const_cast <void *>(sendbuff), max_send_size,
1386+ flagcxMemcpyDeviceToHost, NULL , NULL );
1387+ timers[TIMER_COLL_MEM_D2H ] = clockNano () - timers[TIMER_COLL_MEM_D2H ];
1388+
1389+ timers[TIMER_COLL_COMM ] = clockNano ();
1390+ cclAdaptors[flagcxCCLAdaptorHost]->alltoAllv (
1391+ buff_in, sendcounts, sdispls, buff_out, recvcounts, rdispls, datatype,
1392+ comm->host_comm , NULL );
1393+ timers[TIMER_COLL_COMM ] = clockNano () - timers[TIMER_COLL_COMM ];
1394+
1395+ timers[TIMER_COLL_MEM_H2D ] = clockNano ();
1396+ deviceAdaptor->deviceMemcpy (recvbuff, buff_out, max_recv_size,
1397+ flagcxMemcpyHostToDevice, NULL , NULL );
1398+ timers[TIMER_COLL_MEM_H2D ] = clockNano () - timers[TIMER_COLL_MEM_H2D ];
1399+
1400+ timers[TIMER_COLL_FREE ] = clockNano ();
1401+ deviceAdaptor->deviceFree (buff_in, flagcxMemHost, NULL );
1402+ deviceAdaptor->deviceFree (buff_out, flagcxMemHost, NULL );
1403+ timers[TIMER_COLL_FREE ] = clockNano () - timers[TIMER_COLL_FREE ];
1404+
1405+ timers[TIMER_COLL_TOTAL ] = clockNano () - timers[TIMER_COLL_TOTAL ];
1406+ INFO (FLAGCX_COLL ,
1407+ " Flagcx timings - %s AlltoAllv: rank %d nranks %d total %.2fms "
1408+ " (memory alloc %.2fms, memory free %.2fms, memory d2h %.2fms, memory h2d %.2fms, comm %.2fms)" ,
1409+ cclAdaptors[flagcxCCLAdaptorHost]->name , comm->rank , comm->nranks ,
1410+ timers[TIMER_COLL_TOTAL ] / 1e6 , timers[TIMER_COLL_ALLOC ] / 1e6 ,
1411+ timers[TIMER_COLL_FREE ] / 1e6 , timers[TIMER_COLL_MEM_D2H ] / 1e6 ,
1412+ timers[TIMER_COLL_MEM_H2D ] / 1e6 , timers[TIMER_COLL_COMM ] / 1e6 );
13681413 } else {
13691414 // Move it into flagcxC2cPlanner workflow
13701415 flagcxC2cPlanner planner;
0 commit comments