OLD | NEW |
1 //===- subzero/crosstest/vectors.h - Common SIMD vector utilies -*- C++ -*-===// | 1 //===- subzero/crosstest/vectors.h - Common SIMD vector utilies -*- C++ -*-===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file provides declarations for PNaCl portable SIMD vector types. In | 10 // This file provides declarations for PNaCl portable SIMD vector types. In |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 | 94 |
95 // In some crosstests, test vectors are deterministically constructed by | 95 // In some crosstests, test vectors are deterministically constructed by |
96 // selecting elements from a pool of scalar values based on a | 96 // selecting elements from a pool of scalar values based on a |
97 // pseudorandom sequence. Testing all possible combinations of scalar | 97 // pseudorandom sequence. Testing all possible combinations of scalar |
98 // values from the value pool is often not tractable. | 98 // values from the value pool is often not tractable. |
99 // | 99 // |
100 // TODO: Replace with a portable PRNG from C++11. | 100 // TODO: Replace with a portable PRNG from C++11. |
101 class PRNG { | 101 class PRNG { |
102 public: | 102 public: |
103 PRNG(uint32_t Seed = 1) : State(Seed) {} | 103 explicit PRNG(uint32_t Seed = 1) : State(Seed) {} |
104 | 104 |
105 uint32_t operator()() { | 105 uint32_t operator()() { |
106 // Lewis, Goodman, and Miller (1969) | 106 // Lewis, Goodman, and Miller (1969) |
107 State = (16807 * State) % 2147483647; | 107 State = (16807 * State) % 2147483647; |
108 return State; | 108 return State; |
109 } | 109 } |
110 | 110 |
111 private: | 111 private: |
112 uint32_t State; | 112 uint32_t State; |
113 }; | 113 }; |
114 | 114 |
115 } // end anonymous namespace | 115 } // end anonymous namespace |
116 | 116 |
117 #endif // VECTORS_H | 117 #endif // VECTORS_H |
OLD | NEW |