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