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 PLATFORM_MANAGER_V2_H
12 : #define PLATFORM_MANAGER_V2_H
13 :
14 : #include <map>
15 : #include <string>
16 : #include <array>
17 : #include <mutex>
18 : #include "platform_infos_def.h"
19 :
20 : #ifdef __cplusplus
21 : extern "C" {
22 : #endif // __cplusplus
23 : class PlatformManagerV2 {
24 : public:
25 : PlatformManagerV2(const PlatformManagerV2&) = delete;
26 : PlatformManagerV2& operator=(const PlatformManagerV2&) = delete;
27 :
28 : static PlatformManagerV2& Instance();
29 :
30 : int32_t GetSocSpec(
31 : const std::string& soc_version, const std::string& label, const std::string& key, std::string& value);
32 :
33 : private:
34 1 : PlatformManagerV2() = default;
35 1 : ~PlatformManagerV2() = default;
36 :
37 : uint32_t LoadIniFile(const std::string& ini_file_real_path);
38 : uint32_t AssemblePlatformInfoVector(std::map<std::string, std::map<std::string, std::string>>& content_info_map);
39 : void FillupFixPipeInfo(fe::PlatFormInfos& platform_infos);
40 : void ParseAICoreintrinsicDtypeMap(
41 : std::map<std::string, std::string>& ai_coreintrinsic_dtype_map, fe::PlatFormInfos& platform_info_temp);
42 : void ParseVectorCoreintrinsicDtypeMap(
43 : std::map<std::string, std::string>& vector_coreintrinsic_dtype_map, fe::PlatFormInfos& platform_info_temp);
44 : void ParsePlatformRes(
45 : const std::string& label, std::map<std::string, std::string>& platform_res_map,
46 : fe::PlatFormInfos& platform_info_temp);
47 : uint32_t ParsePlatformInfo(
48 : std::map<std::string, std::map<std::string, std::string>>& content_info_map,
49 : fe::PlatFormInfos& platform_info_temp);
50 : uint32_t InitPlatformInfos(const std::string& soc_version);
51 : int32_t GetPlatformInfos(const std::string& soc_version, fe::PlatFormInfos& platform_info);
52 :
53 : private:
54 : std::mutex soc_lock_;
55 : std::map<std::string, bool> soc_file_status_;
56 :
57 : std::map<std::string, fe::PlatFormInfos> platform_infos_map_;
58 : };
59 :
60 : #ifdef __cplusplus
61 : }
62 : #endif // __cplusplus
63 : #endif
|