From patchwork Mon Feb 4 08:36:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10795129 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 DBB3F6C2 for ; Mon, 4 Feb 2019 08:36:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDC952AE59 for ; Mon, 4 Feb 2019 08:36:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C23622AE7F; Mon, 4 Feb 2019 08:36:44 +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 7A0FA2ADBB for ; Mon, 4 Feb 2019 08:36:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BBB386E43C; Mon, 4 Feb 2019 08:36:35 +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 B1C156E40F; Mon, 4 Feb 2019 08:36:31 +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 15453948-1500050 for multiple; Mon, 04 Feb 2019 08:36:15 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 4 Feb 2019 08:36:09 +0000 Message-Id: <20190204083614.2385-8-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204083614.2385-1-chris@chris-wilson.co.uk> References: <20190204083614.2385-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 08/13] i915/gem_exec_latency: Normalize results into ns 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 Present the latency results in nanoseconds not RCS cycles. Signed-off-by: Chris Wilson --- tests/i915/gem_exec_latency.c | 36 ++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tests/i915/gem_exec_latency.c b/tests/i915/gem_exec_latency.c index de16322a6..b16b25e53 100644 --- a/tests/i915/gem_exec_latency.c +++ b/tests/i915/gem_exec_latency.c @@ -59,6 +59,7 @@ #define PREEMPT 0x2 static unsigned int ring_size; +static double rcs_clock; static void poll_ring(int fd, unsigned ring, const char *name) @@ -238,10 +239,11 @@ static void latency_on_ring(int fd, igt_assert(offset == obj[2].offset); gem_set_domain(fd, obj[1].handle, I915_GEM_DOMAIN_GTT, 0); - igt_info("%s: dispatch latency: %.2f, execution latency: %.2f (target %.2f)\n", + igt_info("%s: dispatch latency: %.1fns, execution latency: %.1fns (target %.1fns)\n", name, - (end - start) / (double)repeats, - gpu_latency, (results[repeats - 1] - results[0]) / (double)(repeats - 1)); + (end - start) / (double)repeats * rcs_clock, + gpu_latency * rcs_clock, + (results[repeats - 1] - results[0]) / (double)(repeats - 1) * rcs_clock); munmap(map, 64*1024); munmap(results, 4096); @@ -620,6 +622,30 @@ rthog_latency_on_ring(int fd, unsigned int engine, const char *name, unsigned in munmap(results, MMAP_SZ); } +static double clockrate(int reg) +{ + volatile uint32_t *mmio; + uint32_t r_start, r_end; + struct timespec tv; + uint64_t t_start, t_end; + uint64_t elapsed; + + mmio = (volatile uint32_t *)((volatile char *)igt_global_mmio + reg); + + t_start = igt_nsec_elapsed(&tv); + r_start = *mmio; + elapsed = igt_nsec_elapsed(&tv) - t_start; + + usleep(1000); + + t_end = igt_nsec_elapsed(&tv); + r_end = *mmio; + elapsed += igt_nsec_elapsed(&tv) - t_end; + + elapsed = (t_end - t_start) + elapsed / 2; + return (r_end - r_start) * 1e9 / elapsed; +} + igt_main { const struct intel_execution_engine *e; @@ -640,6 +666,10 @@ igt_main ring_size = 1024; intel_register_access_init(intel_get_pci_device(), false, device); + rcs_clock = clockrate(RCS_TIMESTAMP); + igt_info("RCS timestamp clock: %.3fKHz, %.1fns\n", + rcs_clock / 1e3, 1e9 / rcs_clock); + rcs_clock = 1e9 / rcs_clock; } igt_subtest("all-rtidle-submit")