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 HWTS_KERNEL_CUST_SO_H
12 : #define HWTS_KERNEL_CUST_SO_H
13 :
14 : #include <mutex>
15 : #include <thread>
16 : #include <set>
17 : #include <vector>
18 :
19 : #include "hwts_kernel.h"
20 :
21 : namespace AicpuSchedule {
22 : class CustOperationCommon {
23 : public:
24 33 : CustOperationCommon() = default;
25 35 : virtual ~CustOperationCommon() = default;
26 : int32_t SendCtrlCpuMsg(int32_t custAicpuPid, const uint32_t eventType, char_t* msg, const uint32_t msgLen) const;
27 : int32_t StartCustProcess(const uint32_t loadLibNum, const char_t* const loadLibName[]) const;
28 : int32_t GetGroupNameInfo(std::vector<std::string>& groupNameList, std::string& groupNameStr) const;
29 : int32_t AicpuNotifyLoadSoEventToCustCtrlCpu(
30 : const uint32_t deviceId, const uint32_t hostPid, const uint32_t vfId, const int32_t custAicpuPid,
31 : const uint32_t loadLibNum, const char_t* const loadLibName[]) const;
32 : int32_t NotifyCustCloseMonitor(const int32_t custAicpuPid) const;
33 : };
34 :
35 : class LoadOpFromBuffTsKernel : public HwTsKernelHandler, public CustOperationCommon {
36 : public:
37 10 : LoadOpFromBuffTsKernel() = default;
38 12 : ~LoadOpFromBuffTsKernel() override = default;
39 : int32_t Compute(const aicpu::HwtsTsKernel& tsKernelInfo) override;
40 :
41 : private:
42 : static std::mutex mutexForStartCustProcess_;
43 : static std::set<std::string> alreadyLoadSoName_;
44 : };
45 :
46 : class BatchLoadSoFromBuffTsKernel : public HwTsKernelHandler, public CustOperationCommon {
47 : public:
48 16 : BatchLoadSoFromBuffTsKernel() = default;
49 16 : ~BatchLoadSoFromBuffTsKernel() override = default;
50 : int32_t Compute(const aicpu::HwtsTsKernel& tsKernelInfo) override;
51 :
52 : private:
53 : int32_t TryToStartCustProcess(const std::unique_ptr<const char_t*[]>& soNames, const uint32_t soNum) const;
54 : };
55 :
56 : class DeleteCustOpTsKernel : public HwTsKernelHandler {
57 : public:
58 21 : DeleteCustOpTsKernel() = default;
59 21 : ~DeleteCustOpTsKernel() override = default;
60 : int32_t Compute(const aicpu::HwtsTsKernel& tsKernelInfo) override;
61 : };
62 : } // namespace AicpuSchedule
63 : #endif // HWTS_KERNEL_CUST_SO_H
|