Commit c629cb3a authored by Frank Barchard's avatar Frank Barchard

add command line cpu info to allow android neon test

in order to compare C and Neon code, a new command line flag is added.
historically environment variables controlled cpu features, but on
android apk it is easier to pass a command line option to disable cpu
optimizations.

R=harryjin@google.com
BUG=libyuv:516

Review URL: https://codereview.chromium.org/1407193009 .
parent 1f1d140b
......@@ -37,7 +37,7 @@ namespace libyuv {
#endif
#define TESTCS(TESTNAME, YUVTOARGB, ARGBTOYUV, HS1, HS, HN, DIFF) \
TEST_F(LibYUVColorTest, TESTNAME) { \
TEST_F(LibYUVColorTest, TESTNAME) { \
const int kPixels = benchmark_width_ * benchmark_height_; \
const int kHalfPixels = ((benchmark_width_ + 1) / 2) * \
((benchmark_height_ + HS1) / HS); \
......@@ -101,7 +101,7 @@ namespace libyuv {
temp_v, (benchmark_width_ + 1) / 2, \
dst_pixels_c, benchmark_width_ * 4, \
benchmark_width_, benchmark_height_); \
MaskCpuFlags(-1); \
MaskCpuFlags(benchmark_cpu_info_); \
\
for (int i = 0; i < benchmark_iterations_; ++i) { \
YUVTOARGB(temp_y, benchmark_width_, \
......
......@@ -264,7 +264,7 @@ TEST_F(LibYUVBaseTest, SumSquareError) {
MaskCpuFlags(disable_cpu_flags_);
uint64 c_err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
MaskCpuFlags(-1);
MaskCpuFlags(benchmark_cpu_info_);
uint64 opt_err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
EXPECT_EQ(c_err, opt_err);
......@@ -281,7 +281,7 @@ TEST_F(LibYUVBaseTest, BenchmarkPsnr_Opt) {
src_b[i] = i;
}
MaskCpuFlags(-1);
MaskCpuFlags(benchmark_cpu_info_);
double opt_time = get_time();
for (int i = 0; i < benchmark_iterations_; ++i)
......@@ -306,7 +306,7 @@ TEST_F(LibYUVBaseTest, BenchmarkPsnr_Unaligned) {
src_b[i] = i;
}
MaskCpuFlags(-1);
MaskCpuFlags(benchmark_cpu_info_);
double opt_time = get_time();
for (int i = 0; i < benchmark_iterations_; ++i)
......@@ -388,7 +388,7 @@ TEST_F(LibYUVBaseTest, Psnr) {
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
MaskCpuFlags(-1);
MaskCpuFlags(benchmark_cpu_info_);
opt_err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
......@@ -408,7 +408,7 @@ TEST_F(LibYUVBaseTest, DISABLED_BenchmarkSsim_Opt) {
src_b[i] = i;
}
MaskCpuFlags(-1);
MaskCpuFlags(benchmark_cpu_info_);
double opt_time = get_time();
for (int i = 0; i < benchmark_iterations_; ++i)
......@@ -497,7 +497,7 @@ TEST_F(LibYUVBaseTest, Ssim) {
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
MaskCpuFlags(-1);
MaskCpuFlags(benchmark_cpu_info_);
opt_err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
......
This diff is collapsed.
......@@ -52,7 +52,16 @@ TEST_F(LibYUVBaseTest, TestCpuHas) {
printf("Has MIPS DSPR2 %x\n", has_mips_dspr2);
}
TEST_F(LibYUVBaseTest, TestCompilerHasAVX2) {
TEST_F(LibYUVBaseTest, TestCpuCompilerEnabled) {
#if defined(__aarch64__)
printf("Arm64 build\n");
#endif
#if defined(__aarch64__) || defined(__ARM_NEON__) || defined(LIBYUV_NEON)
printf("Neon build enabled\n");
#endif
#if defined(__x86_64__) || defined(_M_X64)
printf("x64 build\n");
#endif
#ifdef _MSC_VER
printf("_MSC_VER %d\n", _MSC_VER);
#endif
......
This diff is collapsed.
......@@ -20,7 +20,9 @@ namespace libyuv {
void TestRotateBpp(int src_width, int src_height,
int dst_width, int dst_height,
libyuv::RotationMode mode,
int benchmark_iterations, int disable_cpu_flags,
int benchmark_iterations,
int disable_cpu_flags,
int benchmark_cpu_info,
const int kBpp) {
if (src_width < 1) {
src_width = 1;
......@@ -54,7 +56,7 @@ void TestRotateBpp(int src_width, int src_height,
dst_argb_c, dst_stride_argb,
src_width, src_height, mode);
MaskCpuFlags(-1); // Enable all CPU optimization.
MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
for (int i = 0; i < benchmark_iterations; ++i) {
RotatePlane(src_argb, src_stride_argb,
dst_argb_opt, dst_stride_argb,
......@@ -66,7 +68,7 @@ void TestRotateBpp(int src_width, int src_height,
dst_argb_c, dst_stride_argb,
src_width, src_height, mode);
MaskCpuFlags(-1); // Enable all CPU optimization.
MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
for (int i = 0; i < benchmark_iterations; ++i) {
ARGBRotate(src_argb, src_stride_argb,
dst_argb_opt, dst_stride_argb,
......@@ -87,115 +89,137 @@ void TestRotateBpp(int src_width, int src_height,
static void ARGBTestRotate(int src_width, int src_height,
int dst_width, int dst_height,
libyuv::RotationMode mode,
int benchmark_iterations, int disable_cpu_flags) {
int benchmark_iterations,
int disable_cpu_flags,
int benchmark_cpu_info) {
TestRotateBpp(src_width, src_height,
dst_width, dst_height,
mode, benchmark_iterations, disable_cpu_flags, 4);
mode, benchmark_iterations,
disable_cpu_flags, benchmark_cpu_info, 4);
}
TEST_F(LibYUVRotateTest, ARGBRotate0) {
ARGBTestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_,
kRotate0, benchmark_iterations_, disable_cpu_flags_);
kRotate0, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, ARGBRotate90) {
ARGBTestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_,
kRotate90, benchmark_iterations_, disable_cpu_flags_);
kRotate90, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, ARGBRotate180) {
ARGBTestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_,
kRotate180, benchmark_iterations_, disable_cpu_flags_);
kRotate180, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, ARGBRotate270) {
ARGBTestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_,
kRotate270, benchmark_iterations_, disable_cpu_flags_);
kRotate270, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, ARGBRotate0_Odd) {
ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1,
kRotate0, benchmark_iterations_, disable_cpu_flags_);
kRotate0, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, ARGBRotate90_Odd) {
ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3,
kRotate90, benchmark_iterations_, disable_cpu_flags_);
kRotate90, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, ARGBRotate180_Odd) {
ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1,
kRotate180, benchmark_iterations_, disable_cpu_flags_);
kRotate180, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, ARGBRotate270_Odd) {
ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3,
kRotate270, benchmark_iterations_, disable_cpu_flags_);
kRotate270, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
static void TestRotatePlane(int src_width, int src_height,
int dst_width, int dst_height,
libyuv::RotationMode mode,
int benchmark_iterations, int disable_cpu_flags) {
int benchmark_iterations,
int disable_cpu_flags,
int benchmark_cpu_info) {
TestRotateBpp(src_width, src_height,
dst_width, dst_height,
mode, benchmark_iterations, disable_cpu_flags, 1);
mode, benchmark_iterations,
disable_cpu_flags, benchmark_cpu_info, 1);
}
TEST_F(LibYUVRotateTest, RotatePlane0) {
TestRotatePlane(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_,
kRotate0, benchmark_iterations_, disable_cpu_flags_);
kRotate0, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, RotatePlane90) {
TestRotatePlane(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_,
kRotate90, benchmark_iterations_, disable_cpu_flags_);
kRotate90, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, RotatePlane180) {
TestRotatePlane(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_,
kRotate180, benchmark_iterations_, disable_cpu_flags_);
kRotate180, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, RotatePlane270) {
TestRotatePlane(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_,
kRotate270, benchmark_iterations_, disable_cpu_flags_);
kRotate270, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, RotatePlane0_Odd) {
TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1,
kRotate0, benchmark_iterations_, disable_cpu_flags_);
kRotate0, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, RotatePlane90_Odd) {
TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3,
kRotate90, benchmark_iterations_, disable_cpu_flags_);
kRotate90, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, RotatePlane180_Odd) {
TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1,
kRotate180, benchmark_iterations_, disable_cpu_flags_);
kRotate180, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, RotatePlane270_Odd) {
TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3,
kRotate270, benchmark_iterations_, disable_cpu_flags_);
kRotate270, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
} // namespace libyuv
......@@ -20,7 +20,8 @@ namespace libyuv {
static void I420TestRotate(int src_width, int src_height,
int dst_width, int dst_height,
libyuv::RotationMode mode,
int benchmark_iterations, int disable_cpu_flags) {
int benchmark_iterations,
int disable_cpu_flags, int benchmark_cpu_info) {
if (src_width < 1) {
src_width = 1;
}
......@@ -59,7 +60,7 @@ static void I420TestRotate(int src_width, int src_height,
(dst_width + 1) / 2,
src_width, src_height, mode);
MaskCpuFlags(-1); // Enable all CPU optimization.
MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
for (int i = 0; i < benchmark_iterations; ++i) {
I420Rotate(src_i420, src_width,
src_i420 + src_i420_y_size, (src_width + 1) / 2,
......@@ -85,55 +86,64 @@ static void I420TestRotate(int src_width, int src_height,
TEST_F(LibYUVRotateTest, I420Rotate0) {
I420TestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_,
kRotate0, benchmark_iterations_, disable_cpu_flags_);
kRotate0, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, I420Rotate90) {
I420TestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_,
kRotate90, benchmark_iterations_, disable_cpu_flags_);
kRotate90, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, I420Rotate180) {
I420TestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_,
kRotate180, benchmark_iterations_, disable_cpu_flags_);
kRotate180, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, I420Rotate270) {
I420TestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_,
kRotate270, benchmark_iterations_, disable_cpu_flags_);
kRotate270, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, I420Rotate0_Odd) {
I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1,
kRotate0, benchmark_iterations_, disable_cpu_flags_);
kRotate0, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, I420Rotate90_Odd) {
I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3,
kRotate90, benchmark_iterations_, disable_cpu_flags_);
kRotate90, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, I420Rotate180_Odd) {
I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1,
kRotate180, benchmark_iterations_, disable_cpu_flags_);
kRotate180, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, I420Rotate270_Odd) {
I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3,
kRotate270, benchmark_iterations_, disable_cpu_flags_);
kRotate270, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
static void NV12TestRotate(int src_width, int src_height,
int dst_width, int dst_height,
libyuv::RotationMode mode,
int benchmark_iterations, int disable_cpu_flags) {
int benchmark_iterations,
int disable_cpu_flags, int benchmark_cpu_info) {
if (src_width < 1) {
src_width = 1;
}
......@@ -172,7 +182,7 @@ static void NV12TestRotate(int src_width, int src_height,
(dst_width + 1) / 2,
src_width, src_height, mode);
MaskCpuFlags(-1); // Enable all CPU optimization.
MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
for (int i = 0; i < benchmark_iterations; ++i) {
NV12ToI420Rotate(src_nv12, src_width,
src_nv12 + src_nv12_y_size, (src_width + 1) & ~1,
......@@ -196,73 +206,85 @@ static void NV12TestRotate(int src_width, int src_height,
TEST_F(LibYUVRotateTest, NV12Rotate0) {
NV12TestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_,
kRotate0, benchmark_iterations_, disable_cpu_flags_);
kRotate0, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, NV12Rotate90) {
NV12TestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_,
kRotate90, benchmark_iterations_, disable_cpu_flags_);
kRotate90, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, NV12Rotate180) {
NV12TestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_,
kRotate180, benchmark_iterations_, disable_cpu_flags_);
kRotate180, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, NV12Rotate270) {
NV12TestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_,
kRotate270, benchmark_iterations_, disable_cpu_flags_);
kRotate270, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, NV12Rotate0_Odd) {
NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1,
kRotate0, benchmark_iterations_, disable_cpu_flags_);
kRotate0, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, NV12Rotate90_Odd) {
NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3,
kRotate90, benchmark_iterations_, disable_cpu_flags_);
kRotate90, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, NV12Rotate180_Odd) {
NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1,
kRotate180, benchmark_iterations_, disable_cpu_flags_);
kRotate180, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, NV12Rotate270_Odd) {
NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3,
kRotate270, benchmark_iterations_, disable_cpu_flags_);
kRotate270, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, NV12Rotate0_Inverted) {
NV12TestRotate(benchmark_width_, -benchmark_height_,
benchmark_width_, benchmark_height_,
kRotate0, benchmark_iterations_, disable_cpu_flags_);
kRotate0, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, NV12Rotate90_Inverted) {
NV12TestRotate(benchmark_width_, -benchmark_height_,
benchmark_height_, benchmark_width_,
kRotate90, benchmark_iterations_, disable_cpu_flags_);
kRotate90, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, NV12Rotate180_Inverted) {
NV12TestRotate(benchmark_width_, -benchmark_height_,
benchmark_width_, benchmark_height_,
kRotate180, benchmark_iterations_, disable_cpu_flags_);
kRotate180, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
TEST_F(LibYUVRotateTest, NV12Rotate270_Inverted) {
NV12TestRotate(benchmark_width_, -benchmark_height_,
benchmark_height_, benchmark_width_,
kRotate270, benchmark_iterations_, disable_cpu_flags_);
kRotate270, benchmark_iterations_,
disable_cpu_flags_, benchmark_cpu_info_);
}
......
......@@ -25,7 +25,7 @@ namespace libyuv {
static int ARGBTestFilter(int src_width, int src_height,
int dst_width, int dst_height,
FilterMode f, int benchmark_iterations,
int disable_cpu_flags) {
int disable_cpu_flags, int benchmark_cpu_info) {
int i, j;
const int b = 0; // 128 to test for padding/stride.
int64 src_argb_plane_size = (Abs(src_width) + b * 2) *
......@@ -57,7 +57,7 @@ static int ARGBTestFilter(int src_width, int src_height,
src_width, src_height,
dst_argb_c + (dst_stride_argb * b) + b * 4, dst_stride_argb,
dst_width, dst_height, f);
MaskCpuFlags(-1); // Enable all CPU optimization.
MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
src_width, src_height,
dst_argb_opt + (dst_stride_argb * b) + b * 4, dst_stride_argb,
......@@ -72,7 +72,7 @@ static int ARGBTestFilter(int src_width, int src_height,
c_time = (get_time() - c_time);
MaskCpuFlags(-1); // Enable all CPU optimization.
MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
double opt_time = get_time();
for (i = 0; i < benchmark_iterations; ++i) {
ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
......@@ -224,7 +224,7 @@ static int ARGBClipTestFilter(int src_width, int src_height,
DX(benchmark_width_, nom, denom), \
DX(benchmark_height_, nom, denom), \
kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
disable_cpu_flags_, benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
TEST_F(LibYUVScaleTest, ARGBScaleDownClipBy##name##_##filter) { \
......@@ -260,14 +260,14 @@ TEST_FACTOR(3, 1, 3)
int diff = ARGBTestFilter(benchmark_width_, benchmark_height_, \
width, height, \
kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
disable_cpu_flags_, benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
TEST_F(LibYUVScaleTest, name##From##width##x##height##_##filter) { \
int diff = ARGBTestFilter(width, height, \
Abs(benchmark_width_), Abs(benchmark_height_), \
kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
disable_cpu_flags_, benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
TEST_F(LibYUVScaleTest, name##ClipTo##width##x##height##_##filter) { \
......
......@@ -24,7 +24,7 @@ namespace libyuv {
static int TestFilter(int src_width, int src_height,
int dst_width, int dst_height,
FilterMode f, int benchmark_iterations,
int disable_cpu_flags) {
int disable_cpu_flags, int benchmark_cpu_info) {
int i, j;
const int b = 0; // 128 to test for padding/stride.
int src_width_uv = (Abs(src_width) + 1) >> 1;
......@@ -80,7 +80,7 @@ static int TestFilter(int src_width, int src_height,
dst_width, dst_height, f);
c_time = (get_time() - c_time);
MaskCpuFlags(-1); // Enable all CPU optimization.
MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
double opt_time = get_time();
for (i = 0; i < benchmark_iterations; ++i) {
I420Scale(src_y + (src_stride_y * b) + b, src_stride_y,
......@@ -284,7 +284,7 @@ static int TestFilter_16(int src_width, int src_height,
DX(benchmark_width_, nom, denom), \
DX(benchmark_height_, nom, denom), \
kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
disable_cpu_flags_, benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
TEST_F(LibYUVScaleTest, DISABLED_ScaleDownBy##name##_##filter##_16) { \
......@@ -320,14 +320,14 @@ TEST_FACTOR(3, 1, 3)
int diff = TestFilter(benchmark_width_, benchmark_height_, \
width, height, \
kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
disable_cpu_flags_, benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
TEST_F(LibYUVScaleTest, name##From##width##x##height##_##filter) { \
int diff = TestFilter(width, height, \
Abs(benchmark_width_), Abs(benchmark_height_), \
kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
disable_cpu_flags_, benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
TEST_F(LibYUVScaleTest, \
......
......@@ -27,6 +27,8 @@ DEFINE_int32(libyuv_width, 0, "width of test image.");
DEFINE_int32(libyuv_height, 0, "height of test image.");
DEFINE_int32(libyuv_repeat, 0, "number of times to repeat test.");
DEFINE_int32(libyuv_flags, 0, "cpu flags for reference code. 0 = C -1 = asm");
DEFINE_int32(libyuv_cpu_info, -1,
"cpu flags for benchmark code. -1 = SIMD, 1 = C");
// For quicker unittests, default is 128 x 72. But when benchmarking,
// default to 720p. Allow size to specify.
......@@ -34,7 +36,7 @@ DEFINE_int32(libyuv_flags, 0, "cpu flags for reference code. 0 = C -1 = asm");
LibYUVConvertTest::LibYUVConvertTest() :
benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(130),
benchmark_height_(72), disable_cpu_flags_(0) {
benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) {
const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT
......@@ -67,6 +69,13 @@ LibYUVConvertTest::LibYUVConvertTest() :
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
const char* cpu_info = getenv("LIBYUV_CPU_INFO");
if (cpu_info) {
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
......@@ -79,7 +88,7 @@ LibYUVConvertTest::LibYUVConvertTest() :
LibYUVColorTest::LibYUVColorTest() :
benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
benchmark_height_(72), disable_cpu_flags_(0) {
benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) {
const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT
......@@ -112,6 +121,13 @@ LibYUVColorTest::LibYUVColorTest() :
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
const char* cpu_info = getenv("LIBYUV_CPU_INFO");
if (cpu_info) {
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
......@@ -124,7 +140,7 @@ LibYUVColorTest::LibYUVColorTest() :
LibYUVScaleTest::LibYUVScaleTest() :
benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
benchmark_height_(72), disable_cpu_flags_(0) {
benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) {
const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT
......@@ -157,6 +173,13 @@ LibYUVScaleTest::LibYUVScaleTest() :
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
const char* cpu_info = getenv("LIBYUV_CPU_INFO");
if (cpu_info) {
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
......@@ -169,7 +192,7 @@ LibYUVScaleTest::LibYUVScaleTest() :
LibYUVRotateTest::LibYUVRotateTest() :
benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
benchmark_height_(72), disable_cpu_flags_(0) {
benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) {
const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT
......@@ -202,6 +225,13 @@ LibYUVRotateTest::LibYUVRotateTest() :
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
const char* cpu_info = getenv("LIBYUV_CPU_INFO");
if (cpu_info) {
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
......@@ -214,7 +244,7 @@ LibYUVRotateTest::LibYUVRotateTest() :
LibYUVPlanarTest::LibYUVPlanarTest() :
benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
benchmark_height_(72), disable_cpu_flags_(0) {
benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) {
const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT
......@@ -247,6 +277,13 @@ LibYUVPlanarTest::LibYUVPlanarTest() :
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
const char* cpu_info = getenv("LIBYUV_CPU_INFO");
if (cpu_info) {
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
......@@ -259,7 +296,7 @@ LibYUVPlanarTest::LibYUVPlanarTest() :
LibYUVBaseTest::LibYUVBaseTest() :
benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
benchmark_height_(72), disable_cpu_flags_(0) {
benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) {
const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT
......@@ -292,6 +329,13 @@ LibYUVBaseTest::LibYUVBaseTest() :
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
const char* cpu_info = getenv("LIBYUV_CPU_INFO");
if (cpu_info) {
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
......
......@@ -82,6 +82,7 @@ class LibYUVColorTest : public ::testing::Test {
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 0. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVConvertTest : public ::testing::Test {
......@@ -94,6 +95,7 @@ class LibYUVConvertTest : public ::testing::Test {
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 0. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVScaleTest : public ::testing::Test {
......@@ -106,6 +108,7 @@ class LibYUVScaleTest : public ::testing::Test {
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 0. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVRotateTest : public ::testing::Test {
......@@ -118,6 +121,7 @@ class LibYUVRotateTest : public ::testing::Test {
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 0. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVPlanarTest : public ::testing::Test {
......@@ -130,6 +134,7 @@ class LibYUVPlanarTest : public ::testing::Test {
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 0. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVBaseTest : public ::testing::Test {
......@@ -142,6 +147,7 @@ class LibYUVBaseTest : public ::testing::Test {
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 0. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
#endif // UNIT_TEST_UNIT_TEST_H_ NOLINT
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