From patchwork Wed May 22 15:57:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10956239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB09714C0 for ; Wed, 22 May 2019 15:57:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC46728716 for ; Wed, 22 May 2019 15:57:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A10DC28BDE; Wed, 22 May 2019 15:57:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,HK_RANDOM_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5076428716 for ; Wed, 22 May 2019 15:57:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8F8E89C6B; Wed, 22 May 2019 15:57:54 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id D4A3389C5E; Wed, 22 May 2019 15:57:46 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2019 08:57:46 -0700 X-ExtLoop1: 1 Received: from dmironox-mobl5.ccr.corp.intel.com (HELO localhost.localdomain) ([10.252.20.122]) by fmsmga005.fm.intel.com with ESMTP; 22 May 2019 08:57:45 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Wed, 22 May 2019 16:57:19 +0100 Message-Id: <20190522155720.28723-15-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190522155720.28723-1-tvrtko.ursulin@linux.intel.com> References: <20190522155720.28723-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 14/15] gem_wsim: Fix prng usage X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Back when gem_wsim used forking it was safe to use the common storage prng, but after converting to threads it no longer is. Fix by storing and using a new per workload seed for batch buffer duration randomness. Signed-off-by: Tvrtko Ursulin Reviewed-by: Chris Wilson --- benchmarks/gem_wsim.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c index 0ccb271575f7..c43bbbc8c94d 100644 --- a/benchmarks/gem_wsim.c +++ b/benchmarks/gem_wsim.c @@ -193,6 +193,7 @@ struct workload unsigned int flags; bool print_stats; + uint32_t bb_prng; uint32_t prng; struct timespec repeat_start; @@ -240,6 +241,8 @@ struct workload static const unsigned int nop_calibration_us = 1000; static unsigned long nop_calibration; +static unsigned int master_prng; + static unsigned int context_vcs_rr; static int verbose = 1; @@ -1067,14 +1070,14 @@ clone_workload(struct workload *_wrk) #define PAGE_SIZE (4096) #endif -static unsigned int get_duration(struct w_step *w) +static unsigned int get_duration(struct workload *wrk, struct w_step *w) { struct duration *dur = &w->duration; if (dur->min == dur->max) return dur->min; else - return dur->min + hars_petruska_f54_1_random_unsafe() % + return dur->min + hars_petruska_f54_1_random(&wrk->bb_prng) % (dur->max + 1 - dur->min); } @@ -1448,6 +1451,7 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) wrk->id = id; wrk->prng = rand(); + wrk->bb_prng = (wrk->flags & SYNCEDCLIENTS) ? master_prng : rand(); wrk->run = true; ctx_vcs = 0; @@ -2607,7 +2611,7 @@ do_eb(struct workload *wrk, struct w_step *w, enum intel_engine_id engine, w->eb.batch_start_offset = w->unbound_duration ? 0 : - ALIGN(w->bb_sz - get_bb_sz(get_duration(w)), + ALIGN(w->bb_sz - get_bb_sz(get_duration(wrk, w)), 2 * sizeof(uint32_t)); for (i = 0; i < w->fence_deps.nr; i++) { @@ -2676,9 +2680,6 @@ static void *run_workload(void *data) clock_gettime(CLOCK_MONOTONIC, &t_start); - hars_petruska_f54_1_random_seed((wrk->flags & SYNCEDCLIENTS) ? - 0 : wrk->id); - init_status_page(wrk, INIT_ALL); for (count = 0; wrk->run && (wrk->background || count < wrk->repeat); count++) { @@ -3117,6 +3118,10 @@ 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) { switch (c) {