[test-suite] r177148 - Add simple RNG to avoid library differences

Renato Golin renato.golin at linaro.org
Fri Mar 15 04:52:08 PDT 2013


Author: rengolin
Date: Fri Mar 15 06:52:08 2013
New Revision: 177148

URL: http://llvm.org/viewvc/llvm-project?rev=177148&view=rev
Log:
Add simple RNG to avoid library differences

Now the reference output is specific to the local implementation, avoiding
dependencies on the library that could change from release to release on
the same architectures.

Tested on x86_64 and ARMv7 (32-bits), so should work on any 32-bit and
64-bit architectures. It's also probably safe on 16-bit archs.

Modified:
    test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/puzzle.c
    test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/puzzle.reference_output

Modified: test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/puzzle.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/puzzle.c?rev=177148&r1=177147&r2=177148&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/puzzle.c (original)
+++ test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/puzzle.c Fri Mar 15 06:52:08 2013
@@ -5,6 +5,23 @@
 #define NLOOPS1 5
 #define NLOOPS2 200
 
+// RNG implemented localy to avoid library incongruences
+#ifdef RAND_MAX
+#undef RAND_MAX
+#endif
+#define RAND_MAX 32767
+static unsigned long long int next = 1;
+ 
+int rand( void ) {
+    next = next * 1103515245 + 12345;
+    return (unsigned int)(next / 65536) % RAND_MAX+1;
+}
+ 
+void srand( unsigned int seed ) {
+    next = seed;
+}
+// End of RNG implementation
+
 int randInt(int min, int max) {
     int k, n;
     n = (max - min) + 1;
@@ -64,4 +81,4 @@ int main() {
 	}
 
     return 0;
-}
\ No newline at end of file
+}

Modified: test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/puzzle.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/puzzle.reference_output?rev=177148&r1=177147&r2=177148&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/puzzle.reference_output (original)
+++ test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/puzzle.reference_output Fri Mar 15 06:52:08 2013
@@ -1,6 +1,6 @@
-Found duplicate: 4
-Found duplicate: 485365
-Found duplicate: 417267
-Found duplicate: 436989
-Found duplicate: 60067
+Found duplicate: 256943
+Found duplicate: 106186
+Found duplicate: 465226
+Found duplicate: 112763
+Found duplicate: 406647
 exit 0





More information about the llvm-commits mailing list