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