Line data Source code
1 : /**
2 : * Copyright (c) 2026 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 : #ifndef THREAD_AICPU_MGR_H
12 : #define THREAD_AICPU_MGR_H
13 :
14 : #include "common.h"
15 : #include "aicpu_launch_manager.h"
16 : #include "thread.h"
17 : #include "hcclCommDfxLite.h"
18 : #include <shared_mutex>
19 : #include <vector>
20 : #include <memory>
21 : #include <functional>
22 :
23 : using namespace hccl;
24 :
25 : namespace hccl {
26 : class AicpuTsThread;
27 : }
28 :
29 : class ThreadAicpuMgr {
30 : public:
31 : ThreadAicpuMgr(HcclCommDfxLite& dfx, std::function<HcclResult(bool)> checkExecStatusCallback);
32 : ~ThreadAicpuMgr();
33 : HcclResult InitThreads(ThreadMgrAicpuParam* param);
34 10 : const std::vector<std::shared_ptr<Thread>>& GetAllThread() { return threads_; }
35 10 : std::shared_mutex& GetThreadMutex() { return threadMutex_; }
36 :
37 : private:
38 : HcclResult RegisterThreadAddDfxTaskInfo(ThreadHandle thread);
39 : HcclResult RegisterThreadCacheCallback(AicpuTsThread* thread);
40 :
41 : std::shared_mutex threadMutex_;
42 : std::vector<std::shared_ptr<Thread>> threads_;
43 : HcclCommDfxLite& dfx_;
44 : std::function<HcclResult(bool)> checkExecStatusCallback_;
45 : };
46 :
47 : #endif // THREAD_AICPU_MGR_H
|