Line data Source code
1 : /**
2 : * Copyright (c) 2026 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 CCU_RES_CONTAINER_H
12 : #define CCU_RES_CONTAINER_H
13 :
14 : #include <memory>
15 : #include <vector>
16 :
17 : #include "ccu_types.h"
18 : #include "ccu_res_pack.h"
19 : #include "ccu_drv_handle.h"
20 : #include "ccu_device_res.h"
21 :
22 : namespace hcomm {
23 :
24 : /**
25 : * @note 职责:管理通信域持有的CCU资源
26 : */
27 : class CcuInstance {
28 : public:
29 27 : explicit CcuInstance(CcuInstanceType insType) : insType_(insType) {};
30 : ~CcuInstance();
31 : CcuResult Init();
32 : CcuResult Reset();
33 : CcuResPack *GetResPack();
34 : CcuResult SaveKernel(const CcuKernelHandle kernelHandle);
35 : const std::vector<CcuKernelHandle> &GetUntranslatedKernels();
36 :
37 : CcuResult BeginRegister();
38 : CcuResult CheckRegistering() const;
39 : CcuResult EndRegister();
40 : void AbortRegister();
41 :
42 : private:
43 : enum class RegisterState { IDLE, REGISTERING, REGISTER_ABORTED };
44 : RegisterState registerState_{RegisterState::IDLE};
45 : CcuInstanceType insType_{CcuInstanceType::CCU_UNUSED};
46 : int32_t devLogicId_{INT32_MAX};
47 : std::shared_ptr<hcomm::CcuDrvHandle> ccuDrvHandle_{};
48 : std::unique_ptr<CcuResPack> resPack_{};
49 : std::vector<CcuKernelHandle> kernelHandles_{};
50 : std::vector<CcuKernelHandle> untranslatedKernelHandles_{};
51 : };
52 :
53 : } // namespace hcomm
54 : #endif // CCU_RES_CONTAINER_H
|