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 "runtime/rts/rts_snapshot.h"
13 : #include "common/log_inner.h"
14 : #include "common/error_codes_inner.h"
15 : #include "common/prof_reporter.h"
16 : #include "mmpa/mmpa_api.h"
17 :
18 : #ifdef __cplusplus
19 : extern "C" {
20 : #endif
21 :
22 4 : aclError aclrtSnapShotProcessLockImpl(int pid, void* reserve)
23 : {
24 4 : ACL_PROFILING_REG(acl::AclProfType::AclrtSnapShotProcessLock);
25 4 : ACL_LOG_INFO("start to execute aclrtSnapShotProcessLock, pid=%d, reserve=%p", pid, reserve);
26 :
27 7 : ACL_CHECK_INVALID_PARAM_WITH_REASON(
28 : pid != static_cast<int32_t>(mmGetPid()), pid,
29 : "pid must be current process pid, cross-process operation is not supported");
30 :
31 3 : ACL_CHECK_INVALID_PARAM_NO_VALUE(
32 : reserve == nullptr, "reserve", "reserve is a reserved parameter and must be nullptr");
33 :
34 2 : ACL_REQUIRES_RTS_OK(rtSnapShotProcessLock());
35 :
36 1 : ACL_LOG_INFO("successfully execute aclrtSnapShotProcessLock");
37 1 : return ACL_SUCCESS;
38 4 : }
39 :
40 2 : aclError aclrtSnapShotProcessUnlockImpl(int pid, void* reserve)
41 : {
42 2 : ACL_PROFILING_REG(acl::AclProfType::AclrtSnapShotProcessUnlock);
43 2 : ACL_LOG_INFO("start to execute aclrtSnapShotProcessUnlock, pid=%d, reserve=%p", pid, reserve);
44 :
45 2 : ACL_CHECK_INVALID_PARAM_WITH_REASON(
46 : pid != static_cast<int32_t>(mmGetPid()), pid,
47 : "pid must be current process pid, cross-process operation is not supported");
48 :
49 2 : ACL_CHECK_INVALID_PARAM_NO_VALUE(
50 : reserve == nullptr, "reserve", "reserve is a reserved parameter and must be nullptr");
51 :
52 2 : ACL_REQUIRES_RTS_OK(rtSnapShotProcessUnlock());
53 :
54 1 : ACL_LOG_INFO("successfully execute aclrtSnapShotProcessUnlock");
55 1 : return ACL_SUCCESS;
56 2 : }
57 :
58 3 : aclError aclrtSnapShotProcessBackupImpl(int pid, aclrtSnapShotBackupArgs* args)
59 : {
60 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtSnapShotProcessBackup);
61 3 : ACL_LOG_INFO("start to execute aclrtSnapShotProcessBackup, pid=%d, args=%p", pid, args);
62 :
63 3 : ACL_CHECK_INVALID_PARAM_WITH_REASON(
64 : pid != static_cast<int32_t>(mmGetPid()), pid,
65 : "pid must be current process pid, cross-process operation is not supported");
66 :
67 3 : ACL_CHECK_INVALID_PARAM_NO_VALUE(args == nullptr, "args", "args is a reserved parameter and must be nullptr");
68 :
69 2 : ACL_REQUIRES_RTS_OK(rtSnapShotProcessBackup());
70 :
71 1 : ACL_LOG_INFO("successfully execute aclrtSnapShotProcessBackup");
72 1 : return ACL_SUCCESS;
73 3 : }
74 :
75 3 : aclError aclrtSnapShotProcessRestoreImpl(int pid, aclrtSnapShotRestoreArgs* args)
76 : {
77 3 : ACL_PROFILING_REG(acl::AclProfType::AclrtSnapShotProcessRestore);
78 3 : ACL_LOG_INFO("start to execute aclrtSnapShotProcessRestore, pid=%d, args=%p", pid, args);
79 :
80 3 : ACL_CHECK_INVALID_PARAM_WITH_REASON(
81 : pid != static_cast<int32_t>(mmGetPid()), pid,
82 : "pid must be current process pid, cross-process operation is not supported");
83 :
84 3 : ACL_CHECK_INVALID_PARAM_NO_VALUE(args == nullptr, "args", "args is a reserved parameter and must be nullptr");
85 :
86 2 : ACL_REQUIRES_RTS_OK(rtSnapShotProcessRestore());
87 :
88 1 : ACL_LOG_INFO("successfully execute aclrtSnapShotProcessRestore");
89 1 : return ACL_SUCCESS;
90 3 : }
91 :
92 1 : aclError aclrtSnapShotCallbackRegisterImpl(aclrtSnapShotStage stage, aclrtSnapShotCallBack callback, void* args)
93 : {
94 1 : ACL_LOG_INFO("start to execute aclrtSnapShotCallbackRegister");
95 1 : ACL_REQUIRES_RTS_OK(rtSnapShotCallbackRegister(
96 : static_cast<rtSnapShotStage>(stage), static_cast<rtSnapShotCallBack>(callback), args));
97 0 : ACL_LOG_INFO("successfully execute aclrtSnapShotCallbackRegister");
98 0 : return ACL_SUCCESS;
99 : }
100 :
101 1 : aclError aclrtSnapShotCallbackUnregisterImpl(aclrtSnapShotStage stage, aclrtSnapShotCallBack callback)
102 : {
103 1 : ACL_LOG_INFO("start to execute aclrtSnapShotCallbackUnregister");
104 1 : ACL_REQUIRES_RTS_OK(
105 : rtSnapShotCallbackUnregister(static_cast<rtSnapShotStage>(stage), static_cast<rtSnapShotCallBack>(callback)));
106 0 : ACL_LOG_INFO("successfully execute aclrtSnapShotCallbackUnregister");
107 0 : return ACL_SUCCESS;
108 : }
109 : #ifdef __cplusplus
110 : }
111 : #endif
|