| 17 | #include <unordered_set> |
| 18 | |
| 19 | PXR_NAMESPACE_OPEN_SCOPE |
| 20 | |
| 21 | void |
| 22 | Exec_CycleDetectingTask::_Compile( |
| 23 | Exec_CompilationState &compilationState, |
| 24 | TaskPhases &taskPhases) |
| 25 | { |
| 26 | TRACE_FUNCTION(); |
| 27 | TfAutoMallocTag tag("Exec", __ARCH_PRETTY_FUNCTION__); |
| 28 | |
| 29 | taskPhases.Invoke( |
| 30 | [this, &compilationState](TaskDependencies &deps) { |
| 31 | TRACE_FUNCTION_SCOPE("search for potential cycles"); |
| 32 | |
| 33 | // If this node is a VdfSpeculationNode, traversal should not proceed |
| 34 | // upwards from here, because VdfSpeculationNodes are specifically |
| 35 | // created to break topological cycles, and there is no need to |
| 36 | // re-detect those cycles. |
| 37 | if (_node->IsSpeculationNode()) { |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | const std::unordered_set<VdfInput *> &inputsRequiringRecompilation = |
| 42 | compilationState.GetProgram()->GetInputsRequiringRecompilation(); |
| 43 | |
| 44 | for (const auto &entry : _node->GetInputsIterator()) { |
| 45 | VdfInput *const input = entry.second; |
| 46 | if (inputsRequiringRecompilation.find(input) != |
| 47 | inputsRequiringRecompilation.end()) { |
| 48 | // This input is being recompiled. This task cannot complete |
| 49 | // until the input has finished recompilation. If recompilation |
| 50 | // of the input depends on the current Exec_CycleDetectingTask, |
| 51 | // then the dependency added here introduces a task cycle, which |
| 52 | // will be caught by the Exec_TaskCycleDetector. |
| 53 | deps.WaitOnInputRecompilationTask(input); |
| 54 | continue; |
| 55 | } |
| 56 | |
| 57 | // The input is not being recompiled. Recursively spawn more cycle |
| 58 | // detecting tasks for all nodes upstream of this input. |
| 59 | for (const VdfConnection *const connection : |
| 60 | input->GetConnections()) { |
| 61 | const VdfNode *const sourceNode = &connection->GetSourceNode(); |
| 62 | if (deps.ClaimCycleDetectingTask(sourceNode)) { |
| 63 | deps.NewSubtask<Exec_CycleDetectingTask>( |
| 64 | compilationState, |
| 65 | sourceNode); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | }, |
| 70 | [this](TaskDependencies &deps) { |
| 71 | // Any upstream inputs undergoing recompilation have completed. |
| 72 | deps.MarkDoneCycleDetectingTask(_node); |
| 73 | } |
| 74 | ); |
| 75 | } |
| 76 |
nothing calls this directly
no test coverage detected