Fix HIP CannyEdgeDetector failure on repeated vxProcessGraph#1
Open
simonCatBot wants to merge 1 commit into
Open
Fix HIP CannyEdgeDetector failure on repeated vxProcessGraph#1simonCatBot wants to merge 1 commit into
simonCatBot wants to merge 1 commit into
Conversation
The HIP Canny stack output synchronization read the GPU atomic counter but never reset it to zero. On the second vxProcessGraph call the kernel saw the previous stackTop, wrote past the buffer, and produced 'invalid argument' / 'single node wait failed' errors. The OpenCL path already resets the counter after reading via map/unmap; this change adds the equivalent hipMemcpyHtoD reset. Also clamp stackTop to the buffer capacity as a defensive guard. Fixes: ROCm#1693 Signed-off-by: Kiriti Gowda <kiriti.gowda@gmail.com>
28074e0 to
6eb3081
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a HIP-specific bug where
CannyEdgeDetectorfails on the second (and subsequent)vxProcessGraphcalls.Problem
The HIP output synchronization for
AGO_TYPE_CANNY_STACKreads the GPU atomic counter to obtainstackTop, but it never resets that counter back to zero. On the next graph execution the Canny suppression kernel sees the stale counter value, believes the stack already contains entries, and either:Hip_CannySuppThreshold_U8XY_U16_3x3uses an atomic increment on the same counter), orhipErrorInvalidArgument/agoWaitForNodesCompletion: single node wait failed.This makes
CannyEdgeDetectorunusable in any graph that is processed more than once.Root cause
In
amd_openvx/openvx/ago/ago_util_hip.cpp,agoGpuHipDataOutputAtomicSync()handles the Canny stack by doing:The OpenCL equivalent (
agoGpuOclDataOutputAtomicSync()) already resets the counter to zero after reading viaclEnqueueMapBuffer/clEnqueueUnmapMemObject. HIP was missing that reset.Fix
After reading the Canny stack entries from GPU memory, reset the GPU counter to 0 with
hipMemcpyHtoD. Also clampstackTopto the declared stack capacity as a defensive guard against reading past the GPU buffer.Verification
Build configuration:
avinya(AMD RYZEN AI MAX+ PRO 395 w/ Radeon 8060S)-DBACKEND=HIP -DGPU_SUPPORT=ON -DNEURAL_NET=OFF -DLOOM=OFF -DMIGRAPHX=OFFTests performed:
vxProcessGraph) — passes after fix, failed on iteration 2 before.vxuCanny+vxCanny) — 56/56 pass.LD_LIBRARY_PATH.openvx-mark --vision-parity FHD— 41/41 pass, 0 skipped, 0 failed.Performance:
CannyEdgeDetectorat FHD: ~2.0 ms (was failing/skipped before).Linked issue
Fixes ROCm#1693
Notes for reviewers