Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "adapter_prof.h"
12 : #include "externalinput_pub.h"
13 : #include "dlrt_function.h"
14 : using namespace hccl;
15 :
16 0 : HcclResult hrtMsprofRegisterCallback(uint32_t moduleId, ProfCommandHandle handle)
17 : {
18 0 : s32 ret = DlProfFunction::GetInstance().dlMsprofRegisterCallback(moduleId, handle);
19 0 : HCCL_INFO("Call MsprofRegisterCallback, return value[%d], Params: moduleId[%u]", ret, moduleId);
20 0 : CHK_PRT_RET(
21 : ret != 0,
22 : HCCL_ERROR("[Register][CtrlCallback]MsprofRegisterCallback fail, return[%d], moduleId[%u]", ret, moduleId),
23 : HCCL_E_PROFILING);
24 0 : return HCCL_SUCCESS;
25 : }
26 :
27 84 : HcclResult hrtMsprofRegTypeInfo(uint16_t level, uint32_t typeId, const char* typeName)
28 : {
29 84 : s32 ret = DlProfFunction::GetInstance().dlMsprofRegTypeInfo(level, typeId, typeName);
30 84 : HCCL_INFO("Call MsprofRegTypeInfo, return value[%d], Params: typeId[%u] typeName = [%s]", ret, typeId, typeName);
31 84 : CHK_PRT_RET(ret != 0, HCCL_ERROR("Call MsprofRegTypeInfo fail, return[%d]", ret), HCCL_E_PROFILING);
32 84 : return HCCL_SUCCESS;
33 : }
34 :
35 53 : HcclResult hrtMsprofReportApi(uint32_t agingFlag, const MsprofApi* api)
36 : {
37 53 : s32 ret = DlProfFunction::GetInstance().dlMsprofReportApi(agingFlag, api);
38 53 : HCCL_INFO("Call MsprofReportApi, return value[%d], Params: agingFlag[%u]", ret, agingFlag);
39 53 : CHK_PRT_RET(ret != 0, HCCL_ERROR("Call MsprofReportApi fail, return[%d]", ret), HCCL_E_PROFILING);
40 53 : return HCCL_SUCCESS;
41 : }
42 :
43 1 : HcclResult hrtMsprofReportCompactInfo(uint32_t agingFlag, const VOID_PTR data, uint32_t length)
44 : {
45 1 : s32 ret = DlProfFunction::GetInstance().dlMsprofReportCompactInfo(agingFlag, data, length);
46 1 : HCCL_INFO("Call MsprofReportCompactInfo, return value[%d], Params: agingFlag[%u]", ret, agingFlag);
47 1 : CHK_PRT_RET(ret != 0, HCCL_ERROR("Call MsprofReportCompactInfo fail, return[%d]", ret), HCCL_E_PROFILING);
48 1 : return HCCL_SUCCESS;
49 : }
50 :
51 48 : HcclResult hrtMsprofReportAdditionalInfo(uint32_t agingFlag, const VOID_PTR data, uint32_t length)
52 : {
53 48 : s32 ret = DlProfFunction::GetInstance().dlMsprofReportAdditionalInfo(agingFlag, data, length);
54 48 : HCCL_INFO("Call MsprofReportAdditionalInfo, return value[%d], Params: agingFlag[%u]", ret, agingFlag);
55 48 : CHK_PRT_RET(ret != 0, HCCL_ERROR("Call MsprofReportAdditionalInfo fail, return[%d]", ret), HCCL_E_PROFILING);
56 48 : return HCCL_SUCCESS;
57 : }
58 :
59 15746 : uint64_t hrtMsprofGetHashId(const char* hashInfo, uint32_t length)
60 : {
61 15746 : if (hashInfo == nullptr || length == 0) {
62 12 : HCCL_WARNING("HashData hashInfo is empty.");
63 12 : return INVALID_U64;
64 : }
65 15734 : u64 ret = DlProfFunction::GetInstance().dlMsprofStr2Id(hashInfo, length);
66 15734 : return ret;
67 : }
68 :
69 402 : uint64_t hrtMsprofSysCycleTime(void)
70 : {
71 402 : if (!GetIfProfile()) {
72 317 : return 0;
73 : }
74 85 : u64 ret = DlProfFunction::GetInstance().dlMsprofSysCycleTime();
75 85 : HCCL_DEBUG("Call MsprofSysCycleTime, return value[%u]", ret);
76 85 : return ret;
77 : }
78 :
79 1 : HcclResult hrtProfRegisterCtrlCallback(uint32_t logId, rtProfCtrlHandle callback)
80 : {
81 1 : rtError_t ret = DlRtFunction::GetInstance().dlrtProfRegisterCtrlCallback(logId, callback);
82 1 : HCCL_DEBUG("Call rtProfRegisterCtrlCallback, return value[%d], Params: logId[%u].", ret, logId);
83 1 : CHK_PRT_RET(
84 : ret != RT_ERROR_NONE,
85 : HCCL_ERROR(
86 : "[Register][CtrlCallback]errNo[0x%016llx] rtProf Register CtrlCallback"
87 : " fail, return[%d], rt logId[%u]",
88 : HCCL_ERROR_CODE(HCCL_E_RUNTIME), ret, logId),
89 : HCCL_E_RUNTIME);
90 1 : return HCCL_SUCCESS;
91 : }
|