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 <atomic>
11 : #include "acl_dump.h"
12 : #include "log/adx_log.h"
13 : #include "adump_api.h"
14 : #include "dump_manager.h"
15 :
16 : namespace Adx {
17 : uint64_t g_chunk[RING_CHUNK_SIZE + MAX_TENSOR_NUM] = {0};
18 : namespace {
19 : std::atomic<uint64_t> g_writeIdx{0};
20 : uint32_t g_atomicIndex = 0x2000;
21 : } // namespace
22 :
23 3 : void *AdumpGetSizeInfoAddr(uint32_t space, uint32_t &atomicIndex)
24 : {
25 3 : if (space > MAX_TENSOR_NUM) {
26 1 : return nullptr;
27 : }
28 :
29 2 : atomicIndex = g_atomicIndex++;
30 2 : auto nextWriteCursor = g_writeIdx.fetch_add(space);
31 2 : return g_chunk + (nextWriteCursor % RING_CHUNK_SIZE);
32 : }
33 :
34 2 : int32_t AdumpRegisterCallback(uint32_t moduleId, AdumpCallback enableFunc, AdumpCallback disableFunc)
35 : {
36 2 : return DumpManager::Instance().RegisterCallback(moduleId, enableFunc, disableFunc);
37 : }
38 : } // namespace Adx
39 :
40 : /**
41 : * @ingroup AscendCL
42 : * @brief Get Exception Dump path.
43 : *
44 : * @retval path for success
45 : * @retval NULL for failed
46 : */
47 1 : const char* acldumpGetPath(acldumpType dumpType)
48 : {
49 : UNUSED(dumpType);
50 1 : return nullptr;
51 : }
|