MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ComputeSchedule

Method ComputeSchedule

tensorflow/core/distributed_runtime/scheduler.cc:211–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211Microseconds GreedyScheduler::ComputeSchedule(
212 std::vector<Microseconds>* start_times) {
213 // Initialize pending_count
214 std::vector<int> pending_count(graph_->num_node_ids());
215 InitializePending(graph_, &pending_count);
216
217 // Initialize event queue
218 std::priority_queue<Event> event_queue;
219 Event src_event;
220 src_event.node = graph_->source_node();
221 src_event.time = 0;
222 src_event.is_completion = true;
223 event_queue.push(src_event);
224 Microseconds max_completion = Microseconds(0);
225
226 while (!event_queue.empty()) {
227 Event event = event_queue.top();
228 event_queue.pop();
229 if (event.is_completion) {
230 Sim* sim = device_states_[event.node->assigned_device_name()];
231 --sim->num_running;
232
233 if (event.time > max_completion) {
234 max_completion = event.time;
235 }
236
237 for (const Edge* out_edge : event.node->out_edges()) {
238 Microseconds copy_time(0);
239 const Node* out = out_edge->dst();
240 if (!out_edge->IsControlEdge() &&
241 event.node->assigned_device_name() != out->assigned_device_name()) {
242 // TODO(yuanbyu): Use below with the real cost model.
243 // int index = out_edge->src_output();
244 // Bytes nb = cost_model_->SizeEstimate(event.node, index);
245 // copy_time = CostModel::CopyTimeEstimate(nb);
246 copy_time = 10;
247 }
248 if ((*start_times)[out->id()] < event.time + copy_time) {
249 (*start_times)[out->id()] = event.time + copy_time;
250 }
251
252 bool is_ready = UpdatePending(out_edge, &pending_count);
253 if (is_ready) {
254 Event e{out, (*start_times)[out->id()], false};
255 event_queue.push(e);
256 }
257 }
258 } else {
259 Sim* sim = device_states_[event.node->assigned_device_name()];
260 sim->ready_nodes.push_back(event.node);
261 }
262
263 for (auto& x : device_states_) {
264 Sim* sim = x.second;
265 while (sim->num_running < sim->degree_parallelism &&
266 !sim->ready_nodes.empty()) {
267 Event e;
268 e.node = GetNodeWithHighestPriority(sim->ready_nodes);

Callers

nothing calls this directly

Calls 13

InitializePendingFunction · 0.85
UpdatePendingFunction · 0.85
TimeEstimateMethod · 0.80
ComputeSlackMethod · 0.80
num_node_idsMethod · 0.45
source_nodeMethod · 0.45
pushMethod · 0.45
emptyMethod · 0.45
popMethod · 0.45
dstMethod · 0.45
IsControlEdgeMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected