aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD1
-rw-r--r--platform.h7
-rw-r--r--test.h9
-rw-r--r--trmul.cc4
-rw-r--r--wait_test.cc5
5 files changed, 25 insertions, 1 deletions
diff --git a/BUILD b/BUILD
index 0f190c4..debccdd 100644
--- a/BUILD
+++ b/BUILD
@@ -69,6 +69,7 @@ cc_test(
name = "wait_test",
srcs = ["wait_test.cc"],
deps = [
+ ":platform",
":wait",
"@com_google_googletest//:gtest",
],
diff --git a/platform.h b/platform.h
index 0aa067f..00c6441 100644
--- a/platform.h
+++ b/platform.h
@@ -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_
diff --git a/test.h b/test.h
index 905379c..dc72c98 100644
--- a/test.h
+++ b/test.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);
diff --git a/trmul.cc b/trmul.cc
index 9fca1bb..85275ef 100644
--- a/trmul.cc
+++ b/trmul.cc
@@ -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);