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_LITE_H
12 : #define HCCLV2_STREAM_LITE_H
13 : #include <vector>
14 : #include <string>
15 : #include <memory>
16 : #include <functional>
17 : #include "types.h"
18 : #include "rtsq_base.h"
19 : #include "dfx_circular_queue.h"
20 : namespace Hccl {
21 :
22 : class StreamLite {
23 : public:
24 : explicit StreamLite(std::vector<char>& uniqueId);
25 : StreamLite(u32 id, u32 sqIds, u32 phyId, u32 cqIds);
26 : StreamLite(u32 id, u32 sqIds, u32 phyId, u32 cqIds, bool launchFlag);
27 :
28 70 : inline u32 GetId() const { return id; }
29 :
30 165 : inline u32 GetSqId() const { return sqId; }
31 :
32 11 : inline u32 GetCqId() const { return cqId; }
33 :
34 2 : inline u32 GetDevPhyId() const { return devPhyId; }
35 :
36 : RtsqBase* GetRtsq() const;
37 :
38 : std::string Describe() const;
39 :
40 : TaskInfoCircularQueue* GetTaskInfos() const;
41 : DfxTaskInfo* NextTaskSlot() const;
42 : void SetReportStreamTaskCallback(std::function<void(TaskInfoCircularQueue*)> callback);
43 : bool HasReportStreamTaskCallback() const;
44 : void ReportStreamTask() const;
45 :
46 : void SetGetLatestDfxOpInfoCallback(std::function<const void*()> callback);
47 :
48 : const void* GetLatestDfxOpInfo() const;
49 :
50 : private:
51 : u32 id;
52 : u32 sqId;
53 : u32 devPhyId{0};
54 : u32 cqId{0};
55 :
56 : std::unique_ptr<RtsqBase> rtsq;
57 : mutable TaskInfoCircularQueue taskInfos_;
58 : std::function<void(TaskInfoCircularQueue*)> reportStreamTaskCallback_{nullptr};
59 : std::function<const void*()> getLatestDfxOpInfoCallback_{nullptr};
60 : };
61 :
62 : } // namespace Hccl
63 :
64 : #endif
|