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