From patchwork Wed Mar 7 11:11:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10263807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 997F760211 for ; Wed, 7 Mar 2018 11:11:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89BD129360 for ; Wed, 7 Mar 2018 11:11:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A9B42947F; Wed, 7 Mar 2018 11:11:33 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 EE84429360 for ; Wed, 7 Mar 2018 11:11:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 50C8E6E176; Wed, 7 Mar 2018 11:11:31 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8FCA06E10C for ; Wed, 7 Mar 2018 11:11:29 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id o8so1755694wra.1 for ; Wed, 07 Mar 2018 03:11:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=gWRZhjcdMLLK3OdzhwTlaMk+bWCrvuWF7RnFGd6NhCU=; b=fwoOSYpQ+Cwer7yQcfvEAhrEORvMdoOKx9XEY55GYEX3of1N0smr1KZk2S5zoUhdhZ yOBJRwcT1/u8N3Qx/LA9o8pyE8P59vU3y94aNhO6wv1KLe9syAwXjMdEO1IvvWAKsIgo 4n9fAlOapQ613eZwZ7KXNIfxNpQk9X1ljD7m4L4Oi20j5hZmN3iqa91MT34fAcBEz4Su FEp5aZGmosqjg8isHbUpLe7FZ1LfhUh+r+pbjhQFGsjGGbMRYn+6D03q037/XooeY4fF o3/SjnPlvJ3BbkLvCjPFMWH6RKf9cYWoIJHxogaqAPC2Fb6vLVUj6J/A+lEzAXNGng9O TlAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gWRZhjcdMLLK3OdzhwTlaMk+bWCrvuWF7RnFGd6NhCU=; b=UZ/SCFudoxazr3dYWHjeEDbgyOC6wzQvu5iRm2jEU4o4ZQfhyYrsXHmAcrs+uqvRQp dGczGTOVtx6z1ha6Pot4k88GKnqrLUYN39+RwwQBQtXYcbeKNsYQJB4tgPhuLru6ZRz9 /EKdS+Hi/XkF2SBTxVMEJxCZd+1uq1f304qQbxDJV1tTi4ZjQlJwqeFnpV8j2V1wWDCF GnmcGFBZbb/QPT8xZoCqNp/Y8HZcMSDik781HpYRpo4/uK/2v4wq6/4vCYHZ7p8AE8kq gmSmSA499HRHZm9jYqDEZZ4d85sos1s2QtbQwKUtevjrkpCoH89Kg6nhIoYocy5Rl+D4 mHaA== X-Gm-Message-State: APf1xPDuaYCeqmDcpP9itDISLN/rkuzV3NGnhvXsjaRhJf1lUueA+N/9 ldW+7yHf0IqAxtqkc2V8RxiO6OrB X-Google-Smtp-Source: AG47ELuvGeHqi+BAOZalQCqSvRLlXyLYDMl706k51kmCTLzHTYj1MjamkvTT3hypXsJmA/H1XmT/0g== X-Received: by 10.223.199.71 with SMTP id b7mr19774748wrh.228.1520421088217; Wed, 07 Mar 2018 03:11:28 -0800 (PST) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id x107sm22634999wrb.97.2018.03.07.03.11.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Mar 2018 03:11:27 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Wed, 7 Mar 2018 11:11:19 +0000 Message-Id: <20180307111119.9423-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 Subject: [Intel-gfx] [PATCH i-g-t] tests/perf_pmu: Use absolute tolerance in accuracy tests 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 MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin We need to use absolute tolerance when asserting on percentages. Relative tolerance in this case is unfair and inaccurate since it's strictness varies with relative target busyness. Signed-off-by: Tvrtko Ursulin Cc: Chris Wilson Reviewed-by: Chris Wilson --- tests/perf_pmu.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c index 9ebffc64d1f1..8e547338b47c 100644 --- a/tests/perf_pmu.c +++ b/tests/perf_pmu.c @@ -1459,7 +1459,15 @@ static void __rearm_spin_batch(igt_spin_t *spin) __sync_synchronize(); } -#define div_round_up(a, b) (((a) + (b) - 1) / (b)) +#define __assert_within(x, ref, tol_up, tol_down) \ + igt_assert_f((double)(x) <= ((double)(ref) + (tol_up)) && \ + (double)(x) >= ((double)(ref) - (tol_down)), \ + "%f not within +%f/-%f of %f! ('%s' vs '%s')\n", \ + (double)(x), (double)(tol_up), (double)(tol_down), \ + (double)(ref), #x, #ref) + +#define assert_within(x, ref, tolerance) \ + __assert_within(x, ref, tolerance, tolerance) static void accuracy(int gem_fd, const struct intel_execution_engine2 *e, @@ -1571,7 +1579,7 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e, /* Let the child run. */ read(link[0], &expected, sizeof(expected)); - assert_within_epsilon(expected, target_busy_pct/100., 0.05); + assert_within(100.0 * expected, target_busy_pct, 5); /* Collect engine busyness for an interesting part of child runtime. */ fd = open_pmu(I915_PMU_ENGINE_BUSY(e->class, e->instance)); @@ -1590,8 +1598,11 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e, igt_info("error=%.2f%% (%.2f%% vs %.2f%%)\n", __error(busy_r, expected), 100 * busy_r, 100 * expected); - assert_within_epsilon(busy_r, expected, 0.15); - assert_within_epsilon(1 - busy_r, 1 - expected, 0.15); + busy_r *= 100.0; + expected *= 100.0; + + assert_within(busy_r, expected, 2); + assert_within(100.0 - busy_r, 100.0 - expected, 2); } igt_main