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 : #include "stream_lite.h"
11 : #include "binary_stream.h"
12 : #include "string_util.h"
13 : #include "rtsq_a5.h"
14 : namespace Hccl {
15 :
16 : // 这里不进行构造时的特殊处理,因为RtsqA5的构造不会抛出异常,唯一的可能是申请内存失败,此时抛出标准异常
17 121 : StreamLite::StreamLite(std::vector<char> &uniqueId)
18 : {
19 121 : BinaryStream binaryStream(uniqueId);
20 121 : binaryStream >> id;
21 121 : binaryStream >> sqId;
22 121 : binaryStream >> devPhyId;
23 121 : binaryStream >> cqId;
24 363 : HCCL_INFO("StreamLite::StreamLite:Start: %s, data=%s", Describe().c_str(),
25 : Bytes2hex(uniqueId.data(), uniqueId.size()).c_str());
26 121 : rtsq = std::make_unique<RtsqA5>(devPhyId, id, sqId);
27 363 : HCCL_INFO("StreamLite::StreamLite:End: %s", Describe().c_str());
28 121 : }
29 :
30 0 : StreamLite::StreamLite(u32 id, u32 sqIds, u32 phyId, u32 cqIds) : id(id), sqId(sqIds), devPhyId(phyId), cqId(cqIds)
31 : {
32 0 : rtsq = std::make_unique<RtsqA5>(phyId, id, sqIds);
33 0 : }
34 :
35 0 : StreamLite::StreamLite(u32 id, u32 sqIds, u32 phyId, u32 cqIds, bool launchFlag) : id(id), sqId(sqIds), devPhyId(phyId), cqId(cqIds)
36 : {
37 0 : rtsq = std::make_unique<RtsqA5>(phyId, id, sqIds, launchFlag);
38 0 : }
39 :
40 303 : RtsqBase *StreamLite::GetRtsq() const
41 : {
42 303 : return rtsq.get();
43 : }
44 :
45 244 : std::string StreamLite::Describe() const
46 : {
47 244 : return StringFormat("StreamLite[id=%u, sqid=%u, devPhyId=%u]", id, sqId, devPhyId);
48 : }
49 :
50 : } // namespace Hccl
|