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 : #ifndef HCCLV2_STREAM_H
12 : #define HCCLV2_STREAM_H
13 :
14 : #include "orion_adapter_rts.h"
15 : #include "stream_lite.h"
16 : namespace Hccl {
17 :
18 : class Stream {
19 : public:
20 : explicit Stream(aclrtStream ptr, bool isMaster = true);
21 :
22 : explicit Stream(bool deviceUsed = false, bool isMaster = true);
23 :
24 : Stream(const Stream& stream, bool isMaster = true) = delete;
25 :
26 : Stream& operator=(const Stream& stream) = delete;
27 :
28 : ~Stream();
29 :
30 7 : bool operator==(const Stream& rhs) const { return ptr == rhs.ptr; }
31 :
32 : bool operator!=(const Stream& rhs) const { return !(rhs == *this); }
33 :
34 : void SetStmMode(u64 stmMode);
35 :
36 : aclrtStream GetPtr() const;
37 :
38 : u32 GetId() const;
39 :
40 : u32 GetSqId() const;
41 :
42 : bool IsMaster() const;
43 :
44 : bool IsSelfOwned() const;
45 :
46 : u64 GetMode() const;
47 :
48 : std::vector<char> GetUniqueId() const;
49 :
50 : std::string Describe() const;
51 :
52 : private:
53 : static constexpr int32_t HCCL_STREAM_PRIORITY_LOW = 5;
54 : static constexpr int32_t HCCL_STREAM_PRIORITY_HIGH = 5;
55 : static constexpr int32_t STREAM_MODE_STOP_ON_FAILURE = 1; // 配置流失败模式为遇错即停
56 :
57 : aclrtStream ptr;
58 : u32 id{0};
59 : bool selfOwned{false};
60 : u64 mode{0};
61 : bool devUsed{false};
62 : u32 sqId{0};
63 : u32 cqId{0};
64 : u32 devPhyId{0};
65 : bool isMaster_{true};
66 :
67 : void InitDevPhyId();
68 : };
69 :
70 : } // namespace Hccl
71 : #endif
|