From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id C468D1F619 for ; Tue, 17 Mar 2020 04:47:17 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7B27A3940CEA; Tue, 17 Mar 2020 04:47:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B27A3940CEA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1584420432; bh=BnOjiGs/EkTdyIv+JtQg9s+vu9qNYqhOOBwb6if9uko=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=FEgi9eRMeHIO6yPOSZrw+vlbMvbUqViGf7yAC+tjUTXDq/CZcYQjH0AXvd8hCjQWt cN4R5eCJ4CrxSPR25WfVORD12bYnRBjiCrq3pn1+uHTc/76VlU9OD97weczjw/vJ6+ +lVaip6vxBhDotOHyFUdY3rBmO8V8kEzA0+w+Wy8= Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by sourceware.org (Postfix) with ESMTPS id D087138A1033 for ; Tue, 17 Mar 2020 04:47:10 +0000 (GMT) Received: by mail-pl1-x643.google.com with SMTP id f16so9058425plj.4 for ; Mon, 16 Mar 2020 21:47:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BnOjiGs/EkTdyIv+JtQg9s+vu9qNYqhOOBwb6if9uko=; b=IeVvhJUqrET52tWubnQIWYxOT97tFRW5COcfDRSmYRge55gmx+bDzeE5poml4vgRvS CsNJQxADp9gYuN6k/dDmnVHqaWt86iNIhoJtPcolZ/ybyyH3v2lEGPQa/hdi1A5FCUdT cF8In6b8zTfcAkmy0iECPU/Ts3zLTa0BBHbPiccs5ST3NBV1Ang81dhBgoSyDnnl1/Ug cnSKnhRsFRXc4YZ2GPiBD7fTV+q1qWflQCUm6E65L1hKh2q7PBEmLMaatvVvVBPsTThh l7ANEnKzMwpqSP0+TsJHpQMxIzyxxJCaJk320hVTqO6DjQ5FKIR/i0Z7UCx3Jfscg5Ux xzAw== X-Gm-Message-State: ANhLgQ00dUTpW5bNdsXUxlGAA7YBmInqg4E5uNr99JtrVzxaZKaLrMFw VGgyIR5hCdwt8ActDpg0JOX3XcVG X-Google-Smtp-Source: ADFU+vsS31fTsgnPTjDNFcVDlQ78whlr7XVrUgIdYYNK4p4aMLSS0VNglqi++cBlh9qtpU3SxF2U1Q== X-Received: by 2002:a17:90a:3a8f:: with SMTP id b15mr3129577pjc.178.1584420429687; Mon, 16 Mar 2020 21:47:09 -0700 (PDT) Received: from Myrtle-ZP-Model0.amd.com.amd.com ([165.204.156.251]) by smtp.gmail.com with ESMTPSA id md20sm1218661pjb.15.2020.03.16.21.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 21:47:09 -0700 (PDT) X-Google-Original-From: Prem Mallappa To: libc-alpha@sourceware.org, codonell@redhat.com, schwab@suse.com, FWeimer@redhat.com Subject: [PATCH 1/3] x86: Refactor platform support in cpu_features Date: Tue, 17 Mar 2020 10:16:44 +0530 Message-Id: <20200317044646.29707-2-PMallappa@amd.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317044646.29707-1-PMallappa@amd.com> References: <20200317044646.29707-1-PMallappa@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , From: Prem Mallappa via Libc-alpha Reply-To: Prem Mallappa Cc: Prem Mallappa Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Prem Mallappa This is a preliminary support to have platform for AMD processors. Signed-off-by: Prem Mallappa --- sysdeps/x86/cpu-features.c | 99 ++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index 81a170a819..a36f385976 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -302,6 +302,58 @@ _Static_assert (((index_arch_Fast_Unaligned_Load == index_arch_Fast_Copy_Backward)), "Incorrect index_arch_Fast_Unaligned_Load"); +static void +set_platform (struct cpu_features *cpu_features) +{ +#ifdef __x86_64__ + const char *platform = NULL; + + GLRO(dl_hwcap) = HWCAP_X86_64; + + if (cpu_features->basic.kind == arch_kind_intel) + { + if (CPU_FEATURES_ARCH_P (cpu_features, AVX512F_Usable) + && CPU_FEATURES_CPU_P (cpu_features, AVX512CD)) + { + if (CPU_FEATURES_CPU_P (cpu_features, AVX512ER)) + { + if (CPU_FEATURES_CPU_P (cpu_features, AVX512PF)) + platform = "xeon_phi"; + } + else + { + if (CPU_FEATURES_CPU_P (cpu_features, AVX512BW) + && CPU_FEATURES_CPU_P (cpu_features, AVX512DQ) + && CPU_FEATURES_CPU_P (cpu_features, AVX512VL)) + GLRO(dl_hwcap) |= HWCAP_X86_AVX512_1; + } + } + + if (platform == NULL + && CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable) + && CPU_FEATURES_ARCH_P (cpu_features, FMA_Usable) + && CPU_FEATURES_CPU_P (cpu_features, BMI1) + && CPU_FEATURES_CPU_P (cpu_features, BMI2) + && CPU_FEATURES_CPU_P (cpu_features, LZCNT) + && CPU_FEATURES_CPU_P (cpu_features, MOVBE) + && CPU_FEATURES_CPU_P (cpu_features, POPCNT)) + platform = "haswell"; + } + + if (platform != NULL) + GLRO(dl_platform) = platform; +#else + GLRO(dl_hwcap) = 0; + if (CPU_FEATURES_CPU_P (cpu_features, SSE2)) + GLRO(dl_hwcap) |= HWCAP_X86_SSE2; + + if (CPU_FEATURES_ARCH_P (cpu_features, I686)) + GLRO(dl_platform) = "i686"; + else if (CPU_FEATURES_ARCH_P (cpu_features, I586)) + GLRO(dl_platform) = "i586"; +#endif +} + static inline void init_cpu_features (struct cpu_features *cpu_features) { @@ -506,52 +558,7 @@ no_cpuid: GLRO(dl_hwcap_mask) = HWCAP_IMPORTANT; #endif -#ifdef __x86_64__ - GLRO(dl_hwcap) = HWCAP_X86_64; - if (cpu_features->basic.kind == arch_kind_intel) - { - const char *platform = NULL; - - if (CPU_FEATURES_ARCH_P (cpu_features, AVX512F_Usable) - && CPU_FEATURES_CPU_P (cpu_features, AVX512CD)) - { - if (CPU_FEATURES_CPU_P (cpu_features, AVX512ER)) - { - if (CPU_FEATURES_CPU_P (cpu_features, AVX512PF)) - platform = "xeon_phi"; - } - else - { - if (CPU_FEATURES_CPU_P (cpu_features, AVX512BW) - && CPU_FEATURES_CPU_P (cpu_features, AVX512DQ) - && CPU_FEATURES_CPU_P (cpu_features, AVX512VL)) - GLRO(dl_hwcap) |= HWCAP_X86_AVX512_1; - } - } - - if (platform == NULL - && CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable) - && CPU_FEATURES_ARCH_P (cpu_features, FMA_Usable) - && CPU_FEATURES_CPU_P (cpu_features, BMI1) - && CPU_FEATURES_CPU_P (cpu_features, BMI2) - && CPU_FEATURES_CPU_P (cpu_features, LZCNT) - && CPU_FEATURES_CPU_P (cpu_features, MOVBE) - && CPU_FEATURES_CPU_P (cpu_features, POPCNT)) - platform = "haswell"; - - if (platform != NULL) - GLRO(dl_platform) = platform; - } -#else - GLRO(dl_hwcap) = 0; - if (CPU_FEATURES_CPU_P (cpu_features, SSE2)) - GLRO(dl_hwcap) |= HWCAP_X86_SSE2; - - if (CPU_FEATURES_ARCH_P (cpu_features, I686)) - GLRO(dl_platform) = "i686"; - else if (CPU_FEATURES_ARCH_P (cpu_features, I586)) - GLRO(dl_platform) = "i586"; -#endif + set_platform(cpu_features); #if CET_ENABLED # if HAVE_TUNABLES -- 2.20.1