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 "coll_comm_c_adpt.h"
11 : #include "coll_comm_mgr.h"
12 : #include <memory>
13 :
14 : using namespace hccl;
15 : static std::unique_ptr<CollCommMgr> g_collCommMgr = std::make_unique<CollCommMgr>();
16 :
17 : /**
18 : * @note 职责:集合通信的通信域管理的C接口的C到C++适配
19 : */
20 :
21 3 : HcclResult HcclCommGetStatus(const char * commId, HcclCommStatus *status)
22 : {
23 3 : CHK_PTR_NULL(commId);
24 3 : CHK_PTR_NULL(status);
25 2 : HcclComm comm = nullptr;
26 : // 公共流程, 需要同时获取单算子和图模式的通信域
27 2 : CHK_RET(HcomGetCommHandleByGroup(commId, &comm));
28 2 : CHK_PRT_RET(comm == nullptr, HCCL_ERROR("%s hcclComm is nullptr, commId[%s]", __func__, commId), HCCL_E_PTR);
29 2 : return static_cast<hccl::hcclComm*>(comm)->GetCommStatus(*status);
30 : }
31 :
32 : /**
33 : * @note C接口适配参考示例
34 : * @code {.c}
35 : * HcclResult HcclCommDestroy(HcclComm comm) {
36 : * return g_collCommMgr->DestroyComm(comm);
37 : * }
38 : * @endcode
39 : */
|