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 : #ifdef __cplusplus
19 : extern "C" {
20 : #endif
21 :
22 3 : aclError aclrtCreateLabelImpl(aclrtLabel* label)
23 : {
24 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtCreateLabel);
25 3 : ACL_LOG_INFO("start to execute aclrtCreateLabel");
26 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(label);
27 :
28 2 : ACL_REQUIRES_RTS_OK(rtsLabelCreate(static_cast<rtLabel_t*>(label)));
29 :
30 1 : ACL_LOG_INFO("successfully execute aclrtCreateLabel");
31 1 : return ACL_SUCCESS;
32 3 : }
33 :
34 4 : aclError aclrtSetLabelImpl(aclrtLabel label, aclrtStream stream)
35 : {
36 4 : 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 : ACL_REQUIRES_RTS_OK(rtsLabelSet(static_cast<rtLabel_t>(label), static_cast<rtStream_t>(stream)));
42 :
43 1 : ACL_LOG_INFO("successfully execute aclrtSetLabel");
44 1 : return ACL_SUCCESS;
45 4 : }
46 :
47 3 : aclError aclrtDestroyLabelImpl(aclrtLabel label)
48 : {
49 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtDestroyLabel);
50 3 : ACL_LOG_INFO("start to execute aclrtDestroyLabel");
51 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(label);
52 :
53 2 : ACL_REQUIRES_RTS_OK(rtsLabelDestroy(static_cast<rtLabel_t>(label)));
54 :
55 1 : ACL_LOG_INFO("successfully execute aclrtDestroyLabel");
56 1 : return ACL_SUCCESS;
57 3 : }
58 :
59 4 : aclError aclrtCreateLabelListImpl(aclrtLabel* labels, size_t num, aclrtLabelList* labelList)
60 : {
61 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtCreateLabelList);
62 4 : ACL_LOG_INFO("start to execute aclrtCreateLabelList, num is [%zu]", num);
63 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(labels);
64 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(labelList);
65 :
66 2 : ACL_REQUIRES_RTS_OK(
67 : rtsLabelSwitchListCreate(static_cast<rtLabel_t*>(labels), num, reinterpret_cast<void**>(labelList)));
68 :
69 1 : ACL_LOG_INFO("successfully execute aclrtCreateLabelList");
70 1 : return ACL_SUCCESS;
71 4 : }
72 :
73 3 : aclError aclrtDestroyLabelListImpl(aclrtLabelList labelList)
74 : {
75 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtDestroyLabelList);
76 3 : ACL_LOG_INFO("start to execute aclrtDestroyLabelList");
77 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(labelList);
78 :
79 2 : ACL_REQUIRES_RTS_OK(rtsLabelSwitchListDestroy(reinterpret_cast<void*>(labelList)));
80 :
81 1 : ACL_LOG_INFO("successfully execute aclrtDestroyLabelList");
82 1 : return ACL_SUCCESS;
83 3 : }
84 :
85 5 : aclError aclrtSwitchLabelByIndexImpl(void* ptr, uint32_t maxValue, aclrtLabelList labelList, aclrtStream stream)
86 : {
87 5 : ACL_PROFILING_REG(acl::AclProfType::AclrtSwitchLabelByIndex);
88 5 : ACL_LOG_INFO("start to execute aclrtSwitchLabelByIndex, maxValue is [%u]", maxValue);
89 5 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(ptr);
90 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(labelList);
91 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(stream);
92 :
93 2 : ACL_REQUIRES_RTS_OK(
94 : rtsLabelSwitchByIndex(ptr, maxValue, reinterpret_cast<void*>(labelList), static_cast<rtStream_t>(stream)));
95 :
96 1 : ACL_LOG_INFO("successfully execute aclrtSwitchLabelByIndex");
97 1 : return ACL_SUCCESS;
98 5 : }
99 : #ifdef __cplusplus
100 : }
101 : #endif
|