LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/common/adapter - adapter_trace.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 58.0 % 50 29
Test Date: 2026-08-04 10:52:23 Functions: 66.7 % 6 4

            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_trace.h"
      12              : #include "dltrace_function.h"
      13              : #include "log.h"
      14              : using namespace hccl;
      15              : 
      16          522 : HcclResult hrtOpenTrace()
      17              : {
      18          522 :     HcclResult ret = DlTraceFunction::GetInstance().DlTraceFunctionInit();
      19          522 :     HCCL_INFO("Call TraceCreate, return value[%d]", ret);
      20          522 :     CHK_PRT_RET(ret != HCCL_SUCCESS, HCCL_ERROR("Call TraceCreate, return value[%d]", ret), HCCL_E_INTERNAL);
      21          522 :     return HCCL_SUCCESS;
      22              : }
      23              : 
      24          309 : void hrtTraceDestroy(TraHandle handle)
      25              : {
      26          309 :     if (DlTraceFunction::GetInstance().dlAtraceDestroy != nullptr) {
      27          309 :         DlTraceFunction::GetInstance().dlAtraceDestroy(handle);
      28              :     } else {
      29            0 :         DlTraceFunction::GetInstance().dlUtraceDestroy(handle);
      30              :     }    
      31          309 :     HCCL_INFO("Call TraceDestroy, Params:handle[%p]", handle);
      32          309 :     return;
      33              : }
      34              : 
      35            1 : HcclResult hrtTraceSubmit(TraHandle handle, const void *buffer, u32 bufSize)
      36              : {
      37            1 :     HcclResult ret = HCCL_E_RESERVED;
      38            1 :     if (DlTraceFunction::GetInstance().dlAtraceSubmit != nullptr) {
      39            1 :         ret = DlTraceFunction::GetInstance().dlAtraceSubmit(handle, buffer, bufSize);
      40              :     } else {
      41            0 :         ret = DlTraceFunction::GetInstance().dlUtraceSubmit(handle, buffer, bufSize);
      42              :     }
      43            1 :     CHK_PRT_RET(ret != 0,
      44              :         HCCL_ERROR("Call TraceSubmit, return value[%d], Params:handle[%p]", ret, handle),
      45              :         HCCL_E_INTERNAL);
      46            1 :     return HCCL_SUCCESS;
      47              : }
      48              : 
      49          310 : HcclResult hrtTraceCreateWithAttr(const char *objName, TraHandle &handle)
      50              : {
      51          310 :     CHK_PTR_NULL(objName);
      52          310 :     TraHandle ret = TRACE_INVALID_HANDLE;
      53          310 :     if (DlTraceFunction::GetInstance().dlAtraceCreateWithAttr != nullptr) {
      54          310 :         TraceAttr hcclAtraceAttr = {0};
      55          310 :         hcclAtraceAttr.exitSave = true;
      56          310 :         hcclAtraceAttr.msgNum = DEFAULT_ATRACE_MSG_NUM;
      57          310 :         hcclAtraceAttr.msgSize = DEFAULT_ATRACE_MSG_SIZE;
      58          310 :         ret = DlTraceFunction::GetInstance().dlAtraceCreateWithAttr(TRACER_TYPE_SCHEDULE,
      59              :             objName, &hcclAtraceAttr);
      60              :     } else {
      61            0 :         TraceAttr hcclUtraceAttr = {0};
      62            0 :         hcclUtraceAttr.exitSave = false;
      63            0 :         hcclUtraceAttr.msgNum = DEFAULT_ATRACE_MSG_NUM;
      64            0 :         hcclUtraceAttr.msgSize = DEFAULT_ATRACE_MSG_SIZE;
      65            0 :         ret = DlTraceFunction::GetInstance().dlUtraceCreateWithAttr(TRACER_TYPE_SCHEDULE,
      66              :         objName, &hcclUtraceAttr);
      67              :     }
      68          310 :     HCCL_INFO("Call TraceCreateWithAttr, return value[%p], Params: objName[%s]", ret, objName);
      69          310 :     CHK_PRT_RET(ret == TRACE_INVALID_HANDLE, HCCL_WARNING("Call TraceCreateWithAttr, return value[%lld]", ret),
      70              :         HCCL_E_INTERNAL);
      71          310 :     handle = ret;
      72          310 :     return HCCL_SUCCESS;
      73              : }
      74              : 
      75            0 : HcclResult hrtTraceSetGlobalAttr(const TraceGlobalAttr *attr)
      76              : {
      77            0 :     TraHandle ret = TRACE_INVALID_HANDLE;
      78            0 :     if (DlTraceFunction::GetInstance().dlAtraceSetGlobalAttr != nullptr) {
      79            0 :         ret = DlTraceFunction::GetInstance().dlAtraceSetGlobalAttr(attr);
      80              :     } else {
      81            0 :         ret = DlTraceFunction::GetInstance().dlUtraceSetGlobalAttr(attr);
      82              :     }
      83            0 :     CHK_PRT_RET(ret != 0,
      84              :         HCCL_ERROR("Call TraceSetGlobalAttr, return value[%d]", ret), HCCL_E_INTERNAL);
      85            0 :     return HCCL_SUCCESS;
      86              : }
      87              : 
      88            0 : HcclResult hrtTraceSave(TracerType tracerType, bool syncFlag)
      89              : {
      90            0 :     TraHandle ret = TRACE_INVALID_HANDLE;
      91            0 :     if (DlTraceFunction::GetInstance().dlAtraceSave != nullptr) {
      92            0 :         ret = DlTraceFunction::GetInstance().dlAtraceSave(tracerType, syncFlag);
      93              :     } else {
      94            0 :         ret = DlTraceFunction::GetInstance().dlUtraceSave(tracerType, syncFlag);
      95              :     }
      96            0 :     CHK_PRT_RET(ret != 0, HCCL_ERROR("Call traceSave, return value[%d]", ret), HCCL_E_INTERNAL);
      97            0 :     return HCCL_SUCCESS;
      98              : }
        

Generated by: LCOV version 2.0-1