diff options
author | Benoit Jacob <benoitjacob@google.com> | 2020-05-26 21:44:55 +0300 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2020-05-26 21:45:21 +0300 |
commit | 736429b486f57a018dff732e816a5ad8db278c28 (patch) | |
tree | c1e8fac325c4bd62ef648f49114e6a77450ed63e /ruy/ctx_test.cc | |
parent | a216c871ebb42f82d0315df75702169fce6d07a3 (diff) |
Refactoring of {Get,Set}RuntimeSupportedPaths:
1. Simpler implementation, avoid double negations, factor logic in a lambda.
2. SetRuntimeSupportedPaths: the `paths` arg must now have kStandardCpp.
3. Better testing: the earlier version of this refactor was rolled back because it accidentally disabled kNeon. This would now be caught in both ctx_test and the general tests. The latter were already checking kNeonDotprod in chromium emulator, now that is extended to kNeon.
PiperOrigin-RevId: 313236703
Diffstat (limited to 'ruy/ctx_test.cc')
-rw-r--r-- | ruy/ctx_test.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/ruy/ctx_test.cc b/ruy/ctx_test.cc index 5b639cf..e65b85b 100644 --- a/ruy/ctx_test.cc +++ b/ruy/ctx_test.cc @@ -31,21 +31,27 @@ TEST(ContextInternalTest, EnabledPathsGeneral) { } #if RUY_PLATFORM(X86) -TEST(ContextInternalTest, EnabledPathsX86) { +TEST(ContextInternalTest, EnabledPathsX86Explicit) { CtxImpl ctx; - ctx.SetRuntimeEnabledPaths(Path::kSse42 | Path::kAvx2 | Path::kAvx512 | - Path::kAvxVnni); + ctx.SetRuntimeEnabledPaths(Path::kAvx2); const auto ruy_paths = ctx.GetRuntimeEnabledPaths(); - EXPECT_EQ(ruy_paths & Path::kStandardCpp, Path::kNone); + EXPECT_EQ(ruy_paths, Path::kStandardCpp | Path::kAvx2); } #endif // RUY_PLATFORM(X86) #if RUY_PLATFORM(ARM) -TEST(ContextInternalTest, EnabledPathsArm) { +TEST(ContextInternalTest, EnabledPathsX86Explicit) { CtxImpl ctx; - ctx.SetRuntimeEnabledPaths(Path::kNeon | Path::kNeonDotprod); + ctx.SetRuntimeEnabledPaths(Path::kNeonDotprod); const auto ruy_paths = ctx.GetRuntimeEnabledPaths(); - EXPECT_EQ(ruy_paths & Path::kStandardCpp, Path::kNone); + EXPECT_EQ(ruy_paths, Path::kStandardCpp | Path::kNeonDotprod); +} + +TEST(ContextInternalTest, EnabledPathsArmDefault) { + CtxImpl ctx; + const auto ruy_paths = ctx.GetRuntimeEnabledPaths(); + EXPECT_EQ(ruy_paths & Path::kStandardCpp, Path::kStandardCpp); + // NEON is always assumed to be supported at the moment. EXPECT_EQ(ruy_paths & Path::kNeon, Path::kNeon); } #endif // RUY_PLATFORM(ARM) |