From patchwork Wed Jul 23 13:14:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 4610751 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 09B549F37C for ; Wed, 23 Jul 2014 13:16:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1536D20179 for ; Wed, 23 Jul 2014 13:15:59 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0A46420142 for ; Wed, 23 Jul 2014 13:15:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B0586E0C7; Wed, 23 Jul 2014 06:15:57 -0700 (PDT) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id B50966E0C7 for ; Wed, 23 Jul 2014 06:15:55 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 23 Jul 2014 06:14:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,717,1400050800"; d="scan'208";a="547751427" Received: from tursulin-linux.iwi.intel.com ([172.28.253.62]) by orsmga001.jf.intel.com with ESMTP; 23 Jul 2014 06:14:22 -0700 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Wed, 23 Jul 2014 14:14:19 +0100 Message-Id: <1406121259-10086-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 1.9.3 Subject: [Intel-gfx] [PATCH] igt/gem_userptr_benchmark: Testing of overlapping synchronized objects X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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=-3.2 required=5.0 tests=BAYES_00,HK_RANDOM_FROM, RCVD_IN_DNSWL_MED, 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 Larger performance impact is expected with first draft of the kernel implementation for overlapping objects so this is just to confirm that. Signed-off-by: Tvrtko Ursulin Cc: Chris Wilson --- benchmarks/gem_userptr_benchmark.c | 97 ++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 25 deletions(-) diff --git a/benchmarks/gem_userptr_benchmark.c b/benchmarks/gem_userptr_benchmark.c index 4d7442b..04af219 100644 --- a/benchmarks/gem_userptr_benchmark.c +++ b/benchmarks/gem_userptr_benchmark.c @@ -213,7 +213,8 @@ static void exchange_ptr(void *array, unsigned i, unsigned j) static void test_malloc_free(int random) { unsigned long iter = 0; - unsigned int i, tot = 1000; + unsigned int i; + const unsigned int tot = 1000; void *ptr[tot]; start_test(test_duration_sec); @@ -230,13 +231,14 @@ static void test_malloc_free(int random) iter++; } - printf("%8lu iter/s\n", iter / test_duration_sec); + printf("%10lu op/s\n", 2 * tot * iter / test_duration_sec); } static void test_malloc_realloc_free(int random) { unsigned long iter = 0; - unsigned int i, tot = 1000; + unsigned int i; + const unsigned int tot = 1000; void *ptr[tot]; start_test(test_duration_sec); @@ -259,13 +261,14 @@ static void test_malloc_realloc_free(int random) iter++; } - printf("%8lu iter/s\n", iter / test_duration_sec); + printf("%10lu op/s\n", 3 * tot * iter / test_duration_sec); } static void test_mmap_unmap(int random) { unsigned long iter = 0; - unsigned int i, tot = 1000; + unsigned int i; + const unsigned int tot = 1000; void *ptr[tot]; start_test(test_duration_sec); @@ -283,7 +286,7 @@ static void test_mmap_unmap(int random) iter++; } - printf("%8lu iter/s\n", iter / test_duration_sec); + printf("%10lu op/s\n", 2 * tot * iter / test_duration_sec); } static void test_ptr_read(void *ptr) @@ -307,7 +310,7 @@ static void test_ptr_read(void *ptr) iter++; } - printf("%8lu MB/s\n", iter / test_duration_sec * BO_SIZE / 1000000); + printf("%10lu MB/s\n", iter / test_duration_sec * BO_SIZE / 1000000); } static void test_ptr_write(void *ptr) @@ -331,7 +334,31 @@ static void test_ptr_write(void *ptr) iter++; } - printf("%8lu MB/s\n", iter / test_duration_sec * BO_SIZE / 1000000); + printf("%10lu MB/s\n", iter / test_duration_sec * BO_SIZE / 1000000); +} + +static void test_impact_common(void *ptr, unsigned int nr) +{ + printf("ptr-read, %5u bos = ", nr); + test_ptr_read(ptr); + + printf("ptr-write, %5u bos = ", nr); + test_ptr_write(ptr); + + printf("malloc-free, %5u bos = ", nr); + test_malloc_free(0); + printf("malloc-free-random, %5u bos = ", nr); + test_malloc_free(1); + + printf("malloc-realloc-free, %5u bos = ", nr); + test_malloc_realloc_free(0); + printf("malloc-realloc-free-random, %5u bos = ", nr); + test_malloc_realloc_free(1); + + printf("mmap-unmap, %5u bos = ", nr); + test_mmap_unmap(0); + printf("mmap-unmap-random, %5u bos = ", nr); + test_mmap_unmap(1); } static void test_impact(int fd) @@ -351,29 +378,46 @@ static void test_impact(int fd) else ptr = buffer; - printf("ptr-read, %5u bos = ", nr_bos[subtest]); - test_ptr_read(ptr); + test_impact_common(ptr, nr_bos[subtest]); - printf("ptr-write %5u bos = ", nr_bos[subtest]); - test_ptr_write(ptr); + for (i = 0; i < nr_bos[subtest]; i++) + free_userptr_bo(fd, handles[i]); + } +} - printf("malloc-free, %5u bos = ", nr_bos[subtest]); - test_malloc_free(0); - printf("malloc-free-random %5u bos = ", nr_bos[subtest]); - test_malloc_free(1); +static void test_impact_overlap(int fd) +{ + unsigned int total = sizeof(nr_bos) / sizeof(nr_bos[0]); + unsigned int subtest, i; + uint32_t handles[nr_bos[total-1]]; + void *ptr; + char buffer[BO_SIZE]; + void *block; + uint32_t handle; + int ret; - printf("malloc-realloc-free, %5u bos = ", nr_bos[subtest]); - test_malloc_realloc_free(0); - printf("malloc-realloc-free-random, %5u bos = ", nr_bos[subtest]); - test_malloc_realloc_free(1); + for (subtest = 0; subtest < total; subtest++) { + if (nr_bos[subtest] > 0) { + ret = posix_memalign(&block, PAGE_SIZE, BO_SIZE * nr_bos[subtest]); + igt_assert(ret == 0); + for (ptr = block, i = 0; i < nr_bos[subtest]; i++) { + ret = gem_userptr(fd, ptr, BO_SIZE, 0, &handle); + igt_assert(ret == 0); + handles[i] = handle; + ptr = (char *)ptr + BO_SIZE / 2; + } + ptr = block; + } else { + ptr = buffer; + } - printf("mmap-unmap, %5u bos = ", nr_bos[subtest]); - test_mmap_unmap(0); - printf("mmap-unmap-random, %5u bos = ", nr_bos[subtest]); - test_mmap_unmap(1); + test_impact_common(ptr, nr_bos[subtest]); for (i = 0; i < nr_bos[subtest]; i++) - free_userptr_bo(fd, handles[i]); + gem_close(fd, handles[i]); + + if (nr_bos[subtest]) + free(block); } } @@ -494,6 +538,9 @@ int main(int argc, char **argv) igt_subtest("userptr-impact-sync") test_impact(fd); + igt_subtest("userptr-overlap-impact-sync") + test_impact_overlap(fd); + igt_exit(); return 0;