1+ #pragma once
2+
3+ /* ___INFO__MARK_BEGIN_NEW__*/
4+ /* **************************************************************************
5+ *
6+ * Copyright 2025 HPC-Gridware GmbH
7+ *
8+ * Licensed under the Apache License, Version 2.0 (the "License");
9+ * you may not use this file except in compliance with the License.
10+ * You may obtain a copy of the License at
11+ *
12+ * http://www.apache.org/licenses/LICENSE-2.0
13+ *
14+ * Unless required by applicable law or agreed to in writing, software
15+ * distributed under the License is distributed on an "AS IS" BASIS,
16+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+ * See the License for the specific language governing permissions and
18+ * limitations under the License.
19+ *
20+ ***************************************************************************/
21+ /* ___INFO__MARK_END_NEW__*/
22+
23+ #include < sstream>
24+ #include < string>
25+ #include < unordered_map>
26+ #include < vector>
27+
28+ namespace ocs {
29+ class TopologyNode {
30+ public:
31+ // Possible statuses for a topology nodes
32+ enum Status {FREE, USED, UNAVAILABLE, UNINITIALIZED};
33+ static std::string status_to_string (Status status);
34+
35+ // Keys used for the property map
36+ static constexpr auto STATUS = " ST" ;
37+ static constexpr auto LOGICAL_SOCKET = " S" ;
38+ static constexpr auto LOGICAL_CORE = " C" ;
39+ static constexpr auto LOGICAL_THREAD = " T" ;
40+ static constexpr auto NUMA_NODE_ID = " N" ;
41+ static constexpr auto CACHE_3RD_ID = " X" ;
42+ static constexpr auto CACHE_2ND_ID = " Y" ;
43+ static constexpr auto TOPOLOGY_ID = " TO" ;
44+ static constexpr auto NUMBER_OF_FREE_C_THREADS = " #C" ;
45+ static constexpr auto NUMBER_OF_FREE_E_THREADS = " #E" ;
46+ static constexpr auto NUMBER_OF_USED_C_THREADS = " #c" ;
47+ static constexpr auto NUMBER_OF_USED_E_THREADS = " #e" ;
48+
49+ // Data
50+ char c;
51+ std::vector<TopologyNode> nodes;
52+ std::unordered_map<std::string, int > properties;
53+
54+ // Constructors
55+ explicit TopologyNode (char c, Status status);
56+ explicit TopologyNode (char c, Status status, std::vector<TopologyNode> nodes);
57+
58+ // Property handling
59+ void assign_prop_if_not_exists (const std::string &name, int value);
60+
61+ // Helper to get combined status of a CPU-threads
62+ static Status get_combined_status (Status status, bool is_free);
63+
64+ // Convert the node to a string representation
65+ void to_string (std::ostringstream& oss) const ;
66+ };
67+ } // namespace ocs
0 commit comments