Commit cc5190eb authored by Evgeny Latkin's avatar Evgeny Latkin Committed by Alexander Alekhin

Merge pull request #13133 from elatkin:el/gapi_perf_sobel_2

GAPI (fluid): Sobel 3x3 optimization: CV_SIMD dynamic dispatching (#13133)

* GAPI (fluid): Sobel 3x3: remove template for run_sobel_row()

* GAPI (fluid): Sobel 3x3: dynamic dispatching of CV_SIMD code

* GAPI (fluid): Sobel 3x3 optimization: fixed CV_SIMD dynamic dispatcher
parent 4e40e5bb
...@@ -69,7 +69,7 @@ set(gapi_srcs ...@@ -69,7 +69,7 @@ set(gapi_srcs
src/backends/fluid/gfluidbuffer.cpp src/backends/fluid/gfluidbuffer.cpp
src/backends/fluid/gfluidbackend.cpp src/backends/fluid/gfluidbackend.cpp
src/backends/fluid/gfluidimgproc.cpp src/backends/fluid/gfluidimgproc.cpp
src/backends/fluid/gfluidimgproc_func.cpp src/backends/fluid/gfluidimgproc_func.dispatch.cpp
src/backends/fluid/gfluidcore.cpp src/backends/fluid/gfluidcore.cpp
# GPU Backend (currently built-in) # GPU Backend (currently built-in)
...@@ -78,12 +78,13 @@ set(gapi_srcs ...@@ -78,12 +78,13 @@ set(gapi_srcs
src/backends/gpu/ggpuimgproc.cpp src/backends/gpu/ggpuimgproc.cpp
src/backends/gpu/ggpucore.cpp src/backends/gpu/ggpucore.cpp
# Compound # Compound
src/backends/common/gcompoundbackend.cpp src/backends/common/gcompoundbackend.cpp
src/backends/common/gcompoundkernel.cpp src/backends/common/gcompoundkernel.cpp
) )
ocv_add_dispatched_file(backends/fluid/gfluidimgproc_func SSE4_1 AVX2)
ocv_list_add_prefix(gapi_srcs "${CMAKE_CURRENT_LIST_DIR}/") ocv_list_add_prefix(gapi_srcs "${CMAKE_CURRENT_LIST_DIR}/")
# For IDE users # For IDE users
......
...@@ -768,7 +768,7 @@ static void run_sobel(Buffer& dst, ...@@ -768,7 +768,7 @@ static void run_sobel(Buffer& dst,
int y0 = dst.priv().writeStart(); int y0 = dst.priv().writeStart();
// int y1 = dst.priv().writeEnd(); // int y1 = dst.priv().writeEnd();
run_sobel_impl(out, in, width, chan, kx, ky, border, scale, delta, buf, y, y0); run_sobel_row(out, in, width, chan, kx, ky, border, scale, delta, buf, y, y0);
} }
GAPI_FLUID_KERNEL(GFluidSobel, cv::gapi::imgproc::GSobel, true) GAPI_FLUID_KERNEL(GFluidSobel, cv::gapi::imgproc::GSobel, true)
......
// 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) 2018 Intel Corporation
#if !defined(GAPI_STANDALONE)
#include "gfluidimgproc_func.hpp"
#include "gfluidimgproc_func.simd.hpp"
#if 1
// NB: workaround for CV_SIMD bug (or feature?):
// - dynamic dispatcher assumes *.simd.hpp is directly in src dir
#include "backends/fluid/gfluidimgproc_func.simd_declarations.hpp"
#else
#include "gfluidimgproc_func.simd_declarations.hpp"
#endif
#include "gfluidutils.hpp"
#include "opencv2/core/cvdef.h"
#include "opencv2/core/hal/intrin.hpp"
#include <cmath>
#include <cstdlib>
#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstrict-overflow"
#endif
namespace cv {
namespace gapi {
namespace fluid {
#define RUN_SOBEL_ROW(DST, SRC) \
void run_sobel_row(DST out[], const SRC *in[], int width, int chan, \
const float kx[], const float ky[], int border, \
float scale, float delta, float *buf[], \
int y, int y0) \
{ \
CV_CPU_DISPATCH(run_sobel_row, \
(out, in, width, chan, kx, ky, border, scale, delta, buf,y, y0), \
CV_CPU_DISPATCH_MODES_ALL); \
}
RUN_SOBEL_ROW(uchar , uchar )
RUN_SOBEL_ROW(ushort, ushort)
RUN_SOBEL_ROW( short, uchar )
RUN_SOBEL_ROW( short, ushort)
RUN_SOBEL_ROW( short, short)
RUN_SOBEL_ROW( float, uchar )
RUN_SOBEL_ROW( float, ushort)
RUN_SOBEL_ROW( float, short)
RUN_SOBEL_ROW( float, float)
#undef RUN_SOBEL_ROW
} // namespace fliud
} // namespace gapi
} // namespace cv
#endif // !defined(GAPI_STANDALONE)
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#if !defined(GAPI_STANDALONE) #if !defined(GAPI_STANDALONE)
#include "opencv2/core.hpp"
namespace cv { namespace cv {
namespace gapi { namespace gapi {
namespace fluid { namespace fluid {
...@@ -18,11 +20,23 @@ namespace fluid { ...@@ -18,11 +20,23 @@ namespace fluid {
// //
//--------------------- //---------------------
template<typename DST, typename SRC> #define RUN_SOBEL_ROW(DST, SRC) \
void run_sobel_impl(DST out[], const SRC *in[], int width, int chan, void run_sobel_row(DST out[], const SRC *in[], int width, int chan, \
const float kx[], const float ky[], int border, const float kx[], const float ky[], int border, \
float scale, float delta, float *buf[], float scale, float delta, float *buf[], \
int y, int y0); int y, int y0);
RUN_SOBEL_ROW(uchar , uchar )
RUN_SOBEL_ROW(ushort, ushort)
RUN_SOBEL_ROW( short, uchar )
RUN_SOBEL_ROW( short, ushort)
RUN_SOBEL_ROW( short, short)
RUN_SOBEL_ROW( float, uchar )
RUN_SOBEL_ROW( float, ushort)
RUN_SOBEL_ROW( float, short)
RUN_SOBEL_ROW( float, float)
#undef RUN_SOBEL_ROW
} // namespace fluid } // namespace fluid
} // namespace gapi } // namespace gapi
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment