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/event.h"
14 : #include "runtime/base.h"
15 : #include "runtime/rts/rts_event.h"
16 :
17 : #include "common/log_inner.h"
18 : #include "common/error_codes_inner.h"
19 : #include "common/prof_reporter.h"
20 :
21 3 : aclError aclrtCreateNotifyImpl(aclrtNotify *notify, uint64_t flag)
22 : {
23 6 : ACL_PROFILING_REG(acl::AclProfType::AclrtCreateNotify);
24 3 : ACL_LOG_INFO("start to execute aclrtCreateNotify, flag is [%lu]", flag);
25 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
26 :
27 2 : const rtError_t rtErr = rtsNotifyCreate(static_cast<rtNotify_t*>(notify), flag);
28 2 : if (rtErr != RT_ERROR_NONE) {
29 1 : ACL_LOG_CALL_ERROR("call rtsNotifyCreate failed, runtime result = %d", rtErr);
30 1 : return ACL_GET_ERRCODE_RTS(rtErr);
31 : }
32 :
33 1 : ACL_LOG_INFO("successfully execute aclrtCreateNotify");
34 1 : return ACL_SUCCESS;
35 : }
36 :
37 3 : aclError aclrtDestroyNotifyImpl(aclrtNotify notify)
38 : {
39 6 : ACL_PROFILING_REG(acl::AclProfType::AclrtDestroyNotify);
40 3 : ACL_LOG_INFO("start to execute aclrtDestroyNotify");
41 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
42 :
43 2 : const rtError_t rtErr = rtsNotifyDestroy(static_cast<rtNotify_t>(notify));
44 2 : if (rtErr != RT_ERROR_NONE) {
45 1 : ACL_LOG_CALL_ERROR("call rtsNotifyDestroy failed, runtime result = %d", rtErr);
46 1 : return ACL_GET_ERRCODE_RTS(rtErr);
47 : }
48 :
49 1 : ACL_LOG_INFO("successfully execute aclrtDestroyNotify");
50 1 : return ACL_SUCCESS;
51 : }
52 :
53 3 : aclError aclrtRecordNotifyImpl(aclrtNotify notify, aclrtStream stream)
54 : {
55 6 : ACL_PROFILING_REG(acl::AclProfType::AclrtRecordNotify);
56 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
57 :
58 2 : const rtError_t rtErr = rtsNotifyRecord(static_cast<rtNotify_t>(notify), static_cast<rtStream_t>(stream));
59 2 : if (rtErr != RT_ERROR_NONE) {
60 1 : ACL_LOG_CALL_ERROR("call rtsNotifyRecord failed, runtime result = %d", rtErr);
61 1 : return ACL_GET_ERRCODE_RTS(rtErr);
62 : }
63 :
64 1 : return ACL_SUCCESS;
65 : }
66 :
67 3 : aclError aclrtWaitAndResetNotifyImpl(aclrtNotify notify, aclrtStream stream, uint32_t timeout)
68 : {
69 6 : ACL_PROFILING_REG(acl::AclProfType::AclrtWaitAndResetNotify);
70 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
71 :
72 2 : const rtError_t rtErr = rtsNotifyWaitAndReset(static_cast<rtNotify_t>(notify),
73 : static_cast<rtStream_t>(stream), timeout);
74 2 : if (rtErr != RT_ERROR_NONE) {
75 1 : ACL_LOG_CALL_ERROR("call rtsNotifyWaitAndReset failed, runtime result = %d", rtErr);
76 1 : return ACL_GET_ERRCODE_RTS(rtErr);
77 : }
78 :
79 1 : return ACL_SUCCESS;
80 : }
81 :
82 4 : aclError aclrtGetNotifyIdImpl(aclrtNotify notify, uint32_t *notifyId)
83 : {
84 8 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetNotifyId);
85 4 : ACL_LOG_INFO("start to execute aclrtGetNotifyId");
86 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
87 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notifyId);
88 :
89 2 : const rtError_t rtErr = rtsNotifyGetId(static_cast<rtNotify_t>(notify), notifyId);
90 2 : if (rtErr != RT_ERROR_NONE) {
91 1 : ACL_LOG_CALL_ERROR("call rtsNotifyGetId failed, runtime result = %d", rtErr);
92 1 : return ACL_GET_ERRCODE_RTS(rtErr);
93 : }
94 :
95 1 : ACL_LOG_INFO("successfully execute aclrtGetNotifyId");
96 1 : return ACL_SUCCESS;
97 : }
98 :
99 3 : aclError aclrtNotifyBatchResetImpl(aclrtNotify *notifies, size_t num)
100 : {
101 6 : ACL_PROFILING_REG(acl::AclProfType::AclrtNotifyBatchReset);
102 3 : ACL_LOG_INFO("start to execute aclrtNotifyBatchReset, num is [%zu]", num);
103 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notifies);
104 :
105 2 : const rtError_t rtErr = rtsNotifyBatchReset(notifies, static_cast<uint32_t>(num));
106 2 : if (rtErr != RT_ERROR_NONE) {
107 1 : ACL_LOG_CALL_ERROR("call rtsNotifyBatchReset failed, runtime result = %d", rtErr);
108 1 : return ACL_GET_ERRCODE_RTS(rtErr);
109 : }
110 :
111 1 : ACL_LOG_INFO("successfully execute aclrtNotifyBatchReset");
112 1 : return ACL_SUCCESS;
113 : }
114 :
115 4 : aclError aclrtNotifyGetExportKeyImpl(aclrtNotify notify, char *key, size_t len, uint64_t flags)
116 : {
117 8 : ACL_PROFILING_REG(acl::AclProfType::AclrtNotifyGetExportKey);
118 4 : ACL_LOG_INFO("start to execute aclrtNotifyGetExportKey, len is [%zu], flags is [%lu]", len, flags);
119 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
120 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(key);
121 :
122 2 : const rtError_t rtErr = rtsNotifyGetExportKey(notify, key, static_cast<uint32_t>(len), flags);
123 2 : if (rtErr != RT_ERROR_NONE) {
124 1 : ACL_LOG_CALL_ERROR("call rtsNotifyGetExportKey failed, runtime result = %d", rtErr);
125 1 : return ACL_GET_ERRCODE_RTS(rtErr);
126 : }
127 :
128 1 : ACL_LOG_INFO("successfully execute aclrtNotifyGetExportKey");
129 1 : return ACL_SUCCESS;
130 : }
131 :
132 4 : aclError aclrtNotifyImportByKeyImpl(aclrtNotify *notify, const char *key, uint64_t flags)
133 : {
134 8 : ACL_PROFILING_REG(acl::AclProfType::AclrtNotifyImportByKey);
135 4 : ACL_LOG_INFO("start to execute aclrtNotifyImportByKey, flags is [%lu]", flags);
136 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
137 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(key);
138 :
139 2 : const rtError_t rtErr = rtsNotifyImportByKey(notify, key, flags);
140 2 : if (rtErr != RT_ERROR_NONE) {
141 1 : ACL_LOG_CALL_ERROR("call rtsNotifyImportByKey failed, runtime result = %d", rtErr);
142 1 : return ACL_GET_ERRCODE_RTS(rtErr);
143 : }
144 :
145 1 : ACL_LOG_INFO("successfully execute aclrtNotifyImportByKey");
146 1 : return ACL_SUCCESS;
147 : }
148 :
149 4 : aclError aclrtNotifySetImportPidImpl(aclrtNotify notify, int32_t *pid, size_t num)
150 : {
151 8 : ACL_PROFILING_REG(acl::AclProfType::AclrtNotifySetImportPid);
152 4 : ACL_LOG_INFO("start to execute aclrtNotifySetImportPid, num is [%zu]", num);
153 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
154 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(pid);
155 :
156 2 : const rtError_t rtErr = rtsNotifySetImportPid(notify, pid, static_cast<int32_t>(num));
157 2 : if (rtErr != RT_ERROR_NONE) {
158 1 : ACL_LOG_CALL_ERROR("call rtsNotifySetImportPid failed, runtime result = %d", rtErr);
159 1 : return ACL_GET_ERRCODE_RTS(rtErr);
160 : }
161 :
162 1 : ACL_LOG_INFO("successfully execute aclrtNotifySetImportPid");
163 1 : return ACL_SUCCESS;
164 : }
165 :
166 2 : aclError aclrtNotifySetImportPidInterServerImpl(aclrtNotify notify, aclrtServerPid *serverPids, size_t num)
167 : {
168 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtNotifySetImportPidInterServer);
169 2 : ACL_LOG_INFO("start to execute aclrtNotifySetImportPidInterServer, num is [%zu]", num);
170 :
171 2 : const rtError_t rtErr = rtNotifySetImportPidInterServer(notify, reinterpret_cast<const rtServerPid *>(serverPids), num);
172 2 : if (rtErr != RT_ERROR_NONE) {
173 1 : ACL_LOG_CALL_ERROR("call rtNotifySetImportPidInterServer failed, runtime result = %d", rtErr);
174 1 : return ACL_GET_ERRCODE_RTS(rtErr);
175 : }
176 :
177 1 : ACL_LOG_INFO("successfully execute aclrtNotifySetImportPidInterServer");
178 1 : return ACL_SUCCESS;
179 : }
180 :
181 2 : aclError aclrtCntNotifyCreateImpl(aclrtCntNotify *cntNotify, uint64_t flag)
182 : {
183 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyCreate);
184 2 : ACL_LOG_INFO("start to execute aclrtCntNotifyCreate, flag is [%lu]", flag);
185 :
186 2 : const rtError_t rtErr = rtCntNotifyCreateServer(static_cast<rtCntNotify_t*>(cntNotify), flag);
187 2 : if (rtErr != RT_ERROR_NONE) {
188 1 : ACL_LOG_CALL_ERROR("call aclrtCntNotifyCreate failed, runtime result = %d", rtErr);
189 1 : return ACL_GET_ERRCODE_RTS(rtErr);
190 : }
191 :
192 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyCreate");
193 1 : return ACL_SUCCESS;
194 : }
195 :
196 2 : aclError aclrtCntNotifyDestroyImpl(aclrtCntNotify cntNotify)
197 : {
198 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyDestroy);
199 2 : ACL_LOG_INFO("start to execute aclrtCntNotifyDestroy");
200 :
201 2 : const rtError_t rtErr = rtCntNotifyDestroy(static_cast<rtCntNotify_t>(cntNotify));
202 2 : if (rtErr != RT_ERROR_NONE) {
203 1 : ACL_LOG_CALL_ERROR("call aclrtCntNotifyDestroy failed, runtime result = %d", rtErr);
204 1 : return ACL_GET_ERRCODE_RTS(rtErr);
205 : }
206 :
207 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyDestroy");
208 1 : return ACL_SUCCESS;
209 : }
210 :
211 3 : aclError aclrtCntNotifyRecordImpl(aclrtCntNotify cntNotify, aclrtStream stream, aclrtCntNotifyRecordInfo *info)
212 : {
213 6 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyRecord);
214 3 : ACL_LOG_INFO("start to execute aclrtCntNotifyRecord");
215 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(info);
216 :
217 2 : const rtError_t rtErr = rtsCntNotifyRecord(cntNotify, stream, reinterpret_cast<rtCntNotifyRecordInfo_t *>(info));
218 2 : if (rtErr != RT_ERROR_NONE) {
219 1 : ACL_LOG_CALL_ERROR("call rtsCntNotifyRecord failed, runtime result = %d", static_cast<int32_t>(rtErr));
220 1 : return ACL_GET_ERRCODE_RTS(rtErr);
221 : }
222 :
223 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyRecord");
224 1 : return ACL_SUCCESS;
225 : }
226 :
227 3 : aclError aclrtCntNotifyWaitWithTimeoutImpl(aclrtCntNotify cntNotify, aclrtStream stream, aclrtCntNotifyWaitInfo *info)
228 : {
229 6 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyWaitWithTimeout);
230 3 : ACL_LOG_INFO("start to execute aclrtCntNotifyWaitWithTimeout");
231 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(info);
232 :
233 2 : const rtError_t rtErr = rtsCntNotifyWaitWithTimeout(cntNotify, stream, reinterpret_cast<rtCntNotifyWaitInfo_t *>(info));
234 2 : if (rtErr != RT_ERROR_NONE) {
235 1 : ACL_LOG_CALL_ERROR("call rtsCntNotifyWaitWithTimeout failed, runtime result = %d", static_cast<int32_t>(rtErr));
236 1 : return ACL_GET_ERRCODE_RTS(rtErr);
237 : }
238 :
239 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyWaitWithTimeout");
240 1 : return ACL_SUCCESS;
241 : }
242 :
243 2 : aclError aclrtCntNotifyResetImpl(aclrtCntNotify cntNotify, aclrtStream stream)
244 : {
245 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyReset);
246 2 : ACL_LOG_INFO("start to execute aclrtCntNotifyReset");
247 :
248 2 : const rtError_t rtErr = rtsCntNotifyReset(cntNotify, stream);
249 2 : if (rtErr != RT_ERROR_NONE) {
250 1 : ACL_LOG_CALL_ERROR("call rtsCntNotifyReset failed, runtime result = %d", static_cast<int32_t>(rtErr));
251 1 : return ACL_GET_ERRCODE_RTS(rtErr);
252 : }
253 :
254 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyReset");
255 1 : return ACL_SUCCESS;
256 : }
257 :
258 2 : aclError aclrtCntNotifyGetIdImpl(aclrtCntNotify cntNotify, uint32_t *notifyId)
259 : {
260 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyGetId);
261 2 : ACL_LOG_INFO("start to execute aclrCntNotifyGetId");
262 :
263 2 : const rtError_t rtErr = rtsCntNotifyGetId(cntNotify, notifyId);
264 2 : if (rtErr != RT_ERROR_NONE) {
265 1 : ACL_LOG_CALL_ERROR("call rtsCntNotifyGetId failed, runtime result = %d", static_cast<int32_t>(rtErr));
266 1 : return ACL_GET_ERRCODE_RTS(rtErr);
267 : }
268 :
269 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyGetId");
270 1 : return ACL_SUCCESS;
271 : }
|