From ab2ae86e867a6cb3e3946251bd788a27b3bdbfd4 Mon Sep 17 00:00:00 2001 From: Kirill Kornyakov Date: Thu, 1 Dec 2011 11:07:25 +0000 Subject: [PATCH] Optimized version of Reduce functions added --- modules/core/src/matrix.cpp | 60 +++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 8188c1b..6b233c4 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -1976,8 +1976,13 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype) { if( op == CV_REDUCE_SUM ) { - if(sdepth == CV_8U && ddepth == CV_32S) + if(sdepth == CV_8U && ddepth == CV_32S) { +#ifdef HAVE_TEGRA_OPTIMIZATION + func = tegra::getTegraOptimized_reduceR8uAdd(tegra::reduceR8uAdd); +#else func = reduceR_ >; +#endif + } else if(sdepth == CV_8U && ddepth == CV_32F) func = reduceR_ >; else if(sdepth == CV_8U && ddepth == CV_64F) @@ -1988,38 +1993,63 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype) func = reduceR_ >; else if(sdepth == CV_16S && ddepth == CV_32F) func = reduceR_ >; - else if(sdepth == CV_16S && ddepth == CV_64F) - func = reduceR_ >; - else if(sdepth == CV_32F && ddepth == CV_32F) + else if(sdepth == CV_16S && ddepth == CV_64F) + func = reduceR_ >; + else if(sdepth == CV_32F && ddepth == CV_32F) { +#ifdef HAVE_TEGRA_OPTIMIZATION + func = tegra::getTegraOptimized_reduceR32fAdd(tegra::reduceR32fAdd); +#else func = reduceR_ >; - else if(sdepth == CV_32F && ddepth == CV_64F) +#endif + } + else if(sdepth == CV_32F && ddepth == CV_64F) func = reduceR_ >; else if(sdepth == CV_64F && ddepth == CV_64F) func = reduceR_ >; } else if(op == CV_REDUCE_MAX) { - if(sdepth == CV_8U && ddepth == CV_8U) + if(sdepth == CV_8U && ddepth == CV_8U) { +#ifdef HAVE_TEGRA_OPTIMIZATION + func = tegra::getTegraOptimized_reduceR8uMax(tegra::reduceR8uMax); +#else func = reduceR_ >; +#endif + } else if(sdepth == CV_16U && ddepth == CV_16U) func = reduceR_ >; else if(sdepth == CV_16S && ddepth == CV_16S) func = reduceR_ >; - else if(sdepth == CV_32F && ddepth == CV_32F) + else if(sdepth == CV_32F && ddepth == CV_32F) { +#ifdef HAVE_TEGRA_OPTIMIZATION + func = tegra::getTegraOptimized_reduceR32fMax(tegra::reduceR32fMax); +#else func = reduceR_ >; +#endif + } else if(sdepth == CV_64F && ddepth == CV_64F) func = reduceR_ >; } else if(op == CV_REDUCE_MIN) { - if(sdepth == CV_8U && ddepth == CV_8U) + if(sdepth == CV_8U && ddepth == CV_8U) { +#ifdef HAVE_TEGRA_OPTIMIZATION + func = tegra::getTegraOptimized_reduceR8uMin(tegra::reduceR8uMin); +#else func = reduceR_ >; +#endif + } else if(sdepth == CV_16U && ddepth == CV_16U) func = reduceR_ >; else if(sdepth == CV_16S && ddepth == CV_16S) func = reduceR_ >; - else if(sdepth == CV_32F && ddepth == CV_32F) + else if(sdepth == CV_32F && ddepth == CV_32F) { +#ifdef HAVE_TEGRA_OPTIMIZATION + func = tegra::getTegraOptimized_reduceR32fMin(tegra::reduceR32fMin); +#else func = reduceR_ >; +#endif + } else if(sdepth == CV_64F && ddepth == CV_64F) func = reduceR_ >; } @@ -2028,7 +2058,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype) { if(op == CV_REDUCE_SUM) { - if(sdepth == CV_8U && ddepth == CV_32S) + if(sdepth == CV_8U && ddepth == CV_32S) func = reduceC_ >; else if(sdepth == CV_8U && ddepth == CV_32F) func = reduceC_ >; @@ -2042,7 +2072,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype) func = reduceC_ >; else if(sdepth == CV_16S && ddepth == CV_64F) func = reduceC_ >; - else if(sdepth == CV_32F && ddepth == CV_32F) + else if(sdepth == CV_32F && ddepth == CV_32F) func = reduceC_ >; else if(sdepth == CV_32F && ddepth == CV_64F) func = reduceC_ >; @@ -2051,26 +2081,26 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype) } else if(op == CV_REDUCE_MAX) { - if(sdepth == CV_8U && ddepth == CV_8U) + if(sdepth == CV_8U && ddepth == CV_8U) func = reduceC_ >; else if(sdepth == CV_16U && ddepth == CV_16U) func = reduceC_ >; else if(sdepth == CV_16S && ddepth == CV_16S) func = reduceC_ >; - else if(sdepth == CV_32F && ddepth == CV_32F) + else if(sdepth == CV_32F && ddepth == CV_32F) func = reduceC_ >; else if(sdepth == CV_64F && ddepth == CV_64F) func = reduceC_ >; } else if(op == CV_REDUCE_MIN) { - if(sdepth == CV_8U && ddepth == CV_8U) + if(sdepth == CV_8U && ddepth == CV_8U) func = reduceC_ >; else if(sdepth == CV_16U && ddepth == CV_16U) func = reduceC_ >; else if(sdepth == CV_16S && ddepth == CV_16S) func = reduceC_ >; - else if(sdepth == CV_32F && ddepth == CV_32F) + else if(sdepth == CV_32F && ddepth == CV_32F) func = reduceC_ >; else if(sdepth == CV_64F && ddepth == CV_64F) func = reduceC_ >; -- 2.7.4