Skip to content

fix(pipeline): eliminate double execution and worker idle race - #74

Closed
simonCatBot wants to merge 1 commit into
KhronosGroup:openvx_1.3.2from
simonCatBot:fix/pipeline-hang-followup
Closed

fix(pipeline): eliminate double execution and worker idle race#74
simonCatBot wants to merge 1 commit into
KhronosGroup:openvx_1.3.2from
simonCatBot:fix/pipeline-hang-followup

Conversation

@simonCatBot

Copy link
Copy Markdown
Contributor

Summary

Fixes two bugs in the streaming/pipelining interaction that were causing the GraphPipeline conformance tests (notably ManualSchedule/4 with loop_count=1000) to hang or time out in CI.

Bug 1: vxExecuteGraph ran every graph twice

The pipeup warm-up loop in vxExecuteGraph was unconditional:

  1. First iteration ran the graph and set steady_done = true.
  2. Second iteration saw !any_pipeup && steady_done and broke.

For normal graphs without pipeup-depth nodes this executed the graph twice. In the pipeline worker that meant each queued frame ran twice, roughly doubling the stress-suite run time.

Fix: add ownGraphHasPipeup() and only request the extra "one steady iteration" when the graph actually contains a node with pipeup_output_depth > 1.

Bug 2: vxWaitGraph could return while the worker was still mid-batch

The pipeline worker runs queued frames back-to-back in one inner loop. It increments in_flight at batch start and decrements it after each frame. There was a window where in_flight was momentarily 0 between frames even though the worker was about to start the next one.

vxWaitGraph only checked in_flight > 0, so it could return during that window. The test then recycled buffers while the worker was still using them, desynchronising the queues and eventually hanging.

Fix: add a worker_is_processing flag to the graph and make vxWaitGraph wait under pipe_lock until !worker_is_processing && in_flight == 0. The worker clears the flag only when it is truly about to go idle.

Verification

  • GraphPipeline.* fast tests: 37/37 pass
  • GraphPipeline.ManualSchedule/4 (loop_count=1000): passes
  • GraphStreaming.*: 24/24 pass
  • Graph.* (non-pipeline graph tests): 233/233 pass

I also ran ManualSchedule/4 50 times in a loop locally without a hang.

Notes

The latest Copilot review on PR #69 was addressed in commit 0b944d6; this PR is a follow-up on top of that merged state.

Two related bugs introduced by the streaming extension were causing the
pipeline conformance tests (especially ManualSchedule/4 loop_count=1000)
to hang or timeout in CI:

1. vxExecuteGraph ran every graph twice.
   The pipeup warm-up loop set steady_done after the first iteration and
   only broke on the next loop check, so non-pipeup graphs executed twice.
   Add ownGraphHasPipeup() and only request the extra steady iteration when
   the graph actually contains a node with pipeup_output_depth > 1.

2. vxWaitGraph could return while the worker was mid-batch.
   The pipeline worker decremented in_flight to 0 between back-to-back
   frames, creating a window where vxWaitGraph saw 'idle' even though the
   worker was about to start the next frame.  Add worker_is_processing and
   only clear it / signal idle when the worker truly has no more work.

Local tests:
- GraphPipeline fast: 37/37 pass
- GraphPipeline.ManualSchedule/4: passes
- GraphStreaming: 24/24 pass
- Graph.*: 233/233 pass
@simonCatBot

Copy link
Copy Markdown
Contributor Author

Opened against the wrong repo — the fix belongs to ROCm/MIVisionX#1722.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant