Files
opencv-MIRROR/modules/core/src/stat.dispatch.cpp
Madan mohan Manokar 498e4692d6 Merge pull request #29479 from amd:5_fast_norm_simd
core: SIMD optimizations for norm, distance and Hamming APIs (5.x) #29479

- Cache normHamming SIMD impl via a function pointer to cut per-call dispatch cost (improves ORB & BRISK)
- Add masked norm and norm-diff SIMD kernels (incl. cn==4 paths) and AVX-512 dispatch for norm/stat
- Add brute-force matcher perf test
- Alternative port of PR #29335 adapted to the 5.x norm.simd.hpp structure

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-07-10 18:31:01 +03:00

37 lines
1.2 KiB
C++

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2026, Advanced Micro Devices, Inc., all rights reserved.
#include "precomp.hpp"
#include "stat.simd.hpp"
#include "stat.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
namespace cv { namespace hal {
// Resolve the SIMD implementation ONCE via a cached function pointer. normHamming
// is called per-descriptor in hot matcher loops on short (32/64-byte) descriptors,
// where a per-call dispatch chain + CV_INSTRUMENT_REGION dominate the cost.
static NormHammingFunc getNormHammingFunc() {
CV_CPU_DISPATCH(getNormHammingFunc, (), CV_CPU_DISPATCH_MODES_ALL);
}
static NormHammingDiffFunc getNormHammingDiffFunc() {
CV_CPU_DISPATCH(getNormHammingDiffFunc, (), CV_CPU_DISPATCH_MODES_ALL);
}
int normHamming(const uchar* a, int n)
{
static const NormHammingFunc fn = getNormHammingFunc();
return fn(a, n);
}
int normHamming(const uchar* a, const uchar* b, int n)
{
static const NormHammingDiffFunc fn = getNormHammingDiffFunc();
return fn(a, b, n);
}
}} //cv::hal