1- /*
1+ /*
2+ * * For inclusion in the SPEC cpu benchmarks
3+ * This file implements the random number generation necessary for the SPEC cpu benchmarks. The functions
4+ * defined here are used in vtr_random.h/cpp
5+
6+
27 A C-program for MT19937, with initialization improved 2002/1/26.
38 Coded by Takuji Nishimura and Makoto Matsumoto.
49
4550/* Slightly modified for use in SPEC CPU by Cloyce D. Spradling (5 Nov 2009)
4651 */
4752
48- #include <stdio.h>
4953#include " specrand.h"
5054
51- #ifdef __cplusplus
52- # define CLINK extern "C"
53- #else
54- # define CLINK
55- #endif
56-
5755/* Period parameters */
5856#define N 624
5957#define M 397
6462static unsigned long mt[N]; /* the array for the state vector */
6563static int mti=N+1 ; /* mti==N+1 means mt[N] is not initialized */
6664
67- CLINK void spec_srand (int seed ) {
65+ void spec_srand (int seed) {
6866 spec_init_genrand ((unsigned long ) seed);
6967}
7068
7169/* Just a copy of spec_genrand_real2() */
72- CLINK double spec_rand (void ) {
70+ double spec_rand () {
7371 return spec_genrand_int32 ()*(1.0 /4294967296.0 );
7472}
7573
7674/* Just a copy of spec_genrand_int31() */
77- CLINK long spec_lrand48 (void ) {
75+ long spec_lrand48 () {
7876 return (long )(spec_genrand_int32 ()>>1 );
7977}
8078
8179/* initializes mt[N] with a seed */
82- CLINK void spec_init_genrand (unsigned long s )
80+ void spec_init_genrand (unsigned long s)
8381{
8482 mt[0 ]= s & 0xffffffffUL ;
8583 for (mti=1 ; mti<N; mti++) {
@@ -98,7 +96,7 @@ CLINK void spec_init_genrand(unsigned long s)
9896/* init_key is the array for initializing keys */
9997/* key_length is its length */
10098/* slight change for C++, 2004/2/26 */
101- CLINK void spec_init_by_array (unsigned long init_key [], int key_length )
99+ void spec_init_by_array (unsigned long init_key[], int key_length)
102100{
103101 int i, j, k;
104102 spec_init_genrand (19650218UL );
@@ -124,7 +122,7 @@ CLINK void spec_init_by_array(unsigned long init_key[], int key_length)
124122}
125123
126124/* generates a random number on [0,0xffffffff]-interval */
127- CLINK unsigned long spec_genrand_int32 (void )
125+ unsigned long spec_genrand_int32 ()
128126{
129127 unsigned long y;
130128 static unsigned long mag01[2 ]={0x0UL , MATRIX_A};
@@ -162,34 +160,34 @@ CLINK unsigned long spec_genrand_int32(void)
162160}
163161
164162/* generates a random number on [0,0x7fffffff]-interval */
165- CLINK long spec_genrand_int31 (void )
163+ long spec_genrand_int31 ()
166164{
167165 return (long )(spec_genrand_int32 ()>>1 );
168166}
169167
170168/* generates a random number on [0,1]-real-interval */
171- CLINK double spec_genrand_real1 (void )
169+ double spec_genrand_real1 ()
172170{
173171 return spec_genrand_int32 ()*(1.0 /4294967295.0 );
174172 /* divided by 2^32-1 */
175173}
176174
177175/* generates a random number on [0,1)-real-interval */
178- CLINK double spec_genrand_real2 (void )
176+ double spec_genrand_real2 ()
179177{
180178 return spec_genrand_int32 ()*(1.0 /4294967296.0 );
181179 /* divided by 2^32 */
182180}
183181
184182/* generates a random number on (0,1)-real-interval */
185- CLINK double spec_genrand_real3 (void )
183+ double spec_genrand_real3 ()
186184{
187185 return (((double )spec_genrand_int32 ()) + 0.5 )*(1.0 /4294967296.0 );
188186 /* divided by 2^32 */
189187}
190188
191189/* generates a random number on [0,1) with 53-bit resolution*/
192- CLINK double spec_genrand_res53 (void )
190+ double spec_genrand_res53 ()
193191{
194192 unsigned long a=spec_genrand_int32 ()>>5 , b=spec_genrand_int32 ()>>6 ;
195193 return (a*67108864.0 +b)*(1.0 /9007199254740992.0 );
0 commit comments