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 : #include <cstdarg>
11 : #include "set_device_vxx.h"
12 : #include "acl_rt_impl.h"
13 : #include "toolchain/dump_shim.h"
14 : #include "adump_pub.h"
15 : #include "adx_datadump_server.h"
16 :
17 : namespace {
18 35 : int32_t SetDumpConfigByShim(const acl::AdumpDumpConfigInfo& configInfo)
19 : {
20 : Adx::DumpConfigInfo adxConfigInfo;
21 35 : adxConfigInfo.dumpConfigPath = configInfo.dumpConfigPath;
22 35 : adxConfigInfo.dumpConfigData = configInfo.dumpConfigData;
23 35 : adxConfigInfo.dumpConfigSize = configInfo.dumpConfigSize;
24 70 : return Adx::AdumpSetDumpConfig(adxConfigInfo);
25 : }
26 :
27 1 : __attribute__((constructor)) void InitializeAscendDump()
28 : {
29 : acl::AdumpCallbacks callbacks;
30 1 : callbacks.setDumpConfig = &SetDumpConfigByShim;
31 1 : callbacks.unsetDump = &Adx::AdumpUnSetDump;
32 1 : callbacks.serverInit = &AdxDataDumpServerInit;
33 1 : callbacks.serverUnInit = &AdxDataDumpServerUnInit;
34 1 : acl::SetAdumpCallbacks(callbacks);
35 1 : }
36 : } // namespace
37 :
38 199 : ACL_FUNC_MAP(ACL_RT_CPP)
39 :
40 : #ifdef ACL_RT_API_HOOK_ENABLE
41 :
42 : #if __GNUC__ >= 8
43 : #pragma GCC diagnostic push
44 : #pragma GCC diagnostic ignored "-Wcast-function-type"
45 : #endif // __GNUC__ >= 8
46 :
47 1692 : ACL_RT_FUNC_MAP(ACL_RT_CPP_HOOKABLE)
48 29 : ACL_RT_ALLOCATOR_FUNC_MAP(ACL_RT_CPP_HOOKABLE)
49 101 : ACL_MDLRI_FUNC_MAP(ACL_RT_CPP_HOOKABLE)
50 :
51 : #if __GNUC__ >= 8
52 : #pragma GCC diagnostic pop
53 : #endif // __GNUC__ >= 8
54 :
55 : #else // ACL_RT_API_HOOK_ENABLE
56 :
57 : ACL_RT_FUNC_MAP(ACL_RT_CPP)
58 : ACL_RT_ALLOCATOR_FUNC_MAP(ACL_RT_CPP)
59 : ACL_MDLRI_FUNC_MAP(ACL_RT_CPP)
60 :
61 : #endif // ACL_RT_API_HOOK_ENABLE
62 :
63 50 : ACL_MDL_FUNC_MAP(ACL_RT_CPP)
64 :
65 9 : void aclAppLog(aclLogLevel logLevel, const char* func, const char* file, uint32_t line, const char* fmt, ...)
66 : {
67 : va_list args;
68 9 : va_start(args, fmt);
69 9 : aclAppLogImpl(logLevel, func, file, line, fmt, args);
70 9 : va_end(args);
71 9 : }
72 :
73 1 : extern "C" ACL_FUNC_VISIBILITY void aclAppLogWithArgs(
74 : aclLogLevel logLevel, const char* func, const char* file, uint32_t line, const char* fmt, va_list args)
75 : {
76 1 : aclAppLogImpl(logLevel, func, file, line, fmt, args);
77 1 : }
78 :
79 11 : ACL_FUNC_VISIBILITY aclError aclrtApiInjectionSetFunc(const char* name, aclrtApiFunc func)
80 : {
81 11 : return aclrtApiInjectionSetFuncImpl(name, func);
82 : }
83 :
84 : ACL_FUNC_VISIBILITY aclError
85 23 : aclrtApiInjectionGetFunc(const char* name, aclrtApiFunc* originFunc, aclrtApiFunc* currentFunc)
86 : {
87 23 : return aclrtApiInjectionGetFuncImpl(name, originFunc, currentFunc);
88 : }
|