Skip to content

Commit 4b9bded

Browse files
luzhixing12345sjp38
authored andcommitted
fix: fix random rndints for 64 bits address space
int rand() could only generate random number in 0-2^31-1, but the region size is size_t(64B), not all addresses in the range could get accessed. Signed-off-by: luzhixing12345 <[email protected]>
1 parent 7f2c425 commit 4b9bded

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

configs/64.cfg

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#regions
2+
# name, length
3+
a, 2147483648
4+
b, 64
5+
c, 128
6+
7+
# phase 1
8+
# name of phase
9+
example phase 1
10+
# time in ms
11+
1000
12+
# access patterns
13+
# name of region, randomness, stride, probability
14+
a, 1, 64, 80
15+
16+
# phase 2
17+
example phase 2
18+
# time in ms
19+
1000
20+
# access patterns
21+
# name of region, randomness, stride, probability
22+
c, 1, 64, 50
23+
b, 0, 4096, 50

masim.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,26 @@ struct access_config {
8787

8888
#define RAND_BATCH 1000
8989
#define RAND_ARR_SZ 1000
90-
int rndints[RAND_BATCH][RAND_ARR_SZ];
90+
size_t rndints[RAND_BATCH][RAND_ARR_SZ];
91+
92+
inline static size_t rand64() {
93+
return ((size_t)rand() << 32) | rand();
94+
}
9195

9296
static void init_rndints(void)
9397
{
9498
int i, j;
9599

96100
for (i = 0; i < RAND_BATCH; i++)
97101
for (j = 0; j < RAND_ARR_SZ; j++)
98-
rndints[i][j] = rand();
102+
rndints[i][j] = rand64();
99103
rndints[0][0] = 1;
100104
}
101105

102106
/*
103107
* Returns a random integer
104108
*/
105-
static int rndint(void)
109+
static size_t rndint(void)
106110
{
107111
static int rndofs;
108112
static int rndarr;

0 commit comments

Comments
 (0)