Commit 2659df3
review: address Copilot review on PR #21 (16 comments)
Four themes, all surfaced by Copilot's code review on the v1.1 PR.
1. Timing-budget hygiene - move allocations out of run_fn (9)
opencv_runner.h documents that setup_fn is the only place a
benchmark may allocate (matching how OpenVX graphs pre-allocate
at vxCreateImage / vxCreateTensor time). Several benches were
violating that contract and timing per-iter cv::Mat::create,
std::vector::reserve, and cv::HOGDescriptor construction:
* cv_multiscale.cpp: GaussianPyramid_ORB, LaplacianPyramid_S16,
LaplacianReconstruct, LaplacianReconstruct_S16 — per-level
Mats now preallocated in shared state, residuals reused.
* cv_extraction.cpp: HOGCells (HOGDescriptor in state),
HOGFeatures (HOGDescriptor + reserved descriptors vector),
HoughLinesP (reserved std::vector<Vec4i>), NonMaxSuppression
(preallocated keep_mask, cv::compare in place).
* cv_pipeline_vision.cpp::SobelMagnitudePhase and
cv_pipeline_feature.cpp::ThresholdedEdge — Sobel direct to
CV_32F so we skip the in-loop S16 to F32 convertTo, plus
preallocated phase/magf/magu8 scratch in shared state.
* cv_feature.cpp::OpticalFlowPyrLK — next_pts/status/err now
reserved to DEFAULT_OPTFLOW_POINTS in setup_fn so the first
per-iter push_back does not realloc.
2. Memory ceiling for HOGFeatures (2)
cv::HOGDescriptor::compute slides a 64x64 window across the full
image. Descriptor storage grows O(w*h) - at 4K thats 800 MB on
the OpenCV side and ~420 MB int16 on the OpenVX side, enough to
OOM CI runners and to dominate the kernel cost with allocator
pressure. Capped both binaries effective HOG dims to 1024x768
(the classic HOG-pedestrian-detect resolution). Window count
capped doesnt change the comparison answer because the per-window
cost is what is being measured.
3. Correctness - TensorMatMul bias actually zero (1)
The bias tensor was created with vxCreateTensor and described as
"zero-filled" but never explicitly initialised. OpenVX does not
guarantee fresh tensor memory is zero (impls may return uninit
pages for perf), so on a strict impl the bias was effectively
garbage and would perturb every matmul result. Fix: explicit
vxCopyTensorPatch with a std::vector<int16_t>(M*M, 0) in
setup_fn. Also fixed surrounding comment wording "M^2 fp16"
to "M^2 int16" to match the actual VX_TYPE_INT16 storage.
4. Tidy - log-dedup tail flush + script robustness (3)
* BenchmarkContext destructor calls resetLogDedup() so the
trailing "(previous message repeated N more times)" line is
always surfaced even when the last benchmark of a run ends
in a suppressing-duplicates state.
* compare_three_way.sh --skip-amd no longer breaks the OpenCV
run. Previously the script ran opencv-mark from $BUILD_AMD/
opencv-mark/opencv-mark even when --skip-amd skipped that
build entirely; now opencv-mark is built inside the rustVX
tree (via -DOPENVX_MARK_BUILD_OPENCV=ON) when AMD is skipped,
and opencv-mark is run from whichever build dir actually has it.
* compare_three_way.sh now honours CARGO_TARGET_DIR for
resolving the rustVX library path - mirrors the resolution
logic already in build_rustvx.sh so the two stay in lockstep.
Verified locally on macOS / OpenCV 4.13:
* openvx-mark --category multiscale @ AMD MIVisionX: 9 pass,
AMD-side S16 Laplacian rows still skip with the expected
one-shot status=-14 log (verifies the destructor flush works).
* opencv-mark --category multiscale,extraction: 15 pass, no
OOM on HOGFeatures at FHD.
* opencv-mark --category pipeline_vision,pipeline_feature,tensor:
15 pass, SobelMagnitudePhase/ThresholdedEdge measured cleanly
with no in-loop allocations.
CHANGELOG [Unreleased] block updated with the full per-fix rationale.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent e1b4298 commit 2659df3
10 files changed
Lines changed: 541 additions & 124 deletions
File tree
- opencv-mark/src/benchmarks
- scripts
- src
- benchmarks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
9 | 114 | | |
10 | 115 | | |
11 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
178 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
179 | 191 | | |
180 | 192 | | |
181 | 193 | | |
182 | 194 | | |
183 | | - | |
| 195 | + | |
184 | 196 | | |
185 | 197 | | |
186 | 198 | | |
187 | 199 | | |
188 | | - | |
189 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
190 | 207 | | |
191 | 208 | | |
192 | | - | |
193 | | - | |
| 209 | + | |
194 | 210 | | |
195 | | - | |
196 | | - | |
| 211 | + | |
| 212 | + | |
197 | 213 | | |
198 | 214 | | |
199 | 215 | | |
| |||
209 | 225 | | |
210 | 226 | | |
211 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
212 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
213 | 257 | | |
214 | 258 | | |
215 | 259 | | |
216 | 260 | | |
217 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
218 | 267 | | |
219 | 268 | | |
220 | 269 | | |
221 | 270 | | |
222 | | - | |
223 | | - | |
| 271 | + | |
| 272 | + | |
224 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
225 | 284 | | |
226 | 285 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
238 | 292 | | |
239 | 293 | | |
240 | 294 | | |
| |||
250 | 304 | | |
251 | 305 | | |
252 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
253 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
254 | 319 | | |
255 | 320 | | |
256 | 321 | | |
257 | 322 | | |
258 | | - | |
| 323 | + | |
259 | 324 | | |
260 | 325 | | |
261 | 326 | | |
262 | 327 | | |
263 | 328 | | |
264 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
265 | 335 | | |
266 | 336 | | |
267 | | - | |
268 | | - | |
269 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
270 | 343 | | |
271 | 344 | | |
272 | 345 | | |
273 | 346 | | |
274 | 347 | | |
275 | | - | |
276 | 348 | | |
277 | 349 | | |
278 | 350 | | |
| |||
291 | 363 | | |
292 | 364 | | |
293 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
294 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
295 | 378 | | |
296 | 379 | | |
297 | 380 | | |
298 | 381 | | |
299 | | - | |
| 382 | + | |
300 | 383 | | |
301 | 384 | | |
302 | 385 | | |
| 386 | + | |
303 | 387 | | |
304 | 388 | | |
305 | | - | |
| 389 | + | |
306 | 390 | | |
307 | 391 | | |
308 | 392 | | |
309 | 393 | | |
310 | | - | |
311 | | - | |
312 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
313 | 400 | | |
314 | 401 | | |
315 | 402 | | |
316 | 403 | | |
317 | 404 | | |
318 | 405 | | |
319 | 406 | | |
320 | | - | |
| 407 | + | |
| 408 | + | |
321 | 409 | | |
322 | 410 | | |
323 | 411 | | |
| |||
0 commit comments