Skip to content

Commit ada9e08

Browse files
committed
EH: CS-732: Move binding decision making into scheduler thread
1 parent 88c27c9 commit ada9e08

7 files changed

Lines changed: 813 additions & 2 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*___INFO__MARK_BEGIN_NEW__*/
2+
/***************************************************************************
3+
*
4+
* Copyright 2025 HPC-Gridware GmbH
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
***************************************************************************/
19+
/*___INFO__MARK_END_NEW__*/
20+
21+
#include <algorithm>
22+
#include <cctype>
23+
#include <sstream>
24+
#include <string>
25+
#include <unordered_map>
26+
27+
#include "uti/sge_string.h"
28+
#include "uti/sge_rmon_macros.h"
29+
30+
#include "sgeobj/ocs_TopologyNode.h"
31+
32+
ocs::TopologyNode::TopologyNode(const char c, const Status status) : c(c) {
33+
assign_prop_if_not_exists(STATUS, status);
34+
}
35+
36+
ocs::TopologyNode::TopologyNode(const char c, const Status status, std::vector<TopologyNode> nodes) : TopologyNode(c, status) {
37+
this->nodes = std::move(nodes);
38+
}
39+
40+
std::string
41+
ocs::TopologyNode::status_to_string(const Status status) {
42+
switch (status) {
43+
case FREE:
44+
return "FREE";
45+
case USED:
46+
return "USED";
47+
case UNAVAILABLE:
48+
return "UNAVAILABLE";
49+
case UNINITIALIZED:
50+
return "UNINITIALIZED";
51+
default:
52+
return "UNKNOWN";
53+
}
54+
}
55+
56+
// Only assign the value if the property doesn't already exist
57+
void
58+
ocs::TopologyNode::assign_prop_if_not_exists(const std::string &name, const int value) {
59+
if (!properties.contains(name)) {
60+
properties[name] = value;
61+
}
62+
}
63+
64+
ocs::TopologyNode::Status
65+
ocs::TopologyNode::get_combined_status(Status status, const bool is_free) {
66+
if (is_free) {
67+
switch (status) {
68+
case UNINITIALIZED:
69+
status = FREE;
70+
break;
71+
case UNAVAILABLE:
72+
status = USED;
73+
break;
74+
case FREE:
75+
case USED:
76+
default:
77+
break;
78+
}
79+
} else {
80+
switch (status) {
81+
case UNINITIALIZED:
82+
status = UNAVAILABLE;
83+
break;
84+
case FREE:
85+
case USED:
86+
status = USED;
87+
break;
88+
case UNAVAILABLE:
89+
default:
90+
break;
91+
}
92+
}
93+
return status;
94+
}
95+
96+
void
97+
ocs::TopologyNode::to_string(std::ostringstream& oss) const {
98+
oss << c;
99+
for (const auto& child : nodes) {
100+
child.to_string(oss);
101+
}
102+
}
103+
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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

Comments
 (0)