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 TASK_INFO_H
11 : #define TASK_INFO_H
12 : #include <string>
13 : #include <memory>
14 : #include <functional>
15 : #include "task_param.h"
16 : #include "coll_operator.h"
17 :
18 : namespace Hccl {
19 :
20 : class DfxOpInfo {
21 : public:
22 : CollOperator op_;
23 : std::string tag_; // 实际是opType
24 : std::string algType_;
25 : u32 commIndex_;
26 : u64 beginTime_;
27 : u64 endTime_;
28 : void* comm_{nullptr};
29 : bool isIndop_{false};
30 : std::string algTag_;
31 : std::string groupName_;
32 : u32 rankSize_{0};
33 : u32 cpuWaitAicpuNotifyId_{0};
34 : std::string commId_{};
35 : u32 opIndex_{0}; // 下发算子总计数(单算子/图模式/CCU快速下发)
36 : u64 headOpCounterAddr_{0}; // 执行算子头计数器地址(执行前加一)
37 : u64 tailOpCounterAddr_{0}; // 执行算子尾计数器地址(执行后加一)
38 : CommEngine engine{CommEngine::COMM_ENGINE_RESERVED};
39 :
40 : public:
41 14 : std::string Describe() const
42 : {
43 : return StringFormat(
44 : "DfxOpInfo: [collOperator:[%s], tag:[%s], algType:[%s], commIndex:[%u], commId[%s], "
45 : "beginTime:[%llu], endTime:[%llu], opIndex[%u], headOpCounterAddr[%llx], "
46 : "tailOpCounterAddr[%llx], groupName[%s], rankSize[%u], myRank[%d], dataType[%s]]",
47 28 : CollOpToString(op_).c_str(), tag_.c_str(), algType_.c_str(), commIndex_, commId_.c_str(), beginTime_,
48 28 : endTime_, opIndex_, headOpCounterAddr_, tailOpCounterAddr_, groupName_.c_str(), rankSize_, op_.myRank,
49 42 : DataTypeToSerialString(static_cast<uint32_t>(op_.dataType)).c_str());
50 : }
51 : };
52 :
53 : class TaskInfo {
54 : public:
55 : u32 streamId_;
56 : u32 taskId_;
57 : u32 remoteRank_{0xffffffff};
58 : TaskParam taskParam_;
59 : std::shared_ptr<DfxOpInfo> dfxOpInfo_;
60 : bool isMaster_;
61 : u64 channelHandle_{INVALID_U64};
62 : std::function<u32(u64)> getRemoteRankByHandle_{nullptr};
63 :
64 : public:
65 : TaskInfo(
66 : u32 streamId, u32 taskId, u32 remoteRank, const TaskParam& taskParam,
67 : const std::shared_ptr<DfxOpInfo>& dfxOpInfo = nullptr, bool isMaster = false);
68 :
69 : std::string Describe() const;
70 :
71 : std::string GetAlgTypeName() const;
72 : std::string GetBaseInfo() const;
73 : std::string GetConciseBaseInfo() const;
74 : std::string GetParaInfo() const;
75 : std::string GetOpInfo() const;
76 :
77 : std::string GetIndopDataInfo() const;
78 : std::string GetIndopBaseInfo() const;
79 : u32 GetRemoteRankId() const;
80 :
81 : private:
82 : std::string GetParaDMA() const;
83 : std::string GetParaReduce() const;
84 : std::string GetParaNotify() const;
85 : std::string GetParaAiv() const;
86 : std::string GetRemoteRankInfo(bool needConcise = false) const;
87 : std::string GetTaskConciseName() const;
88 : std::string GetNotifyInfo() const;
89 : std::string GetReduceOp() const;
90 : };
91 :
92 : void PrintTaskLog(u32 streamId, u32 taskId, const TaskParam& taskParam, u32 remoteRankId);
93 :
94 : } // namespace Hccl
95 :
96 : #endif
|