[beast] BSE: don't run subnormal checks on AMD64 if SSE unit is in DAZ mode
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast] BSE: don't run subnormal checks on AMD64 if SSE unit is in DAZ mode
- Date: Tue, 25 Jan 2011 01:39:17 +0000 (UTC)
commit 548ac252c6613e21ffeb7f5e2053d33ac8e36816
Author: Stefan Westerfeld <stefan space twc de>
Date: Sun Jan 9 17:02:56 2011 +0100
BSE: don't run subnormal checks on AMD64 if SSE unit is in DAZ mode
bse/tests/subnormals.cc | 43 +++++++++++++++++++++++++++++++++++--------
1 files changed, 35 insertions(+), 8 deletions(-)
---
diff --git a/bse/tests/subnormals.cc b/bse/tests/subnormals.cc
index 6a5f31b..e8d98ab 100644
--- a/bse/tests/subnormals.cc
+++ b/bse/tests/subnormals.cc
@@ -21,6 +21,9 @@
//#define TEST_VERBOSE
#include <birnet/birnettests.h>
#include <stdio.h>
+#ifdef __SSE__
+#include <xmmintrin.h>
+#endif
#if 1
inline float test1f (float v) { return v; }
@@ -210,21 +213,45 @@ benchmark_subnormal_eliminations ()
treport_minimized ("Subnormals-bse-flush", test6_time, TUNIT_SECOND);
}
+bool
+check_denormals_are_zero()
+{
+#if defined (__x86_64__) && (FLT_EVAL_METHOD == 0) && defined (__SSE__)
+ if (_MM_GET_FLUSH_ZERO_MODE() == _MM_FLUSH_ZERO_ON)
+ {
+ const int MM_DENORMALS_ARE_ZERO = 0x40;
+
+ if (_mm_getcsr() & MM_DENORMALS_ARE_ZERO)
+ {
+ return true;
+ }
+ }
+#endif
+
+ return false;
+}
+
int
main (int argc,
char *argv[])
{
bse_init_test (&argc, &argv, NULL);
- test_correct_subnormal_elimination<test2f> ("zap");
- test_correct_subnormal_elimination<test3f> ("inlined-cond");
- test_correct_subnormal_elimination<test4f> ("if-cond");
- test_correct_subnormal_elimination<test5f> ("arithmetic");
+ g_printerr ("Checking if your processor is in 'denormals are zero' (DAZ) mode... ");
+ bool daz_mode = check_denormals_are_zero();
+ g_printerr (daz_mode ? "yes - skipping subnormal elimination tests.\n" : "no.\n");
+ if (!daz_mode)
+ {
+ test_correct_subnormal_elimination<test2f> ("zap");
+ test_correct_subnormal_elimination<test3f> ("inlined-cond");
+ test_correct_subnormal_elimination<test4f> ("if-cond");
+ test_correct_subnormal_elimination<test5f> ("arithmetic");
- test_correct_subnormal_elimination<test2d> ("zap-double");
- test_correct_subnormal_elimination<test3d> ("inlined-cond-double");
- test_correct_subnormal_elimination<test4d> ("if-cond-double");
- test_correct_subnormal_elimination<test5d> ("arithmetic-double");
+ test_correct_subnormal_elimination<test2d> ("zap-double");
+ test_correct_subnormal_elimination<test3d> ("inlined-cond-double");
+ test_correct_subnormal_elimination<test4d> ("if-cond-double");
+ test_correct_subnormal_elimination<test5d> ("arithmetic-double");
+ }
if (sfi_init_settings().test_perf)
benchmark_subnormal_eliminations();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]