Commit 62a1f544 authored by Chris Wilson's avatar Chris Wilson 😣

wsim: Per-client prng pool for miscellaneous randoms

Signed-off-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
parent 0d67d8ee
......@@ -105,6 +105,8 @@ struct workload
unsigned int nr_steps;
struct w_step *steps;
uint32_t prng;
struct timespec repeat_start;
int pipe[2];
......@@ -628,6 +630,8 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)
struct w_step *w;
int i;
wrk->prng = rand();
if (flags & INITVCSRR)
wrk->vcs_rr = id & 1;
......@@ -818,7 +822,7 @@ __rt_balance(const struct workload_balancer *balancer,
else if (qd[VCS2] < qd[VCS1])
n = 1;
else if (random)
n = hars_petruska_f54_1_random_unsafe() & 1;
n = hars_petruska_f54_1_random(&wrk->prng) & 1;
else
n = wrk->vcs_rr;
......@@ -845,7 +849,6 @@ static enum intel_engine_id
rtr_balance(const struct workload_balancer *balancer,
struct workload *wrk, struct w_step *w)
{
return __rt_balance(balancer, wrk, w, true);
}
......
#include "igt_rand.h"
static uint32_t state = 0x12345678;
static uint32_t global = 0x12345678;
uint32_t
hars_petruska_f54_1_random_seed(uint32_t new_state)
uint32_t hars_petruska_f54_1_random_seed(uint32_t new_state)
{
uint32_t old_state = state;
state = new_state;
uint32_t old_state = global;
global = new_state;
return old_state;
}
uint32_t
hars_petruska_f54_1_random_unsafe(void)
uint32_t hars_petruska_f54_1_random(uint32_t *s)
{
#define rol(x,k) ((x << k) | (x >> (32-k)))
return state = (state ^ rol (state, 5) ^ rol (state, 24)) + 0x37798849;
return *s = (*s ^ rol(*s, 5) ^ rol(*s, 24)) + 0x37798849;
#undef rol
}
uint32_t hars_petruska_f54_1_random_unsafe(void)
{
return hars_petruska_f54_1_random(&global);
}
......@@ -26,6 +26,8 @@
#include <stdint.h>
uint32_t hars_petruska_f54_1_random(uint32_t *state);
uint32_t hars_petruska_f54_1_random_seed(uint32_t seed);
uint32_t hars_petruska_f54_1_random_unsafe(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment