Skip to content

Commit

Permalink
fix test thresholds and use smaller numbers to avoid f16 precision loss
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 732905371
  • Loading branch information
jan-wassenberg authored and copybara-github committed Mar 3, 2025
1 parent e35f0f9 commit d3cb61d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion hwy/perf_counters_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ TEST(PerfCountersTest, RunBranches) {
HWY_ASSERT(values[PerfCounters::kCacheRefs] < 1E8); // 5M..27M
HWY_ASSERT(values[PerfCounters::kCacheMisses] < 1E8); // 500K..10M
HWY_ASSERT(values[PerfCounters::kBusCycles] < 1E11); // 1M..10B
HWY_ASSERT(values[PerfCounters::kPageFaults] < 100.0); // 0..12
HWY_ASSERT(values[PerfCounters::kPageFaults] < 1E4); // 0..1.1K (in SDE)
}

} // namespace
Expand Down
66 changes: 33 additions & 33 deletions hwy/tests/complex_arithmetic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct TestMulComplex {
HWY_NOINLINE void operator()(T /*unused*/, D d) {
#if HWY_TARGET != HWY_SCALAR
const Vec<D> v1 = Iota(d, 2);
const Vec<D> v2 = Iota(d, 10);
const Vec<D> v2 = Iota(d, 5);

const size_t N = Lanes(d);
auto expected = AllocateAligned<T>(N);
Expand All @@ -70,8 +70,8 @@ struct TestMulComplex {
// expected = (x + iy)(u + iv)
auto x = ConvertScalarTo<T>(i + 2);
auto y = ConvertScalarTo<T>(i + 2 + 1);
auto u = ConvertScalarTo<T>(i + 10);
auto v = ConvertScalarTo<T>(i + 10 + 1);
auto u = ConvertScalarTo<T>(i + 5);
auto v = ConvertScalarTo<T>(i + 5 + 1);
expected[i + 0] = ConvertScalarTo<T>((x * u) - (y * v));
expected[i + 1] = ConvertScalarTo<T>((x * v) + (y * u));
}
Expand All @@ -91,8 +91,8 @@ struct TestMulComplexAdd {
HWY_NOINLINE void operator()(T /*unused*/, D d) {
#if HWY_TARGET != HWY_SCALAR
const Vec<D> v1 = Iota(d, 2);
const Vec<D> v2 = Iota(d, 10);
const Vec<D> v3 = Iota(d, 15);
const Vec<D> v2 = Iota(d, 5);
const Vec<D> v3 = Iota(d, 6);

const size_t N = Lanes(d);
auto expected = AllocateAligned<T>(N);
Expand All @@ -102,10 +102,10 @@ struct TestMulComplexAdd {
// expected = (x + iy)(u + iv) + a + ib
auto x = ConvertScalarTo<T>(i + 2);
auto y = ConvertScalarTo<T>(i + 2 + 1);
auto u = ConvertScalarTo<T>(i + 10);
auto v = ConvertScalarTo<T>(i + 10 + 1);
auto a = ConvertScalarTo<T>(i + 15);
auto b = ConvertScalarTo<T>(i + 15 + 1);
auto u = ConvertScalarTo<T>(i + 5);
auto v = ConvertScalarTo<T>(i + 5 + 1);
auto a = ConvertScalarTo<T>(i + 6);
auto b = ConvertScalarTo<T>(i + 6 + 1);
expected[i + 0] = ConvertScalarTo<T>((x * u) - (y * v) + a);
expected[i + 1] = ConvertScalarTo<T>((x * v) + (y * u) + b);
}
Expand All @@ -125,8 +125,8 @@ struct TestMaskedMulComplexOr {
HWY_NOINLINE void operator()(T /*unused*/, D d) {
#if HWY_TARGET != HWY_SCALAR
const Vec<D> v1 = Iota(d, 2);
const Vec<D> v2 = Iota(d, 10);
const Vec<D> v3 = Iota(d, 15);
const Vec<D> v2 = Iota(d, 5);
const Vec<D> v3 = Iota(d, 6);

const size_t N = Lanes(d);
auto expected = AllocateAligned<T>(N);
Expand All @@ -137,10 +137,10 @@ struct TestMaskedMulComplexOr {
// expected = (x + iy)(u + iv)
auto x = ConvertScalarTo<T>(i + 2);
auto y = ConvertScalarTo<T>(i + 2 + 1);
auto u = ConvertScalarTo<T>(i + 10);
auto v = ConvertScalarTo<T>(i + 10 + 1);
auto a = ConvertScalarTo<T>(i + 15);
auto b = ConvertScalarTo<T>(i + 15 + 1);
auto u = ConvertScalarTo<T>(i + 5);
auto v = ConvertScalarTo<T>(i + 5 + 1);
auto a = ConvertScalarTo<T>(i + 6);
auto b = ConvertScalarTo<T>(i + 6 + 1);
// Alternate between masking the real and imaginary lanes
if ((i % 4) == 0) {
bool_lanes[i + 0] = ConvertScalarTo<T>(1);
Expand Down Expand Up @@ -174,7 +174,7 @@ struct TestMulComplexConj {
HWY_NOINLINE void operator()(T /*unused*/, D d) {
#if HWY_TARGET != HWY_SCALAR
const Vec<D> v1 = Iota(d, 2);
const Vec<D> v2 = Iota(d, 10);
const Vec<D> v2 = Iota(d, 5);

const size_t N = Lanes(d);
auto expected = AllocateAligned<T>(N);
Expand All @@ -184,8 +184,8 @@ struct TestMulComplexConj {
// expected = (x + iy)(u - iv)
auto x = ConvertScalarTo<T>(i + 2);
auto y = ConvertScalarTo<T>(i + 2 + 1);
auto u = ConvertScalarTo<T>(i + 10);
auto v = ConvertScalarTo<T>(i + 10 + 1);
auto u = ConvertScalarTo<T>(i + 5);
auto v = ConvertScalarTo<T>(i + 5 + 1);
expected[i + 0] = ConvertScalarTo<T>((x * u) + (y * v));
expected[i + 1] = ConvertScalarTo<T>((y * u) - (x * v));
}
Expand All @@ -205,8 +205,8 @@ struct TestMulComplexConjAdd {
HWY_NOINLINE void operator()(T /*unused*/, D d) {
#if HWY_TARGET != HWY_SCALAR
const Vec<D> v1 = Iota(d, 2);
const Vec<D> v2 = Iota(d, 10);
const Vec<D> v3 = Iota(d, 15);
const Vec<D> v2 = Iota(d, 5);
const Vec<D> v3 = Iota(d, 6);

const size_t N = Lanes(d);
auto expected = AllocateAligned<T>(N);
Expand All @@ -216,10 +216,10 @@ struct TestMulComplexConjAdd {
// expected = (x + iy)(u - iv) + a + ib
auto x = ConvertScalarTo<T>(i + 2);
auto y = ConvertScalarTo<T>(i + 2 + 1);
auto u = ConvertScalarTo<T>(i + 10);
auto v = ConvertScalarTo<T>(i + 10 + 1);
auto a = ConvertScalarTo<T>(i + 15);
auto b = ConvertScalarTo<T>(i + 15 + 1);
auto u = ConvertScalarTo<T>(i + 5);
auto v = ConvertScalarTo<T>(i + 5 + 1);
auto a = ConvertScalarTo<T>(i + 6);
auto b = ConvertScalarTo<T>(i + 6 + 1);
expected[i + 0] = ConvertScalarTo<T>((a + (u * x)) + (v * y));
expected[i + 1] = ConvertScalarTo<T>((b + (u * y)) - (v * x));
}
Expand All @@ -239,7 +239,7 @@ struct TestMaskedMulComplexConj {
HWY_NOINLINE void operator()(T /*unused*/, D d) {
#if HWY_TARGET != HWY_SCALAR
const Vec<D> v1 = Iota(d, 2);
const Vec<D> v2 = Iota(d, 10);
const Vec<D> v2 = Iota(d, 5);

const size_t N = Lanes(d);
auto expected = AllocateAligned<T>(N);
Expand All @@ -250,8 +250,8 @@ struct TestMaskedMulComplexConj {
// expected = (x + iy)(u - iv)
auto x = ConvertScalarTo<T>(i + 2);
auto y = ConvertScalarTo<T>(i + 2 + 1);
auto u = ConvertScalarTo<T>(i + 10);
auto v = ConvertScalarTo<T>(i + 10 + 1);
auto u = ConvertScalarTo<T>(i + 5);
auto v = ConvertScalarTo<T>(i + 5 + 1);
// Alternate between masking the real and imaginary lanes
if ((i % 4) == 0) {
bool_lanes[i + 0] = ConvertScalarTo<T>(1);
Expand Down Expand Up @@ -285,8 +285,8 @@ struct TestMaskedMulComplexConjAdd {
HWY_NOINLINE void operator()(T /*unused*/, D d) {
#if HWY_TARGET != HWY_SCALAR
const Vec<D> v1 = Iota(d, 2);
const Vec<D> v2 = Iota(d, 10);
const Vec<D> v3 = Iota(d, 15);
const Vec<D> v2 = Iota(d, 5);
const Vec<D> v3 = Iota(d, 6);

const size_t N = Lanes(d);
auto expected = AllocateAligned<T>(N);
Expand All @@ -297,10 +297,10 @@ struct TestMaskedMulComplexConjAdd {
// expected = (x + iy)(u - iv) + a + ib
auto x = ConvertScalarTo<T>(i + 2);
auto y = ConvertScalarTo<T>(i + 2 + 1);
auto u = ConvertScalarTo<T>(i + 10);
auto v = ConvertScalarTo<T>(i + 10 + 1);
auto a = ConvertScalarTo<T>(i + 15);
auto b = ConvertScalarTo<T>(i + 15 + 1);
auto u = ConvertScalarTo<T>(i + 5);
auto v = ConvertScalarTo<T>(i + 5 + 1);
auto a = ConvertScalarTo<T>(i + 6);
auto b = ConvertScalarTo<T>(i + 6 + 1);
// Alternate between masking the real and imaginary lanes
if ((i % 4) == 2) {
bool_lanes[i + 0] = ConvertScalarTo<T>(1);
Expand Down

0 comments on commit d3cb61d

Please sign in to comment.