From 879577b2dda6404191435337119fcfb4270dbdef Mon Sep 17 00:00:00 2001 From: Prasadayus <22bcs191@iiitdmj.ac.in> Date: Mon, 31 Aug 2026 16:23:26 +0530 Subject: [PATCH] avoid PPL auto_partitioner on ARM64 --- modules/core/src/parallel.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index 3aa72f9f44..f2884d2b2b 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -449,6 +449,18 @@ namespace { this->ParallelLoopBodyWrapper::operator()(cv::Range(i, i + 1)); } }; + + // PPL's default auto_partitioner silently skips whole chunks of the range on + // ARM64 (unfixed MSVC bug, developercommunity.visualstudio.com/t/1027444). + template + static inline void pplParallelFor(int first, int last, const Body& body) + { +#if defined(_M_ARM64) || defined(_M_ARM64EC) + Concurrency::parallel_for(first, last, body, Concurrency::static_partitioner()); +#else + Concurrency::parallel_for(first, last, body); +#endif + } #else typedef ParallelLoopBodyWrapper ProxyLoopBody; #endif @@ -593,18 +605,18 @@ static void parallel_for_impl(const cv::Range& range, const cv::ParallelLoopBody #elif defined WINRT - Concurrency::parallel_for(stripeRange.start, stripeRange.end, pbody); + pplParallelFor(stripeRange.start, stripeRange.end, pbody); #elif defined HAVE_CONCURRENCY if(!pplScheduler || pplScheduler->Id() == Concurrency::CurrentScheduler::Id()) { - Concurrency::parallel_for(stripeRange.start, stripeRange.end, pbody); + pplParallelFor(stripeRange.start, stripeRange.end, pbody); } else { pplScheduler->Attach(); - Concurrency::parallel_for(stripeRange.start, stripeRange.end, pbody); + pplParallelFor(stripeRange.start, stripeRange.end, pbody); Concurrency::CurrentScheduler::Detach(); }