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 "hccl/hcom.h"
12 : #include "hccl/hccl_ex.h"
13 : #include "common/bqs_log.h"
14 : #include "hccl/hccl_so_manager.h"
15 :
16 0 : HcclResult HcclInitComm(const char_t *rankTableM, uint32_t rank, const CommAttr *attr, HcclComm *comm)
17 : {
18 0 : void * const func = dgw::HcclSoManager::GetInstance()->GetFunc("HcclInitComm");
19 0 : if (func == nullptr) {
20 0 : DGW_LOG_ERROR("libhccl.so can't get function [HcclInitComm]");
21 0 : return HCCL_E_RESERVED;
22 : }
23 0 : return (PtrToFunctionPtr<void, dgw::HcclInitCommFunc>(func))(rankTableM, rank, attr, comm);
24 : }
25 :
26 0 : HcclResult HcclFinalizeComm(HcclComm comm)
27 : {
28 0 : void * const func = dgw::HcclSoManager::GetInstance()->GetFunc("HcclFinalizeComm");
29 0 : if (func == nullptr) {
30 0 : DGW_LOG_ERROR("libhccl.so can't get function [HcclFinalizeComm]");
31 0 : return HCCL_E_RESERVED;
32 : }
33 0 : return (PtrToFunctionPtr<void, dgw::HcclFinalizeCommFunc>(func))(comm);
34 : }
35 :
36 0 : int HcclIsend(void *buffer, int count, HcclDataType dataType,
37 : int dstRank, int tag, HcclComm comm, HcclRequest *request)
38 : {
39 0 : void * const func = dgw::HcclSoManager::GetInstance()->GetFunc("HcclIsend");
40 0 : if (func == nullptr) {
41 0 : DGW_LOG_ERROR("libhccl.so can't get function [HcclIsend]");
42 0 : return HCCL_E_RESERVED;
43 : }
44 0 : return (PtrToFunctionPtr<void, dgw::HcclIsendFunc>(func))(buffer, count, dataType, dstRank, tag, comm, request);
45 : }
46 :
47 0 : int HcclImrecv(void *buffer, int count, HcclDataType datatype, HcclMessage *msg, HcclRequest *request)
48 : {
49 0 : void * const func = dgw::HcclSoManager::GetInstance()->GetFunc("HcclImrecv");
50 0 : if (func == nullptr) {
51 0 : DGW_LOG_ERROR("libhccl.so can't get function [HcclImrecv]");
52 0 : return HCCL_E_RESERVED;
53 : }
54 0 : return (PtrToFunctionPtr<void, dgw::HcclImrecvFunc>(func))(buffer, count, datatype, msg, request);
55 : }
56 :
57 0 : int HcclImprobe(int srcRank, int tag, HcclComm comm, int *flag, HcclMessage *msg, HcclStatus *status)
58 : {
59 0 : void * const func = dgw::HcclSoManager::GetInstance()->GetFunc("HcclImprobe");
60 0 : if (func == nullptr) {
61 0 : DGW_LOG_ERROR("libhccl.so can't get function [HcclImprobe]");
62 0 : return HCCL_E_RESERVED;
63 : }
64 0 : return (PtrToFunctionPtr<void, dgw::HcclImprobeFunc>(func))(srcRank, tag, comm, flag, msg, status);
65 : }
66 :
67 0 : int HcclGetCount(const HcclStatus *status, HcclDataType dataType, int *count)
68 : {
69 0 : void * const func = dgw::HcclSoManager::GetInstance()->GetFunc("HcclGetCount");
70 0 : if (func == nullptr) {
71 0 : DGW_LOG_ERROR("libhccl.so can't get function [HcclGetCount]");
72 0 : return HCCL_E_RESERVED;
73 : }
74 0 : return (PtrToFunctionPtr<void, dgw::HcclGetCountFunc>(func))(status, dataType, count);
75 : }
76 :
77 0 : int HcclTestSome(int count, HcclRequest requestArray[], int *compCount, int compIndices[], HcclStatus compStatus[])
78 : {
79 0 : void * const func = dgw::HcclSoManager::GetInstance()->GetFunc("HcclTestSome");
80 0 : if (func == nullptr) {
81 0 : DGW_LOG_ERROR("libhccl.so can't get function [HcclTestSome]");
82 0 : return HCCL_E_RESERVED;
83 : }
84 0 : return (PtrToFunctionPtr<void, dgw::HcclTestSomeFunc>(func))(count, requestArray, compCount, compIndices, compStatus);
85 : }
86 :
87 0 : HcclResult HcclRegisterMemory(HcclComm comm, void *addr, uint64_t size)
88 : {
89 0 : void * const func = dgw::HcclSoManager::GetInstance()->GetFunc("HcclRegisterMemory");
90 0 : if (func == nullptr) {
91 0 : DGW_LOG_ERROR("libhccl.so can't get function [HcclRegisterMemory]");
92 0 : return HCCL_E_RESERVED;
93 : }
94 0 : return (PtrToFunctionPtr<void, dgw::HcclRegisterMemoryFunc>(func))(comm, addr, size);
95 : }
96 :
97 0 : HcclResult HcclUnregisterMemory(HcclComm comm, void *addr)
98 : {
99 0 : void * const func = dgw::HcclSoManager::GetInstance()->GetFunc("HcclUnregisterMemory");
100 0 : if (func == nullptr) {
101 0 : DGW_LOG_ERROR("libhccl.so can't get function [HcclUnregisterMemory]");
102 0 : return HCCL_E_RESERVED;
103 : }
104 0 : return (PtrToFunctionPtr<void, dgw::HcclUnregisterMemoryFunc>(func))(comm, addr);
105 : }
106 :
107 0 : HcclResult HcclSetGrpIdCallback(int32_t(*grpIdCallback)(int32_t, int32_t*, int32_t*))
108 : {
109 0 : void * const func = dgw::HcclSoManager::GetInstance()->GetFunc("HcclSetGrpIdCallback");
110 0 : if (func == nullptr) {
111 0 : DGW_LOG_ERROR("libhccl.so can't get function [HcclSetGrpIdCallback]");
112 0 : return HCCL_E_RESERVED;
113 : }
114 0 : return (PtrToFunctionPtr<void, dgw::HcclSetGrpIdCallback>(func))(grpIdCallback);
115 : }
|