trying mormords ideas and why its slower
This commit is contained in:
parent
a6dd3f93cd
commit
42943f4678
13
fastrand.h
13
fastrand.h
@ -125,6 +125,15 @@ static inline uint32_t lcg_ilp(rand_ilp_state *state, RAND_ILP which) {
|
|||||||
return state->h;
|
return state->h;
|
||||||
}
|
}
|
||||||
assert(0);
|
assert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Slower for me than lcg_ilp because that gets optimized out in unrolled loop! */
|
||||||
|
static inline uint32_t lcg_ilp2(rand_ilp_state *state, RAND_ILP which)
|
||||||
|
{
|
||||||
|
uint32_t *s = &(state->a) + which;
|
||||||
|
*s = *s * 1664525u + 1013904223u;
|
||||||
|
return *s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Pick a "reasonably random" number in [0, until-1] without modulus */
|
/** Pick a "reasonably random" number in [0, until-1] without modulus */
|
||||||
@ -134,8 +143,8 @@ static inline uint32_t rand_until(rand_state *restrict state, uint32_t until) {
|
|||||||
return (uint32_t)(((uint64_t)rand * until) >> 32);
|
return (uint32_t)(((uint64_t)rand * until) >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t fastmodlike(uint32_t num, uint32_t m) {
|
static inline uint32_t fastmodlike(uint32_t num, uint32_t m) {
|
||||||
return (((uint64_t) num) * m);
|
return (uint32_t)(((uint64_t) num * m) >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user