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 "aicpu_comm_destroy_func.h"
12 : #include "kfc.h"
13 : #include "communicator_impl_lite.h"
14 : #include "communicator_impl_lite_manager.h"
15 :
16 : namespace Hccl {
17 :
18 7 : AicpuCommDestroyFunc& AicpuCommDestroyFunc::GetInstance()
19 : {
20 7 : static AicpuCommDestroyFunc func;
21 7 : return func;
22 : }
23 :
24 1 : void AicpuCommDestroyFunc::Call()
25 : {
26 1 : std::vector<CommunicatorImplLite*> commLites = CommunicatorImplLiteMgr::GetInstance().GetAll();
27 3 : for (auto& comm : commLites) {
28 2 : if (!comm->IsCommReady()) {
29 2 : continue;
30 : }
31 :
32 0 : KfcCommand cmd = comm->BackGroundGetCmd();
33 0 : if (cmd != KfcCommand::DESTROY_AICPU_COMM) {
34 0 : continue;
35 : }
36 0 : HCCL_INFO("Received KfcCommand[DESTROY_AICPU_COMM]");
37 0 : comm->BackGroundSetStatus(KfcStatus::DESTROY_AICPU_COMM_DONE);
38 0 : auto idIndex = comm->GetCommIdIndex();
39 0 : CommunicatorImplLiteMgr::GetInstance().DestroyComm(idIndex);
40 0 : HCCL_INFO("Send KfcStatus[DESTROY_AICPU_COMM_DONE]");
41 : }
42 1 : }
43 :
44 : } // namespace Hccl
|