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 COMM_ENGINE_UTILS_H
12 : #define COMM_ENGINE_UTILS_H
13 :
14 : #include <string>
15 : #include <unordered_map>
16 : #include "hcomm_res_defs.h"
17 :
18 : template <typename MapType>
19 576 : inline std::string GetEnumToString(const MapType& mappingMap, typename MapType::key_type enumValue)
20 : {
21 576 : auto iter = mappingMap.find(enumValue);
22 576 : if (iter != mappingMap.end()) {
23 576 : return iter->second;
24 : }
25 0 : return "Unknown";
26 : }
27 :
28 576 : inline const std::unordered_map<CommEngine, std::string>& GetCommEngineStatusStrMap()
29 : {
30 : static const std::unordered_map<CommEngine, std::string> COMMENGINE_STATUS_STR_MAP{
31 0 : {COMM_ENGINE_RESERVED, "RESERVED"},
32 0 : {COMM_ENGINE_CPU, "CPU"},
33 0 : {COMM_ENGINE_CPU_TS, "CPU_TS"},
34 0 : {COMM_ENGINE_AICPU, "AICPU"},
35 0 : {COMM_ENGINE_AICPU_TS, "AICPU_TS"},
36 0 : {COMM_ENGINE_AIV, "AIV"},
37 649 : {COMM_ENGINE_CCU, "CCU"}};
38 576 : return COMMENGINE_STATUS_STR_MAP;
39 8 : }
40 :
41 : #endif
|