Add MaskCpuFlags(benchmark_cpu_info_) to unittest initialization

When command line --libyuv_cpu_info is used the individual tests
used to need to set the cpumask.  This CL moves that to the init
for each test class so the individual tests dont need to set it.

TBR=kjellander@chromium.org
BUG=libyuv:720
TEST=LibYUVBaseTest.TestCpuHas

Change-Id: I6ae180388debf6cf76be6df5b81cfffeb35ee2eb
Reviewed-on: https://chromium-review.googlesource.com/662367
Reviewed-by: Cheng Wang <wangcheng@google.com>
This commit is contained in:
Frank Barchard 2017-09-12 12:11:45 -07:00
parent 6e80fc10ab
commit 80e27fc747
3 changed files with 8 additions and 4 deletions

View File

@ -2836,7 +2836,6 @@ TEST_F(LibYUVPlanarTest, TestGaussRow_Opt) {
orig_pixels[i] = i * 256;
}
GaussRow_C(&orig_pixels[0], &dst_pixels_c[0], 640);
MaskCpuFlags(benchmark_cpu_info_);
for (int i = 0; i < benchmark_pixels_div1280_ * 2; ++i) {
#if !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
int has_neon = TestCpuFlag(kCpuHasNEON);
@ -2890,7 +2889,6 @@ TEST_F(LibYUVPlanarTest, TestGaussCol_Opt) {
GaussCol_C(&orig_pixels[0], &orig_pixels[640], &orig_pixels[640 * 2],
&orig_pixels[640 * 3], &orig_pixels[640 * 4], &dst_pixels_c[0],
640);
MaskCpuFlags(benchmark_cpu_info_);
for (int i = 0; i < benchmark_pixels_div1280_ * 2; ++i) {
#if !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
int has_neon = TestCpuFlag(kCpuHasNEON);

View File

@ -472,7 +472,6 @@ TEST_F(LibYUVScaleTest, TestScaleRowUp2_16) {
orig_pixels[i] = i;
}
ScaleRowUp2_16_C(&orig_pixels[0], 640, &dst_pixels_c[0], 1280);
MaskCpuFlags(benchmark_cpu_info_);
for (int i = 0; i < benchmark_pixels_div1280_; ++i) {
#if !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
int has_neon = TestCpuFlag(kCpuHasNEON);
@ -511,7 +510,6 @@ TEST_F(LibYUVScaleTest, TestScaleRowDown2Box_16) {
orig_pixels[i] = i;
}
ScaleRowDown2Box_16_C(&orig_pixels[0], 2560, &dst_pixels_c[0], 1280);
MaskCpuFlags(benchmark_cpu_info_);
for (int i = 0; i < benchmark_pixels_div1280_; ++i) {
#if !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
int has_neon = TestCpuFlag(kCpuHasNEON);

View File

@ -17,6 +17,7 @@
#ifdef LIBYUV_USE_GFLAGS
#include "gflags/gflags.h"
#endif
#include "libyuv/cpu_id.h"
// Change this to 1000 for benchmarking.
// TODO(fbarchard): Add command line parsing to pass this as option.
@ -90,6 +91,7 @@ LibYUVConvertTest::LibYUVConvertTest()
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
libyuv::MaskCpuFlags(benchmark_cpu_info_);
benchmark_pixels_div256_ =
static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
@ -149,6 +151,7 @@ LibYUVColorTest::LibYUVColorTest()
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
libyuv::MaskCpuFlags(benchmark_cpu_info_);
benchmark_pixels_div256_ =
static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
@ -208,6 +211,7 @@ LibYUVScaleTest::LibYUVScaleTest()
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
libyuv::MaskCpuFlags(benchmark_cpu_info_);
benchmark_pixels_div256_ =
static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
@ -267,6 +271,7 @@ LibYUVRotateTest::LibYUVRotateTest()
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
libyuv::MaskCpuFlags(benchmark_cpu_info_);
benchmark_pixels_div256_ =
static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
@ -326,6 +331,7 @@ LibYUVPlanarTest::LibYUVPlanarTest()
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
libyuv::MaskCpuFlags(benchmark_cpu_info_);
benchmark_pixels_div256_ =
static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
@ -385,6 +391,7 @@ LibYUVBaseTest::LibYUVBaseTest()
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
libyuv::MaskCpuFlags(benchmark_cpu_info_);
benchmark_pixels_div256_ =
static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
@ -444,6 +451,7 @@ LibYUVCompareTest::LibYUVCompareTest()
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
libyuv::MaskCpuFlags(benchmark_cpu_info_);
benchmark_pixels_div256_ =
static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *