Skip to content

Commit b3c1cef

Browse files
committed
add comments - change specrand.c to .cpp
1 parent 0d049f7 commit b3c1cef

File tree

4 files changed

+35
-36
lines changed

4 files changed

+35
-36
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ endif()
304304
#
305305
set(SPEC_CPU_FLAGS "")
306306
if(SPEC_CPU)
307-
#Enable gcov
307+
# Enable SPEC CPU flag - Maximizes portability of code and minimizing the variation in how much work we do on different platforms
308308
set(SPEC_CPU_FLAGS "-DSPEC_CPU")
309309
message(STATUS "SPEC CPU FLAGS: ${SPEC_CPU_FLAGS}")
310310
endif()

libs/libvtrutil/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ add_custom_command(OUTPUT ${VTR_VERSION_FILE_OUT}
8383
#
8484
# Source files and library
8585
#
86-
file(GLOB_RECURSE LIB_SOURCES src/*.cpp src/*.c)
86+
file(GLOB_RECURSE LIB_SOURCES src/*.cpp)
8787
file(GLOB_RECURSE LIB_HEADERS src/*.hpp src/*.h)
8888
files_to_dirs(LIB_HEADERS LIB_INCLUDE_DIRS)
8989

libs/libvtrutil/src/specrand.c renamed to libs/libvtrutil/src/specrand.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
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
@@ -45,15 +50,8 @@
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
@@ -64,22 +62,22 @@
6462
static unsigned long mt[N]; /* the array for the state vector */
6563
static 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);

libs/libvtrutil/src/specrand.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
/*
1+
#ifndef VPR_SPEC_RAND_H
2+
#define VPR_SPEC_RAND_H
3+
/*
4+
* For inclusion in the SPEC cpu benchmarks
5+
* This file implements the random number generation necessary for the SPEC cpu benchmarks. The functions
6+
* defined here are used in vtr_random.h/cpp
7+
*
8+
*
29
* A C-program for MT19937, with initialization improved 2002/1/26.
310
* Coded by Takuji Nishimura and Makoto Matsumoto.
411
*
@@ -45,13 +52,9 @@
4552
/* Slightly modified for use in SPEC CPU by Cloyce D. Spradling (5 Nov 2009)
4653
*/
4754

48-
#ifdef __cplusplus
49-
extern "C" {
50-
#endif
51-
5255
void spec_srand(int seed);
53-
double spec_rand(void);
54-
long spec_lrand48(void);
56+
double spec_rand();
57+
long spec_lrand48();
5558

5659
/* initializes mt[N] with a seed */
5760
void spec_init_genrand(unsigned long s);
@@ -63,23 +66,21 @@ void spec_init_genrand(unsigned long s);
6366
void spec_init_by_array(unsigned long init_key[], int key_length);
6467

6568
/* generates a random number on [0,0xffffffff]-interval */
66-
unsigned long spec_genrand_int32(void);
69+
unsigned long spec_genrand_int32();
6770

6871
/* generates a random number on [0,0x7fffffff]-interval */
69-
long spec_genrand_int31(void);
72+
long spec_genrand_int31();
7073

7174
/* generates a random number on [0,1]-real-interval */
72-
double spec_genrand_real1(void);
75+
double spec_genrand_real1();
7376

7477
/* generates a random number on [0,1)-real-interval */
75-
double spec_genrand_real2(void);
78+
double spec_genrand_real2();
7679

7780
/* generates a random number on (0,1)-real-interval */
78-
double spec_genrand_real3(void);
81+
double spec_genrand_real3();
7982

8083
/* generates a random number on [0,1) with 53-bit resolution*/
81-
double spec_genrand_res53(void);
84+
double spec_genrand_res53();
8285

83-
#ifdef __cplusplus
84-
}
8586
#endif

0 commit comments

Comments
 (0)