From: Tvrtko Ursulin <tvrtko.ursu...@intel.com>

New command line option to allow controling the initial pseudo random
generator seed in order to allow repeatable runs.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursu...@intel.com>
Suggested-by: Chris Wilson <ch...@chris-wilson.co.uk>
Suggested-by: Simon Ser <simon....@intel.com>
---
 benchmarks/gem_wsim.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index c43bbbc8c94d..e2ffb93a94d5 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -2946,6 +2946,7 @@ static void print_help(void)
 "  -t <n>          Nop calibration tolerance percentage.\n"
 "                  Use when there is a difficulty obtaining calibration with 
the\n"
 "                  default settings.\n"
+"  -I <n>          Initial randomness seed.\n"
 "  -p <n>          Context priority to use for the following workload on the\n"
 "                  command line.\n"
 "  -w <desc|path>  Filename or a workload descriptor.\n"
@@ -3119,11 +3120,9 @@ int main(int argc, char **argv)
        init_clocks();
 
        master_prng = time(NULL);
-       srand(master_prng);
-       master_prng = rand();
 
        while ((c = getopt(argc, argv,
-                          "hqv2RsSHxGdc:n:r:w:W:a:t:b:p:")) != -1) {
+                          "hqv2RsSHxGdc:n:r:w:W:a:t:b:p:I:")) != -1) {
                switch (c) {
                case 'W':
                        if (master_workload >= 0) {
@@ -3210,6 +3209,9 @@ int main(int argc, char **argv)
                                return 1;
                        }
                        break;
+               case 'I':
+                       master_prng = strtol(optarg, NULL, 0);
+                       break;
                case 'h':
                        print_help();
                        return 0;
@@ -3294,6 +3296,7 @@ int main(int argc, char **argv)
                clients = nr_w_args;
 
        if (verbose > 1) {
+               printf("Random seed is %u.\n", master_prng);
                printf("Using %lu nop calibration for %uus delay.\n",
                       nop_calibration, nop_calibration_us);
                printf("%u client%s.\n", clients, clients > 1 ? "s" : "");
@@ -3312,6 +3315,9 @@ int main(int argc, char **argv)
                }
        }
 
+       srand(master_prng);
+       master_prng = rand();
+
        if (master_workload >= 0 && clients == 1)
                master_workload = -1;
 
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to