Revision 58b941b9 xseg/peers/user/bench-xseg.h
b/xseg/peers/user/bench-xseg.h | ||
---|---|---|
145 | 145 |
\**************/ |
146 | 146 |
|
147 | 147 |
struct lfsr { |
148 |
uint8_t length; |
|
149 |
uint64_t limit; |
|
150 | 148 |
uint64_t state; |
151 | 149 |
uint64_t xnormask; |
150 |
uint64_t cached_bit; //It's faster if it's on the same cacheline |
|
151 |
uint64_t limit; |
|
152 |
uint8_t length; |
|
152 | 153 |
}; |
153 | 154 |
|
154 | 155 |
int lfsr_init(struct lfsr *lfsr, uint64_t size, uint64_t seed); |
... | ... | |
160 | 161 |
static inline uint64_t lfsr_next(struct lfsr *lfsr) |
161 | 162 |
{ |
162 | 163 |
do { |
163 |
lfsr->state = (lfsr->state >> 1) ^
|
|
164 |
lfsr->state = ((lfsr->state >> 1) | lfsr->cached_bit) ^
|
|
164 | 165 |
(((lfsr->state & 1UL) - 1UL) & lfsr->xnormask); |
165 |
} while (lfsr->state > lfsr->limit); |
|
166 |
|
|
166 |
//lfsr->state = (lfsr->state >> 1) ^ (-(lfsr->state & 1UL) & lfsr->xnormask); |
|
167 |
//printf("State: %lu\n", lfsr->state); |
|
168 |
} while (lfsr->state >= lfsr->limit); |
|
169 |
//} while (lfsr->state > lfsr->limit); |
|
170 |
//printf("------------\n"); |
|
167 | 171 |
return lfsr->state; |
168 | 172 |
} |
169 | 173 |
|
Also available in: Unified diff