Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/osp/bsp/model/BspSchedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ class BspSchedule : public IBspSchedule<GraphT>, public IBspScheduleEval<GraphT>
for (unsigned step = 0; step < numberOfSupersteps_; step++) {
for (unsigned proc = 0; proc < instance_->NumberOfProcessors(); proc++) {
VMemwT<GraphT> memory = 0;
for (const auto &node : setSchedule.stepProcessorVertices_[step][proc]) {
for (const auto &node : setSchedule.GetProcessorStepVertices()[step][proc]) {
memory += instance_->GetComputationalDag().VertexMemWeight(node);
}

Expand Down Expand Up @@ -677,7 +677,7 @@ class BspSchedule : public IBspSchedule<GraphT>, public IBspScheduleEval<GraphT>
for (unsigned step = 0; step < numberOfSupersteps_; step++) {
for (unsigned proc = 0; proc < instance_->NumberOfProcessors(); proc++) {
VMemwT<GraphT> memory = 0;
for (const auto &node : setSchedule.stepProcessorVertices_[step][proc]) {
for (const auto &node : setSchedule.GetProcessorStepVertices()[step][proc]) {
memory += instance_->GetComputationalDag().VertexMemWeight(node)
+ instance_->GetComputationalDag().VertexCommWeight(node);

Expand Down Expand Up @@ -705,7 +705,7 @@ class BspSchedule : public IBspSchedule<GraphT>, public IBspScheduleEval<GraphT>
std::unordered_set<VertexIdxT<GraphT>> nodesWithIncomingEdges;

VMemwT<GraphT> memory = 0;
for (const auto &node : setSchedule.stepProcessorVertices_[step][proc]) {
for (const auto &node : setSchedule.GetProcessorStepVertices()[step][proc]) {
memory += instance_->GetComputationalDag().VertexCommWeight(node);

for (const auto &parent : instance_->GetComputationalDag().Parents(node)) {
Expand Down Expand Up @@ -735,7 +735,7 @@ class BspSchedule : public IBspSchedule<GraphT>, public IBspScheduleEval<GraphT>
std::unordered_set<VertexIdxT<GraphT>> nodesWithIncomingEdges;

VMemwT<GraphT> memory = 0;
for (const auto &node : setSchedule.stepProcessorVertices_[step][proc]) {
for (const auto &node : setSchedule.GetProcessorStepVertices()[step][proc]) {
if (IsSource(node, instance_->GetComputationalDag())) {
memory += instance_->GetComputationalDag().VertexMemWeight(node);
}
Expand Down
86 changes: 60 additions & 26 deletions include/osp/bsp/model/IBspSchedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,77 @@ limitations under the License.

namespace osp {

/// @class IBspSchedule
/// @brief Interface for a BSP (Bulk Synchronous Parallel) schedule.
/**
* @class IBspSchedule
* @brief Pure interface class to organize the interaction with a BSP schedule.
*
* A BSP schedule assigns nodes to processors and supersteps, is based on an instance, and has a number of supersteps.
* It provides unified access for different data implementations.
*
* - The class `BspSchedule` implements the assignments as vectors.
* - The class `SetBspSchedule` implements containers that contain all nodes assigned to a pair of processor and superstep.
*
* @tparam GraphT The type of the computational DAG, which must satisfy `is_computational_dag_v`.
* @see BspInstance
* @see BspSchedule
* @see SetBspSchedule
*/
template <typename GraphT>
class IBspSchedule {
using VertexIdx = VertexIdxT<GraphT>;

static_assert(isComputationalDagV<GraphT>, "IBspSchedule can only be used with computational DAGs.");

public:
/// @brief Destructor.
virtual ~IBspSchedule() = default;

virtual const BspInstance<GraphT> &GetInstance() const = 0;

/// @brief Set the assigned superstep for a node.
/// @param node The node index.
/// @param superstep The assigned superstep.
/**
* @brief Get the BSP instance associated with this schedule.
*
* @return The BSP instance.
*/
[[nodiscard]] virtual const BspInstance<GraphT> &GetInstance() const = 0;

/**
* @brief Set the assigned superstep for a node.
*
* @param node The node index.
* @param superstep The assigned superstep.
*/
virtual void SetAssignedSuperstep(VertexIdx node, unsigned int superstep) = 0;

/// @brief Set the assigned processor for a node.
/// @param node The node index.
/// @param processor The assigned processor.
/**
* @brief Set the assigned processor for a node.
*
* @param node The node index.
* @param processor The assigned processor.
*/
virtual void SetAssignedProcessor(VertexIdx node, unsigned int processor) = 0;

/// @brief Get the assigned superstep of a node.
/// @param node The node index.
/// @return The assigned superstep of the node.
/// If the node is not assigned to a superstep, this.NumberOfSupersteps() is returned.
virtual unsigned AssignedSuperstep(VertexIdx node) const = 0;

/// @brief Get the assigned processor of a node.
/// @param node The node index.
/// @return The assigned processor of the node.
/// If the node is not assigned to a processor, this.GetInstance().NumberOfProcessors() is returned.
virtual unsigned AssignedProcessor(VertexIdx node) const = 0;

/// @brief Get the number of supersteps in the schedule.
/// @return The number of supersteps in the schedule.
virtual unsigned NumberOfSupersteps() const = 0;
/**
* @brief Get the assigned superstep of a node.
*
* @param node The node index.
* @return The assigned superstep of the node.
* If the node is not assigned to a superstep, this.NumberOfSupersteps() is returned.
*/
[[nodiscard]] virtual unsigned AssignedSuperstep(VertexIdx node) const = 0;

/**
* @brief Get the assigned processor of a node.
*
* @param node The node index.
* @return The assigned processor of the node.
* If the node is not assigned to a processor, this.GetInstance().NumberOfProcessors() is returned.
*/
[[nodiscard]] virtual unsigned AssignedProcessor(VertexIdx node) const = 0;

/**
* @brief Get the number of supersteps in the schedule.
*
* @return The number of supersteps in the schedule.
*/
[[nodiscard]] virtual unsigned NumberOfSupersteps() const = 0;
};

} // namespace osp
Loading