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 : #include "acl_rt_impl_base.h"
13 : #include "runtime/dev.h"
14 : #include "runtime/kernel.h"
15 : #include "runtime/config.h"
16 : #include "runtime/rts/rts_device.h"
17 : #include "runtime/rts/rts_stream.h"
18 : #include "common/log_inner.h"
19 : #include "common/error_codes_inner.h"
20 : #include "common/prof_reporter.h"
21 : #include "common/resource_statistics.h"
22 : #include "runtime/rt_inner_device.h"
23 : #include "utils/data_type_utils.h"
24 :
25 : namespace {
26 : constexpr int32_t DEVICE_UTILIZATION_NOT_SUPPORT = -1;
27 :
28 6 : int32_t GetAllUtilizations(const int32_t deviceId, const rtTypeUtil_t utilType)
29 : {
30 6 : uint8_t utilRate = 0U;
31 6 : const rtError_t rtErr = rtGetAllUtilizations(deviceId, utilType, &utilRate);
32 6 : if (rtErr == ACL_ERROR_RT_FEATURE_NOT_SUPPORT) {
33 1 : ACL_LOG_WARN("rtGetAllUtilizations not to support this query, utilType = %d, runtime result = %d.",
34 : static_cast<int32_t>(utilType), static_cast<int32_t>(rtErr));
35 1 : return DEVICE_UTILIZATION_NOT_SUPPORT;
36 : }
37 5 : if (rtErr != RT_ERROR_NONE) {
38 1 : ACL_LOG_CALL_ERROR("rtGetAllUtilizations failed, utilType = %d, runtime result = %d.",
39 : static_cast<int32_t>(utilType), static_cast<int32_t>(rtErr));
40 1 : return DEVICE_UTILIZATION_NOT_SUPPORT;
41 : }
42 4 : ACL_LOG_INFO("successfully execute rtGetAllUtilizations, utilType = %d, utilRate = %u.",
43 : static_cast<int32_t>(utilType), utilRate);
44 4 : return static_cast<int32_t>(utilRate);
45 : }
46 : }
47 :
48 : #ifdef __cplusplus
49 : extern "C" {
50 : #endif
51 :
52 13 : aclError aclrtSetDeviceImpl(int32_t deviceId)
53 : {
54 13 : ACL_PROFILING_REG(acl::AclProfType::AclrtSetDevice);
55 13 : ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_SET_RESET_DEVICE);
56 13 : ACL_LOG_INFO("start to execute aclrtSetDevice, deviceId = %d.", deviceId);
57 13 : ACL_REQUIRES_RTS_OK(rtSetDevice(deviceId));
58 11 : ACL_LOG_INFO("successfully execute aclrtSetDevice, deviceId = %d", deviceId);
59 11 : ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_SET_RESET_DEVICE);
60 : // update platform info
61 11 : const auto err = acl::UpdatePlatformInfoWithDevice(deviceId);
62 11 : if (err != ACL_SUCCESS) {
63 7 : ACL_LOG_WARN("update platform info with device failed, error code is [%d], deviceId is [%d]", err, deviceId);
64 : }
65 11 : return ACL_SUCCESS;
66 13 : }
67 :
68 4 : aclError aclrtSetDeviceWithoutTsdVXXImpl(int32_t deviceId)
69 : {
70 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtSetDeviceWithoutTsdVXX);
71 4 : ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_SET_RESET_DEVICE);
72 4 : ACL_LOG_INFO("start to execute aclrtSetDeviceWithoutTsdVXX, deviceId = %d.", deviceId);
73 4 : const std::string &socVersion = acl::GetSocVersion();
74 4 : if (strncmp(socVersion.c_str(), "Ascend910", (sizeof("Ascend910") - 1UL)) != 0) {
75 0 : ACL_LOG_INFO("The soc version is not Ascend910, which is not supported");
76 0 : acl::AclErrorLogManager::ReportInputError(acl::UNSUPPORTED_SYSTEM_MSG, {"func"},
77 : {"aclrtSetDeviceWithoutTsdVXX, only Ascend 910 chips are supported"});
78 0 : return ACL_ERROR_API_NOT_SUPPORT;
79 : }
80 4 : ACL_REQUIRES_RTS_OK(rtSetDeviceWithoutTsd(deviceId));
81 2 : ACL_LOG_INFO("open device %d successfully.", deviceId);
82 2 : ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_SET_RESET_DEVICE);
83 2 : return ACL_SUCCESS;
84 4 : }
85 :
86 5 : aclError aclrtResetDeviceImpl(int32_t deviceId)
87 : {
88 5 : ACL_PROFILING_REG(acl::AclProfType::AclrtResetDevice);
89 5 : ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_SET_RESET_DEVICE);
90 5 : ACL_LOG_INFO("start to execute aclrtResetDevice, deviceId = %d.", deviceId);
91 5 : ACL_REQUIRES_RTS_OK(rtDeviceReset(deviceId));
92 2 : ACL_LOG_INFO("successfully execute aclrtResetDevice, reset device %d.", deviceId);
93 2 : ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_SET_RESET_DEVICE);
94 2 : return ACL_SUCCESS;
95 5 : }
96 :
97 5 : aclError aclrtResetDeviceForceImpl(int32_t deviceId)
98 : {
99 5 : ACL_PROFILING_REG(acl::AclProfType::AclrtResetDeviceForce);
100 5 : ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_SET_RESET_DEVICE);
101 5 : ACL_LOG_INFO("start to execute aclrtResetDeviceForce, deviceId = %d.", deviceId);
102 5 : ACL_REQUIRES_RTS_OK(rtDeviceResetForce(deviceId));
103 3 : ACL_LOG_INFO("successfully execute aclrtResetDeviceForce, reset device %d.", deviceId);
104 3 : ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_SET_RESET_DEVICE);
105 3 : return ACL_SUCCESS;
106 5 : }
107 :
108 4 : aclError aclrtResetDeviceWithoutTsdVXXImpl(int32_t deviceId)
109 : {
110 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtResetDeviceWithoutTsdVXX);
111 4 : ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_SET_RESET_DEVICE);
112 4 : ACL_LOG_INFO("start to execute aclrtResetDeviceWithoutTsdVXX, deviceId = %d.", deviceId);
113 4 : const std::string &socVersion = acl::GetSocVersion();
114 4 : if (strncmp(socVersion.c_str(), "Ascend910", (sizeof("Ascend910") - 1UL)) != 0) {
115 0 : ACL_LOG_ERROR("The soc version is not Ascend910, which is not supported");
116 0 : acl::AclErrorLogManager::ReportInputError(acl::UNSUPPORTED_SYSTEM_MSG, {"func"},
117 : {"aclrtResetDeviceWithoutTsdVXX, only Ascend 910 chips are supported"});
118 0 : return ACL_ERROR_API_NOT_SUPPORT;
119 : }
120 4 : ACL_REQUIRES_RTS_OK(rtDeviceResetWithoutTsd(deviceId));
121 2 : ACL_LOG_INFO("successfully execute aclrtResetDeviceWithoutTsdVXX, reset device %d", deviceId);
122 2 : ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_SET_RESET_DEVICE);
123 2 : return ACL_SUCCESS;
124 4 : }
125 :
126 6 : aclError aclrtGetDeviceImpl(int32_t *deviceId)
127 : {
128 6 : ACL_LOG_INFO("start to execute aclrtGetDevice");
129 6 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(deviceId);
130 4 : const rtError_t rtErr = rtGetDevice(deviceId);
131 4 : if (rtErr != RT_ERROR_NONE) {
132 2 : ACL_LOG_INFO("Cannot get device id, runtime result = %d.", static_cast<int32_t>(rtErr));
133 2 : return ACL_GET_ERRCODE_RTS(rtErr);
134 : }
135 2 : ACL_LOG_DEBUG("successfully execute aclrtGetDevice, get device id is %d.", *deviceId);
136 2 : return ACL_SUCCESS;
137 : }
138 :
139 20 : aclError aclrtGetRunModeImpl(aclrtRunMode *runMode)
140 : {
141 20 : ACL_LOG_INFO("start to execute aclrtGetRunMode");
142 20 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(runMode);
143 : rtRunMode rtMode;
144 20 : ACL_REQUIRES_RTS_OK(rtGetRunMode(&rtMode));
145 17 : if (rtMode == RT_RUN_MODE_OFFLINE) {
146 15 : *runMode = ACL_DEVICE;
147 15 : return ACL_SUCCESS;
148 : }
149 2 : *runMode = ACL_HOST;
150 2 : ACL_LOG_INFO("successfully execute aclrtGetRunMode, current runMode is %d.", static_cast<int32_t>(*runMode));
151 2 : return ACL_SUCCESS;
152 : }
153 :
154 4 : aclError aclrtSynchronizeDeviceImpl()
155 : {
156 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtSynchronizeDevice);
157 4 : ACL_LOG_INFO("start to execute aclrtSynchronizeDevice");
158 4 : ACL_REQUIRES_RTS_OK(rtDeviceSynchronize());
159 2 : ACL_LOG_INFO("device synchronize successfully.");
160 2 : return ACL_SUCCESS;
161 4 : }
162 :
163 7 : aclError aclrtSynchronizeDeviceWithTimeoutImpl(int32_t timeout)
164 : {
165 7 : ACL_PROFILING_REG(acl::AclProfType::AclrtSynchronizeDeviceWithTimeout);
166 7 : ACL_LOG_INFO("start to execute aclrtSynchronizeDeviceWithTimeout, timeout %dms", timeout);
167 7 : constexpr int32_t defaultTimeout = -1;
168 13 : ACL_CHECK_INVALID_VALUE_WITH_EXPECT_RET(timeout >= defaultTimeout, timeout, "[-1, INT_MAX]", ACL_ERROR_RT_PARAM_INVALID);
169 :
170 5 : const rtError_t rtErr = rtDeviceSynchronizeWithTimeout(timeout);
171 5 : if (rtErr == ACL_ERROR_RT_STREAM_SYNC_TIMEOUT) {
172 1 : return ACL_ERROR_RT_STREAM_SYNC_TIMEOUT;
173 4 : } else if (rtErr != RT_ERROR_NONE) {
174 1 : return ACL_GET_ERRCODE_RTS(rtErr);
175 : }
176 3 : ACL_LOG_INFO("device synchronize with timeout %dms successfully.", timeout);
177 3 : return ACL_SUCCESS;
178 7 : }
179 :
180 6 : aclError aclrtSetTsDeviceImpl(aclrtTsId tsId)
181 : {
182 6 : ACL_PROFILING_REG(acl::AclProfType::AclrtSetTsDevice);
183 6 : ACL_LOG_INFO("start to execute aclrtSetTsDevice, tsId = %d.", static_cast<int32_t>(tsId));
184 6 : if ((tsId != ACL_TS_ID_AICORE) && (tsId != ACL_TS_ID_AIVECTOR)) {
185 2 : std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);
186 2 : acl::AclErrorLogManager::ReportInputError(acl::INVALID_VALUE_MSG,
187 4 : std::vector<const char *>({"func", "value", "param", "expect"}),
188 4 : std::vector<const char *>({funcName.c_str(), acl::GetTsIdDesc(tsId), "tsId", "ACL_TS_ID_AICORE or ACL_TS_ID_AIVECTOR"}));
189 2 : return ACL_ERROR_INVALID_PARAM;
190 2 : }
191 4 : ACL_REQUIRES_RTS_OK(rtSetTSDevice(static_cast<uint32_t>(tsId)));
192 2 : ACL_LOG_INFO("successfully execute aclrtSetTsDevice, set device ts %d", static_cast<int32_t>(tsId));
193 2 : return ACL_SUCCESS;
194 6 : }
195 :
196 3 : aclError aclrtGetDeviceUtilizationRateImpl(int32_t deviceId, aclrtUtilizationInfo *utilizationInfo)
197 : {
198 3 : ACL_LOG_INFO("start to execute aclrtGetDeviceUtilizationRate, device is %d.", deviceId);
199 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(utilizationInfo);
200 3 : aclrtUtilizationExtendInfo *utilizationExtend = utilizationInfo->utilizationExtend;
201 :
202 3 : ACL_CHECK_INVALID_PARAM_NO_VALUE(utilizationExtend == nullptr, "utilizationInfo->utilizationExtend",
203 : "utilizationExtend is a reserved parameter and must be nullptr");
204 2 : utilizationInfo->cubeUtilization = GetAllUtilizations(deviceId, RT_UTIL_TYPE_AICORE);
205 2 : utilizationInfo->vectorUtilization = GetAllUtilizations(deviceId, RT_UTIL_TYPE_AIVECTOR);
206 2 : utilizationInfo->aicpuUtilization = GetAllUtilizations(deviceId, RT_UTIL_TYPE_AICPU);
207 : // Currently, memory is not supported
208 2 : utilizationInfo->memoryUtilization = DEVICE_UTILIZATION_NOT_SUPPORT;
209 2 : ACL_LOG_INFO("successfully execute aclrtGetDeviceUtilizationRate, device is %d.", deviceId);
210 2 : return ACL_SUCCESS;
211 : };
212 :
213 6 : aclError aclrtGetDeviceCountImpl(uint32_t *count)
214 : {
215 6 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetDeviceCount);
216 6 : ACL_LOG_INFO("start to execute aclrtGetDeviceCount");
217 6 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(count);
218 :
219 4 : ACL_REQUIRES_RTS_OK(rtGetDeviceCount(reinterpret_cast<int32_t *>(count)));
220 2 : ACL_LOG_INFO("successfully execute aclrtGetDeviceCount, get device count is %u.", *count);
221 2 : return ACL_SUCCESS;
222 6 : }
223 :
224 2 : aclError aclrtGetDeviceSatModeImpl(aclrtFloatOverflowMode *mode)
225 : {
226 2 : ACL_LOG_INFO("start to execute aclrtGetDeviceSatMode");
227 2 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(mode);
228 2 : rtFloatOverflowMode_t rtMode = RT_OVERFLOW_MODE_UNDEF;
229 2 : ACL_REQUIRES_RTS_OK(rtGetDeviceSatMode(&rtMode));
230 1 : *mode = static_cast<aclrtFloatOverflowMode>(rtMode);
231 1 : ACL_LOG_INFO("successfully execute aclrtGetDeviceSatMode, mode is %d.", *mode);
232 1 : return ACL_SUCCESS;
233 : }
234 :
235 2 : aclError aclrtSetDeviceSatModeImpl(aclrtFloatOverflowMode mode)
236 : {
237 2 : ACL_LOG_INFO("start to execute aclrtSetDeviceSatMode, mode is %d", mode);
238 2 : ACL_REQUIRES_RTS_OK(rtSetDeviceSatMode(static_cast<rtFloatOverflowMode_t>(mode)));
239 1 : ACL_LOG_INFO("successfully execute aclrtSetDeviceSatMode, mode is %d", mode);
240 1 : return ACL_SUCCESS;
241 : }
242 :
243 3 : aclError aclrtGetOverflowStatusImpl(void *outputAddr, size_t outputSize, aclrtStream stream)
244 : {
245 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetOverflowStatus);
246 3 : ACL_LOG_INFO("start to execute aclrtGetOverflowStatus, outputSize = %lu", outputSize);
247 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(outputAddr);
248 2 : ACL_REQUIRES_RTS_OK(rtGetDeviceSatStatus(outputAddr, outputSize, static_cast<rtStream_t>(stream)));
249 1 : ACL_LOG_INFO("successfully execute aclrtGetOverflowStatus");
250 1 : return ACL_SUCCESS;
251 3 : }
252 :
253 2 : aclError aclrtResetOverflowStatusImpl(aclrtStream stream)
254 : {
255 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtResetOverflowStatus);
256 2 : ACL_LOG_INFO("start to execute aclrtResetOverflowStatus");
257 2 : ACL_REQUIRES_RTS_OK(rtCleanDeviceSatStatus(static_cast<rtStream_t>(stream)));
258 1 : ACL_LOG_INFO("successfully execute aclrtResetOverflowStatus");
259 1 : return ACL_SUCCESS;
260 2 : }
261 :
262 3 : aclError aclrtQueryDeviceStatusImpl(int32_t deviceId, aclrtDeviceStatus *deviceStatus)
263 : {
264 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtQueryDeviceStatus);
265 3 : ACL_LOG_INFO("start to execute aclrtQueryDeviceStatus with device id:%d", deviceId);
266 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(deviceStatus);
267 2 : rtDeviceStatus rtDevStatus = RT_DEVICE_STATUS_END;
268 2 : const rtError_t rtErr = rtDeviceStatusQuery(static_cast<uint32_t>(deviceId), &rtDevStatus);
269 2 : if (rtErr != RT_ERROR_NONE) {
270 1 : ACL_LOG_WARN("rtDeviceStatusQuery failed, runtime result = %d.", static_cast<int32_t>(rtErr));
271 1 : return ACL_GET_ERRCODE_RTS(rtErr);
272 : }
273 1 : *deviceStatus = static_cast<aclrtDeviceStatus>(rtDevStatus);
274 1 : ACL_LOG_INFO("successfully execute aclrtQueryDeviceStatus");
275 1 : return ACL_SUCCESS;
276 3 : }
277 :
278 2 : aclError aclrtDeviceTaskAbortImpl(int32_t deviceId, uint32_t timeout)
279 : {
280 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtDeviceTaskAbort);
281 2 : ACL_LOG_INFO("start to execute aclrtDeviceTaskAbort on device %d, timeout %ums", deviceId, timeout);
282 2 : const rtError_t rtErr = rtDeviceTaskAbort(deviceId, timeout);
283 2 : if (rtErr != RT_ERROR_NONE) {
284 1 : ACL_LOG_ERROR("rtDeviceTaskAbort for device %d, failed, runtime result = %d.",
285 : deviceId, static_cast<int32_t>(rtErr));
286 1 : return ACL_GET_ERRCODE_RTS(rtErr);
287 : }
288 1 : return ACL_SUCCESS;
289 2 : }
290 :
291 8 : aclError aclrtGetDeviceInfoImpl(uint32_t deviceId, aclrtDevAttr attr, int64_t *value)
292 : {
293 8 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetDeviceInfo);
294 8 : ACL_LOG_INFO("start to execute aclrtGetDeviceInfo");
295 8 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(value);
296 :
297 5 : ACL_REQUIRES_RTS_OK(rtsDeviceGetInfo(deviceId, static_cast<rtDevAttr>(attr), value));
298 :
299 3 : ACL_LOG_INFO("successfully execute aclrtGetDeviceInfo");
300 3 : return ACL_SUCCESS;
301 8 : }
302 :
303 4 : aclError aclrtDeviceGetStreamPriorityRangeImpl(int32_t *leastPriority, int32_t *greatestPriority)
304 : {
305 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtDeviceGetStreamPriorityRange);
306 4 : ACL_LOG_INFO("start to execute aclrtDeviceGetStreamPriorityRange");
307 :
308 4 : ACL_REQUIRES_RTS_OK(rtsDeviceGetStreamPriorityRange(leastPriority, greatestPriority));
309 :
310 4 : ACL_LOG_INFO("successfully execute aclrtDeviceGetStreamPriorityRange");
311 4 : return ACL_SUCCESS;
312 4 : }
313 :
314 3 : aclError aclrtGetDeviceCapabilityImpl(int32_t deviceId, aclrtDevFeatureType devFeatureType, int32_t *value)
315 : {
316 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetDeviceCapability);
317 3 : ACL_LOG_INFO("start to execute aclrtGetDeviceCapability");
318 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(value);
319 :
320 2 : ACL_REQUIRES_RTS_OK(rtsDeviceGetCapability(deviceId, devFeatureType, value));
321 :
322 1 : ACL_LOG_INFO("successfully execute aclrtGetDeviceCapability");
323 1 : return ACL_SUCCESS;
324 3 : }
325 :
326 3 : aclError aclrtDeviceGetHostAtomicCapabilitiesImpl(uint32_t* capabilities, const aclrtAtomicOperation* operations,
327 : const uint32_t count, int32_t deviceId)
328 : {
329 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtDeviceGetHostAtomicCapabilities);
330 3 : ACL_LOG_INFO("start to execute aclrtDeviceGetHostAtomicCapabilities, deviceId is [%u], count is [%u]",
331 : deviceId, count);
332 :
333 3 : ACL_REQUIRES_RTS_OK(rtDeviceGetHostAtomicCapabilities(capabilities,
334 : reinterpret_cast<const rtAtomicOperation*>(operations), count, deviceId));
335 :
336 1 : ACL_LOG_INFO("successfully execute aclrtDeviceGetHostAtomicCapabilities");
337 1 : return ACL_SUCCESS;
338 3 : }
339 :
340 3 : aclError aclrtDeviceGetP2PAtomicCapabilitiesImpl(uint32_t* capabilities, const aclrtAtomicOperation* operations,
341 : const uint32_t count, int32_t srcDeviceId, int32_t dstDeviceId)
342 : {
343 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtDeviceGetP2PAtomicCapabilities);
344 3 : ACL_LOG_INFO("start to execute aclrtDeviceGetP2PAtomicCapabilities, srcDeviceId is [%u], dstDeviceId is [%u], "
345 : "count is [%u]", srcDeviceId, dstDeviceId, count);
346 :
347 3 : ACL_REQUIRES_RTS_OK(rtDeviceGetP2PAtomicCapabilities(capabilities,
348 : reinterpret_cast<const rtAtomicOperation*>(operations), count, srcDeviceId, dstDeviceId));
349 :
350 1 : ACL_LOG_INFO("successfully execute aclrtDeviceGetP2PAtomicCapabilities");
351 1 : return ACL_SUCCESS;
352 3 : }
353 :
354 4 : aclError aclrtDeviceGetUuidImpl(int32_t deviceId, aclrtUuid *uuid)
355 : {
356 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtDeviceGetUuid);
357 4 : ACL_LOG_INFO("start to execute aclrtGetDeviceUuid, deviceId is [%d]", deviceId);
358 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(uuid);
359 3 : ACL_REQUIRES_RTS_OK_WARN_NOT_SUPPORT(rtGetDeviceUuid(deviceId, reinterpret_cast<rtUuid_t*>(uuid)), rtGetDeviceUuid);
360 :
361 1 : ACL_LOG_INFO("successfully execute aclrtGetDeviceUuid");
362 1 : return ACL_SUCCESS;
363 4 : }
364 :
365 3 : aclError aclrtGetDeviceResLimitImpl(int32_t deviceId, aclrtDevResLimitType type, uint32_t *value)
366 : {
367 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetDeviceResLimit);
368 3 : ACL_LOG_INFO("start to execute aclrtGetDeviceResLimit, deviceId is [%d], type is [%u]", deviceId,
369 : static_cast<uint32_t>(type));
370 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(value);
371 :
372 2 : ACL_REQUIRES_RTS_OK(rtsGetDeviceResLimit(deviceId, static_cast<rtDevResLimitType_t>(type), value));
373 :
374 1 : ACL_LOG_INFO("successfully execute aclrtGetDeviceResLimit");
375 1 : return ACL_SUCCESS;
376 3 : }
377 :
378 2 : aclError aclrtSetDeviceResLimitImpl(int32_t deviceId, aclrtDevResLimitType type, uint32_t value)
379 : {
380 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtSetDeviceResLimit);
381 2 : ACL_LOG_INFO("start to execute aclrtSetDeviceResLimit, deviceId is [%d], type is [%u], value is [%u]", deviceId,
382 : static_cast<uint32_t>(type), value);
383 :
384 2 : ACL_REQUIRES_RTS_OK(rtsSetDeviceResLimit(deviceId, static_cast<rtDevResLimitType_t>(type), value));
385 :
386 1 : ACL_LOG_INFO("successfully execute aclrtSetDeviceResLimit");
387 1 : return ACL_SUCCESS;
388 2 : }
389 :
390 2 : aclError aclrtResetDeviceResLimitImpl(int32_t deviceId)
391 : {
392 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtResetDeviceResLimit);
393 2 : ACL_LOG_INFO("start to execute aclrtResetDeviceResLimit, deviceId is [%d]", deviceId);
394 :
395 2 : ACL_REQUIRES_RTS_OK(rtsResetDeviceResLimit(deviceId));
396 :
397 1 : ACL_LOG_INFO("successfully execute aclrtResetDeviceResLimit");
398 1 : return ACL_SUCCESS;
399 2 : }
400 :
401 4 : aclError aclrtGetStreamResLimitImpl(aclrtStream stream, aclrtDevResLimitType type, uint32_t *value)
402 : {
403 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetStreamResLimit);
404 4 : ACL_LOG_INFO("start to execute aclrtGetStreamResLimit, type is [%u]", static_cast<uint32_t>(type));
405 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(value);
406 3 : ACL_REQUIRES_RTS_OK(rtsGetStreamResLimit(static_cast<rtStream_t>(stream), static_cast<rtDevResLimitType_t>(type), value));
407 :
408 1 : ACL_LOG_INFO("successfully execute aclrtGetStreamResLimit, value is [%u]", *value);
409 1 : return ACL_SUCCESS;
410 4 : }
411 :
412 3 : aclError aclrtSetStreamResLimitImpl(aclrtStream stream, aclrtDevResLimitType type, uint32_t value)
413 : {
414 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtSetStreamResLimit);
415 3 : ACL_LOG_INFO("start to execute aclrtSetStreamResLimit, type is [%u], value is [%u]", static_cast<uint32_t>(type), value);
416 3 : ACL_REQUIRES_RTS_OK(rtsSetStreamResLimit(static_cast<rtStream_t>(stream), static_cast<rtDevResLimitType_t>(type), value));
417 :
418 1 : ACL_LOG_INFO("successfully execute aclrtSetStreamResLimit");
419 1 : return ACL_SUCCESS;
420 3 : }
421 :
422 3 : aclError aclrtResetStreamResLimitImpl(aclrtStream stream)
423 : {
424 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtResetStreamResLimit);
425 3 : ACL_LOG_INFO("start to execute aclrtResetStreamResLimit");
426 3 : ACL_REQUIRES_RTS_OK(rtsResetStreamResLimit(static_cast<rtStream_t>(stream)));
427 :
428 1 : ACL_LOG_INFO("successfully execute aclrtResetStreamResLimit");
429 1 : return ACL_SUCCESS;
430 3 : }
431 :
432 3 : aclError aclrtUseStreamResInCurrentThreadImpl(aclrtStream stream)
433 : {
434 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtUseStreamResInCurrentThread);
435 3 : ACL_LOG_INFO("start to execute aclrtUseStreamResInCurrentThread");
436 3 : ACL_REQUIRES_RTS_OK(rtsUseStreamResInCurrentThread(static_cast<rtStream_t>(stream)));
437 :
438 1 : ACL_LOG_INFO("successfully execute aclrtUseStreamResInCurrentThread");
439 1 : return ACL_SUCCESS;
440 3 : }
441 :
442 3 : aclError aclrtUnuseStreamResInCurrentThreadImpl(aclrtStream stream)
443 : {
444 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtUnuseStreamResInCurrentThread);
445 3 : ACL_LOG_INFO("start to execute aclrtUnuseStreamResInCurrentThread");
446 3 : ACL_REQUIRES_RTS_OK(rtsNotUseStreamResInCurrentThread(static_cast<rtStream_t>(stream)));
447 :
448 1 : ACL_LOG_INFO("successfully execute aclrtUnuseStreamResInCurrentThread");
449 1 : return ACL_SUCCESS;
450 3 : }
451 :
452 3 : aclError aclrtGetResInCurrentThreadImpl(aclrtDevResLimitType type, uint32_t *value)
453 : {
454 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetResInCurrentThread);
455 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(value);
456 2 : ACL_REQUIRES_RTS_OK(rtsGetResInCurrentThread(static_cast<rtDevResLimitType_t>(type), value));
457 :
458 1 : return ACL_SUCCESS;
459 3 : }
460 :
461 3 : aclError aclrtGetDevicesTopoImpl(uint32_t deviceId, uint32_t otherDeviceId, uint64_t *value)
462 : {
463 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetDevicesTopo);
464 3 : ACL_LOG_INFO("start to execute aclrtGetDevicesTopo, deviceId is [%u], otherDeviceId is [%u]",
465 : deviceId, otherDeviceId);
466 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(value);
467 :
468 2 : ACL_REQUIRES_RTS_OK(rtsGetPairDevicesInfo(deviceId, otherDeviceId,
469 : static_cast<int32_t>(RT_DEVS_INFO_TYPE_TOPOLOGY), value));
470 :
471 1 : ACL_LOG_INFO("successfully execute aclrtGetDevicesTopo");
472 1 : return ACL_SUCCESS;
473 3 : }
474 :
475 2 : aclError aclrtGetLogicDevIdByUserDevIdImpl(const int32_t userDevid, int32_t *const logicDevId)
476 : {
477 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetLogicDevIdByUserDevId);
478 2 : ACL_LOG_INFO("start to execute aclrtGetLogicDevIdByUserDevId, userDevid is [%d]", userDevid);
479 2 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(logicDevId);
480 2 : ACL_REQUIRES_RTS_OK(rtsGetLogicDevIdByUserDevId(userDevid, logicDevId));
481 :
482 1 : ACL_LOG_INFO("successfully execute aclrtGetLogicDevIdByUserDevId");
483 1 : return ACL_SUCCESS;
484 2 : }
485 :
486 2 : aclError aclrtGetUserDevIdByLogicDevIdImpl(const int32_t logicDevId, int32_t *const userDevid)
487 : {
488 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetUserDevIdByLogicDevId);
489 2 : ACL_LOG_INFO("start to execute aclrtGetUserDevIdByLogicDevId, logicDevId is [%d]", logicDevId);
490 2 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(userDevid);
491 2 : ACL_REQUIRES_RTS_OK(rtsGetUserDevIdByLogicDevId(logicDevId, userDevid));
492 :
493 1 : ACL_LOG_INFO("successfully execute aclrtGetUserDevIdByLogicDevId");
494 1 : return ACL_SUCCESS;
495 2 : }
496 :
497 2 : aclError aclrtGetLogicDevIdByPhyDevIdImpl(int32_t phyDevId, int32_t *const logicDevId)
498 : {
499 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetLogicDevIdByPhyDevId);
500 2 : ACL_LOG_INFO("start to execute aclrtGetLogicDevIdByPhyDevId, phyDevId is [%d]", phyDevId);
501 2 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(logicDevId);
502 2 : ACL_REQUIRES_RTS_OK(rtsGetLogicDevIdByPhyDevId(phyDevId, logicDevId));
503 :
504 1 : ACL_LOG_INFO("successfully execute aclrtGetLogicDevIdByPhyDevId");
505 1 : return ACL_SUCCESS;
506 2 : }
507 :
508 2 : aclError aclrtGetPhyDevIdByLogicDevIdImpl(int32_t logicDevId, int32_t *const phyDevId)
509 : {
510 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetPhyDevIdByLogicDevId);
511 2 : ACL_LOG_INFO("start to execute aclrtGetPhyDevIdByLogicDevId, logicDevId is [%d]", logicDevId);
512 2 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(phyDevId);
513 2 : ACL_REQUIRES_RTS_OK(rtsGetPhyDevIdByLogicDevId(logicDevId, phyDevId));
514 :
515 1 : ACL_LOG_INFO("successfully execute aclrtGetPhyDevIdByLogicDevId");
516 1 : return ACL_SUCCESS;
517 2 : }
518 :
519 4 : aclError aclrtGetUserDevIdByPhyDevIdImpl(const int32_t phyDevId, int32_t *const userDevId)
520 : {
521 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetUserDevIdByPhyDevId);
522 4 : ACL_LOG_INFO("start to execute aclrtGetUserDevIdByPhyDevId, phyDevId is [%d]", phyDevId);
523 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(userDevId);
524 3 : ACL_REQUIRES_RTS_OK(rtsGetLogicDevIdByPhyDevId(phyDevId, userDevId));
525 :
526 2 : ACL_LOG_INFO("successfully execute aclrtGetUserDevIdByPhyDevId");
527 2 : return ACL_SUCCESS;
528 4 : }
529 :
530 4 : aclError aclrtGetPhyDevIdByUserDevIdImpl(const int32_t userDevId, int32_t *const phyDevId)
531 : {
532 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetPhyDevIdByUserDevId);
533 4 : ACL_LOG_INFO("start to execute aclrtGetPhyDevIdByUserDevId, userDevId is [%d]", userDevId);
534 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(phyDevId);
535 3 : ACL_REQUIRES_RTS_OK(rtsGetPhyDevIdByLogicDevId(userDevId, phyDevId));
536 :
537 2 : ACL_LOG_INFO("successfully execute aclrtGetPhyDevIdByUserDevId");
538 2 : return ACL_SUCCESS;
539 4 : }
540 :
541 3 : aclError aclrtGetOpExecuteTimeoutImpl(uint32_t *const timeoutMs)
542 : {
543 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtGetOpExecuteTimeout);
544 3 : ACL_LOG_INFO("start to execute aclrtGetOpExecuteTimeout");
545 3 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(timeoutMs);
546 2 : ACL_REQUIRES_RTS_OK(rtGetOpExecuteTimeoutV2(timeoutMs));
547 1 : ACL_LOG_INFO("successfully execute aclrtGetOpExecuteTimeout");
548 1 : return ACL_SUCCESS;
549 3 : }
550 :
551 2 : aclError aclrtCheckArchCompatibilityImpl(const char *socVersion, int32_t *canCompatible)
552 : {
553 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtCheckArchCompatibility);
554 2 : ACL_LOG_INFO("start to execute aclrtCheckArchCompatibility");
555 2 : ACL_REQUIRES_RTS_OK(rtCheckArchCompatibility(socVersion, canCompatible));
556 1 : ACL_LOG_INFO("successfully execute aclrtCheckArchCompatibility");
557 1 : return ACL_SUCCESS;
558 2 : }
559 : #ifdef __cplusplus
560 : }
561 : #endif
|