fpmas 1.6
scheduled_load_balancing.h
Go to the documentation of this file.
1#ifndef FPMAS_SCHEDULED_LOAD_BALANCING_H
2#define FPMAS_SCHEDULED_LOAD_BALANCING_H
3
13
14#include <set>
15
16namespace fpmas { namespace graph {
19
24 template<typename T>
26 private:
29 api::runtime::Runtime& runtime;
30
31 public:
46 ) : fixed_vertices_lb(fixed_vertices_lb), scheduler(scheduler), runtime(runtime) {}
47
54
62 api::graph::PartitionMode partition_mode) override;
63
64 };
65
66 template<typename T>
68 return balance(nodes, api::graph::PARTITION);
69 }
70
71 template<typename T>
74 scheduler::Epoch epoch;
75 scheduler.build(runtime.currentDate() + 1, epoch);
76 // Global node map
77 NodeMap<T> node_map;
78 // Nodes currently fixed
79 PartitionMap fixed_nodes;
80 // Current partition
81 PartitionMap partition;
82
83 for(const api::scheduler::Job* job : epoch) {
84 for(api::scheduler::Task* task : *job) {
85 if(api::scheduler::NodeTask<T>* node_task = dynamic_cast<api::scheduler::NodeTask<T>*>(task)) {
86 // Node is bound to a Task that will be executed in
87 // job. Only LOCAL nodes are considered in this
88 // process, since DISTANT nodes are never executed.
89 auto node = node_task->node();
90 node_map[node->getId()] = node;
91 }
92 }
93 // Partitions only the nodes that will be executed in this job,
94 // fixing nodes that will be executed in previous jobs (that
95 // are already partitionned). Notice that fixed_nodes is
96 // included in node_map.
97 partition = fixed_vertices_lb.balance(node_map, fixed_nodes, partition_mode);
98 // Fixes nodes currently partitionned
99 fixed_nodes = partition;
100 };
101 // Finally, partition all other nodes, that are not executed within
102 // this epoch, or that are not bound to any Task.
103 partition = fixed_vertices_lb.balance(nodes, fixed_nodes, partition_mode);
104 return partition;
105 }
106}}
107#endif
Definition: load_balancing.h:47
Definition: load_balancing.h:92
Definition: runtime.h:18
Definition: scheduler.h:135
Definition: scheduler.h:117
Definition: scheduler.h:302
Definition: scheduler.h:76
Definition: scheduled_load_balancing.h:25
ScheduledLoadBalancing(api::graph::FixedVerticesLoadBalancing< T > &fixed_vertices_lb, api::scheduler::Scheduler &scheduler, api::runtime::Runtime &runtime)
Definition: scheduled_load_balancing.h:42
PartitionMap balance(api::graph::NodeMap< T > nodes) override
Definition: scheduled_load_balancing.h:67
Definition: scheduler.h:238
std::unordered_map< DistributedId, int, api::graph::IdHash< DistributedId > > PartitionMap
Definition: load_balancing.h:19
PartitionMode
Definition: load_balancing.h:30
@ PARTITION
Definition: load_balancing.h:35
typename graph::Graph< graph::DistributedNode< T >, graph::DistributedEdge< T > >::NodeMap NodeMap
Definition: load_balancing.h:25
Definition: fpmas.cpp:3