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(unsigned int, unsigned int,
33 : void (*ackFunc)(unsigned int, unsigned int, u8 *, unsigned int))> dlHalEschedRegisterAckFunc;
34 : std::function<drvError_t(int, unsigned int *, unsigned int *,
35 : unsigned int *, unsigned int *)> dlHalDrvQueryProcessHostPid;
36 : std::function<DVresult(unsigned long long dst, unsigned long long destMax,
37 : unsigned long long src, unsigned long long count)> dlDrvMemCpy;
38 : std::function<drvError_t(uint32_t *)> dlHalDrvGetDevNum;
39 : std::function<drvError_t(uint32_t, int32_t, int32_t, int64_t *)> dlHalGetDeviceInfo;
40 : std::function<pid_t(void)> dlDrvDeviceGetBareTgid;
41 : std::function<drvError_t(GroupQueryCmdType, void *, unsigned int, void *, unsigned int *)> dlHalGrpQuery;
42 : std::function<drvError_t(unsigned int devId)> dlHalEschedDettachDevice;
43 : std::function<drvError_t(uint32_t *)> dlHalDrvGetPlatformInfo;
44 : std::function<drvError_t(uint32_t, halChipInfo *)> dlHalGetChipInfo;
45 : std::function<drvError_t(BIND_CGROUP_TYPE)> dlHalBindCgroup;
46 : std::function<drvError_t(void *, uint64_t, uint32_t, uint32_t, void **)> dlHalHostRegister;
47 : std::function<drvError_t(void *, uint32_t)> dlHalHostUnregister;
48 : std::function<drvError_t(void *, uint32_t, uint32_t)> dlHalHostUnregisterEx;
49 : std::function<drvError_t(int, void*, size_t, void*, size_t*)> dlHalMemCtl;
50 : std::function<drvError_t(uint32_t, struct halSensorNodeCfg *, uint64_t *)> dlHalSensorNodeRegister;
51 : std::function<drvError_t(uint32_t, uint64_t)> dlHalSensorNodeUnregister;
52 : std::function<drvError_t(uint32_t, uint64_t, int, halGeneralEventType_t)> dlHalSensorNodeUpdateState;
53 1050 : bool DlHalFunctionIsInit()
54 : {
55 1050 : std::lock_guard<std::mutex> lock(handleMutex_);
56 1050 : return (handle_ != nullptr);
57 1050 : }
58 :
59 : protected:
60 : private:
61 : void *handle_;
62 : std::mutex handleMutex_;
63 : DlHalFunction(const DlHalFunction&);
64 : DlHalFunction &operator=(const DlHalFunction&);
65 : DlHalFunction();
66 : HcclResult DlHalFunctionEschedInit();
67 : };
68 : } // namespace hccl
69 :
70 : #endif // HCCL_SRC_DLHALFUNCTION_H
|