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 32 : CustOperationCommon() = default;
25 32 : 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(const uint32_t deviceId, const uint32_t hostPid, const uint32_t vfId,
30 : const int32_t custAicpuPid, const uint32_t loadLibNum,
31 : const char_t * const loadLibName[]) const;
32 : };
33 :
34 : class LoadOpFromBuffTsKernel : public HwTsKernelHandler, public CustOperationCommon {
35 : public:
36 10 : LoadOpFromBuffTsKernel() = default;
37 10 : ~LoadOpFromBuffTsKernel() override = default;
38 : int32_t Compute(const aicpu::HwtsTsKernel &tsKernelInfo) override;
39 : private:
40 : static std::mutex mutexForStartCustProcess_;
41 : static std::set<std::string> alreadyLoadSoName_;
42 : };
43 :
44 : class BatchLoadSoFromBuffTsKernel : public HwTsKernelHandler, public CustOperationCommon {
45 : public:
46 16 : BatchLoadSoFromBuffTsKernel() = default;
47 16 : ~BatchLoadSoFromBuffTsKernel() override = default;
48 : int32_t Compute(const aicpu::HwtsTsKernel &tsKernelInfo) override;
49 :
50 : private:
51 : int32_t TryToStartCustProcess(const std::unique_ptr<const char_t *[]> &soNames, const uint32_t soNum) const;
52 : };
53 :
54 : class DeleteCustOpTsKernel : public HwTsKernelHandler {
55 : public:
56 21 : DeleteCustOpTsKernel() = default;
57 21 : ~DeleteCustOpTsKernel() override = default;
58 : int32_t Compute(const aicpu::HwtsTsKernel &tsKernelInfo) override;
59 : };
60 : } // namespace AicpuSchedule
61 : #endif // HWTS_KERNEL_CUST_SO_H
|