From patchwork Wed Mar 17 02:35:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naohiro Tamura X-Patchwork-Id: 42664 X-Patchwork-Delegate: szabolcs.nagy@arm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70C2038618AA; Wed, 17 Mar 2021 02:36:38 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa5.hc1455-7.c3s2.iphmx.com (esa5.hc1455-7.c3s2.iphmx.com [68.232.139.130]) by sourceware.org (Postfix) with ESMTPS id 812F13851C26 for ; Wed, 17 Mar 2021 02:36:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 812F13851C26 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=fujitsu.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=naohirot@fujitsu.com IronPort-SDR: mAZg3FtOj7gPvO7lcD1ehGKvRGIYw4SSGpnePX56tONf+xM3ffNnHZiIsuRIrwMQA+ehqrrwtZ mv+Gvgi+rPpXRjZzmqbOoo/VXtf4inVwvhn1fhlRKChmpy+DOcJttvq5hub8v3H7oDOKO6ecn2 mPiBYnZEVYX7PVXYi++QIcRl1T2dxoUIQk/1XlVvyK2+z+dOojnwHnG93G+Oe1SXLka9ckD+PO 76Qw3++oRPd1RbpgkXCivPKmH4RSz/RLAwDhI2E25FaTF9z3n68rM+JEeRQdl5nwYf7D7pmBOg OzA= X-IronPort-AV: E=McAfee;i="6000,8403,9925"; a="22989387" X-IronPort-AV: E=Sophos;i="5.81,254,1610377200"; d="scan'208";a="22989387" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa5.hc1455-7.c3s2.iphmx.com with ESMTP; 17 Mar 2021 11:36:33 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 57F1E4088FD for ; Wed, 17 Mar 2021 11:36:32 +0900 (JST) Received: from m3051.s.css.fujitsu.com (m3051.s.css.fujitsu.com [10.134.21.209]) by oym-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 5EEC944A01E for ; Wed, 17 Mar 2021 11:36:31 +0900 (JST) Received: from bionic.lxd (unknown [10.126.53.116]) by m3051.s.css.fujitsu.com (Postfix) with ESMTP id 3EF9593; Wed, 17 Mar 2021 11:36:31 +0900 (JST) From: Naohiro Tamura To: libc-alpha@sourceware.org Subject: [PATCH 4/5] scripts: Added Vector Length Set test helper script Date: Wed, 17 Mar 2021 02:35:10 +0000 Message-Id: <20210317023510.323258-1-naohirot@fujitsu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317022849.323046-1-naohirot@fujitsu.com> References: <20210317022849.323046-1-naohirot@fujitsu.com> X-TM-AS-GCONF: 00 X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Naohiro Tamura Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Naohiro Tamura This patch is a test helper script to change Vector Length for child process. This script can be used as test-wrapper for 'make check'. Usage examples: ubuntu@bionic:~/build$ make check subdirs=string \ test-wrapper='~/glibc/scripts/vltest.py 16' ubuntu@bionic:~/build$ ~/glibc/scripts/vltest.py 16 make test \ t=string/test-memcpy ubuntu@bionic:~/build$ ~/glibc/scripts/vltest.py 32 ./debugglibc.sh \ string/test-memmove ubuntu@bionic:~/build$ ~/glibc/scripts/vltest.py 64 ./testrun.sh string/test-memset --- scripts/vltest.py | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 scripts/vltest.py diff --git a/scripts/vltest.py b/scripts/vltest.py new file mode 100755 index 0000000000..264dfa449f --- /dev/null +++ b/scripts/vltest.py @@ -0,0 +1,82 @@ +#!/usr/bin/python3 +# Set Scalable Vector Length test helper +# Copyright (C) 2019-2021 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# . +"""Set Scalable Vector Length test helper. + +Set Scalable Vector Length for child process. + +examples: + +ubuntu@bionic:~/build$ make check subdirs=string \ +test-wrapper='~/glibc/scripts/vltest.py 16' + +ubuntu@bionic:~/build$ ~/glibc/scripts/vltest.py 16 make test \ +t=string/test-memcpy + +ubuntu@bionic:~/build$ ~/glibc/scripts/vltest.py 32 ./debugglibc.sh \ +string/test-memmove + +ubuntu@bionic:~/build$ ~/glibc/scripts/vltest.py 64 ./testrun.sh \ +string/test-memset +""" +import argparse +from ctypes import cdll, CDLL +import os +import sys + +EXIT_SUCCESS = 0 +EXIT_FAILURE = 1 +EXIT_UNSUPPORTED = 77 + +AT_HWCAP = 16 +HWCAP_SVE = (1 << 22) + +PR_SVE_GET_VL = 51 +PR_SVE_SET_VL = 50 +PR_SVE_SET_VL_ONEXEC = (1 << 18) +PR_SVE_VL_INHERIT = (1 << 17) +PR_SVE_VL_LEN_MASK = 0xffff + +def main(args): + libc = CDLL("libc.so.6") + if not libc.getauxval(AT_HWCAP) & HWCAP_SVE: + print("CPU doesn't support SVE") + sys.exit(EXIT_UNSUPPORTED) + + libc.prctl(PR_SVE_SET_VL, + args.vl[0] | PR_SVE_SET_VL_ONEXEC | PR_SVE_VL_INHERIT) + os.execvp(args.args[0], args.args) + print("exec system call failure") + sys.exit(EXIT_FAILURE) + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description= + "Set Scalable Vector Length test helper", + formatter_class=argparse.ArgumentDefaultsHelpFormatter) + + # positional argument + parser.add_argument("vl", nargs=1, type=int, + choices=range(16, 257, 16), + help=('vector length '\ + 'which is multiples of 16 from 16 to 256')) + # remainDer arguments + parser.add_argument('args', nargs=argparse.REMAINDER, + help=('args '\ + 'which is passed to child process')) + args = parser.parse_args() + main(args)