Skip to content

Commit da183ee

Browse files
committed
setschedule revision
1 parent 191562b commit da183ee

File tree

2 files changed

+7
-130
lines changed

2 files changed

+7
-130
lines changed

include/osp/bsp/model/util/SetSchedule.hpp

Lines changed: 7 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,15 @@ namespace osp {
2828

2929
/**
3030
* @class SetSchedule
31-
* @brief Represents a working schedule set for the BSP scheduling algorithm.
3231
*
33-
* This class implements the `IBspSchedule` interface and provides functionality to manage the assignment of nodes to
34-
* processors and supersteps. It stores the assignment information in a data structure called `stepProcessorVertices_`,
35-
* which is a 2D vector of unordered sets. Each element in the `stepProcessorVertices_` vector represents a superstep
36-
* and a processor, and contains a set of nodes assigned to that processor and superstep.
37-
*
38-
* The `SetSchedule` class provides methods to set and retrieve the assigned processor and superstep for a given
39-
* node as well as to manipulate the schedule.
40-
*
41-
* @warning The getter and setter methods for individual nodes are inefficient (O(P * S)) as they require searching
42-
* through all processor-superstep sets. This class is useful for cases where all nodes of a superstep/processor
43-
* pair need to be enumerated often.
32+
* The SetSchedule stores the assignment of nodes to processors and supersteps in a vector of unordered sets.
33+
* Each element in the vector represents a superstep and contains a set of nodes for each processor.
34+
* This class is useful for cases where all nodes of a superstep/processor pair need to be enumerated often.
4435
*
4536
* @tparam GraphT The type of the computational DAG.
4637
*/
4738
template <typename GraphT>
48-
class SetSchedule : public IBspSchedule<GraphT> {
39+
class SetSchedule {
4940
static_assert(isComputationalDagV<GraphT>, "SetSchedule can only be used with computational DAGs.");
5041

5142
private:
@@ -59,15 +50,6 @@ class SetSchedule : public IBspSchedule<GraphT> {
5950
public:
6051
SetSchedule() = default;
6152

62-
/**
63-
* @brief Constructs a SetSchedule with a given BSP instance and number of supersteps.
64-
* @param inst The BSP instance.
65-
* @param numSupersteps The number of supersteps to initialize.
66-
*/
67-
SetSchedule(const BspInstance<GraphT> &inst, unsigned numSupersteps) : instance_(&inst), numberOfSupersteps_(numSupersteps) {
68-
stepProcessorVertices_.resize(numSupersteps, std::vector<std::unordered_set<VertexIdx>>(inst.NumberOfProcessors()));
69-
}
70-
7153
/**
7254
* @brief Constructs a SetSchedule from another IBspSchedule.
7355
* @param schedule The source schedule to copy from.
@@ -87,7 +69,7 @@ class SetSchedule : public IBspSchedule<GraphT> {
8769
}
8870
}
8971

90-
~SetSchedule() override = default;
72+
~SetSchedule() = default;
9173

9274
/**
9375
* @brief Clears the schedule assignments and resets the number of supersteps to 0.
@@ -102,113 +84,9 @@ class SetSchedule : public IBspSchedule<GraphT> {
10284
*
10385
* @return The BSP instance.
10486
*/
105-
[[nodiscard]] const BspInstance<GraphT> &GetInstance() const override { return *instance_; }
106-
107-
[[nodiscard]] unsigned NumberOfSupersteps() const override { return numberOfSupersteps_; }
108-
109-
/**
110-
* @brief Sets the assigned superstep for a node.
111-
*
112-
* @warning This operation has a complexity of O(P * S), where P is the number of processors
113-
* and S is the number of supersteps, as it requires searching for the node in all sets.
114-
*
115-
* @param node The node index.
116-
* @param superstep The assigned superstep.
117-
*/
118-
void SetAssignedSuperstep(VertexIdx node, unsigned superstep) override {
119-
unsigned assignedProcessor = 0;
120-
bool found = false;
121-
122-
// Find current assignment
123-
for (unsigned step = 0; step < numberOfSupersteps_; step++) {
124-
for (unsigned proc = 0; proc < instance_->NumberOfProcessors(); proc++) {
125-
if (stepProcessorVertices_[step][proc].erase(node) > 0) {
126-
assignedProcessor = proc;
127-
found = true;
128-
break;
129-
}
130-
}
131-
if (found) {
132-
break;
133-
}
134-
}
135-
136-
if (superstep < numberOfSupersteps_) {
137-
stepProcessorVertices_[superstep][assignedProcessor].insert(node);
138-
}
139-
}
140-
141-
/**
142-
* @brief Sets the assigned processor for a node.
143-
*
144-
* @warning This operation has a complexity of O(P * S), where P is the number of processors
145-
* and S is the number of supersteps, as it requires searching for the node in all sets.
146-
*
147-
* @param node The node index.
148-
* @param processor The assigned processor.
149-
*/
150-
void SetAssignedProcessor(VertexIdx node, unsigned processor) override {
151-
unsigned assignedStep = 0;
152-
bool found = false;
153-
154-
// Find current assignment
155-
for (unsigned step = 0; step < numberOfSupersteps_; step++) {
156-
for (unsigned proc = 0; proc < instance_->NumberOfProcessors(); proc++) {
157-
if (stepProcessorVertices_[step][proc].erase(node) > 0) {
158-
assignedStep = step;
159-
found = true;
160-
break;
161-
}
162-
}
163-
if (found) {
164-
break;
165-
}
166-
}
167-
168-
if (assignedStep < numberOfSupersteps_ && processor < instance_->NumberOfProcessors()) {
169-
stepProcessorVertices_[assignedStep][processor].insert(node);
170-
}
171-
}
87+
[[nodiscard]] const BspInstance<GraphT> &GetInstance() const { return *instance_; }
17288

173-
/**
174-
* @brief Get the assigned superstep of a node.
175-
*
176-
* @warning This query has a complexity of O(P * S), where P is the number of processors
177-
* and S is the number of supersteps.
178-
*
179-
* @param node The node index.
180-
* @return The assigned superstep.
181-
*/
182-
[[nodiscard]] unsigned AssignedSuperstep(VertexIdx node) const override {
183-
for (unsigned step = 0; step < numberOfSupersteps_; step++) {
184-
for (unsigned proc = 0; proc < instance_->NumberOfProcessors(); proc++) {
185-
if (stepProcessorVertices_[step][proc].find(node) != stepProcessorVertices_[step][proc].end()) {
186-
return step;
187-
}
188-
}
189-
}
190-
return numberOfSupersteps_;
191-
}
192-
193-
/**
194-
* @brief Get the assigned processor of a node.
195-
*
196-
* @warning This query has a complexity of O(P * S), where P is the number of processors
197-
* and S is the number of supersteps.
198-
*
199-
* @param node The node index.
200-
* @return The assigned processor.
201-
*/
202-
[[nodiscard]] unsigned AssignedProcessor(VertexIdx node) const override {
203-
for (unsigned step = 0; step < numberOfSupersteps_; step++) {
204-
for (unsigned proc = 0; proc < instance_->NumberOfProcessors(); proc++) {
205-
if (stepProcessorVertices_[step][proc].find(node) != stepProcessorVertices_[step][proc].end()) {
206-
return proc;
207-
}
208-
}
209-
}
210-
return instance_->NumberOfProcessors();
211-
}
89+
[[nodiscard]] unsigned NumberOfSupersteps() const { return numberOfSupersteps_; }
21290

21391
/**
21492
* @brief Merges a range of supersteps into a single superstep (the startStep).

include/osp/bsp/scheduler/IlpSchedulers/CoptFullScheduler.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ limitations under the License.
2727
#include "osp/bsp/model/BspScheduleRecomp.hpp"
2828
#include "osp/bsp/model/MaxBspSchedule.hpp"
2929
#include "osp/bsp/model/MaxBspScheduleCS.hpp"
30-
#include "osp/bsp/model/util/VectorSchedule.hpp"
3130
#include "osp/bsp/scheduler/Scheduler.hpp"
3231

3332
namespace osp {

0 commit comments

Comments
 (0)