From patchwork Thu Nov 9 05:13:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 836181 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-86925-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Z5tK/ctg"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yXWYL29s2z9sNc for ; Thu, 9 Nov 2017 16:14:14 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=OOIcUakUHDvdPoOOgYKrLBZce+Oz+7G Vt/D+jeNOmoAExiYdEOlNpe7ECM3Y5IMA8b0SrpTcScHUqnVQivzd9hAoKOYBmT1 +3G8u1+86cBXMZfX/AX4bHtxSpE3FDeWmArlssp70aoj4SD1+AMrwF8JfcyVkskT dY2+ve6/pjks= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=KIk2D43pUUyBFxtg6Lt8P0HAMDI=; b=Z5tK/ ctg2LWngzdpf4sd8n6c97MltWxqcEfia40jg0qbwQv71Pz14UNaOaeySmwS+e1pQ wKzJ8astv+MyMS28xYwnQc0jEh8tgdtrhZ8uU+vpW61NV63mWFu7LWMu+y/u7f+o m9niR7MbA6uhZQDzRKokJI/7dKctZwDhiQu7zk= Received: (qmail 78663 invoked by alias); 9 Nov 2017 05:14:01 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 78620 invoked by uid 89); 9 Nov 2017 05:14:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=multiplying X-HELO: homiemail-a52.g.dreamhost.com From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Cc: Wilco.Dijkstra@arm.com, szabolcs.nagy@arm.com Subject: [PATCH 1/3] benchtests: Fix walking sizes and directions for *-walk benchmarks Date: Thu, 9 Nov 2017 10:43:26 +0530 Message-Id: <1510204408-1739-2-git-send-email-siddhesh@sourceware.org> In-Reply-To: <1510204408-1739-1-git-send-email-siddhesh@sourceware.org> References: <1510204408-1739-1-git-send-email-siddhesh@sourceware.org> Make the walking benchmarks walk only backwards since copying both ways is biased in favour of implementations that use non-temporal stores for larger sizes; falkor is one of them. This also fixes up bugs in computation of the result which ended up multiplying the length with the timing result unnecessarily. * benchtests/bench-memcpy-walk.c (do_one_test): Copy only backwards. Fix timing computation. * benchtests/bench-memmove-walk.c (do_one_test): Likewise. * benchtests/bench-memset-walk.c (do_one_test): Walk backwards on memset by N at a time. Fix timing computation. --- benchtests/bench-memcpy-walk.c | 14 +++++--------- benchtests/bench-memmove-walk.c | 15 +++++---------- benchtests/bench-memset-walk.c | 4 ++-- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/benchtests/bench-memcpy-walk.c b/benchtests/bench-memcpy-walk.c index 69d467d..5b56341 100644 --- a/benchtests/bench-memcpy-walk.c +++ b/benchtests/bench-memcpy-walk.c @@ -47,26 +47,22 @@ static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src, size_t len) { - size_t i, iters = MIN_PAGE_SIZE / len; + size_t i = 0; timing_t start, stop, cur; char *dst_end = dst + MIN_PAGE_SIZE - len; char *src_end = src + MIN_PAGE_SIZE - len; TIMING_NOW (start); - /* Copy the entire buffer back and forth, LEN at a time. */ - for (i = 0; i < iters && dst_end >= dst && src <= src_end; src++, dst_end--) - { - CALL (impl, dst_end, src, len); - CALL (impl, src, dst_end, len); - i += 2; - } + /* Copy the entire buffer backwards, LEN at a time. */ + for (; src_end >= src && dst_end >= dst; src_end -= len, dst_end -= len, i++) + CALL (impl, src_end, dst_end, len); TIMING_NOW (stop); TIMING_DIFF (cur, start, stop); /* Get time taken per function call. */ - json_element_double (json_ctx, (double) cur * len / i); + json_element_double (json_ctx, (double) cur / i); } static void diff --git a/benchtests/bench-memmove-walk.c b/benchtests/bench-memmove-walk.c index 54dcd64..969ddd9 100644 --- a/benchtests/bench-memmove-walk.c +++ b/benchtests/bench-memmove-walk.c @@ -47,26 +47,22 @@ static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src, size_t len) { - size_t i, iters = MIN_PAGE_SIZE / len; + size_t i = 0; timing_t start, stop, cur; char *dst_end = dst + MIN_PAGE_SIZE - len; char *src_end = src + MIN_PAGE_SIZE - len; TIMING_NOW (start); - /* Copy the entire buffer back and forth, LEN at a time. */ - for (i = 0; i < iters && dst_end >= dst && src <= src_end; src++, dst_end--) - { - CALL (impl, dst_end, src, len); - CALL (impl, src, dst_end, len); - i += 2; - } + /* Copy the entire buffer backwards, LEN at a time. */ + for (; src_end >= src && dst <= dst_end; dst += len, src_end -= len, i++) + CALL (impl, dst, src_end, len); TIMING_NOW (stop); TIMING_DIFF (cur, start, stop); /* Get time taken per function call. */ - json_element_double (json_ctx, (double) cur * len / i); + json_element_double (json_ctx, (double) cur / i); } static void @@ -79,7 +75,6 @@ do_test (json_ctx_t *json_ctx, size_t len, bool overlap) if (overlap) buf2 = buf1; - /* First the non-overlapping moves. */ FOR_EACH_IMPL (impl, 0) do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, len); diff --git a/benchtests/bench-memset-walk.c b/benchtests/bench-memset-walk.c index 59d2626..80fbe09 100644 --- a/benchtests/bench-memset-walk.c +++ b/benchtests/bench-memset-walk.c @@ -66,14 +66,14 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, CHAR *s_end, timing_t start, stop, cur; TIMING_NOW (start); - for (i = 0; i < iters && s <= s_end; s++, i++) + for (i = 0; i < iters && s <= s_end; s_end -= n, i++) CALL (impl, s, c, n); TIMING_NOW (stop); TIMING_DIFF (cur, start, stop); /* Get time taken per function call. */ - json_element_double (json_ctx, (double) cur * n / i); + json_element_double (json_ctx, (double) cur / i); } static void