1010
1111#include < boost/gil.hpp>
1212
13+ inline bool is_odd (benchmark::IterationCount cnt) { return (cnt % 2 ); }
14+
1315static void ipp_flip_left_right (benchmark::State& state)
1416{
1517 using namespace boost ::gil;
@@ -24,11 +26,14 @@ static void ipp_flip_left_right(benchmark::State& state)
2426
2527 for (auto _ : state) {
2628 // The code to benchmark
27- ippiMirror_8u_C1R (
28- boost::gil::interleaved_view_get_raw_data (const_view (in)), (int ) in. width (),
29- boost::gil::interleaved_view_get_raw_data (view (out)), (int ) out. width (),
29+ auto res = ippiMirror_8u_C1R (
30+ boost::gil::interleaved_view_get_raw_data (const_view (in)), (int )const_view (in). pixels (). row_size (),
31+ boost::gil::interleaved_view_get_raw_data (view (out)), (int )view (in). pixels (). row_size (),
3032 srcRoi,
3133 ippAxsVertical);
34+
35+ if (res != ippStsNoErr)
36+ state.SkipWithError (" ipp_flip_left_right failed" );
3237 }
3338
3439 if (!equal_pixels (flipped_left_right_view (const_view (in)), const_view (out)))
@@ -50,14 +55,23 @@ static void ipp_flip_left_right_inplace(benchmark::State& state)
5055
5156 for (auto _ : state) {
5257 // The code to benchmark
53- ippiMirror_8u_C1IR (
54- boost::gil::interleaved_view_get_raw_data (view (in)), (int ) in. width (),
58+ auto res = ippiMirror_8u_C1IR (
59+ boost::gil::interleaved_view_get_raw_data (view (in)), (int )view (in). pixels (). row_size (),
5560 srcRoi,
5661 ippAxsVertical);
62+
63+ if (res != ippStsNoErr)
64+ state.SkipWithError (" ipp_flip_left_right_inplace failed" );
65+ }
66+
67+ if (is_odd (state.iterations ())) {
68+ if (!equal_pixels (flipped_left_right_view (const_view (in_ref)), const_view (in)))
69+ state.SkipWithError (" ipp_flip_left_right_inplace wrong result" );
70+ }
71+ else {
72+ if (!equal_pixels (const_view (in_ref), const_view (in)))
73+ state.SkipWithError (" ipp_flip_left_right_inplace wrong result" );
5774 }
58-
59- if (!equal_pixels (flipped_left_right_view (const_view (in)), const_view (in_ref)))
60- state.SkipWithError (" ipp_flip_left_right_inplace wrong result" );
6175}
6276BENCHMARK (ipp_flip_left_right_inplace)->RangeMultiplier(2 )->Range(256 , 8 << 10 );
6377
@@ -75,15 +89,24 @@ static void ipp_flip_up_down(benchmark::State& state)
7589
7690 for (auto _ : state) {
7791 // The code to benchmark
78- ippiMirror_8u_C1R (
79- boost::gil::interleaved_view_get_raw_data (const_view (in)), (int ) in. width (),
80- boost::gil::interleaved_view_get_raw_data (view (out)), (int ) out. width (),
92+ auto res = ippiMirror_8u_C1R (
93+ boost::gil::interleaved_view_get_raw_data (const_view (in)), (int )const_view (in). pixels (). row_size (),
94+ boost::gil::interleaved_view_get_raw_data (view (out)), (int )view ( out). pixels (). row_size (),
8195 srcRoi,
8296 ippAxsHorizontal);
97+
98+ if (res != ippStsNoErr)
99+ state.SkipWithError (" ipp_flip_up_down failed" );
100+ }
101+
102+ if (is_odd (state.iterations ())) {
103+ if (!equal_pixels (flipped_up_down_view (const_view (in)), const_view (out)))
104+ state.SkipWithError (" ipp_flip_up_down wrong result" );
105+ }
106+ else {
107+ if (!equal_pixels (const_view (in), const_view (out)))
108+ state.SkipWithError (" ipp_flip_up_down wrong result" );
83109 }
84-
85- if (!equal_pixels (flipped_left_right_view (const_view (in)), const_view (out)))
86- state.SkipWithError (" ipp_flip_up_down wrong result" );
87110}
88111BENCHMARK (ipp_flip_up_down)->RangeMultiplier(2 )->Range(256 , 8 << 10 );
89112
@@ -101,13 +124,16 @@ static void ipp_flip_up_down_inplace(benchmark::State& state)
101124
102125 for (auto _ : state) {
103126 // The code to benchmark
104- ippiMirror_8u_C1IR (
105- boost::gil::interleaved_view_get_raw_data (view (in)), (int ) in. width (),
127+ auto res = ippiMirror_8u_C1IR (
128+ boost::gil::interleaved_view_get_raw_data (view (in)), (int )view (in). pixels (). row_size (),
106129 srcRoi,
107130 ippAxsHorizontal);
131+
132+ if (res != ippStsNoErr)
133+ state.SkipWithError (" ipp_flip_up_down_inplace failed" );
108134 }
109135
110- if (!equal_pixels (flipped_left_right_view (const_view (in )), const_view (in_ref )))
136+ if (!equal_pixels (flipped_up_down_view (const_view (in_ref )), const_view (in )))
111137 state.SkipWithError (" ipp_flip_up_down_inplace wrong result" );
112138}
113139BENCHMARK (ipp_flip_up_down_inplace)->RangeMultiplier(2 )->Range(256 , 8 << 10 );
0 commit comments