MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / Schedule

Method Schedule

oneflow/core/vm/virtual_machine_engine.cpp:426–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426void VirtualMachineEngine::Schedule(const ScheduleCtx& schedule_ctx) {
427 // Release finished instructions and try to schedule out instructions in DAG onto ready list.
428 if (unlikely(mut_active_stream_list()->size())) { ReleaseFinishedInstructions(schedule_ctx); }
429 // Try run the first barrier instruction.
430 if (unlikely(mut_barrier_instruction_list()->size())) { TryRunBarrierInstruction(schedule_ctx); }
431 // Handle pending instructions, and try schedule them to ready list.
432 // Use thread_unsafe_size to avoid acquiring mutex lock.
433 // The inconsistency between pending_instruction_list.list_head_.list_head_.container_ and
434 // pending_instruction_list.list_head_.list_head_.size_ is not a fatal error because
435 // VirtualMachineEngine::Schedule is always in a busy loop. All instructions will get handled
436 // eventually.
437 // VirtualMachineEngine::Receive may be less effiencient if the thread safe version
438 // `pending_instruction_list().size()` used here, because VirtualMachineEngine::Schedule is more
439 // likely to get the mutex lock.
440 if (unlikely(local_pending_instruction_list().size())) {
441 HandleLocalPending();
442 } else if (unlikely(pending_instruction_list().thread_unsafe_size())) {
443 // MoveTo is under a lock.
444 mut_pending_instruction_list()->MoveTo(mut_local_pending_instruction_list());
445 if (local_pending_instruction_list().size()) { HandleLocalPending(); }
446 }
447 // dispatch ready instructions and try to schedule out instructions in DAG onto ready list.
448 if (unlikely(mut_ready_instruction_list()->size())) {
449 DispatchAndPrescheduleInstructions(schedule_ctx);
450 }
451 // handle scheduler probes
452 if (unlikely(local_probe_list_.size())) {
453 HandleLocalProbe();
454 } else if (unlikely(probe_list_.thread_unsafe_size())) {
455 probe_list_.MoveTo(&local_probe_list_);
456 if (local_probe_list_.size()) { HandleLocalProbe(); }
457 }
458}
459
460bool VirtualMachineEngine::SchedulerThreadUnsafeEmpty() const {
461 return pending_instruction_list().thread_unsafe_size() == 0

Callers 3

ScheduleUntilVMEmptyFunction · 0.45
ScheduleLoopMethod · 0.45
ForwardDataContentMethod · 0.45

Calls 3

thread_unsafe_sizeMethod · 0.80
sizeMethod · 0.45
MoveToMethod · 0.45

Tested by

no test coverage detected