zhangjinhan fb96a94a03 Merge pull request #29930 from Xlawy:opt/rvv-reduce-sum2-32f
core: optimize float REDUCE_SUM2 with RVV - #29930

### Summary

Add an RVV 1.0 kernel for `cv::reduce` with `dim=0` and `CV_32F`
input/output through the CPU dispatch mechanism.

The optimized path targets the floating-point `REDUCE_SUM2` operation.

### Implementation

Process four source rows per vector iteration to reduce intermediate
buffer traffic while preserving source-row accumulation order.

The RVV kernel uses LMUL=4 and dynamic vector lengths for tail handling.

Output writes are deferred until all input rows have been read. This
preserves correct behavior when the source and destination matrices
overlap.

The implementation is VLEN-agnostic.

### Functional Testing

The Reduce tests were run with:

```bash
./bin/opencv_test_core \
    --gtest_filter='*Reduce*:*reduce*' \
    --test_threads=1
```

### Performance Testing

Performance was measured with:

```bash
./bin/opencv_perf_core \
    --gtest_filter='*reduceR*' \
    --perf_threads=1
```

Test environment:

- SpacemiT K3
- VLEN = 256
- GCC 14.3.0
- Release build
- Single thread
- 10 samples per case

Results were compared against an unmodified `5.x` baseline.

`CV_32FC1 REDUCE_SUM2` median execution time (ms):

| Size | Baseline | Patched | Speedup |
| --- | ---: | ---: | ---: |
| 640x480 | 0.20 | 0.08 | 2.50x |
| 1280x720 | 0.64 | 0.29 | 2.21x |
| 1920x1080 | 1.33 | 1.05 | 1.27x |

Speedups are approximate and calculated from the rounded benchmark
output.

### Co-authors

- Yang Wang <yangwang@iscas.ac.cn>
- Yuansheng <yuansheng@isrc.iscas.ac.cn>

### Pull Request Readiness Checklist

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2026-09-18 14:56:16 +03:00
2026-09-17 11:51:55 +03:00
2026-07-28 20:27:29 +05:30
2018-10-11 17:57:51 +00:00
2025-08-07 10:35:20 +03:00

OpenCV: Open Source Computer Vision Library

Resources

Contributing

Please read the contribution guidelines before starting work on a pull request.

Summary of the guidelines:

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.

Additional Resources

Languages
C++ 86%
Python 4.1%
C 2.9%
CMake 2.2%
Java 1.6%
Other 3.1%