From patchwork Thu Jun 8 09:58:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9774347 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 07B9860393 for ; Thu, 8 Jun 2017 09:58:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E921122B39 for ; Thu, 8 Jun 2017 09:58:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE18E26490; Thu, 8 Jun 2017 09:58:26 +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 6369522B39 for ; Thu, 8 Jun 2017 09:58:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 403DE6E383; Thu, 8 Jun 2017 09:58:23 +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 AADFC6E37F for ; Thu, 8 Jun 2017 09:58:21 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id e23so3361759wre.3 for ; Thu, 08 Jun 2017 02:58:21 -0700 (PDT) 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:in-reply-to:references; bh=1Lu76zkpbzu3Y69WxvrUbNioEHPd/X24NlMS4kIGqEU=; b=wVZIdYjQa+7O7uziboTlSakSnLxUYlyIC26VBj0HcnhFpZ/fG8pYli7LdPEv3sbTGi OU2HJB4GTfe4iCl70Bv949v9GadJmOij2jJndsbjsxBtPwQl+ynFShFFbuzD9DWBQkfq 2NIxHNYmEu5WDMDQiNrPRyN6XuQV3VPhTHjabqDEIovzDAxTORifszzcWQOOlApRGU95 cl5Ph+swgnAQte/dHC0cPrYCpeJhgDJAUFQSkjAjewNDkupam22zZDs+YfvWtkSM0LWI GqScKHlaQLkNGXH6n8trBv90KWAK5yh+FF0A6B+hnPo+3GMcVKnJm4mRhQnwUGKGjv7p tzLQ== 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:in-reply-to :references; bh=1Lu76zkpbzu3Y69WxvrUbNioEHPd/X24NlMS4kIGqEU=; b=mp/veVRM7zrVvLWomXOpZZS53RdUVDldemPOAxa/rb3khlN8xfi6mhEeg/UlO20KXF REFqbnQFeyKwK5/dYS343Lj3c2VUrHuQI3nooTvScK+40ZjTN55q3Wnzvd4MPbhX88kt AwiesnT92sV7/yvuFbwTc0+YtF76Gl2tTlR8YxTFX3EtUsIYQCMZ18UccKJWPZDtVzvU GI4QnaPZWkJPXXT9GNubY2lw35cFzvYB+XYBqkSlDH4ztAiBP/i5Lg0WDk+pFBPe1l0N pfJgG3Bmov0S6Q9OWHU9Xywtjjx9l1r4XdfiPn7OHg2nHKWmXp7jnH0K4yEZMNgvgx4i FqvA== X-Gm-Message-State: AODbwcD8Q/cY4hSIFdeV9D1y2r1D9u7CwLtVBaDgn7PUZ4SK95uwh4Zv gdh/zuy7lPDzUI/Yy2o= X-Received: by 10.223.183.20 with SMTP id l20mr14665575wre.154.1496915900074; Thu, 08 Jun 2017 02:58:20 -0700 (PDT) Received: from t460p.intel ([90.218.120.90]) by smtp.gmail.com with ESMTPSA id m141sm3353739wma.7.2017.06.08.02.58.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 02:58:19 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Thu, 8 Jun 2017 10:58:12 +0100 Message-Id: <20170608095812.18237-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170608095812.18237-1-tvrtko.ursulin@linux.intel.com> References: <20170608095812.18237-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/2] igt/gem_fence_upload: Stabilise results X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Most of the subtest were failing on my SKL GT2 and on the various CI systems as well. Try to fix that by different tweaks per subtests: performance: We cannot say how big the performance drop will be once the fences are contented, just that there will be one, so modify the assert accordingly. thread-performance-*: Similar to "performance", but also on some machine the peak performance to compare against seems to be num_cpu dependant which the biggest aggregate throughput with num_cpu clients. On other machines the results are more stable so this change should not affect those. Also, on some machines writes are much faster than reads which was making the "-write" subtest a bit unstable. Increased the number of iterations to hopefully stabilise this. thread-contention: Same as "performance" - we don't know how big the drop to expect. wc-contention: This subtest should not expect a tiled performance drop since CPU WC maps are under test. Change a few things: 1. Number of iterations was to small causing result instability on some machines. 2. There seems to be a performance valley with num_threads == num_cpus so do a pre-warm step in those cases which seem to fix it. 3. Only assert that the final step is slower than the reference, and for the reference take the single thred result which looks to be the fastest. 4. Check that linear vs tiled results in each step are within 15% tolerance to verify the above attempts to stabilise the test. Signed-off-by: Tvrtko Ursulin --- benchmarks/gem_fence_upload.c | 51 ++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/benchmarks/gem_fence_upload.c b/benchmarks/gem_fence_upload.c index 7d9acdc0fcb3..d656d4ea70f8 100644 --- a/benchmarks/gem_fence_upload.c +++ b/benchmarks/gem_fence_upload.c @@ -103,7 +103,7 @@ static void performance(void) errno = 0; igt_assert(linear[1] > 0.75 * linear[0]); - igt_assert(tiled[1] > 0.75 * tiled[0]); + igt_assert(tiled[1] < tiled[0]); } struct thread_performance { @@ -155,7 +155,8 @@ static const char *direction_string(unsigned mask) } static void thread_performance(unsigned mask) { - const int loops = 4096; + const int ncpus = sysconf(_SC_NPROCESSORS_ONLN); + const int loops = (mask & READ) ? 4096 : 32768; int n, count; int fd, num_fences; double linear[2], tiled[2]; @@ -164,9 +165,11 @@ static void thread_performance(unsigned mask) num_fences = gem_available_fences(fd); igt_require(num_fences > 0); + igt_require(num_fences > ncpus); for (count = 2; count < 4*num_fences; count *= 2) { const int nthreads = (mask & READ ? count : 0) + (mask & WRITE ? count : 0); + const int idx = ncpus != count; struct timeval start, end; struct thread_performance readers[count]; struct thread_performance writers[count]; @@ -209,8 +212,8 @@ static void thread_performance(unsigned mask) } gettimeofday(&end, NULL); - linear[count != 2] = nthreads * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096); - igt_info("%s rate for %d linear surfaces, %d threads: %7.3fMiB/s\n", direction_string(mask), count, nthreads, linear[count != 2]); + linear[idx] = nthreads * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096); + igt_info("%s rate for %d linear surfaces, %d threads: %7.3fMiB/s\n", direction_string(mask), count, nthreads, linear[idx]); for (n = 0; n < count; n++) gem_set_tiling(fd, handle[n], I915_TILING_X, 1024); @@ -230,8 +233,8 @@ static void thread_performance(unsigned mask) } gettimeofday(&end, NULL); - tiled[count != 2] = nthreads * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096); - igt_info("%s rate for %d tiled surfaces, %d threads: %7.3fMiB/s\n", direction_string(mask), count, nthreads, tiled[count != 2]); + tiled[idx] = nthreads * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096); + igt_info("%s rate for %d tiled surfaces, %d threads: %7.3fMiB/s\n", direction_string(mask), count, nthreads, tiled[idx]); for (n = 0; n < count; n++) { munmap(ptr[n], OBJECT_SIZE); @@ -241,7 +244,7 @@ static void thread_performance(unsigned mask) errno = 0; igt_assert(linear[1] > 0.75 * linear[0]); - igt_assert(tiled[1] > 0.75 * tiled[0]); + igt_assert(tiled[1] < tiled[0]); } struct thread_contention { @@ -329,13 +332,13 @@ static void thread_contention(void) errno = 0; igt_assert(linear[1] > 0.75 * linear[0]); - igt_assert(tiled[1] > 0.75 * tiled[0]); + igt_assert(tiled[1] < tiled[0]); } static void wc_contention(void) { - const int loops = 4096; - int n, count; + const int ncpus = sysconf(_SC_NPROCESSORS_ONLN); + int n, count, order; int fd, num_fences; double linear[2], tiled[2]; @@ -344,8 +347,13 @@ static void wc_contention(void) num_fences = gem_available_fences(fd); igt_require(num_fences > 0); + igt_require(num_fences > ncpus); - for (count = 1; count < 4*num_fences; count *= 2) { + for (count = 1, order = log2(num_fences * 2) + 1; + count < 4 * num_fences; + count *= 2, order--) { + const int loops = 4096 * order * 2; + const int idx = 1 != count; struct timeval start, end; struct thread_contention threads[count]; @@ -355,15 +363,20 @@ static void wc_contention(void) threads[n].fd = fd; } + if (count <= ncpus / 2) { + for (n = 0; n < count; n++) + pthread_create(&threads[n].thread, NULL, wc_mmap, &threads[n]); + for (n = 0; n < count; n++) + pthread_join(threads[n].thread, NULL); + } gettimeofday(&start, NULL); for (n = 0; n < count; n++) pthread_create(&threads[n].thread, NULL, wc_mmap, &threads[n]); for (n = 0; n < count; n++) pthread_join(threads[n].thread, NULL); gettimeofday(&end, NULL); - - linear[count != 2] = count * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096); - igt_info("Contended upload rate for %d linear threads/wc: %7.3fMiB/s\n", count, linear[count != 2]); + linear[idx] = count * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096); + igt_info("Contended upload rate for %d linear threads/wc: %7.3fMiB/s\n", count, linear[idx]); for (n = 0; n < count; n++) gem_set_tiling(fd, threads[n].handle, I915_TILING_X, 1024); @@ -375,17 +388,19 @@ static void wc_contention(void) pthread_join(threads[n].thread, NULL); gettimeofday(&end, NULL); - tiled[count != 2] = count * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096); - igt_info("Contended upload rate for %d tiled threads/wc: %7.3fMiB/s\n", count, tiled[count != 2]); + tiled[idx] = count * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096); + igt_info("Contended upload rate for %d tiled threads/wc: %7.3fMiB/s\n", count, tiled[idx]); for (n = 0; n < count; n++) { gem_close(fd, threads[n].handle); } + + igt_require(fabs((linear[idx] - tiled[idx]) / linear[idx]) < 0.15); } errno = 0; - igt_assert(linear[1] > 0.75 * linear[0]); - igt_assert(tiled[1] > 0.75 * tiled[0]); + igt_assert(linear[1] < linear[0]); + igt_assert(tiled[1] < tiled[0]); } igt_main