| @@ -22,7 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | 23 | ||
C | |||
| 24 | 24 | ||
| 25 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 25 | +#include "analysis/csrc/infrastructure/utils/prof_struct.h" |
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | namespace Analysis | 28 | namespace Analysis |
| @@ -21,7 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 24 | +#include "analysis/csrc/infrastructure/utils/parser_struct.h" |
| 25 | 25 | ||
| 26 | namespace Analysis | 26 | namespace Analysis |
| 27 | { | 27 | { |
| @@ -49,16 +49,16 @@ struct AicpuData | |||
| 49 | TaskId aicpuTaskId; | 49 | TaskId aicpuTaskId; |
| 50 | union | 50 | union |
| 51 | { | 51 | { |
| 52 | - MsprofAicpuNodeAdditionalData node; | 52 | + ParserAicpuNodeAdditionalData node; |
| 53 | - MsprofAicpuDpAdditionalData dp; | 53 | + ParserAicpuDpAdditionalData dp; |
| 54 | - MsprofAicpuModelAdditionalData model; | 54 | + ParserAicpuModelAdditionalData model; |
| 55 | - MsprofAicpuMiAdditionalData mi; | 55 | + ParserAicpuMiAdditionalData mi; |
| 56 | - AicpuKfcProfCommTurn commTurn; | 56 | + ParserAicpuKfcProfCommTurn commTurn; |
| 57 | - AicpuKfcProfComputeTurn computeTurn; | 57 | + ParserAicpuKfcProfComputeTurn computeTurn; |
| 58 | - MsprofAicpuHCCLOPInfo opInfo; | 58 | + ParserAicpuHCCLOPInfo opInfo; |
| 59 | - MsporfAicpuFlipTask flipTask; | 59 | + ParserAicpuFlipTask flipTask; |
| 60 | - MsprofAicpuHcclMainStreamTask mainStreamTask; | 60 | + ParserAicpuHcclMainStreamTask mainStreamTask; |
| 61 | - MsprofKfcInfos KfcInfos; | 61 | + ParserKfcInfos KfcInfos; |
| 62 | }; | 62 | }; |
| 63 | AicpuData() {} | 63 | AicpuData() {} |
| 64 | }; | 64 | }; |
| @@ -22,7 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 25 | +#include "analysis/csrc/infrastructure/utils/parser_struct.h" |
| 26 | 26 | ||
| 27 | namespace Analysis | 27 | namespace Analysis |
| 28 | { | 28 | { |
| @@ -45,11 +45,11 @@ enum class OpType | |||
| 45 | // 计算算子描述信息 | 45 | // 计算算子描述信息 |
| 46 | struct OpDesc | 46 | struct OpDesc |
| 47 | { | 47 | { |
| 48 | - std::shared_ptr<MsprofCompactInfo> nodeDesc = nullptr; | 48 | + std::shared_ptr<ParserCompactInfo> nodeDesc = nullptr; |
| 49 | - std::shared_ptr<MsprofCompactInfo> nodeAttr = nullptr; | 49 | + std::shared_ptr<ParserCompactInfo> nodeAttr = nullptr; |
| 50 | - std::shared_ptr<MsprofCompactInfo> runtimeTrackDesc = nullptr; | 50 | + std::shared_ptr<ParserCompactInfo> runtimeTrackDesc = nullptr; |
| 51 | - std::shared_ptr<ConcatTensorInfo> tensorDesc = nullptr; | 51 | + std::shared_ptr<ParserConcatTensorInfo> tensorDesc = nullptr; |
| 52 | - std::shared_ptr<MsprofAdditionalInfo> ctxId = nullptr; | 52 | + std::shared_ptr<ParserAdditionalInfo> ctxId = nullptr; |
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | // 通信小算子描述信息 | 55 | // 通信小算子描述信息 |
| @@ -57,9 +57,9 @@ struct HcclSmallOpDesc | |||
| 57 | { | 57 | { |
| 58 | uint32_t ctxId = DEFAULT_CONTEXT_ID; | 58 | uint32_t ctxId = DEFAULT_CONTEXT_ID; |
| 59 | uint8_t isMaster = 0; // 1代表master | 59 | uint8_t isMaster = 0; // 1代表master |
| 60 | - std::shared_ptr<MsprofAdditionalInfo> hcclInfo = nullptr; | 60 | + std::shared_ptr<ParserAdditionalInfo> hcclInfo = nullptr; |
| 61 | 61 | ||
| 62 | - HcclSmallOpDesc(uint32_t ctxId, uint32_t isMaster, const std::shared_ptr<MsprofAdditionalInfo> &hcclInfo) | 62 | + HcclSmallOpDesc(uint32_t ctxId, uint32_t isMaster, const std::shared_ptr<ParserAdditionalInfo> &hcclInfo) |
| 63 | : ctxId(ctxId), isMaster(isMaster), hcclInfo(hcclInfo) | 63 | : ctxId(ctxId), isMaster(isMaster), hcclInfo(hcclInfo) |
| 64 | { | 64 | { |
| 65 | } | 65 | } |
| @@ -75,13 +75,13 @@ struct HcclBigOpDesc | |||
| 75 | int32_t indexId = 0; | 75 | int32_t indexId = 0; |
| 76 | int64_t connectionId = 0; | 76 | int64_t connectionId = 0; |
| 77 | uint32_t threadId = 0; | 77 | uint32_t threadId = 0; |
| 78 | - std::shared_ptr<MsprofCompactInfo> nodeDesc = nullptr; | 78 | + std::shared_ptr<ParserCompactInfo> nodeDesc = nullptr; |
| 79 | - std::shared_ptr<MsprofCompactInfo> opInfoDesc = nullptr; | 79 | + std::shared_ptr<ParserCompactInfo> opInfoDesc = nullptr; |
| 80 | std::string kfcConnectionIds; | 80 | std::string kfcConnectionIds; |
| 81 | 81 | ||
| 82 | HcclBigOpDesc(uint64_t begin, uint64_t end, uint16_t deviceId, uint64_t modelId, int32_t indexId, | 82 | HcclBigOpDesc(uint64_t begin, uint64_t end, uint16_t deviceId, uint64_t modelId, int32_t indexId, |
| 83 | - int64_t connectionId, uint32_t threadId, const std::shared_ptr<MsprofCompactInfo> &node, | 83 | + int64_t connectionId, uint32_t threadId, const std::shared_ptr<ParserCompactInfo> &node, |
| 84 | - const std::shared_ptr<MsprofCompactInfo> &hcclOpDesc, std::string ids) | 84 | + const std::shared_ptr<ParserCompactInfo> &hcclOpDesc, std::string ids) |
| 85 | : beginTime(begin), | 85 | : beginTime(begin), |
| 86 | endTime(end), | 86 | endTime(end), |
| 87 | deviceId(deviceId), | 87 | deviceId(deviceId), |
| @@ -165,8 +165,8 @@ struct HostTask | |||
| 165 | struct GeFusionOpInfo | 165 | struct GeFusionOpInfo |
| 166 | { | 166 | { |
| 167 | uint64_t modelId; | 167 | uint64_t modelId; |
| 168 | - std::shared_ptr<ProfFusionOpInfo> fusionOpInfo = nullptr; | 168 | + std::shared_ptr<ParserProfFusionOpInfo> fusionOpInfo = nullptr; |
| 169 | - GeFusionOpInfo(uint64_t modelId, const std::shared_ptr<ProfFusionOpInfo> &fusionOp) | 169 | + GeFusionOpInfo(uint64_t modelId, const std::shared_ptr<ParserProfFusionOpInfo> &fusionOp) |
| 170 | : modelId(modelId), fusionOpInfo(fusionOp) | 170 | : modelId(modelId), fusionOpInfo(fusionOp) |
| 171 | { | 171 | { |
| 172 | } | 172 | } |
| @@ -18,25 +18,31 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | -namespace Analysis { | 21 | +namespace Analysis |
| 22 | -namespace Domain { | 22 | +{ |
| 23 | +namespace Domain | ||
| 24 | +{ | ||
| 23 | 25 | ||
| 24 | std::atomic<uint32_t> g_eventIDCnt{0}; | 26 | std::atomic<uint32_t> g_eventIDCnt{0}; |
| 25 | 27 | ||
| 26 | -Event::Event(std::shared_ptr<MsprofApi> eventPtr, const EventInfo &eventInfo) | 28 | +Event::Event(std::shared_ptr<ParserApi> eventPtr, const EventInfo &eventInfo) |
| 27 | : apiPtr(std::move(eventPtr)), info(eventInfo), id(++g_eventIDCnt) | 29 | : apiPtr(std::move(eventPtr)), info(eventInfo), id(++g_eventIDCnt) |
| 28 | -{} | 30 | +{ |
| 31 | +} | ||
| 29 | 32 | ||
| 30 | -Event::Event(std::shared_ptr<MsprofAdditionalInfo> eventPtr, const EventInfo &eventInfo) | 33 | +Event::Event(std::shared_ptr<ParserAdditionalInfo> eventPtr, const EventInfo &eventInfo) |
| 31 | : additionPtr(std::move(eventPtr)), info(eventInfo), id(++g_eventIDCnt) | 34 | : additionPtr(std::move(eventPtr)), info(eventInfo), id(++g_eventIDCnt) |
| 32 | -{} | 35 | +{ |
| 36 | +} | ||
| 33 | 37 | ||
| 34 | -Event::Event(std::shared_ptr<MsprofCompactInfo> eventPtr, const EventInfo &eventInfo) | 38 | +Event::Event(std::shared_ptr<ParserCompactInfo> eventPtr, const EventInfo &eventInfo) |
| 35 | : compactPtr(std::move(eventPtr)), info(eventInfo), id(++g_eventIDCnt) | 39 | : compactPtr(std::move(eventPtr)), info(eventInfo), id(++g_eventIDCnt) |
| 36 | -{} | 40 | +{ |
| 41 | +} | ||
| 37 | 42 | ||
| 38 | -Event::Event(std::shared_ptr<ConcatTensorInfo> eventPtr, const EventInfo &eventInfo) | 43 | +Event::Event(std::shared_ptr<ParserConcatTensorInfo> eventPtr, const EventInfo &eventInfo) |
| 39 | : tensorPtr(std::move(eventPtr)), info(eventInfo), id(++g_eventIDCnt) | 44 | : tensorPtr(std::move(eventPtr)), info(eventInfo), id(++g_eventIDCnt) |
| 40 | -{} | 45 | +{ |
| 41 | -} // namespace Entities | 46 | +} |
| 42 | -} // namespace Analysis | 47 | +} // namespace Domain |
| 48 | +} // namespace Analysis | ||
| @@ -22,7 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 25 | +#include "analysis/csrc/infrastructure/utils/parser_struct.h" |
| 26 | + | ||
| 26 | 27 | ||
| 27 | namespace Analysis | 28 | namespace Analysis |
| 28 | { | 29 | { |
| @@ -82,16 +83,16 @@ struct EventInfo | |||
| 82 | // Event为本工程对软硬件上报的各类信息(Trace)的抽象, 表示一个时间点或时间片发生的事件 | 83 | // Event为本工程对软硬件上报的各类信息(Trace)的抽象, 表示一个时间点或时间片发生的事件 |
| 83 | struct Event | 84 | struct Event |
| 84 | { | 85 | { |
| 85 | - Event(std::shared_ptr<MsprofApi> eventPtr, const EventInfo &eventInfo); | 86 | + Event(std::shared_ptr<ParserApi> eventPtr, const EventInfo &eventInfo); |
| 86 | - Event(std::shared_ptr<MsprofAdditionalInfo> eventPtr, const EventInfo &eventInfo); | 87 | + Event(std::shared_ptr<ParserAdditionalInfo> eventPtr, const EventInfo &eventInfo); |
| 87 | - Event(std::shared_ptr<MsprofCompactInfo> eventPtr, const EventInfo &eventInfo); | 88 | + Event(std::shared_ptr<ParserCompactInfo> eventPtr, const EventInfo &eventInfo); |
| 88 | - Event(std::shared_ptr<ConcatTensorInfo> eventPtr, const EventInfo &eventInfo); | 89 | + Event(std::shared_ptr<ParserConcatTensorInfo> eventPtr, const EventInfo &eventInfo); |
| 89 | union | 90 | union |
| 90 | { | 91 | { |
| 91 | - std::shared_ptr<MsprofApi> apiPtr; | 92 | + std::shared_ptr<ParserApi> apiPtr; |
| 92 | - std::shared_ptr<MsprofAdditionalInfo> additionPtr; | 93 | + std::shared_ptr<ParserAdditionalInfo> additionPtr; |
| 93 | - std::shared_ptr<MsprofCompactInfo> compactPtr; | 94 | + std::shared_ptr<ParserCompactInfo> compactPtr; |
| 94 | - std::shared_ptr<ConcatTensorInfo> tensorPtr; | 95 | + std::shared_ptr<ParserConcatTensorInfo> tensorPtr; |
| 95 | }; | 96 | }; |
| 96 | EventInfo info; | 97 | EventInfo info; |
| 97 | int64_t id = 0; // 全局唯一ID | 98 | int64_t id = 0; // 全局唯一ID |
| @@ -36,22 +36,22 @@ const uint16_t BIT_NUM = 16; | |||
| 36 | const uint16_t BIT_V2_NUM = 32; | 36 | const uint16_t BIT_V2_NUM = 32; |
| 37 | } // namespace | 37 | } // namespace |
| 38 | 38 | ||
| 39 | -uint16_t Flip::GetTaskId(const MsprofCompactInfo &task) | 39 | +uint16_t Flip::GetTaskId(const ParserCompactInfo &task) |
| 40 | { | 40 | { |
| 41 | - return task.data.runtimeTrackV2.taskId & TASK_ID_BIT; // taskId是低16位 | 41 | + return task.data.runtimeTrack.taskId & TASK_ID_BIT; // taskId是低16位 |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | -uint16_t Flip::GetBatchId(const MsprofCompactInfo &task) | 44 | +uint16_t Flip::GetBatchId(const ParserCompactInfo &task) |
| 45 | { | 45 | { |
| 46 | - return task.data.runtimeTrackV2.taskId >> BIT_NUM; // batchId/flipNum是高16位 | 46 | + return task.data.runtimeTrack.taskId >> BIT_NUM; // batchId/flipNum是高16位 |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | -void Flip::SetBatchId(MsprofCompactInfo &task, uint32_t batchId) | 49 | +void Flip::SetBatchId(ParserCompactInfo &task, uint32_t batchId) |
| 50 | { | 50 | { |
| 51 | - task.data.runtimeTrackV2.taskId = (task.data.runtimeTrackV2.taskId & TASK_ID_BIT) + (batchId << BIT_NUM); | 51 | + task.data.runtimeTrack.taskId = (task.data.runtimeTrack.taskId & TASK_ID_BIT) + (batchId << BIT_NUM); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | -std::shared_ptr<FlipTask> Flip::CreateFlipTask(MsprofCompactInfo *taskTrack) | 54 | +std::shared_ptr<FlipTask> Flip::CreateFlipTask(ParserCompactInfo *taskTrack) |
| 55 | { | 55 | { |
| 56 | if (!taskTrack) | 56 | if (!taskTrack) |
| 57 | { | 57 | { |
| @@ -61,16 +61,16 @@ std::shared_ptr<FlipTask> Flip::CreateFlipTask(MsprofCompactInfo *taskTrack) | |||
| 61 | std::shared_ptr<FlipTask> flipTask; | 61 | std::shared_ptr<FlipTask> flipTask; |
| 62 | MAKE_SHARED0_RETURN_VALUE(flipTask, FlipTask, nullptr); | 62 | MAKE_SHARED0_RETURN_VALUE(flipTask, FlipTask, nullptr); |
| 63 | 63 | ||
| 64 | - flipTask->deviceId = taskTrack->data.runtimeTrackV2.deviceId; | 64 | + flipTask->deviceId = taskTrack->data.runtimeTrack.deviceId; |
| 65 | - flipTask->streamId = taskTrack->data.runtimeTrackV2.streamId; | 65 | + flipTask->streamId = taskTrack->data.runtimeTrack.streamId; |
| 66 | flipTask->taskId = GetTaskId(*taskTrack); | 66 | flipTask->taskId = GetTaskId(*taskTrack); |
| 67 | flipTask->timeStamp = taskTrack->timeStamp; | 67 | flipTask->timeStamp = taskTrack->timeStamp; |
| 68 | flipTask->flipNum = GetBatchId(*taskTrack); | 68 | flipTask->flipNum = GetBatchId(*taskTrack); |
| 69 | return flipTask; | 69 | return flipTask; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | -void Flip::ComputeBatchId(std::vector<std::shared_ptr<MsprofCompactInfo>> &taskTrack, | 72 | +void Flip::ComputeBatchId(std::vector<std::shared_ptr<ParserCompactInfo>> &taskTrack, |
| 73 | - std::vector<std::shared_ptr<FlipTask>> &flipTask, bool isV2) | 73 | + std::vector<std::shared_ptr<FlipTask>> &flipTask, RuntimeTrackFormat runtimeTrackFormat) |
| 74 | { | 74 | { |
| 75 | if (taskTrack.empty()) | 75 | if (taskTrack.empty()) |
| 76 | { | 76 | { |
| @@ -83,6 +83,7 @@ void Flip::ComputeBatchId(std::vector<std::shared_ptr<MsprofCompactInfo>> &taskT | |||
| 83 | MAKE_SHARED0_RETURN_VOID(maxFlip, FlipTask); | 83 | MAKE_SHARED0_RETURN_VOID(maxFlip, FlipTask); |
| 84 | 84 | ||
| 85 | maxFlip->timeStamp = std::numeric_limits<uint64_t>::max(); | 85 | maxFlip->timeStamp = std::numeric_limits<uint64_t>::max(); |
| 86 | + bool isV2 = (runtimeTrackFormat == RuntimeTrackFormat::V2); | ||
| 86 | for (auto &item : taskTrackBin) | 87 | for (auto &item : taskTrackBin) |
| 87 | { | 88 | { |
| 88 | const auto &key = item.first; | 89 | const auto &key = item.first; |
| @@ -115,7 +116,7 @@ void Flip::ComputeBatchId(std::vector<std::shared_ptr<MsprofCompactInfo>> &taskT | |||
| 115 | if (task->timeStamp > flip->timeStamp) | 116 | if (task->timeStamp > flip->timeStamp) |
| 116 | { | 117 | { |
| 117 | ++batchId; // next flip | 118 | ++batchId; // next flip |
| 118 | - CalibrateFlipTaskIdNotZero(taskTrackInStream, flip, taskIdx, batchId, isV2); | 119 | + CalibrateFlipTaskIdNotZero(taskTrackInStream, flip, taskIdx, batchId, runtimeTrackFormat); |
| 119 | continue; | 120 | continue; |
| 120 | } | 121 | } |
| 121 | SetBatchId(*task, batchId); | 122 | SetBatchId(*task, batchId); |
| @@ -140,7 +141,7 @@ Flip::FlipTaskMap Flip::SepFlipTask(const std::vector<std::shared_ptr<FlipTask>> | |||
| 140 | return data; | 141 | return data; |
| 141 | } | 142 | } |
| 142 | 143 | ||
| 143 | -Flip::CompactInfoMap Flip::SepTaskTrack(const std::vector<std::shared_ptr<MsprofCompactInfo>> &taskTrack) | 144 | +Flip::CompactInfoMap Flip::SepTaskTrack(const std::vector<std::shared_ptr<ParserCompactInfo>> &taskTrack) |
| 144 | { | 145 | { |
| 145 | CompactInfoMap data; | 146 | CompactInfoMap data; |
| 146 | for (const auto &task : taskTrack) | 147 | for (const auto &task : taskTrack) |
| @@ -151,22 +152,22 @@ Flip::CompactInfoMap Flip::SepTaskTrack(const std::vector<std::shared_ptr<Msprof | |||
| 151 | continue; | 152 | continue; |
| 152 | } | 153 | } |
| 153 | // deviceId为高32bit, streamId为低32bit,拼接为key | 154 | // deviceId为高32bit, streamId为低32bit,拼接为key |
| 154 | - uint64_t key = (static_cast<uint64_t>(task->data.runtimeTrackV2.deviceId) << BIT_V2_NUM) + | 155 | + uint64_t key = (static_cast<uint64_t>(task->data.runtimeTrack.deviceId) << BIT_V2_NUM) + |
| 155 | - static_cast<uint64_t>(task->data.runtimeTrackV2.streamId); | 156 | + static_cast<uint64_t>(task->data.runtimeTrack.streamId); |
| 156 | data[key].emplace_back(task); | 157 | data[key].emplace_back(task); |
| 157 | } | 158 | } |
| 158 | return data; | 159 | return data; |
| 159 | } | 160 | } |
| 160 | 161 | ||
| 161 | -void Flip::CalibrateFlipTaskIdNotZero(std::vector<std::shared_ptr<MsprofCompactInfo>> &taskTrack, | 162 | +void Flip::CalibrateFlipTaskIdNotZero(std::vector<std::shared_ptr<ParserCompactInfo>> &taskTrack, |
| 162 | const std::shared_ptr<FlipTask> &flip, uint32_t taskIdx, uint32_t batchId, | 163 | const std::shared_ptr<FlipTask> &flip, uint32_t taskIdx, uint32_t batchId, |
| 163 | - bool isV2) | 164 | + RuntimeTrackFormat runtimeTrackFormat) |
| 164 | { | 165 | { |
| 165 | - if (!isV2 && flip->flipNum == STREAM_DESTROY_FLIP) | 166 | + if (runtimeTrackFormat == RuntimeTrackFormat::V1 && flip->flipNum == STREAM_DESTROY_FLIP) |
| 166 | { | 167 | { |
| 167 | return; | 168 | return; |
| 168 | } | 169 | } |
| 169 | - if (isV2 && flip->flipNum == STREAM_DESTROY_FLIP_V2) | 170 | + if (runtimeTrackFormat == RuntimeTrackFormat::V2 && flip->flipNum == STREAM_DESTROY_FLIP_V2) |
| 170 | { | 171 | { |
| 171 | return; | 172 | return; |
| 172 | } | 173 | } |
| @@ -21,8 +21,8 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 24 | +#include "analysis/csrc/infrastructure/utils/parser_struct.h" |
| 25 | - | 25 | +#include "analysis/csrc/infrastructure/utils/prof_struct.h" |
| 26 | namespace Analysis | 26 | namespace Analysis |
| 27 | { | 27 | { |
| 28 | namespace Domain | 28 | namespace Domain |
| @@ -33,7 +33,7 @@ struct FlipTask | |||
| 33 | { | 33 | { |
| 34 | uint16_t deviceId; | 34 | uint16_t deviceId; |
| 35 | uint32_t streamId; | 35 | uint32_t streamId; |
| 36 | - uint32_t taskId; | 36 | + uint16_t taskId; |
| 37 | uint32_t flipNum; | 37 | uint32_t flipNum; |
| 38 | uint64_t timeStamp; | 38 | uint64_t timeStamp; |
| 39 | }; | 39 | }; |
| @@ -42,21 +42,22 @@ struct FlipTask | |||
| 42 | class Flip | 42 | class Flip |
| 43 | { | 43 | { |
| 44 | public: | 44 | public: |
| 45 | - static void ComputeBatchId(std::vector<std::shared_ptr<MsprofCompactInfo>> &taskTrack, | 45 | + static void ComputeBatchId(std::vector<std::shared_ptr<ParserCompactInfo>> &taskTrack, |
| 46 | - std::vector<std::shared_ptr<FlipTask>> &flipTask, bool isV2 = false); | 46 | + std::vector<std::shared_ptr<FlipTask>> &flipTask, |
| 47 | - static uint16_t GetTaskId(const MsprofCompactInfo &task); | 47 | + RuntimeTrackFormat runtimeTrackFormat = RuntimeTrackFormat::V1); |
| 48 | - static uint16_t GetBatchId(const MsprofCompactInfo &task); | 48 | + static uint16_t GetTaskId(const ParserCompactInfo &task); |
| 49 | - static std::shared_ptr<FlipTask> CreateFlipTask(MsprofCompactInfo *taskTrack); | 49 | + static uint16_t GetBatchId(const ParserCompactInfo &task); |
| 50 | + static std::shared_ptr<FlipTask> CreateFlipTask(ParserCompactInfo *taskTrack); | ||
| 50 | 51 | ||
| 51 | private: | 52 | private: |
| 52 | - using CompactInfoMap = std::unordered_map<uint64_t, std::vector<std::shared_ptr<MsprofCompactInfo>>>; | 53 | + using CompactInfoMap = std::unordered_map<uint64_t, std::vector<std::shared_ptr<ParserCompactInfo>>>; |
| 53 | using FlipTaskMap = std::unordered_map<uint64_t, std::vector<std::shared_ptr<FlipTask>>>; | 54 | using FlipTaskMap = std::unordered_map<uint64_t, std::vector<std::shared_ptr<FlipTask>>>; |
| 54 | - static void CalibrateFlipTaskIdNotZero(std::vector<std::shared_ptr<MsprofCompactInfo>> &taskTrack, | 55 | + static void CalibrateFlipTaskIdNotZero(std::vector<std::shared_ptr<ParserCompactInfo>> &taskTrack, |
| 55 | const std::shared_ptr<FlipTask> &flip, uint32_t taskIdx, uint32_t batchId, | 56 | const std::shared_ptr<FlipTask> &flip, uint32_t taskIdx, uint32_t batchId, |
| 56 | - bool isV2 = false); | 57 | + RuntimeTrackFormat runtimeTrackFormat = RuntimeTrackFormat::V1); |
| 57 | - static CompactInfoMap SepTaskTrack(const std::vector<std::shared_ptr<MsprofCompactInfo>> &taskTrack); | 58 | + static CompactInfoMap SepTaskTrack(const std::vector<std::shared_ptr<ParserCompactInfo>> &taskTrack); |
| 58 | static FlipTaskMap SepFlipTask(const std::vector<std::shared_ptr<FlipTask>> &flipTask); | 59 | static FlipTaskMap SepFlipTask(const std::vector<std::shared_ptr<FlipTask>> &flipTask); |
| 59 | - static void SetBatchId(MsprofCompactInfo &task, uint32_t batchId); | 60 | + static void SetBatchId(ParserCompactInfo &task, uint32_t batchId); |
| 60 | 61 | ||
| 61 | }; // class Flip | 62 | }; // class Flip |
| 62 | } // namespace Adapter | 63 | } // namespace Adapter |
| @@ -0,0 +1,573 @@ | |||
| 1 | +/* ------------------------------------------------------------------------- | ||
| 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | + * This file is part of the MindStudio project. | ||
| 4 | + * | ||
| 5 | + * MindStudio is licensed under Mulan PSL v2. | ||
| 6 | + * You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
| 7 | + * You may obtain a copy of Mulan PSL v2 at: | ||
| 8 | + * | ||
| 9 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
| 10 | + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
| 11 | + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
| 12 | + * See the Mulan PSL v2 for more details. | ||
| 13 | + * -------------------------------------------------------------------------*/ | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +namespace Analysis | ||
| 23 | +{ | ||
| 24 | +namespace Domain | ||
| 25 | +{ | ||
| 26 | +namespace Adapter | ||
| 27 | +{ | ||
| 28 | +using namespace Analysis::Utils; | ||
| 29 | +namespace | ||
| 30 | +{ | ||
| 31 | +void AdapterRuntimeTrackV1(const MsprofCompactInfo* compact, ParserCompactInfo* parsed) | ||
| 32 | +{ | ||
| 33 | + parsed->data.runtimeTrack.deviceId = compact->data.runtimeTrack.deviceId; | ||
| 34 | + parsed->data.runtimeTrack.streamId = compact->data.runtimeTrack.streamId; | ||
| 35 | + parsed->data.runtimeTrack.taskId = compact->data.runtimeTrack.taskId; | ||
| 36 | + parsed->data.runtimeTrack.taskType = compact->data.runtimeTrack.taskType; | ||
| 37 | + parsed->data.runtimeTrack.kernelName = compact->data.runtimeTrack.kernelName; | ||
| 38 | + parsed->data.runtimeTrack.kernelInfo.argsSize = compact->data.runtimeTrack.extInfo.kernelInfo.argsSize; | ||
| 39 | + parsed->data.runtimeTrack.kernelInfo.numBlocks = compact->data.runtimeTrack.extInfo.kernelInfo.numBlocks; | ||
| 40 | + parsed->data.runtimeTrack.kernelInfo.ratio = compact->data.runtimeTrack.extInfo.kernelInfo.ratio; | ||
| 41 | + parsed->data.runtimeTrack.kernelInfo.schedMode = compact->data.runtimeTrack.extInfo.kernelInfo.schedMode; | ||
| 42 | + parsed->data.runtimeTrack.simtKernelInfo.argsSize = compact->data.runtimeTrack.extInfo.simtKernelInfo.argsSize; | ||
| 43 | + parsed->data.runtimeTrack.simtKernelInfo.blockDim = compact->data.runtimeTrack.extInfo.simtKernelInfo.blockDim; | ||
| 44 | + parsed->data.runtimeTrack.simtKernelInfo.gridDim = compact->data.runtimeTrack.extInfo.simtKernelInfo.gridDim; | ||
| 45 | + parsed->data.runtimeTrack.simtKernelInfo.schedMode = compact->data.runtimeTrack.extInfo.simtKernelInfo.schedMode; | ||
| 46 | + parsed->data.runtimeTrack.modelInfo.modelId = compact->data.runtimeTrack.extInfo.modelInfo.modelId; | ||
| 47 | + parsed->data.runtimeTrack.eventInfo.key = compact->data.runtimeTrack.extInfo.eventInfo.key; | ||
| 48 | + parsed->data.runtimeTrack.notifyInfo.key = compact->data.runtimeTrack.extInfo.notifyInfo.key; | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +void AdapterRuntimeTrackV2(const MsprofCompactInfo* compact, ParserCompactInfo* parsed) | ||
| 52 | +{ | ||
| 53 | + parsed->data.runtimeTrack.deviceId = compact->data.runtimeTrackV2.deviceId; | ||
| 54 | + parsed->data.runtimeTrack.streamId = compact->data.runtimeTrackV2.streamId; | ||
| 55 | + parsed->data.runtimeTrack.taskId = compact->data.runtimeTrackV2.taskId; | ||
| 56 | + parsed->data.runtimeTrack.taskType = compact->data.runtimeTrackV2.taskType; | ||
| 57 | + parsed->data.runtimeTrack.kernelName = compact->data.runtimeTrackV2.kernelName; | ||
| 58 | + parsed->data.runtimeTrack.kernelInfo.argsSize = compact->data.runtimeTrackV2.extInfo.kernelInfo.argsSize; | ||
| 59 | + parsed->data.runtimeTrack.kernelInfo.numBlocks = compact->data.runtimeTrackV2.extInfo.kernelInfo.numBlocks; | ||
| 60 | + parsed->data.runtimeTrack.kernelInfo.ratio = compact->data.runtimeTrackV2.extInfo.kernelInfo.ratio; | ||
| 61 | + parsed->data.runtimeTrack.kernelInfo.schedMode = compact->data.runtimeTrackV2.extInfo.kernelInfo.schedMode; | ||
| 62 | + parsed->data.runtimeTrack.simtKernelInfo.argsSize = compact->data.runtimeTrackV2.extInfo.simtKernelInfo.argsSize; | ||
| 63 | + parsed->data.runtimeTrack.simtKernelInfo.blockDim = compact->data.runtimeTrackV2.extInfo.simtKernelInfo.blockDim; | ||
| 64 | + parsed->data.runtimeTrack.simtKernelInfo.gridDim = compact->data.runtimeTrackV2.extInfo.simtKernelInfo.gridDim; | ||
| 65 | + parsed->data.runtimeTrack.simtKernelInfo.schedMode = compact->data.runtimeTrackV2.extInfo.simtKernelInfo.schedMode; | ||
| 66 | + parsed->data.runtimeTrack.modelInfo.modelId = compact->data.runtimeTrackV2.extInfo.modelInfo.modelId; | ||
| 67 | + parsed->data.runtimeTrack.eventInfo.key = compact->data.runtimeTrackV2.extInfo.eventInfo.key; | ||
| 68 | + parsed->data.runtimeTrack.notifyInfo.key = compact->data.runtimeTrackV2.extInfo.notifyInfo.key; | ||
| 69 | +} | ||
| 70 | +} // namespace | ||
| 71 | + | ||
| 72 | +bool ParserCompactInfoAdapter::AdapterCompactInfo(const MsprofCompactInfo* compact, ParserCompactInfo* parsed, | ||
C 【review】【编码】适配器公共方法入口缺少参数判空
![]() ![]() | |||
| 73 | + CompactInfoFormat parserType) | ||
| 74 | +{ | ||
| 75 | + if (compact == nullptr || parsed == nullptr) | ||
| 76 | + { | ||
| 77 | + ERROR("adapter compactInfo data failed."); | ||
| 78 | + return false; | ||
| 79 | + } | ||
| 80 | + parsed->magicNumber = compact->magicNumber; | ||
| 81 | + parsed->level = compact->level; | ||
| 82 | + parsed->type = compact->type; | ||
| 83 | + parsed->threadId = compact->threadId; | ||
| 84 | + parsed->dataLen = compact->dataLen; | ||
| 85 | + parsed->timeStamp = compact->timeStamp; | ||
| 86 | + switch (parserType) | ||
| 87 | + { | ||
| 88 | + case CompactInfoFormat::DPU_TRACK_TYPE: | ||
| 89 | + AdapterDpuTrack(compact, parsed); | ||
| 90 | + return true; | ||
| 91 | + case CompactInfoFormat::NODE_BASIC_INFO_TYPE: | ||
| 92 | + AdapterNodeBasicInfo(compact, parsed); | ||
| 93 | + return true; | ||
| 94 | + case CompactInfoFormat::ATTR_INFO_TYPE: | ||
| 95 | + AdapterAttrInfo(compact, parsed); | ||
| 96 | + return true; | ||
| 97 | + case CompactInfoFormat::HCCL_OP_INFO_TYPE: | ||
| 98 | + AdapterHcclopInfo(compact, parsed); | ||
| 99 | + return true; | ||
| 100 | + case CompactInfoFormat::MEMCPY_INFO_TYPE: | ||
| 101 | + AdapterMemcpyInfo(compact, parsed); | ||
| 102 | + return true; | ||
| 103 | + default: | ||
| 104 | + ERROR("Unsupported CompactInfo format: %.", static_cast<uint32_t>(parserType)); | ||
| 105 | + return false; | ||
| 106 | + } | ||
| 107 | +} | ||
| 108 | + | ||
| 109 | +bool ParserCompactInfoAdapter::AdapterRuntimeTrack(const MsprofCompactInfo* compact, RuntimeTrackFormat format, | ||
| 110 | + ParserCompactInfo* parsed) | ||
| 111 | +{ | ||
| 112 | + if (compact == nullptr || parsed == nullptr) | ||
| 113 | + { | ||
| 114 | + ERROR("adapter runtimeTrack data failed."); | ||
| 115 | + return false; | ||
| 116 | + } | ||
| 117 | + parsed->magicNumber = compact->magicNumber; | ||
| 118 | + parsed->level = compact->level; | ||
| 119 | + parsed->type = compact->type; | ||
| 120 | + parsed->threadId = compact->threadId; | ||
| 121 | + parsed->dataLen = compact->dataLen; | ||
| 122 | + parsed->timeStamp = compact->timeStamp; | ||
| 123 | + switch (format) | ||
| 124 | + { | ||
| 125 | + case RuntimeTrackFormat::V1: | ||
| 126 | + AdapterRuntimeTrackV1(compact, parsed); | ||
| 127 | + return true; | ||
| 128 | + case RuntimeTrackFormat::V2: | ||
| 129 | + AdapterRuntimeTrackV2(compact, parsed); | ||
| 130 | + return true; | ||
| 131 | + default: | ||
| 132 | + ERROR("Unsupported runtime track format: %.", static_cast<uint32_t>(format)); | ||
| 133 | + return false; | ||
| 134 | + } | ||
| 135 | +} | ||
| 136 | + | ||
| 137 | +bool ParserCompactInfoAdapter::AdapterCaptureStreamInfo(const MsprofCompactInfo* compact, CaptureStreamFormat format, | ||
| 138 | + ParserCompactInfo* parsed) | ||
| 139 | +{ | ||
| 140 | + if (compact == nullptr || parsed == nullptr) | ||
| 141 | + { | ||
| 142 | + ERROR("adapter captureStreamInfo data failed."); | ||
| 143 | + return false; | ||
| 144 | + } | ||
| 145 | + parsed->magicNumber = compact->magicNumber; | ||
| 146 | + parsed->level = compact->level; | ||
| 147 | + parsed->type = compact->type; | ||
| 148 | + parsed->threadId = compact->threadId; | ||
| 149 | + parsed->dataLen = compact->dataLen; | ||
| 150 | + parsed->timeStamp = compact->timeStamp; | ||
| 151 | + switch (format) | ||
| 152 | + { | ||
| 153 | + case CaptureStreamFormat::V1: | ||
| 154 | + parsed->data.captureStreamInfo.deviceId = compact->data.captureStreamInfo.deviceId; | ||
| 155 | + parsed->data.captureStreamInfo.captureStatus = compact->data.captureStreamInfo.captureStatus; | ||
| 156 | + parsed->data.captureStreamInfo.streamId = compact->data.captureStreamInfo.modelStreamId; | ||
| 157 | + parsed->data.captureStreamInfo.originalStreamId = compact->data.captureStreamInfo.originalStreamId; | ||
| 158 | + parsed->data.captureStreamInfo.modelId = compact->data.captureStreamInfo.modelId; | ||
| 159 | + return true; | ||
| 160 | + case CaptureStreamFormat::V2: | ||
| 161 | + parsed->data.captureStreamInfo.deviceId = compact->data.captureStreamInfoV2.deviceId; | ||
| 162 | + parsed->data.captureStreamInfo.captureStatus = compact->data.captureStreamInfoV2.captureStatus; | ||
| 163 | + parsed->data.captureStreamInfo.streamId = compact->data.captureStreamInfoV2.streamId; | ||
| 164 | + parsed->data.captureStreamInfo.originalStreamId = compact->data.captureStreamInfoV2.originalStreamId; | ||
| 165 | + parsed->data.captureStreamInfo.modelId = compact->data.captureStreamInfoV2.modelId; | ||
| 166 | + return true; | ||
| 167 | + default: | ||
| 168 | + ERROR("Unsupported capture stream format: %.", static_cast<uint32_t>(format)); | ||
| 169 | + return false; | ||
| 170 | + } | ||
| 171 | +} | ||
| 172 | + | ||
| 173 | +void ParserCompactInfoAdapter::AdapterDpuTrack(const MsprofCompactInfo* compact, ParserCompactInfo* parsed) | ||
| 174 | +{ | ||
| 175 | + parsed->data.dpuTrack.deviceId = compact->data.dpuTrack.deviceId; | ||
| 176 | + parsed->data.dpuTrack.streamId = compact->data.dpuTrack.streamId; | ||
| 177 | + parsed->data.dpuTrack.taskId = compact->data.dpuTrack.taskId; | ||
| 178 | + parsed->data.dpuTrack.taskType = compact->data.dpuTrack.taskType; | ||
| 179 | + parsed->data.dpuTrack.res = compact->data.dpuTrack.res; | ||
| 180 | + parsed->data.dpuTrack.startTime = compact->data.dpuTrack.startTime; | ||
| 181 | +} | ||
| 182 | + | ||
| 183 | +void ParserCompactInfoAdapter::AdapterNodeBasicInfo(const MsprofCompactInfo* compact, ParserCompactInfo* parsed) | ||
| 184 | +{ | ||
| 185 | + parsed->data.nodeBasicInfo.opName = compact->data.nodeBasicInfo.opName; | ||
| 186 | + parsed->data.nodeBasicInfo.taskType = compact->data.nodeBasicInfo.taskType; | ||
| 187 | + parsed->data.nodeBasicInfo.opType = compact->data.nodeBasicInfo.opType; | ||
| 188 | + parsed->data.nodeBasicInfo.blockNum = compact->data.nodeBasicInfo.blockNum; | ||
| 189 | + parsed->data.nodeBasicInfo.opFlag = compact->data.nodeBasicInfo.opFlag; | ||
| 190 | + parsed->data.nodeBasicInfo.opState = compact->data.nodeBasicInfo.opState; | ||
| 191 | +} | ||
| 192 | + | ||
| 193 | +void ParserCompactInfoAdapter::AdapterAttrInfo(const MsprofCompactInfo* compact, ParserCompactInfo* parsed) | ||
| 194 | +{ | ||
| 195 | + parsed->data.nodeAttrInfo.opName = compact->data.nodeAttrInfo.opName; | ||
| 196 | + parsed->data.nodeAttrInfo.attrType = compact->data.nodeAttrInfo.attrType; | ||
| 197 | + parsed->data.nodeAttrInfo.hashId = compact->data.nodeAttrInfo.hashId; | ||
| 198 | +} | ||
| 199 | + | ||
| 200 | +void ParserCompactInfoAdapter::AdapterHcclopInfo(const MsprofCompactInfo* compact, ParserCompactInfo* parsed) | ||
| 201 | +{ | ||
| 202 | + parsed->data.hcclopInfo.relay = compact->data.hcclopInfo.relay; | ||
| 203 | + parsed->data.hcclopInfo.retry = compact->data.hcclopInfo.retry; | ||
| 204 | + parsed->data.hcclopInfo.dataType = compact->data.hcclopInfo.dataType; | ||
| 205 | + parsed->data.hcclopInfo.algType = compact->data.hcclopInfo.algType; | ||
| 206 | + parsed->data.hcclopInfo.count = compact->data.hcclopInfo.count; | ||
| 207 | + parsed->data.hcclopInfo.groupName = compact->data.hcclopInfo.groupName; | ||
| 208 | +} | ||
| 209 | + | ||
| 210 | +void ParserCompactInfoAdapter::AdapterMemcpyInfo(const MsprofCompactInfo* compact, ParserCompactInfo* parsed) | ||
| 211 | +{ | ||
| 212 | + parsed->data.memcpyInfo.dataSize = compact->data.memcpyInfo.dataSize; | ||
| 213 | + parsed->data.memcpyInfo.maxSize = compact->data.memcpyInfo.maxSize; | ||
| 214 | + parsed->data.memcpyInfo.memcpyDirection = compact->data.memcpyInfo.memcpyDirection; | ||
| 215 | +} | ||
| 216 | + | ||
| 217 | +bool ParserApiAdapter::AdapterApi(const MsprofApi* apiData, ParserApi* parsed) | ||
| 218 | +{ | ||
| 219 | + if (apiData == nullptr || parsed == nullptr) | ||
| 220 | + { | ||
| 221 | + ERROR("adapter api data failed."); | ||
| 222 | + return false; | ||
| 223 | + } | ||
| 224 | + parsed->magicNumber = apiData->magicNumber; | ||
| 225 | + parsed->level = apiData->level; | ||
| 226 | + parsed->itemId = apiData->itemId; | ||
| 227 | + parsed->endTime = apiData->endTime; | ||
| 228 | + parsed->beginTime = apiData->beginTime; | ||
| 229 | + parsed->threadId = apiData->threadId; | ||
| 230 | + parsed->type = apiData->type; | ||
| 231 | + return true; | ||
| 232 | +} | ||
| 233 | + | ||
| 234 | +bool ParserAdditionalInfoAdapter::AdapterAdditionalInfo(MsprofAdditionalInfo* addition, ParserAdditionalInfo* parsed, | ||
| 235 | + AdditionalInfoFormat parserType) | ||
| 236 | +{ | ||
| 237 | + if (addition == nullptr || parsed == nullptr) | ||
| 238 | + { | ||
| 239 | + ERROR("adapter additionalInfo data failed."); | ||
| 240 | + return false; | ||
| 241 | + } | ||
| 242 | + parsed->magicNumber = addition->magicNumber; | ||
| 243 | + parsed->level = addition->level; | ||
| 244 | + parsed->type = addition->type; | ||
| 245 | + parsed->threadId = addition->threadId; | ||
| 246 | + parsed->dataLen = addition->dataLen; | ||
| 247 | + parsed->timeStamp = addition->timeStamp; | ||
| 248 | + switch (parserType) | ||
| 249 | + { | ||
| 250 | + case AdditionalInfoFormat::CONTEXT_ID_INFO_TYPE: | ||
| 251 | + AdapterContextIdInfo(addition, parsed); | ||
| 252 | + return true; | ||
| 253 | + case AdditionalInfoFormat::FUSION_OP_INFO_TYPE: | ||
| 254 | + AdapterFusionOpInfo(addition, parsed); | ||
| 255 | + return true; | ||
| 256 | + case AdditionalInfoFormat::GRAPH_ID_TYPE: | ||
| 257 | + return AdapterGraphId(addition, parsed); | ||
| 258 | + case AdditionalInfoFormat::HCCL_INFO_TYPE: | ||
| 259 | + AdapterHcclInfo(addition, parsed); | ||
| 260 | + return true; | ||
| 261 | + case AdditionalInfoFormat::MULTI_THREAD_TYPE: | ||
| 262 | + AdapterMultiThread(addition, parsed); | ||
| 263 | + return true; | ||
| 264 | + default: | ||
| 265 | + ERROR("Unsupported Additional Info: %.", static_cast<uint32_t>(parserType)); | ||
| 266 | + return false; | ||
| 267 | + } | ||
| 268 | +} | ||
| 269 | + | ||
| 270 | +void ParserAdditionalInfoAdapter::AdapterContextIdInfo(const MsprofAdditionalInfo* addition, | ||
| 271 | + ParserAdditionalInfo* parsed) | ||
| 272 | +{ | ||
| 273 | + parsed->contextIdInfo.opName = addition->contextIdInfo.opName; | ||
| 274 | + parsed->contextIdInfo.ctxIdNum = addition->contextIdInfo.ctxIdNum; | ||
| 275 | + uint32_t ctxIdNum = parsed->contextIdInfo.ctxIdNum; | ||
| 276 | + if (ctxIdNum > MSPROF_CTX_ID_MAX_NUM) | ||
| 277 | + { | ||
| 278 | + ctxIdNum = MSPROF_CTX_ID_MAX_NUM; | ||
| 279 | + } | ||
| 280 | + for (uint32_t i = 0; i < ctxIdNum; i++) | ||
| 281 | + { | ||
| 282 | + parsed->contextIdInfo.ctxIds[i] = addition->contextIdInfo.ctxIds[i]; | ||
| 283 | + } | ||
| 284 | +} | ||
| 285 | + | ||
| 286 | +void ParserAdditionalInfoAdapter::AdapterFusionOpInfo(const MsprofAdditionalInfo* addition, | ||
| 287 | + ParserAdditionalInfo* parsed) | ||
| 288 | +{ | ||
| 289 | + parsed->fusionOpInfo.opName = addition->fusionOpInfo.opName; | ||
| 290 | + parsed->fusionOpInfo.fusionOpNum = addition->fusionOpInfo.fusionOpNum; | ||
| 291 | + parsed->fusionOpInfo.inputMemsize = addition->fusionOpInfo.inputMemsize; | ||
| 292 | + parsed->fusionOpInfo.outputMemsize = addition->fusionOpInfo.outputMemsize; | ||
| 293 | + parsed->fusionOpInfo.weightMemSize = addition->fusionOpInfo.weightMemSize; | ||
| 294 | + parsed->fusionOpInfo.workspaceMemSize = addition->fusionOpInfo.workspaceMemSize; | ||
| 295 | + parsed->fusionOpInfo.totalMemSize = addition->fusionOpInfo.totalMemSize; | ||
| 296 | + uint32_t opNum = parsed->fusionOpInfo.fusionOpNum; | ||
| 297 | + if (opNum > MSPROF_GE_FUSION_OP_NUM) | ||
| 298 | + { | ||
| 299 | + opNum = MSPROF_GE_FUSION_OP_NUM; | ||
| 300 | + } | ||
| 301 | + for (uint32_t i = 0; i < opNum; i++) | ||
| 302 | + { | ||
| 303 | + parsed->fusionOpInfo.fusionOpId[i] = addition->fusionOpInfo.fusionOpId[i]; | ||
| 304 | + } | ||
| 305 | +} | ||
| 306 | + | ||
| 307 | +bool ParserAdditionalInfoAdapter::AdapterGraphId(MsprofAdditionalInfo* addition, ParserAdditionalInfo* parsed) | ||
| 308 | +{ | ||
| 309 | + if (addition->data == nullptr) | ||
| 310 | + { | ||
| 311 | + ERROR("covert Graph id info data failed."); | ||
| 312 | + return false; | ||
| 313 | + } | ||
| 314 | + auto curr = ReinterpretConvert<MsprofGraphIdInfo*>(addition->data); | ||
[review] 问题: MapGraphId 直接将 addition->data 通过 ReinterpretConvert 转换为 MsprofGraphIdInfo *,随后立即解引用,没有校验 data 是否为空,也没有校验 dataLen 是否至少达到 sizeof(MsprofGraphIdInfo)。 影响: 输入数据异常、截断或协议版本不匹配时,可能发生非法内存访问、越界读取,严重时导致解析进程崩溃。 ![]() ![]() | |||
| 315 | + parsed->graphIdInfo.modelName = curr->modelName; | ||
| 316 | + parsed->graphIdInfo.graphId = curr->graphId; | ||
| 317 | + parsed->graphIdInfo.modelId = curr->modelId; | ||
| 318 | + return true; | ||
| 319 | +} | ||
| 320 | + | ||
| 321 | +void ParserAdditionalInfoAdapter::AdapterHcclInfo(const MsprofAdditionalInfo* addition, ParserAdditionalInfo* parsed) | ||
| 322 | +{ | ||
| 323 | + parsed->hcclInfo.itemId = addition->hcclInfo.itemId; | ||
| 324 | + parsed->hcclInfo.cclTag = addition->hcclInfo.cclTag; | ||
| 325 | + parsed->hcclInfo.groupName = addition->hcclInfo.groupName; | ||
| 326 | + parsed->hcclInfo.localRank = addition->hcclInfo.localRank; | ||
| 327 | + parsed->hcclInfo.remoteRank = addition->hcclInfo.remoteRank; | ||
| 328 | + parsed->hcclInfo.rankSize = addition->hcclInfo.rankSize; | ||
| 329 | + parsed->hcclInfo.workFlowMode = addition->hcclInfo.workFlowMode; | ||
| 330 | + parsed->hcclInfo.planeID = addition->hcclInfo.planeID; | ||
| 331 | + parsed->hcclInfo.ctxID = addition->hcclInfo.ctxID; | ||
| 332 | + parsed->hcclInfo.notifyID = addition->hcclInfo.notifyID; | ||
| 333 | + parsed->hcclInfo.stage = addition->hcclInfo.stage; | ||
| 334 | + parsed->hcclInfo.role = addition->hcclInfo.role; | ||
| 335 | + parsed->hcclInfo.durationEstimated = addition->hcclInfo.durationEstimated; | ||
| 336 | + parsed->hcclInfo.srcAddr = addition->hcclInfo.srcAddr; | ||
| 337 | + parsed->hcclInfo.dstAddr = addition->hcclInfo.dstAddr; | ||
| 338 | + parsed->hcclInfo.dataSize = addition->hcclInfo.dataSize; | ||
| 339 | + parsed->hcclInfo.opType = addition->hcclInfo.opType; | ||
| 340 | + parsed->hcclInfo.dataType = addition->hcclInfo.dataType; | ||
| 341 | + parsed->hcclInfo.linkType = addition->hcclInfo.linkType; | ||
| 342 | + parsed->hcclInfo.transportType = addition->hcclInfo.transportType; | ||
| 343 | + parsed->hcclInfo.rdmaType = addition->hcclInfo.rdmaType; | ||
| 344 | + parsed->hcclInfo.reserve2 = addition->hcclInfo.reserve2; | ||
| 345 | +} | ||
| 346 | + | ||
| 347 | +void ParserAdditionalInfoAdapter::AdapterMultiThread(const MsprofAdditionalInfo* addition, ParserAdditionalInfo* parsed) | ||
| 348 | +{ | ||
| 349 | + parsed->multiThread.threadNum = addition->multiThread.threadNum; | ||
| 350 | + uint32_t threadNum = parsed->multiThread.threadNum; | ||
| 351 | + if (threadNum > MSPROF_MULTI_THREAD_MAX_NUM) | ||
| 352 | + { | ||
| 353 | + threadNum = MSPROF_MULTI_THREAD_MAX_NUM; | ||
| 354 | + } | ||
| 355 | + for (uint32_t i = 0; i < threadNum; i++) | ||
| 356 | + { | ||
| 357 | + parsed->multiThread.threadId[i] = addition->multiThread.threadId[i]; | ||
| 358 | + } | ||
| 359 | +} | ||
| 360 | + | ||
| 361 | +bool ParserAicpuAdapter::AdapterNode(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData) | ||
| 362 | +{ | ||
| 363 | + if (additionalData == nullptr || aicpuData == nullptr) | ||
| 364 | + { | ||
| 365 | + ERROR("adapter node data failed."); | ||
| 366 | + return false; | ||
| 367 | + } | ||
| 368 | + aicpuData->node.streamId = additionalData->aicpuNode.streamId; | ||
| 369 | + aicpuData->node.taskId = additionalData->aicpuNode.taskId; | ||
| 370 | + aicpuData->node.rev = additionalData->aicpuNode.rev; | ||
| 371 | + aicpuData->node.runStartTime = additionalData->aicpuNode.runStartTime; | ||
| 372 | + aicpuData->node.runStartTick = additionalData->aicpuNode.runStartTick; | ||
| 373 | + aicpuData->node.computeStartTime = additionalData->aicpuNode.computeStartTime; | ||
| 374 | + aicpuData->node.memcpyStartTime = additionalData->aicpuNode.memcpyStartTime; | ||
| 375 | + aicpuData->node.memcpyEndTime = additionalData->aicpuNode.memcpyEndTime; | ||
| 376 | + aicpuData->node.runEndTime = additionalData->aicpuNode.runEndTime; | ||
| 377 | + aicpuData->node.runEndTick = additionalData->aicpuNode.runEndTick; | ||
| 378 | + aicpuData->node.threadId = additionalData->aicpuNode.threadId; | ||
| 379 | + aicpuData->node.deviceId = additionalData->aicpuNode.deviceId; | ||
| 380 | + aicpuData->node.submitTick = additionalData->aicpuNode.submitTick; | ||
| 381 | + aicpuData->node.scheduleTick = additionalData->aicpuNode.scheduleTick; | ||
| 382 | + aicpuData->node.tickBeforeRun = additionalData->aicpuNode.tickBeforeRun; | ||
| 383 | + aicpuData->node.tickAfterRun = additionalData->aicpuNode.tickAfterRun; | ||
| 384 | + aicpuData->node.kernelType = additionalData->aicpuNode.kernelType; | ||
| 385 | + aicpuData->node.dispatchTime = additionalData->aicpuNode.dispatchTime; | ||
| 386 | + aicpuData->node.totalTime = additionalData->aicpuNode.totalTime; | ||
| 387 | + aicpuData->node.fftsThreadId = additionalData->aicpuNode.fftsThreadId; | ||
| 388 | + aicpuData->node.version = additionalData->aicpuNode.version; | ||
| 389 | + return true; | ||
| 390 | +} | ||
| 391 | + | ||
| 392 | +bool ParserAicpuAdapter::AdapterModel(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData) | ||
| 393 | +{ | ||
| 394 | + if (additionalData == nullptr || aicpuData == nullptr) | ||
| 395 | + { | ||
| 396 | + ERROR("adapter model data failed."); | ||
| 397 | + return false; | ||
| 398 | + } | ||
| 399 | + aicpuData->model.indexId = additionalData->aicpuModel.indexId; | ||
| 400 | + aicpuData->model.modelId = additionalData->aicpuModel.modelId; | ||
| 401 | + aicpuData->model.tagId = additionalData->aicpuModel.tagId; | ||
| 402 | + aicpuData->model.rsv1 = additionalData->aicpuModel.rsv1; | ||
| 403 | + aicpuData->model.eventId = additionalData->aicpuModel.eventId; | ||
| 404 | + return true; | ||
| 405 | +} | ||
| 406 | + | ||
| 407 | +bool ParserAicpuAdapter::AdapterDp(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData) | ||
| 408 | +{ | ||
| 409 | + if (additionalData == nullptr || aicpuData == nullptr) | ||
| 410 | + { | ||
| 411 | + ERROR("adapter dp data failed."); | ||
| 412 | + return false; | ||
| 413 | + } | ||
| 414 | + errno_t res = memcpy_s(aicpuData->dp.action, sizeof(aicpuData->dp.action), additionalData->aicpuDp.action, | ||
[review] 问题: MapDp 内部的 memcpy_s 可能失败,但函数返回类型为 void。失败后只是记录日志并 return,调用方无法知道映射失败。 影响: aicpuData->dp 可能处于部分初始化状态,但上层仍可能把该对象当成解析成功的数据继续处理,产生脏数据或错误持久化。 ![]() ![]() | |||
| 415 | + sizeof(additionalData->aicpuDp.action)); | ||
| 416 | + errno_t resOst = memcpy_s(aicpuData->dp.source, sizeof(aicpuData->dp.source), additionalData->aicpuDp.source, | ||
| 417 | + sizeof(additionalData->aicpuDp.source)); | ||
| 418 | + if (res != EOK || resOst != EOK) | ||
| 419 | + { | ||
| 420 | + ERROR("memcpy aicpuDp data failed!"); | ||
| 421 | + return false; | ||
| 422 | + } | ||
| 423 | + aicpuData->dp.index = additionalData->aicpuDp.index; | ||
| 424 | + aicpuData->dp.size = additionalData->aicpuDp.size; | ||
| 425 | + return true; | ||
| 426 | +} | ||
| 427 | + | ||
| 428 | +bool ParserAicpuAdapter::AdapterMi(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData) | ||
| 429 | +{ | ||
| 430 | + if (additionalData == nullptr || aicpuData == nullptr) | ||
| 431 | + { | ||
| 432 | + ERROR("adapter mi data failed."); | ||
| 433 | + return false; | ||
| 434 | + } | ||
| 435 | + aicpuData->mi.nodeTag = additionalData->aicpuMi.nodeTag; | ||
| 436 | + aicpuData->mi.reserve = additionalData->aicpuMi.reserve; | ||
| 437 | + aicpuData->mi.queueSize = additionalData->aicpuMi.queueSize; | ||
| 438 | + aicpuData->mi.runStartTime = additionalData->aicpuMi.runStartTime; | ||
| 439 | + aicpuData->mi.runEndTime = additionalData->aicpuMi.runEndTime; | ||
| 440 | + return true; | ||
| 441 | +} | ||
| 442 | + | ||
| 443 | +bool ParserAicpuAdapter::AdapterCommTurn(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData) | ||
| 444 | +{ | ||
| 445 | + if (additionalData == nullptr || aicpuData == nullptr) | ||
| 446 | + { | ||
| 447 | + ERROR("adapter commTurn data failed."); | ||
| 448 | + return false; | ||
| 449 | + } | ||
| 450 | + aicpuData->commTurn.serverStartTime = additionalData->commTurn.serverStartTime; | ||
| 451 | + aicpuData->commTurn.waitMsgStartTime = additionalData->commTurn.waitMsgStartTime; | ||
| 452 | + aicpuData->commTurn.kfcAlgExeStartTime = additionalData->commTurn.kfcAlgExeStartTime; | ||
| 453 | + aicpuData->commTurn.sendTaskStartTime = additionalData->commTurn.sendTaskStartTime; | ||
| 454 | + aicpuData->commTurn.sendSqeFinishTime = additionalData->commTurn.sendSqeFinishTime; | ||
| 455 | + aicpuData->commTurn.rtsqExeEndTime = additionalData->commTurn.rtsqExeEndTime; | ||
| 456 | + aicpuData->commTurn.serverEndTime = additionalData->commTurn.serverEndTime; | ||
| 457 | + aicpuData->commTurn.dataLen = additionalData->commTurn.dataLen; | ||
| 458 | + aicpuData->commTurn.deviceId = additionalData->commTurn.deviceId; | ||
| 459 | + aicpuData->commTurn.streamId = additionalData->commTurn.streamId; | ||
| 460 | + aicpuData->commTurn.taskId = additionalData->commTurn.taskId; | ||
| 461 | + aicpuData->commTurn.version = additionalData->commTurn.version; | ||
| 462 | + aicpuData->commTurn.commTurn = additionalData->commTurn.commTurn; | ||
| 463 | + aicpuData->commTurn.currentTurn = additionalData->commTurn.currentTurn; | ||
| 464 | + return true; | ||
| 465 | +} | ||
| 466 | + | ||
| 467 | +bool ParserAicpuAdapter::AdapterComputeTurn(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData) | ||
| 468 | +{ | ||
| 469 | + if (additionalData == nullptr || aicpuData == nullptr) | ||
| 470 | + { | ||
| 471 | + ERROR("adapter computeTurn data failed."); | ||
| 472 | + return false; | ||
| 473 | + } | ||
| 474 | + aicpuData->computeTurn.waitComputeStartTime = additionalData->computeTurn.waitComputeStartTime; | ||
| 475 | + aicpuData->computeTurn.computeStartTime = additionalData->computeTurn.computeStartTime; | ||
| 476 | + aicpuData->computeTurn.computeExeEndTime = additionalData->computeTurn.computeExeEndTime; | ||
| 477 | + aicpuData->computeTurn.dataLen = additionalData->computeTurn.dataLen; | ||
| 478 | + aicpuData->computeTurn.deviceId = additionalData->computeTurn.deviceId; | ||
| 479 | + aicpuData->computeTurn.streamId = additionalData->computeTurn.streamId; | ||
| 480 | + aicpuData->computeTurn.taskId = additionalData->computeTurn.taskId; | ||
| 481 | + aicpuData->computeTurn.version = additionalData->computeTurn.version; | ||
| 482 | + aicpuData->computeTurn.computeTurn = additionalData->computeTurn.computeTurn; | ||
| 483 | + aicpuData->computeTurn.currentTurn = additionalData->computeTurn.currentTurn; | ||
| 484 | + return true; | ||
| 485 | +} | ||
| 486 | + | ||
| 487 | +bool ParserAicpuAdapter::AdapterOpInfo(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData) | ||
| 488 | +{ | ||
| 489 | + if (additionalData == nullptr || aicpuData == nullptr) | ||
| 490 | + { | ||
| 491 | + ERROR("adapter opInfo data failed."); | ||
| 492 | + return false; | ||
| 493 | + } | ||
| 494 | + aicpuData->opInfo.relay = additionalData->opInfo.relay; | ||
| 495 | + aicpuData->opInfo.retry = additionalData->opInfo.retry; | ||
| 496 | + aicpuData->opInfo.dataType = additionalData->opInfo.dataType; | ||
| 497 | + aicpuData->opInfo.algType = additionalData->opInfo.algType; | ||
| 498 | + aicpuData->opInfo.count = additionalData->opInfo.count; | ||
| 499 | + aicpuData->opInfo.groupName = additionalData->opInfo.groupName; | ||
| 500 | + aicpuData->opInfo.rankSize = additionalData->opInfo.rankSize; | ||
| 501 | + aicpuData->opInfo.streamId = additionalData->opInfo.streamId; | ||
| 502 | + aicpuData->opInfo.taskId = additionalData->opInfo.taskId; | ||
| 503 | + return true; | ||
| 504 | +} | ||
| 505 | + | ||
| 506 | +bool ParserAicpuAdapter::AdapterFlipTask(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData) | ||
| 507 | +{ | ||
| 508 | + if (additionalData == nullptr || aicpuData == nullptr) | ||
| 509 | + { | ||
| 510 | + ERROR("adapter flip task data failed."); | ||
| 511 | + return false; | ||
| 512 | + } | ||
| 513 | + aicpuData->flipTask.streamId = additionalData->flipTask.streamId; | ||
| 514 | + aicpuData->flipTask.taskId = additionalData->flipTask.taskId; | ||
| 515 | + aicpuData->flipTask.flipNum = additionalData->flipTask.flipNum; | ||
| 516 | + return true; | ||
| 517 | +} | ||
| 518 | + | ||
| 519 | +bool ParserAicpuAdapter::AdapterMainStreamTask(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData) | ||
| 520 | +{ | ||
| 521 | + if (additionalData == nullptr || aicpuData == nullptr) | ||
| 522 | + { | ||
| 523 | + ERROR("adapter mainStream task data failed."); | ||
| 524 | + return false; | ||
| 525 | + } | ||
| 526 | + aicpuData->mainStreamTask.aicpuStreamId = additionalData->mainStreamTask.aicpuStreamId; | ||
| 527 | + aicpuData->mainStreamTask.aicpuTaskId = additionalData->mainStreamTask.aicpuTaskId; | ||
| 528 | + aicpuData->mainStreamTask.streamId = additionalData->mainStreamTask.streamId; | ||
| 529 | + aicpuData->mainStreamTask.taskId = additionalData->mainStreamTask.taskId; | ||
| 530 | + aicpuData->mainStreamTask.type = additionalData->mainStreamTask.type; | ||
| 531 | + return true; | ||
| 532 | +} | ||
| 533 | + | ||
| 534 | +bool ParserAicpuAdapter::AdapterKfcInfos(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData) | ||
| 535 | +{ | ||
| 536 | + if (additionalData == nullptr || aicpuData == nullptr) | ||
| 537 | + { | ||
| 538 | + ERROR("adapter KfcInfo data failed."); | ||
| 539 | + return false; | ||
| 540 | + } | ||
| 541 | + for (uint32_t i = 0; i < KFC_INFOS_NUM; i++) | ||
[review] 问题: KFC_INFOS_NUM 被硬编码为 2,随后直接用于访问源对象和目标对象的 infos[i],没有与两侧数组真实容量建立编译期关联。 影响: 后续协议结构发生调整,例如 infos 从 2 个修改为其他数量时,该常量很容易遗漏修改;如果常量大于数组实际容量,则直接产生越界访问。 ![]() ![]() | |||
| 542 | + { | ||
| 543 | + aicpuData->KfcInfos.infos[i].itemId = additionalData->kfcInfos.infos[i].itemId; | ||
| 544 | + aicpuData->KfcInfos.infos[i].cclTag = additionalData->kfcInfos.infos[i].cclTag; | ||
| 545 | + aicpuData->KfcInfos.infos[i].groupName = additionalData->kfcInfos.infos[i].groupName; | ||
| 546 | + aicpuData->KfcInfos.infos[i].localRank = additionalData->kfcInfos.infos[i].localRank; | ||
| 547 | + aicpuData->KfcInfos.infos[i].remoteRank = additionalData->kfcInfos.infos[i].remoteRank; | ||
| 548 | + aicpuData->KfcInfos.infos[i].rankSize = additionalData->kfcInfos.infos[i].rankSize; | ||
| 549 | + aicpuData->KfcInfos.infos[i].stage = additionalData->kfcInfos.infos[i].stage; | ||
| 550 | + aicpuData->KfcInfos.infos[i].notifyID = additionalData->kfcInfos.infos[i].notifyID; | ||
| 551 | + aicpuData->KfcInfos.infos[i].timeStamp = additionalData->kfcInfos.infos[i].timeStamp; | ||
| 552 | + aicpuData->KfcInfos.infos[i].durationEstimated = additionalData->kfcInfos.infos[i].durationEstimated; | ||
| 553 | + aicpuData->KfcInfos.infos[i].srcAddr = additionalData->kfcInfos.infos[i].srcAddr; | ||
| 554 | + aicpuData->KfcInfos.infos[i].dstAddr = additionalData->kfcInfos.infos[i].dstAddr; | ||
| 555 | + aicpuData->KfcInfos.infos[i].dataSize = additionalData->kfcInfos.infos[i].dataSize; | ||
| 556 | + aicpuData->KfcInfos.infos[i].taskId = additionalData->kfcInfos.infos[i].taskId; | ||
| 557 | + aicpuData->KfcInfos.infos[i].reserve = additionalData->kfcInfos.infos[i].reserve; | ||
| 558 | + aicpuData->KfcInfos.infos[i].streamId = additionalData->kfcInfos.infos[i].streamId; | ||
| 559 | + aicpuData->KfcInfos.infos[i].planeID = additionalData->kfcInfos.infos[i].planeID; | ||
| 560 | + aicpuData->KfcInfos.infos[i].opType = additionalData->kfcInfos.infos[i].opType; | ||
| 561 | + aicpuData->KfcInfos.infos[i].dataType = additionalData->kfcInfos.infos[i].dataType; | ||
| 562 | + aicpuData->KfcInfos.infos[i].linkType = additionalData->kfcInfos.infos[i].linkType; | ||
| 563 | + aicpuData->KfcInfos.infos[i].transportType = additionalData->kfcInfos.infos[i].transportType; | ||
| 564 | + aicpuData->KfcInfos.infos[i].rdmaType = additionalData->kfcInfos.infos[i].rdmaType; | ||
| 565 | + aicpuData->KfcInfos.infos[i].role = additionalData->kfcInfos.infos[i].role; | ||
| 566 | + aicpuData->KfcInfos.infos[i].workFlowMode = additionalData->kfcInfos.infos[i].workFlowMode; | ||
| 567 | + } | ||
| 568 | + return true; | ||
| 569 | +} | ||
| 570 | + | ||
| 571 | +} // namespace Adapter | ||
| 572 | +} // namespace Domain | ||
| 573 | +} // namespace Analysis | ||
| @@ -0,0 +1,84 @@ | |||
| 1 | +/* ------------------------------------------------------------------------- | ||
| 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | + * This file is part of the MindStudio project. | ||
| 4 | + * | ||
| 5 | + * MindStudio is licensed under Mulan PSL v2. | ||
| 6 | + * You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
| 7 | + * You may obtain a copy of Mulan PSL v2 at: | ||
| 8 | + * | ||
| 9 | + * http://license.coscl.org.cn/MulanPSL2 | ||
| 10 | + * | ||
| 11 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
| 12 | + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
| 13 | + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
| 14 | + * See the Mulan PSL v2 for more details. | ||
| 15 | + * -------------------------------------------------------------------------*/ | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
C 【review】【设计】infrastructure 层反向依赖 domain 层
![]() ![]() | |||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +namespace Analysis | ||
| 25 | +{ | ||
| 26 | +namespace Domain | ||
| 27 | +{ | ||
| 28 | +namespace Adapter | ||
| 29 | +{ | ||
| 30 | +using namespace Analysis::Domain; | ||
| 31 | +class ParserCompactInfoAdapter | ||
C 【review】【测试】适配器层(约 565 行新代码)缺少单元测试覆盖
![]() ![]() | |||
| 32 | +{ | ||
| 33 | + public: | ||
| 34 | + static bool AdapterCompactInfo(const MsprofCompactInfo* compact, ParserCompactInfo* parsed, | ||
| 35 | + CompactInfoFormat parserType = CompactInfoFormat::COMPACT_INFO_TYPE); | ||
| 36 | + static bool AdapterRuntimeTrack(const MsprofCompactInfo* compact, RuntimeTrackFormat format, | ||
| 37 | + ParserCompactInfo* parsed); | ||
| 38 | + static bool AdapterCaptureStreamInfo(const MsprofCompactInfo* compact, CaptureStreamFormat format, | ||
| 39 | + ParserCompactInfo* parsed); | ||
| 40 | + static void AdapterDpuTrack(const MsprofCompactInfo* compact, ParserCompactInfo* parsed); | ||
| 41 | + static void AdapterNodeBasicInfo(const MsprofCompactInfo* compact, ParserCompactInfo* parsed); | ||
| 42 | + static void AdapterAttrInfo(const MsprofCompactInfo* compact, ParserCompactInfo* parsed); | ||
| 43 | + static void AdapterHcclopInfo(const MsprofCompactInfo* compact, ParserCompactInfo* parsed); | ||
| 44 | + static void AdapterMemcpyInfo(const MsprofCompactInfo* compact, ParserCompactInfo* parsed); | ||
| 45 | +}; | ||
| 46 | + | ||
| 47 | +class ParserApiAdapter | ||
| 48 | +{ | ||
| 49 | + public: | ||
| 50 | + static bool AdapterApi(const MsprofApi* apiData, ParserApi* parsed); | ||
| 51 | +}; | ||
| 52 | + | ||
| 53 | +class ParserAdditionalInfoAdapter | ||
| 54 | +{ | ||
| 55 | + public: | ||
| 56 | + static bool AdapterAdditionalInfo(MsprofAdditionalInfo* addition, ParserAdditionalInfo* parsed, | ||
| 57 | + AdditionalInfoFormat parserType = AdditionalInfoFormat::ADDITIONAL_INFO_TYPE); | ||
| 58 | + static void AdapterContextIdInfo(const MsprofAdditionalInfo* addition, ParserAdditionalInfo* parsed); | ||
| 59 | + static void AdapterFusionOpInfo(const MsprofAdditionalInfo* addition, ParserAdditionalInfo* parsed); | ||
| 60 | + static bool AdapterGraphId(MsprofAdditionalInfo* addition, ParserAdditionalInfo* parsed); | ||
| 61 | + static void AdapterHcclInfo(const MsprofAdditionalInfo* addition, ParserAdditionalInfo* parsed); | ||
| 62 | + static void AdapterMultiThread(const MsprofAdditionalInfo* addition, ParserAdditionalInfo* parsed); | ||
| 63 | +}; | ||
| 64 | + | ||
| 65 | +class ParserAicpuAdapter | ||
| 66 | +{ | ||
| 67 | + public: | ||
| 68 | + static bool AdapterNode(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData); | ||
| 69 | + static bool AdapterModel(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData); | ||
| 70 | + static bool AdapterDp(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData); | ||
| 71 | + static bool AdapterMi(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData); | ||
| 72 | + static bool AdapterCommTurn(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData); | ||
| 73 | + static bool AdapterComputeTurn(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData); | ||
| 74 | + static bool AdapterOpInfo(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData); | ||
| 75 | + static bool AdapterFlipTask(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData); | ||
| 76 | + static bool AdapterMainStreamTask(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData); | ||
| 77 | + static bool AdapterKfcInfos(const MsprofAdditionalInfo* additionalData, AicpuData* aicpuData); | ||
| 78 | +}; | ||
| 79 | + | ||
| 80 | +} // namespace Adapter | ||
| 81 | +} // namespace Domain | ||
| 82 | +} // namespace Analysis | ||
| 83 | + | ||
| 84 | + | ||
| @@ -131,12 +131,12 @@ class TreeAnalyzer | |||
| 131 | uint8_t isMaster); | 131 | uint8_t isMaster); |
| 132 | 132 | ||
| 133 | // 根据输入参数生成HostTask,该函数纯粹负责HostTask生成 | 133 | // 根据输入参数生成HostTask,该函数纯粹负责HostTask生成 |
| 134 | - std::shared_ptr<HostTask> GenHostTask(const std::shared_ptr<MsprofCompactInfo> &track, | 134 | + std::shared_ptr<HostTask> GenHostTask(const std::shared_ptr<ParserCompactInfo> &track, |
| 135 | - const std::shared_ptr<MsprofApi> &modelApi, | 135 | + const std::shared_ptr<ParserApi> &modelApi, |
| 136 | const std::shared_ptr<Operator> &opPtr, uint32_t ctxId, uint16_t taskType, | 136 | const std::shared_ptr<Operator> &opPtr, uint32_t ctxId, uint16_t taskType, |
| 137 | int64_t connectionId); | 137 | int64_t connectionId); |
| 138 | // 根据输入参数生成HostTask数组 | 138 | // 根据输入参数生成HostTask数组 |
| 139 | - HostTasks GenComputeHostTasks(ComputeOpDescs &ops, const std::shared_ptr<MsprofCompactInfo> &track, | 139 | + HostTasks GenComputeHostTasks(ComputeOpDescs &ops, const std::shared_ptr<ParserCompactInfo> &track, |
| 140 | int64_t connectionId); | 140 | int64_t connectionId); |
| 141 | 141 | ||
| 142 | void UpdateComputeDescForFftsSituation(ComputeOpDescs &descs, const std::shared_ptr<Event> &track); | 142 | void UpdateComputeDescForFftsSituation(ComputeOpDescs &descs, const std::shared_ptr<Event> &track); |
| @@ -17,20 +17,24 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | + | ||
| 20 | 21 | ||
| 21 | 22 | ||
| 22 | - | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 28 | +#include "analysis/csrc/infrastructure/utils/parser_struct.h" |
| 29 | + | ||
| 29 | 30 | ||
| 30 | 31 | ||
| 31 | -namespace Analysis { | 32 | +namespace Analysis |
| 32 | -namespace Domain { | 33 | +{ |
| 33 | -namespace Cann { | 34 | +namespace Domain |
| 35 | +{ | ||
| 36 | +namespace Cann | ||
| 37 | +{ | ||
| 34 | 38 | ||
| 35 | using EventQueue = Analysis::Domain::EventQueue; | 39 | using EventQueue = Analysis::Domain::EventQueue; |
| 36 | using TreeNode = Analysis::Domain::TreeNode; | 40 | using TreeNode = Analysis::Domain::TreeNode; |
| @@ -43,27 +47,29 @@ using ThreadPool = Analysis::Utils::ThreadPool; | |||
| 43 | using EventQueuePair = std::pair<std::shared_ptr<EventQueue>, std::shared_ptr<EventQueue>>; | 47 | using EventQueuePair = std::pair<std::shared_ptr<EventQueue>, std::shared_ptr<EventQueue>>; |
| 44 | 48 | ||
| 45 | // 一个TreeBuilder对象负责将一个threadId的Event数据建成一棵树 | 49 | // 一个TreeBuilder对象负责将一个threadId的Event数据建成一棵树 |
| 46 | -class TreeBuilder { | 50 | +class TreeBuilder |
| 47 | -public: | 51 | +{ |
| 52 | + public: | ||
| 48 | TreeBuilder(std::shared_ptr<CANNWarehouse> &cannWarehouse, const uint32_t threadId) | 53 | TreeBuilder(std::shared_ptr<CANNWarehouse> &cannWarehouse, const uint32_t threadId) |
| 49 | : cannWarehouse_(cannWarehouse), threadId_(threadId) | 54 | : cannWarehouse_(cannWarehouse), threadId_(threadId) |
| 50 | - {} | 55 | + { |
| 56 | + } | ||
| 51 | // 用api和task_track建核心树 | 57 | // 用api和task_track建核心树 |
| 52 | std::shared_ptr<TreeNode> Build(); | 58 | std::shared_ptr<TreeNode> Build(); |
| 53 | // 多线程添加附加Event | 59 | // 多线程添加附加Event |
| 54 | void MultiThreadAddLevelEvents(); | 60 | void MultiThreadAddLevelEvents(); |
| 55 | // 向核心树的Model, Node, Hccl 层节点添加附加Event | 61 | // 向核心树的Model, Node, Hccl 层节点添加附加Event |
| 56 | - bool AddLevelEvents(std::shared_ptr<EventQueue> &events, | 62 | + bool AddLevelEvents(std::shared_ptr<EventQueue> &events, std::vector<std::shared_ptr<TreeNode>> &levelNodes, |
| 57 | - std::vector<std::shared_ptr<TreeNode>> &levelNodes, | ||
| 58 | EventType eventType) const; | 63 | EventType eventType) const; |
| 59 | // 向叶子节点添加Runtime层的event | 64 | // 向叶子节点添加Runtime层的event |
| 60 | - bool AddTaskTrackEvents(std::shared_ptr<TreeNode> &treeNode, | 65 | + bool AddTaskTrackEvents(std::shared_ptr<TreeNode> &treeNode, std::shared_ptr<EventQueue> &events, |
| 61 | - std::shared_ptr<EventQueue> &events, uint16_t depth = 1); | 66 | + uint16_t depth = 1); |
| 62 | // 返回容纳taskTrackEvent的节点 | 67 | // 返回容纳taskTrackEvent的节点 |
| 63 | - std::shared_ptr<TreeNode> MakeDummyNode(const std::shared_ptr<Event>& event); | 68 | + std::shared_ptr<TreeNode> MakeDummyNode(const std::shared_ptr<Event> &event); |
| 64 | // 记录父节点绑定runtime event结果日志 | 69 | // 记录父节点绑定runtime event结果日志 |
| 65 | void LogTreeNode(std::shared_ptr<TreeNode> &treeNode); | 70 | void LogTreeNode(std::shared_ptr<TreeNode> &treeNode); |
| 66 | -private: | 71 | + |
| 72 | + private: | ||
| 67 | // 建树核心逻辑 | 73 | // 建树核心逻辑 |
| 68 | std::shared_ptr<TreeNode> BuildTree(std::shared_ptr<TreeNode>, int depth); | 74 | std::shared_ptr<TreeNode> BuildTree(std::shared_ptr<TreeNode>, int depth); |
| 69 | // 将ctxIdEvents按Level分为Node和HCCL层 | 75 | // 将ctxIdEvents按Level分为Node和HCCL层 |
| @@ -73,7 +79,8 @@ private: | |||
| 73 | std::shared_ptr<TreeNode> GenerateRoot(); | 79 | std::shared_ptr<TreeNode> GenerateRoot(); |
| 74 | static size_t GetEventOffset(size_t idx, std::shared_ptr<Event> &event, | 80 | static size_t GetEventOffset(size_t idx, std::shared_ptr<Event> &event, |
| 75 | std::vector<std::shared_ptr<TreeNode>> &levelNodes, EventType eventType); | 81 | std::vector<std::shared_ptr<TreeNode>> &levelNodes, EventType eventType); |
| 76 | -private: | 82 | + |
| 83 | + private: | ||
| 77 | // 用于建树的Model、Node、HCCL Level的Api Type Events | 84 | // 用于建树的Model、Node、HCCL Level的Api Type Events |
| 78 | std::shared_ptr<EventQueue> kernelEvents_ = nullptr; | 85 | std::shared_ptr<EventQueue> kernelEvents_ = nullptr; |
| 79 | // 包含各个类型的events | 86 | // 包含各个类型的events |
| @@ -87,7 +94,7 @@ private: | |||
| 87 | std::vector<std::shared_ptr<TreeNode>> hcclLevelNodes_; | 94 | std::vector<std::shared_ptr<TreeNode>> hcclLevelNodes_; |
| 88 | std::vector<std::shared_ptr<TreeNode>> runtimeLevelNodes_; | 95 | std::vector<std::shared_ptr<TreeNode>> runtimeLevelNodes_; |
| 89 | }; | 96 | }; |
| 90 | -} // namespace Cann | 97 | +} // namespace Cann |
| 91 | -} // namespace Association | 98 | +} // namespace Domain |
| 92 | -} // namespace Analysis | 99 | +} // namespace Analysis |
| 93 | -#endif // ANALYSIS_ASSOCIATION_CANN_TREE_BUILDER_H | 100 | +#endif // ANALYSIS_ASSOCIATION_CANN_TREE_BUILDER_H |
| @@ -75,15 +75,15 @@ const std::set<std::string> KERNEL_COMPUTE_WHITE_LIST = { | |||
| 75 | KERNEL_AI_CPU_TASK_TYPE, Analysis::Common::KERNEL_SIMT_TASK_TYPE, | 75 | KERNEL_AI_CPU_TASK_TYPE, Analysis::Common::KERNEL_SIMT_TASK_TYPE, |
| 76 | KERNEL_MIX_AIC_TASK_TYPE, KERNEL_MIX_AIV_TASK_TYPE}; | 76 | KERNEL_MIX_AIC_TASK_TYPE, KERNEL_MIX_AIV_TASK_TYPE}; |
| 77 | 77 | ||
| 78 | -uint64_t GetModelId(const std::shared_ptr<MsprofCompactInfo> &track, const std::shared_ptr<MsprofApi> &api, | 78 | +uint64_t GetModelId(const std::shared_ptr<ParserCompactInfo> &track, const std::shared_ptr<ParserApi> &api, |
| 79 | uint16_t deviceId, uint32_t streamId, uint32_t batchId, uint64_t timestamp) | 79 | uint16_t deviceId, uint32_t streamId, uint32_t batchId, uint64_t timestamp) |
| 80 | { | 80 | { |
| 81 | if (track->level == MSPROF_REPORT_RUNTIME_LEVEL) | 81 | if (track->level == MSPROF_REPORT_RUNTIME_LEVEL) |
| 82 | { | 82 | { |
| 83 | - auto taskType = TypeData::GetInstance().Get(MSPROF_REPORT_RUNTIME_LEVEL, track->data.runtimeTrackV2.taskType); | 83 | + auto taskType = TypeData::GetInstance().Get(MSPROF_REPORT_RUNTIME_LEVEL, track->data.runtimeTrack.taskType); |
| 84 | if (taskType == MSPROF_RUNTIME_MODEL_EXECUTE || taskType == MSPROF_RUNTIME_MODEL_WAIT_COMPLETE) | 84 | if (taskType == MSPROF_RUNTIME_MODEL_EXECUTE || taskType == MSPROF_RUNTIME_MODEL_WAIT_COMPLETE) |
| 85 | { | 85 | { |
| 86 | - return track->data.runtimeTrackV2.extInfo.modelInfo.modelId; | 86 | + return track->data.runtimeTrack.modelInfo.modelId; |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | return api != nullptr ? api->itemId | 89 | return api != nullptr ? api->itemId |
| @@ -216,9 +216,9 @@ void TreeAnalyzer::AnalyzeModelNode(const std::shared_ptr<TreeNode> &node) | |||
| 216 | auto fusionOp = record->additionPtr; | 216 | auto fusionOp = record->additionPtr; |
| 217 | if (fusionOp) | 217 | if (fusionOp) |
| 218 | { | 218 | { |
| 219 | - auto fusionStruct = Utils::ReinterpretConvert<ProfFusionOpInfo *>(fusionOp->data); | 219 | + auto fusionStruct = fusionOp->fusionOpInfo; |
| 220 | - std::shared_ptr<ProfFusionOpInfo> fusionOpInfo; | 220 | + std::shared_ptr<ParserProfFusionOpInfo> fusionOpInfo; |
| 221 | - MAKE_SHARED_RETURN_VOID(fusionOpInfo, ProfFusionOpInfo, *fusionStruct); | 221 | + MAKE_SHARED_RETURN_VOID(fusionOpInfo, ParserProfFusionOpInfo, fusionStruct); |
| 222 | std::shared_ptr<GeFusionOpInfo> geFusionOpInfo; | 222 | std::shared_ptr<GeFusionOpInfo> geFusionOpInfo; |
| 223 | MAKE_SHARED_RETURN_VOID(geFusionOpInfo, GeFusionOpInfo, modelId, fusionOpInfo); | 223 | MAKE_SHARED_RETURN_VOID(geFusionOpInfo, GeFusionOpInfo, modelId, fusionOpInfo); |
| 224 | geFusionOpInfos_.emplace_back(geFusionOpInfo); | 224 | geFusionOpInfos_.emplace_back(geFusionOpInfo); |
| @@ -257,7 +257,7 @@ bool TreeAnalyzer::IsComputeTask(const std::shared_ptr<TreeNode> &node) | |||
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | auto trace = record->compactPtr; | 259 | auto trace = record->compactPtr; |
| 260 | - auto taskTypeVal = trace->data.runtimeTrackV2.taskType; | 260 | + auto taskTypeVal = trace->data.runtimeTrack.taskType; |
| 261 | auto taskType = TypeData::GetInstance().Get(node->event->info.level, taskTypeVal); | 261 | auto taskType = TypeData::GetInstance().Get(node->event->info.level, taskTypeVal); |
| 262 | if (taskType.substr(0, KERNEL_TASK_PREFIX.size()) == KERNEL_TASK_PREFIX || | 262 | if (taskType.substr(0, KERNEL_TASK_PREFIX.size()) == KERNEL_TASK_PREFIX || |
| 263 | taskType == KERNEL_STARS_COMMON_TASK_TYPE) | 263 | taskType == KERNEL_STARS_COMMON_TASK_TYPE) |
| @@ -299,19 +299,19 @@ void TreeAnalyzer::UpdateHcclBigOpDescs(const std::shared_ptr<TreeNode> &node) | |||
| 299 | auto modelTrace = path_.find(MSPROF_REPORT_MODEL_LEVEL) != path_.end() ? path_[MSPROF_REPORT_MODEL_LEVEL] : nullptr; | 299 | auto modelTrace = path_.find(MSPROF_REPORT_MODEL_LEVEL) != path_.end() ? path_[MSPROF_REPORT_MODEL_LEVEL] : nullptr; |
| 300 | auto modelApi = modelTrace != nullptr ? modelTrace->event->apiPtr : nullptr; | 300 | auto modelApi = modelTrace != nullptr ? modelTrace->event->apiPtr : nullptr; |
| 301 | auto indexId = modelApi != nullptr ? modelApi->reserve : -1; | 301 | auto indexId = modelApi != nullptr ? modelApi->reserve : -1; |
| 302 | - auto deviceId = track->data.runtimeTrackV2.deviceId; | 302 | + auto deviceId = track->data.runtimeTrack.deviceId; |
| 303 | - auto streamId = track->data.runtimeTrackV2.streamId; | 303 | + auto streamId = track->data.runtimeTrack.streamId; |
| 304 | - auto batchId = GetBatchId(track->data.runtimeTrackV2.taskId); | 304 | + auto batchId = GetBatchId(track->data.runtimeTrack.taskId); |
| 305 | auto modelId = GetModelId(track, modelApi, deviceId, streamId, batchId, track->timeStamp); | 305 | auto modelId = GetModelId(track, modelApi, deviceId, streamId, batchId, track->timeStamp); |
| 306 | auto connectionId = nodeNode->event->id; | 306 | auto connectionId = nodeNode->event->id; |
| 307 | auto nodeRecords = GetNodeRecordsByType(nodeNode, EventType::EVENT_TYPE_NODE_BASIC_INFO); | 307 | auto nodeRecords = GetNodeRecordsByType(nodeNode, EventType::EVENT_TYPE_NODE_BASIC_INFO); |
| 308 | - std::shared_ptr<MsprofCompactInfo> nodeDesc = nullptr; | 308 | + std::shared_ptr<ParserCompactInfo> nodeDesc = nullptr; |
| 309 | if (!nodeRecords.empty() && nodeRecords.front() != nullptr) | 309 | if (!nodeRecords.empty() && nodeRecords.front() != nullptr) |
| 310 | { | 310 | { |
| 311 | nodeDesc = nodeRecords.front()->compactPtr; | 311 | nodeDesc = nodeRecords.front()->compactPtr; |
| 312 | } | 312 | } |
| 313 | auto hcclOpRecords = GetNodeRecordsByType(nodeNode, EventType::EVENT_TYPE_HCCL_OP_INFO); | 313 | auto hcclOpRecords = GetNodeRecordsByType(nodeNode, EventType::EVENT_TYPE_HCCL_OP_INFO); |
| 314 | - std::shared_ptr<MsprofCompactInfo> hcclOpDesc = nullptr; | 314 | + std::shared_ptr<ParserCompactInfo> hcclOpDesc = nullptr; |
| 315 | if (!hcclOpRecords.empty() && hcclOpRecords.front() != nullptr) | 315 | if (!hcclOpRecords.empty() && hcclOpRecords.front() != nullptr) |
| 316 | { | 316 | { |
| 317 | hcclOpDesc = hcclOpRecords.front()->compactPtr; | 317 | hcclOpDesc = hcclOpRecords.front()->compactPtr; |
| @@ -354,8 +354,8 @@ std::vector<std::shared_ptr<Event>> TreeAnalyzer::GetNodeRecordsByType(const std | |||
| 354 | return records; | 354 | return records; |
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | -std::shared_ptr<HostTask> TreeAnalyzer::GenHostTask(const std::shared_ptr<MsprofCompactInfo> &track, | 357 | +std::shared_ptr<HostTask> TreeAnalyzer::GenHostTask(const std::shared_ptr<ParserCompactInfo> &track, |
| 358 | - const std::shared_ptr<MsprofApi> &modelApi, | 358 | + const std::shared_ptr<ParserApi> &modelApi, |
| 359 | const std::shared_ptr<Operator> &opPtr, uint32_t ctxId, | 359 | const std::shared_ptr<Operator> &opPtr, uint32_t ctxId, |
| 360 | uint16_t taskType, int64_t connectionId) | 360 | uint16_t taskType, int64_t connectionId) |
| 361 | { | 361 | { |
| @@ -369,16 +369,16 @@ std::shared_ptr<HostTask> TreeAnalyzer::GenHostTask(const std::shared_ptr<Msprof | |||
| 369 | task->threadId = track->threadId; | 369 | task->threadId = track->threadId; |
| 370 | task->taskType = taskType; | 370 | task->taskType = taskType; |
| 371 | task->requestId = modelApi != nullptr ? modelApi->reserve : INVALID_VALUE; | 371 | task->requestId = modelApi != nullptr ? modelApi->reserve : INVALID_VALUE; |
| 372 | - task->streamId = track->data.runtimeTrackV2.streamId; | 372 | + task->streamId = track->data.runtimeTrack.streamId; |
| 373 | - task->taskId = static_cast<uint32_t>(track->data.runtimeTrackV2.taskId & GetTaskIdBit()); | 373 | + task->taskId = static_cast<uint32_t>(track->data.runtimeTrack.taskId & GetTaskIdBit()); |
| 374 | - task->batchId = GetBatchId(track->data.runtimeTrackV2.taskId); | 374 | + task->batchId = GetBatchId(track->data.runtimeTrack.taskId); |
| 375 | - task->deviceId = track->data.runtimeTrackV2.deviceId; | 375 | + task->deviceId = track->data.runtimeTrack.deviceId; |
| 376 | - task->kernelName = track->data.runtimeTrackV2.kernelName; | 376 | + task->kernelName = track->data.runtimeTrack.kernelName; |
| 377 | task->modelId = GetModelId(track, modelApi, task->deviceId, task->streamId, task->batchId, task->timeStamp); | 377 | task->modelId = GetModelId(track, modelApi, task->deviceId, task->streamId, task->batchId, task->timeStamp); |
| 378 | return task; | 378 | return task; |
| 379 | } | 379 | } |
| 380 | 380 | ||
| 381 | -HostTasks TreeAnalyzer::GenComputeHostTasks(ComputeOpDescs &ops, const std::shared_ptr<MsprofCompactInfo> &track, | 381 | +HostTasks TreeAnalyzer::GenComputeHostTasks(ComputeOpDescs &ops, const std::shared_ptr<ParserCompactInfo> &track, |
| 382 | int64_t connectionId) | 382 | int64_t connectionId) |
| 383 | { | 383 | { |
| 384 | auto modelNode = path_.find(MSPROF_REPORT_MODEL_LEVEL) != path_.end() ? path_[MSPROF_REPORT_MODEL_LEVEL] : nullptr; | 384 | auto modelNode = path_.find(MSPROF_REPORT_MODEL_LEVEL) != path_.end() ? path_[MSPROF_REPORT_MODEL_LEVEL] : nullptr; |
| @@ -397,14 +397,14 @@ HostTasks TreeAnalyzer::GenComputeHostTasks(ComputeOpDescs &ops, const std::shar | |||
| 397 | MAKE_SHARED_RETURN_VALUE(desc, OpDesc, {}); | 397 | MAKE_SHARED_RETURN_VALUE(desc, OpDesc, {}); |
| 398 | desc->runtimeTrackDesc = track; | 398 | desc->runtimeTrackDesc = track; |
| 399 | MAKE_SHARED_RETURN_VALUE(op, Operator, {}, desc, nodeNode->event->apiPtr->itemId, OpType::OPTYPE_COMPUTE); | 399 | MAKE_SHARED_RETURN_VALUE(op, Operator, {}, desc, nodeNode->event->apiPtr->itemId, OpType::OPTYPE_COMPUTE); |
| 400 | - auto taskTypeVal = track->data.runtimeTrackV2.taskType; | 400 | + auto taskTypeVal = track->data.runtimeTrack.taskType; |
| 401 | auto task = | 401 | auto task = |
| 402 | GenHostTask(track, modelApi, op, DEFAULT_CONTEXT_ID, static_cast<uint16_t>(taskTypeVal), connectionId); | 402 | GenHostTask(track, modelApi, op, DEFAULT_CONTEXT_ID, static_cast<uint16_t>(taskTypeVal), connectionId); |
| 403 | return (task != nullptr) ? HostTasks{task} : HostTasks{}; | 403 | return (task != nullptr) ? HostTasks{task} : HostTasks{}; |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | HostTasks results; | 406 | HostTasks results; |
| 407 | - auto taskTypeVal = track->data.runtimeTrackV2.taskType; | 407 | + auto taskTypeVal = track->data.runtimeTrack.taskType; |
| 408 | for (const auto &pair : ops) | 408 | for (const auto &pair : ops) |
| 409 | { | 409 | { |
| 410 | auto desc = pair.second->opDesc; | 410 | auto desc = pair.second->opDesc; |
| @@ -419,8 +419,8 @@ HostTasks TreeAnalyzer::GenComputeHostTasks(ComputeOpDescs &ops, const std::shar | |||
| 419 | // 只有FFTS+类型应该保留CtxId | 419 | // 只有FFTS+类型应该保留CtxId |
| 420 | if (desc->ctxId && !IsChipV6()) | 420 | if (desc->ctxId && !IsChipV6()) |
| 421 | { | 421 | { |
| 422 | - auto ctxIdInfo = ReinterpretConvert<MsprofContextIdInfo *>(desc->ctxId->data); | 422 | + auto ctxIdInfo = desc->ctxId->contextIdInfo; |
| 423 | - ctxIds.assign(ctxIdInfo->ctxIds, ctxIdInfo->ctxIds + ctxIdInfo->ctxIdNum); | 423 | + ctxIds.assign(ctxIdInfo.ctxIds, ctxIdInfo.ctxIds + ctxIdInfo.ctxIdNum); |
| 424 | } | 424 | } |
| 425 | else | 425 | else |
| 426 | { | 426 | { |
| @@ -492,11 +492,11 @@ void TreeAnalyzer::UpdateComputeDescForHcclSituation(ComputeOpDescs &descs, cons | |||
| 492 | if (!pair.second->opDesc->nodeDesc) | 492 | if (!pair.second->opDesc->nodeDesc) |
| 493 | { | 493 | { |
| 494 | // 避免内存泄露 | 494 | // 避免内存泄露 |
| 495 | - MAKE_SHARED0_NO_OPERATION(pair.second->opDesc->nodeDesc, MsprofCompactInfo); | 495 | + MAKE_SHARED0_NO_OPERATION(pair.second->opDesc->nodeDesc, ParserCompactInfo); |
| 496 | } | 496 | } |
| 497 | // 特殊场景2:hccl类任务将opName刷成item id | 497 | // 特殊场景2:hccl类任务将opName刷成item id |
| 498 | pair.second->opDesc->nodeDesc->data.nodeBasicInfo.opName = item_id; | 498 | pair.second->opDesc->nodeDesc->data.nodeBasicInfo.opName = item_id; |
| 499 | - auto taskTypeVal = track->compactPtr->data.runtimeTrackV2.taskType; | 499 | + auto taskTypeVal = track->compactPtr->data.runtimeTrack.taskType; |
| 500 | auto taskTypeStr = TypeData::GetInstance().Get(MSPROF_REPORT_RUNTIME_LEVEL, taskTypeVal); | 500 | auto taskTypeStr = TypeData::GetInstance().Get(MSPROF_REPORT_RUNTIME_LEVEL, taskTypeVal); |
| 501 | if (taskTypeStr == KERNEL_AI_CPU_TASK_TYPE) | 501 | if (taskTypeStr == KERNEL_AI_CPU_TASK_TYPE) |
| 502 | { | 502 | { |
| @@ -544,7 +544,7 @@ HostTasks TreeAnalyzer::GetComputeTaskDescs(const std::shared_ptr<TreeNode> &nod | |||
| 544 | } | 544 | } |
| 545 | 545 | ||
| 546 | auto track = tracks.back()->compactPtr; | 546 | auto track = tracks.back()->compactPtr; |
| 547 | - auto taskTypeVal = track->data.runtimeTrackV2.taskType; | 547 | + auto taskTypeVal = track->data.runtimeTrack.taskType; |
| 548 | std::string type = TypeData::GetInstance().Get(MSPROF_REPORT_RUNTIME_LEVEL, taskTypeVal); | 548 | std::string type = TypeData::GetInstance().Get(MSPROF_REPORT_RUNTIME_LEVEL, taskTypeVal); |
| 549 | bool useCtxId = CONTEXT_ID_WHITE_LIST.find(type) != CONTEXT_ID_WHITE_LIST.end(); | 549 | bool useCtxId = CONTEXT_ID_WHITE_LIST.find(type) != CONTEXT_ID_WHITE_LIST.end(); |
| 550 | ComputeOpDescs ops = GetComputeOpDescs(nodeNode, useCtxId); | 550 | ComputeOpDescs ops = GetComputeOpDescs(nodeNode, useCtxId); |
| @@ -597,7 +597,7 @@ HostTasks TreeAnalyzer::GetHcclTaskDescs(const std::shared_ptr<TreeNode> &node) | |||
| 597 | for (const auto &pair : hcclOpDescs) | 597 | for (const auto &pair : hcclOpDescs) |
| 598 | { | 598 | { |
| 599 | auto desc = pair.second->hcclSmallOpDesc; | 599 | auto desc = pair.second->hcclSmallOpDesc; |
| 600 | - auto taskTypeVal = track->data.runtimeTrackV2.taskType; | 600 | + auto taskTypeVal = track->data.runtimeTrack.taskType; |
| 601 | auto task = GenHostTask(track, modelApi, pair.second, desc->ctxId, static_cast<uint16_t>(taskTypeVal), | 601 | auto task = GenHostTask(track, modelApi, pair.second, desc->ctxId, static_cast<uint16_t>(taskTypeVal), |
| 602 | nodeNode->event->id); | 602 | nodeNode->event->id); |
| 603 | if (task) | 603 | if (task) |
| @@ -619,7 +619,7 @@ std::shared_ptr<HostTask> TreeAnalyzer::GetOtherTaskDesc(const std::shared_ptr<T | |||
| 619 | return nullptr; | 619 | return nullptr; |
| 620 | } | 620 | } |
| 621 | auto track = tracks.back()->compactPtr; | 621 | auto track = tracks.back()->compactPtr; |
| 622 | - auto taskTypeVal = track->data.runtimeTrackV2.taskType; | 622 | + auto taskTypeVal = track->data.runtimeTrack.taskType; |
| 623 | auto taskType = TypeData::GetInstance().Get(MSPROF_REPORT_RUNTIME_LEVEL, taskTypeVal); | 623 | auto taskType = TypeData::GetInstance().Get(MSPROF_REPORT_RUNTIME_LEVEL, taskTypeVal); |
| 624 | uint32_t contextId = (taskType == KERNEL_MIX_AIC_TASK_TYPE || taskType == KERNEL_MIX_AIV_TASK_TYPE) && !IsChipV6() | 624 | uint32_t contextId = (taskType == KERNEL_MIX_AIC_TASK_TYPE || taskType == KERNEL_MIX_AIV_TASK_TYPE) && !IsChipV6() |
| 625 | ? 0 | 625 | ? 0 |
| @@ -629,7 +629,7 @@ std::shared_ptr<HostTask> TreeAnalyzer::GetOtherTaskDesc(const std::shared_ptr<T | |||
| 629 | std::shared_ptr<OpDesc> desc; | 629 | std::shared_ptr<OpDesc> desc; |
| 630 | MAKE_SHARED_RETURN_VALUE(desc, OpDesc, {}); | 630 | MAKE_SHARED_RETURN_VALUE(desc, OpDesc, {}); |
| 631 | desc->runtimeTrackDesc = track; | 631 | desc->runtimeTrackDesc = track; |
| 632 | - auto kernelName = track->data.runtimeTrackV2.kernelName; | 632 | + auto kernelName = track->data.runtimeTrack.kernelName; |
| 633 | MAKE_SHARED_RETURN_VALUE(op, Operator, {}, desc, kernelName, OpType::OPTYPE_RESERVED); | 633 | MAKE_SHARED_RETURN_VALUE(op, Operator, {}, desc, kernelName, OpType::OPTYPE_RESERVED); |
| 634 | auto task = | 634 | auto task = |
| 635 | GenHostTask(track, modelApi, op, contextId, static_cast<uint16_t>(taskTypeVal), node->parent->event->id); | 635 | GenHostTask(track, modelApi, op, contextId, static_cast<uint16_t>(taskTypeVal), node->parent->event->id); |
| @@ -648,24 +648,24 @@ ComputeOpDescs TreeAnalyzer::GetComputeOpDescs(const std::shared_ptr<TreeNode> & | |||
| 648 | { | 648 | { |
| 649 | if (record->info.type == EventType::EVENT_TYPE_NODE_BASIC_INFO) | 649 | if (record->info.type == EventType::EVENT_TYPE_NODE_BASIC_INFO) |
| 650 | { | 650 | { |
| 651 | - std::shared_ptr<MsprofCompactInfo> trace; | 651 | + std::shared_ptr<ParserCompactInfo> trace; |
| 652 | - MAKE_SHARED_RETURN_VALUE(trace, MsprofCompactInfo, opDescs, *(record->compactPtr)); | 652 | + MAKE_SHARED_RETURN_VALUE(trace, ParserCompactInfo, opDescs, *(record->compactPtr)); |
| 653 | - UpdateComputeOpDescs<MsprofCompactInfo, &OpDesc::nodeDesc>(opDescs, trace, trace->data.nodeBasicInfo.opName, | 653 | + UpdateComputeOpDescs<ParserCompactInfo, &OpDesc::nodeDesc>(opDescs, trace, trace->data.nodeBasicInfo.opName, |
| 654 | nodeNode->event->id); | 654 | nodeNode->event->id); |
| 655 | } | 655 | } |
| 656 | else if (record->info.type == EventType::EVENT_TYPE_NODE_ATTR_INFO) | 656 | else if (record->info.type == EventType::EVENT_TYPE_NODE_ATTR_INFO) |
| 657 | { | 657 | { |
| 658 | - std::shared_ptr<MsprofCompactInfo> trace; | 658 | + std::shared_ptr<ParserCompactInfo> trace; |
| 659 | - MAKE_SHARED_RETURN_VALUE(trace, MsprofCompactInfo, opDescs, *(record->compactPtr)); | 659 | + MAKE_SHARED_RETURN_VALUE(trace, ParserCompactInfo, opDescs, *(record->compactPtr)); |
| 660 | - UpdateComputeOpDescs<MsprofCompactInfo, &OpDesc::nodeAttr>(opDescs, trace, trace->data.nodeAttrInfo.opName, | 660 | + UpdateComputeOpDescs<ParserCompactInfo, &OpDesc::nodeAttr>(opDescs, trace, trace->data.nodeAttrInfo.opName, |
| 661 | nodeNode->event->id); | 661 | nodeNode->event->id); |
| 662 | } | 662 | } |
| 663 | else if (record->info.type == EventType::EVENT_TYPE_TENSOR_INFO) | 663 | else if (record->info.type == EventType::EVENT_TYPE_TENSOR_INFO) |
| 664 | { | 664 | { |
| 665 | - std::shared_ptr<ConcatTensorInfo> trace; | 665 | + std::shared_ptr<ParserConcatTensorInfo> trace; |
| 666 | - MAKE_SHARED_RETURN_VALUE(trace, ConcatTensorInfo, opDescs, *(record->tensorPtr)); | 666 | + MAKE_SHARED_RETURN_VALUE(trace, ParserConcatTensorInfo, opDescs, *(record->tensorPtr)); |
| 667 | - UpdateComputeOpDescs<ConcatTensorInfo, &OpDesc::tensorDesc>(opDescs, trace, trace->opName, | 667 | + UpdateComputeOpDescs<ParserConcatTensorInfo, &OpDesc::tensorDesc>(opDescs, trace, trace->opName, |
| 668 | - nodeNode->event->id); | 668 | + nodeNode->event->id); |
| 669 | } | 669 | } |
| 670 | else if (record->info.type == EventType::EVENT_TYPE_CONTEXT_ID) | 670 | else if (record->info.type == EventType::EVENT_TYPE_CONTEXT_ID) |
| 671 | { | 671 | { |
| @@ -673,10 +673,10 @@ ComputeOpDescs TreeAnalyzer::GetComputeOpDescs(const std::shared_ptr<TreeNode> & | |||
| 673 | { | 673 | { |
| 674 | continue; | 674 | continue; |
| 675 | } | 675 | } |
| 676 | - std::shared_ptr<MsprofAdditionalInfo> trace; | 676 | + std::shared_ptr<ParserAdditionalInfo> trace; |
| 677 | - MAKE_SHARED_RETURN_VALUE(trace, MsprofAdditionalInfo, opDescs, *(record->additionPtr)); | 677 | + MAKE_SHARED_RETURN_VALUE(trace, ParserAdditionalInfo, opDescs, *(record->additionPtr)); |
| 678 | - auto ctxIdNode = ReinterpretConvert<MsprofContextIdInfo *>(trace->data); | 678 | + auto ctxIdNode = trace->contextIdInfo; |
| 679 | - UpdateComputeOpDescs<MsprofAdditionalInfo, &OpDesc::ctxId>(opDescs, trace, ctxIdNode->opName, | 679 | + UpdateComputeOpDescs<ParserAdditionalInfo, &OpDesc::ctxId>(opDescs, trace, ctxIdNode.opName, |
| 680 | nodeNode->event->id); | 680 | nodeNode->event->id); |
| 681 | } | 681 | } |
| 682 | else if (record->info.type == EventType::EVENT_TYPE_HCCL_OP_INFO) | 682 | else if (record->info.type == EventType::EVENT_TYPE_HCCL_OP_INFO) |
| @@ -747,19 +747,19 @@ bool TreeAnalyzer::UpdateHcclSmallOpDescs(HCCLSmallOpDescs &descs, | |||
| 747 | for (const auto &record : ctxIdRecords) | 747 | for (const auto &record : ctxIdRecords) |
| 748 | { | 748 | { |
| 749 | auto trace = record->additionPtr; | 749 | auto trace = record->additionPtr; |
| 750 | - auto ctxIdTrace = ReinterpretConvert<MsprofContextIdInfo *>(trace->data); | 750 | + auto ctxIdTrace = trace->contextIdInfo; |
| 751 | - if (ctxIdTrace->ctxIdNum != VALID_CTXID_NUM) | 751 | + if (ctxIdTrace.ctxIdNum != VALID_CTXID_NUM) |
| 752 | { | 752 | { |
| 753 | - ERROR("Expect ctxIdNum is 2, but get ctxIdNum is %, threadId = %", ctxIdTrace->ctxIdNum, threadId_); | 753 | + ERROR("Expect ctxIdNum is 2, but get ctxIdNum is %, threadId = %", ctxIdTrace.ctxIdNum, threadId_); |
| 754 | return false; | 754 | return false; |
| 755 | } | 755 | } |
| 756 | - for (uint32_t id = ctxIdTrace->ctxIds[0]; id <= ctxIdTrace->ctxIds[1]; ++id) | 756 | + for (uint32_t id = ctxIdTrace.ctxIds[0]; id <= ctxIdTrace.ctxIds[1]; ++id) |
| 757 | { | 757 | { |
| 758 | std::shared_ptr<HcclSmallOpDesc> desc; | 758 | std::shared_ptr<HcclSmallOpDesc> desc; |
| 759 | MAKE_SHARED_RETURN_VALUE(desc, HcclSmallOpDesc, false, DEFAULT_CONTEXT_ID, isMaster, nullptr); | 759 | MAKE_SHARED_RETURN_VALUE(desc, HcclSmallOpDesc, false, DEFAULT_CONTEXT_ID, isMaster, nullptr); |
| 760 | desc->ctxId = id; | 760 | desc->ctxId = id; |
| 761 | std::shared_ptr<Operator> op; | 761 | std::shared_ptr<Operator> op; |
| 762 | - MAKE_SHARED_RETURN_VALUE(op, Operator, false, desc, ctxIdTrace->opName, OpType::OPTYPE_HCCL_SMALL); | 762 | + MAKE_SHARED_RETURN_VALUE(op, Operator, false, desc, ctxIdTrace.opName, OpType::OPTYPE_HCCL_SMALL); |
| 763 | descs.insert({id, op}); | 763 | descs.insert({id, op}); |
| 764 | } | 764 | } |
| 765 | } | 765 | } |
| @@ -777,8 +777,8 @@ bool TreeAnalyzer::UpdateHcclSmallOpDescs(HCCLSmallOpDescs &descs, | |||
| 777 | for (const auto &record : hcclInfoRecords) | 777 | for (const auto &record : hcclInfoRecords) |
| 778 | { | 778 | { |
| 779 | auto trace = record->additionPtr; | 779 | auto trace = record->additionPtr; |
| 780 | - auto hcclTrace = ReinterpretConvert<MsprofHcclInfo *>(trace->data); | 780 | + auto hcclTrace = trace->hcclInfo; |
| 781 | - auto key = hcclTrace->ctxID; | 781 | + auto key = hcclTrace.ctxID; |
| 782 | if (descs.find(key) != descs.end()) | 782 | if (descs.find(key) != descs.end()) |
| 783 | { | 783 | { |
| 784 | auto hcclPtr = descs[key]->hcclSmallOpDesc; | 784 | auto hcclPtr = descs[key]->hcclSmallOpDesc; |
| @@ -798,14 +798,14 @@ bool TreeAnalyzer::UpdateHcclSmallOpDescs(HCCLSmallOpDescs &descs, | |||
| 798 | for (const auto &record : hcclInfoRecords) | 798 | for (const auto &record : hcclInfoRecords) |
| 799 | { | 799 | { |
| 800 | auto trace = record->additionPtr; | 800 | auto trace = record->additionPtr; |
| 801 | - auto hcclTrace = ReinterpretConvert<MsprofHcclInfo *>(trace->data); | 801 | + auto hcclTrace = trace->hcclInfo; |
| 802 | - auto key = hcclTrace->ctxID; | 802 | + auto key = hcclTrace.ctxID; |
| 803 | 803 | ||
| 804 | std::shared_ptr<HcclSmallOpDesc> desc; | 804 | std::shared_ptr<HcclSmallOpDesc> desc; |
| 805 | MAKE_SHARED_RETURN_VALUE(desc, HcclSmallOpDesc, false, DEFAULT_CONTEXT_ID, isMaster, nullptr); | 805 | MAKE_SHARED_RETURN_VALUE(desc, HcclSmallOpDesc, false, DEFAULT_CONTEXT_ID, isMaster, nullptr); |
| 806 | desc->hcclInfo = trace; | 806 | desc->hcclInfo = trace; |
| 807 | std::shared_ptr<Operator> op; | 807 | std::shared_ptr<Operator> op; |
| 808 | - MAKE_SHARED_RETURN_VALUE(op, Operator, false, desc, hcclTrace->itemId, OpType::OPTYPE_HCCL_SMALL); | 808 | + MAKE_SHARED_RETURN_VALUE(op, Operator, false, desc, hcclTrace.itemId, OpType::OPTYPE_HCCL_SMALL); |
| 809 | 809 | ||
| 810 | descs.insert({key, op}); | 810 | descs.insert({key, op}); |
| 811 | auto hcclPtr = descs[key]->hcclSmallOpDesc; | 811 | auto hcclPtr = descs[key]->hcclSmallOpDesc; |
| @@ -15,16 +15,21 @@ | |||
| 15 | * -------------------------------------------------------------------------*/ | 15 | * -------------------------------------------------------------------------*/ |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | + | ||
| 18 | 19 | ||
| 19 | 20 | ||
| 20 | -namespace Analysis { | 21 | +namespace Analysis |
| 21 | -namespace Domain { | 22 | +{ |
| 22 | -namespace Cann { | 23 | +namespace Domain |
| 24 | +{ | ||
| 25 | +namespace Cann | ||
| 26 | +{ | ||
| 23 | 27 | ||
| 24 | -namespace { | 28 | +namespace |
| 29 | +{ | ||
| 25 | const int MAX_DEPTH = 20; | 30 | const int MAX_DEPTH = 20; |
| 26 | const int MAX_BINDING_DEPTH = 5; | 31 | const int MAX_BINDING_DEPTH = 5; |
| 27 | -} | 32 | +} // namespace |
| 28 | 33 | ||
| 29 | using namespace Analysis::Utils; | 34 | using namespace Analysis::Utils; |
| 30 | /* | 35 | /* |
| @@ -44,7 +49,8 @@ using namespace Analysis::Utils; | |||
| 44 | */ | 49 | */ |
| 45 | std::shared_ptr<TreeNode> TreeBuilder::Build() | 50 | std::shared_ptr<TreeNode> TreeBuilder::Build() |
| 46 | { | 51 | { |
| 47 | - if (!cannWarehouse_->kernelEvents && !cannWarehouse_->taskTrackEvents) { | 52 | + if (!cannWarehouse_->kernelEvents && !cannWarehouse_->taskTrackEvents) |
| 53 | + { | ||
| 48 | WARN("No key profiling info to build tree, threadId = %", threadId_); | 54 | WARN("No key profiling info to build tree, threadId = %", threadId_); |
| 49 | return nullptr; | 55 | return nullptr; |
| 50 | } | 56 | } |
| @@ -53,21 +59,26 @@ std::shared_ptr<TreeNode> TreeBuilder::Build() | |||
| 53 | 59 | ||
| 54 | auto rootNode = GenerateRoot(); | 60 | auto rootNode = GenerateRoot(); |
| 55 | std::shared_ptr<TreeNode> tree; | 61 | std::shared_ptr<TreeNode> tree; |
| 56 | - if (kernelEvents_ and !kernelEvents_->Empty()) { | 62 | + if (kernelEvents_ and !kernelEvents_->Empty()) |
| 63 | + { | ||
| 57 | // 1. 用Api和TaskTrack Event建立核心树 | 64 | // 1. 用Api和TaskTrack Event建立核心树 |
| 58 | tree = BuildTree(rootNode, 0); | 65 | tree = BuildTree(rootNode, 0); |
| 59 | - } else { | 66 | + } |
| 67 | + else | ||
| 68 | + { | ||
| 60 | // 1. root节点就是整颗核心树 | 69 | // 1. root节点就是整颗核心树 |
| 61 | tree = rootNode; | 70 | tree = rootNode; |
| 62 | } | 71 | } |
| 63 | - if (!tree) { | 72 | + if (!tree) |
| 73 | + { | ||
| 64 | ERROR("Build Tree Failed, ThreadId = %", threadId_); | 74 | ERROR("Build Tree Failed, ThreadId = %", threadId_); |
| 65 | return nullptr; | 75 | return nullptr; |
| 66 | } | 76 | } |
| 67 | MultiThreadAddLevelEvents(); | 77 | MultiThreadAddLevelEvents(); |
| 68 | // 向核心树添加TaskTrack类型的events | 78 | // 向核心树添加TaskTrack类型的events |
| 69 | AddTaskTrackEvents(rootNode, taskTrackEvents); | 79 | AddTaskTrackEvents(rootNode, taskTrackEvents); |
| 70 | - if (taskTrackEvents && !taskTrackEvents->Empty()) { | 80 | + if (taskTrackEvents && !taskTrackEvents->Empty()) |
| 81 | + { | ||
| 71 | ERROR("taskTrackEvents matching is not complete, threadId: %", threadId_); | 82 | ERROR("taskTrackEvents matching is not complete, threadId: %", threadId_); |
| 72 | } | 83 | } |
| 73 | INFO("Build Tree End, ThreadId = %", threadId_); | 84 | INFO("Build Tree End, ThreadId = %", threadId_); |
| @@ -94,25 +105,27 @@ void TreeBuilder::MultiThreadAddLevelEvents() | |||
| 94 | pool.Start(); | 105 | pool.Start(); |
| 95 | 106 | ||
| 96 | // Model Level | 107 | // Model Level |
| 97 | - pool.AddTask([this, &fusionOpInfoEvents]() { | 108 | + pool.AddTask([this, &fusionOpInfoEvents]() |
| 98 | - AddLevelEvents(fusionOpInfoEvents, modelLevelNodes_, EventType::EVENT_TYPE_FUSION_OP_INFO); | 109 | + { AddLevelEvents(fusionOpInfoEvents, modelLevelNodes_, EventType::EVENT_TYPE_FUSION_OP_INFO); }); |
| 99 | - }); | ||
| 100 | 110 | ||
| 101 | // Node Level | 111 | // Node Level |
| 102 | - pool.AddTask([this, &nodeCtxIdEvents, &tensorInfoEvents, &nodeBasicInfoEvents, | 112 | + pool.AddTask( |
| 103 | - &nodeAttrInfoEvents, &hcclOpInfoEvents]() { | 113 | + [this, &nodeCtxIdEvents, &tensorInfoEvents, &nodeBasicInfoEvents, &nodeAttrInfoEvents, &hcclOpInfoEvents]() |
| 104 | - AddLevelEvents(nodeBasicInfoEvents, nodeLevelNodes_, EventType::EVENT_TYPE_NODE_BASIC_INFO); | 114 | + { |
| 105 | - AddLevelEvents(nodeAttrInfoEvents, nodeLevelNodes_, EventType::EVENT_TYPE_NODE_ATTR_INFO); | 115 | + AddLevelEvents(nodeBasicInfoEvents, nodeLevelNodes_, EventType::EVENT_TYPE_NODE_BASIC_INFO); |
| 106 | - AddLevelEvents(tensorInfoEvents, nodeLevelNodes_, EventType::EVENT_TYPE_TENSOR_INFO); | 116 | + AddLevelEvents(nodeAttrInfoEvents, nodeLevelNodes_, EventType::EVENT_TYPE_NODE_ATTR_INFO); |
| 107 | - AddLevelEvents(nodeCtxIdEvents, nodeLevelNodes_, EventType::EVENT_TYPE_CONTEXT_ID); | 117 | + AddLevelEvents(tensorInfoEvents, nodeLevelNodes_, EventType::EVENT_TYPE_TENSOR_INFO); |
| 108 | - AddLevelEvents(hcclOpInfoEvents, nodeLevelNodes_, EventType::EVENT_TYPE_HCCL_OP_INFO); | 118 | + AddLevelEvents(nodeCtxIdEvents, nodeLevelNodes_, EventType::EVENT_TYPE_CONTEXT_ID); |
| 109 | - }); | 119 | + AddLevelEvents(hcclOpInfoEvents, nodeLevelNodes_, EventType::EVENT_TYPE_HCCL_OP_INFO); |
| 120 | + }); | ||
| 110 | 121 | ||
| 111 | // Hccl level | 122 | // Hccl level |
| 112 | - pool.AddTask([this, &hcclCtxIdEvents, &hcclInfoEvents]() { | 123 | + pool.AddTask( |
| 113 | - AddLevelEvents(hcclCtxIdEvents, hcclLevelNodes_, EventType::EVENT_TYPE_CONTEXT_ID); | 124 | + [this, &hcclCtxIdEvents, &hcclInfoEvents]() |
| 114 | - AddLevelEvents(hcclInfoEvents, hcclLevelNodes_, EventType::EVENT_TYPE_HCCL_INFO); | 125 | + { |
| 115 | - }); | 126 | + AddLevelEvents(hcclCtxIdEvents, hcclLevelNodes_, EventType::EVENT_TYPE_CONTEXT_ID); |
| 127 | + AddLevelEvents(hcclInfoEvents, hcclLevelNodes_, EventType::EVENT_TYPE_HCCL_INFO); | ||
| 128 | + }); | ||
| 116 | 129 | ||
| 117 | pool.WaitAllTasks(); | 130 | pool.WaitAllTasks(); |
| 118 | pool.Stop(); | 131 | pool.Stop(); |
| @@ -122,15 +135,18 @@ std::shared_ptr<TreeNode> TreeBuilder::GenerateRoot() | |||
| 122 | { | 135 | { |
| 123 | uint64_t bound; | 136 | uint64_t bound; |
| 124 | // rootNode的时间片应该覆盖整个EventQueue | 137 | // rootNode的时间片应该覆盖整个EventQueue |
| 125 | - if (!kernelEvents_ or kernelEvents_->Empty()) { | 138 | + if (!kernelEvents_ or kernelEvents_->Empty()) |
| 139 | + { | ||
| 126 | bound = cannWarehouse_->taskTrackEvents->GetBound(); | 140 | bound = cannWarehouse_->taskTrackEvents->GetBound(); |
| 127 | - } else { | 141 | + } |
| 142 | + else | ||
| 143 | + { | ||
| 128 | auto tkBound = cannWarehouse_->taskTrackEvents ? cannWarehouse_->taskTrackEvents->GetBound() : 0; | 144 | auto tkBound = cannWarehouse_->taskTrackEvents ? cannWarehouse_->taskTrackEvents->GetBound() : 0; |
| 129 | bound = std::max(tkBound, kernelEvents_->GetBound()); | 145 | bound = std::max(tkBound, kernelEvents_->GetBound()); |
| 130 | } | 146 | } |
| 131 | EventInfo rootInfo{EventType::EVENT_TYPE_API, 0, 0, bound + 1}; | 147 | EventInfo rootInfo{EventType::EVENT_TYPE_API, 0, 0, bound + 1}; |
| 132 | - std::shared_ptr<MsprofApi> api; | 148 | + std::shared_ptr<ParserApi> api; |
| 133 | - MAKE_SHARED0_RETURN_VALUE(api, MsprofApi, nullptr); | 149 | + MAKE_SHARED0_RETURN_VALUE(api, ParserApi, nullptr); |
| 134 | std::shared_ptr<Event> rootEvent; | 150 | std::shared_ptr<Event> rootEvent; |
| 135 | MAKE_SHARED_RETURN_VALUE(rootEvent, Event, nullptr, api, rootInfo); | 151 | MAKE_SHARED_RETURN_VALUE(rootEvent, Event, nullptr, api, rootInfo); |
| 136 | std::shared_ptr<TreeNode> rootNode; | 152 | std::shared_ptr<TreeNode> rootNode; |
| @@ -142,7 +158,8 @@ std::shared_ptr<TreeNode> TreeBuilder::GenerateRoot() | |||
| 142 | EventQueuePair TreeBuilder::GroupCtxIdEvents(std::shared_ptr<EventQueue> &ctxIdEvents) | 158 | EventQueuePair TreeBuilder::GroupCtxIdEvents(std::shared_ptr<EventQueue> &ctxIdEvents) |
| 143 | { | 159 | { |
| 144 | uint64_t ctxIdSize = 0; | 160 | uint64_t ctxIdSize = 0; |
| 145 | - if (ctxIdEvents) { | 161 | + if (ctxIdEvents) |
| 162 | + { | ||
| 146 | ctxIdSize = ctxIdEvents->GetSize(); | 163 | ctxIdSize = ctxIdEvents->GetSize(); |
| 147 | } | 164 | } |
| 148 | std::shared_ptr<EventQueue> nodeCtxIdEvent; | 165 | std::shared_ptr<EventQueue> nodeCtxIdEvent; |
| @@ -150,11 +167,15 @@ EventQueuePair TreeBuilder::GroupCtxIdEvents(std::shared_ptr<EventQueue> &ctxIdE | |||
| 150 | std::shared_ptr<EventQueue> hcclCtxIdEvent; | 167 | std::shared_ptr<EventQueue> hcclCtxIdEvent; |
| 151 | MAKE_SHARED_RETURN_VALUE(hcclCtxIdEvent, EventQueue, {}, threadId_, ctxIdSize); | 168 | MAKE_SHARED_RETURN_VALUE(hcclCtxIdEvent, EventQueue, {}, threadId_, ctxIdSize); |
| 152 | 169 | ||
| 153 | - while (ctxIdEvents && !ctxIdEvents->Empty()) { | 170 | + while (ctxIdEvents && !ctxIdEvents->Empty()) |
| 171 | + { | ||
| 154 | auto ctxId = ctxIdEvents->Pop(); | 172 | auto ctxId = ctxIdEvents->Pop(); |
| 155 | - if (ctxId->info.level == MSPROF_REPORT_NODE_LEVEL) { | 173 | + if (ctxId->info.level == MSPROF_REPORT_NODE_LEVEL) |
| 174 | + { | ||
| 156 | nodeCtxIdEvent->Push(ctxId); | 175 | nodeCtxIdEvent->Push(ctxId); |
| 157 | - } else if (ctxId->info.level == MSPROF_REPORT_HCCL_NODE_LEVEL) { | 176 | + } |
| 177 | + else if (ctxId->info.level == MSPROF_REPORT_HCCL_NODE_LEVEL) | ||
| 178 | + { | ||
| 158 | hcclCtxIdEvent->Push(ctxId); | 179 | hcclCtxIdEvent->Push(ctxId); |
| 159 | } | 180 | } |
| 160 | } | 181 | } |
| @@ -168,13 +189,16 @@ size_t TreeBuilder::GetEventOffset(size_t idx, std::shared_ptr<Event> &event, | |||
| 168 | // hccl aicpu下发场景, 会出现2层node嵌套, 需要计算offset, 关联至准确的node api | 189 | // hccl aicpu下发场景, 会出现2层node嵌套, 需要计算offset, 关联至准确的node api |
| 169 | // [=======================Node(hcom_allReduce_)==============================] | 190 | // [=======================Node(hcom_allReduce_)==============================] |
| 170 | // [===Node(hcomAicpuInit)==] [===Node(allreduceAicpuKernel)==] | 191 | // [===Node(hcomAicpuInit)==] [===Node(allreduceAicpuKernel)==] |
| 171 | - if (eventType != EventType::EVENT_TYPE_NODE_BASIC_INFO) { | 192 | + if (eventType != EventType::EVENT_TYPE_NODE_BASIC_INFO) |
| 193 | + { | ||
| 172 | // hccl aicpu下发场景暂时只有node basic info上报 | 194 | // hccl aicpu下发场景暂时只有node basic info上报 |
| 173 | return 0; | 195 | return 0; |
| 174 | } | 196 | } |
| 175 | size_t offset = 1; | 197 | size_t offset = 1; |
| 176 | - while ((idx + offset) < levelNodes.size() && levelNodes[idx + offset]->event->info.start <= event->info.start) { | 198 | + while ((idx + offset) < levelNodes.size() && levelNodes[idx + offset]->event->info.start <= event->info.start) |
| 177 | - if (event->info.start <= levelNodes[idx + offset]->event->info.end) { | 199 | + { |
| 200 | + if (event->info.start <= levelNodes[idx + offset]->event->info.end) | ||
| 201 | + { | ||
| 178 | return offset; | 202 | return offset; |
| 179 | } | 203 | } |
| 180 | ++offset; | 204 | ++offset; |
| @@ -184,56 +208,66 @@ size_t TreeBuilder::GetEventOffset(size_t idx, std::shared_ptr<Event> &event, | |||
| 184 | 208 | ||
| 185 | // 双指针遍历向Model Node HCCL Level的TreeNode中添加events | 209 | // 双指针遍历向Model Node HCCL Level的TreeNode中添加events |
| 186 | bool TreeBuilder::AddLevelEvents(std::shared_ptr<EventQueue> &events, | 210 | bool TreeBuilder::AddLevelEvents(std::shared_ptr<EventQueue> &events, |
| 187 | - std::vector<std::shared_ptr<TreeNode>> &levelNodes, | 211 | + std::vector<std::shared_ptr<TreeNode>> &levelNodes, EventType eventType) const |
| 188 | - EventType eventType) const | ||
| 189 | { | 212 | { |
| 190 | // 检查输入各Type的Events指针 | 213 | // 检查输入各Type的Events指针 |
| 191 | - if (!events || events->Empty()) { | 214 | + if (!events || events->Empty()) |
| 215 | + { | ||
| 192 | WARN("No Events, event type: %, threadId = %", static_cast<int>(eventType), threadId_); | 216 | WARN("No Events, event type: %, threadId = %", static_cast<int>(eventType), threadId_); |
| 193 | return false; | 217 | return false; |
| 194 | } | 218 | } |
| 195 | // 保证非空 | 219 | // 保证非空 |
| 196 | - if (levelNodes.empty()) { | 220 | + if (levelNodes.empty()) |
| 221 | + { | ||
| 197 | ERROR("LevelNodes is empty, level: %, threadId = % ", events->Top()->info.level, threadId_); | 222 | ERROR("LevelNodes is empty, level: %, threadId = % ", events->Top()->info.level, threadId_); |
| 198 | return false; | 223 | return false; |
| 199 | } | 224 | } |
| 200 | - uint64_t matchCnt = 0; // 在时间片范围内的数量 | 225 | + uint64_t matchCnt = 0; // 在时间片范围内的数量 |
| 201 | - uint64_t mismatchCnt = 0; // 在时间片范围外的数量 | 226 | + uint64_t mismatchCnt = 0; // 在时间片范围外的数量 |
| 202 | auto it = levelNodes.begin(); | 227 | auto it = levelNodes.begin(); |
| 203 | size_t idx = 0; | 228 | size_t idx = 0; |
| 204 | - while (!events->Empty() && it != levelNodes.end()) { | 229 | + while (!events->Empty() && it != levelNodes.end()) |
| 230 | + { | ||
| 205 | auto event = events->Top(); | 231 | auto event = events->Top(); |
| 206 | - if (event->info.start > (*it)->event->info.start && event->info.start <= (*it)->event->info.end) { | 232 | + if (event->info.start > (*it)->event->info.start && event->info.start <= (*it)->event->info.end) |
| 233 | + { | ||
| 207 | // event在TreeNode时间片内:(start, end],将event记录在TreeNode的附加信息中 | 234 | // event在TreeNode时间片内:(start, end],将event记录在TreeNode的附加信息中 |
| 208 | // hccl aicpu下发场景, 计算offset, 关联至准确的node api | 235 | // hccl aicpu下发场景, 计算offset, 关联至准确的node api |
| 209 | auto offset = GetEventOffset(idx, event, levelNodes, eventType); | 236 | auto offset = GetEventOffset(idx, event, levelNodes, eventType); |
| 210 | (*(it + offset))->records.emplace_back(event); | 237 | (*(it + offset))->records.emplace_back(event); |
| 211 | events->Pop(); | 238 | events->Pop(); |
| 212 | matchCnt++; | 239 | matchCnt++; |
| 213 | - } else if (event->info.start > (*it)->event->info.end) { | 240 | + } |
| 241 | + else if (event->info.start > (*it)->event->info.end) | ||
| 242 | + { | ||
| 214 | // event超过TreeNode的结束时间,需要检查是否在下一个TreeNode的开始之前 | 243 | // event超过TreeNode的结束时间,需要检查是否在下一个TreeNode的开始之前 |
| 215 | - if (std::next(it) != levelNodes.end() && event->info.start < (*std::next(it))->event->info.start) { | 244 | + if (std::next(it) != levelNodes.end() && event->info.start < (*std::next(it))->event->info.start) |
| 216 | - events->Pop(); // 丢掉此event | 245 | + { |
| 246 | + events->Pop(); // 丢掉此event | ||
| 217 | mismatchCnt++; | 247 | mismatchCnt++; |
| 218 | - ERROR("Drop event threadId = %, start = %, event type: %, its start time between " | 248 | + ERROR( |
| 219 | - "last TreeNode end and next TreeNode start", threadId_, event->info.start, | 249 | + "Drop event threadId = %, start = %, event type: %, its start time between " |
| 220 | - static_cast<int>(eventType)); | 250 | + "last TreeNode end and next TreeNode start", |
| 251 | + threadId_, event->info.start, static_cast<int>(eventType)); | ||
| 221 | } | 252 | } |
| 222 | it++; | 253 | it++; |
| 223 | idx++; | 254 | idx++; |
| 224 | - } else { | 255 | + } |
| 256 | + else | ||
| 257 | + { | ||
| 225 | // event小于TreeNode的开始时间,此event对应的TreeNode丢失 | 258 | // event小于TreeNode的开始时间,此event对应的TreeNode丢失 |
| 226 | - events->Pop(); // 丢掉此event | 259 | + events->Pop(); // 丢掉此event |
| 227 | mismatchCnt++; | 260 | mismatchCnt++; |
| 228 | ERROR("Drop event threadId = %, event type: %, event time range: [%, %], node time range: [%, %]", | 261 | ERROR("Drop event threadId = %, event type: %, event time range: [%, %], node time range: [%, %]", |
| 229 | - threadId_, static_cast<int>(eventType), event->info.start, event->info.end, | 262 | + threadId_, static_cast<int>(eventType), event->info.start, event->info.end, (*it)->event->info.start, |
| 230 | - (*it)->event->info.start, (*it)->event->info.end); | 263 | + (*it)->event->info.end); |
| 231 | } | 264 | } |
| 232 | } | 265 | } |
| 233 | - INFO("Add LevelEvents done, threadId = %, event type: %, matchCnt = %, mismatchCnt = % ", | 266 | + INFO("Add LevelEvents done, threadId = %, event type: %, matchCnt = %, mismatchCnt = % ", threadId_, |
| 234 | - threadId_, static_cast<int>(eventType), matchCnt, mismatchCnt); | 267 | + static_cast<int>(eventType), matchCnt, mismatchCnt); |
| 235 | // events没有匹配完 | 268 | // events没有匹配完 |
| 236 | - if (!events->Empty()) { | 269 | + if (!events->Empty()) |
| 270 | + { | ||
| 237 | ERROR("After matching events is not empty, size = %, threadId = %", events->GetSize(), threadId_); | 271 | ERROR("After matching events is not empty, size = %, threadId = %", events->GetSize(), threadId_); |
| 238 | return false; | 272 | return false; |
| 239 | } | 273 | } |
| @@ -243,10 +277,9 @@ bool TreeBuilder::AddLevelEvents(std::shared_ptr<EventQueue> &events, | |||
| 243 | std::shared_ptr<TreeNode> TreeBuilder::MakeDummyNode(const std::shared_ptr<Event> &event) | 277 | std::shared_ptr<TreeNode> TreeBuilder::MakeDummyNode(const std::shared_ptr<Event> &event) |
| 244 | { | 278 | { |
| 245 | // 建立dummy节点 | 279 | // 建立dummy节点 |
| 246 | - EventInfo dummyInfo{EventType::EVENT_TYPE_DUMMY, MSPROF_REPORT_RUNTIME_LEVEL, | 280 | + EventInfo dummyInfo{EventType::EVENT_TYPE_DUMMY, MSPROF_REPORT_RUNTIME_LEVEL, event->info.start, event->info.end}; |
| 247 | - event->info.start, event->info.end}; | 281 | + std::shared_ptr<ParserApi> api; |
| 248 | - std::shared_ptr<MsprofApi> api; | 282 | + MAKE_SHARED0_RETURN_VALUE(api, ParserApi, nullptr); |
| 249 | - MAKE_SHARED0_RETURN_VALUE(api, MsprofApi, nullptr); | ||
| 250 | std::shared_ptr<Event> dummyEvent; | 283 | std::shared_ptr<Event> dummyEvent; |
| 251 | MAKE_SHARED_RETURN_VALUE(dummyEvent, Event, nullptr, api, dummyInfo); | 284 | MAKE_SHARED_RETURN_VALUE(dummyEvent, Event, nullptr, api, dummyInfo); |
| 252 | std::shared_ptr<TreeNode> dummyNode; | 285 | std::shared_ptr<TreeNode> dummyNode; |
| @@ -256,48 +289,57 @@ std::shared_ptr<TreeNode> TreeBuilder::MakeDummyNode(const std::shared_ptr<Event | |||
| 256 | } | 289 | } |
| 257 | 290 | ||
| 258 | // 深度优先搜索+队列匹配添加TaskTrackEvents,基于rootNode和events有序 | 291 | // 深度优先搜索+队列匹配添加TaskTrackEvents,基于rootNode和events有序 |
| 259 | -bool TreeBuilder::AddTaskTrackEvents(std::shared_ptr<TreeNode> &treeNode, | 292 | +bool TreeBuilder::AddTaskTrackEvents(std::shared_ptr<TreeNode> &treeNode, std::shared_ptr<EventQueue> &events, |
| 260 | - std::shared_ptr<EventQueue> &events, uint16_t depth) | 293 | + uint16_t depth) |
| 261 | { | 294 | { |
| 262 | - if (!treeNode || depth > MAX_BINDING_DEPTH) { | 295 | + if (!treeNode || depth > MAX_BINDING_DEPTH) |
| 296 | + { | ||
| 263 | ERROR("The tree node is null or recursion depth % exceeds the maximum depth %.", depth, MAX_BINDING_DEPTH); | 297 | ERROR("The tree node is null or recursion depth % exceeds the maximum depth %.", depth, MAX_BINDING_DEPTH); |
| 264 | return false; | 298 | return false; |
| 265 | } | 299 | } |
| 266 | // 检查输入Runtime Events指针 | 300 | // 检查输入Runtime Events指针 |
| 267 | - if (!events || events->Empty()) { | 301 | + if (!events || events->Empty()) |
| 302 | + { | ||
| 268 | INFO("TaskTrack Events have been processed, threadId = %", threadId_); | 303 | INFO("TaskTrack Events have been processed, threadId = %", threadId_); |
| 269 | return true; | 304 | return true; |
| 270 | } | 305 | } |
| 271 | // event属于根节点时间范围内情况 | 306 | // event属于根节点时间范围内情况 |
| 272 | - auto oriSize = treeNode->children.size(); // 只遍历原始数据大小 | 307 | + auto oriSize = treeNode->children.size(); // 只遍历原始数据大小 |
| 273 | uint64_t prevEndTime = treeNode->event->info.start; | 308 | uint64_t prevEndTime = treeNode->event->info.start; |
| 274 | - for (size_t i = 0; i < oriSize; ++i) { // 使用索引遍历,避免迭代器失效 | 309 | + for (size_t i = 0; i < oriSize; ++i) |
| 310 | + { // 使用索引遍历,避免迭代器失效 | ||
| 275 | auto child = treeNode->children[i]; | 311 | auto child = treeNode->children[i]; |
| 276 | // event在当前子节点开始时间和上一个子节点结束时间之间情况(包括第一个节点之前),添加到根节点 | 312 | // event在当前子节点开始时间和上一个子节点结束时间之间情况(包括第一个节点之前),添加到根节点 |
| 277 | - while (!events->Empty() && events->Top()->info.start > prevEndTime | 313 | + while (!events->Empty() && events->Top()->info.start > prevEndTime && |
| 278 | - && events->Top()->info.start <= child->event->info.start) { | 314 | + events->Top()->info.start <= child->event->info.start) |
| 315 | + { | ||
| 279 | auto dummyNode = MakeDummyNode(events->Pop()); | 316 | auto dummyNode = MakeDummyNode(events->Pop()); |
| 280 | - if (!dummyNode) { | 317 | + if (!dummyNode) |
| 318 | + { | ||
| 281 | return false; | 319 | return false; |
| 282 | } | 320 | } |
| 283 | dummyNode->parent = treeNode; | 321 | dummyNode->parent = treeNode; |
| 284 | treeNode->children.emplace_back(dummyNode); | 322 | treeNode->children.emplace_back(dummyNode); |
| 285 | } | 323 | } |
| 286 | // event在当前子节点的时间范围内情况 | 324 | // event在当前子节点的时间范围内情况 |
| 287 | - while (!events->Empty() && events->Top()->info.start > child->event->info.start | 325 | + while (!events->Empty() && events->Top()->info.start > child->event->info.start && |
| 288 | - && events->Top()->info.start <= child->event->info.end) { | 326 | + events->Top()->info.start <= child->event->info.end) |
| 327 | + { | ||
| 289 | // 递归调用AddTaskTrackEvents添加event | 328 | // 递归调用AddTaskTrackEvents添加event |
| 290 | - if (!AddTaskTrackEvents(child, events, depth + 1)) { | 329 | + if (!AddTaskTrackEvents(child, events, depth + 1)) |
| 330 | + { | ||
| 291 | return false; | 331 | return false; |
| 292 | } | 332 | } |
| 293 | } | 333 | } |
| 294 | prevEndTime = child->event->info.end; | 334 | prevEndTime = child->event->info.end; |
| 295 | } | 335 | } |
| 296 | // event不在根节点的所有子节点时间范围内,但在根节点时间范围内情况 | 336 | // event不在根节点的所有子节点时间范围内,但在根节点时间范围内情况 |
| 297 | - while (!events->Empty() && events->Top()->info.start > treeNode->event->info.start | 337 | + while (!events->Empty() && events->Top()->info.start > treeNode->event->info.start && |
| 298 | - && events->Top()->info.start <= treeNode->event->info.end) { | 338 | + events->Top()->info.start <= treeNode->event->info.end) |
| 339 | + { | ||
| 299 | auto dummyNode = MakeDummyNode(events->Pop()); | 340 | auto dummyNode = MakeDummyNode(events->Pop()); |
| 300 | - if (!dummyNode) { | 341 | + if (!dummyNode) |
| 342 | + { | ||
| 301 | return false; | 343 | return false; |
| 302 | } | 344 | } |
| 303 | dummyNode->parent = treeNode; | 345 | dummyNode->parent = treeNode; |
| @@ -310,8 +352,10 @@ bool TreeBuilder::AddTaskTrackEvents(std::shared_ptr<TreeNode> &treeNode, | |||
| 310 | void TreeBuilder::LogTreeNode(std::shared_ptr<TreeNode> &treeNode) | 352 | void TreeBuilder::LogTreeNode(std::shared_ptr<TreeNode> &treeNode) |
| 311 | { | 353 | { |
| 312 | uint64_t runtimeNodes = 0; | 354 | uint64_t runtimeNodes = 0; |
| 313 | - for (auto child : treeNode->children) { | 355 | + for (auto child : treeNode->children) |
| 314 | - if (child->event->info.level == MSPROF_REPORT_RUNTIME_LEVEL) { | 356 | + { |
| 357 | + if (child->event->info.level == MSPROF_REPORT_RUNTIME_LEVEL) | ||
| 358 | + { | ||
| 315 | runtimeNodes++; | 359 | runtimeNodes++; |
| 316 | } | 360 | } |
| 317 | } | 361 | } |
| @@ -320,34 +364,44 @@ void TreeBuilder::LogTreeNode(std::shared_ptr<TreeNode> &treeNode) | |||
| 320 | treeNode->children.size(), runtimeNodes); | 364 | treeNode->children.size(), runtimeNodes); |
| 321 | } | 365 | } |
| 322 | 366 | ||
| 323 | -void TreeBuilder::RecordTreeNode(const std::shared_ptr<TreeNode> &treeNode, | 367 | +void TreeBuilder::RecordTreeNode(const std::shared_ptr<TreeNode> &treeNode, const uint16_t &eventLevel) |
| 324 | - const uint16_t &eventLevel) | ||
| 325 | { | 368 | { |
| 326 | - if (eventLevel == MSPROF_REPORT_MODEL_LEVEL) { | 369 | + if (eventLevel == MSPROF_REPORT_MODEL_LEVEL) |
| 370 | + { | ||
| 327 | modelLevelNodes_.emplace_back(treeNode); | 371 | modelLevelNodes_.emplace_back(treeNode); |
| 328 | - } else if (eventLevel == MSPROF_REPORT_NODE_LEVEL) { | 372 | + } |
| 373 | + else if (eventLevel == MSPROF_REPORT_NODE_LEVEL) | ||
| 374 | + { | ||
| 329 | nodeLevelNodes_.emplace_back(treeNode); | 375 | nodeLevelNodes_.emplace_back(treeNode); |
| 330 | - } else if (eventLevel == MSPROF_REPORT_HCCL_NODE_LEVEL) { | 376 | + } |
| 377 | + else if (eventLevel == MSPROF_REPORT_HCCL_NODE_LEVEL) | ||
| 378 | + { | ||
| 331 | hcclLevelNodes_.emplace_back(treeNode); | 379 | hcclLevelNodes_.emplace_back(treeNode); |
| 332 | - } else if (eventLevel == MSPROF_REPORT_RUNTIME_LEVEL) { | 380 | + } |
| 381 | + else if (eventLevel == MSPROF_REPORT_RUNTIME_LEVEL) | ||
| 382 | + { | ||
| 333 | runtimeLevelNodes_.emplace_back(treeNode); | 383 | runtimeLevelNodes_.emplace_back(treeNode); |
| 334 | } | 384 | } |
| 335 | } | 385 | } |
| 336 | 386 | ||
| 337 | std::shared_ptr<TreeNode> TreeBuilder::BuildTree(std::shared_ptr<TreeNode> parent, int depth) | 387 | std::shared_ptr<TreeNode> TreeBuilder::BuildTree(std::shared_ptr<TreeNode> parent, int depth) |
| 338 | { | 388 | { |
| 339 | - if (depth >= MAX_DEPTH) { | 389 | + if (depth >= MAX_DEPTH) |
| 390 | + { | ||
| 340 | ERROR("The maximum recursion depth is exceeded, thread id: %", threadId_); | 391 | ERROR("The maximum recursion depth is exceeded, thread id: %", threadId_); |
| 341 | return nullptr; | 392 | return nullptr; |
| 342 | } | 393 | } |
| 343 | - if (!parent) { | 394 | + if (!parent) |
| 395 | + { | ||
| 344 | ERROR("Parent pointer is nullptr, thread id: %", threadId_); | 396 | ERROR("Parent pointer is nullptr, thread id: %", threadId_); |
| 345 | return nullptr; | 397 | return nullptr; |
| 346 | } | 398 | } |
| 347 | 399 | ||
| 348 | - while (true) { | 400 | + while (true) |
| 401 | + { | ||
| 349 | auto checkEvent = kernelEvents_->Top(); | 402 | auto checkEvent = kernelEvents_->Top(); |
| 350 | - if (!checkEvent || checkEvent->info.end > parent->event->info.end) { | 403 | + if (!checkEvent || checkEvent->info.end > parent->event->info.end) |
| 404 | + { | ||
| 351 | break; | 405 | break; |
| 352 | } | 406 | } |
| 353 | auto event = kernelEvents_->Pop(); | 407 | auto event = kernelEvents_->Pop(); |
| @@ -357,7 +411,8 @@ std::shared_ptr<TreeNode> TreeBuilder::BuildTree(std::shared_ptr<TreeNode> paren | |||
| 357 | RecordTreeNode(childNode, event->info.level); | 411 | RecordTreeNode(childNode, event->info.level); |
| 358 | 412 | ||
| 359 | auto childTree = BuildTree(childNode, depth + 1); | 413 | auto childTree = BuildTree(childNode, depth + 1); |
| 360 | - if (childTree != nullptr) { | 414 | + if (childTree != nullptr) |
| 415 | + { | ||
| 361 | childTree->parent = parent; | 416 | childTree->parent = parent; |
| 362 | parent->children.emplace_back(childTree); | 417 | parent->children.emplace_back(childTree); |
| 363 | } | 418 | } |
| @@ -365,6 +420,6 @@ std::shared_ptr<TreeNode> TreeBuilder::BuildTree(std::shared_ptr<TreeNode> paren | |||
| 365 | return parent; | 420 | return parent; |
| 366 | } | 421 | } |
| 367 | 422 | ||
| 368 | -} // namespace Cann | 423 | +} // namespace Cann |
| 369 | -} // namespace Association | 424 | +} // namespace Domain |
| 370 | -} // namespace Analysis | 425 | +} // namespace Analysis |
| @@ -173,7 +173,7 @@ void HostTraceWorker::DumpModelName(ThreadPool &pool, const std::string &hostDat | |||
| 173 | TimeLogger t{"Dump model name data start"}; | 173 | TimeLogger t{"Dump model name data start"}; |
| 174 | std::shared_ptr<GraphIdParser> parser; | 174 | std::shared_ptr<GraphIdParser> parser; |
| 175 | MAKE_SHARED_RETURN_VOID(parser, GraphIdParser, hostDataPath); | 175 | MAKE_SHARED_RETURN_VOID(parser, GraphIdParser, hostDataPath); |
| 176 | - auto traces = parser->ParseData<MsprofAdditionalInfo>(); | 176 | + auto traces = parser->ParseData<ParserAdditionalInfo>(); |
| 177 | // ModelName 数据落盘 | 177 | // ModelName 数据落盘 |
| 178 | std::shared_ptr<ModelNameDBDumper> modelNameDumper; | 178 | std::shared_ptr<ModelNameDBDumper> modelNameDumper; |
| 179 | MAKE_SHARED_RETURN_VOID(modelNameDumper, ModelNameDBDumper, hostPath_); | 179 | MAKE_SHARED_RETURN_VOID(modelNameDumper, ModelNameDBDumper, hostPath_); |
| @@ -209,7 +209,7 @@ void HostTraceWorker::DumpMemcpyInfo(const std::string &hostDataPath) | |||
| 209 | TimeLogger t{"Dump memcpy info data start"}; | 209 | TimeLogger t{"Dump memcpy info data start"}; |
| 210 | std::shared_ptr<MemcpyInfoParser> parser; | 210 | std::shared_ptr<MemcpyInfoParser> parser; |
| 211 | MAKE_SHARED_RETURN_VOID(parser, MemcpyInfoParser, hostDataPath); | 211 | MAKE_SHARED_RETURN_VOID(parser, MemcpyInfoParser, hostDataPath); |
| 212 | - auto traces = parser->ParseData<MsprofCompactInfo>(); | 212 | + auto traces = parser->ParseData<ParserCompactInfo>(); |
| 213 | // MemcpyInfo 数据落盘 | 213 | // MemcpyInfo 数据落盘 |
| 214 | std::shared_ptr<MemcpyInfoDumper> memcpyInfoDumper; | 214 | std::shared_ptr<MemcpyInfoDumper> memcpyInfoDumper; |
| 215 | MAKE_SHARED_RETURN_VOID(memcpyInfoDumper, MemcpyInfoDumper, hostPath_); | 215 | MAKE_SHARED_RETURN_VOID(memcpyInfoDumper, MemcpyInfoDumper, hostPath_); |
| @@ -23,7 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 26 | +#include "analysis/csrc/infrastructure/utils/prof_struct.h" |
| 27 | 27 | ||
| 28 | namespace Analysis | 28 | namespace Analysis |
| 29 | { | 29 | { |
| @@ -17,22 +17,44 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | + | ||
| 21 | + | ||
| 20 | 22 | ||
| 21 | 23 | ||
| 22 | -namespace Analysis { | 24 | +namespace Analysis |
| 23 | -namespace Domain { | ||
| 24 | -namespace Host { | ||
| 25 | -namespace Cann { | ||
| 26 | -using namespace Analysis::Utils; | ||
| 27 | -namespace { | ||
| 28 | -std::shared_ptr<ConcatTensorInfo> CreateConcatTensorInfo(MsprofAdditionalInfo *additionalInfo) | ||
| 29 | { | 25 | { |
| 30 | - if (!additionalInfo) { | 26 | +namespace Domain |
| 27 | +{ | ||
| 28 | +namespace Host | ||
| 29 | +{ | ||
| 30 | +namespace Cann | ||
| 31 | +{ | ||
| 32 | +using namespace Analysis::Utils; | ||
| 33 | +using namespace Analysis::Domain::Adapter; | ||
| 34 | +namespace | ||
| 35 | +{ | ||
| 36 | +ParserTensorData ConvertTensorData(const MsrofTensorData &src) | ||
| 37 | +{ | ||
| 38 | + ParserTensorData dst; | ||
| 39 | + dst.tensorType = src.tensorType; | ||
| 40 | + dst.format = src.format; | ||
| 41 | + dst.dataType = src.dataType; | ||
| 42 | + for (uint32_t i = 0; i < MSPROF_GE_TENSOR_DATA_SHAPE_LEN; ++i) | ||
| 43 | + { | ||
| 44 | + dst.shape[i] = src.shape[i]; | ||
| 45 | + } | ||
| 46 | + return dst; | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +std::shared_ptr<ParserConcatTensorInfo> CreateConcatTensorInfo(MsprofAdditionalInfo *additionalInfo) | ||
| 50 | +{ | ||
| 51 | + if (!additionalInfo) | ||
| 52 | + { | ||
| 31 | ERROR("Additional info is null."); | 53 | ERROR("Additional info is null."); |
| 32 | return nullptr; | 54 | return nullptr; |
| 33 | } | 55 | } |
| 34 | - std::shared_ptr<ConcatTensorInfo> concatTensorInfo; | 56 | + std::shared_ptr<ParserConcatTensorInfo> concatTensorInfo; |
| 35 | - MAKE_SHARED0_RETURN_VALUE(concatTensorInfo, ConcatTensorInfo, nullptr); | 57 | + MAKE_SHARED0_RETURN_VALUE(concatTensorInfo, ParserConcatTensorInfo, nullptr); |
| 36 | 58 | ||
| 37 | concatTensorInfo->level = additionalInfo->level; | 59 | concatTensorInfo->level = additionalInfo->level; |
| 38 | concatTensorInfo->type = additionalInfo->type; | 60 | concatTensorInfo->type = additionalInfo->type; |
| @@ -42,8 +64,9 @@ std::shared_ptr<ConcatTensorInfo> CreateConcatTensorInfo(MsprofAdditionalInfo *a | |||
| 42 | auto tensorInfo = ReinterpretConvert<MsprofTensorInfo *>(additionalInfo->data); | 64 | auto tensorInfo = ReinterpretConvert<MsprofTensorInfo *>(additionalInfo->data); |
| 43 | concatTensorInfo->opName = tensorInfo->opName; | 65 | concatTensorInfo->opName = tensorInfo->opName; |
| 44 | concatTensorInfo->tensorNum = tensorInfo->tensorNum; | 66 | concatTensorInfo->tensorNum = tensorInfo->tensorNum; |
| 45 | - for (uint32_t i = 0; i < tensorInfo->tensorNum; ++i) { | 67 | + for (uint32_t i = 0; i < tensorInfo->tensorNum; ++i) |
| 46 | - concatTensorInfo->tensorData[i] = tensorInfo->tensorData[i]; | 68 | + { |
| 69 | + concatTensorInfo->tensorData[i] = ConvertTensorData(tensorInfo->tensorData[i]); | ||
| 47 | } | 70 | } |
| 48 | return concatTensorInfo; | 71 | return concatTensorInfo; |
| 49 | } | 72 | } |
| @@ -54,69 +77,89 @@ void AdditionInfoParser::Init(const std::vector<std::string> &filePrefix) | |||
| 54 | MAKE_SHARED_RETURN_VOID(chunkProducer_, ChunkGenerator, sizeof(MsprofAdditionalInfo), path_, filePrefix); | 77 | MAKE_SHARED_RETURN_VOID(chunkProducer_, ChunkGenerator, sizeof(MsprofAdditionalInfo), path_, filePrefix); |
| 55 | } | 78 | } |
| 56 | 79 | ||
| 57 | -template<> | 80 | +template <> |
| 58 | -std::vector<std::shared_ptr<MsprofAdditionalInfo>> AdditionInfoParser::GetData() | 81 | +std::vector<std::shared_ptr<ParserAdditionalInfo>> AdditionInfoParser::GetData() |
| 59 | { | 82 | { |
| 60 | return additionalData_; | 83 | return additionalData_; |
| 61 | } | 84 | } |
| 62 | 85 | ||
| 63 | -template<> | 86 | +template <> |
| 64 | -std::vector<std::shared_ptr<ConcatTensorInfo>> AdditionInfoParser::GetData() | 87 | +std::vector<std::shared_ptr<ParserConcatTensorInfo>> AdditionInfoParser::GetData() |
| 65 | { | 88 | { |
| 66 | return concatTensorData_; | 89 | return concatTensorData_; |
| 67 | } | 90 | } |
| 68 | 91 | ||
| 69 | int AdditionInfoParser::ProduceData() | 92 | int AdditionInfoParser::ProduceData() |
| 70 | { | 93 | { |
| 71 | - if (chunkProducer_->Empty()) { | 94 | + if (chunkProducer_->Empty()) |
| 95 | + { | ||
| 72 | return ANALYSIS_OK; | 96 | return ANALYSIS_OK; |
| 73 | } | 97 | } |
| 74 | - if (!Reserve(additionalData_, chunkProducer_->Size())) { | 98 | + if (!Reserve(additionalData_, chunkProducer_->Size())) |
| 99 | + { | ||
| 75 | ERROR("%: Reserve data failed", parserName_); | 100 | ERROR("%: Reserve data failed", parserName_); |
| 76 | return ANALYSIS_ERROR; | 101 | return ANALYSIS_ERROR; |
| 77 | } | 102 | } |
| 78 | - while (!chunkProducer_->Empty()) { | 103 | + while (!chunkProducer_->Empty()) |
| 104 | + { | ||
| 79 | auto additionalInfo = ReinterpretConvert<MsprofAdditionalInfo *>(chunkProducer_->Pop()); | 105 | auto additionalInfo = ReinterpretConvert<MsprofAdditionalInfo *>(chunkProducer_->Pop()); |
| 80 | - if (!additionalInfo) { | 106 | + if (!additionalInfo) |
| 107 | + { | ||
| 81 | ERROR("%: Pop chunk failed.", parserName_); | 108 | ERROR("%: Pop chunk failed.", parserName_); |
| 82 | return ANALYSIS_ERROR; | 109 | return ANALYSIS_ERROR; |
| 83 | } | 110 | } |
| 84 | - if (additionalInfo->magicNumber != MSPROF_DATA_HEAD_MAGIC_NUM) { | 111 | + if (additionalInfo->magicNumber != MSPROF_DATA_HEAD_MAGIC_NUM) |
| 112 | + { | ||
| 85 | ERROR("%: The last %th data check failed.", parserName_, chunkProducer_->Size()); | 113 | ERROR("%: The last %th data check failed.", parserName_, chunkProducer_->Size()); |
| 86 | delete additionalInfo; | 114 | delete additionalInfo; |
| 87 | continue; | 115 | continue; |
| 88 | } | 116 | } |
| 89 | - additionalData_.emplace_back(std::shared_ptr<MsprofAdditionalInfo>(additionalInfo)); | 117 | + auto parser = std::make_shared<ParserAdditionalInfo>(); |
| 118 | + if (!ParserAdditionalInfoAdapter::AdapterAdditionalInfo(additionalInfo, parser.get(), parserType_)) | ||
| 119 | + { | ||
| 120 | + ERROR("%: copy addition info data failed.", parserName_); | ||
| 121 | + delete additionalInfo; | ||
| 122 | + return ANALYSIS_ERROR; | ||
| 123 | + } | ||
| 124 | + delete additionalInfo; | ||
| 125 | + additionalData_.emplace_back(std::move(parser)); | ||
| 90 | } | 126 | } |
| 91 | return ANALYSIS_OK; | 127 | return ANALYSIS_OK; |
| 92 | } | 128 | } |
| 93 | 129 | ||
| 94 | int TensorInfoParser::ProduceData() | 130 | int TensorInfoParser::ProduceData() |
| 95 | { | 131 | { |
| 96 | - if (chunkProducer_->Empty()) { | 132 | + if (chunkProducer_->Empty()) |
| 133 | + { | ||
| 97 | return ANALYSIS_OK; | 134 | return ANALYSIS_OK; |
| 98 | } | 135 | } |
| 99 | - if (!Reserve(concatTensorData_, chunkProducer_->Size())) { | 136 | + if (!Reserve(concatTensorData_, chunkProducer_->Size())) |
| 137 | + { | ||
| 100 | ERROR("%: Reserve data failed", parserName_); | 138 | ERROR("%: Reserve data failed", parserName_); |
| 101 | return ANALYSIS_ERROR; | 139 | return ANALYSIS_ERROR; |
| 102 | } | 140 | } |
| 103 | - std::unordered_map<std::string, std::shared_ptr<ConcatTensorInfo>> concatTensorMap; | 141 | + std::unordered_map<std::string, std::shared_ptr<ParserConcatTensorInfo>> concatTensorMap; |
| 104 | - while (!chunkProducer_->Empty()) { | 142 | + while (!chunkProducer_->Empty()) |
| 143 | + { | ||
| 105 | auto currTensorInfo = ReinterpretConvert<MsprofAdditionalInfo *>(chunkProducer_->Pop()); | 144 | auto currTensorInfo = ReinterpretConvert<MsprofAdditionalInfo *>(chunkProducer_->Pop()); |
| 106 | - if (!currTensorInfo) { | 145 | + if (!currTensorInfo) |
| 146 | + { | ||
| 107 | ERROR("%: Pop chunk failed.", parserName_); | 147 | ERROR("%: Pop chunk failed.", parserName_); |
| 108 | return ANALYSIS_ERROR; | 148 | return ANALYSIS_ERROR; |
| 109 | } | 149 | } |
| 110 | - if (currTensorInfo->magicNumber != MSPROF_DATA_HEAD_MAGIC_NUM) { | 150 | + if (currTensorInfo->magicNumber != MSPROF_DATA_HEAD_MAGIC_NUM) |
| 151 | + { | ||
| 111 | ERROR("%: The last %th data check failed.", parserName_, chunkProducer_->Size()); | 152 | ERROR("%: The last %th data check failed.", parserName_, chunkProducer_->Size()); |
| 112 | delete currTensorInfo; | 153 | delete currTensorInfo; |
| 113 | continue; | 154 | continue; |
| 114 | } | 155 | } |
| 115 | auto currTensor = ReinterpretConvert<MsprofTensorInfo *>(currTensorInfo->data); | 156 | auto currTensor = ReinterpretConvert<MsprofTensorInfo *>(currTensorInfo->data); |
| 116 | std::string key = Utils::Join("_", currTensor->opName, currTensorInfo->timeStamp, currTensorInfo->threadId); | 157 | std::string key = Utils::Join("_", currTensor->opName, currTensorInfo->timeStamp, currTensorInfo->threadId); |
| 117 | - if (concatTensorMap.find(key) == concatTensorMap.end()) { | 158 | + if (concatTensorMap.find(key) == concatTensorMap.end()) |
| 159 | + { | ||
| 118 | auto concatTensor = CreateConcatTensorInfo(currTensorInfo); | 160 | auto concatTensor = CreateConcatTensorInfo(currTensorInfo); |
| 119 | - if (!concatTensor) { | 161 | + if (!concatTensor) |
| 162 | + { | ||
| 120 | ERROR("%: Create concat tensor failed."); | 163 | ERROR("%: Create concat tensor failed."); |
| 121 | delete currTensorInfo; | 164 | delete currTensorInfo; |
| 122 | return ANALYSIS_ERROR; | 165 | return ANALYSIS_ERROR; |
| @@ -127,22 +170,27 @@ int TensorInfoParser::ProduceData() | |||
| 127 | } | 170 | } |
| 128 | auto concatTensor = concatTensorMap[key]; | 171 | auto concatTensor = concatTensorMap[key]; |
| 129 | // tensor info拼接 | 172 | // tensor info拼接 |
| 130 | - for (uint32_t i = 0; i < currTensor->tensorNum; ++i) { | 173 | + for (uint32_t i = 0; i < currTensor->tensorNum; ++i) |
| 131 | - if (concatTensor->tensorNum >= MSPROF_GE_TENSOR_DATA_NUM) { | 174 | + { |
| 132 | - concatTensor->tensorData.emplace_back(currTensor->tensorData[i]); | 175 | + if (concatTensor->tensorNum >= MSPROF_GE_TENSOR_DATA_NUM) |
| 133 | - } else { | 176 | + { |
| 134 | - concatTensor->tensorData[concatTensor->tensorNum] = currTensor->tensorData[i]; | 177 | + concatTensor->tensorData.emplace_back(ConvertTensorData(currTensor->tensorData[i])); |
| 178 | + } | ||
| 179 | + else | ||
| 180 | + { | ||
| 181 | + concatTensor->tensorData[concatTensor->tensorNum] = ConvertTensorData(currTensor->tensorData[i]); | ||
| 135 | } | 182 | } |
| 136 | concatTensor->tensorNum += 1; | 183 | concatTensor->tensorNum += 1; |
| 137 | } | 184 | } |
| 138 | delete currTensorInfo; | 185 | delete currTensorInfo; |
| 139 | } | 186 | } |
| 140 | - for (const auto &kv: concatTensorMap) { | 187 | + for (const auto &kv : concatTensorMap) |
| 188 | + { | ||
| 141 | concatTensorData_.emplace_back(kv.second); | 189 | concatTensorData_.emplace_back(kv.second); |
| 142 | } | 190 | } |
| 143 | return ANALYSIS_OK; | 191 | return ANALYSIS_OK; |
| 144 | } | 192 | } |
| 145 | } // namespace Cann | 193 | } // namespace Cann |
| 146 | } // namespace Host | 194 | } // namespace Host |
| 147 | -} // namespace Parser | 195 | +} // namespace Domain |
| 148 | } // namespace Analysis | 196 | } // namespace Analysis |
| @@ -21,37 +21,48 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 24 | +#include "analysis/csrc/infrastructure/utils/parser_struct.h" |
| 25 | + | ||
| 25 | 26 | ||
| 26 | -namespace Analysis { | 27 | +namespace Analysis |
| 27 | -namespace Domain { | 28 | +{ |
| 28 | -namespace Host { | 29 | +namespace Domain |
| 29 | -namespace Cann { | 30 | +{ |
| 31 | +namespace Host | ||
| 32 | +{ | ||
| 33 | +namespace Cann | ||
| 34 | +{ | ||
| 30 | // 该类的作用是Addition数据的解析 | 35 | // 该类的作用是Addition数据的解析 |
| 31 | -class AdditionInfoParser : public BaseParser<AdditionInfoParser> { | 36 | +class AdditionInfoParser : public BaseParser<AdditionInfoParser> |
| 32 | -public: | 37 | +{ |
| 33 | - explicit AdditionInfoParser(const std::string &path, const std::string &parserName) | 38 | + public: |
| 34 | - : BaseParser(path, parserName) {} | 39 | + explicit AdditionInfoParser(const std::string &path, const std::string &parserName) : BaseParser(path, parserName) |
| 40 | + { | ||
| 41 | + } | ||
| 35 | void Init(const std::vector<std::string> &filePrefix); | 42 | void Init(const std::vector<std::string> &filePrefix); |
| 36 | - template<typename T> std::vector<std::shared_ptr<T>> GetData(); | 43 | + template <typename T> |
| 44 | + std::vector<std::shared_ptr<T>> GetData(); | ||
| 45 | + AdditionalInfoFormat parserType_ = AdditionalInfoFormat::ADDITIONAL_INFO_TYPE; | ||
| 37 | 46 | ||
| 38 | -protected: | 47 | + protected: |
| 39 | int ProduceData() override; | 48 | int ProduceData() override; |
| 40 | 49 | ||
| 41 | -protected: | 50 | + protected: |
| 42 | - std::vector<std::shared_ptr<MsprofAdditionalInfo>> additionalData_; // not owned | 51 | + std::vector<std::shared_ptr<ParserAdditionalInfo>> additionalData_; // not owned |
| 43 | - std::vector<std::shared_ptr<ConcatTensorInfo>> concatTensorData_; // not owned | 52 | + std::vector<std::shared_ptr<ParserConcatTensorInfo>> concatTensorData_; // not owned |
| 44 | }; // class AdditionInfoParser | 53 | }; // class AdditionInfoParser |
| 45 | 54 | ||
| 46 | // 该类的作用是CtxId数据的解析 | 55 | // 该类的作用是CtxId数据的解析 |
| 47 | -class CtxIdParser final : public AdditionInfoParser { | 56 | +class CtxIdParser final : public AdditionInfoParser |
| 48 | -public: | 57 | +{ |
| 58 | + public: | ||
| 49 | explicit CtxIdParser(const std::string &path) : AdditionInfoParser(path, "CtxIdParser") | 59 | explicit CtxIdParser(const std::string &path) : AdditionInfoParser(path, "CtxIdParser") |
| 50 | { | 60 | { |
| 61 | + parserType_ = AdditionalInfoFormat::CONTEXT_ID_INFO_TYPE; | ||
| 51 | Init(filePrefix_); | 62 | Init(filePrefix_); |
| 52 | } | 63 | } |
| 53 | 64 | ||
| 54 | -private: | 65 | + private: |
| 55 | std::vector<std::string> filePrefix_ = { | 66 | std::vector<std::string> filePrefix_ = { |
| 56 | "unaging.additional.context_id_info.slice", | 67 | "unaging.additional.context_id_info.slice", |
| 57 | "aging.additional.context_id_info.slice", | 68 | "aging.additional.context_id_info.slice", |
| @@ -59,14 +70,16 @@ private: | |||
| 59 | }; // class CtxIdParser | 70 | }; // class CtxIdParser |
| 60 | 71 | ||
| 61 | // 该类的作用是fusion op数据的解析 | 72 | // 该类的作用是fusion op数据的解析 |
| 62 | -class FusionOpInfoParser final : public AdditionInfoParser { | 73 | +class FusionOpInfoParser final : public AdditionInfoParser |
| 63 | -public: | 74 | +{ |
| 75 | + public: | ||
| 64 | explicit FusionOpInfoParser(const std::string &path) : AdditionInfoParser(path, "FusionOpInfoParser") | 76 | explicit FusionOpInfoParser(const std::string &path) : AdditionInfoParser(path, "FusionOpInfoParser") |
| 65 | { | 77 | { |
| 78 | + parserType_ = AdditionalInfoFormat::FUSION_OP_INFO_TYPE; | ||
| 66 | Init(filePrefix_); | 79 | Init(filePrefix_); |
| 67 | } | 80 | } |
| 68 | 81 | ||
| 69 | -private: | 82 | + private: |
| 70 | std::vector<std::string> filePrefix_ = { | 83 | std::vector<std::string> filePrefix_ = { |
| 71 | "unaging.additional.fusion_op_info.slice", | 84 | "unaging.additional.fusion_op_info.slice", |
| 72 | "aging.additional.fusion_op_info.slice", | 85 | "aging.additional.fusion_op_info.slice", |
| @@ -74,14 +87,16 @@ private: | |||
| 74 | }; // class FusionOpInfoParser | 87 | }; // class FusionOpInfoParser |
| 75 | 88 | ||
| 76 | // 该类的作用是graph_id_map数据的解析 | 89 | // 该类的作用是graph_id_map数据的解析 |
| 77 | -class GraphIdParser final : public AdditionInfoParser { | 90 | +class GraphIdParser final : public AdditionInfoParser |
| 78 | -public: | 91 | +{ |
| 92 | + public: | ||
| 79 | explicit GraphIdParser(const std::string &path) : AdditionInfoParser(path, "GraphIdParser") | 93 | explicit GraphIdParser(const std::string &path) : AdditionInfoParser(path, "GraphIdParser") |
| 80 | { | 94 | { |
| 95 | + parserType_ = AdditionalInfoFormat::GRAPH_ID_TYPE; | ||
| 81 | Init(filePrefix_); | 96 | Init(filePrefix_); |
| 82 | } | 97 | } |
| 83 | 98 | ||
| 84 | -private: | 99 | + private: |
| 85 | std::vector<std::string> filePrefix_ = { | 100 | std::vector<std::string> filePrefix_ = { |
| 86 | "unaging.additional.graph_id_map.slice", | 101 | "unaging.additional.graph_id_map.slice", |
| 87 | "aging.additional.graph_id_map.slice", | 102 | "aging.additional.graph_id_map.slice", |
| @@ -89,17 +104,19 @@ private: | |||
| 89 | }; // class GraphIdParser | 104 | }; // class GraphIdParser |
| 90 | 105 | ||
| 91 | // 该类的作用是tensor info数据的解析 | 106 | // 该类的作用是tensor info数据的解析 |
| 92 | -class TensorInfoParser final : public AdditionInfoParser { | 107 | +class TensorInfoParser final : public AdditionInfoParser |
| 93 | -public: | 108 | +{ |
| 109 | + public: | ||
| 94 | explicit TensorInfoParser(const std::string &path) : AdditionInfoParser(path, "TensorInfoParser") | 110 | explicit TensorInfoParser(const std::string &path) : AdditionInfoParser(path, "TensorInfoParser") |
| 95 | { | 111 | { |
| 112 | + parserType_ = AdditionalInfoFormat::TENSOR_INFO_TYPE; | ||
| 96 | Init(filePrefix_); | 113 | Init(filePrefix_); |
| 97 | } | 114 | } |
| 98 | 115 | ||
| 99 | -private: | 116 | + private: |
| 100 | int ProduceData() override; | 117 | int ProduceData() override; |
| 101 | 118 | ||
| 102 | -private: | 119 | + private: |
| 103 | std::vector<std::string> filePrefix_ = { | 120 | std::vector<std::string> filePrefix_ = { |
| 104 | "unaging.additional.tensor_info.slice", | 121 | "unaging.additional.tensor_info.slice", |
| 105 | "aging.additional.tensor_info.slice", | 122 | "aging.additional.tensor_info.slice", |
| @@ -107,14 +124,16 @@ private: | |||
| 107 | }; // class TensorInfoParser | 124 | }; // class TensorInfoParser |
| 108 | 125 | ||
| 109 | // 该类的作用是hccl info数据的解析 | 126 | // 该类的作用是hccl info数据的解析 |
| 110 | -class HcclInfoParser final : public AdditionInfoParser { | 127 | +class HcclInfoParser final : public AdditionInfoParser |
| 111 | -public: | 128 | +{ |
| 129 | + public: | ||
| 112 | explicit HcclInfoParser(const std::string &path) : AdditionInfoParser(path, "HcclInfoParser") | 130 | explicit HcclInfoParser(const std::string &path) : AdditionInfoParser(path, "HcclInfoParser") |
| 113 | { | 131 | { |
| 132 | + parserType_ = AdditionalInfoFormat::HCCL_INFO_TYPE; | ||
| 114 | Init(filePrefix_); | 133 | Init(filePrefix_); |
| 115 | } | 134 | } |
| 116 | 135 | ||
| 117 | -private: | 136 | + private: |
| 118 | std::vector<std::string> filePrefix_ = { | 137 | std::vector<std::string> filePrefix_ = { |
| 119 | "unaging.additional.hccl_info.slice", | 138 | "unaging.additional.hccl_info.slice", |
| 120 | "aging.additional.hccl_info.slice", | 139 | "aging.additional.hccl_info.slice", |
| @@ -122,14 +141,16 @@ private: | |||
| 122 | }; // class HcclInfoParser | 141 | }; // class HcclInfoParser |
| 123 | 142 | ||
| 124 | // 该类的作用是memory application数据的解析 | 143 | // 该类的作用是memory application数据的解析 |
| 125 | -class MemoryApplicationParser final : public AdditionInfoParser { | 144 | +class MemoryApplicationParser final : public AdditionInfoParser |
| 126 | -public: | 145 | +{ |
| 146 | + public: | ||
| 127 | explicit MemoryApplicationParser(const std::string &path) : AdditionInfoParser(path, "MemoryApplicationParser") | 147 | explicit MemoryApplicationParser(const std::string &path) : AdditionInfoParser(path, "MemoryApplicationParser") |
| 128 | { | 148 | { |
| 149 | + parserType_ = AdditionalInfoFormat::MEMORY_APPLICATION_TYPE; | ||
| 129 | Init(filePrefix_); | 150 | Init(filePrefix_); |
| 130 | } | 151 | } |
| 131 | 152 | ||
| 132 | -private: | 153 | + private: |
| 133 | std::vector<std::string> filePrefix_ = { | 154 | std::vector<std::string> filePrefix_ = { |
| 134 | "unaging.additional.memory_application.slice", | 155 | "unaging.additional.memory_application.slice", |
| 135 | "aging.additional.memory_application.slice", | 156 | "aging.additional.memory_application.slice", |
| @@ -137,14 +158,16 @@ private: | |||
| 137 | }; // class MemoryApplicationParser | 158 | }; // class MemoryApplicationParser |
| 138 | 159 | ||
| 139 | // 该类的作用是multi thread数据的解析 | 160 | // 该类的作用是multi thread数据的解析 |
| 140 | -class MultiThreadParser final : public AdditionInfoParser { | 161 | +class MultiThreadParser final : public AdditionInfoParser |
| 141 | -public: | 162 | +{ |
| 163 | + public: | ||
| 142 | explicit MultiThreadParser(const std::string &path) : AdditionInfoParser(path, "MultiThreadParser") | 164 | explicit MultiThreadParser(const std::string &path) : AdditionInfoParser(path, "MultiThreadParser") |
| 143 | { | 165 | { |
| 166 | + parserType_ = AdditionalInfoFormat::MULTI_THREAD_TYPE; | ||
| 144 | Init(filePrefix_); | 167 | Init(filePrefix_); |
| 145 | } | 168 | } |
| 146 | 169 | ||
| 147 | -private: | 170 | + private: |
| 148 | std::vector<std::string> filePrefix_ = { | 171 | std::vector<std::string> filePrefix_ = { |
| 149 | "unaging.additional.Multi_Thread.slice", | 172 | "unaging.additional.Multi_Thread.slice", |
| 150 | "aging.additional.Multi_Thread.slice", | 173 | "aging.additional.Multi_Thread.slice", |
| @@ -155,4 +178,4 @@ private: | |||
| 155 | } // namespace Domain | 178 | } // namespace Domain |
| 156 | } // namespace Analysis | 179 | } // namespace Analysis |
| 157 | 180 | ||
| 158 | -#endif // ANALYSIS_PARSER_HOST_CANN_ADDITION_INFO_PARSER_H | 181 | +#endif // ANALYSIS_PARSER_HOST_CANN_ADDITION_INFO_PARSER_H |
| @@ -16,15 +16,22 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | -namespace Analysis { | 19 | +namespace Analysis |
| 20 | -namespace Domain { | 20 | +{ |
| 21 | -namespace Host { | 21 | +namespace Domain |
| 22 | -namespace Cann { | 22 | +{ |
| 23 | +namespace Host | ||
| 24 | +{ | ||
| 25 | +namespace Cann | ||
| 26 | +{ | ||
| 23 | using namespace Analysis::Utils; | 27 | using namespace Analysis::Utils; |
| 24 | -namespace { | 28 | +using namespace Analysis::Domain::Adapter; |
| 29 | +namespace | ||
| 30 | +{ | ||
| 25 | std::shared_ptr<MsprofApi> CreateMsprofApi(const MsprofEvent *startEvent, const MsprofEvent *endEvent) | 31 | std::shared_ptr<MsprofApi> CreateMsprofApi(const MsprofEvent *startEvent, const MsprofEvent *endEvent) |
| 26 | { | 32 | { |
| 27 | - if (!startEvent || !endEvent) { | 33 | + if (!startEvent || !endEvent) |
| 34 | + { | ||
| 28 | ERROR("Event data is null."); | 35 | ERROR("Event data is null."); |
| 29 | return nullptr; | 36 | return nullptr; |
| 30 | } | 37 | } |
| @@ -41,14 +48,16 @@ std::shared_ptr<MsprofApi> CreateMsprofApi(const MsprofEvent *startEvent, const | |||
| 41 | return apiData; | 48 | return apiData; |
| 42 | } | 49 | } |
| 43 | 50 | ||
| 44 | -void ClearStartEventMap(std::map<std::tuple<uint16_t, uint32_t, uint32_t, uint32_t, uint64_t>, | 51 | +void ClearStartEventMap( |
| 45 | - MsprofEvent*>& startEventMap) | 52 | + std::map<std::tuple<uint16_t, uint32_t, uint32_t, uint32_t, uint64_t>, MsprofEvent *> &startEventMap) |
| 46 | { | 53 | { |
| 47 | - if (startEventMap.empty()) { | 54 | + if (startEventMap.empty()) |
| 55 | + { | ||
| 48 | return; | 56 | return; |
| 49 | } | 57 | } |
| 50 | ERROR("There is remaining start event."); | 58 | ERROR("There is remaining start event."); |
| 51 | - for (auto &startEvent : startEventMap) { | 59 | + for (auto &startEvent : startEventMap) |
| 60 | + { | ||
| 52 | delete startEvent.second; | 61 | delete startEvent.second; |
| 53 | startEvent.second = nullptr; | 62 | startEvent.second = nullptr; |
| 54 | } | 63 | } |
| @@ -62,49 +71,64 @@ ApiEventParser::ApiEventParser(const std::string &path) : BaseParser(path, "ApiE | |||
| 62 | MAKE_SHARED_NO_OPERATION(chunkProducer_, ChunkGenerator, sizeof(MsprofApi), path_, filePrefix_); | 71 | MAKE_SHARED_NO_OPERATION(chunkProducer_, ChunkGenerator, sizeof(MsprofApi), path_, filePrefix_); |
| 63 | } | 72 | } |
| 64 | 73 | ||
| 65 | -template<> | 74 | +template <> |
| 66 | -std::vector<std::shared_ptr<MsprofApi>> ApiEventParser::GetData() | 75 | +std::vector<std::shared_ptr<ParserApi>> ApiEventParser::GetData() |
| 67 | { | 76 | { |
| 68 | return apiData_; | 77 | return apiData_; |
| 69 | } | 78 | } |
| 70 | 79 | ||
| 71 | -template<> | 80 | +template <> |
| 72 | -std::vector<std::shared_ptr<MsprofEvent>> ApiEventParser::GetData() | 81 | +std::vector<std::shared_ptr<ParserEvent>> ApiEventParser::GetData() |
| 73 | { | 82 | { |
| 74 | return eventData_; | 83 | return eventData_; |
| 75 | } | 84 | } |
| 76 | 85 | ||
| 77 | int ApiEventParser::ProduceData() | 86 | int ApiEventParser::ProduceData() |
| 78 | { | 87 | { |
| 79 | - if (chunkProducer_->Empty()) { | 88 | + if (chunkProducer_->Empty()) |
| 89 | + { | ||
| 80 | return ANALYSIS_OK; | 90 | return ANALYSIS_OK; |
| 81 | } | 91 | } |
| 82 | - std::map<std::tuple<uint16_t, uint32_t, uint32_t, uint32_t, uint64_t>, MsprofEvent*> startEventMap; | 92 | + std::map<std::tuple<uint16_t, uint32_t, uint32_t, uint32_t, uint64_t>, MsprofEvent *> startEventMap; |
| 83 | - if (!Reserve(apiData_, chunkProducer_->Size())) { | 93 | + if (!Reserve(apiData_, chunkProducer_->Size())) |
| 94 | + { | ||
| 84 | ERROR("%: Reserve data failed", parserName_); | 95 | ERROR("%: Reserve data failed", parserName_); |
| 85 | return ANALYSIS_ERROR; | 96 | return ANALYSIS_ERROR; |
| 86 | } | 97 | } |
| 87 | - while (!chunkProducer_->Empty()) { | 98 | + while (!chunkProducer_->Empty()) |
| 88 | - auto event = ReinterpretConvert<MsprofEvent*>(chunkProducer_->Pop()); | 99 | + { |
| 89 | - if (!event) { | 100 | + auto event = ReinterpretConvert<MsprofEvent *>(chunkProducer_->Pop()); |
| 101 | + if (!event) | ||
| 102 | + { | ||
| 90 | ERROR("%: Pop chunk failed.", parserName_); | 103 | ERROR("%: Pop chunk failed.", parserName_); |
| 91 | ClearStartEventMap(startEventMap); | 104 | ClearStartEventMap(startEventMap); |
| 92 | return ANALYSIS_ERROR; | 105 | return ANALYSIS_ERROR; |
| 93 | } | 106 | } |
| 94 | - if (event->magicNumber != MSPROF_DATA_HEAD_MAGIC_NUM) { | 107 | + if (event->magicNumber != MSPROF_DATA_HEAD_MAGIC_NUM) |
| 108 | + { | ||
| 95 | ERROR("%: The last %th data check failed.", parserName_, chunkProducer_->Size()); | 109 | ERROR("%: The last %th data check failed.", parserName_, chunkProducer_->Size()); |
| 96 | delete event; | 110 | delete event; |
| 97 | continue; | 111 | continue; |
| 98 | } | 112 | } |
| 99 | - if (event->reserve != MSPROF_EVENT_FLAG) { | 113 | + if (event->reserve != MSPROF_EVENT_FLAG) |
| 114 | + { | ||
| 100 | // api data | 115 | // api data |
| 101 | - apiData_.emplace_back(std::shared_ptr<MsprofApi>(ReinterpretConvert<MsprofApi*>(event))); | 116 | + auto parser = std::make_shared<ParserApi>(); |
| 117 | + if (!ParserApiAdapter::AdapterApi(ReinterpretConvert<MsprofApi *>(event), parser.get())) | ||
| 118 | + { | ||
| 119 | + ERROR("%: copy api data data failed.", parserName_); | ||
| 120 | + delete event; | ||
| 121 | + return ANALYSIS_ERROR; | ||
| 122 | + } | ||
| 123 | + apiData_.emplace_back(parser); | ||
| 124 | + delete event; | ||
| 102 | continue; | 125 | continue; |
| 103 | } | 126 | } |
| 104 | // event data,根据level, type, threadId, requestId, itemId合并start event和end event | 127 | // event data,根据level, type, threadId, requestId, itemId合并start event和end event |
| 105 | auto key = std::make_tuple(event->level, event->type, event->threadId, event->requestId, event->itemId); | 128 | auto key = std::make_tuple(event->level, event->type, event->threadId, event->requestId, event->itemId); |
| 106 | auto iter = startEventMap.find(key); | 129 | auto iter = startEventMap.find(key); |
| 107 | - if (iter == startEventMap.end()) { | 130 | + if (iter == startEventMap.end()) |
| 131 | + { | ||
| 108 | startEventMap[key] = event; | 132 | startEventMap[key] = event; |
| 109 | continue; | 133 | continue; |
| 110 | } | 134 | } |
| @@ -113,17 +137,24 @@ int ApiEventParser::ProduceData() | |||
| 113 | startEventMap.erase(iter); | 137 | startEventMap.erase(iter); |
| 114 | delete startEvent; | 138 | delete startEvent; |
| 115 | delete event; | 139 | delete event; |
| 116 | - if (!apiData) { | 140 | + if (!apiData) |
| 141 | + { | ||
| 117 | ERROR("Api data is null."); | 142 | ERROR("Api data is null."); |
| 118 | ClearStartEventMap(startEventMap); | 143 | ClearStartEventMap(startEventMap); |
| 119 | return ANALYSIS_ERROR; | 144 | return ANALYSIS_ERROR; |
| 120 | } | 145 | } |
| 121 | - apiData_.emplace_back(apiData); | 146 | + auto parser = std::make_shared<ParserApi>(); |
| 147 | + if (!ParserApiAdapter::AdapterApi(apiData.get(), parser.get())) | ||
| 148 | + { | ||
| 149 | + ERROR("%: copy api data data failed.", parserName_); | ||
| 150 | + return ANALYSIS_ERROR; | ||
| 151 | + } | ||
| 152 | + apiData_.emplace_back(parser); | ||
| 122 | } | 153 | } |
| 123 | ClearStartEventMap(startEventMap); | 154 | ClearStartEventMap(startEventMap); |
| 124 | return ANALYSIS_OK; | 155 | return ANALYSIS_OK; |
| 125 | } | 156 | } |
| 126 | } // namespace Cann | 157 | } // namespace Cann |
| 127 | } // namespace Host | 158 | } // namespace Host |
| 128 | -} // namespace Parser | 159 | +} // namespace Domain |
| 129 | } // namespace Analysis | 160 | } // namespace Analysis |
| @@ -20,25 +20,32 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | + | ||
| 23 | 24 | ||
| 24 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 25 | +#include "analysis/csrc/infrastructure/utils/parser_struct.h" |
| 25 | 26 | ||
| 26 | -namespace Analysis { | 27 | +namespace Analysis |
| 27 | -namespace Domain { | 28 | +{ |
| 28 | -namespace Host { | 29 | +namespace Domain |
| 29 | -namespace Cann { | 30 | +{ |
| 31 | +namespace Host | ||
| 32 | +{ | ||
| 33 | +namespace Cann | ||
| 34 | +{ | ||
| 30 | // 该类的作用是Api和Event数据的解析 | 35 | // 该类的作用是Api和Event数据的解析 |
| 31 | -class ApiEventParser final : public BaseParser<ApiEventParser> { | 36 | +class ApiEventParser final : public BaseParser<ApiEventParser> |
| 32 | -public: | 37 | +{ |
| 38 | + public: | ||
| 33 | explicit ApiEventParser(const std::string &path); | 39 | explicit ApiEventParser(const std::string &path); |
| 34 | - template<typename T> std::vector<std::shared_ptr<T>> GetData(); | 40 | + template <typename T> |
| 41 | + std::vector<std::shared_ptr<T>> GetData(); | ||
| 35 | 42 | ||
| 36 | -private: | 43 | + private: |
| 37 | int ProduceData() override; | 44 | int ProduceData() override; |
| 38 | 45 | ||
| 39 | -private: | 46 | + private: |
| 40 | - std::vector<std::shared_ptr<MsprofApi>> apiData_; // not owned | 47 | + std::vector<std::shared_ptr<ParserApi>> apiData_; // not owned |
| 41 | - std::vector<std::shared_ptr<MsprofEvent>> eventData_; // not owned | 48 | + std::vector<std::shared_ptr<ParserEvent>> eventData_; // not owned |
| 42 | std::vector<std::string> filePrefix_ = { | 49 | std::vector<std::string> filePrefix_ = { |
| 43 | "unaging.api_event.data.slice", | 50 | "unaging.api_event.data.slice", |
| 44 | "aging.api_event.data.slice", | 51 | "aging.api_event.data.slice", |
| @@ -46,6 +53,6 @@ private: | |||
| 46 | }; // class ApiEventParser | 53 | }; // class ApiEventParser |
| 47 | } // namespace Cann | 54 | } // namespace Cann |
| 48 | } // namespace Host | 55 | } // namespace Host |
| 49 | -} // namespace Parser | 56 | +} // namespace Domain |
| 50 | } // namespace Analysis | 57 | } // namespace Analysis |
| 51 | -#endif // ANALYSIS_PARSER_HOST_CANN_API_EVENT_PARSER_H | 58 | +#endif // ANALYSIS_PARSER_HOST_CANN_API_EVENT_PARSER_H |
| @@ -18,8 +18,8 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + | ||
| 21 | 22 | ||
| 22 | - | ||
| 23 | 23 | ||
| 24 | namespace Analysis | 24 | namespace Analysis |
| 25 | { | 25 | { |
| @@ -50,7 +50,7 @@ void CompactInfoParser::Init(const std::vector<std::string> &filePrefix) | |||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | template <> | 52 | template <> |
| 53 | -std::vector<std::shared_ptr<MsprofCompactInfo>> CompactInfoParser::GetData() | 53 | +std::vector<std::shared_ptr<ParserCompactInfo>> CompactInfoParser::GetData() |
| 54 | { | 54 | { |
| 55 | return compactData_; | 55 | return compactData_; |
| 56 | } | 56 | } |
| @@ -86,7 +86,15 @@ int CompactInfoParser::ProduceData() | |||
| 86 | delete compactInfo; | 86 | delete compactInfo; |
| 87 | continue; | 87 | continue; |
| 88 | } | 88 | } |
| 89 | - compactData_.emplace_back(std::shared_ptr<MsprofCompactInfo>(compactInfo)); | 89 | + auto parserCompactInfo = std::make_shared<ParserCompactInfo>(); |
C 【review】【性能】解析热路径每事件增加一次堆分配与逐字段拷贝
![]() ![]() | |||
| 90 | + if (!ParserCompactInfoAdapter::AdapterCompactInfo(compactInfo, parserCompactInfo.get(), parserType_)) | ||
| 91 | + { | ||
| 92 | + ERROR("%: copy compactInfo data failed.", parserName_); | ||
| 93 | + delete compactInfo; | ||
| 94 | + return ANALYSIS_ERROR; | ||
| 95 | + } | ||
| 96 | + delete compactInfo; | ||
| 97 | + compactData_.emplace_back(std::move(parserCompactInfo)); | ||
| 90 | } | 98 | } |
| 91 | return ANALYSIS_OK; | 99 | return ANALYSIS_OK; |
| 92 | } | 100 | } |
| @@ -132,31 +140,21 @@ int NodeBasicInfoParser::ProduceData() | |||
| 132 | delete compactInfo; | 140 | delete compactInfo; |
| 133 | continue; | 141 | continue; |
| 134 | } | 142 | } |
| 135 | - compactInfo->data.nodeBasicInfo.opState = opState; | 143 | + auto parserCompactInfo = std::make_shared<ParserCompactInfo>(); |
| 136 | - compactData_.emplace_back(std::shared_ptr<MsprofCompactInfo>(compactInfo)); | 144 | + if (!ParserCompactInfoAdapter::AdapterCompactInfo(compactInfo, parserCompactInfo.get(), parserType_)) |
| 145 | + { | ||
| 146 | + ERROR("%: copy nodeBasic info data failed.", parserName_); | ||
| 147 | + delete compactInfo; | ||
| 148 | + return ANALYSIS_ERROR; | ||
| 149 | + } | ||
| 150 | + parserCompactInfo->data.nodeBasicInfo.opState = opState; | ||
| 151 | + delete compactInfo; | ||
| 152 | + compactData_.emplace_back(std::move(parserCompactInfo)); | ||
| 137 | } | 153 | } |
| 138 | } | 154 | } |
| 139 | return ANALYSIS_OK; | 155 | return ANALYSIS_OK; |
| 140 | } | 156 | } |
| 141 | 157 | ||
| 142 | -void TaskTrackParser::NormalizeRuntimeTrack(MsprofCompactInfo *compactInfo) | ||
| 143 | -{ | ||
| 144 | - // V1数据归一化到V2格式:统一使用runtimeTrackV2,上层不再区分V1/V2 | ||
| 145 | - MsprofRuntimeTrack v1Track = compactInfo->data.runtimeTrack; | ||
| 146 | - compactInfo->data.runtimeTrackV2.deviceId = v1Track.deviceId; | ||
| 147 | - compactInfo->data.runtimeTrackV2.streamId = v1Track.streamId; | ||
| 148 | - compactInfo->data.runtimeTrackV2.taskId = v1Track.taskId; | ||
| 149 | - // v1版本的taskType上报数据不超过uint16_t | ||
| 150 | - compactInfo->data.runtimeTrackV2.taskType = static_cast<uint32_t>(v1Track.taskType); | ||
| 151 | - compactInfo->data.runtimeTrackV2.kernelName = v1Track.kernelName; | ||
| 152 | - errno_t res = memcpy_s(&compactInfo->data.runtimeTrackV2.extInfo, sizeof(compactInfo->data.runtimeTrackV2.extInfo), | ||
| 153 | - &v1Track.extInfo, sizeof(v1Track.extInfo)); | ||
| 154 | - if (res != EOK) | ||
| 155 | - { | ||
| 156 | - errorNum_++; | ||
| 157 | - } | ||
| 158 | -} | ||
| 159 | - | ||
| 160 | int TaskTrackParser::ProduceData() | 158 | int TaskTrackParser::ProduceData() |
| 161 | { | 159 | { |
| 162 | if (chunkProducer_->Empty()) | 160 | if (chunkProducer_->Empty()) |
| @@ -170,7 +168,7 @@ int TaskTrackParser::ProduceData() | |||
| 170 | ERROR("%: Reserve data failed", parserName_); | 168 | ERROR("%: Reserve data failed", parserName_); |
| 171 | return ANALYSIS_ERROR; | 169 | return ANALYSIS_ERROR; |
| 172 | } | 170 | } |
| 173 | - auto isV2 = IsRuntimeTrackV2(); | 171 | + auto runtimeTrackFormat = GetRuntimeTrackFormat(); |
| 174 | while (!chunkProducer_->Empty()) | 172 | while (!chunkProducer_->Empty()) |
| 175 | { | 173 | { |
| 176 | auto compactInfo = ReinterpretConvert<MsprofCompactInfo *>(chunkProducer_->Pop()); | 174 | auto compactInfo = ReinterpretConvert<MsprofCompactInfo *>(chunkProducer_->Pop()); |
| @@ -185,14 +183,17 @@ int TaskTrackParser::ProduceData() | |||
| 185 | delete compactInfo; | 183 | delete compactInfo; |
| 186 | continue; | 184 | continue; |
| 187 | } | 185 | } |
| 188 | - if (!isV2) | 186 | + auto parserCompactInfo = std::make_shared<ParserCompactInfo>(); |
| 187 | + if (!ParserCompactInfoAdapter::AdapterRuntimeTrack(compactInfo, runtimeTrackFormat, parserCompactInfo.get())) | ||
| 189 | { | 188 | { |
| 190 | - NormalizeRuntimeTrack(compactInfo); | 189 | + ERROR("%: copy runtimeTrack data failed.", parserName_); |
| 191 | - } | ||
| 192 | - if (compactInfo->data.runtimeTrackV2.taskType == flipTaskType) | ||
| 193 | - { | ||
| 194 | - auto flipTask = Flip::CreateFlipTask(compactInfo); | ||
| 195 | delete compactInfo; | 190 | delete compactInfo; |
| 191 | + return ANALYSIS_ERROR; | ||
| 192 | + } | ||
| 193 | + delete compactInfo; | ||
| 194 | + if (parserCompactInfo->data.runtimeTrack.taskType == flipTaskType) | ||
| 195 | + { | ||
| 196 | + auto flipTask = Flip::CreateFlipTask(parserCompactInfo.get()); | ||
| 196 | if (!flipTask) | 197 | if (!flipTask) |
| 197 | { | 198 | { |
| 198 | ERROR("FlipTask is null."); | 199 | ERROR("FlipTask is null."); |
| @@ -202,31 +203,29 @@ int TaskTrackParser::ProduceData() | |||
| 202 | continue; | 203 | continue; |
| 203 | } | 204 | } |
| 204 | 205 | ||
| 205 | - if (compactInfo->data.runtimeTrackV2.taskType == maintenanceTaskType) | 206 | + if (parserCompactInfo->data.runtimeTrack.taskType == maintenanceTaskType) |
| 206 | { | 207 | { |
| 207 | - delete compactInfo; | ||
| 208 | continue; | 208 | continue; |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | // Collect DPU kernel name for cross-reference | 211 | // Collect DPU kernel name for cross-reference |
| 212 | - DevType devType = static_cast<DevType>((compactInfo->data.runtimeTrackV2.deviceId >> 12) & 0xF); | 212 | + DevType devType = static_cast<DevType>((parserCompactInfo->data.runtimeTrack.deviceId >> 12) & 0xF); |
| 213 | if (devType == DevType::DPU) | 213 | if (devType == DevType::DPU) |
| 214 | { | 214 | { |
| 215 | - uint16_t devId = compactInfo->data.runtimeTrackV2.deviceId; | 215 | + uint16_t devId = parserCompactInfo->data.runtimeTrack.deviceId; |
| 216 | - uint32_t taskId = compactInfo->data.runtimeTrackV2.taskId; | 216 | + uint32_t taskId = parserCompactInfo->data.runtimeTrack.taskId; |
| 217 | uint64_t key = (static_cast<uint64_t>(devId) << 32) | taskId; | 217 | uint64_t key = (static_cast<uint64_t>(devId) << 32) | taskId; |
| 218 | - dpuKernelNameMap_[key] = compactInfo->data.runtimeTrackV2.kernelName; | 218 | + dpuKernelNameMap_[key] = parserCompactInfo->data.runtimeTrack.kernelName; |
| 219 | - delete compactInfo; | ||
| 220 | continue; | 219 | continue; |
| 221 | } | 220 | } |
| 222 | - compactData_.emplace_back(std::shared_ptr<MsprofCompactInfo>(compactInfo)); | 221 | + compactData_.emplace_back(std::move(parserCompactInfo)); |
| 223 | } | 222 | } |
| 224 | - Sort<MsprofCompactInfo, uint64_t, &MsprofCompactInfo::timeStamp>(compactData_); | 223 | + Sort<ParserCompactInfo, uint64_t, &ParserCompactInfo::timeStamp>(compactData_); |
| 225 | Sort<FlipTask, uint64_t, &FlipTask::timeStamp>(flipTaskData_); | 224 | Sort<FlipTask, uint64_t, &FlipTask::timeStamp>(flipTaskData_); |
| 226 | if (Context::GetInstance().IsAllExport() && | 225 | if (Context::GetInstance().IsAllExport() && |
| 227 | !Environment::Context::GetInstance().IsChipV6(Environment::Context::GetInstance().GetPlatformVersion())) | 226 | !Environment::Context::GetInstance().IsChipV6(Environment::Context::GetInstance().GetPlatformVersion())) |
| 228 | { | 227 | { |
| 229 | - Flip::ComputeBatchId(compactData_, flipTaskData_, isV2); | 228 | + Flip::ComputeBatchId(compactData_, flipTaskData_, runtimeTrackFormat); |
| 230 | } | 229 | } |
| 231 | return ANALYSIS_OK; | 230 | return ANALYSIS_OK; |
| 232 | } | 231 | } |
| @@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 27 | +#include "analysis/csrc/infrastructure/utils/prof_struct.h" |
| 28 | 28 | ||
| 29 | namespace Analysis | 29 | namespace Analysis |
| 30 | { | 30 | { |
| @@ -43,12 +43,13 @@ class CompactInfoParser : public BaseParser<CompactInfoParser> | |||
| 43 | void Init(const std::vector<std::string> &filePrefix); | 43 | void Init(const std::vector<std::string> &filePrefix); |
| 44 | template <typename T> | 44 | template <typename T> |
| 45 | std::vector<std::shared_ptr<T>> GetData(); | 45 | std::vector<std::shared_ptr<T>> GetData(); |
| 46 | + CompactInfoFormat parserType_ = CompactInfoFormat::COMPACT_INFO_TYPE; | ||
| 46 | 47 | ||
| 47 | protected: | 48 | protected: |
| 48 | int ProduceData() override; | 49 | int ProduceData() override; |
| 49 | 50 | ||
| 50 | protected: | 51 | protected: |
| 51 | - std::vector<std::shared_ptr<MsprofCompactInfo>> compactData_; // not owned | 52 | + std::vector<std::shared_ptr<ParserCompactInfo>> compactData_; // not owned |
| 52 | std::vector<std::shared_ptr<Adapter::FlipTask>> flipTaskData_; // not owned | 53 | std::vector<std::shared_ptr<Adapter::FlipTask>> flipTaskData_; // not owned |
| 53 | }; // class CompactInfoParser | 54 | }; // class CompactInfoParser |
| 54 | 55 | ||
| @@ -58,6 +59,7 @@ class NodeBasicInfoParser final : public CompactInfoParser | |||
| 58 | public: | 59 | public: |
| 59 | explicit NodeBasicInfoParser(const std::string &path) : CompactInfoParser(path, "NodeBasicInfoParser") | 60 | explicit NodeBasicInfoParser(const std::string &path) : CompactInfoParser(path, "NodeBasicInfoParser") |
| 60 | { | 61 | { |
| 62 | + parserType_ = CompactInfoFormat::NODE_BASIC_INFO_TYPE; | ||
| 61 | Init(filePrefix_); | 63 | Init(filePrefix_); |
| 62 | } | 64 | } |
| 63 | 65 | ||
| @@ -84,6 +86,7 @@ class NodeAttrInfoParser final : public CompactInfoParser | |||
| 84 | public: | 86 | public: |
| 85 | explicit NodeAttrInfoParser(const std::string &path) : CompactInfoParser(path, "NodeAttrInfoParser") | 87 | explicit NodeAttrInfoParser(const std::string &path) : CompactInfoParser(path, "NodeAttrInfoParser") |
| 86 | { | 88 | { |
| 89 | + parserType_ = CompactInfoFormat::ATTR_INFO_TYPE; | ||
| 87 | Init(filePrefix_); | 90 | Init(filePrefix_); |
| 88 | } | 91 | } |
| 89 | 92 | ||
| @@ -100,6 +103,7 @@ class MemcpyInfoParser final : public CompactInfoParser | |||
| 100 | public: | 103 | public: |
| 101 | explicit MemcpyInfoParser(const std::string &path) : CompactInfoParser(path, "MemcpyInfoParser") | 104 | explicit MemcpyInfoParser(const std::string &path) : CompactInfoParser(path, "MemcpyInfoParser") |
| 102 | { | 105 | { |
| 106 | + parserType_ = CompactInfoFormat::MEMCPY_INFO_TYPE; | ||
| 103 | Init(filePrefix_); | 107 | Init(filePrefix_); |
| 104 | } | 108 | } |
| 105 | 109 | ||
| @@ -121,31 +125,22 @@ class TaskTrackParser final : public CompactInfoParser | |||
| 121 | if (!Analysis::Utils::File::GetFilesWithPrefix(path, filePrefix_[0]).empty() || | 125 | if (!Analysis::Utils::File::GetFilesWithPrefix(path, filePrefix_[0]).empty() || |
| 122 | !Analysis::Utils::File::GetFilesWithPrefix(path, filePrefix_[1]).empty()) | 126 | !Analysis::Utils::File::GetFilesWithPrefix(path, filePrefix_[1]).empty()) |
| 123 | { | 127 | { |
| 124 | - isRuntimeTrackV2_ = false; | 128 | + runtimeTrackFormat_ = RuntimeTrackFormat::V1; |
| 125 | } | 129 | } |
| 126 | else if (!Analysis::Utils::File::GetFilesWithPrefix(path, filePrefixV2_[0]).empty() || | 130 | else if (!Analysis::Utils::File::GetFilesWithPrefix(path, filePrefixV2_[0]).empty() || |
| 127 | !Analysis::Utils::File::GetFilesWithPrefix(path, filePrefixV2_[1]).empty()) | 131 | !Analysis::Utils::File::GetFilesWithPrefix(path, filePrefixV2_[1]).empty()) |
| 128 | { | 132 | { |
| 129 | selected = filePrefixV2_; | 133 | selected = filePrefixV2_; |
| 130 | - isRuntimeTrackV2_ = true; | 134 | + runtimeTrackFormat_ = RuntimeTrackFormat::V2; |
| 131 | } | 135 | } |
| 132 | Init(selected); | 136 | Init(selected); |
| 133 | } | 137 | } |
| 134 | // Get DPU kernel name map: key = ((uint64_t)deviceId << 32) | taskId | 138 | // Get DPU kernel name map: key = ((uint64_t)deviceId << 32) | taskId |
| 135 | const std::unordered_map<uint64_t, uint64_t> &GetDpuKernelNameMap() const; | 139 | const std::unordered_map<uint64_t, uint64_t> &GetDpuKernelNameMap() const; |
| 136 | - bool IsRuntimeTrackV2() const { return isRuntimeTrackV2_; } | 140 | + RuntimeTrackFormat GetRuntimeTrackFormat() const { return runtimeTrackFormat_; } |
| 137 | - | ||
| 138 | - ~TaskTrackParser() | ||
| 139 | - { | ||
| 140 | - if (errorNum_ > 0) | ||
| 141 | - { | ||
| 142 | - ERROR("memcpy runtimeTrack failed!"); | ||
| 143 | - } | ||
| 144 | - } | ||
| 145 | 141 | ||
| 146 | private: | 142 | private: |
| 147 | int ProduceData() override; | 143 | int ProduceData() override; |
| 148 | - void NormalizeRuntimeTrack(MsprofCompactInfo *compactInfo); | ||
| 149 | 144 | ||
| 150 | private: | 145 | private: |
| 151 | std::vector<std::string> filePrefix_ = { | 146 | std::vector<std::string> filePrefix_ = { |
| @@ -158,8 +153,7 @@ class TaskTrackParser final : public CompactInfoParser | |||
| 158 | "aging.compact.task_track_v2.slice", | 153 | "aging.compact.task_track_v2.slice", |
| 159 | }; | 154 | }; |
| 160 | std::unordered_map<uint64_t, uint64_t> dpuKernelNameMap_; | 155 | std::unordered_map<uint64_t, uint64_t> dpuKernelNameMap_; |
| 161 | - bool isRuntimeTrackV2_ = false; | 156 | + RuntimeTrackFormat runtimeTrackFormat_ = RuntimeTrackFormat::V1; |
| 162 | - uint64_t errorNum_ = 0; | ||
| 163 | }; // class TaskTrackParser | 157 | }; // class TaskTrackParser |
| 164 | 158 | ||
| 165 | // 该类的作用是dpu task track数据的解析 | 159 | // 该类的作用是dpu task track数据的解析 |
| @@ -168,6 +162,7 @@ class DpuTaskTrackParser final : public CompactInfoParser | |||
| 168 | public: | 162 | public: |
| 169 | explicit DpuTaskTrackParser(const std::string &path) : CompactInfoParser(path, "DpuTaskTrackParser") | 163 | explicit DpuTaskTrackParser(const std::string &path) : CompactInfoParser(path, "DpuTaskTrackParser") |
| 170 | { | 164 | { |
| 165 | + parserType_ = CompactInfoFormat::DPU_TRACK_TYPE; | ||
| 171 | Init(filePrefix_); | 166 | Init(filePrefix_); |
| 172 | } | 167 | } |
| 173 | 168 | ||
| @@ -176,7 +171,7 @@ class DpuTaskTrackParser final : public CompactInfoParser | |||
| 176 | "aging.compact.dpu_track.slice", | 171 | "aging.compact.dpu_track.slice", |
| 177 | "unaging.compact.dpu_track.slice", | 172 | "unaging.compact.dpu_track.slice", |
| 178 | }; | 173 | }; |
| 179 | - std::vector<std::shared_ptr<MsprofCompactInfo>> dpuTrackData_; | 174 | + std::vector<std::shared_ptr<ParserCompactInfo>> dpuTrackData_; |
| 180 | }; // class DpuTaskTrackParser | 175 | }; // class DpuTaskTrackParser |
| 181 | 176 | ||
| 182 | // 该类的作用是hccl op info info数据的解析 | 177 | // 该类的作用是hccl op info info数据的解析 |
| @@ -185,6 +180,7 @@ class HcclOpInfoParser final : public CompactInfoParser | |||
| 185 | public: | 180 | public: |
| 186 | explicit HcclOpInfoParser(const std::string &path) : CompactInfoParser(path, "HcclOpInfoParser") | 181 | explicit HcclOpInfoParser(const std::string &path) : CompactInfoParser(path, "HcclOpInfoParser") |
| 187 | { | 182 | { |
| 183 | + parserType_ = CompactInfoFormat::HCCL_OP_INFO_TYPE; | ||
| 188 | Init(filePrefix_); | 184 | Init(filePrefix_); |
| 189 | } | 185 | } |
| 190 | 186 | ||
| @@ -46,7 +46,7 @@ std::vector<std::shared_ptr<Event>> &EventGrouper::GetApiTraces() { return apiTr | |||
| 46 | 46 | ||
| 47 | std::vector<std::shared_ptr<Adapter::FlipTask>> &EventGrouper::GetFlipTasks() { return flipTasks_; } | 47 | std::vector<std::shared_ptr<Adapter::FlipTask>> &EventGrouper::GetFlipTasks() { return flipTasks_; } |
| 48 | 48 | ||
| 49 | -std::vector<std::shared_ptr<MsprofCompactInfo>> &EventGrouper::GetDpuTrackData() { return dpuTrackData_; } | 49 | +std::vector<std::shared_ptr<ParserCompactInfo>> &EventGrouper::GetDpuTrackData() { return dpuTrackData_; } |
| 50 | std::unordered_map<uint64_t, uint64_t> &EventGrouper::GetDpuKernelNameMap() { return dpuKernelNameMap_; } | 50 | std::unordered_map<uint64_t, uint64_t> &EventGrouper::GetDpuKernelNameMap() { return dpuKernelNameMap_; } |
| 51 | 51 | ||
| 52 | bool EventGrouper::Group() | 52 | bool EventGrouper::Group() |
| @@ -59,35 +59,35 @@ bool EventGrouper::Group() | |||
| 59 | // 每个Parser一个线程 | 59 | // 每个Parser一个线程 |
| 60 | pool.AddTask( | 60 | pool.AddTask( |
| 61 | [this]() | 61 | [this]() |
| 62 | - { GroupEvents<ApiEventParser, MsprofApi, &CANNWarehouse::kernelEvents>("Kernel", EventType::EVENT_TYPE_API); }); | 62 | + { GroupEvents<ApiEventParser, ParserApi, &CANNWarehouse::kernelEvents>("Kernel", EventType::EVENT_TYPE_API); }); |
| 63 | pool.AddTask( | 63 | pool.AddTask( |
| 64 | [this]() | 64 | [this]() |
| 65 | { | 65 | { |
| 66 | - GroupEvents<GraphIdParser, MsprofAdditionalInfo, &CANNWarehouse::graphIdMapEvents>( | 66 | + GroupEvents<GraphIdParser, ParserAdditionalInfo, &CANNWarehouse::graphIdMapEvents>( |
| 67 | "GraphIdMap", EventType::EVENT_TYPE_GRAPH_ID_MAP); | 67 | "GraphIdMap", EventType::EVENT_TYPE_GRAPH_ID_MAP); |
| 68 | }); | 68 | }); |
| 69 | pool.AddTask( | 69 | pool.AddTask( |
| 70 | [this]() | 70 | [this]() |
| 71 | { | 71 | { |
| 72 | - GroupEvents<FusionOpInfoParser, MsprofAdditionalInfo, &CANNWarehouse::fusionOpInfoEvents>( | 72 | + GroupEvents<FusionOpInfoParser, ParserAdditionalInfo, &CANNWarehouse::fusionOpInfoEvents>( |
| 73 | "FusionOpInfo", EventType::EVENT_TYPE_FUSION_OP_INFO); | 73 | "FusionOpInfo", EventType::EVENT_TYPE_FUSION_OP_INFO); |
| 74 | }); | 74 | }); |
| 75 | pool.AddTask( | 75 | pool.AddTask( |
| 76 | [this]() | 76 | [this]() |
| 77 | { | 77 | { |
| 78 | - GroupEvents<NodeBasicInfoParser, MsprofCompactInfo, &CANNWarehouse::nodeBasicInfoEvents>( | 78 | + GroupEvents<NodeBasicInfoParser, ParserCompactInfo, &CANNWarehouse::nodeBasicInfoEvents>( |
| 79 | "NodeBasicInfo", EventType::EVENT_TYPE_NODE_BASIC_INFO); | 79 | "NodeBasicInfo", EventType::EVENT_TYPE_NODE_BASIC_INFO); |
| 80 | }); | 80 | }); |
| 81 | pool.AddTask( | 81 | pool.AddTask( |
| 82 | [this]() | 82 | [this]() |
| 83 | { | 83 | { |
| 84 | - GroupEvents<NodeAttrInfoParser, MsprofCompactInfo, &CANNWarehouse::nodeAttrInfoEvents>( | 84 | + GroupEvents<NodeAttrInfoParser, ParserCompactInfo, &CANNWarehouse::nodeAttrInfoEvents>( |
| 85 | "NodeAttrInfo", EventType::EVENT_TYPE_NODE_ATTR_INFO); | 85 | "NodeAttrInfo", EventType::EVENT_TYPE_NODE_ATTR_INFO); |
| 86 | }); | 86 | }); |
| 87 | pool.AddTask( | 87 | pool.AddTask( |
| 88 | [this]() | 88 | [this]() |
| 89 | { | 89 | { |
| 90 | - GroupEvents<TensorInfoParser, ConcatTensorInfo, &CANNWarehouse::tensorInfoEvents>( | 90 | + GroupEvents<TensorInfoParser, ParserConcatTensorInfo, &CANNWarehouse::tensorInfoEvents>( |
| 91 | "TensorInfo", EventType::EVENT_TYPE_TENSOR_INFO); | 91 | "TensorInfo", EventType::EVENT_TYPE_TENSOR_INFO); |
| 92 | }); | 92 | }); |
| 93 | if (!Environment::Context::GetInstance().IsChipV6(Environment::Context::GetInstance().GetPlatformVersion())) | 93 | if (!Environment::Context::GetInstance().IsChipV6(Environment::Context::GetInstance().GetPlatformVersion())) |
| @@ -95,33 +95,33 @@ bool EventGrouper::Group() | |||
| 95 | pool.AddTask( | 95 | pool.AddTask( |
| 96 | [this]() | 96 | [this]() |
| 97 | { | 97 | { |
| 98 | - GroupEvents<CtxIdParser, MsprofAdditionalInfo, &CANNWarehouse::contextIdEvents>( | 98 | + GroupEvents<CtxIdParser, ParserAdditionalInfo, &CANNWarehouse::contextIdEvents>( |
| 99 | "ContextId", EventType::EVENT_TYPE_CONTEXT_ID); | 99 | "ContextId", EventType::EVENT_TYPE_CONTEXT_ID); |
| 100 | }); | 100 | }); |
| 101 | } | 101 | } |
| 102 | pool.AddTask( | 102 | pool.AddTask( |
| 103 | [this]() | 103 | [this]() |
| 104 | { | 104 | { |
| 105 | - GroupEvents<HcclInfoParser, MsprofAdditionalInfo, &CANNWarehouse::hcclInfoEvents>( | 105 | + GroupEvents<HcclInfoParser, ParserAdditionalInfo, &CANNWarehouse::hcclInfoEvents>( |
| 106 | "HcclInfo", EventType::EVENT_TYPE_HCCL_INFO); | 106 | "HcclInfo", EventType::EVENT_TYPE_HCCL_INFO); |
| 107 | }); | 107 | }); |
| 108 | pool.AddTask( | 108 | pool.AddTask( |
| 109 | [this]() | 109 | [this]() |
| 110 | { | 110 | { |
| 111 | - GroupEvents<TaskTrackParser, MsprofCompactInfo, &CANNWarehouse::taskTrackEvents>( | 111 | + GroupEvents<TaskTrackParser, ParserCompactInfo, &CANNWarehouse::taskTrackEvents>( |
| 112 | "TaskTrack", EventType::EVENT_TYPE_TASK_TRACK); | 112 | "TaskTrack", EventType::EVENT_TYPE_TASK_TRACK); |
| 113 | }); | 113 | }); |
| 114 | pool.AddTask( | 114 | pool.AddTask( |
| 115 | [this]() | 115 | [this]() |
| 116 | { | 116 | { |
| 117 | - GroupEvents<HcclOpInfoParser, MsprofCompactInfo, &CANNWarehouse::hcclOpInfoEvents>( | 117 | + GroupEvents<HcclOpInfoParser, ParserCompactInfo, &CANNWarehouse::hcclOpInfoEvents>( |
| 118 | "HcclOpInfo", EventType::EVENT_TYPE_HCCL_OP_INFO); | 118 | "HcclOpInfo", EventType::EVENT_TYPE_HCCL_OP_INFO); |
| 119 | }); | 119 | }); |
| 120 | pool.AddTask( | 120 | pool.AddTask( |
| 121 | [this]() | 121 | [this]() |
| 122 | { | 122 | { |
| 123 | // 复用模板函数 临时使用taskTrackEvents占位 实际业务不使用 | 123 | // 复用模板函数 临时使用taskTrackEvents占位 实际业务不使用 |
| 124 | - GroupEvents<DpuTaskTrackParser, MsprofCompactInfo, &CANNWarehouse::taskTrackEvents>( | 124 | + GroupEvents<DpuTaskTrackParser, ParserCompactInfo, &CANNWarehouse::taskTrackEvents>( |
| 125 | "DpuTaskTrack", EventType::EVENT_TYPE_TASK_TRACK); | 125 | "DpuTaskTrack", EventType::EVENT_TYPE_TASK_TRACK); |
| 126 | }); | 126 | }); |
| 127 | 127 | ||
| @@ -168,7 +168,7 @@ void EventGrouper::InitLastKernelTimes(const std::set<uint32_t> &threadIds) | |||
| 168 | } | 168 | } |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | -bool EventGrouper::IsBuildTreeWithAcl(const std::shared_ptr<MsprofApi> &trace) | 171 | +bool EventGrouper::IsBuildTreeWithAcl(const std::shared_ptr<ParserApi> &trace) |
| 172 | { | 172 | { |
| 173 | if (trace->level == MSPROF_REPORT_ACL_LEVEL) | 173 | if (trace->level == MSPROF_REPORT_ACL_LEVEL) |
| 174 | { | 174 | { |
| @@ -178,7 +178,7 @@ bool EventGrouper::IsBuildTreeWithAcl(const std::shared_ptr<MsprofApi> &trace) | |||
| 178 | return false; | 178 | return false; |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | -bool EventGrouper::isKernelApiEvent(const std::shared_ptr<MsprofApi> &trace) | 181 | +bool EventGrouper::isKernelApiEvent(const std::shared_ptr<ParserApi> &trace) |
| 182 | { | 182 | { |
| 183 | if (trace->level == MSPROF_REPORT_ACL_LEVEL || trace->level == MSPROF_REPORT_MODEL_LEVEL || | 183 | if (trace->level == MSPROF_REPORT_ACL_LEVEL || trace->level == MSPROF_REPORT_MODEL_LEVEL || |
| 184 | trace->level == MSPROF_REPORT_NODE_LEVEL || trace->level == MSPROF_REPORT_HCCL_NODE_LEVEL) | 184 | trace->level == MSPROF_REPORT_NODE_LEVEL || trace->level == MSPROF_REPORT_HCCL_NODE_LEVEL) |
| @@ -214,7 +214,7 @@ bool EventGrouper::isKernelApiEvent(const std::shared_ptr<MsprofApi> &trace) | |||
| 214 | 214 | ||
| 215 | // 对于KernelEvents特化 | 215 | // 对于KernelEvents特化 |
| 216 | template <> | 216 | template <> |
| 217 | -void EventGrouper::GroupEvents<ApiEventParser, MsprofApi, &CANNWarehouse::kernelEvents>(const std::string &typeName, | 217 | +void EventGrouper::GroupEvents<ApiEventParser, ParserApi, &CANNWarehouse::kernelEvents>(const std::string &typeName, |
| 218 | EventType eventType) | 218 | EventType eventType) |
| 219 | { | 219 | { |
| 220 | // 1. 解析bin | 220 | // 1. 解析bin |
| @@ -222,7 +222,7 @@ void EventGrouper::GroupEvents<ApiEventParser, MsprofApi, &CANNWarehouse::kernel | |||
| 222 | std::shared_ptr<ApiEventParser> parser; | 222 | std::shared_ptr<ApiEventParser> parser; |
| 223 | MAKE_SHARED_RETURN_VOID(parser, ApiEventParser, hostPath_); | 223 | MAKE_SHARED_RETURN_VOID(parser, ApiEventParser, hostPath_); |
| 224 | 224 | ||
| 225 | - auto traces = parser->ParseData<MsprofApi>(); | 225 | + auto traces = parser->ParseData<ParserApi>(); |
| 226 | SortByTimeAndLevel(traces); | 226 | SortByTimeAndLevel(traces); |
| 227 | // 统计各个threadId元素个数,用于EventQueue分配精确的内存大小,避免大量内存浪费 | 227 | // 统计各个threadId元素个数,用于EventQueue分配精确的内存大小,避免大量内存浪费 |
| 228 | std::unordered_map<uint32_t, uint64_t> threadIdNum; | 228 | std::unordered_map<uint32_t, uint64_t> threadIdNum; |
| @@ -279,7 +279,7 @@ void EventGrouper::GroupEvents<ApiEventParser, MsprofApi, &CANNWarehouse::kernel | |||
| 279 | 279 | ||
| 280 | // 对于taskTrackEvents特化 | 280 | // 对于taskTrackEvents特化 |
| 281 | template <> | 281 | template <> |
| 282 | -void EventGrouper::GroupEvents<TaskTrackParser, MsprofCompactInfo, &CANNWarehouse::taskTrackEvents>( | 282 | +void EventGrouper::GroupEvents<TaskTrackParser, ParserCompactInfo, &CANNWarehouse::taskTrackEvents>( |
| 283 | const std::string &typeName, EventType eventType) | 283 | const std::string &typeName, EventType eventType) |
| 284 | { | 284 | { |
| 285 | // 1. 解析bin | 285 | // 1. 解析bin |
| @@ -287,7 +287,7 @@ void EventGrouper::GroupEvents<TaskTrackParser, MsprofCompactInfo, &CANNWarehous | |||
| 287 | std::shared_ptr<TaskTrackParser> parser; | 287 | std::shared_ptr<TaskTrackParser> parser; |
| 288 | MAKE_SHARED_RETURN_VOID(parser, TaskTrackParser, hostPath_); | 288 | MAKE_SHARED_RETURN_VOID(parser, TaskTrackParser, hostPath_); |
| 289 | 289 | ||
| 290 | - auto traces = parser->ParseData<MsprofCompactInfo>(); | 290 | + auto traces = parser->ParseData<ParserCompactInfo>(); |
| 291 | SortByTimeAndLevel(traces); | 291 | SortByTimeAndLevel(traces); |
| 292 | flipTasks_ = parser->GetData<Adapter::FlipTask>(); | 292 | flipTasks_ = parser->GetData<Adapter::FlipTask>(); |
| 293 | dpuKernelNameMap_ = parser->GetDpuKernelNameMap(); | 293 | dpuKernelNameMap_ = parser->GetDpuKernelNameMap(); |
| @@ -324,20 +324,20 @@ void EventGrouper::GroupEvents<TaskTrackParser, MsprofCompactInfo, &CANNWarehous | |||
| 324 | 324 | ||
| 325 | // dpuTaskTrack特化 | 325 | // dpuTaskTrack特化 |
| 326 | template <> | 326 | template <> |
| 327 | -void EventGrouper::GroupEvents<DpuTaskTrackParser, MsprofCompactInfo, &CANNWarehouse::taskTrackEvents>( | 327 | +void EventGrouper::GroupEvents<DpuTaskTrackParser, ParserCompactInfo, &CANNWarehouse::taskTrackEvents>( |
| 328 | const std::string &typeName, EventType eventType) | 328 | const std::string &typeName, EventType eventType) |
| 329 | { | 329 | { |
| 330 | Utils::TimeLogger t{"Group " + typeName}; | 330 | Utils::TimeLogger t{"Group " + typeName}; |
| 331 | std::shared_ptr<DpuTaskTrackParser> parser; | 331 | std::shared_ptr<DpuTaskTrackParser> parser; |
| 332 | MAKE_SHARED_RETURN_VOID(parser, DpuTaskTrackParser, hostPath_); | 332 | MAKE_SHARED_RETURN_VOID(parser, DpuTaskTrackParser, hostPath_); |
| 333 | - dpuTrackData_ = parser->ParseData<MsprofCompactInfo>(); | 333 | + dpuTrackData_ = parser->ParseData<ParserCompactInfo>(); |
| 334 | INFO("Parsed DPU task track data, size: %", dpuTrackData_.size()); | 334 | INFO("Parsed DPU task track data, size: %", dpuTrackData_.size()); |
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | template <> | 337 | template <> |
| 338 | -void EventGrouper::SortByTimeAndLevel<MsprofApi>(std::vector<std::shared_ptr<MsprofApi>> &traces) | 338 | +void EventGrouper::SortByTimeAndLevel<ParserApi>(std::vector<std::shared_ptr<ParserApi>> &traces) |
| 339 | { | 339 | { |
| 340 | - auto comp = [](std::shared_ptr<MsprofApi> &api1, std::shared_ptr<MsprofApi> &api2) | 340 | + auto comp = [](std::shared_ptr<ParserApi> &api1, std::shared_ptr<ParserApi> &api2) |
| 341 | { return api1->beginTime < api2->beginTime || (api1->beginTime == api2->beginTime && api1->level > api2->level); }; | 341 | { return api1->beginTime < api2->beginTime || (api1->beginTime == api2->beginTime && api1->level > api2->level); }; |
| 342 | std::sort(traces.begin(), traces.end(), comp); | 342 | std::sort(traces.begin(), traces.end(), comp); |
| 343 | } | 343 | } |
| @@ -30,7 +30,8 @@ | |||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 33 | +#include "analysis/csrc/infrastructure/utils/parser_struct.h" |
| 34 | + | ||
| 34 | 35 | ||
| 35 | 36 | ||
| 36 | 37 | ||
| @@ -70,14 +71,14 @@ class EventGrouper | |||
| 70 | // 获取FlipTask数据 | 71 | // 获取FlipTask数据 |
| 71 | std::vector<std::shared_ptr<Adapter::FlipTask>> &GetFlipTasks(); | 72 | std::vector<std::shared_ptr<Adapter::FlipTask>> &GetFlipTasks(); |
| 72 | // 获取DpuTrack数据 | 73 | // 获取DpuTrack数据 |
| 73 | - std::vector<std::shared_ptr<MsprofCompactInfo>> &GetDpuTrackData(); | 74 | + std::vector<std::shared_ptr<ParserCompactInfo>> &GetDpuTrackData(); |
| 74 | // 获取DpuKernelNameMap | 75 | // 获取DpuKernelNameMap |
| 75 | std::unordered_map<uint64_t, uint64_t> &GetDpuKernelNameMap(); | 76 | std::unordered_map<uint64_t, uint64_t> &GetDpuKernelNameMap(); |
| 76 | // ACL层建树白名单 | 77 | // ACL层建树白名单 |
| 77 | - bool IsBuildTreeWithAcl(const std::shared_ptr<MsprofApi> &trace); | 78 | + bool IsBuildTreeWithAcl(const std::shared_ptr<ParserApi> &trace); |
| 78 | 79 | ||
| 79 | private: | 80 | private: |
| 80 | - bool isKernelApiEvent(const std::shared_ptr<MsprofApi> &trace); | 81 | + bool isKernelApiEvent(const std::shared_ptr<ParserApi> &trace); |
| 81 | void InitLastKernelTimes(const std::set<uint32_t> &threadIds); | 82 | void InitLastKernelTimes(const std::set<uint32_t> &threadIds); |
| 82 | void RecordCANNWareHouses(); | 83 | void RecordCANNWareHouses(); |
| 83 | 84 | ||
| @@ -135,7 +136,7 @@ class EventGrouper | |||
| 135 | std::mutex tidLock_; | 136 | std::mutex tidLock_; |
| 136 | std::vector<std::shared_ptr<Event>> apiTraces_; | 137 | std::vector<std::shared_ptr<Event>> apiTraces_; |
| 137 | std::vector<std::shared_ptr<Adapter::FlipTask>> flipTasks_; | 138 | std::vector<std::shared_ptr<Adapter::FlipTask>> flipTasks_; |
| 138 | - std::vector<std::shared_ptr<MsprofCompactInfo>> dpuTrackData_; | 139 | + std::vector<std::shared_ptr<ParserCompactInfo>> dpuTrackData_; |
| 139 | std::unordered_map<uint64_t, uint64_t> dpuKernelNameMap_; | 140 | std::unordered_map<uint64_t, uint64_t> dpuKernelNameMap_; |
| 140 | std::set<uint32_t> threadIds_; | 141 | std::set<uint32_t> threadIds_; |
| 141 | std::string hostPath_; | 142 | std::string hostPath_; |
| @@ -146,19 +147,19 @@ class EventGrouper | |||
| 146 | 147 | ||
| 147 | // 特化模板需要声明在类外 | 148 | // 特化模板需要声明在类外 |
| 148 | template <> | 149 | template <> |
| 149 | -void EventGrouper::GroupEvents<ApiEventParser, MsprofApi, &CANNWarehouse::kernelEvents>(const std::string &typeName, | 150 | +void EventGrouper::GroupEvents<ApiEventParser, ParserApi, &CANNWarehouse::kernelEvents>(const std::string &typeName, |
| 150 | EventType eventType); | 151 | EventType eventType); |
| 151 | 152 | ||
| 152 | template <> | 153 | template <> |
| 153 | -void EventGrouper::GroupEvents<TaskTrackParser, MsprofCompactInfo, &CANNWarehouse::taskTrackEvents>( | 154 | +void EventGrouper::GroupEvents<TaskTrackParser, ParserCompactInfo, &CANNWarehouse::taskTrackEvents>( |
| 154 | const std::string &typeName, EventType eventType); | 155 | const std::string &typeName, EventType eventType); |
| 155 | 156 | ||
| 156 | template <> | 157 | template <> |
| 157 | -void EventGrouper::GroupEvents<DpuTaskTrackParser, MsprofCompactInfo, &CANNWarehouse::taskTrackEvents>( | 158 | +void EventGrouper::GroupEvents<DpuTaskTrackParser, ParserCompactInfo, &CANNWarehouse::taskTrackEvents>( |
| 158 | const std::string &typeName, EventType eventType); | 159 | const std::string &typeName, EventType eventType); |
| 159 | 160 | ||
| 160 | template <> | 161 | template <> |
| 161 | -void EventGrouper::SortByTimeAndLevel<MsprofApi>(std::vector<std::shared_ptr<MsprofApi>> &traces); | 162 | +void EventGrouper::SortByTimeAndLevel<ParserApi>(std::vector<std::shared_ptr<ParserApi>> &traces); |
| 162 | 163 | ||
| 163 | } // namespace Cann | 164 | } // namespace Cann |
| 164 | } // namespace Host | 165 | } // namespace Host |
| @@ -15,20 +15,24 @@ | |||
| 15 | * -------------------------------------------------------------------------*/ | 15 | * -------------------------------------------------------------------------*/ |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | -#include "analysis/csrc/infrastructure/dfx/log.h" | 18 | + |
| 19 | - | ||
| 20 | 19 | ||
| 21 | - | ||
| 22 | 20 | ||
| 23 | 21 | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 24 | 25 | ||
| 25 | -namespace Analysis { | 26 | +namespace Analysis |
| 26 | -namespace Domain { | 27 | +{ |
| 28 | +namespace Domain | ||
| 29 | +{ | ||
| 27 | using namespace Analysis::Utils; | 30 | using namespace Analysis::Utils; |
| 28 | 31 | ||
| 29 | int AccPmuParserItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t *halUniData, uint16_t expandStatus) | 32 | int AccPmuParserItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t *halUniData, uint16_t expandStatus) |
| 30 | { | 33 | { |
| 31 | - if (binaryDataSize != sizeof(AccPmu)) { | 34 | + if (binaryDataSize != sizeof(AccPmu)) |
| 35 | + { | ||
| 32 | ERROR("The trunkSize of accPmu is not equal with the AccPmu struct"); | 36 | ERROR("The trunkSize of accPmu is not equal with the AccPmu struct"); |
| 33 | return PARSER_ERROR_SIZE_MISMATCH; | 37 | return PARSER_ERROR_SIZE_MISMATCH; |
| 34 | } | 38 | } |
| @@ -38,16 +42,16 @@ int AccPmuParserItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t *halU | |||
| 38 | unionData->accPmu.timestamp = accPmu->timestamp; | 42 | unionData->accPmu.timestamp = accPmu->timestamp; |
| 39 | unionData->accPmu.accId = accPmu->accId; | 43 | unionData->accPmu.accId = accPmu->accId; |
| 40 | unionData->hd.timestamp = accPmu->timestamp; | 44 | unionData->hd.timestamp = accPmu->timestamp; |
| 41 | - errno_t resBandwidth = memcpy_s(unionData->accPmu.bandwidth, sizeof(unionData->accPmu.bandwidth), | 45 | + errno_t resBandwidth = memcpy_s(unionData->accPmu.bandwidth, sizeof(unionData->accPmu.bandwidth), accPmu->bandwidth, |
| 42 | - accPmu->bandwidth, sizeof(accPmu->bandwidth)); | 46 | + sizeof(accPmu->bandwidth)); |
| 43 | - errno_t resOst = memcpy_s(unionData->accPmu.ost, sizeof(unionData->accPmu.ost), | 47 | + errno_t resOst = memcpy_s(unionData->accPmu.ost, sizeof(unionData->accPmu.ost), accPmu->ost, sizeof(accPmu->ost)); |
| 44 | - accPmu->ost, sizeof(accPmu->ost)); | 48 | + if (resBandwidth != EOK || resOst != EOK) |
| 45 | - if (resBandwidth != EOK || resOst != EOK) { | 49 | + { |
| 46 | ERROR("memcpy accPmu failed! accId is %", accPmu->accId); | 50 | ERROR("memcpy accPmu failed! accId is %", accPmu->accId); |
| 47 | } | 51 | } |
| 48 | return accPmu->cnt; | 52 | return accPmu->cnt; |
| 49 | } | 53 | } |
| 50 | 54 | ||
| 51 | REGISTER_PARSER_ITEM(LOG_PARSER, PARSER_ITEM_ACC_PMU, AccPmuParserItem); | 55 | REGISTER_PARSER_ITEM(LOG_PARSER, PARSER_ITEM_ACC_PMU, AccPmuParserItem); |
| 52 | -} | 56 | +} // namespace Domain |
| 53 | -} | 57 | +} // namespace Analysis |
| @@ -15,6 +15,7 @@ | |||
| 15 | * -------------------------------------------------------------------------*/ | 15 | * -------------------------------------------------------------------------*/ |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | + | ||
| 18 | 19 | ||
| 19 | 20 | ||
| 20 | 21 | ||
| @@ -38,6 +39,7 @@ const int AICPU_FLIP_TASK_TYPE = static_cast<int>(AicpuType::AICPU_FLIP_TASK); | |||
| 38 | const int AICPU_MASTER_STREAM_HCCL_TASK_TYPE = static_cast<int>(AicpuType::AICPU_MASTER_STREAM_HCCL_TASK); | 39 | const int AICPU_MASTER_STREAM_HCCL_TASK_TYPE = static_cast<int>(AicpuType::AICPU_MASTER_STREAM_HCCL_TASK); |
| 39 | const int KFC_HCCL_INFO_TYPE = static_cast<int>(AicpuType::KFC_HCCL_INFO); | 40 | const int KFC_HCCL_INFO_TYPE = static_cast<int>(AicpuType::KFC_HCCL_INFO); |
| 40 | } // namespace | 41 | } // namespace |
| 42 | +using namespace Analysis::Domain::Adapter; | ||
| 41 | using namespace Analysis::Utils; | 43 | using namespace Analysis::Utils; |
| 42 | 44 | ||
| 43 | int AicpuNodeParseItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t *aicpuData, uint16_t expandStatus) | 45 | int AicpuNodeParseItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t *aicpuData, uint16_t expandStatus) |
| @@ -46,7 +48,10 @@ int AicpuNodeParseItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t *ai | |||
| 46 | 48 | ||
| 47 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); | 49 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); |
| 48 | data->timeStamp = additionalData->timeStamp; | 50 | data->timeStamp = additionalData->timeStamp; |
| 49 | - data->node = additionalData->aicpuNode; | 51 | + if (!ParserAicpuAdapter::AdapterNode(additionalData, data)) |
| 52 | + { | ||
| 53 | + return ANALYSIS_ERROR; | ||
| 54 | + } | ||
| 50 | 55 | ||
| 51 | data->taskId.streamId = | 56 | data->taskId.streamId = |
| 52 | StarsCommon::GetStreamId(additionalData->aicpuNode.streamId, additionalData->aicpuNode.taskId, expandStatus); | 57 | StarsCommon::GetStreamId(additionalData->aicpuNode.streamId, additionalData->aicpuNode.taskId, expandStatus); |
| @@ -64,7 +69,10 @@ int AicpuDpParseItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t *aicp | |||
| 64 | 69 | ||
| 65 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); | 70 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); |
| 66 | data->timeStamp = additionalData->timeStamp; | 71 | data->timeStamp = additionalData->timeStamp; |
| 67 | - data->dp = additionalData->aicpuDp; | 72 | + if (!ParserAicpuAdapter::AdapterDp(additionalData, data)) |
| 73 | + { | ||
| 74 | + return ANALYSIS_ERROR; | ||
| 75 | + } | ||
| 68 | data->type = AicpuType::AICPU_DP; | 76 | data->type = AicpuType::AICPU_DP; |
| 69 | return ANALYSIS_OK; | 77 | return ANALYSIS_OK; |
| 70 | } | 78 | } |
| @@ -75,7 +83,10 @@ int AicpuModelParseItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t *a | |||
| 75 | 83 | ||
| 76 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); | 84 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); |
| 77 | data->timeStamp = additionalData->timeStamp; | 85 | data->timeStamp = additionalData->timeStamp; |
| 78 | - data->model = additionalData->aicpuModel; | 86 | + if (!ParserAicpuAdapter::AdapterModel(additionalData, data)) |
| 87 | + { | ||
| 88 | + return ANALYSIS_ERROR; | ||
| 89 | + } | ||
| 79 | data->type = AicpuType::AICPU_MODEL; | 90 | data->type = AicpuType::AICPU_MODEL; |
| 80 | return ANALYSIS_OK; | 91 | return ANALYSIS_OK; |
| 81 | } | 92 | } |
| @@ -86,7 +97,10 @@ int AicpuMiParseItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t *aicp | |||
| 86 | 97 | ||
| 87 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); | 98 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); |
| 88 | data->timeStamp = additionalData->timeStamp; | 99 | data->timeStamp = additionalData->timeStamp; |
| 89 | - data->mi = additionalData->aicpuMi; | 100 | + if (!ParserAicpuAdapter::AdapterMi(additionalData, data)) |
| 101 | + { | ||
| 102 | + return ANALYSIS_ERROR; | ||
| 103 | + } | ||
| 90 | data->type = AicpuType::AICPU_MI; | 104 | data->type = AicpuType::AICPU_MI; |
| 91 | return ANALYSIS_OK; | 105 | return ANALYSIS_OK; |
| 92 | } | 106 | } |
| @@ -97,7 +111,10 @@ int KfcCommTurnParseItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t * | |||
| 97 | 111 | ||
| 98 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); | 112 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); |
| 99 | data->timeStamp = additionalData->timeStamp; | 113 | data->timeStamp = additionalData->timeStamp; |
| 100 | - data->commTurn = additionalData->commTurn; | 114 | + if (!ParserAicpuAdapter::AdapterCommTurn(additionalData, data)) |
| 115 | + { | ||
| 116 | + return ANALYSIS_ERROR; | ||
| 117 | + } | ||
| 101 | 118 | ||
| 102 | data->taskId.streamId = | 119 | data->taskId.streamId = |
| 103 | StarsCommon::GetStreamId(additionalData->commTurn.streamId, additionalData->commTurn.taskId, expandStatus); | 120 | StarsCommon::GetStreamId(additionalData->commTurn.streamId, additionalData->commTurn.taskId, expandStatus); |
| @@ -115,7 +132,10 @@ int KfcComputeTurnParseItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_ | |||
| 115 | 132 | ||
| 116 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); | 133 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); |
| 117 | data->timeStamp = additionalData->timeStamp; | 134 | data->timeStamp = additionalData->timeStamp; |
| 118 | - data->computeTurn = additionalData->computeTurn; | 135 | + if (!ParserAicpuAdapter::AdapterComputeTurn(additionalData, data)) |
| 136 | + { | ||
| 137 | + return ANALYSIS_ERROR; | ||
| 138 | + } | ||
| 119 | 139 | ||
| 120 | data->taskId.streamId = StarsCommon::GetStreamId(additionalData->computeTurn.streamId, | 140 | data->taskId.streamId = StarsCommon::GetStreamId(additionalData->computeTurn.streamId, |
| 121 | additionalData->computeTurn.taskId, expandStatus); | 141 | additionalData->computeTurn.taskId, expandStatus); |
| @@ -133,7 +153,10 @@ int HcclOpInfoParseItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t *a | |||
| 133 | 153 | ||
| 134 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); | 154 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); |
| 135 | data->timeStamp = additionalData->timeStamp; | 155 | data->timeStamp = additionalData->timeStamp; |
| 136 | - data->opInfo = additionalData->opInfo; | 156 | + if (!ParserAicpuAdapter::AdapterOpInfo(additionalData, data)) |
| 157 | + { | ||
| 158 | + return ANALYSIS_ERROR; | ||
| 159 | + } | ||
| 137 | 160 | ||
| 138 | data->taskId.streamId = | 161 | data->taskId.streamId = |
| 139 | StarsCommon::GetStreamId(additionalData->opInfo.streamId, additionalData->opInfo.taskId, expandStatus); | 162 | StarsCommon::GetStreamId(additionalData->opInfo.streamId, additionalData->opInfo.taskId, expandStatus); |
| @@ -151,7 +174,10 @@ int AicpuFlipTaskParseItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t | |||
| 151 | 174 | ||
| 152 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); | 175 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); |
| 153 | data->timeStamp = additionalData->timeStamp; | 176 | data->timeStamp = additionalData->timeStamp; |
| 154 | - data->flipTask = additionalData->flipTask; | 177 | + if (!ParserAicpuAdapter::AdapterFlipTask(additionalData, data)) |
| 178 | + { | ||
| 179 | + return ANALYSIS_ERROR; | ||
| 180 | + } | ||
| 155 | 181 | ||
| 156 | data->taskId.streamId = | 182 | data->taskId.streamId = |
| 157 | StarsCommon::GetStreamId(additionalData->flipTask.streamId, additionalData->flipTask.taskId, expandStatus); | 183 | StarsCommon::GetStreamId(additionalData->flipTask.streamId, additionalData->flipTask.taskId, expandStatus); |
| @@ -170,7 +196,10 @@ int AicpuMasterStreamHcclTaskParseItem(uint8_t *binaryData, uint32_t binaryDataS | |||
| 170 | 196 | ||
| 171 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); | 197 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); |
| 172 | data->timeStamp = additionalData->timeStamp; | 198 | data->timeStamp = additionalData->timeStamp; |
| 173 | - data->mainStreamTask = additionalData->mainStreamTask; | 199 | + if (!ParserAicpuAdapter::AdapterMainStreamTask(additionalData, data)) |
| 200 | + { | ||
| 201 | + return ANALYSIS_ERROR; | ||
| 202 | + } | ||
| 174 | 203 | ||
| 175 | // aicpu task | 204 | // aicpu task |
| 176 | data->aicpuTaskId.streamId = StarsCommon::GetStreamId(additionalData->mainStreamTask.aicpuStreamId, | 205 | data->aicpuTaskId.streamId = StarsCommon::GetStreamId(additionalData->mainStreamTask.aicpuStreamId, |
| @@ -197,7 +226,10 @@ int KfcHcclInfoParseItem(uint8_t *binaryData, uint32_t binaryDataSize, uint8_t * | |||
| 197 | 226 | ||
| 198 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); | 227 | auto *data = ReinterpretConvert<AicpuData *>(aicpuData); |
| 199 | data->timeStamp = additionalData->timeStamp; | 228 | data->timeStamp = additionalData->timeStamp; |
| 200 | - data->KfcInfos = additionalData->kfcInfos; | 229 | + if (!ParserAicpuAdapter::AdapterKfcInfos(additionalData, data)) |
| 230 | + { | ||
| 231 | + return ANALYSIS_ERROR; | ||
| 232 | + } | ||
| 201 | data->type = AicpuType::KFC_HCCL_INFO; | 233 | data->type = AicpuType::KFC_HCCL_INFO; |
| 202 | return ANALYSIS_OK; | 234 | return ANALYSIS_OK; |
| 203 | } | 235 | } |
| @@ -264,8 +264,8 @@ void CANNTraceDBDumper::DumpOpDesc(const HostTasks &computeTasks) | |||
| 264 | } | 264 | } |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | -void CANNTraceDBDumper::AddTensorShapeInfo(const std::shared_ptr<ConcatTensorInfo> &tensorDesc, | 267 | +void CANNTraceDBDumper::AddTensorShapeInfo(const std::shared_ptr<ParserConcatTensorInfo> &tensorDesc, |
| 268 | - const MsprofNodeBasicInfo *nodeBasicInfo, TaskInfoData &data, | 268 | + const ParserNodeBasicInfo *nodeBasicInfo, TaskInfoData &data, |
| 269 | const std::shared_ptr<HostTask> &task) | 269 | const std::shared_ptr<HostTask> &task) |
| 270 | { | 270 | { |
| 271 | auto tensorNum = tensorDesc->tensorNum; | 271 | auto tensorNum = tensorDesc->tensorNum; |
| @@ -402,7 +402,7 @@ void CANNTraceDBDumper::AddTaskInfoForOnlyTaskTrack(const std::shared_ptr<HostTa | |||
| 402 | } | 402 | } |
| 403 | } | 403 | } |
| 404 | 404 | ||
| 405 | -void CANNTraceDBDumper::ProcessRuntimeTrackInfo(const std::shared_ptr<MsprofCompactInfo> &runtimeTrack, | 405 | +void CANNTraceDBDumper::ProcessRuntimeTrackInfo(const std::shared_ptr<ParserCompactInfo> &runtimeTrack, |
| 406 | uint32_t &blockNum, uint32_t &mixBlockNum, std::string &gridDim, | 406 | uint32_t &blockNum, uint32_t &mixBlockNum, std::string &gridDim, |
| 407 | std::string &blockDim) | 407 | std::string &blockDim) |
| 408 | { | 408 | { |
| @@ -410,11 +410,11 @@ void CANNTraceDBDumper::ProcessRuntimeTrackInfo(const std::shared_ptr<MsprofComp | |||
| 410 | { | 410 | { |
| 411 | return; | 411 | return; |
| 412 | } | 412 | } |
| 413 | - auto taskTypeVal = runtimeTrack->data.runtimeTrackV2.taskType; | 413 | + auto taskTypeVal = runtimeTrack->data.runtimeTrack.taskType; |
| 414 | auto taskType = TypeData::GetInstance().Get(MSPROF_REPORT_RUNTIME_LEVEL, taskTypeVal); | 414 | auto taskType = TypeData::GetInstance().Get(MSPROF_REPORT_RUNTIME_LEVEL, taskTypeVal); |
| 415 | if (taskType == KERNEL_SIMT_TASK_TYPE) | 415 | if (taskType == KERNEL_SIMT_TASK_TYPE) |
| 416 | { | 416 | { |
| 417 | - auto &simtInfo = runtimeTrack->data.runtimeTrackV2.extInfo.simtKernelInfo; | 417 | + auto &simtInfo = runtimeTrack->data.runtimeTrack.simtKernelInfo; |
| 418 | gridDim = | 418 | gridDim = |
| 419 | Utils::Join(std::vector<std::string>{std::to_string(simtInfo.gridDim.x), std::to_string(simtInfo.gridDim.y), | 419 | Utils::Join(std::vector<std::string>{std::to_string(simtInfo.gridDim.x), std::to_string(simtInfo.gridDim.y), |
| 420 | std::to_string(simtInfo.gridDim.z)}, | 420 | std::to_string(simtInfo.gridDim.z)}, |
| @@ -426,7 +426,7 @@ void CANNTraceDBDumper::ProcessRuntimeTrackInfo(const std::shared_ptr<MsprofComp | |||
| 426 | } | 426 | } |
| 427 | else | 427 | else |
| 428 | { | 428 | { |
| 429 | - auto &kernelInfo = runtimeTrack->data.runtimeTrackV2.extInfo.kernelInfo; | 429 | + auto &kernelInfo = runtimeTrack->data.runtimeTrack.kernelInfo; |
| 430 | blockNum = kernelInfo.numBlocks; | 430 | blockNum = kernelInfo.numBlocks; |
| 431 | mixBlockNum = kernelInfo.numBlocks * kernelInfo.ratio; | 431 | mixBlockNum = kernelInfo.numBlocks * kernelInfo.ratio; |
| 432 | } | 432 | } |
| @@ -534,16 +534,16 @@ void CANNTraceDBDumper::DumpHcclTasks(const HostTasks &hcclTasks) | |||
| 534 | task->threadId, 0, task->connectionId); | 534 | task->threadId, 0, task->connectionId); |
| 535 | continue; | 535 | continue; |
| 536 | } | 536 | } |
| 537 | - auto hcclTrace = Utils::ReinterpretConvert<MsprofHcclInfo *>(desc->hcclInfo->data); | 537 | + auto hcclTrace = desc->hcclInfo->hcclInfo; |
| 538 | data.emplace_back( | 538 | data.emplace_back( |
| 539 | - task->modelId, task->requestId, HashData::GetInstance().Get(hcclTrace->itemId), | 539 | + task->modelId, task->requestId, HashData::GetInstance().Get(hcclTrace.itemId), |
| 540 | - std::to_string(hcclTrace->groupName), hcclTrace->planeID, std::to_string(task->timeStamp), task->streamId, | 540 | + std::to_string(hcclTrace.groupName), hcclTrace.planeID, std::to_string(task->timeStamp), task->streamId, |
| 541 | - task->taskId, task->contextId, task->batchId, task->deviceId, desc->isMaster, hcclTrace->localRank, | 541 | + task->taskId, task->contextId, task->batchId, task->deviceId, desc->isMaster, hcclTrace.localRank, |
| 542 | - hcclTrace->remoteRank, NumberMapping::Get(MappingType::HCCL_TRANSPORT_TYPE, hcclTrace->transportType), | 542 | + hcclTrace.remoteRank, NumberMapping::Get(MappingType::HCCL_TRANSPORT_TYPE, hcclTrace.transportType), |
| 543 | - static_cast<double>(hcclTrace->dataSize), | 543 | + static_cast<double>(hcclTrace.dataSize), |
| 544 | - NumberMapping::Get(MappingType::HCCL_DATA_TYPE, hcclTrace->dataType), | 544 | + NumberMapping::Get(MappingType::HCCL_DATA_TYPE, hcclTrace.dataType), |
| 545 | - NumberMapping::Get(MappingType::HCCL_LINK_TYPE, hcclTrace->linkType), std::to_string(hcclTrace->notifyID), | 545 | + NumberMapping::Get(MappingType::HCCL_LINK_TYPE, hcclTrace.linkType), std::to_string(hcclTrace.notifyID), |
| 546 | - NumberMapping::Get(MappingType::HCCL_RDMA_TYPE, hcclTrace->rdmaType), task->threadId, hcclTrace->rankSize, | 546 | + NumberMapping::Get(MappingType::HCCL_RDMA_TYPE, hcclTrace.rdmaType), task->threadId, hcclTrace.rankSize, |
| 547 | task->connectionId); | 547 | task->connectionId); |
| 548 | } | 548 | } |
| 549 | if (!hcclTaskDBRunner.InsertData("HCCLTask", data)) | 549 | if (!hcclTaskDBRunner.InsertData("HCCLTask", data)) |
| @@ -73,10 +73,10 @@ class CANNTraceDBDumper | |||
| 73 | void AddTaskInfo(const std::shared_ptr<HostTask> &task, TaskInfoData &data, bool isLevel0); | 73 | void AddTaskInfo(const std::shared_ptr<HostTask> &task, TaskInfoData &data, bool isLevel0); |
| 74 | void AddTaskInfoForOnlyTaskTrack(const std::shared_ptr<HostTask> &task, TaskInfoData &data, bool isLevel0); | 74 | void AddTaskInfoForOnlyTaskTrack(const std::shared_ptr<HostTask> &task, TaskInfoData &data, bool isLevel0); |
| 75 | 75 | ||
| 76 | - void AddTensorShapeInfo(const std::shared_ptr<ConcatTensorInfo> &tensorDesc, | 76 | + void AddTensorShapeInfo(const std::shared_ptr<ParserConcatTensorInfo> &tensorDesc, |
| 77 | - const MsprofNodeBasicInfo *nodeBasicInfo, TaskInfoData &data, | 77 | + const ParserNodeBasicInfo *nodeBasicInfo, TaskInfoData &data, |
| 78 | const std::shared_ptr<HostTask> &task); | 78 | const std::shared_ptr<HostTask> &task); |
| 79 | - static void ProcessRuntimeTrackInfo(const std::shared_ptr<MsprofCompactInfo> &runtimeTrack, uint32_t &blockNum, | 79 | + static void ProcessRuntimeTrackInfo(const std::shared_ptr<ParserCompactInfo> &runtimeTrack, uint32_t &blockNum, |
| 80 | uint32_t &mixBlockNum, std::string &gridDimStr, std::string &blockDimStr); | 80 | uint32_t &mixBlockNum, std::string &gridDimStr, std::string &blockDimStr); |
| 81 | static std::string GetFormat(uint32_t oriFormat); | 81 | static std::string GetFormat(uint32_t oriFormat); |
| 82 | const uint32_t poolSize_ = 4; | 82 | const uint32_t poolSize_ = 4; |
| @@ -25,7 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 28 | +#include "analysis/csrc/infrastructure/utils/parser_struct.h" |
| 29 | 29 | ||
| 30 | namespace Analysis | 30 | namespace Analysis |
| 31 | { | 31 | { |
| @@ -37,7 +37,7 @@ using DpuTaskTrackData = | |||
| 37 | 37 | ||
| 38 | class DpuTaskTrackDBDumper final : public BaseDumper<DpuTaskTrackDBDumper> | 38 | class DpuTaskTrackDBDumper final : public BaseDumper<DpuTaskTrackDBDumper> |
| 39 | { | 39 | { |
| 40 | - using DpuTrackInfos = std::vector<std::shared_ptr<MsprofCompactInfo>>; | 40 | + using DpuTrackInfos = std::vector<std::shared_ptr<ParserCompactInfo>>; |
| 41 | 41 | ||
| 42 | public: | 42 | public: |
| 43 | explicit DpuTaskTrackDBDumper(const std::string &hostFilePath); | 43 | explicit DpuTaskTrackDBDumper(const std::string &hostFilePath); |
| @@ -17,14 +17,14 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 20 | +#include "analysis/csrc/infrastructure/utils/parser_struct.h" |
| 21 | 21 | ||
| 22 | namespace Analysis | 22 | namespace Analysis |
| 23 | { | 23 | { |
| 24 | namespace Domain | 24 | namespace Domain |
| 25 | { | 25 | { |
| 26 | using MemcpyInfoData = std::vector<std::tuple<uint32_t, uint32_t, uint32_t, uint32_t, uint16_t, int64_t, uint16_t>>; | 26 | using MemcpyInfoData = std::vector<std::tuple<uint32_t, uint32_t, uint32_t, uint32_t, uint16_t, int64_t, uint16_t>>; |
| 27 | -using MemcpyInfos = std::vector<std::shared_ptr<MsprofCompactInfo>>; | 27 | +using MemcpyInfos = std::vector<std::shared_ptr<ParserCompactInfo>>; |
| 28 | struct MemcpyAsyncTask | 28 | struct MemcpyAsyncTask |
| 29 | { | 29 | { |
| 30 | uint32_t threadId; | 30 | uint32_t threadId; |
| @@ -14,12 +14,14 @@ | |||
| 14 | * See the Mulan PSL v2 for more details. | 14 | * See the Mulan PSL v2 for more details. |
| 15 | * -------------------------------------------------------------------------*/ | 15 | * -------------------------------------------------------------------------*/ |
| 16 | 16 | ||
| 17 | -#include "analysis/csrc/domain/services/persistence/host/number_mapping.h" | 17 | + |
| 18 | 18 | ||
| 19 | + | ||
| 19 | 20 | ||
| 20 | - | 21 | +namespace Analysis |
| 21 | -namespace Analysis { | 22 | +{ |
| 22 | -namespace Domain { | 23 | +namespace Domain |
| 24 | +{ | ||
| 23 | using HashData = Analysis::Domain::Host::Cann::HashData; | 25 | using HashData = Analysis::Domain::Host::Cann::HashData; |
| 24 | ModelNameDBDumper::ModelNameDBDumper(const std::string &hostFilePath) | 26 | ModelNameDBDumper::ModelNameDBDumper(const std::string &hostFilePath) |
| 25 | : BaseDumper<ModelNameDBDumper>(hostFilePath, "ModelName") | 27 | : BaseDumper<ModelNameDBDumper>(hostFilePath, "ModelName") |
| @@ -30,16 +32,17 @@ ModelNameDBDumper::ModelNameDBDumper(const std::string &hostFilePath) | |||
| 30 | ModelNameData ModelNameDBDumper::GenerateData(const GraphIdMaps &graphIdMaps) | 32 | ModelNameData ModelNameDBDumper::GenerateData(const GraphIdMaps &graphIdMaps) |
| 31 | { | 33 | { |
| 32 | ModelNameData data; | 34 | ModelNameData data; |
| 33 | - if (Utils::Reserve(data, graphIdMaps.size())) { | 35 | + if (Utils::Reserve(data, graphIdMaps.size())) |
| 34 | - for (auto &graphIdMap: graphIdMaps) { | 36 | + { |
| 35 | - auto idMapStruct = Utils::ReinterpretConvert<MsprofGraphIdInfo *>(graphIdMap->data); | 37 | + for (auto &graphIdMap : graphIdMaps) |
| 36 | - auto modelId = idMapStruct->modelId; | 38 | + { |
| 37 | - auto modelName = (idMapStruct->modelName == 0) ? "0" : | 39 | + auto idMapStruct = graphIdMap->graphIdInfo; |
| 38 | - HashData::GetInstance().Get(idMapStruct->modelName); | 40 | + auto modelId = idMapStruct.modelId; |
| 41 | + auto modelName = (idMapStruct.modelName == 0) ? "0" : HashData::GetInstance().Get(idMapStruct.modelName); | ||
| 39 | data.emplace_back(modelId, modelName); | 42 | data.emplace_back(modelId, modelName); |
| 40 | } | 43 | } |
| 41 | } | 44 | } |
| 42 | return data; | 45 | return data; |
| 43 | } | 46 | } |
| 44 | -} // Viewer | 47 | +} // namespace Domain |
| 45 | -} // Analysis | 48 | +} // namespace Analysis |
| @@ -16,19 +16,23 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | - | ||
| 20 | 19 | ||
| 20 | + | ||
| 21 | 21 | ||
| 22 | -namespace Analysis { | 22 | +namespace Analysis |
| 23 | -namespace Domain { | 23 | +{ |
| 24 | +namespace Domain | ||
| 25 | +{ | ||
| 24 | using ModelNameData = std::vector<std::tuple<uint32_t, std::string>>; | 26 | using ModelNameData = std::vector<std::tuple<uint32_t, std::string>>; |
| 25 | -class ModelNameDBDumper : public BaseDumper<ModelNameDBDumper> { | 27 | +class ModelNameDBDumper : public BaseDumper<ModelNameDBDumper> |
| 26 | - using GraphIdMaps = std::vector<std::shared_ptr<MsprofAdditionalInfo>>; | 28 | +{ |
| 27 | -public: | 29 | + using GraphIdMaps = std::vector<std::shared_ptr<ParserAdditionalInfo>>; |
| 30 | + | ||
| 31 | + public: | ||
| 28 | explicit ModelNameDBDumper(const std::string &hostFilePath); | 32 | explicit ModelNameDBDumper(const std::string &hostFilePath); |
| 29 | ModelNameData GenerateData(const GraphIdMaps &graphIdMaps); | 33 | ModelNameData GenerateData(const GraphIdMaps &graphIdMaps); |
| 30 | }; | 34 | }; |
| 31 | -} // Domain | 35 | +} // namespace Domain |
| 32 | -} // Analysis | 36 | +} // namespace Analysis |
| 33 | 37 | ||
| 34 | -#endif // ANALYSIS_CSRC_VIEWER_DATABASE_MODEL_NAME_DB_DUMPER_H | 38 | +#endif // ANALYSIS_CSRC_VIEWER_DATABASE_MODEL_NAME_DB_DUMPER_H |
| @@ -0,0 +1,495 @@ | |||
| 1 | +/* ------------------------------------------------------------------------- | ||
| 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | + * This file is part of the MindStudio project. | ||
| 4 | + * | ||
| 5 | + * MindStudio is licensed under Mulan PSL v2. | ||
| 6 | + * You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
| 7 | + * You may obtain a copy of Mulan PSL v2 at: | ||
| 8 | + * | ||
| 9 | + * http://license.coscl.org.cn/MulanPSL2 | ||
| 10 | + * | ||
| 11 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
| 12 | + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
| 13 | + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
| 14 | + * See the Mulan PSL v2 for more details. | ||
| 15 | + * -------------------------------------------------------------------------*/ | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +enum class CompactInfoFormat : uint8_t | ||
| 26 | +{ | ||
| 27 | + COMPACT_INFO_TYPE = 0, | ||
| 28 | + RUNTIME_TRACK_TYPE, | ||
| 29 | + DPU_TRACK_TYPE, | ||
| 30 | + CAPTURE_STREAM_INFO_TYP, | ||
| 31 | + NODE_BASIC_INFO_TYPE, | ||
| 32 | + ATTR_INFO_TYPE, | ||
| 33 | + HCCL_OP_INFO_TYPE, | ||
| 34 | + MEMCPY_INFO_TYPE, | ||
| 35 | +}; | ||
| 36 | + | ||
| 37 | +enum class AdditionalInfoFormat : uint8_t | ||
| 38 | +{ | ||
| 39 | + ADDITIONAL_INFO_TYPE = 0, | ||
| 40 | + CONTEXT_ID_INFO_TYPE, | ||
| 41 | + FUSION_OP_INFO_TYPE, | ||
| 42 | + GRAPH_ID_TYPE, | ||
| 43 | + TENSOR_INFO_TYPE, | ||
| 44 | + HCCL_INFO_TYPE, | ||
| 45 | + MEMORY_APPLICATION_TYPE, | ||
| 46 | + MULTI_THREAD_TYPE, | ||
| 47 | +}; | ||
| 48 | + | ||
| 49 | +enum class RuntimeTrackFormat : uint8_t | ||
| 50 | +{ | ||
| 51 | + V1 = 0, | ||
| 52 | + V2, | ||
| 53 | +}; | ||
| 54 | + | ||
| 55 | +enum class CaptureStreamFormat : uint8_t | ||
| 56 | +{ | ||
| 57 | + V1 = 0, | ||
| 58 | + V2, | ||
| 59 | +}; | ||
| 60 | + | ||
| 61 | +struct ParserApi | ||
| 62 | +{ | ||
| 63 | + uint16_t magicNumber = MSPROF_DATA_HEAD_MAGIC_NUM; | ||
| 64 | + uint16_t level; | ||
| 65 | + uint32_t type; | ||
| 66 | + uint32_t threadId; | ||
| 67 | + uint32_t reserve; | ||
| 68 | + uint64_t beginTime; | ||
| 69 | + uint64_t endTime; | ||
| 70 | + uint64_t itemId; | ||
| 71 | +}; | ||
| 72 | + | ||
| 73 | +struct ParserEvent | ||
| 74 | +{ | ||
| 75 | + uint16_t magicNumber = MSPROF_DATA_HEAD_MAGIC_NUM; | ||
| 76 | + uint16_t level; | ||
| 77 | + uint32_t type; | ||
| 78 | + uint32_t threadId; | ||
| 79 | + uint32_t requestId; // 0xFFFF means single event | ||
| 80 | + uint64_t timeStamp; | ||
| 81 | + uint64_t reserve = MSPROF_EVENT_FLAG; | ||
| 82 | + uint64_t itemId; | ||
| 83 | +}; | ||
| 84 | + | ||
| 85 | +struct ParserKernelInfo | ||
| 86 | +{ | ||
| 87 | + uint16_t numBlocks; | ||
| 88 | + uint16_t argsSize; | ||
| 89 | + uint8_t ratio; | ||
| 90 | + uint8_t schedMode; | ||
| 91 | +}; | ||
| 92 | + | ||
| 93 | +struct ParserSimtKernelInfo | ||
| 94 | +{ | ||
| 95 | + MsprofDim3 gridDim; | ||
| 96 | + MsprofDim3 blockDim; | ||
| 97 | + uint16_t argsSize; | ||
| 98 | + uint8_t schedMode; | ||
| 99 | +}; | ||
| 100 | + | ||
| 101 | +struct ParserModelInfo | ||
| 102 | +{ | ||
| 103 | + uint32_t modelId; | ||
| 104 | +}; | ||
| 105 | + | ||
| 106 | +struct ParserEventInfo | ||
| 107 | +{ | ||
| 108 | + uint64_t key; | ||
| 109 | +}; | ||
| 110 | + | ||
| 111 | +struct ParserNotifyInfo | ||
| 112 | +{ | ||
| 113 | + uint64_t key; | ||
| 114 | +}; | ||
| 115 | + | ||
| 116 | +struct ParserRuntimeTrack | ||
| 117 | +{ // for MsprofReportCompactInfo buffer data | ||
| 118 | + uint16_t deviceId; | ||
| 119 | + uint32_t streamId; | ||
| 120 | + uint32_t taskId; | ||
| 121 | + uint64_t taskType; | ||
| 122 | + uint64_t kernelName; | ||
| 123 | + struct ParserKernelInfo kernelInfo; | ||
| 124 | + struct ParserSimtKernelInfo simtKernelInfo; | ||
| 125 | + struct ParserModelInfo modelInfo; | ||
| 126 | + struct ParserEventInfo eventInfo; | ||
| 127 | + struct ParserNotifyInfo notifyInfo; | ||
| 128 | +}; | ||
| 129 | + | ||
| 130 | +struct ParserDpuTrack | ||
| 131 | +{ // for MsprofReportCompactInfo buffer data | ||
| 132 | + uint16_t deviceId; // high 4 bits, devType: dpu: 1, low 12 bits device id | ||
| 133 | + uint32_t streamId; | ||
| 134 | + uint32_t taskId; | ||
| 135 | + uint32_t taskType; // task type enum | ||
| 136 | + uint32_t res; | ||
| 137 | + uint64_t startTime; // start time | ||
| 138 | +}; | ||
| 139 | + | ||
| 140 | +struct ParserCaptureStreamInfo | ||
| 141 | +{ | ||
| 142 | + uint16_t deviceId; | ||
| 143 | + uint16_t captureStatus; // 0:创建 1:销毁 | ||
| 144 | + uint32_t streamId; | ||
| 145 | + uint32_t originalStreamId; | ||
| 146 | + uint32_t modelId; | ||
| 147 | +}; | ||
| 148 | + | ||
| 149 | +struct ParserHcclOPInfo | ||
| 150 | +{ // for MsprofReportCompactInfo buffer data | ||
| 151 | + uint8_t relay; | ||
| 152 | + uint8_t retry; | ||
| 153 | + uint8_t dataType; | ||
| 154 | + uint64_t algType; // 通信算子使用的算法,hash的key,其值是以"-"分隔的字符串 | ||
| 155 | + uint64_t count; | ||
| 156 | + uint64_t groupName; | ||
| 157 | +}; | ||
| 158 | + | ||
| 159 | +struct ParserMemcpyInfo | ||
| 160 | +{ // for MsprofReportCompactInfo buffer data | ||
| 161 | + uint64_t dataSize; // 数据量大小, 字节 | ||
| 162 | + uint64_t maxSize; // 单个task拷贝的最大数据量 | ||
| 163 | + uint16_t memcpyDirection; // memcpy的方向 | ||
| 164 | +}; | ||
| 165 | + | ||
| 166 | +struct ParserNodeBasicInfo | ||
| 167 | +{ | ||
| 168 | + uint64_t opName; | ||
| 169 | + uint32_t taskType; | ||
| 170 | + uint64_t opType; | ||
| 171 | + uint32_t blockNum; | ||
| 172 | + uint32_t opFlag; | ||
| 173 | + uint8_t opState; | ||
| 174 | +}; | ||
| 175 | + | ||
| 176 | +struct ParserAttrInfo | ||
| 177 | +{ | ||
| 178 | + uint64_t opName; | ||
| 179 | + uint32_t attrType; | ||
| 180 | + uint64_t hashId; | ||
| 181 | +}; | ||
| 182 | + | ||
| 183 | +const uint16_t PARSER_COMPACT_INFO_DATA_LENGTH = 104; | ||
| 184 | +struct ParserCompactInfo | ||
| 185 | +{ | ||
| 186 | + uint16_t magicNumber = MSPROF_DATA_HEAD_MAGIC_NUM; | ||
| 187 | + uint16_t level; | ||
| 188 | + uint32_t type; | ||
| 189 | + uint32_t threadId; | ||
| 190 | + uint32_t dataLen; | ||
| 191 | + uint64_t timeStamp; | ||
| 192 | + union | ||
| 193 | + { | ||
| 194 | + uint8_t info[PARSER_COMPACT_INFO_DATA_LENGTH]; | ||
| 195 | + ParserRuntimeTrack runtimeTrack; | ||
| 196 | + ParserDpuTrack dpuTrack; | ||
| 197 | + ParserCaptureStreamInfo captureStreamInfo; | ||
| 198 | + ParserNodeBasicInfo nodeBasicInfo; | ||
| 199 | + ParserAttrInfo nodeAttrInfo; | ||
| 200 | + ParserHcclOPInfo hcclopInfo; | ||
| 201 | + ParserMemcpyInfo memcpyInfo; | ||
| 202 | + } data; | ||
| 203 | +}; | ||
| 204 | + | ||
| 205 | +struct ParserAicpuNodeAdditionalData | ||
| 206 | +{ | ||
| 207 | + uint16_t streamId; | ||
| 208 | + uint16_t taskId; | ||
| 209 | + uint32_t rev; | ||
| 210 | + uint64_t runStartTime; | ||
| 211 | + uint64_t runStartTick; | ||
| 212 | + uint64_t computeStartTime; | ||
| 213 | + uint64_t memcpyStartTime; | ||
| 214 | + uint64_t memcpyEndTime; | ||
| 215 | + uint64_t runEndTime; | ||
| 216 | + uint64_t runEndTick; | ||
| 217 | + uint32_t threadId; | ||
| 218 | + uint32_t deviceId; | ||
| 219 | + uint64_t submitTick; | ||
| 220 | + uint64_t scheduleTick; | ||
| 221 | + uint64_t tickBeforeRun; | ||
| 222 | + uint64_t tickAfterRun; | ||
| 223 | + uint32_t kernelType; | ||
| 224 | + uint32_t dispatchTime; | ||
| 225 | + uint32_t totalTime; | ||
| 226 | + uint16_t fftsThreadId; | ||
| 227 | + uint8_t version; | ||
| 228 | +}; | ||
| 229 | + | ||
| 230 | +struct ParserAicpuDpAdditionalData | ||
| 231 | +{ | ||
| 232 | + char action[MSPROF_DP_DATA_ACTION_LEN]; | ||
| 233 | + char source[MSPROF_DP_DATA_SOURCE_LEN]; | ||
| 234 | + uint64_t index; | ||
| 235 | + uint64_t size; | ||
| 236 | +}; | ||
| 237 | + | ||
| 238 | +struct ParserAicpuModelAdditionalData | ||
| 239 | +{ | ||
| 240 | + uint64_t indexId; | ||
| 241 | + uint32_t modelId; | ||
| 242 | + uint16_t tagId; | ||
| 243 | + uint16_t rsv1; | ||
| 244 | + uint64_t eventId; | ||
| 245 | +}; | ||
| 246 | + | ||
| 247 | +struct ParserAicpuMiAdditionalData | ||
| 248 | +{ | ||
| 249 | + uint32_t nodeTag; // MsprofMindsporeNodeTag:1 | ||
| 250 | + uint32_t reserve; | ||
| 251 | + uint64_t queueSize; | ||
| 252 | + uint64_t runStartTime; | ||
| 253 | + uint64_t runEndTime; | ||
| 254 | +}; | ||
| 255 | + | ||
| 256 | +struct ParserAicpuKfcProfCommTurn | ||
| 257 | +{ | ||
| 258 | + uint64_t serverStartTime; // 进入KFC流程 | ||
| 259 | + uint64_t waitMsgStartTime; // 开始等待客户端消息 | ||
| 260 | + uint64_t kfcAlgExeStartTime; // 开始通信算法执行 | ||
| 261 | + uint64_t sendTaskStartTime; // 开始下发task | ||
| 262 | + uint64_t sendSqeFinishTime; // task下发完成 | ||
| 263 | + uint64_t rtsqExeEndTime; // sq执行结束时间 | ||
| 264 | + uint64_t serverEndTime; // KFC流程结束时间 | ||
| 265 | + uint64_t dataLen; // 本轮通信数据长度 | ||
| 266 | + uint32_t deviceId; | ||
| 267 | + uint16_t streamId; | ||
| 268 | + uint16_t taskId; | ||
| 269 | + uint8_t version; | ||
| 270 | + uint8_t commTurn; // 总通信轮次 | ||
| 271 | + uint8_t currentTurn; | ||
| 272 | + uint8_t reserve[5]; | ||
| 273 | +}; | ||
| 274 | + | ||
| 275 | +struct ParserAicpuKfcProfComputeTurn | ||
| 276 | +{ | ||
| 277 | + uint64_t waitComputeStartTime; // 开始等待计算 | ||
| 278 | + uint64_t computeStartTime; // 开始计算 | ||
| 279 | + uint64_t computeExeEndTime; // 计算执行结束 | ||
| 280 | + uint64_t dataLen; // 本轮计算数据长度 | ||
| 281 | + uint32_t deviceId; | ||
| 282 | + uint16_t streamId; | ||
| 283 | + uint16_t taskId; | ||
| 284 | + uint8_t version; | ||
| 285 | + uint8_t computeTurn; // 总计算轮次 | ||
| 286 | + uint8_t currentTurn; | ||
| 287 | + uint8_t reserve[5]; | ||
| 288 | +}; | ||
| 289 | + | ||
| 290 | +struct ParserAicpuFlipTask | ||
| 291 | +{ | ||
| 292 | + uint16_t streamId; | ||
| 293 | + uint16_t taskId; // 值无特殊要求 | ||
| 294 | + uint32_t flipNum; | ||
| 295 | + uint32_t reserve[2]; | ||
| 296 | +}; | ||
| 297 | + | ||
| 298 | +struct ParserAicpuHcclMainStreamTask | ||
| 299 | +{ | ||
| 300 | + uint16_t aicpuStreamId; | ||
| 301 | + uint16_t aicpuTaskId; | ||
| 302 | + uint16_t streamId; | ||
| 303 | + uint16_t taskId; | ||
| 304 | + uint16_t type; // 0是头 1是尾 | ||
| 305 | + uint16_t reserve[3]; | ||
| 306 | +}; | ||
| 307 | + | ||
| 308 | +struct ParserHcclInfo | ||
| 309 | +{ | ||
| 310 | + uint64_t itemId; | ||
| 311 | + uint64_t cclTag; | ||
| 312 | + uint64_t groupName; | ||
| 313 | + uint32_t localRank; | ||
| 314 | + uint32_t remoteRank; | ||
| 315 | + uint32_t rankSize; | ||
| 316 | + uint32_t workFlowMode; | ||
| 317 | + uint32_t planeID; | ||
| 318 | + uint32_t ctxID; | ||
| 319 | + uint64_t notifyID; | ||
| 320 | + uint32_t stage; | ||
| 321 | + uint32_t role; // role {0: dst, 1:src} | ||
| 322 | + double durationEstimated; | ||
| 323 | + uint64_t srcAddr; | ||
| 324 | + uint64_t dstAddr; | ||
| 325 | + uint64_t dataSize; // bytes | ||
| 326 | + uint32_t opType; // {0: sum, 1: mul, 2: max, 3: min} | ||
| 327 | + uint32_t dataType; // data type {0: INT8, 1: INT16, 2: INT32, 3: FP16, 4:FP32, 5:INT64, 6:UINT64} | ||
| 328 | + uint32_t linkType; // link type {0: 'OnChip', 1: 'HCCS', 2: 'PCIe', 3: 'RoCE', 4: 'SIO'} | ||
| 329 | + uint32_t transportType; // transport type {0: SDMA, 1: RDMA, 2:LOCAL} | ||
| 330 | + uint32_t rdmaType; // RDMA type {0: RDMASendNotify, 1:RDMASendPayload} | ||
| 331 | + uint32_t reserve2; | ||
| 332 | +}; | ||
| 333 | + | ||
| 334 | +struct ParserMultiThread | ||
| 335 | +{ | ||
| 336 | + uint32_t threadNum; | ||
| 337 | + uint32_t threadId[MSPROF_MULTI_THREAD_MAX_NUM]; | ||
| 338 | +}; | ||
| 339 | + | ||
| 340 | +struct ParserTensorData | ||
| 341 | +{ | ||
| 342 | + uint32_t tensorType; | ||
| 343 | + uint32_t format; | ||
| 344 | + uint32_t dataType; | ||
| 345 | + uint32_t shape[MSPROF_GE_TENSOR_DATA_SHAPE_LEN]; | ||
| 346 | +}; | ||
| 347 | + | ||
| 348 | +struct ParserTensorInfo | ||
| 349 | +{ | ||
| 350 | + uint64_t opName; | ||
| 351 | + uint32_t tensorNum; | ||
| 352 | + ParserTensorData tensorData[MSPROF_GE_TENSOR_DATA_NUM]; | ||
| 353 | +}; | ||
| 354 | + | ||
| 355 | +struct ParserConcatTensorInfo | ||
| 356 | +{ | ||
| 357 | + uint16_t magicNumber = MSPROF_DATA_HEAD_MAGIC_NUM; | ||
| 358 | + uint16_t level = 0; | ||
| 359 | + uint32_t type = 0; | ||
| 360 | + uint32_t threadId = 0; | ||
| 361 | + uint32_t dataLen = 0; | ||
| 362 | + uint64_t timeStamp = 0; | ||
| 363 | + uint64_t opName = 0; | ||
| 364 | + uint32_t tensorNum = 0; | ||
| 365 | + std::vector<ParserTensorData> tensorData{MSPROF_GE_TENSOR_DATA_NUM}; | ||
| 366 | +}; | ||
| 367 | + | ||
| 368 | +struct ParserProfFusionOpInfo | ||
| 369 | +{ | ||
| 370 | + uint64_t opName; | ||
| 371 | + uint32_t fusionOpNum; | ||
| 372 | + uint64_t inputMemsize; | ||
| 373 | + uint64_t outputMemsize; | ||
| 374 | + uint64_t weightMemSize; | ||
| 375 | + uint64_t workspaceMemSize; | ||
| 376 | + uint64_t totalMemSize; | ||
| 377 | + uint64_t fusionOpId[MSPROF_GE_FUSION_OP_NUM]; | ||
| 378 | +}; | ||
| 379 | + | ||
| 380 | +struct ParserContextIdInfo | ||
| 381 | +{ | ||
| 382 | + uint64_t opName; | ||
| 383 | + uint32_t ctxIdNum; | ||
| 384 | + uint32_t ctxIds[MSPROF_CTX_ID_MAX_NUM]; | ||
| 385 | +}; | ||
| 386 | + | ||
| 387 | +struct ParserGraphIdInfo | ||
| 388 | +{ | ||
| 389 | + uint64_t modelName; | ||
| 390 | + uint32_t graphId; | ||
| 391 | + uint32_t modelId; | ||
| 392 | +}; | ||
| 393 | + | ||
| 394 | +struct ParserMemoryInfo | ||
| 395 | +{ | ||
| 396 | + uint64_t addr; | ||
| 397 | + int64_t size; | ||
| 398 | + uint64_t nodeId; | ||
| 399 | + uint64_t totalAllocateMemory; | ||
| 400 | + uint64_t totalReserveMemory; | ||
| 401 | + uint32_t deviceId; | ||
| 402 | + uint32_t deviceType; | ||
| 403 | +}; | ||
| 404 | + | ||
| 405 | +struct ParserStaticOpMem | ||
| 406 | +{ | ||
| 407 | + int64_t size; // op memory size | ||
| 408 | + uint64_t opName; // op name hash id | ||
| 409 | + uint64_t lifeStart; // serial number of op memory used | ||
| 410 | + uint64_t lifeEnd; // serial number of op memory used | ||
| 411 | + uint64_t totalAllocateMemory; // static graph total allocate memory | ||
| 412 | + uint64_t dynOpName; // 0: invalid, other: dynamic op name of root | ||
| 413 | + uint32_t graphId; // multiple model | ||
| 414 | +}; | ||
| 415 | + | ||
| 416 | +struct ParserAicpuHCCLOPInfo | ||
| 417 | +{ | ||
| 418 | + uint8_t relay; // 借轨通信 | ||
| 419 | + uint8_t retry; // 重传标识 | ||
| 420 | + uint8_t dataType; // 跟HcclDataType类型保存一致 | ||
| 421 | + uint64_t algType; // 通信算子使用的算法,hash的key,其值是以"-"分隔的字符串 | ||
| 422 | + uint64_t count; // 发送数据个数 | ||
| 423 | + uint64_t groupName; // group hash id | ||
| 424 | + uint32_t rankSize; | ||
| 425 | + uint16_t streamId; | ||
| 426 | + uint32_t taskId; | ||
| 427 | +}; | ||
| 428 | + | ||
| 429 | +struct ParserAicpuHcclTaskInfo | ||
| 430 | +{ | ||
| 431 | + uint64_t itemId; | ||
| 432 | + uint64_t cclTag; | ||
| 433 | + uint64_t groupName; | ||
| 434 | + uint32_t localRank; | ||
| 435 | + uint32_t remoteRank; | ||
| 436 | + uint32_t rankSize; | ||
| 437 | + uint32_t stage; | ||
| 438 | + uint64_t notifyID; | ||
| 439 | + uint64_t timeStamp; | ||
| 440 | + double durationEstimated; | ||
| 441 | + uint64_t srcAddr; | ||
| 442 | + uint64_t dstAddr; | ||
| 443 | + uint64_t dataSize; // bytes | ||
| 444 | + uint32_t taskId; | ||
| 445 | + uint32_t reserve; | ||
| 446 | + uint16_t streamId; | ||
| 447 | + uint16_t planeID; | ||
| 448 | + uint8_t opType; // {0: sum, 1: mul, 2: max, 3: min} | ||
| 449 | + uint8_t dataType; // data type {0: INT8, 1: INT16, 2: INT32, 3: FP16, 4:FP32, 5:INT64, 6:UINT64} | ||
| 450 | + uint8_t linkType; // link type {0: 'OnChip', 1: 'HCCS', 2: 'PCIe', 3: 'RoCE'} | ||
| 451 | + uint8_t transportType; // transport type {0: SDMA, 1: RDMA, 2:LOCAL} | ||
| 452 | + uint8_t rdmaType; // RDMA type {0: RDMASendNotify, 1:RDMASendPayload} | ||
| 453 | + uint8_t role; // role {0: dst, 1:src} | ||
| 454 | + uint8_t workFlowMode; | ||
| 455 | + uint8_t reserves[9]; | ||
| 456 | +}; | ||
| 457 | + | ||
| 458 | +struct ParserKfcInfos | ||
| 459 | +{ | ||
| 460 | + ParserAicpuHcclTaskInfo infos[KFC_INFOS_NUM]; | ||
| 461 | +}; | ||
| 462 | + | ||
| 463 | +struct ParserAdditionalInfo | ||
| 464 | +{ // for MsprofReportAdditionalInfo buffer data | ||
| 465 | + uint16_t magicNumber = MSPROF_DATA_HEAD_MAGIC_NUM; | ||
| 466 | + uint16_t level; | ||
| 467 | + uint32_t type; | ||
| 468 | + uint32_t threadId; | ||
| 469 | + uint32_t dataLen; | ||
| 470 | + uint64_t timeStamp; | ||
| 471 | + union | ||
| 472 | + { | ||
| 473 | + uint8_t data[MSPROF_ADDITIONAL_INFO_DATA_LENGTH]; | ||
| 474 | + ParserAicpuNodeAdditionalData aicpuNode; | ||
| 475 | + ParserAicpuDpAdditionalData aicpuDp; | ||
| 476 | + ParserAicpuModelAdditionalData aicpuModel; | ||
| 477 | + ParserAicpuMiAdditionalData aicpuMi; | ||
| 478 | + ParserAicpuKfcProfCommTurn commTurn; | ||
| 479 | + ParserAicpuKfcProfComputeTurn computeTurn; | ||
| 480 | + ParserAicpuHCCLOPInfo opInfo; | ||
| 481 | + ParserAicpuFlipTask flipTask; | ||
| 482 | + ParserAicpuHcclMainStreamTask mainStreamTask; | ||
| 483 | + ParserKfcInfos kfcInfos; | ||
| 484 | + ParserHcclInfo hcclInfo; | ||
| 485 | + ParserMultiThread multiThread; | ||
| 486 | + ParserNodeBasicInfo nodeBasicInfo; | ||
| 487 | + ParserAttrInfo attrInfo; | ||
| 488 | + ParserTensorInfo tensorInfo; | ||
| 489 | + ParserProfFusionOpInfo fusionOpInfo; | ||
| 490 | + ParserContextIdInfo contextIdInfo; | ||
| 491 | + ParserGraphIdInfo graphIdInfo; | ||
| 492 | + }; | ||
| 493 | +}; | ||
| 494 | + | ||
| 495 | + | ||
| @@ -13,8 +13,8 @@ | |||
| 13 | * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | 13 | * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. |
| 14 | * See the Mulan PSL v2 for more details. | 14 | * See the Mulan PSL v2 for more details. |
| 15 | * -------------------------------------------------------------------------*/ | 15 | * -------------------------------------------------------------------------*/ |
| 16 | -#ifndef MSPROFILER_PROF_COMMON_H_ | 16 | +#ifndef MSPROFILER_PROF_STRUCT_H_ |
| 17 | -#define MSPROFILER_PROF_COMMON_H_ | 17 | +#define MSPROFILER_PROF_STRUCT_H_ |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| @@ -289,10 +289,10 @@ extern "C" | |||
| 289 | uint8_t reserves[9]; | 289 | uint8_t reserves[9]; |
| 290 | }; | 290 | }; |
| 291 | 291 | ||
| 292 | - | 292 | + const uint32_t KFC_INFOS_NUM = 2; |
W [review] 当前文件名是原本采集侧遗留的结构体。内部较多常量定义在解析侧可能不感知。建议整理当前的文件内容,清理不必要的数据内容,后续若有需要再单独补充。包括常量定义,冗余结构体等。另外,相关的文件命名也可调整对齐解析结构体文件。没有必要突出common字样等内容。 ![]() ![]() | |||
| 293 | struct MsprofKfcInfos | 293 | struct MsprofKfcInfos |
| 294 | { | 294 | { |
| 295 | - MsprofAicpuHcclTaskInfo infos[2]; | 295 | + MsprofAicpuHcclTaskInfo infos[KFC_INFOS_NUM]; |
| 296 | }; | 296 | }; |
| 297 | 297 | ||
| 298 | // AICPU kfc算子执行时间 | 298 | // AICPU kfc算子执行时间 |
| @@ -724,4 +724,4 @@ extern "C" | |||
| 724 | } | 724 | } |
| 725 | 725 | ||
| 726 | 726 | ||
| 727 | -#endif // MSPROFILER_PROF_COMMON_H_ | 727 | +#endif // MSPROFILER_PROF_STRUCT_H_ |
| @@ -25,7 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 28 | +#include "analysis/csrc/infrastructure/utils/prof_struct.h" |
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | using namespace Analysis::Domain::Host::Cann; | 31 | using namespace Analysis::Domain::Host::Cann; |
| @@ -226,17 +226,15 @@ std::shared_ptr<EventQueue> GenTaskTrackEventQueue(const std::vector<std::pair<u | |||
| 226 | std::shared_ptr<Event> GenCtxIdEvent(uint64_t dot, uint16_t level, uint32_t ctxIdNum) | 226 | std::shared_ptr<Event> GenCtxIdEvent(uint64_t dot, uint16_t level, uint32_t ctxIdNum) |
| 227 | { | 227 | { |
| 228 | EventInfo testInfo{EventType::EVENT_TYPE_CONTEXT_ID, level, dot, dot}; | 228 | EventInfo testInfo{EventType::EVENT_TYPE_CONTEXT_ID, level, dot, dot}; |
| 229 | - auto additionInfo = std::make_shared<MsprofAdditionalInfo>(); | 229 | + auto additionInfo = std::make_shared<ParserAdditionalInfo>(); |
| 230 | uint32_t dataLen = 2; | 230 | uint32_t dataLen = 2; |
| 231 | additionInfo->timeStamp = dot; | 231 | additionInfo->timeStamp = dot; |
| 232 | additionInfo->dataLen = dataLen; | 232 | additionInfo->dataLen = dataLen; |
| 233 | 233 | ||
| 234 | - MsprofContextIdInfo ctxId; | 234 | + additionInfo->contextIdInfo.opName = dot; |
| 235 | - ctxId.opName = dot; | 235 | + additionInfo->contextIdInfo.ctxIdNum = ctxIdNum; |
| 236 | - ctxId.ctxIdNum = ctxIdNum; | 236 | + additionInfo->contextIdInfo.ctxIds[0] = 0; |
| 237 | - uint32_t ids[2] = {0, 1}; | 237 | + additionInfo->contextIdInfo.ctxIds[1] = 1; |
| 238 | - std::memcpy(ctxId.ctxIds, &ids, sizeof(ids)); | ||
| 239 | - std::memcpy(additionInfo->data, &ctxId, sizeof(ctxId)); | ||
| 240 | 238 | ||
| 241 | auto eventPtr = std::make_shared<Event>(additionInfo, testInfo); | 239 | auto eventPtr = std::make_shared<Event>(additionInfo, testInfo); |
| 242 | return eventPtr; | 240 | return eventPtr; |
| @@ -246,16 +244,14 @@ std::shared_ptr<Event> GenHcclInfoEvent(uint64_t dot) | |||
| 246 | { | 244 | { |
| 247 | uint32_t cnt = 0; | 245 | uint32_t cnt = 0; |
| 248 | EventInfo testInfo{EventType::EVENT_TYPE_HCCL_INFO, MSPROF_REPORT_HCCL_NODE_LEVEL, dot, dot}; | 246 | EventInfo testInfo{EventType::EVENT_TYPE_HCCL_INFO, MSPROF_REPORT_HCCL_NODE_LEVEL, dot, dot}; |
| 249 | - auto hcclInfo = std::make_shared<MsprofAdditionalInfo>(); | 247 | + auto hcclInfo = std::make_shared<ParserAdditionalInfo>(); |
| 250 | hcclInfo->magicNumber = MSPROF_DATA_HEAD_MAGIC_NUM; | 248 | hcclInfo->magicNumber = MSPROF_DATA_HEAD_MAGIC_NUM; |
| 251 | hcclInfo->level = MSPROF_REPORT_HCCL_NODE_LEVEL; | 249 | hcclInfo->level = MSPROF_REPORT_HCCL_NODE_LEVEL; |
| 252 | hcclInfo->type = static_cast<uint32_t>(EventType::EVENT_TYPE_HCCL_INFO); | 250 | hcclInfo->type = static_cast<uint32_t>(EventType::EVENT_TYPE_HCCL_INFO); |
| 253 | hcclInfo->timeStamp = static_cast<uint64_t>(dot); | 251 | hcclInfo->timeStamp = static_cast<uint64_t>(dot); |
| 254 | 252 | ||
| 255 | - auto hcclTrace = MsprofHcclInfo{}; | 253 | + hcclInfo->hcclInfo.ctxID = cnt; |
| 256 | - hcclTrace.ctxID = cnt; | 254 | + hcclInfo->hcclInfo.itemId = dot; |
| 257 | - hcclTrace.itemId = dot; | ||
| 258 | - std::memcpy(hcclInfo->data, &hcclTrace, sizeof(hcclTrace)); | ||
| 259 | auto eventPtr = std::make_shared<Event>(hcclInfo, testInfo); | 255 | auto eventPtr = std::make_shared<Event>(hcclInfo, testInfo); |
| 260 | 256 | ||
| 261 | return eventPtr; | 257 | return eventPtr; |
| @@ -276,7 +272,7 @@ std::shared_ptr<EventQueue> GenFusionOpEventQueue(const std::vector<uint64_t> &f | |||
| 276 | { | 272 | { |
| 277 | auto fusionOpInfoEvents = std::make_shared<EventQueue>(1, 10); | 273 | auto fusionOpInfoEvents = std::make_shared<EventQueue>(1, 10); |
| 278 | for (auto dot: fusionOps) { | 274 | for (auto dot: fusionOps) { |
| 279 | - auto additionPtr = std::make_shared<MsprofAdditionalInfo>(); | 275 | + auto additionPtr = std::make_shared<ParserAdditionalInfo>(); |
| 280 | FakeEventGenerator::AddFusionOpEvent(fusionOpInfoEvents, dot, additionPtr); | 276 | FakeEventGenerator::AddFusionOpEvent(fusionOpInfoEvents, dot, additionPtr); |
| 281 | } | 277 | } |
| 282 | fusionOpInfoEvents->Sort(); | 278 | fusionOpInfoEvents->Sort(); |
| @@ -23,7 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 26 | +#include "analysis/csrc/infrastructure/utils/prof_struct.h" |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | using namespace Analysis::Domain::Host::Cann; | 29 | using namespace Analysis::Domain::Host::Cann; |
| @@ -261,7 +261,7 @@ TEST_F(TreeBuilderUTest, TestAddLevelEventsShouldMatchCorrectNodeWhenInputNotEmp | |||
| 261 | std::vector<std::pair<uint64_t, uint64_t>> nodesTimes{{2, 3}, {5, 8}, {10, 12}}; | 261 | std::vector<std::pair<uint64_t, uint64_t>> nodesTimes{{2, 3}, {5, 8}, {10, 12}}; |
| 262 | for (auto range: nodesTimes) { | 262 | for (auto range: nodesTimes) { |
| 263 | EventInfo info{EventType::EVENT_TYPE_API, 0, range.first, range.second}; | 263 | EventInfo info{EventType::EVENT_TYPE_API, 0, range.first, range.second}; |
| 264 | - auto event = std::make_shared<Event>(std::shared_ptr<MsprofApi>{}, | 264 | + auto event = std::make_shared<Event>(std::shared_ptr<ParserApi>{}, |
| 265 | info); | 265 | info); |
| 266 | levelNodes.emplace_back(std::make_shared<TreeNode>(event)); | 266 | levelNodes.emplace_back(std::make_shared<TreeNode>(event)); |
| 267 | } | 267 | } |
| @@ -271,7 +271,7 @@ TEST_F(TreeBuilderUTest, TestAddLevelEventsShouldMatchCorrectNodeWhenInputNotEmp | |||
| 271 | auto eventQueue = std::make_shared<EventQueue>(1, eventDots.size()); | 271 | auto eventQueue = std::make_shared<EventQueue>(1, eventDots.size()); |
| 272 | for (auto dot: eventDots) { | 272 | for (auto dot: eventDots) { |
| 273 | EventInfo info{EventType::EVENT_TYPE_NODE_BASIC_INFO, 0, dot, dot}; | 273 | EventInfo info{EventType::EVENT_TYPE_NODE_BASIC_INFO, 0, dot, dot}; |
| 274 | - auto eventPtr = std::make_shared<Event>(std::shared_ptr<MsprofCompactInfo>{}, | 274 | + auto eventPtr = std::make_shared<Event>(std::shared_ptr<ParserCompactInfo>{}, |
| 275 | info); | 275 | info); |
| 276 | eventQueue->Push(eventPtr); | 276 | eventQueue->Push(eventPtr); |
| 277 | } | 277 | } |
| @@ -400,13 +400,13 @@ TEST_F(TreeBuilderUTest, TestGetEventOffsetShouldReturnOffset2WhenNodeNested) | |||
| 400 | // hccl aicpu下发场景, 会出现2层node嵌套, 需要计算offset, 关联至准确的node api | 400 | // hccl aicpu下发场景, 会出现2层node嵌套, 需要计算offset, 关联至准确的node api |
| 401 | // [=======================Node(hcom_allReduce_)==============================] | 401 | // [=======================Node(hcom_allReduce_)==============================] |
| 402 | // [===Node(hcomAicpuInit)==] [===Node(allreduceAicpuKernel)==] | 402 | // [===Node(hcomAicpuInit)==] [===Node(allreduceAicpuKernel)==] |
| 403 | - std::shared_ptr<MsprofCompactInfo> compactEvent; | 403 | + std::shared_ptr<ParserCompactInfo> compactEvent; |
| 404 | uint16_t level = 3; | 404 | uint16_t level = 3; |
| 405 | uint64_t eventTime = 100; | 405 | uint64_t eventTime = 100; |
| 406 | EventInfo nodeBasicInfo(EventType::EVENT_TYPE_NODE_BASIC_INFO, level, eventTime, eventTime); | 406 | EventInfo nodeBasicInfo(EventType::EVENT_TYPE_NODE_BASIC_INFO, level, eventTime, eventTime); |
| 407 | std::shared_ptr<Event> event = std::make_shared<Event>(compactEvent, nodeBasicInfo); | 407 | std::shared_ptr<Event> event = std::make_shared<Event>(compactEvent, nodeBasicInfo); |
| 408 | 408 | ||
| 409 | - std::shared_ptr<MsprofApi> apiEvent; | 409 | + std::shared_ptr<ParserApi> apiEvent; |
| 410 | uint64_t startTime1 = 10; | 410 | uint64_t startTime1 = 10; |
| 411 | uint64_t endTime1 = 200; | 411 | uint64_t endTime1 = 200; |
| 412 | EventInfo apiEventInfo1(EventType::EVENT_TYPE_API, level, startTime1, endTime1); | 412 | EventInfo apiEventInfo1(EventType::EVENT_TYPE_API, level, startTime1, endTime1); |
| @@ -21,7 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 24 | +#include "analysis/csrc/infrastructure/utils/prof_struct.h" |
| 25 | 25 | ||
| 26 | using namespace Analysis::Domain; | 26 | using namespace Analysis::Domain; |
| 27 | 27 | ||
| @@ -49,7 +49,7 @@ TEST_F(EventQueueUTest, TestPushCheckBound) | |||
| 49 | /* 测试Push函数 lock前Push需要满足维护队列bound值正确性 */ | 49 | /* 测试Push函数 lock前Push需要满足维护队列bound值正确性 */ |
| 50 | for (int i = 0; i < pushNum; ++i) { | 50 | for (int i = 0; i < pushNum; ++i) { |
| 51 | EventInfo testInfo{EventType::EVENT_TYPE_API, 0, (uint64_t) i, (uint64_t) (2 * i)}; | 51 | EventInfo testInfo{EventType::EVENT_TYPE_API, 0, (uint64_t) i, (uint64_t) (2 * i)}; |
| 52 | - auto eventPtr = std::make_shared<Event>(std::shared_ptr<MsprofApi>{}, | 52 | + auto eventPtr = std::make_shared<Event>(std::shared_ptr<ParserApi>{}, |
| 53 | testInfo); | 53 | testInfo); |
| 54 | eventQueue->Push(eventPtr); | 54 | eventQueue->Push(eventPtr); |
| 55 | } | 55 | } |
| @@ -83,7 +83,7 @@ TEST_F(EventQueueUTest, PopWhenQueueNotEmpty) | |||
| 83 | const int pushNum = 10; | 83 | const int pushNum = 10; |
| 84 | for (int i = 0; i < pushNum; ++i) { | 84 | for (int i = 0; i < pushNum; ++i) { |
| 85 | EventInfo testInfo{EventType::EVENT_TYPE_API, 0, (uint64_t) i, (uint64_t) (2 * i)}; | 85 | EventInfo testInfo{EventType::EVENT_TYPE_API, 0, (uint64_t) i, (uint64_t) (2 * i)}; |
| 86 | - auto eventPtr = std::make_shared<Event>(std::shared_ptr<MsprofApi>{}, | 86 | + auto eventPtr = std::make_shared<Event>(std::shared_ptr<ParserApi>{}, |
| 87 | testInfo); | 87 | testInfo); |
| 88 | eventQueue->Push(eventPtr); | 88 | eventQueue->Push(eventPtr); |
| 89 | } | 89 | } |
| @@ -112,7 +112,7 @@ TEST_F(EventQueueUTest, SortWhenStartEqualOrLevelEqual) | |||
| 112 | /* 测试Sort函数 start不同 Level相同时 排序正确性 */ | 112 | /* 测试Sort函数 start不同 Level相同时 排序正确性 */ |
| 113 | for (int i = pushStartNum; i > 0; --i) { | 113 | for (int i = pushStartNum; i > 0; --i) { |
| 114 | EventInfo testInfo{EventType::EVENT_TYPE_API, 0, (uint64_t) i, (uint64_t) (2 * i)}; | 114 | EventInfo testInfo{EventType::EVENT_TYPE_API, 0, (uint64_t) i, (uint64_t) (2 * i)}; |
| 115 | - auto eventPtr = std::make_shared<Event>(std::shared_ptr<MsprofApi>{}, | 115 | + auto eventPtr = std::make_shared<Event>(std::shared_ptr<ParserApi>{}, |
| 116 | testInfo); | 116 | testInfo); |
| 117 | eventQueue->Push(eventPtr); | 117 | eventQueue->Push(eventPtr); |
| 118 | } | 118 | } |
| @@ -121,7 +121,7 @@ TEST_F(EventQueueUTest, SortWhenStartEqualOrLevelEqual) | |||
| 121 | /* 测试Sort函数 start 相同时按照level排序的正确性 */ | 121 | /* 测试Sort函数 start 相同时按照level排序的正确性 */ |
| 122 | for (int i = 1; i < pushLevelNum; ++i) { | 122 | for (int i = 1; i < pushLevelNum; ++i) { |
| 123 | EventInfo testInfo{EventType::EVENT_TYPE_API, (uint16_t) i, (uint64_t) 1, (uint64_t) 1}; | 123 | EventInfo testInfo{EventType::EVENT_TYPE_API, (uint16_t) i, (uint64_t) 1, (uint64_t) 1}; |
| 124 | - auto eventPtr = std::make_shared<Event>(std::shared_ptr<MsprofApi>{}, | 124 | + auto eventPtr = std::make_shared<Event>(std::shared_ptr<ParserApi>{}, |
| 125 | testInfo); | 125 | testInfo); |
| 126 | eventQueue->Push(eventPtr); | 126 | eventQueue->Push(eventPtr); |
| 127 | } | 127 | } |
| @@ -154,7 +154,7 @@ TEST_F(EventQueueUTest, TopShouldTopValueSmallest) | |||
| 154 | const int pushStartNum = 10; | 154 | const int pushStartNum = 10; |
| 155 | for (int i = 0; i < pushStartNum; ++i) { | 155 | for (int i = 0; i < pushStartNum; ++i) { |
| 156 | EventInfo testInfo{EventType::EVENT_TYPE_API, 0, (uint64_t) i, (uint64_t) (2 * i)}; | 156 | EventInfo testInfo{EventType::EVENT_TYPE_API, 0, (uint64_t) i, (uint64_t) (2 * i)}; |
| 157 | - auto eventPtr = std::make_shared<Event>(std::shared_ptr<MsprofApi>{}, | 157 | + auto eventPtr = std::make_shared<Event>(std::shared_ptr<ParserApi>{}, |
| 158 | testInfo); | 158 | testInfo); |
| 159 | eventQueue->Push(eventPtr); | 159 | eventQueue->Push(eventPtr); |
| 160 | } | 160 | } |
| @@ -37,7 +37,7 @@ protected: | |||
| 37 | TEST_F(TreeUTest, GetRootNullptrAndNotNullptr) | 37 | TEST_F(TreeUTest, GetRootNullptrAndNotNullptr) |
| 38 | { | 38 | { |
| 39 | EventInfo testInfo{EventType::EVENT_TYPE_API, 0, 0, 0}; | 39 | EventInfo testInfo{EventType::EVENT_TYPE_API, 0, 0, 0}; |
| 40 | - auto eventPtr = std::make_shared<Event>(std::shared_ptr<MsprofApi>{}, | 40 | + auto eventPtr = std::make_shared<Event>(std::shared_ptr<ParserApi>{}, |
| 41 | testInfo); | 41 | testInfo); |
| 42 | auto treeNode = std::make_shared<TreeNode>(eventPtr); | 42 | auto treeNode = std::make_shared<TreeNode>(eventPtr); |
| 43 | 43 | ||
| @@ -133,7 +133,7 @@ protected: | |||
| 133 | fakeGen->WriteBin<MsprofAdditionalInfo>(agingTraces, EventType::EVENT_TYPE_TENSOR_INFO, true); | 133 | fakeGen->WriteBin<MsprofAdditionalInfo>(agingTraces, EventType::EVENT_TYPE_TENSOR_INFO, true); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | - static void Check(const std::vector<std::shared_ptr<MsprofAdditionalInfo>> &data, | 136 | + static void Check(const std::vector<std::shared_ptr<ParserAdditionalInfo>> &data, |
| 137 | EventType type, uint16_t level, uint16_t dataNum) | 137 | EventType type, uint16_t level, uint16_t dataNum) |
| 138 | { | 138 | { |
| 139 | ASSERT_EQ(dataNum, data.size()); | 139 | ASSERT_EQ(dataNum, data.size()); |
| @@ -152,17 +152,17 @@ protected: | |||
| 152 | TEST_F(AdditionInfoParserUTest, TestCtxIdParserShouldReturn30DataWhenParseSuccess) | 152 | TEST_F(AdditionInfoParserUTest, TestCtxIdParserShouldReturn30DataWhenParseSuccess) |
| 153 | { | 153 | { |
| 154 | auto parser = std::make_shared<CtxIdParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 154 | auto parser = std::make_shared<CtxIdParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 155 | - auto data = parser->ParseData<MsprofAdditionalInfo>(); | 155 | + auto data = parser->ParseData<ParserAdditionalInfo>(); |
| 156 | Check(data, EventType::EVENT_TYPE_CONTEXT_ID, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); | 156 | Check(data, EventType::EVENT_TYPE_CONTEXT_ID, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | TEST_F(AdditionInfoParserUTest, TestAdditionInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) | 159 | TEST_F(AdditionInfoParserUTest, TestAdditionInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) |
| 160 | { | 160 | { |
| 161 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofAdditionalInfo>>).stubs().will(returnValue(false)); | 161 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserAdditionalInfo>>).stubs().will(returnValue(false)); |
| 162 | auto parser = std::make_shared<CtxIdParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 162 | auto parser = std::make_shared<CtxIdParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 163 | - auto data = parser->ParseData<MsprofAdditionalInfo>(); | 163 | + auto data = parser->ParseData<ParserAdditionalInfo>(); |
| 164 | EXPECT_EQ(0, data.size()); | 164 | EXPECT_EQ(0, data.size()); |
| 165 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofAdditionalInfo>>).reset(); | 165 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserAdditionalInfo>>).reset(); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | TEST_F(AdditionInfoParserUTest, TestAdditionInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) | 168 | TEST_F(AdditionInfoParserUTest, TestAdditionInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) |
| @@ -170,7 +170,7 @@ TEST_F(AdditionInfoParserUTest, TestAdditionInfoParserProduceDataShouldReturnEmp | |||
| 170 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() | 170 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() |
| 171 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); | 171 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); |
| 172 | auto parser = std::make_shared<CtxIdParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 172 | auto parser = std::make_shared<CtxIdParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 173 | - auto data = parser->ParseData<MsprofAdditionalInfo>(); | 173 | + auto data = parser->ParseData<ParserAdditionalInfo>(); |
| 174 | EXPECT_EQ(0, data.size()); | 174 | EXPECT_EQ(0, data.size()); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| @@ -179,35 +179,35 @@ TEST_F(AdditionInfoParserUTest, TestAdditionInfoParserProduceDataShouldReturn29D | |||
| 179 | const uint16_t invalidDataNum = 1; | 179 | const uint16_t invalidDataNum = 1; |
| 180 | GenAdditionalInfoData(EventType::EVENT_TYPE_CONTEXT_ID, MSPROF_REPORT_NODE_LEVEL, invalidDataNum); | 180 | GenAdditionalInfoData(EventType::EVENT_TYPE_CONTEXT_ID, MSPROF_REPORT_NODE_LEVEL, invalidDataNum); |
| 181 | auto parser = std::make_shared<CtxIdParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 181 | auto parser = std::make_shared<CtxIdParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 182 | - auto data = parser->ParseData<MsprofAdditionalInfo>(); | 182 | + auto data = parser->ParseData<ParserAdditionalInfo>(); |
| 183 | Check(data, EventType::EVENT_TYPE_CONTEXT_ID, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); | 183 | Check(data, EventType::EVENT_TYPE_CONTEXT_ID, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | TEST_F(AdditionInfoParserUTest, TestFusionOpInfoParserShouldReturn30DataWhenParseSuccess) | 186 | TEST_F(AdditionInfoParserUTest, TestFusionOpInfoParserShouldReturn30DataWhenParseSuccess) |
| 187 | { | 187 | { |
| 188 | auto parser = std::make_shared<FusionOpInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 188 | auto parser = std::make_shared<FusionOpInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 189 | - auto data = parser->ParseData<MsprofAdditionalInfo>(); | 189 | + auto data = parser->ParseData<ParserAdditionalInfo>(); |
| 190 | Check(data, EventType::EVENT_TYPE_FUSION_OP_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); | 190 | Check(data, EventType::EVENT_TYPE_FUSION_OP_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | TEST_F(AdditionInfoParserUTest, TestGraphIdParserShouldReturn30DataWhenParseSuccess) | 193 | TEST_F(AdditionInfoParserUTest, TestGraphIdParserShouldReturn30DataWhenParseSuccess) |
| 194 | { | 194 | { |
| 195 | auto parser = std::make_shared<GraphIdParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 195 | auto parser = std::make_shared<GraphIdParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 196 | - auto data = parser->ParseData<MsprofAdditionalInfo>(); | 196 | + auto data = parser->ParseData<ParserAdditionalInfo>(); |
| 197 | Check(data, EventType::EVENT_TYPE_GRAPH_ID_MAP, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); | 197 | Check(data, EventType::EVENT_TYPE_GRAPH_ID_MAP, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | TEST_F(AdditionInfoParserUTest, TestHcclInfoParserShouldReturn30DataWhenParseSuccess) | 200 | TEST_F(AdditionInfoParserUTest, TestHcclInfoParserShouldReturn30DataWhenParseSuccess) |
| 201 | { | 201 | { |
| 202 | auto parser = std::make_shared<HcclInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 202 | auto parser = std::make_shared<HcclInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 203 | - auto data = parser->ParseData<MsprofAdditionalInfo>(); | 203 | + auto data = parser->ParseData<ParserAdditionalInfo>(); |
| 204 | Check(data, EventType::EVENT_TYPE_HCCL_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); | 204 | Check(data, EventType::EVENT_TYPE_HCCL_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | TEST_F(AdditionInfoParserUTest, TestTensorInfoParserShouldReturn6000ConcatTensorInfoDataWhenParseSuccess) | 207 | TEST_F(AdditionInfoParserUTest, TestTensorInfoParserShouldReturn6000ConcatTensorInfoDataWhenParseSuccess) |
| 208 | { | 208 | { |
| 209 | auto parser = std::make_shared<TensorInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 209 | auto parser = std::make_shared<TensorInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 210 | - auto concatTensorInfo = parser->ParseData<ConcatTensorInfo>(); | 210 | + auto concatTensorInfo = parser->ParseData<ParserConcatTensorInfo>(); |
| 211 | const uint32_t dataLen = 8; | 211 | const uint32_t dataLen = 8; |
| 212 | const uint32_t dataNum = TENSOR_DATA_NUM / TENSOR_NUM_TO_CONCAT; | 212 | const uint32_t dataNum = TENSOR_DATA_NUM / TENSOR_NUM_TO_CONCAT; |
| 213 | ASSERT_EQ(dataNum, concatTensorInfo.size()); | 213 | ASSERT_EQ(dataNum, concatTensorInfo.size()); |
| @@ -222,11 +222,11 @@ TEST_F(AdditionInfoParserUTest, TestTensorInfoParserShouldReturn6000ConcatTensor | |||
| 222 | 222 | ||
| 223 | TEST_F(AdditionInfoParserUTest, TestTensorInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) | 223 | TEST_F(AdditionInfoParserUTest, TestTensorInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) |
| 224 | { | 224 | { |
| 225 | - MOCKER_CPP(&Reserve<std::shared_ptr<ConcatTensorInfo>>).stubs().will(returnValue(false)); | 225 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserConcatTensorInfo>>).stubs().will(returnValue(false)); |
| 226 | auto parser = std::make_shared<TensorInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 226 | auto parser = std::make_shared<TensorInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 227 | - auto data = parser->ParseData<ConcatTensorInfo>(); | 227 | + auto data = parser->ParseData<ParserConcatTensorInfo>(); |
| 228 | EXPECT_EQ(0, data.size()); | 228 | EXPECT_EQ(0, data.size()); |
| 229 | - MOCKER_CPP(&Reserve<std::shared_ptr<ConcatTensorInfo>>).reset(); | 229 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserConcatTensorInfo>>).reset(); |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | TEST_F(AdditionInfoParserUTest, TestTensorInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) | 232 | TEST_F(AdditionInfoParserUTest, TestTensorInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) |
| @@ -234,7 +234,7 @@ TEST_F(AdditionInfoParserUTest, TestTensorInfoParserProduceDataShouldReturnEmpty | |||
| 234 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() | 234 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() |
| 235 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); | 235 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); |
| 236 | auto parser = std::make_shared<TensorInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 236 | auto parser = std::make_shared<TensorInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 237 | - auto data = parser->ParseData<ConcatTensorInfo>(); | 237 | + auto data = parser->ParseData<ParserConcatTensorInfo>(); |
| 238 | EXPECT_EQ(0, data.size()); | 238 | EXPECT_EQ(0, data.size()); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| @@ -242,7 +242,7 @@ TEST_F(AdditionInfoParserUTest, TestTensorInfoParserProduceDataShouldReturn6000D | |||
| 242 | { | 242 | { |
| 243 | GenTensorData(MSPROF_REPORT_NODE_LEVEL, TENSOR_NUM_TO_CONCAT, 1); | 243 | GenTensorData(MSPROF_REPORT_NODE_LEVEL, TENSOR_NUM_TO_CONCAT, 1); |
| 244 | auto parser = std::make_shared<TensorInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 244 | auto parser = std::make_shared<TensorInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 245 | - auto data = parser->ParseData<ConcatTensorInfo>(); | 245 | + auto data = parser->ParseData<ParserConcatTensorInfo>(); |
| 246 | const uint32_t dataLen = 8; | 246 | const uint32_t dataLen = 8; |
| 247 | const uint32_t dataNum = TENSOR_DATA_NUM / TENSOR_NUM_TO_CONCAT; | 247 | const uint32_t dataNum = TENSOR_DATA_NUM / TENSOR_NUM_TO_CONCAT; |
| 248 | ASSERT_EQ(dataNum, data.size()); | 248 | ASSERT_EQ(dataNum, data.size()); |
| @@ -260,7 +260,7 @@ TEST_F(AdditionInfoParserUTest, TestTensorInfoParserProduceDataShouldReturn3600D | |||
| 260 | uint32_t geTensorNum = 3; | 260 | uint32_t geTensorNum = 3; |
| 261 | GenTensorData(MSPROF_REPORT_NODE_LEVEL, concatTensorNum, 0, geTensorNum); | 261 | GenTensorData(MSPROF_REPORT_NODE_LEVEL, concatTensorNum, 0, geTensorNum); |
| 262 | auto parser = std::make_shared<TensorInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 262 | auto parser = std::make_shared<TensorInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 263 | - auto data = parser->ParseData<ConcatTensorInfo>(); | 263 | + auto data = parser->ParseData<ParserConcatTensorInfo>(); |
| 264 | const uint32_t dataLen = 8; | 264 | const uint32_t dataLen = 8; |
| 265 | const uint16_t dataNum = TENSOR_DATA_NUM / concatTensorNum; | 265 | const uint16_t dataNum = TENSOR_DATA_NUM / concatTensorNum; |
| 266 | ASSERT_EQ(dataNum, data.size()); | 266 | ASSERT_EQ(dataNum, data.size()); |
| @@ -97,7 +97,7 @@ protected: | |||
| 97 | fakeGen->WriteBin<MsprofEvent>(agingTraces, EventType::EVENT_TYPE_EVENT, true); | 97 | fakeGen->WriteBin<MsprofEvent>(agingTraces, EventType::EVENT_TYPE_EVENT, true); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | - static void Check(const std::vector<std::shared_ptr<MsprofApi>> &data, uint16_t dataNum) | 100 | + static void Check(const std::vector<std::shared_ptr<ParserApi>> &data, uint16_t dataNum) |
| 101 | { | 101 | { |
| 102 | ASSERT_EQ(dataNum, data.size()); | 102 | ASSERT_EQ(dataNum, data.size()); |
| 103 | const uint16_t level = MSPROF_REPORT_NODE_LEVEL; | 103 | const uint16_t level = MSPROF_REPORT_NODE_LEVEL; |
| @@ -125,8 +125,8 @@ protected: | |||
| 125 | TEST_F(ApiEventParserUTest, TestProduceDataShouldReturn27ApiDataAnd0EventDataWhenParseSuccess) | 125 | TEST_F(ApiEventParserUTest, TestProduceDataShouldReturn27ApiDataAnd0EventDataWhenParseSuccess) |
| 126 | { | 126 | { |
| 127 | auto parser = std::make_shared<ApiEventParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 127 | auto parser = std::make_shared<ApiEventParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 128 | - auto apiData = parser->ParseData<MsprofApi>(); | 128 | + auto apiData = parser->ParseData<ParserApi>(); |
| 129 | - auto eventData = parser->ParseData<MsprofEvent>(); | 129 | + auto eventData = parser->ParseData<ParserEvent>(); |
| 130 | const uint16_t apiDataNum = API_DATA_NUM + EVENT_DATA_NUM / 2; // 2个event数据合成一个api数据 | 130 | const uint16_t apiDataNum = API_DATA_NUM + EVENT_DATA_NUM / 2; // 2个event数据合成一个api数据 |
| 131 | Check(apiData, apiDataNum); | 131 | Check(apiData, apiDataNum); |
| 132 | EXPECT_EQ(0, eventData.size()); | 132 | EXPECT_EQ(0, eventData.size()); |
| @@ -134,11 +134,11 @@ TEST_F(ApiEventParserUTest, TestProduceDataShouldReturn27ApiDataAnd0EventDataWhe | |||
| 134 | 134 | ||
| 135 | TEST_F(ApiEventParserUTest, TestProduceDataShouldReturnEmptyWhenReserveFailed) | 135 | TEST_F(ApiEventParserUTest, TestProduceDataShouldReturnEmptyWhenReserveFailed) |
| 136 | { | 136 | { |
| 137 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofApi>>).stubs().will(returnValue(false)); | 137 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserApi>>).stubs().will(returnValue(false)); |
| 138 | auto parser = std::make_shared<ApiEventParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 138 | auto parser = std::make_shared<ApiEventParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 139 | - auto data = parser->ParseData<MsprofApi>(); | 139 | + auto data = parser->ParseData<ParserApi>(); |
| 140 | EXPECT_EQ(0, data.size()); | 140 | EXPECT_EQ(0, data.size()); |
| 141 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofApi>>).reset(); | 141 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserApi>>).reset(); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | TEST_F(ApiEventParserUTest, TestProduceDataShouldReturnEmptyWhenPopNullptr) | 144 | TEST_F(ApiEventParserUTest, TestProduceDataShouldReturnEmptyWhenPopNullptr) |
| @@ -146,6 +146,6 @@ TEST_F(ApiEventParserUTest, TestProduceDataShouldReturnEmptyWhenPopNullptr) | |||
| 146 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() | 146 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() |
| 147 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); | 147 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); |
| 148 | auto parser = std::make_shared<ApiEventParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 148 | auto parser = std::make_shared<ApiEventParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 149 | - auto data = parser->ParseData<MsprofApi>(); | 149 | + auto data = parser->ParseData<ParserApi>(); |
| 150 | EXPECT_EQ(0, data.size()); | 150 | EXPECT_EQ(0, data.size()); |
| 151 | } | 151 | } |
| @@ -104,7 +104,7 @@ protected: | |||
| 104 | fakeGen->WriteBin<MsprofCompactInfo>(agingTraces, type, true); | 104 | fakeGen->WriteBin<MsprofCompactInfo>(agingTraces, type, true); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | - static void Check(const std::vector<std::shared_ptr<MsprofCompactInfo>> &data, | 107 | + static void Check(const std::vector<std::shared_ptr<ParserCompactInfo>> &data, |
| 108 | EventType type, uint16_t level, uint16_t dataNum) | 108 | EventType type, uint16_t level, uint16_t dataNum) |
| 109 | { | 109 | { |
| 110 | ASSERT_EQ(dataNum, data.size()); | 110 | ASSERT_EQ(dataNum, data.size()); |
| @@ -123,17 +123,17 @@ protected: | |||
| 123 | TEST_F(CompactInfoParserUTest, TestMemcpyInfoParserShouldReturn10DataWhenParseSuccess) | 123 | TEST_F(CompactInfoParserUTest, TestMemcpyInfoParserShouldReturn10DataWhenParseSuccess) |
| 124 | { | 124 | { |
| 125 | auto parser = std::make_shared<MemcpyInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 125 | auto parser = std::make_shared<MemcpyInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 126 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 126 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 127 | Check(data, EventType::EVENT_TYPE_MEM_CPY, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); | 127 | Check(data, EventType::EVENT_TYPE_MEM_CPY, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | TEST_F(CompactInfoParserUTest, TestCompactInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) | 130 | TEST_F(CompactInfoParserUTest, TestCompactInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) |
| 131 | { | 131 | { |
| 132 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofCompactInfo>>).stubs().will(returnValue(false)); | 132 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserCompactInfo>>).stubs().will(returnValue(false)); |
| 133 | auto parser = std::make_shared<MemcpyInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 133 | auto parser = std::make_shared<MemcpyInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 134 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 134 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 135 | EXPECT_EQ(0, data.size()); | 135 | EXPECT_EQ(0, data.size()); |
| 136 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofCompactInfo>>).reset(); | 136 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserCompactInfo>>).reset(); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | TEST_F(CompactInfoParserUTest, TestCompactInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) | 139 | TEST_F(CompactInfoParserUTest, TestCompactInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) |
| @@ -141,7 +141,7 @@ TEST_F(CompactInfoParserUTest, TestCompactInfoParserProduceDataShouldReturnEmpty | |||
| 141 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() | 141 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() |
| 142 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); | 142 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); |
| 143 | auto parser = std::make_shared<MemcpyInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 143 | auto parser = std::make_shared<MemcpyInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 144 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 144 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 145 | EXPECT_EQ(0, data.size()); | 145 | EXPECT_EQ(0, data.size()); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| @@ -150,7 +150,7 @@ TEST_F(CompactInfoParserUTest, TestCompactInfoParserProduceDataShouldReturn9Data | |||
| 150 | const uint16_t invalidDataNum = 1; | 150 | const uint16_t invalidDataNum = 1; |
| 151 | GenCompactInfoData(EventType::EVENT_TYPE_MEM_CPY, MSPROF_REPORT_NODE_LEVEL, invalidDataNum); | 151 | GenCompactInfoData(EventType::EVENT_TYPE_MEM_CPY, MSPROF_REPORT_NODE_LEVEL, invalidDataNum); |
| 152 | auto parser = std::make_shared<MemcpyInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 152 | auto parser = std::make_shared<MemcpyInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 153 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 153 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 154 | Check(data, EventType::EVENT_TYPE_MEM_CPY, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); | 154 | Check(data, EventType::EVENT_TYPE_MEM_CPY, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| @@ -159,14 +159,14 @@ TEST_F(CompactInfoParserUTest, TestCompactInfoParserProduceDataShouldReturnEmpty | |||
| 159 | MOCKER_CPP(&FileReader::ReadBinary) | 159 | MOCKER_CPP(&FileReader::ReadBinary) |
| 160 | .stubs().will(returnValue(ANALYSIS_ERROR)); | 160 | .stubs().will(returnValue(ANALYSIS_ERROR)); |
| 161 | auto parser = std::make_shared<MemcpyInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 161 | auto parser = std::make_shared<MemcpyInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 162 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 162 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 163 | EXPECT_EQ(0, data.size()); | 163 | EXPECT_EQ(0, data.size()); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | TEST_F(CompactInfoParserUTest, TestNodeBasicInfoParserProduceDataShouldReturn10DataWhenParseSuccess) | 166 | TEST_F(CompactInfoParserUTest, TestNodeBasicInfoParserProduceDataShouldReturn10DataWhenParseSuccess) |
| 167 | { | 167 | { |
| 168 | auto parser = std::make_shared<NodeBasicInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 168 | auto parser = std::make_shared<NodeBasicInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 169 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 169 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 170 | Check(data, EventType::EVENT_TYPE_NODE_BASIC_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); | 170 | Check(data, EventType::EVENT_TYPE_NODE_BASIC_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); |
| 171 | for (size_t i = 0; i < DATA_NUM; ++i) { | 171 | for (size_t i = 0; i < DATA_NUM; ++i) { |
| 172 | if (i * 2 < DATA_NUM) { // 前1/2的数据是unaging,opState是0;后1/2的数据是aging,opState是1 | 172 | if (i * 2 < DATA_NUM) { // 前1/2的数据是unaging,opState是0;后1/2的数据是aging,opState是1 |
| @@ -179,11 +179,11 @@ TEST_F(CompactInfoParserUTest, TestNodeBasicInfoParserProduceDataShouldReturn10D | |||
| 179 | 179 | ||
| 180 | TEST_F(CompactInfoParserUTest, TestNodeBasicInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) | 180 | TEST_F(CompactInfoParserUTest, TestNodeBasicInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) |
| 181 | { | 181 | { |
| 182 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofCompactInfo>>).stubs().will(returnValue(false)); | 182 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserCompactInfo>>).stubs().will(returnValue(false)); |
| 183 | auto parser = std::make_shared<NodeBasicInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 183 | auto parser = std::make_shared<NodeBasicInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 184 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 184 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 185 | EXPECT_EQ(0, data.size()); | 185 | EXPECT_EQ(0, data.size()); |
| 186 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofCompactInfo>>).reset(); | 186 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserCompactInfo>>).reset(); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | TEST_F(CompactInfoParserUTest, TestNodeBasicInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) | 189 | TEST_F(CompactInfoParserUTest, TestNodeBasicInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) |
| @@ -191,7 +191,7 @@ TEST_F(CompactInfoParserUTest, TestNodeBasicInfoParserProduceDataShouldReturnEmp | |||
| 191 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() | 191 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() |
| 192 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); | 192 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); |
| 193 | auto parser = std::make_shared<NodeBasicInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 193 | auto parser = std::make_shared<NodeBasicInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 194 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 194 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 195 | EXPECT_EQ(0, data.size()); | 195 | EXPECT_EQ(0, data.size()); |
| 196 | } | 196 | } |
| 197 | 197 | ||
| @@ -200,7 +200,7 @@ TEST_F(CompactInfoParserUTest, TestNodeBasicInfoParserProduceDataShouldReturnEmp | |||
| 200 | MOCKER_CPP(&FileReader::ReadBinary) | 200 | MOCKER_CPP(&FileReader::ReadBinary) |
| 201 | .stubs().will(returnValue(ANALYSIS_OK)).then(returnValue(ANALYSIS_ERROR)); | 201 | .stubs().will(returnValue(ANALYSIS_OK)).then(returnValue(ANALYSIS_ERROR)); |
| 202 | auto parser = std::make_shared<NodeBasicInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 202 | auto parser = std::make_shared<NodeBasicInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 203 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 203 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 204 | EXPECT_EQ(0, data.size()); | 204 | EXPECT_EQ(0, data.size()); |
| 205 | } | 205 | } |
| 206 | 206 | ||
| @@ -209,7 +209,7 @@ TEST_F(CompactInfoParserUTest, TestNodeBasicInfoParserProduceDataShouldReturn9Da | |||
| 209 | const uint16_t invalidDataNum = 1; | 209 | const uint16_t invalidDataNum = 1; |
| 210 | GenCompactInfoData(EventType::EVENT_TYPE_NODE_BASIC_INFO, MSPROF_REPORT_NODE_LEVEL, invalidDataNum); | 210 | GenCompactInfoData(EventType::EVENT_TYPE_NODE_BASIC_INFO, MSPROF_REPORT_NODE_LEVEL, invalidDataNum); |
| 211 | auto parser = std::make_shared<NodeBasicInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 211 | auto parser = std::make_shared<NodeBasicInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 212 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 212 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 213 | Check(data, EventType::EVENT_TYPE_NODE_BASIC_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); | 213 | Check(data, EventType::EVENT_TYPE_NODE_BASIC_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| @@ -220,7 +220,7 @@ TEST_F(CompactInfoParserUTest, TestTaskTrackParserProduceDataShouldReturn8Compac | |||
| 220 | const uint16_t flipTaskNum = 1; | 220 | const uint16_t flipTaskNum = 1; |
| 221 | const uint16_t maintenanceTaskNum = 1; | 221 | const uint16_t maintenanceTaskNum = 1; |
| 222 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 222 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 223 | - auto compactInfo = parser->ParseData<MsprofCompactInfo>(); | 223 | + auto compactInfo = parser->ParseData<ParserCompactInfo>(); |
| 224 | auto flipTask = parser->ParseData<Adapter::FlipTask>(); | 224 | auto flipTask = parser->ParseData<Adapter::FlipTask>(); |
| 225 | Check(compactInfo, EventType::EVENT_TYPE_TASK_TRACK, MSPROF_REPORT_NODE_LEVEL, | 225 | Check(compactInfo, EventType::EVENT_TYPE_TASK_TRACK, MSPROF_REPORT_NODE_LEVEL, |
| 226 | DATA_NUM - flipTaskNum - maintenanceTaskNum); | 226 | DATA_NUM - flipTaskNum - maintenanceTaskNum); |
| @@ -229,13 +229,13 @@ TEST_F(CompactInfoParserUTest, TestTaskTrackParserProduceDataShouldReturn8Compac | |||
| 229 | 229 | ||
| 230 | TEST_F(CompactInfoParserUTest, TestTaskTrackParserProduceDataShouldReturnEmptyWhenReserveFailed) | 230 | TEST_F(CompactInfoParserUTest, TestTaskTrackParserProduceDataShouldReturnEmptyWhenReserveFailed) |
| 231 | { | 231 | { |
| 232 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofCompactInfo>>).stubs().will(returnValue(false)); | 232 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserCompactInfo>>).stubs().will(returnValue(false)); |
| 233 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 233 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 234 | - auto compactInfo = parser->ParseData<MsprofCompactInfo>(); | 234 | + auto compactInfo = parser->ParseData<ParserCompactInfo>(); |
| 235 | auto flipTask = parser->ParseData<Adapter::FlipTask>(); | 235 | auto flipTask = parser->ParseData<Adapter::FlipTask>(); |
| 236 | EXPECT_EQ(0, compactInfo.size()); | 236 | EXPECT_EQ(0, compactInfo.size()); |
| 237 | EXPECT_EQ(0, flipTask.size()); | 237 | EXPECT_EQ(0, flipTask.size()); |
| 238 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofCompactInfo>>).reset(); | 238 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserCompactInfo>>).reset(); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | TEST_F(CompactInfoParserUTest, TestTaskTrackParserProduceDataShouldReturnEmptyWhenPopNullptr) | 241 | TEST_F(CompactInfoParserUTest, TestTaskTrackParserProduceDataShouldReturnEmptyWhenPopNullptr) |
| @@ -243,7 +243,7 @@ TEST_F(CompactInfoParserUTest, TestTaskTrackParserProduceDataShouldReturnEmptyWh | |||
| 243 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() | 243 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() |
| 244 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); | 244 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); |
| 245 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 245 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 246 | - auto compactInfo = parser->ParseData<MsprofCompactInfo>(); | 246 | + auto compactInfo = parser->ParseData<ParserCompactInfo>(); |
| 247 | auto flipTask = parser->ParseData<Adapter::FlipTask>(); | 247 | auto flipTask = parser->ParseData<Adapter::FlipTask>(); |
| 248 | EXPECT_EQ(0, compactInfo.size()); | 248 | EXPECT_EQ(0, compactInfo.size()); |
| 249 | EXPECT_EQ(0, flipTask.size()); | 249 | EXPECT_EQ(0, flipTask.size()); |
| @@ -254,7 +254,7 @@ TEST_F(CompactInfoParserUTest, TestTaskTrackParserProduceDataShouldReturnEmptyWh | |||
| 254 | { | 254 | { |
| 255 | MOCKER_CPP(&Adapter::Flip::CreateFlipTask).stubs().will(returnValue(std::shared_ptr<Adapter::FlipTask>{})); | 255 | MOCKER_CPP(&Adapter::Flip::CreateFlipTask).stubs().will(returnValue(std::shared_ptr<Adapter::FlipTask>{})); |
| 256 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 256 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 257 | - auto compactInfo = parser->ParseData<MsprofCompactInfo>(); | 257 | + auto compactInfo = parser->ParseData<ParserCompactInfo>(); |
| 258 | auto flipTask = parser->ParseData<Adapter::FlipTask>(); | 258 | auto flipTask = parser->ParseData<Adapter::FlipTask>(); |
| 259 | EXPECT_EQ(0, compactInfo.size()); | 259 | EXPECT_EQ(0, compactInfo.size()); |
| 260 | EXPECT_EQ(0, flipTask.size()); | 260 | EXPECT_EQ(0, flipTask.size()); |
| @@ -266,24 +266,24 @@ TEST_F(CompactInfoParserUTest, TestTaskTrackParserProduceDataShouldReturn7DataWh | |||
| 266 | const uint16_t invalidDataNum = 3; | 266 | const uint16_t invalidDataNum = 3; |
| 267 | GenCompactInfoData(EventType::EVENT_TYPE_TASK_TRACK, MSPROF_REPORT_NODE_LEVEL, invalidDataNum, true); | 267 | GenCompactInfoData(EventType::EVENT_TYPE_TASK_TRACK, MSPROF_REPORT_NODE_LEVEL, invalidDataNum, true); |
| 268 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 268 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 269 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 269 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 270 | Check(data, EventType::EVENT_TYPE_TASK_TRACK, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); | 270 | Check(data, EventType::EVENT_TYPE_TASK_TRACK, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); |
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | TEST_F(CompactInfoParserUTest, TestNodeAttrInfoParserShouldReturn10DataWhenParseSuccess) | 273 | TEST_F(CompactInfoParserUTest, TestNodeAttrInfoParserShouldReturn10DataWhenParseSuccess) |
| 274 | { | 274 | { |
| 275 | auto parser = std::make_shared<NodeAttrInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 275 | auto parser = std::make_shared<NodeAttrInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 276 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 276 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 277 | Check(data, EventType::EVENT_TYPE_NODE_ATTR_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); | 277 | Check(data, EventType::EVENT_TYPE_NODE_ATTR_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); |
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | TEST_F(CompactInfoParserUTest, TestNodeAttrInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) | 280 | TEST_F(CompactInfoParserUTest, TestNodeAttrInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) |
| 281 | { | 281 | { |
| 282 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofCompactInfo>>).stubs().will(returnValue(false)); | 282 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserCompactInfo>>).stubs().will(returnValue(false)); |
| 283 | auto parser = std::make_shared<NodeAttrInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 283 | auto parser = std::make_shared<NodeAttrInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 284 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 284 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 285 | EXPECT_EQ(0, data.size()); | 285 | EXPECT_EQ(0, data.size()); |
| 286 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofCompactInfo>>).reset(); | 286 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserCompactInfo>>).reset(); |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | TEST_F(CompactInfoParserUTest, TestNodeAttrInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) | 289 | TEST_F(CompactInfoParserUTest, TestNodeAttrInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) |
| @@ -291,7 +291,7 @@ TEST_F(CompactInfoParserUTest, TestNodeAttrInfoParserProduceDataShouldReturnEmpt | |||
| 291 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() | 291 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() |
| 292 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); | 292 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); |
| 293 | auto parser = std::make_shared<NodeAttrInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 293 | auto parser = std::make_shared<NodeAttrInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 294 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 294 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 295 | EXPECT_EQ(0, data.size()); | 295 | EXPECT_EQ(0, data.size()); |
| 296 | } | 296 | } |
| 297 | 297 | ||
| @@ -300,24 +300,24 @@ TEST_F(CompactInfoParserUTest, TestNodeAttrInfoParserProduceDataShouldReturn9Dat | |||
| 300 | const uint16_t invalidDataNum = 1; | 300 | const uint16_t invalidDataNum = 1; |
| 301 | GenCompactInfoData(EventType::EVENT_TYPE_NODE_ATTR_INFO, MSPROF_REPORT_NODE_LEVEL, invalidDataNum); | 301 | GenCompactInfoData(EventType::EVENT_TYPE_NODE_ATTR_INFO, MSPROF_REPORT_NODE_LEVEL, invalidDataNum); |
| 302 | auto parser = std::make_shared<NodeAttrInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 302 | auto parser = std::make_shared<NodeAttrInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 303 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 303 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 304 | Check(data, EventType::EVENT_TYPE_NODE_ATTR_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); | 304 | Check(data, EventType::EVENT_TYPE_NODE_ATTR_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | TEST_F(CompactInfoParserUTest, TestHcclOpInfoParserShouldReturn10DataWhenParseSuccess) | 307 | TEST_F(CompactInfoParserUTest, TestHcclOpInfoParserShouldReturn10DataWhenParseSuccess) |
| 308 | { | 308 | { |
| 309 | auto parser = std::make_shared<HcclOpInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 309 | auto parser = std::make_shared<HcclOpInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 310 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 310 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 311 | Check(data, EventType::EVENT_TYPE_HCCL_OP_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); | 311 | Check(data, EventType::EVENT_TYPE_HCCL_OP_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM); |
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | TEST_F(CompactInfoParserUTest, TestHcclOpInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) | 314 | TEST_F(CompactInfoParserUTest, TestHcclOpInfoParserProduceDataShouldReturnEmptyWhenReserveFailed) |
| 315 | { | 315 | { |
| 316 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofCompactInfo>>).stubs().will(returnValue(false)); | 316 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserCompactInfo>>).stubs().will(returnValue(false)); |
| 317 | auto parser = std::make_shared<HcclOpInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 317 | auto parser = std::make_shared<HcclOpInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 318 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 318 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 319 | EXPECT_EQ(0, data.size()); | 319 | EXPECT_EQ(0, data.size()); |
| 320 | - MOCKER_CPP(&Reserve<std::shared_ptr<MsprofCompactInfo>>).reset(); | 320 | + MOCKER_CPP(&Reserve<std::shared_ptr<ParserCompactInfo>>).reset(); |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | TEST_F(CompactInfoParserUTest, TestHcclOpInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) | 323 | TEST_F(CompactInfoParserUTest, TestHcclOpInfoParserProduceDataShouldReturnEmptyWhenPopNullptr) |
| @@ -325,7 +325,7 @@ TEST_F(CompactInfoParserUTest, TestHcclOpInfoParserProduceDataShouldReturnEmptyW | |||
| 325 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() | 325 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() |
| 326 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); | 326 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); |
| 327 | auto parser = std::make_shared<HcclOpInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 327 | auto parser = std::make_shared<HcclOpInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 328 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 328 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 329 | EXPECT_EQ(0, data.size()); | 329 | EXPECT_EQ(0, data.size()); |
| 330 | } | 330 | } |
| 331 | 331 | ||
| @@ -334,7 +334,7 @@ TEST_F(CompactInfoParserUTest, TestHcclOpInfoParserProduceDataShouldReturn9DataW | |||
| 334 | const uint16_t invalidDataNum = 1; | 334 | const uint16_t invalidDataNum = 1; |
| 335 | GenCompactInfoData(EventType::EVENT_TYPE_HCCL_OP_INFO, MSPROF_REPORT_NODE_LEVEL, invalidDataNum); | 335 | GenCompactInfoData(EventType::EVENT_TYPE_HCCL_OP_INFO, MSPROF_REPORT_NODE_LEVEL, invalidDataNum); |
| 336 | auto parser = std::make_shared<HcclOpInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 336 | auto parser = std::make_shared<HcclOpInfoParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 337 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 337 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 338 | Check(data, EventType::EVENT_TYPE_HCCL_OP_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); | 338 | Check(data, EventType::EVENT_TYPE_HCCL_OP_INFO, MSPROF_REPORT_NODE_LEVEL, DATA_NUM - invalidDataNum); |
| 339 | } | 339 | } |
| 340 | 340 | ||
| @@ -380,7 +380,7 @@ TEST_F(CompactInfoParserUTest, TestDpuTaskTrackParserShouldReturn10DataWhenParse | |||
| 380 | { | 380 | { |
| 381 | GenDpuTrackData(); | 381 | GenDpuTrackData(); |
| 382 | auto parser = std::make_shared<DpuTaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 382 | auto parser = std::make_shared<DpuTaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 383 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 383 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 384 | EXPECT_EQ(data.size(), DATA_NUM); | 384 | EXPECT_EQ(data.size(), DATA_NUM); |
| 385 | for (uint32_t i = 0; i < data.size(); ++i) { | 385 | for (uint32_t i = 0; i < data.size(); ++i) { |
| 386 | EXPECT_EQ(data[i]->data.dpuTrack.deviceId, i); | 386 | EXPECT_EQ(data[i]->data.dpuTrack.deviceId, i); |
| @@ -395,7 +395,7 @@ TEST_F(CompactInfoParserUTest, TestDpuTaskTrackParserProduceDataShouldReturnEmpt | |||
| 395 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() | 395 | MOCKER_CPP(&ChunkGenerator::Pop).stubs() |
| 396 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); | 396 | .will(returnValue(static_cast<CHAR_PTR>(nullptr))); |
| 397 | auto parser = std::make_shared<DpuTaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 397 | auto parser = std::make_shared<DpuTaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 398 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 398 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 399 | EXPECT_EQ(0, data.size()); | 399 | EXPECT_EQ(0, data.size()); |
| 400 | } | 400 | } |
| 401 | 401 | ||
| @@ -404,7 +404,7 @@ TEST_F(CompactInfoParserUTest, TestDpuTaskTrackParserProduceDataShouldReturn8Dat | |||
| 404 | const uint16_t invalidDataNum = 2; | 404 | const uint16_t invalidDataNum = 2; |
| 405 | GenDpuTrackData(DATA_NUM, invalidDataNum); | 405 | GenDpuTrackData(DATA_NUM, invalidDataNum); |
| 406 | auto parser = std::make_shared<DpuTaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 406 | auto parser = std::make_shared<DpuTaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 407 | - auto data = parser->ParseData<MsprofCompactInfo>(); | 407 | + auto data = parser->ParseData<ParserCompactInfo>(); |
| 408 | EXPECT_EQ(data.size(), DATA_NUM - invalidDataNum); | 408 | EXPECT_EQ(data.size(), DATA_NUM - invalidDataNum); |
| 409 | } | 409 | } |
| 410 | 410 | ||
| @@ -457,7 +457,7 @@ TEST_F(CompactInfoParserUTest, TestTaskTrackParserShouldCollectDpuKernelNamesWhe | |||
| 457 | const std::vector<uint64_t> dpuKernelNames = {0xABCD, 0x1234}; | 457 | const std::vector<uint64_t> dpuKernelNames = {0xABCD, 0x1234}; |
| 458 | GenTaskTrackWithDPUData(dpuIndices, dpuKernelNames, totalData); | 458 | GenTaskTrackWithDPUData(dpuIndices, dpuKernelNames, totalData); |
| 459 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 459 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 460 | - auto compactData = parser->ParseData<MsprofCompactInfo>(); | 460 | + auto compactData = parser->ParseData<ParserCompactInfo>(); |
| 461 | auto &kernelMap = parser->GetDpuKernelNameMap(); | 461 | auto &kernelMap = parser->GetDpuKernelNameMap(); |
| 462 | EXPECT_EQ(compactData.size(), totalData - dpuIndices.size()); | 462 | EXPECT_EQ(compactData.size(), totalData - dpuIndices.size()); |
| 463 | EXPECT_EQ(kernelMap.size(), dpuIndices.size()); | 463 | EXPECT_EQ(kernelMap.size(), dpuIndices.size()); |
| @@ -482,7 +482,7 @@ TEST_F(CompactInfoParserUTest, TestTaskTrackParserDpuKernelNameMapShouldBeEmptyW | |||
| 482 | const std::vector<uint64_t> dpuKernelNames = {}; | 482 | const std::vector<uint64_t> dpuKernelNames = {}; |
| 483 | GenTaskTrackWithDPUData(dpuIndices, dpuKernelNames, totalData); | 483 | GenTaskTrackWithDPUData(dpuIndices, dpuKernelNames, totalData); |
| 484 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); | 484 | auto parser = std::make_shared<TaskTrackParser>(File::PathJoin(std::vector<std::string>{DATA_DIR, "host", "data"})); |
| 485 | - auto compactData = parser->ParseData<MsprofCompactInfo>(); | 485 | + auto compactData = parser->ParseData<ParserCompactInfo>(); |
| 486 | auto &kernelMap = parser->GetDpuKernelNameMap(); | 486 | auto &kernelMap = parser->GetDpuKernelNameMap(); |
| 487 | EXPECT_EQ(compactData.size(), totalData); | 487 | EXPECT_EQ(compactData.size(), totalData); |
| 488 | EXPECT_TRUE(kernelMap.empty()); | 488 | EXPECT_TRUE(kernelMap.empty()); |
| @@ -27,7 +27,7 @@ | |||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 30 | +#include "analysis/csrc/infrastructure/utils/prof_struct.h" |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | 33 | ||
| @@ -41,14 +41,14 @@ protected: | |||
| 41 | return data; | 41 | return data; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | - static void SetTaskTrack(std::shared_ptr<MsprofCompactInfo> &taskTrack, | 44 | + static void SetTaskTrack(std::shared_ptr<ParserCompactInfo> &taskTrack, |
| 45 | - const uint64_t &timeStamp, const MsprofRuntimeTrackV2 &runtimeTrack) | 45 | + const uint64_t &timeStamp, const ParserRuntimeTrack &runtimeTrack) |
| 46 | { | 46 | { |
| 47 | taskTrack->timeStamp = timeStamp; | 47 | taskTrack->timeStamp = timeStamp; |
| 48 | - taskTrack->data.runtimeTrackV2 = runtimeTrack; | 48 | + taskTrack->data.runtimeTrack = runtimeTrack; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | - static void CheckBatchId(const std::vector<std::shared_ptr<MsprofCompactInfo>> &taskTrack, uint16_t dataNum, | 51 | + static void CheckBatchId(const std::vector<std::shared_ptr<ParserCompactInfo>> &taskTrack, uint16_t dataNum, |
| 52 | const std::vector<uint16_t> &batchIds) | 52 | const std::vector<uint16_t> &batchIds) |
| 53 | { | 53 | { |
| 54 | ASSERT_EQ(dataNum, taskTrack.size()); | 54 | ASSERT_EQ(dataNum, taskTrack.size()); |
| @@ -61,7 +61,7 @@ protected: | |||
| 61 | 61 | ||
| 62 | TEST_F(FlipUTest, TestComputeBatchIdShouldReturnEmptyWhenTaskTrackIsEmpty) | 62 | TEST_F(FlipUTest, TestComputeBatchIdShouldReturnEmptyWhenTaskTrackIsEmpty) |
| 63 | { | 63 | { |
| 64 | - std::vector<std::shared_ptr<MsprofCompactInfo>> taskTrack {}; | 64 | + std::vector<std::shared_ptr<ParserCompactInfo>> taskTrack {}; |
| 65 | std::vector<std::shared_ptr<FlipTask>> flipTask {}; | 65 | std::vector<std::shared_ptr<FlipTask>> flipTask {}; |
| 66 | Flip::ComputeBatchId(taskTrack, flipTask); | 66 | Flip::ComputeBatchId(taskTrack, flipTask); |
| 67 | EXPECT_EQ(0, taskTrack.size()); | 67 | EXPECT_EQ(0, taskTrack.size()); |
| @@ -70,10 +70,10 @@ TEST_F(FlipUTest, TestComputeBatchIdShouldReturnEmptyWhenTaskTrackIsEmpty) | |||
| 70 | TEST_F(FlipUTest, TestComputeBatchIdShoulSetBatchId0WhenFlipDataIsEmpty) | 70 | TEST_F(FlipUTest, TestComputeBatchIdShoulSetBatchId0WhenFlipDataIsEmpty) |
| 71 | { | 71 | { |
| 72 | const uint16_t dataNum = 2; | 72 | const uint16_t dataNum = 2; |
| 73 | - auto taskTrack = CreateData<MsprofCompactInfo>(dataNum); | 73 | + auto taskTrack = CreateData<ParserCompactInfo>(dataNum); |
| 74 | - // runtimeTrackV2: deviceId, rsv, streamId, (batchId, taskId), taskType | 74 | + // runtimeTrack: deviceId, streamId, (batchId, taskId), taskType |
| 75 | - taskTrack[0]->data.runtimeTrackV2 = {0, {0, 0}, 1, 0x00010001, 1}; | 75 | + taskTrack[0]->data.runtimeTrack = {0,1, 0x00010001, 1}; |
| 76 | - taskTrack[1]->data.runtimeTrackV2 = {0, {0, 0}, 1, 0x00010002, 1}; | 76 | + taskTrack[1]->data.runtimeTrack = {0,1, 0x00010002, 1}; |
| 77 | std::vector<std::shared_ptr<FlipTask>> flipTask {}; | 77 | std::vector<std::shared_ptr<FlipTask>> flipTask {}; |
| 78 | Flip::ComputeBatchId(taskTrack, flipTask); | 78 | Flip::ComputeBatchId(taskTrack, flipTask); |
| 79 | ASSERT_EQ(dataNum, taskTrack.size()); | 79 | ASSERT_EQ(dataNum, taskTrack.size()); |
| @@ -85,25 +85,25 @@ TEST_F(FlipUTest, TestComputeBatchIdShouldSetBatchIdWithEachStreamWhenFlipSepTas | |||
| 85 | { | 85 | { |
| 86 | const uint32_t compactInfoDataNum = 10; | 86 | const uint32_t compactInfoDataNum = 10; |
| 87 | const uint32_t flipDataNum = 4; | 87 | const uint32_t flipDataNum = 4; |
| 88 | - auto taskTrack = CreateData<MsprofCompactInfo>(compactInfoDataNum); | 88 | + auto taskTrack = CreateData<ParserCompactInfo>(compactInfoDataNum); |
| 89 | auto flipData = CreateData<FlipTask>(flipDataNum); | 89 | auto flipData = CreateData<FlipTask>(flipDataNum); |
| 90 | - // runtimeTrackV2: deviceId, rsv, streamId, (batchId, taskId), taskType | 90 | + // runtimeTrack: deviceId, streamId, (batchId, taskId), taskType |
| 91 | // deviceId 0, streamId 1 | 91 | // deviceId 0, streamId 1 |
| 92 | - SetTaskTrack(taskTrack[0], 111111, {0, {0, 0}, 1, 0x00000001, 1}); // 第0个数据,timeStamp=111111 | 92 | + SetTaskTrack(taskTrack[0], 111111, {0,1, 0x00000001, 1}); // 第0个数据,timeStamp=111111 |
| 93 | - SetTaskTrack(taskTrack[1], 111112, {0, {0, 0}, 1, 0x00000002, 1}); // 第1个数据,timeStamp=111112 | 93 | + SetTaskTrack(taskTrack[1], 111112, {0,1, 0x00000002, 1}); // 第1个数据,timeStamp=111112 |
| 94 | - SetTaskTrack(taskTrack[2], 111116, {0, {0, 0}, 1, 0x0000FFFE, 1}); // 第2个数据,timeStamp=111116 | 94 | + SetTaskTrack(taskTrack[2], 111116, {0,1, 0x0000FFFE, 1}); // 第2个数据,timeStamp=111116 |
| 95 | *flipData[0] = {0, 1, 0, 1, 111118}; // 第0个flip | 95 | *flipData[0] = {0, 1, 0, 1, 111118}; // 第0个flip |
| 96 | - SetTaskTrack(taskTrack[3], 111120, {0, {0, 0}, 1, 0x00000001, 1}); // 第3个数据,timeStamp=111120 | 96 | + SetTaskTrack(taskTrack[3], 111120, {0,1, 0x00000001, 1}); // 第3个数据,timeStamp=111120 |
| 97 | - SetTaskTrack(taskTrack[4], 111130, {0, {0, 0}, 1, 0x00000002, 1}); // 第4个数据,timeStamp=111130 | 97 | + SetTaskTrack(taskTrack[4], 111130, {0,1, 0x00000002, 1}); // 第4个数据,timeStamp=111130 |
| 98 | *flipData[1] = {0, 1, 3, 65535, 111140}; // stream destroy, 第1个flip | 98 | *flipData[1] = {0, 1, 3, 65535, 111140}; // stream destroy, 第1个flip |
| 99 | // deviceId 0, streamId 2 | 99 | // deviceId 0, streamId 2 |
| 100 | - SetTaskTrack(taskTrack[5], 111130, {0, {0, 0}, 2, 0x00000001, 1}); // 第5个数据,timeStamp=111130 | 100 | + SetTaskTrack(taskTrack[5], 111130, {0,2, 0x00000001, 1}); // 第5个数据,timeStamp=111130 |
| 101 | - SetTaskTrack(taskTrack[6], 111131, {0, {0, 0}, 2, 0x0000FFFE, 1}); // 第6个数据,timeStamp=111131 | 101 | + SetTaskTrack(taskTrack[6], 111131, {0,2, 0x0000FFFE, 1}); // 第6个数据,timeStamp=111131 |
| 102 | *flipData[2] = {0, 2, 0, 1, 111132}; // 第2个flip | 102 | *flipData[2] = {0, 2, 0, 1, 111132}; // 第2个flip |
| 103 | - SetTaskTrack(taskTrack[7], 111140, {0, {0, 0}, 2, 0x00000001, 1}); // 第7个数据,timeStamp=111140 | 103 | + SetTaskTrack(taskTrack[7], 111140, {0,2, 0x00000001, 1}); // 第7个数据,timeStamp=111140 |
| 104 | *flipData[3] = {0, 2, 3, 65535, 111141}; // stream destroy, 第3个flip | 104 | *flipData[3] = {0, 2, 3, 65535, 111141}; // stream destroy, 第3个flip |
| 105 | - SetTaskTrack(taskTrack[8], 111150, {0, {0, 0}, 2, 0x00000001, 1}); // 第8个数据,timeStamp=111150 | 105 | + SetTaskTrack(taskTrack[8], 111150, {0,2, 0x00000001, 1}); // 第8个数据,timeStamp=111150 |
| 106 | - SetTaskTrack(taskTrack[9], 111160, {0, {0, 0}, 2, 0x00000002, 1}); // 第9个数据,timeStamp=111160 | 106 | + SetTaskTrack(taskTrack[9], 111160, {0,2, 0x00000002, 1}); // 第9个数据,timeStamp=111160 |
| 107 | 107 | ||
| 108 | Flip::ComputeBatchId(taskTrack, flipData); | 108 | Flip::ComputeBatchId(taskTrack, flipData); |
| 109 | CheckBatchId(taskTrack, compactInfoDataNum, | 109 | CheckBatchId(taskTrack, compactInfoDataNum, |
| @@ -115,26 +115,26 @@ TEST_F(FlipUTest, TestComputeBatchIdShoulSetBatchIdWhenFlipTaskIdIsNot0) | |||
| 115 | { | 115 | { |
| 116 | const uint32_t compactInfoDataNum = 12; | 116 | const uint32_t compactInfoDataNum = 12; |
| 117 | const uint32_t flipDataNum = 3; | 117 | const uint32_t flipDataNum = 3; |
| 118 | - auto taskTrack = CreateData<MsprofCompactInfo>(compactInfoDataNum); | 118 | + auto taskTrack = CreateData<ParserCompactInfo>(compactInfoDataNum); |
| 119 | auto flipData = CreateData<FlipTask>(flipDataNum); | 119 | auto flipData = CreateData<FlipTask>(flipDataNum); |
| 120 | // deviceId 0, streamId 1 | 120 | // deviceId 0, streamId 1 |
| 121 | - SetTaskTrack(taskTrack[0], 111111, {0, {0, 0}, 1, 0x00000001, 1}); // 第0个数据,timeStamp=111111 | 121 | + SetTaskTrack(taskTrack[0], 111111, {0,1, 0x00000001, 1}); // 第0个数据,timeStamp=111111 |
| 122 | - SetTaskTrack(taskTrack[1], 111112, {0, {0, 0}, 1, 0x00000002, 1}); // 第1个数据,timeStamp=111112 | 122 | + SetTaskTrack(taskTrack[1], 111112, {0,1, 0x00000002, 1}); // 第1个数据,timeStamp=111112 |
| 123 | - SetTaskTrack(taskTrack[2], 111116, {0, {0, 0}, 1, 0x0000FFFE, 1}); // 第2个数据,timeStamp=111116 | 123 | + SetTaskTrack(taskTrack[2], 111116, {0,1, 0x0000FFFE, 1}); // 第2个数据,timeStamp=111116 |
| 124 | // real flip 0 | 124 | // real flip 0 |
| 125 | - SetTaskTrack(taskTrack[3], 111120, {0, {0, 0}, 1, 0x00000000, 1}); // 第3个数据,timeStamp=111120 | 125 | + SetTaskTrack(taskTrack[3], 111120, {0,1, 0x00000000, 1}); // 第3个数据,timeStamp=111120 |
| 126 | - SetTaskTrack(taskTrack[4], 111130, {0, {0, 0}, 1, 0x00000001, 1}); // 第4个数据,timeStamp=111130 | 126 | + SetTaskTrack(taskTrack[4], 111130, {0,1, 0x00000001, 1}); // 第4个数据,timeStamp=111130 |
| 127 | *flipData[0] = {0, 1, 2, 1, 111135}; // 第0个flip, taskId=2 | 127 | *flipData[0] = {0, 1, 2, 1, 111135}; // 第0个flip, taskId=2 |
| 128 | - SetTaskTrack(taskTrack[5], 111140, {0, {0, 0}, 1, 0x00000003, 1}); // 第5个数据,timeStamp=111140 | 128 | + SetTaskTrack(taskTrack[5], 111140, {0,1, 0x00000003, 1}); // 第5个数据,timeStamp=111140 |
| 129 | - SetTaskTrack(taskTrack[6], 111141, {0, {0, 0}, 1, 0x00000004, 1}); // 第6个数据,timeStamp=111141 | 129 | + SetTaskTrack(taskTrack[6], 111141, {0,1, 0x00000004, 1}); // 第6个数据,timeStamp=111141 |
| 130 | - SetTaskTrack(taskTrack[7], 111144, {0, {0, 0}, 1, 0x0000FFFE, 1}); // 第7个数据,timeStamp=111144 | 130 | + SetTaskTrack(taskTrack[7], 111144, {0,1, 0x0000FFFE, 1}); // 第7个数据,timeStamp=111144 |
| 131 | // real flip 1 | 131 | // real flip 1 |
| 132 | - SetTaskTrack(taskTrack[8], 111150, {0, {0, 0}, 1, 0x00000002, 1}); // 第8个数据,timeStamp=111150 | 132 | + SetTaskTrack(taskTrack[8], 111150, {0,1, 0x00000002, 1}); // 第8个数据,timeStamp=111150 |
| 133 | - SetTaskTrack(taskTrack[9], 111160, {0, {0, 0}, 1, 0x00000003, 1}); // 第9个数据,timeStamp=111160 | 133 | + SetTaskTrack(taskTrack[9], 111160, {0,1, 0x00000003, 1}); // 第9个数据,timeStamp=111160 |
| 134 | *flipData[1] = {0, 1, 6, 1, 111165}; // 第1个flip, taskId=6 | 134 | *flipData[1] = {0, 1, 6, 1, 111165}; // 第1个flip, taskId=6 |
| 135 | - SetTaskTrack(taskTrack[10], 111170, {0, {0, 0}, 1, 0x00000009, 1}); // 第10个数据,timeStamp=111170 | 135 | + SetTaskTrack(taskTrack[10], 111170, {0,1, 0x00000009, 1}); // 第10个数据,timeStamp=111170 |
| 136 | *flipData[2] = {0, 1, 10, 65535, 111175}; // 第2个flip, taskId=10 | 136 | *flipData[2] = {0, 1, 10, 65535, 111175}; // 第2个flip, taskId=10 |
| 137 | - SetTaskTrack(taskTrack[11], 111190, {0, {0, 0}, 1, 0x00000001, 1}); // 第11个数据,timeStamp=111190 | 137 | + SetTaskTrack(taskTrack[11], 111190, {0,1, 0x00000001, 1}); // 第11个数据,timeStamp=111190 |
| 138 | 138 | ||
| 139 | Flip::ComputeBatchId(taskTrack, flipData); | 139 | Flip::ComputeBatchId(taskTrack, flipData); |
| 140 | CheckBatchId(taskTrack, compactInfoDataNum, {0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3}); | 140 | CheckBatchId(taskTrack, compactInfoDataNum, {0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3}); |
| @@ -19,7 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | -#include "analysis/csrc/infrastructure/utils/prof_common.h" | 22 | +#include "analysis/csrc/infrastructure/utils/prof_struct.h" |
| 23 | 23 | ||
| 24 | using namespace testing; | 24 | using namespace testing; |
| 25 | 25 | ||


【review】【编码】当前PR的commit节点过多,且message信息都为"test",不符合上库规范,建议消减commit节点或者squash描述修改的范围和步骤