From patchwork Fri Jan 2 11:03:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: akash.goel@intel.com X-Patchwork-Id: 5558571 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 83D689F37F for ; Fri, 2 Jan 2015 10:58:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A36252017D for ; Fri, 2 Jan 2015 10:58:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C417920166 for ; Fri, 2 Jan 2015 10:58:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B4C36E34E; Fri, 2 Jan 2015 02:58:23 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B3CE6E34E for ; Fri, 2 Jan 2015 02:58:22 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 02 Jan 2015 02:58:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,684,1413270000"; d="scan'208";a="663567864" Received: from akashgoe-desktop.iind.intel.com ([10.223.82.76]) by orsmga002.jf.intel.com with ESMTP; 02 Jan 2015 02:58:18 -0800 From: akash.goel@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 2 Jan 2015 16:33:32 +0530 Message-Id: <1420196614-13543-5-git-send-email-akash.goel@intel.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1420196614-13543-1-git-send-email-akash.goel@intel.com> References: <1420196614-13543-1-git-send-email-akash.goel@intel.com> Cc: daniel.vetter@ffwll.ch Subject: [Intel-gfx] [PATCH 4/6] igt/gem_fence_upload: Add comparison against wc mmaps 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Chris Wilson Signed-off-by: Chris Wilson --- tests/gem_fence_upload.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/tests/gem_fence_upload.c b/tests/gem_fence_upload.c index 88da5dc..81f797b 100644 --- a/tests/gem_fence_upload.c +++ b/tests/gem_fence_upload.c @@ -267,6 +267,21 @@ static void *no_contention(void *closure) return NULL; } +static void *wc_mmap(void *closure) +{ + struct thread_contention *t = closure; + int n; + + for (n = 0; n < t->loops; n++) { + uint32_t *ptr = gem_mmap__wc(t->fd, t->handle, 0, OBJECT_SIZE, PROT_READ | PROT_WRITE); + igt_assert(ptr); + memset(ptr + (rand() % 256) * 4096 / 4, 0, 4096); + munmap(ptr, OBJECT_SIZE); + } + + return NULL; +} + static void thread_contention(void) { const int loops = 4096; @@ -322,6 +337,62 @@ static void thread_contention(void) igt_assert(tiled[1] > 0.75 * tiled[0]); } +static void wc_contention(void) +{ + const int loops = 4096; + int n, count; + int fd, num_fences; + double linear[2], tiled[2]; + + fd = drm_open_any(); + igt_require_mmap_wc(fd); + + num_fences = gem_available_fences(fd); + igt_require(num_fences > 0); + + for (count = 1; count < 4*num_fences; count *= 2) { + struct timeval start, end; + struct thread_contention threads[count]; + + for (n = 0; n < count; n++) { + threads[n].handle = gem_create(fd, OBJECT_SIZE); + threads[n].loops = loops; + threads[n].fd = fd; + } + + 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]); + + for (n = 0; n < count; n++) + gem_set_tiling(fd, threads[n].handle, I915_TILING_X, 1024); + + 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); + + 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]); + + for (n = 0; n < count; n++) { + gem_close(fd, threads[n].handle); + } + } + + errno = 0; + igt_assert(linear[1] > 0.75 * linear[0]); + igt_assert(tiled[1] > 0.75 * tiled[0]); +} + igt_main { igt_skip_on_simulation(); @@ -330,6 +401,8 @@ igt_main performance(); igt_subtest("thread-contention") thread_contention(); + igt_subtest("wc-contention") + wc_contention(); igt_subtest("thread-performance-read") thread_performance(READ); igt_subtest("thread-performance-write")