| 44 | } |
| 45 | |
| 46 | void ClientEndpoint::Replay() { |
| 47 | auto start_replay = std::chrono::high_resolution_clock::now(); |
| 48 | tool::Logging(LOG_INFO, myName_, "start replaying %zu requests from registerIOVList\n", regIOVList.size()); |
| 49 | SendRegisterRequest(this, true); |
| 50 | |
| 51 | // std::ofstream outFile2("api_records_replay.log", std::ios::out); |
| 52 | tool::Logging(LOG_INFO, myName_, "start replaying %zu requests from requestIOVList\n", reqIOVList.size()); |
| 53 | for (auto it = reqIOVList.begin(); it != reqIOVList.end(); ++it) { |
| 54 | RequestIOV* tmpReqIOV = &(*it); |
| 55 | // outFile2 << tmpReqIOV->GetRequestType() << std::endl; |
| 56 | |
| 57 | if (tmpReqIOV->GetRequestType() == NCCL_GET_UNIQUE_ID) { |
| 58 | ncclUniqueId uniqueId; |
| 59 | RequestIOV resBuf = RequestIOV(); |
| 60 | resBuf.Push(uniqueId); |
| 61 | SendRequestRecvResponse(tmpReqIOV, &resBuf, true, false); |
| 62 | #ifdef GV_GPUMAP |
| 63 | gpuIdMap->UpdateUniqueID((uint8_t*)&uniqueId, sizeof(ncclUniqueId)); |
| 64 | tool::Logging(LOG_INFO, myName_, "[pid:%d, tid:%d] updated uniqueId\n", _processID, _threadID); |
| 65 | #else |
| 66 | tool::Logging(LOG_ERROR, myName_, "Replaying for ncclGetUniqueId is not supported in non-GV_GPUMAP mode\n"); |
| 67 | exit(EXIT_FAILURE); |
| 68 | #endif // GV_GPUMAP |
| 69 | continue; |
| 70 | } |
| 71 | else if (tmpReqIOV->GetRequestType() == NCCL_COMM_INIT_RANK |
| 72 | || tmpReqIOV->GetRequestType() == NCCL_COMM_INIT_RANK_CONFIG) { |
| 73 | ncclUniqueId uniqueId; |
| 74 | #ifdef GV_GPUMAP |
| 75 | gpuIdMap->RequestUniqueID((uint8_t*)&uniqueId, sizeof(ncclUniqueId)); |
| 76 | tmpReqIOV->SetElement(2, &uniqueId, sizeof(ncclUniqueId)); |
| 77 | SendRequest(tmpReqIOV, true, false); |
| 78 | tool::Logging(LOG_INFO, myName_, "[pid:%d, tid:%d] requested uniqueId\n", _processID, _threadID); |
| 79 | #else |
| 80 | tool::Logging(LOG_ERROR, myName_, "Replaying for ncclCommInitRank is not supported in non-GV_GPUMAP mode\n"); |
| 81 | exit(EXIT_FAILURE); |
| 82 | #endif // GV_GPUMAP |
| 83 | } |
| 84 | else if (tmpReqIOV->GetRequestType() == CUDA_MEMCPY_ASYNC_H2D) { |
| 85 | SendRequestH2D(tmpReqIOV, (uint8_t*)tmpReqIOV->GetHeaders(), sizeof(cudaMemcpyKind)+sizeof(size_t)+sizeof(uint64_t)+sizeof(uint8_t)+sizeof(uint64_t), false, false); |
| 86 | } |
| 87 | else if (tmpReqIOV->GetRequestType() == CUDA_STREAM_SYNCHRONIZE || tmpReqIOV->GetRequestType() == NCCL_COMM_GET_ASYNC_ERROR) { |
| 88 | int result = 0; |
| 89 | RequestIOV resBuf = RequestIOV(); |
| 90 | resBuf.Push(&result); |
| 91 | SendRequestRecvResponse(tmpReqIOV, &resBuf, true, false); |
| 92 | } |
| 93 | else { |
| 94 | SendRequest(tmpReqIOV, true, false); |
| 95 | } |
| 96 | } |
| 97 | // outFile2.close(); |
| 98 | |
| 99 | // eval for replay time |
| 100 | size_t free = 0; |
| 101 | size_t total = 0; |
| 102 | int replayFinished = 1; |
| 103 | RequestIOV reqBuf = RequestIOV(); |
nothing calls this directly
no test coverage detected