summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-05-09 12:42:41 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2017-05-09 15:36:54 +0100
commit62a1f544fcbb264b8b70d25ed9fb7395e109160a (patch)
treea9172c1dba2c46bc24d758636f580de587e267b6
parent0d67d8ee678e883ba8a1e40699b73b7db2d540fe (diff)
wsim: Per-client prng pool for miscellaneous randoms
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--benchmarks/gem_wsim.c7
-rw-r--r--lib/igt_rand.c19
-rw-r--r--lib/igt_rand.h2
3 files changed, 18 insertions, 10 deletions
diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index 8023cd0e..2a8af7ba 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -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);
}
diff --git a/lib/igt_rand.c b/lib/igt_rand.c
index a3298a9f..b8d3a92c 100644
--- a/lib/igt_rand.c
+++ b/lib/igt_rand.c
@@ -1,19 +1,22 @@
#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);
+}
diff --git a/lib/igt_rand.h b/lib/igt_rand.h
index d676752d..f664af41 100644
--- a/lib/igt_rand.h
+++ b/lib/igt_rand.h
@@ -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);