[llvm-commits] [test-suite] r165801 - in /test-suite/trunk/SingleSource/UnitTests/Vector/Altivec: alti.expandfft.c alti.stepfft.c

Ulrich Weigand ulrich.weigand at de.ibm.com
Fri Oct 12 08:25:04 PDT 2012


Author: uweigand
Date: Fri Oct 12 10:25:04 2012
New Revision: 165801

URL: http://llvm.org/viewvc/llvm-project?rev=165801&view=rev
Log:
Work around sin/cos accuracy differences by artifically rounding
off sin/cos results.  Code taken from:
SingleSource/Benchmarks/Misc-C++/Large/sphereflake.cpp

Modified:
    test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c
    test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.stepfft.c

Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c?rev=165801&r1=165800&r2=165801&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c (original)
+++ test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c Fri Oct 12 10:25:04 2012
@@ -249,6 +249,26 @@
       vec_st(V7,0,(vector float *) (d+k4));     /* store d */
    }
 }
+
+// LLVM LOCAL begin
+// Implementations of sin() and cos() may vary slightly in the accuracy of
+// their results, typically only in the least significant bit.  Round to make
+// the results consistent across platforms.
+typedef union { double d; unsigned long long ll; } dbl_ll_union;
+static double LLVMsin(double d) {
+  dbl_ll_union u;
+  u.d = sin(d);
+  u.ll = (u.ll + 1) & ~1ULL;
+  return u.d;
+}
+static double LLVMcos(double d) {
+  dbl_ll_union u;
+  u.d = cos(d);
+  u.ll = (u.ll + 1) & ~1ULL;
+  return u.d;
+}
+// LLVM LOCAL end
+
 void cffti(int n, float w[][2])
 {
 
@@ -263,8 +283,8 @@
    aw = 2.0*pi/((float)n);
    for(i=0;i<n2;i++){
       arg   = aw*((float)i);
-      w[i][0] = cos(arg);
-      w[i][1] = sin(arg);
+      w[i][0] = LLVMcos(arg);
+      w[i][1] = LLVMsin(arg);
    }
 }
 #include <math.h>

Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.stepfft.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.stepfft.c?rev=165801&r1=165800&r2=165801&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.stepfft.c (original)
+++ test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.stepfft.c Fri Oct 12 10:25:04 2012
@@ -105,6 +105,26 @@
    mj   = n/2;
    step(n,mj,&x[0][0],&x[n/2][0],&y[0][0],&y[mj][0],w,sign);
 }
+
+// LLVM LOCAL begin
+// Implementations of sin() and cos() may vary slightly in the accuracy of
+// their results, typically only in the least significant bit.  Round to make
+// the results consistent across platforms.
+typedef union { double d; unsigned long long ll; } dbl_ll_union;
+static double LLVMsin(double d) {
+  dbl_ll_union u;
+  u.d = sin(d);
+  u.ll = (u.ll + 1) & ~1ULL;
+  return u.d;
+}
+static double LLVMcos(double d) {
+  dbl_ll_union u;
+  u.d = cos(d);
+  u.ll = (u.ll + 1) & ~1ULL;
+  return u.d;
+}
+// LLVM LOCAL end
+
 void cffti(int n, float w[][2])
 {
    int i,n2;
@@ -114,8 +134,8 @@
    aw = 2.0*pi/((float)n);
    for(i=0;i<n2;i++){
       arg   = aw*((float)i);
-      w[i][0] = cos(arg);
-      w[i][1] = sin(arg);
+      w[i][0] = LLVMcos(arg);
+      w[i][1] = LLVMsin(arg);
    }
 }
 void ccopy(int n, float x[][2], float y[][2])





More information about the llvm-commits mailing list