LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/resource/stream - stream.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 85.9 % 327 281
Test Date: 2026-08-18 17:47:01 Functions: 82.6 % 23 19

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #include "adapter_rts.h"
      12              : #include "adapter_error_manager.h"
      13              : #include "sal.h"
      14              : #include "stream_pub.h"
      15              : 
      16              : namespace hccl {
      17              : // 默认构造函数只产生无效的Stream对象
      18         6044 : Stream::Stream()
      19         6044 :     : stream_(nullptr),
      20         6044 :       device_id_(HCCL_DEVICE_NOT_SET),
      21         6044 :       stream_owner_(false),
      22         6049 :       streamId_(0),
      23         6049 :       isMainStream_(true),
      24         6049 :       modeGotFlag_(false),
      25         6049 :       streamMode_(0),
      26         6049 :       sqId_(0),
      27         6049 :       ctx_(nullptr),
      28         6049 :       cqId_(0),
      29         6044 :       logicCqid_(0)
      30         6051 : {}
      31              : 
      32         2321 : Stream::Stream(const Stream& that)
      33         4641 :     : stream_(that.ptr()),
      34         2320 :       device_id_(that.device_id_),
      35         2320 :       stream_owner_(false),
      36         2322 :       streamId_(that.streamId_),
      37         2322 :       isMainStream_(that.isMainStream_),
      38         2322 :       modeGotFlag_(that.modeGotFlag_),
      39         2322 :       streamMode_(that.streamMode_),
      40         2322 :       sqId_(that.sqId_),
      41         2322 :       ctx_(that.ctx_),
      42         2322 :       cqId_(that.cqId_),
      43         2322 :       logicCqid_(that.logicCqid_),
      44         2322 :       sqeContext_(that.sqeContext_),
      45         2322 :       cqeContext_(that.cqeContext_),
      46         2322 :       streamInfo_(that.streamInfo_),
      47         2321 :       invalidFlag_(that.invalidFlag_)
      48         2327 : {} // 共享销毁标志, 副本与owner持有同一份
      49              : 
      50          593 : Stream::Stream(Stream&& that)
      51         1186 :     : stream_(that.ptr()),
      52          593 :       device_id_(that.device_id_),
      53          593 :       stream_owner_(that.stream_owner_),
      54          593 :       streamId_(that.streamId_),
      55          593 :       isMainStream_(that.isMainStream_),
      56          593 :       modeGotFlag_(that.modeGotFlag_),
      57          593 :       streamMode_(that.streamMode_),
      58          593 :       sqId_(that.sqId_),
      59          593 :       ctx_(that.ctx_),
      60          593 :       cqId_(that.cqId_),
      61          593 :       logicCqid_(that.logicCqid_),
      62          593 :       sqeContext_(that.sqeContext_),
      63          593 :       cqeContext_(that.cqeContext_),
      64          593 :       streamInfo_(that.streamInfo_),
      65          593 :       invalidFlag_(std::move(that.invalidFlag_)) // 转移销毁标志所有权, 源置空避免源析构影响
      66              : {
      67          593 :     that.stream_ = nullptr;
      68          593 :     that.device_id_ = HCCL_DEVICE_NOT_SET;
      69          593 :     that.stream_owner_ = false;
      70          593 :     that.streamId_ = 0;
      71          593 :     that.isMainStream_ = true;
      72          593 :     that.modeGotFlag_ = false;
      73          593 :     that.streamMode_ = 0;
      74          593 :     that.sqId_ = 0;
      75          593 :     that.cqId_ = 0;
      76          593 :     that.logicCqid_ = 0;
      77          593 :     that.sqeContext_ = nullptr;
      78          593 :     that.cqeContext_ = nullptr;
      79          593 :     that.streamInfo_.actualStreamId = 0;
      80          593 :     that.streamInfo_.logicCqId = 0;
      81          593 :     that.streamInfo_.sqBaseAddr = nullptr;
      82          593 :     that.streamInfo_.sqDepth = 0;
      83          593 :     that.streamInfo_.sqId = 0;
      84          593 : }
      85              : 
      86          697 : Stream::Stream(const StreamType streamType, bool isMainStream)
      87          697 :     : stream_(nullptr),
      88          697 :       device_id_(HCCL_DEVICE_NOT_SET),
      89          697 :       stream_owner_(true),
      90          696 :       streamId_(0),
      91          696 :       isMainStream_(isMainStream),
      92          696 :       modeGotFlag_(false),
      93          696 :       streamMode_(0),
      94          696 :       sqId_(0),
      95          696 :       ctx_(nullptr),
      96          696 :       cqId_(0),
      97          697 :       logicCqid_(0)
      98              : {
      99              :     HcclResult ret;
     100          694 :     aclrtStream rtStream = nullptr;
     101              : 
     102              :     // 申请rtStream
     103          694 :     if (streamType == StreamType::STREAM_TYPE_ONLINE) {
     104          293 :         ret = hrtStreamCreateWithFlags(
     105              :             &rtStream, HCCL_STREAM_PRIORITY_HIGH, ACL_STREAM_FAST_LAUNCH | ACL_STREAM_FAST_SYNC);
     106          401 :     } else if (streamType == StreamType::STREAM_TYPE_DEVICE) {
     107          278 :         ret = hrtStreamCreateWithFlags(&rtStream, HCCL_STREAM_PRIORITY_HIGH, ACL_STREAM_DEVICE_USE_ONLY);
     108              :     } else {
     109          123 :         ret = hrtStreamCreateWithFlags(&rtStream, HCCL_STREAM_PRIORITY_LOW, ACL_STREAM_PERSISTENT);
     110              :     }
     111              : 
     112          700 :     if (ret == HCCL_SUCCESS) {
     113          695 :         HCCL_DEBUG("rtStreamCreate ok, streamType[%d]", streamType);
     114          695 :         stream_ = const_cast<void*>(rtStream);
     115          695 :         InitStream();
     116          695 :         HCCL_INFO(
     117              :             "Construct stream by stream type success, ptr[%p] ctx[%p], stream id[%d], cqId[%d], logicCqid[%d]",
     118              :             rtStream, ctx_, streamId_, cqId_, logicCqid_);
     119              :     } else {
     120           55 :         RPT_ENV_ERR(
     121              :             true, "EI0007", std::vector<std::string>({"resource_type", "resource_info"}),
     122              :             std::vector<std::string>(
     123              :                 {"stream", std::string("StreamCreateWithFlags, streamType:") + std::to_string(uint32_t(streamType))}));
     124            5 :         HCCL_ERROR(
     125              :             "[%s][%s]Construct stream by stream type failed, errNo[0x%016llx] rtStreamCreate error, ret[%d]",
     126              :             LOG_KEYWORDS_INIT_GROUP.c_str(), LOG_KEYWORDS_RESOURCE.c_str(), HCCL_ERROR_CODE(HCCL_E_RUNTIME), ret);
     127              :     }
     128          700 :     bool isSupportV2 = false;
     129          700 :     CHK_PRT_CONT(hrtGetHcclV2Support(&isSupportV2), HCCL_WARNING("[Stream] Can not check hccl version"));
     130          700 :     if (isSupportV2 && streamType == StreamType::STREAM_TYPE_ONLINE) {
     131           81 :         HcclResult setModeRet = hrtStreamSetMode(stream_, STREAM_MODE_STOP_ON_FAILURE);
     132           81 :         if (setModeRet != HCCL_SUCCESS) {
     133            0 :             HCCL_ERROR(
     134              :                 "[Stream][SetMode]Failed to set stream mode, errNo[0x%016llx], ret[%d], stream id[%d]",
     135              :                 HCCL_ERROR_CODE(setModeRet), setModeRet, streamId_);
     136              :         }
     137              :     }
     138          715 : }
     139              : 
     140          474 : Stream::Stream(const rtStream_t rtStream, bool isMainStream)
     141          474 :     : stream_(const_cast<void*>(rtStream)),
     142          474 :       device_id_(HCCL_DEVICE_NOT_SET),
     143          474 :       stream_owner_(false),
     144          424 :       streamId_(0),
     145          424 :       isMainStream_(isMainStream),
     146          424 :       modeGotFlag_(false),
     147          424 :       streamMode_(0),
     148          424 :       sqId_(0),
     149          424 :       ctx_(nullptr),
     150          424 :       cqId_(0),
     151          474 :       logicCqid_(0)
     152              : {
     153          423 :     InitStream();
     154          474 : }
     155              : 
     156          500 : Stream::Stream(const HcclComStreamInfo& streamInfo, bool isMainStream)
     157          500 :     : stream_(static_cast<void*>(streamInfo.sqBaseAddr)),
     158          500 :       device_id_(HCCL_DEVICE_NOT_SET),
     159          500 :       stream_owner_(false),
     160          500 :       streamId_(streamInfo.actualStreamId),
     161          500 :       isMainStream_(isMainStream),
     162          500 :       modeGotFlag_(false),
     163          500 :       streamMode_(0),
     164          500 :       sqId_(streamInfo.sqId),
     165          500 :       ctx_(nullptr)
     166              : {
     167          500 :     SetStreamInfo(streamInfo);
     168          500 : }
     169              : 
     170        10850 : Stream::~Stream() { DestroyStream(); }
     171              : 
     172          431 : Stream& Stream::operator=(const Stream& that)
     173              : {
     174          431 :     if (&that != this) {
     175          431 :         stream_ = that.ptr();
     176          429 :         device_id_ = that.device_id_;
     177          429 :         stream_owner_ = false;
     178          429 :         taskLogicInfo_ = that.taskLogicInfo_;
     179          406 :         streamId_ = that.streamId_;
     180          406 :         isMainStream_ = that.isMainStream_;
     181          406 :         modeGotFlag_ = that.modeGotFlag_;
     182          406 :         streamMode_ = that.streamMode_;
     183          406 :         sqId_ = that.sqId_;
     184          406 :         ctx_ = that.ctx_;
     185          406 :         cqId_ = that.cqId_;
     186          406 :         logicCqid_ = that.logicCqid_;
     187          406 :         sqeContext_ = that.sqeContext_;
     188          406 :         cqeContext_ = that.cqeContext_;
     189          406 :         streamInfo_.actualStreamId = that.streamInfo_.actualStreamId;
     190          406 :         streamInfo_.logicCqId = that.streamInfo_.logicCqId;
     191          406 :         streamInfo_.sqBaseAddr = that.streamInfo_.sqBaseAddr;
     192          406 :         streamInfo_.sqDepth = that.streamInfo_.sqDepth;
     193          406 :         streamInfo_.sqId = that.streamInfo_.sqId;
     194          406 :         invalidFlag_ = that.invalidFlag_; // 共享销毁标志, 副本与owner持有同一份
     195              :     }
     196          413 :     return *this;
     197              : }
     198              : 
     199          582 : Stream Stream::operator=(Stream&& that)
     200              : {
     201          582 :     if (&that != this) {
     202          582 :         stream_ = that.stream_;
     203          582 :         device_id_ = that.device_id_;
     204          582 :         stream_owner_ = that.stream_owner_;
     205          582 :         taskLogicInfo_ = that.taskLogicInfo_;
     206          582 :         streamId_ = that.streamId_;
     207          582 :         isMainStream_ = that.isMainStream_;
     208          582 :         modeGotFlag_ = that.modeGotFlag_;
     209          582 :         streamMode_ = that.streamMode_;
     210          582 :         sqId_ = that.sqId_;
     211          582 :         ctx_ = that.ctx_;
     212          582 :         cqId_ = that.cqId_;
     213          582 :         logicCqid_ = that.logicCqid_;
     214          582 :         sqeContext_ = that.sqeContext_;
     215          582 :         cqeContext_ = that.cqeContext_;
     216          582 :         streamInfo_.actualStreamId = that.streamInfo_.actualStreamId;
     217          582 :         streamInfo_.logicCqId = that.streamInfo_.logicCqId;
     218          582 :         streamInfo_.sqBaseAddr = that.streamInfo_.sqBaseAddr;
     219          582 :         streamInfo_.sqDepth = that.streamInfo_.sqDepth;
     220          582 :         streamInfo_.sqId = that.streamInfo_.sqId;
     221          582 :         invalidFlag_ = std::move(that.invalidFlag_); // 转移销毁标志所有权
     222              :     }
     223              : 
     224          582 :     that.stream_ = nullptr;
     225          582 :     that.device_id_ = HCCL_DEVICE_NOT_SET;
     226          582 :     that.stream_owner_ = false;
     227          582 :     that.taskLogicInfo_ = taskLogicInfo_;
     228          582 :     that.streamId_ = 0;
     229          582 :     that.isMainStream_ = isMainStream_;
     230          582 :     that.modeGotFlag_ = modeGotFlag_;
     231          582 :     that.streamMode_ = streamMode_;
     232          582 :     that.sqId_ = sqId_;
     233          582 :     that.ctx_ = ctx_;
     234          582 :     that.cqId_ = cqId_;
     235          582 :     that.logicCqid_ = logicCqid_;
     236          582 :     that.sqeContext_ = nullptr;
     237          582 :     that.cqeContext_ = nullptr;
     238          582 :     that.streamInfo_.actualStreamId = streamInfo_.actualStreamId;
     239          582 :     that.streamInfo_.logicCqId = streamInfo_.logicCqId;
     240          582 :     that.streamInfo_.sqBaseAddr = nullptr;
     241          582 :     that.streamInfo_.sqDepth = streamInfo_.sqDepth;
     242          582 :     that.streamInfo_.sqId = streamInfo_.sqId;
     243          582 :     return *this;
     244              : }
     245              : 
     246        10624 : void Stream::DestroyStream()
     247              : {
     248              :     // owner销毁stream前先标记invalid, 让持有副本的dispatcher能感知并跳过, 避免访问悬空的sqeContext_
     249              :     // 必须在hrtStreamDestroy之前置位, 确保并发遍历streamMap_的线程在此期间读到true
     250        10624 :     if (invalidFlag_ != nullptr) {
     251         9446 :         invalidFlag_->store(true, std::memory_order_relaxed);
     252              :     }
     253              :     // 销毁stream
     254        10666 :     if (stream_owner_ && stream_ != nullptr) {
     255              :         // stream需要在原ctx上销毁
     256          686 :         aclrtContext ctxTmp = nullptr;
     257          686 :         HcclResult ret = hrtCtxGetCurrent(&ctxTmp);
     258          686 :         bool needChangeCtx = (ret == HCCL_SUCCESS && ctx_ != nullptr);
     259          686 :         if (needChangeCtx) {
     260          684 :             ret = hrtCtxSetCurrent(ctx_);
     261          684 :             HCCL_INFO("Switch Ctx ret[%d], curCtx[%p], setCtx[%p], stream id[%d]", ret, ctxTmp, ctx_, streamId_);
     262              :         }
     263          686 :         ret = hrtStreamDestroy(stream_);
     264          686 :         HCCL_RUN_INFO("[HCCL_TRACE]StreamDestroy, streamPtr[%p], stream id[%d]", stream_, streamId_);
     265          686 :         if (ret != HCCL_SUCCESS) {
     266            0 :             HCCL_WARNING("errNo[0x%016llx] hrtStreamDestroy error, ret[%d]", HCCL_ERROR_CODE(HCCL_E_RUNTIME), ret);
     267              :         }
     268          686 :         if (needChangeCtx) {
     269          684 :             ret = hrtCtxSetCurrent(ctxTmp);
     270          684 :             HCCL_INFO("Restore Ctx ret[%d], setCtx[%p], stream id[%d]", ret, ctxTmp, streamId_);
     271              :         }
     272              :     }
     273        10666 : }
     274              : 
     275            2 : void Stream::SetEmpty()
     276              : {
     277            2 :     DestroyStream();
     278            2 :     stream_ = nullptr;
     279            2 :     device_id_ = HCCL_DEVICE_NOT_SET;
     280            2 :     stream_owner_ = false;
     281            2 :     streamId_ = 0;
     282            2 :     isMainStream_ = true;
     283            2 :     sqId_ = 0;
     284            2 :     ctx_ = nullptr;
     285            2 :     cqId_ = 0;
     286            2 :     logicCqid_ = 0;
     287            2 : }
     288              : 
     289         1118 : HcclResult Stream::InitStream()
     290              : {
     291         1118 :     if (stream_ != nullptr) {
     292         1118 :         HcclResult ret = hrtGetStreamId(stream_, streamId_);
     293         1170 :         if (ret != HCCL_SUCCESS) {
     294            0 :             SetEmpty();
     295            0 :             HCCL_ERROR(
     296              :                 "[InitStream]Failed to get the streamId through the rtstream, errNo[0x%016llx]"
     297              :                 "hrtGetStreamId error, ret[%d]",
     298              :                 HCCL_ERROR_CODE(HCCL_E_RUNTIME), ret);
     299            0 :             return HCCL_E_INTERNAL;
     300              :         }
     301              : 
     302         1170 :         ret = hrtStreamGetSqid(stream_, &(sqId_));
     303         1166 :         if (ret != HCCL_SUCCESS) {
     304            2 :             SetEmpty();
     305            2 :             HCCL_ERROR(
     306              :                 "[InitStream]Failed to get the sqId through the rtstream, errNo[0x%016llx]"
     307              :                 "hrtStreamGetSqid error, ret[%d]",
     308              :                 HCCL_ERROR_CODE(HCCL_E_RUNTIME), ret);
     309            2 :             return HCCL_E_INTERNAL;
     310              :         }
     311         1164 :         (void)hrtCtxGetCurrent(&ctx_);
     312              : 
     313         1165 :         ret = hrtStreamGetCqid(stream_, &(cqId_), &(logicCqid_));
     314         1166 :         if (ret != HCCL_SUCCESS) {
     315            0 :             SetEmpty();
     316            0 :             HCCL_ERROR(
     317              :                 "[InitStream]Failed to get the cqId through the rtstream, errNo[0x%016llx]"
     318              :                 "hrtStreamGetCqid error, ret[%d]",
     319              :                 HCCL_ERROR_CODE(HCCL_E_RUNTIME), ret);
     320            0 :             return HCCL_E_INTERNAL;
     321              :         }
     322              :     }
     323         1166 :     return HCCL_SUCCESS;
     324              : }
     325              : 
     326          106 : HcclResult Stream::SetMode(const uint64_t stmMode)
     327              : {
     328          106 :     HcclResult ret = hrtStreamSetMode(stream_, stmMode);
     329          106 :     if (ret != HCCL_SUCCESS) {
     330            1 :         HCCL_ERROR(
     331              :             "[Stream][SetMode]errNo[0x%016llx] hrtStreamSetMode error, ret[%d]", HCCL_ERROR_CODE(HCCL_E_RUNTIME), ret);
     332            1 :         return HCCL_E_INTERNAL;
     333              :     }
     334          105 :     return HCCL_SUCCESS;
     335              : }
     336              : 
     337           99 : HcclResult Stream::GetMode(uint64_t* const stmMode)
     338              : {
     339           99 :     if (modeGotFlag_ == false) {
     340           99 :         HcclResult ret = hrtStreamGetMode(stream_, &streamMode_);
     341           99 :         if (ret != HCCL_SUCCESS) {
     342            0 :             HCCL_ERROR(
     343              :                 "[Stream][GetMode]errNo[0x%016llx] hrtStreamGetMode error, ret[%d]", HCCL_ERROR_CODE(HCCL_E_RUNTIME),
     344              :                 ret);
     345            0 :             return HCCL_E_INTERNAL;
     346              :         }
     347              :     }
     348           99 :     *stmMode = streamMode_;
     349           99 :     return HCCL_SUCCESS;
     350              : }
     351              : 
     352            0 : void Stream::PushTaskLogicInfo(TaskLogicInfo& taskLogicInfo)
     353              : {
     354            0 :     taskLogicInfo_.push(taskLogicInfo);
     355            0 :     HCCL_INFO(
     356              :         "[PushTaskLogicInfo] stream[%p], taskLogicType[%d], taskLogicFuncType[%d], taskLogicInfo size[%d]", stream_,
     357              :         taskLogicInfo.taskLogicCmd.taskLogicType, taskLogicInfo.taskFuncType, taskLogicInfo_.size());
     358            0 : }
     359              : 
     360            0 : HcclResult Stream::PopTaskLogicInfo(TaskLogicInfo& taskLogicInfo)
     361              : {
     362            0 :     if (taskLogicInfo_.size() > 0) {
     363            0 :         taskLogicInfo = taskLogicInfo_.front();
     364            0 :         HCCL_INFO(
     365              :             "[PopTaskLogicInfo] stream[%p], taskLogicType[%d], taskLogicFuncType[%d], taskLogicInfo size[%d]", stream_,
     366              :             taskLogicInfo.taskLogicCmd.taskLogicType, taskLogicInfo.taskFuncType, taskLogicInfo_.size());
     367            0 :         taskLogicInfo_.pop();
     368            0 :         return HCCL_SUCCESS;
     369              :     }
     370            0 :     return HCCL_E_NOT_FOUND;
     371              : }
     372              : 
     373              : HcclResult
     374           20 : Stream::GetNextSqeBufferAddr(uint8_t*& sqeBufferAddr, uint8_t*& sqeTypeAddr, uint8_t*& sqeDfxInfoAddr, uint16_t& taskId)
     375              : {
     376           20 :     if (UNLIKELY(sqeContext_ == nullptr)) {
     377            0 :         HCCL_ERROR("[Stream][GetNextSqeBufferAddr] Sqe context is null");
     378            0 :         return HCCL_E_INTERNAL;
     379              :     }
     380           20 :     auto& buff = sqeContext_->buffer;
     381           20 :     if (UNLIKELY(buff.tailSqeIdx >= HCCL_SQE_MAX_CNT)) {
     382            0 :         HCCL_INFO("[Stream][GetNextSqeBufferAddr] Sqe index to 2048, need clear");
     383            0 :         if (buff.sqeCnt != 0) {
     384            0 :             HCCL_ERROR("[Stream][GetNextSqeBufferAddr] Sqe index to 2048, but sqeCnt is not 0");
     385            0 :             return HCCL_E_INTERNAL;
     386              :         }
     387            0 :         CHK_RET(ClearLocalBuff());
     388              :     }
     389           20 :     sqeBufferAddr = buff.localBuff + buff.tailSqeIdx * HCCL_SQE_SIZE;
     390           20 :     sqeTypeAddr = &buff.sqeType[buff.tailSqeIdx];
     391           20 :     sqeDfxInfoAddr = reinterpret_cast<uint8_t*>(&buff.dfxInfo[buff.tailSqeIdx]);
     392              : 
     393           20 :     buff.profTimestap[buff.tailSqeIdx] = ProfGetCurCpuTimestamp();
     394           20 :     taskId = buff.tailSqeTaskId;
     395              : 
     396           20 :     HCCL_DEBUG(
     397              :         "[Stream][GetNextSqeBufferAddr] streamId: %u Get next idx:%u, taskId:%u, flipNum:%u",
     398              :         streamInfo_.actualStreamId, buff.tailSqeIdx, taskId, buff.filpNum);
     399           20 :     if (UNLIKELY(buff.tailSqeTaskId == UINT16_MAX)) {
     400            0 :         buff.filpNum++;
     401            0 :         HCCL_WARNING("[Stream][GetNextSqeBufferAddr] Sqe context cur taskId is uint16_max");
     402              :     }
     403           20 :     buff.tailSqeTaskId++;
     404           20 :     buff.sqeCnt++;
     405           20 :     buff.tailSqeIdx++;
     406           20 :     return HCCL_SUCCESS;
     407              : }
     408              : 
     409          496 : HcclResult Stream::InitSqAndCqeContext(uint32_t sqHead, uint32_t sqTail, SqCqeContext* context)
     410              : {
     411          496 :     CHK_PTR_NULL(context);
     412          496 :     sqeContext_ = &context->sqContext;
     413          496 :     CHK_PTR_NULL(sqeContext_);
     414          496 :     cqeContext_ = &context->cqeContext;
     415          496 :     CHK_PTR_NULL(cqeContext_);
     416              : 
     417          496 :     auto& buff = sqeContext_->buffer;
     418          496 :     buff.sqHead = sqHead;
     419          496 :     buff.sqTail = sqTail;
     420          496 :     cqeContext_->cqeStatus = 0;
     421          496 :     HCCL_INFO(
     422              :         "%s success, streamId:%u, sqHead:%u, sqTail:%u, context:%p", __func__, streamId_, sqHead, sqTail, context);
     423          496 :     return HCCL_SUCCESS;
     424              : }
     425              : 
     426            6 : HcclResult Stream::ClearLocalBuff()
     427              : {
     428            6 :     CHK_PTR_NULL(sqeContext_);
     429            1 :     auto& buff = sqeContext_->buffer;
     430            1 :     if (memset_s(buff.localBuff, sizeof(buff.localBuff), 0, buff.tailSqeIdx * HCCL_SQE_SIZE) != EOK) {
     431            0 :         HCCL_ERROR("[Stream][ClearLocalBuff] clear local buff failed");
     432            0 :         return HCCL_E_MEMORY;
     433              :     }
     434            1 :     if (memset_s(buff.sqeType, sizeof(buff.sqeType), 0, buff.tailSqeIdx) != EOK) {
     435            0 :         HCCL_ERROR("[Stream][ClearLocalBuff] clear sqe type failed");
     436            0 :         return HCCL_E_MEMORY;
     437              :     }
     438            1 :     if (memset_s(buff.addInfo, sizeof(buff.addInfo), 0, buff.tailSqeIdx) != EOK) {
     439            0 :         HCCL_ERROR("[Stream][ClearLocalBuff] clear add info failed");
     440            0 :         return HCCL_E_MEMORY;
     441              :     }
     442            1 :     buff.sqeCnt = 0;
     443            1 :     buff.tailSqeIdx = 0;
     444              : 
     445            1 :     if (cqeContext_ != nullptr && memset_s(cqeContext_, sizeof(ErrCqeContext), 0, sizeof(ErrCqeContext)) != EOK) {
     446            0 :         HCCL_ERROR("[Stream][ClearLocalBuff] clear cqe context failed");
     447            0 :         return HCCL_E_MEMORY;
     448              :     }
     449            1 :     return HCCL_SUCCESS;
     450              : }
     451              : 
     452            0 : HcclResult Stream::SetCqeContext(const ErrCqeContext& cqeContext)
     453              : {
     454            0 :     CHK_PTR_NULL(cqeContext_);
     455            0 :     *cqeContext_ = cqeContext;
     456            0 :     return HCCL_SUCCESS;
     457              : }
     458              : 
     459            0 : HcclResult Stream::GetCqeContext(ErrCqeContext& cqeContext)
     460              : {
     461            0 :     CHK_PTR_NULL(cqeContext_);
     462            0 :     cqeContext = *cqeContext_;
     463            0 :     return HCCL_SUCCESS;
     464              : }
     465              : 
     466            5 : HcclResult Stream::GetStreamInfo(const HcclComStreamInfo*& streamInfo)
     467              : {
     468            5 :     streamInfo = &streamInfo_;
     469            5 :     return HCCL_SUCCESS;
     470              : }
     471              : } // namespace hccl
        

Generated by: LCOV version 2.0-1