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 : #include "hccl/hccl_res_expt.h"
12 : #include "hccl_comm_pub.h"
13 : #include "coll_comm_config_consistency.h"
14 :
15 : using namespace hccl;
16 :
17 1 : HcclResult HcclCommAddExchangeInfo(HcclComm comm, const void* data, uint32_t length)
18 : {
19 1 : CHK_PTR_NULL(comm);
20 1 : CHK_PTR_NULL(data);
21 1 : CHK_PRT_RET(length == 0, HCCL_ERROR("[HcclCommAddExchangeInfo] length is 0."), HCCL_E_PARA);
22 1 : hccl::hcclComm* hcclComm = static_cast<hccl::hcclComm*>(comm);
23 1 : hccl::CollComm* collComm = hcclComm->GetCollComm();
24 1 : CHK_PTR_NULL(collComm);
25 1 : hccl::MyRank* myRank = collComm->GetMyRank();
26 1 : CHK_PTR_NULL(myRank);
27 1 : CollCommConfigConsistency& collCommConfigConsistency = myRank->GetCollCommConfigConsistency();
28 1 : return collCommConfigConsistency.AddExchangeInfo(data, length);
29 : }
30 :
31 : HcclResult
32 1 : HcclCommGetExchangeInfo(HcclComm comm, uint32_t remoteRank, uint32_t length, void* data, uint32_t* actualLength)
33 : {
34 1 : CHK_PTR_NULL(comm);
35 1 : CHK_PTR_NULL(data);
36 1 : CHK_PTR_NULL(actualLength);
37 1 : hccl::hcclComm* hcclComm = static_cast<hccl::hcclComm*>(comm);
38 1 : hccl::CollComm* collComm = hcclComm->GetCollComm();
39 1 : CHK_PTR_NULL(collComm);
40 1 : hccl::MyRank* myRank = collComm->GetMyRank();
41 1 : CHK_PTR_NULL(myRank);
42 1 : CollCommConfigConsistency& collCommConfigConsistency = myRank->GetCollCommConfigConsistency();
43 1 : return collCommConfigConsistency.GetExchangeInfo(remoteRank, length, data, actualLength);
44 : }
45 :
46 1 : HcclResult HcclCommResetExchangeInfo(HcclComm comm)
47 : {
48 1 : CHK_PTR_NULL(comm);
49 1 : hccl::hcclComm* hcclComm = static_cast<hccl::hcclComm*>(comm);
50 1 : hccl::CollComm* collComm = hcclComm->GetCollComm();
51 1 : CHK_PTR_NULL(collComm);
52 1 : hccl::MyRank* myRank = collComm->GetMyRank();
53 1 : CHK_PTR_NULL(myRank);
54 1 : CollCommConfigConsistency& collCommConfigConsistency = myRank->GetCollCommConfigConsistency();
55 1 : return collCommConfigConsistency.ResetExchangeInfo();
56 : }
|