diff options
-rw-r--r-- | BUILD | 1 | ||||
-rw-r--r-- | platform.h | 7 | ||||
-rw-r--r-- | test.h | 9 | ||||
-rw-r--r-- | trmul.cc | 4 | ||||
-rw-r--r-- | wait_test.cc | 5 |
5 files changed, 25 insertions, 1 deletions
@@ -69,6 +69,7 @@ cc_test( name = "wait_test", srcs = ["wait_test.cc"], deps = [ + ":platform", ":wait", "@com_google_googletest//:gtest", ], @@ -132,4 +132,11 @@ limitations under the License. #define RUY_DONOTUSEDIRECTLY_APPLE 0 #endif +// Detect Emscripten, typically Wasm. +#ifdef __EMSCRIPTEN__ +#define RUY_DONOTUSEDIRECTLY_EMSCRIPTEN 1 +#else +#define RUY_DONOTUSEDIRECTLY_EMSCRIPTEN 0 +#endif + #endif // TENSORFLOW_LITE_EXPERIMENTAL_RUY_PLATFORM_H_ @@ -576,6 +576,13 @@ void TestSet<LhsScalar, RhsScalar, SpecType>::DoMul(TestResultType* result) { prepacked_rhs_ptr); } +// When building for WAsm, ASSERT_DEATH is not defined. +#ifdef ASSERT_DEATH +#define RUY_ASSERT_DEATH(CONDITION, MESSAGE) ASSERT_DEATH(CONDITION, MESSAGE) +#else +#define RUY_ASSERT_DEATH(CONDITION, MESSAGE) +#endif + template <typename LhsScalar, typename RhsScalar, typename SpecType> void TestSet<LhsScalar, RhsScalar, SpecType>::EvalRuy(TestResultType* result) { GlobalContext().explicit_tuning = result->tuning; @@ -594,7 +601,7 @@ void TestSet<LhsScalar, RhsScalar, SpecType>::EvalRuy(TestResultType* result) { // TODO(benoitjacob) TSan and ASan seem to be breaking ASSERT_DEATH. // Report a bug? #if (!defined NDEBUG) && (!defined RUY_ASAN) && (!defined RUY_TSAN) - ASSERT_DEATH(DoMul(result), ""); + RUY_ASSERT_DEATH(DoMul(result), ""); #endif } else { RUY_CHECK(false); @@ -245,6 +245,10 @@ void AllocatePMatrix(Allocator* allocator, PMatrix* packed) { } int GetThreadCount(Context* context, int rows, int cols, int depth) { +#if RUY_PLATFORM(EMSCRIPTEN) + // b/139927184, std::thread constructor raises exception + return 1; +#endif // Empirically determined rule for reasonable number of // threads to use. This is proportional to the number of arithmetic ops // in this Mul (product of the 3 sizes). diff --git a/wait_test.cc b/wait_test.cc index 2af832f..88f8f16 100644 --- a/wait_test.cc +++ b/wait_test.cc @@ -21,6 +21,7 @@ limitations under the License. #include <thread> // NOLINT(build/c++11) #include "testing/base/public/gunit.h" +#include "platform.h" namespace ruy { namespace { @@ -63,6 +64,10 @@ class ThreadCountingUpToValue { }; void WaitTest(const Duration& spin_duration, const Duration& delay) { +#if RUY_PLATFORM(EMSCRIPTEN) + // b/139927184, std::thread constructor raises exception + return; +#endif std::condition_variable condvar; std::mutex mutex; std::atomic<int> value(0); |