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 : #ifndef HCCL_SO_MANAGER_H
12 : #define HCCL_SO_MANAGER_H
13 :
14 : #include <unordered_map>
15 : #include <mutex>
16 : #include <vector>
17 : #include "hccl/hccl_ex.h"
18 : #include "common/bqs_log.h"
19 :
20 : namespace dgw {
21 : using HcclInitCommFunc = HcclResult (*)(const char_t*, uint32_t, const CommAttr*, HcclComm*);
22 : using HcclFinalizeCommFunc = HcclResult (*)(HcclComm);
23 :
24 : // MPI API
25 : using HcclIsendFunc = int32_t (*)(void*, int32_t, HcclDataType, int32_t, int32_t, HcclComm, HcclRequest*);
26 : using HcclImrecvFunc = int32_t (*)(void*, int32_t, HcclDataType, HcclMessage*, HcclRequest*);
27 : using HcclImprobeFunc = int32_t (*)(int32_t, int32_t, HcclComm, int32_t*, HcclMessage*, HcclStatus*);
28 : using HcclGetCountFunc = int32_t (*)(const HcclStatus*, HcclDataType, int32_t*);
29 : using HcclTestSomeFunc = int32_t (*)(int32_t, HcclRequest[], int32_t*, int32_t[], HcclStatus[]);
30 :
31 : using HcclRegisterMemoryFunc = HcclResult (*)(HcclComm, void*, uint64_t);
32 : using HcclUnregisterMemoryFunc = HcclResult (*)(HcclComm, void*);
33 : using HcclSetGrpIdCallback = HcclResult (*)(int32_t (*)(int32_t, int32_t*, int32_t*));
34 :
35 : class HcclSoManager {
36 : public:
37 : static HcclSoManager* GetInstance();
38 :
39 : virtual ~HcclSoManager();
40 :
41 : /**
42 : * load hccl so
43 : */
44 : void LoadSo();
45 :
46 : /**
47 : * unload hccl so
48 : */
49 : void UnloadSo();
50 :
51 : /**
52 : * get function
53 : * @param name hccl function name
54 : * @return void *
55 : */
56 : void* GetFunc(const std::string& name) const;
57 :
58 : private:
59 1 : HcclSoManager() = default;
60 :
61 : std::unordered_map<std::string, void*> funcMap_;
62 : void* soHandle_ = nullptr;
63 : };
64 : } // namespace dgw
65 : #endif // HCCL_SO_MANAGER_H
|