From patchwork Wed Aug 8 14:59:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10560161 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 59F1814C0 for ; Wed, 8 Aug 2018 15:00:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 475922AFE3 for ; Wed, 8 Aug 2018 15:00:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AB5B2AFE7; Wed, 8 Aug 2018 15:00:01 +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,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 DFD2E2AFE3 for ; Wed, 8 Aug 2018 15:00:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6CE676E595; Wed, 8 Aug 2018 15:00:00 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id A7B916E10E; Wed, 8 Aug 2018 14:59:55 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 12719211-1500050 for multiple; Wed, 08 Aug 2018 15:59:46 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Wed, 8 Aug 2018 15:59:45 +0100 Message-Id: <20180808145945.26159-2-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180808145945.26159-1-chris@chris-wilson.co.uk> References: <20180808145945.26159-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 2/2] igt/perf_pmu: Improve the presentation of the accuracy calibration 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: igt-dev@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Normalize the variance to stddev, and remove some redundant steps in computing the time from itself. Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin Reviewed-by: Tvrtko Ursulin --- tests/perf_pmu.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c index 5a26d5272..4e8da3d94 100644 --- a/tests/perf_pmu.c +++ b/tests/perf_pmu.c @@ -1577,8 +1577,8 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e, /* 1st pass is calibration, second pass is the test. */ for (int pass = 0; pass < ARRAY_SIZE(timeout); pass++) { unsigned int target_idle_us = idle_us; - uint64_t busy_ns = 0, idle_ns = 0; struct timespec start = { }; + uint64_t busy_ns = 0; unsigned long pass_ns = 0; double avg = 0.0, var = 0.0; unsigned int n = 0; @@ -1589,6 +1589,7 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e, unsigned long loop_ns, loop_busy; struct timespec _ts = { }; double err, tmp; + uint64_t now; /* PWM idle sleep. */ _ts.tv_nsec = target_idle_us * 1000; @@ -1605,14 +1606,13 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e, igt_spin_batch_end(spin); /* Time accounting. */ - loop_ns = igt_nsec_elapsed(&start); - loop_busy = loop_ns - loop_busy; - loop_ns -= pass_ns; + now = igt_nsec_elapsed(&start); + loop_busy = now - loop_busy; + loop_ns = now - pass_ns; + pass_ns = now; busy_ns += loop_busy; total_busy_ns += loop_busy; - idle_ns += loop_ns - loop_busy; - pass_ns += loop_ns; total_ns += loop_ns; /* Re-calibrate. */ @@ -1628,10 +1628,14 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e, var += (err - avg) * (err - tmp); } while (pass_ns < timeout[pass]); + pass_ns = igt_nsec_elapsed(&start); expected = (double)busy_ns / pass_ns; - igt_info("%u: busy %"PRIu64"us, idle %"PRIu64"us -> %.2f%% (target: %lu%%; average=%.2f, variance=%f)\n", - pass, busy_ns / 1000, idle_ns / 1000, - 100 * expected, target_busy_pct, avg, var / n); + + igt_info("%u: busy %"PRIu64"us, idle %"PRIu64"us -> %.2f%% (target: %lu%%; average=%.2f±%.3f%%)\n", + pass, busy_ns / 1000, (pass_ns - busy_ns) / 1000, + 100 * expected, target_busy_pct, + avg, sqrt(var / n)); + write(link[1], &expected, sizeof(expected)); }