From patchwork Thu May 24 17:40:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 920025 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-92743-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="fl84CJ/m"; 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 40sGr8224Yz9ry1 for ; Fri, 25 May 2018 03:40:39 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=ZmcsFNmewfs0Tzt6m0eVb694j1Nti M2qTZ2EUvzP0w1OgE/1UkAZ3b7q4plpGMIP8i/34mIYexp+8XNEfDSGLcwykCiG+ e0ytSeeBM3RwuH5Z2h5RMZD9GWRf+ojEU1Bo0Ierx38tHJxTTLuWZk6h1sIYsp0Q gYoDshkOmhBVxA= 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:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=WeY4nj+bFriCQxgk0EYMr9nKxiE=; b=fl8 4CJ/mqifBcbxDgyYZYdHbH1ZUoStKgRZDA4of/suxONlwu4xjgsfUTS/GsLVWLq4 iKyZBhvGnSEfO+zez6ZhxzfJhPL9eDdmbYuryGyKS0MsxQNZlAk2vK1sT9MoFdh0 BB+a4ofyT2zAa3xfzXKNqMmcx7boxy/1bcaSacdI= Received: (qmail 15340 invoked by alias); 24 May 2018 17:40:33 -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 15322 invoked by uid 89); 24 May 2018 17:40:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM autolearn=ham version=3.3.2 spammy=Hx-languages-length:3632, separated, ifuncs X-HELO: mga06.intel.com X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False X-ExtLoop1: 1 Date: Thu, 24 May 2018 10:40:29 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] benchtests: Add -f/--functions argument Message-ID: <20180524174029.GA9357@intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.5 (2018-04-13) On x86-64, there may be multiple IFUNC implementations for a given function. But we may be only interested in a subset of them. This patch adds -f/--functions argument to compare a subset of IFUNC implementations. Any comments? H.J. --- * benchtests/scripts/compare_strings.py (process_results): Add funcs argument. Compare only functions which are selected. (main): Check if base function is among selected functions. Pass selected functions to process_results. (__main__): Add -f/--functions argument. --- benchtests/scripts/compare_strings.py | 50 ++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/benchtests/scripts/compare_strings.py b/benchtests/scripts/compare_strings.py index d37442076b..4500cdc659 100755 --- a/benchtests/scripts/compare_strings.py +++ b/benchtests/scripts/compare_strings.py @@ -79,12 +79,13 @@ def draw_graph(f, v, ifuncs, results): pylab.savefig('%s-%s.png' % (f, v), bbox_inches='tight') -def process_results(results, attrs, base_func, graph): +def process_results(results, attrs, funcs, base_func, graph): """ Process results and print them Args: results: JSON dictionary of results attrs: Attributes that form the test criteria + funcs: Functions that are selected """ for f in results['functions'].keys(): @@ -92,11 +93,32 @@ def process_results(results, attrs, base_func, graph): v = results['functions'][f]['bench-variant'] print('Variant: %s' % v) + selected = {} + index = 0 base_index = 0 + if funcs: + ifuncs = [] + first_func = True + for i in results['functions'][f]['ifuncs']: + if i in funcs: + if first_func: + base_index = index + first_func = False + selected[index] = 1 + ifuncs.append(i) + else: + selected[index] = 0 + index += 1 + else: + ifuncs = results['functions'][f]['ifuncs'] + for i in ifuncs: + selected[index] = 1 + index += 1 + if base_func: base_index = results['functions'][f]['ifuncs'].index(base_func) - print("%36s%s" % (' ', '\t'.join(results['functions'][f]['ifuncs']))) + print("%36s%s" % (' ', '\t'.join(ifuncs))) print("=" * 120) graph_res = {} for res in results['functions'][f]['results']: @@ -106,12 +128,13 @@ def process_results(results, attrs, base_func, graph): sys.stdout.write('%36s: ' % key) graph_res[key] = res['timings'] for t in res['timings']: - sys.stdout.write ('%12.2f' % t) - if i != base_index: - base = res['timings'][base_index] - diff = (base - t) * 100 / base - sys.stdout.write (' (%6.2f%%)' % diff) - sys.stdout.write('\t') + if selected[i]: + sys.stdout.write ('%12.2f' % t) + if i != base_index: + base = res['timings'][base_index] + diff = (base - t) * 100 / base + sys.stdout.write (' (%6.2f%%)' % diff) + sys.stdout.write('\t') i = i + 1 print('') @@ -130,9 +153,16 @@ def main(args): schema_filename = args.schema base_func = args.base attrs = args.attributes.split(',') + if args.functions: + funcs = args.functions.split(',') + if base_func and not base_func in funcs: + print('Baseline function (%s) not found.' % base_func) + sys.exit(os.EX_DATAERR) + else: + funcs = None results = parse_file(args.input, args.schema) - process_results(results, attrs, base_func, args.graph) + process_results(results, attrs, funcs, base_func, args.graph) if __name__ == '__main__': @@ -148,6 +178,8 @@ if __name__ == '__main__': help='Schema file to validate the result file.') # Optional arguments. + parser.add_argument('-f', '--functions', + help='Comma separated list of functions.') parser.add_argument('-b', '--base', help='IFUNC variant to set as baseline.') parser.add_argument('-g', '--graph', action='store_true',