From patchwork Wed Mar 28 08:19:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Phillips X-Patchwork-Id: 892015 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-91275-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="NiDw3c5p"; 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 40B15v6zrdz9s25 for ; Wed, 28 Mar 2018 19:20:19 +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:date:to:from:reply-to:subject:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=IPdFhqOLx4iveTqw2X3Yf28zn9PB6yyese5sqn7bCooJARtNbUJjh 1usuNCi9uzkxKAPRdPdqWWJuNo7+JK17JKqjoPGOuekpt/XiZIyTNzGUrB01EcjX pg3B9lGU9lXyIgK6Mglnjqx1DjmK5ltDu9VzZi+K3/XMwZbf1PGnIM= 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:to:from:reply-to:subject:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=RgduskNHbqYZ64/Y+lJjW+/IceU=; b=NiDw3c5pS/MBGiY0LDiuMkhvqI82 Id0xqdDc95sgliJQiOEyG3FKwyyv2K2ZYMfMvW5N799R/F13l3h+zN0N3G2Zocc2 zG1OdaHnf4ZvHQrP64IE85FnTQ7RlKGvFvzbTLPojXnJeneDLigbusA51VrnByeD 4nvyhY5JE4sFJCk= Received: (qmail 16593 invoked by alias); 28 Mar 2018 08:20:13 -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 16559 invoked by uid 89); 28 Mar 2018 08:20:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=H*R:D*protonmail.com, H*RU:sk:mail4.p, H*r:sk:mail4.p, Hx-spam-relays-external:sk:mail4.p X-HELO: mail4.protonmail.ch Date: Wed, 28 Mar 2018 04:19:57 -0400 To: "libc-alpha@sourceware.org" From: Nathan Phillips Reply-To: Nathan Phillips Subject: [PATCH] powerpc: Expose VSX feature test Message-ID: Feedback-ID: pIMM7SjgsBkoh1VHiFjtO1aCnt3hdIguBtsk5guUZVvO7OljEshi__TzlKj4CrF76xqm0sJcB-O9Syj4wMI1Lg==:Ext:ProtonMail MIME-Version: 1.0 Hope it's OK to submit a small change like this. Trying to familiarize myself with the patch process. My copyright assignment is underway. --- Read the HWCAP auxval key to test for VSX support. Expose result through the cpu_features interface. Preliminary change to prepare for PowerPC optimized libmvec implementations [BZ #20123]. Enables selecting optimized version at load time in ifunc resolver. * sysdeps/powerpc/cpu-features.h (cpu_features): Add vsx field. * sysdeps/powerpc/cpu-features.c (init_cpu_features): Feature test VSX availability. --- diff --git a/sysdeps/powerpc/cpu-features.c b/sysdeps/powerpc/cpu-features.c index 955d4778a6..477c7504b9 100644 --- a/sysdeps/powerpc/cpu-features.c +++ b/sysdeps/powerpc/cpu-features.c @@ -16,6 +16,8 @@ License along with the GNU C Library; if not, see . */ +#include +#include #include #include @@ -26,6 +28,9 @@ static inline void init_cpu_features (struct cpu_features *cpu_features) { + errno = 0; + unsigned long int hwcap = getauxval (AT_HWCAP); + /* Default is to use aligned memory access on optimized function unless tunables is enable, since for this case user can explicit disable unaligned optimizations. */ @@ -36,4 +41,13 @@ init_cpu_features (struct cpu_features *cpu_features) #else cpu_features->use_cached_memopt = false; #endif + + if (errno == ENOENT) + { + cpu_features->vsx = false; + } + else + { + cpu_features->vsx = ((hwcap & PPC_FEATURE_HAS_VSX) != 0); + } } diff --git a/sysdeps/powerpc/cpu-features.h b/sysdeps/powerpc/cpu-features.h index e596385b4b..0248862b8a 100644 --- a/sysdeps/powerpc/cpu-features.h +++ b/sysdeps/powerpc/cpu-features.h @@ -23,6 +23,7 @@ struct cpu_features { bool use_cached_memopt; + bool vsx; }; #endif /* __CPU_FEATURES_H */