LCOV - code coverage report
Current view: top level - acl/aclrt_impl - label.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 64 64 100.0 %
Date: 2026-08-27 13:24:42 Functions: 6 6 100.0 %

          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 "acl_rt_impl.h"
      12             : 
      13             : #include "runtime/rts/rts_model.h"
      14             : #include "common/log_inner.h"
      15             : #include "common/error_codes_inner.h"
      16             : #include "common/prof_reporter.h"
      17             : 
      18           3 : aclError aclrtCreateLabelImpl(aclrtLabel *label)
      19             : {
      20           6 :     ACL_PROFILING_REG(acl::AclProfType::AclrtCreateLabel);
      21           3 :     ACL_LOG_INFO("start to execute aclrtCreateLabel");
      22           3 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(label);
      23             : 
      24           2 :     const rtError_t rtErr = rtsLabelCreate(static_cast<rtLabel_t*>(label));
      25           2 :     if (rtErr != RT_ERROR_NONE) {
      26           1 :         ACL_LOG_CALL_ERROR("call rtsLabelCreate failed, runtime result = %d", rtErr);
      27           1 :         return ACL_GET_ERRCODE_RTS(rtErr);
      28             :     }
      29             : 
      30           1 :     ACL_LOG_INFO("successfully execute aclrtCreateLabel");
      31           1 :     return ACL_SUCCESS;
      32             : }
      33             : 
      34           4 : aclError aclrtSetLabelImpl(aclrtLabel label, aclrtStream stream)
      35             : {
      36           8 :     ACL_PROFILING_REG(acl::AclProfType::AclrtSetLabel);
      37           4 :     ACL_LOG_INFO("start to execute aclrtSetLabel");
      38           4 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(label);
      39           3 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(stream);
      40             : 
      41           2 :     const rtError_t rtErr = rtsLabelSet(static_cast<rtLabel_t>(label), static_cast<rtStream_t>(stream));
      42           2 :     if (rtErr != RT_ERROR_NONE) {
      43           1 :         ACL_LOG_CALL_ERROR("call rtsLabelSet failed, runtime result = %d", rtErr);
      44           1 :         return ACL_GET_ERRCODE_RTS(rtErr);
      45             :     }
      46             : 
      47           1 :     ACL_LOG_INFO("successfully execute aclrtSetLabel");
      48           1 :     return ACL_SUCCESS;
      49             : }
      50             : 
      51           3 : aclError aclrtDestroyLabelImpl(aclrtLabel label)
      52             : {
      53           6 :     ACL_PROFILING_REG(acl::AclProfType::AclrtDestroyLabel);
      54           3 :     ACL_LOG_INFO("start to execute aclrtDestroyLabel");
      55           3 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(label);
      56             : 
      57           2 :     const rtError_t rtErr = rtsLabelDestroy(static_cast<rtLabel_t>(label));
      58           2 :     if (rtErr != RT_ERROR_NONE) {
      59           1 :         ACL_LOG_CALL_ERROR("call rtsLabelDestroy failed, runtime result = %d", rtErr);
      60           1 :         return ACL_GET_ERRCODE_RTS(rtErr);
      61             :     }
      62             : 
      63           1 :     ACL_LOG_INFO("successfully execute aclrtDestroyLabel");
      64           1 :     return ACL_SUCCESS;
      65             : }
      66             : 
      67           4 : aclError aclrtCreateLabelListImpl(aclrtLabel *labels, size_t num, aclrtLabelList *labelList)
      68             : {
      69           8 :     ACL_PROFILING_REG(acl::AclProfType::AclrtCreateLabelList);
      70           4 :     ACL_LOG_INFO("start to execute aclrtCreateLabelList, num is [%zu]", num);
      71           4 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(labels);
      72           3 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(labelList);
      73             : 
      74           2 :     const rtError_t rtErr = rtsLabelSwitchListCreate(static_cast<rtLabel_t*>(labels), num,
      75             :         reinterpret_cast<void**>(labelList));
      76           2 :     if (rtErr != RT_ERROR_NONE) {
      77           1 :         ACL_LOG_CALL_ERROR("call rtsLabelSwitchListCreate failed, runtime result = %d", rtErr);
      78           1 :         return ACL_GET_ERRCODE_RTS(rtErr);
      79             :     }
      80             : 
      81           1 :     ACL_LOG_INFO("successfully execute aclrtCreateLabelList");
      82           1 :     return ACL_SUCCESS;
      83             : }
      84             : 
      85           3 : aclError aclrtDestroyLabelListImpl(aclrtLabelList labelList)
      86             : {
      87           6 :     ACL_PROFILING_REG(acl::AclProfType::AclrtDestroyLabelList);
      88           3 :     ACL_LOG_INFO("start to execute aclrtDestroyLabelList");
      89           3 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(labelList);
      90             : 
      91           2 :     const rtError_t rtErr = rtsLabelSwitchListDestroy(reinterpret_cast<void*>(labelList));
      92           2 :     if (rtErr != RT_ERROR_NONE) {
      93           1 :         ACL_LOG_CALL_ERROR("call rtsLabelSwitchListDestroy failed, runtime result = %d", rtErr);
      94           1 :         return ACL_GET_ERRCODE_RTS(rtErr);
      95             :     }
      96             : 
      97           1 :     ACL_LOG_INFO("successfully execute aclrtDestroyLabelList");
      98           1 :     return ACL_SUCCESS;
      99             : }
     100             : 
     101           5 : aclError aclrtSwitchLabelByIndexImpl(void *ptr, uint32_t maxValue, aclrtLabelList labelList, aclrtStream stream)
     102             : {
     103          10 :     ACL_PROFILING_REG(acl::AclProfType::AclrtSwitchLabelByIndex);
     104           5 :     ACL_LOG_INFO("start to execute aclrtSwitchLabelByIndex, maxValue is [%u]", maxValue);
     105           5 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(ptr);
     106           4 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(labelList);
     107           3 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(stream);
     108             : 
     109           2 :     const rtError_t rtErr = rtsLabelSwitchByIndex(ptr, maxValue, reinterpret_cast<void*>(labelList),
     110             :         static_cast<rtStream_t>(stream));
     111           2 :     if (rtErr != RT_ERROR_NONE) {
     112           1 :         ACL_LOG_CALL_ERROR("call rtsLabelSwitchByIndex failed, runtime result = %d", rtErr);
     113           1 :         return ACL_GET_ERRCODE_RTS(rtErr);
     114             :     }
     115             : 
     116           1 :     ACL_LOG_INFO("successfully execute aclrtSwitchLabelByIndex");
     117           1 :     return ACL_SUCCESS;
     118             : }

Generated by: LCOV version 1.14