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_SRC_DLHALFUNCTION_H
12 : #define HCCL_SRC_DLHALFUNCTION_H
13 :
14 : #include <functional>
15 : #include <mutex>
16 : #include <hccl/hccl_types.h>
17 :
18 : #include "hccl/base.h"
19 : #include "ascend_hal.h"
20 : #include "ascend_hal_define.h"
21 :
22 : namespace hccl {
23 : class DlHalFunction {
24 : public:
25 : virtual ~DlHalFunction();
26 : static DlHalFunction& GetInstance();
27 : HcclResult DlHalFunctionInit();
28 : std::function<drvError_t(unsigned int, struct event_summary*)> dlHalEschedSubmitEvent;
29 : std::function<drvError_t(unsigned int)> dlHalEschedAttachDevice;
30 : std::function<drvError_t(int*)> dlHalGetAPIVersion;
31 : std::function<drvError_t(unsigned int, unsigned int, GROUP_TYPE)> dlHalEschedCreateGrp;
32 : std::function<drvError_t(
33 : unsigned int, unsigned int, void (*ackFunc)(unsigned int, unsigned int, u8*, unsigned int))>
34 : dlHalEschedRegisterAckFunc;
35 : std::function<drvError_t(int, unsigned int*, unsigned int*, unsigned int*, unsigned int*)>
36 : dlHalDrvQueryProcessHostPid;
37 : std::function<DVresult(
38 : unsigned long long dst, unsigned long long destMax, unsigned long long src, unsigned long long count)>
39 : dlDrvMemCpy;
40 : std::function<drvError_t(uint32_t*)> dlHalDrvGetDevNum;
41 : std::function<drvError_t(uint32_t, int32_t, int32_t, int64_t*)> dlHalGetDeviceInfo;
42 : std::function<pid_t(void)> dlDrvDeviceGetBareTgid;
43 : std::function<drvError_t(GroupQueryCmdType, void*, unsigned int, void*, unsigned int*)> dlHalGrpQuery;
44 : std::function<drvError_t(unsigned int devId)> dlHalEschedDettachDevice;
45 : std::function<drvError_t(uint32_t*)> dlHalDrvGetPlatformInfo;
46 : std::function<drvError_t(uint32_t, halChipInfo*)> dlHalGetChipInfo;
47 : std::function<drvError_t(BIND_CGROUP_TYPE)> dlHalBindCgroup;
48 : std::function<drvError_t(void*, uint64_t, uint32_t, uint32_t, void**)> dlHalHostRegister;
49 : std::function<drvError_t(void*, uint32_t)> dlHalHostUnregister;
50 : std::function<drvError_t(void*, uint32_t, uint32_t)> dlHalHostUnregisterEx;
51 : std::function<drvError_t(int, void*, size_t, void*, size_t*)> dlHalMemCtl;
52 : std::function<drvError_t(uint32_t, struct halSensorNodeCfg*, uint64_t*)> dlHalSensorNodeRegister;
53 : std::function<drvError_t(uint32_t, uint64_t)> dlHalSensorNodeUnregister;
54 : std::function<drvError_t(uint32_t, uint64_t, int, halGeneralEventType_t)> dlHalSensorNodeUpdateState;
55 1060 : bool DlHalFunctionIsInit()
56 : {
57 1060 : std::lock_guard<std::mutex> lock(handleMutex_);
58 1060 : return (handle_ != nullptr);
59 1060 : }
60 :
61 : protected:
62 : private:
63 : void* handle_;
64 : std::mutex handleMutex_;
65 : DlHalFunction(const DlHalFunction&);
66 : DlHalFunction& operator=(const DlHalFunction&);
67 : DlHalFunction();
68 : HcclResult DlHalFunctionEschedInit();
69 : };
70 : } // namespace hccl
71 :
72 : #endif // HCCL_SRC_DLHALFUNCTION_H
|