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 : #ifdef __cplusplus
22 : extern "C" {
23 : #endif
24 :
25 3 : aclError aclrtCreateNotifyImpl(aclrtNotify* notify, uint64_t flag)
26 : {
27 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtCreateNotify);
28 3 : ACL_LOG_INFO("start to execute aclrtCreateNotify, flag is [%lu]", flag);
29 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
30 :
31 2 : ACL_REQUIRES_RTS_OK(rtsNotifyCreate(static_cast<rtNotify_t*>(notify), flag));
32 :
33 1 : ACL_LOG_INFO("successfully execute aclrtCreateNotify");
34 1 : return ACL_SUCCESS;
35 3 : }
36 :
37 3 : aclError aclrtDestroyNotifyImpl(aclrtNotify notify)
38 : {
39 3 : 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 : ACL_REQUIRES_RTS_OK(rtsNotifyDestroy(static_cast<rtNotify_t>(notify)));
44 :
45 1 : ACL_LOG_INFO("successfully execute aclrtDestroyNotify");
46 1 : return ACL_SUCCESS;
47 3 : }
48 :
49 3 : aclError aclrtRecordNotifyImpl(aclrtNotify notify, aclrtStream stream)
50 : {
51 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtRecordNotify);
52 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
53 :
54 2 : ACL_REQUIRES_RTS_OK(rtsNotifyRecord(static_cast<rtNotify_t>(notify), static_cast<rtStream_t>(stream)));
55 :
56 1 : return ACL_SUCCESS;
57 3 : }
58 :
59 3 : aclError aclrtWaitAndResetNotifyImpl(aclrtNotify notify, aclrtStream stream, uint32_t timeout)
60 : {
61 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtWaitAndResetNotify);
62 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
63 :
64 2 : ACL_REQUIRES_RTS_OK(
65 : rtsNotifyWaitAndReset(static_cast<rtNotify_t>(notify), static_cast<rtStream_t>(stream), timeout));
66 :
67 1 : return ACL_SUCCESS;
68 3 : }
69 :
70 4 : aclError aclrtGetNotifyIdImpl(aclrtNotify notify, uint32_t* notifyId)
71 : {
72 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetNotifyId);
73 4 : ACL_LOG_INFO("start to execute aclrtGetNotifyId");
74 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
75 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notifyId);
76 :
77 2 : ACL_REQUIRES_RTS_OK(rtsNotifyGetId(static_cast<rtNotify_t>(notify), notifyId));
78 :
79 1 : ACL_LOG_INFO("successfully execute aclrtGetNotifyId");
80 1 : return ACL_SUCCESS;
81 4 : }
82 :
83 3 : aclError aclrtNotifyBatchResetImpl(aclrtNotify* notifies, size_t num)
84 : {
85 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtNotifyBatchReset);
86 3 : ACL_LOG_INFO("start to execute aclrtNotifyBatchReset, num is [%zu]", num);
87 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notifies);
88 2 : ACL_REQUIRES_RTS_OK(rtsNotifyBatchReset(notifies, static_cast<uint32_t>(num)));
89 :
90 1 : ACL_LOG_INFO("successfully execute aclrtNotifyBatchReset");
91 1 : return ACL_SUCCESS;
92 3 : }
93 :
94 4 : aclError aclrtNotifyGetExportKeyImpl(aclrtNotify notify, char* key, size_t len, uint64_t flags)
95 : {
96 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtNotifyGetExportKey);
97 4 : ACL_LOG_INFO("start to execute aclrtNotifyGetExportKey, len is [%zu], flags is [%lu]", len, flags);
98 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
99 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(key);
100 :
101 2 : ACL_REQUIRES_RTS_OK(rtsNotifyGetExportKey(notify, key, static_cast<uint32_t>(len), flags));
102 :
103 1 : ACL_LOG_INFO("successfully execute aclrtNotifyGetExportKey");
104 1 : return ACL_SUCCESS;
105 4 : }
106 :
107 4 : aclError aclrtNotifyImportByKeyImpl(aclrtNotify* notify, const char* key, uint64_t flags)
108 : {
109 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtNotifyImportByKey);
110 4 : ACL_LOG_INFO("start to execute aclrtNotifyImportByKey, flags is [%lu]", flags);
111 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
112 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(key);
113 :
114 2 : ACL_REQUIRES_RTS_OK(rtsNotifyImportByKey(notify, key, flags));
115 :
116 1 : ACL_LOG_INFO("successfully execute aclrtNotifyImportByKey");
117 1 : return ACL_SUCCESS;
118 4 : }
119 :
120 4 : aclError aclrtNotifySetImportPidImpl(aclrtNotify notify, int32_t* pid, size_t num)
121 : {
122 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtNotifySetImportPid);
123 4 : ACL_LOG_INFO("start to execute aclrtNotifySetImportPid, num is [%zu]", num);
124 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(notify);
125 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(pid);
126 :
127 2 : ACL_REQUIRES_RTS_OK(rtsNotifySetImportPid(notify, pid, static_cast<int32_t>(num)));
128 :
129 1 : ACL_LOG_INFO("successfully execute aclrtNotifySetImportPid");
130 1 : return ACL_SUCCESS;
131 4 : }
132 :
133 2 : aclError aclrtNotifySetImportPidInterServerImpl(aclrtNotify notify, aclrtServerPid* serverPids, size_t num)
134 : {
135 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtNotifySetImportPidInterServer);
136 2 : ACL_LOG_INFO("start to execute aclrtNotifySetImportPidInterServer, num is [%zu]", num);
137 :
138 2 : ACL_REQUIRES_RTS_OK(rtNotifySetImportPidInterServer(notify, reinterpret_cast<const rtServerPid*>(serverPids), num));
139 :
140 1 : ACL_LOG_INFO("successfully execute aclrtNotifySetImportPidInterServer");
141 1 : return ACL_SUCCESS;
142 2 : }
143 :
144 2 : aclError aclrtCntNotifyCreateImpl(aclrtCntNotify* cntNotify, uint64_t flag)
145 : {
146 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyCreate);
147 2 : ACL_LOG_INFO("start to execute aclrtCntNotifyCreate, flag is [%lu]", flag);
148 :
149 2 : ACL_REQUIRES_RTS_OK(rtCntNotifyCreateServer(static_cast<rtCntNotify_t*>(cntNotify), flag));
150 :
151 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyCreate");
152 1 : return ACL_SUCCESS;
153 2 : }
154 :
155 2 : aclError aclrtCntNotifyDestroyImpl(aclrtCntNotify cntNotify)
156 : {
157 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyDestroy);
158 2 : ACL_LOG_INFO("start to execute aclrtCntNotifyDestroy");
159 :
160 2 : ACL_REQUIRES_RTS_OK(rtCntNotifyDestroy(static_cast<rtCntNotify_t>(cntNotify)));
161 :
162 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyDestroy");
163 1 : return ACL_SUCCESS;
164 2 : }
165 :
166 3 : aclError aclrtCntNotifyRecordImpl(aclrtCntNotify cntNotify, aclrtStream stream, aclrtCntNotifyRecordInfo* info)
167 : {
168 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyRecord);
169 3 : ACL_LOG_INFO("start to execute aclrtCntNotifyRecord");
170 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(info);
171 :
172 2 : ACL_REQUIRES_RTS_OK(rtsCntNotifyRecord(cntNotify, stream, reinterpret_cast<rtCntNotifyRecordInfo_t*>(info)));
173 :
174 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyRecord");
175 1 : return ACL_SUCCESS;
176 3 : }
177 :
178 3 : aclError aclrtCntNotifyWaitWithTimeoutImpl(aclrtCntNotify cntNotify, aclrtStream stream, aclrtCntNotifyWaitInfo* info)
179 : {
180 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyWaitWithTimeout);
181 3 : ACL_LOG_INFO("start to execute aclrtCntNotifyWaitWithTimeout");
182 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(info);
183 2 : ACL_REQUIRES_RTS_OK(rtsCntNotifyWaitWithTimeout(cntNotify, stream, reinterpret_cast<rtCntNotifyWaitInfo_t*>(info)));
184 :
185 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyWaitWithTimeout");
186 1 : return ACL_SUCCESS;
187 3 : }
188 :
189 2 : aclError aclrtCntNotifyResetImpl(aclrtCntNotify cntNotify, aclrtStream stream)
190 : {
191 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyReset);
192 2 : ACL_LOG_INFO("start to execute aclrtCntNotifyReset");
193 :
194 2 : ACL_REQUIRES_RTS_OK(rtsCntNotifyReset(cntNotify, stream));
195 :
196 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyReset");
197 1 : return ACL_SUCCESS;
198 2 : }
199 :
200 2 : aclError aclrtCntNotifyGetIdImpl(aclrtCntNotify cntNotify, uint32_t* notifyId)
201 : {
202 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtCntNotifyGetId);
203 2 : ACL_LOG_INFO("start to execute aclrCntNotifyGetId");
204 :
205 2 : ACL_REQUIRES_RTS_OK(rtsCntNotifyGetId(cntNotify, notifyId));
206 :
207 1 : ACL_LOG_INFO("successfully execute aclrtCntNotifyGetId");
208 1 : return ACL_SUCCESS;
209 2 : }
210 : #ifdef __cplusplus
211 : }
212 : #endif
|