Package: guix-patches;
Reported by: Efraim Flashner <efraim <at> flashner.co.il>
Date: Wed, 9 Feb 2022 10:19:01 UTC
Severity: normal
Tags: patch
Done: Efraim Flashner <efraim <at> flashner.co.il>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 53895 in the body.
You can then email your comments to 53895 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Wed, 09 Feb 2022 10:19:01 GMT) Full text and rfc822 format available.Efraim Flashner <efraim <at> flashner.co.il>
:guix-patches <at> gnu.org
.
(Wed, 09 Feb 2022 10:19:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Efraim Flashner <efraim <at> flashner.co.il> To: guix-patches <at> gnu.org Cc: Efraim Flashner <efraim <at> flashner.co.il> Subject: [PATCH 0/5] More CPU detection Date: Wed, 9 Feb 2022 12:16:51 +0200
I noticed that my AMD CPU was showing up as bonnell, which was clearly wrong. I ended up rewriting parts of the x86_64 section (and considered having it also serve for i686) and then tried to add some bits for aarch64. IMO it's worth having the compiler-cpu-architectures for aarch64/armhf, at least until (guix transformations) is taught that for aarch64/armhf to use -mtune in place of -march. Efraim Flashner (5): guix: cpu: Rewrite based on feature flags. gnu: cpu: Add detection for AMD CPUs. gnu: gcc: Add compiler-cpu-architectures for aarch64. gnu: gcc: Add compiler-cpu-architectures for armhf. WIP: guix: cpu: Add detection for aarch64 CPUs. gnu/packages/gcc.scm | 33 +++++++- guix/cpu.scm | 186 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 186 insertions(+), 33 deletions(-) base-commit: 71438cd4222a02b1f89152437c1ea20499baa6a2 -- 2.34.0
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Wed, 09 Feb 2022 10:23:01 GMT) Full text and rfc822 format available.Message #8 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Efraim Flashner <efraim <at> flashner.co.il> To: 53895 <at> debbugs.gnu.org Cc: Efraim Flashner <efraim <at> flashner.co.il> Subject: [PATCH 1/5] guix: cpu: Rewrite based on feature flags. Date: Wed, 9 Feb 2022 12:21:47 +0200
* guix/cpu.scm (cpu->gcc-architecture): Rewrite detection based on detected feature flags. --- guix/cpu.scm | 56 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/guix/cpu.scm b/guix/cpu.scm index e1911f52a8..5bb3fa9d2f 100644 --- a/guix/cpu.scm +++ b/guix/cpu.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Ludovic Courtès <ludo <at> gnu.org> +;;; Copyright © 2022 Efraim Flashner <efraim <at> flashner.co.il> ;;; ;;; This file is part of GNU Guix. ;;; @@ -87,28 +88,39 @@ (define (cpu->gcc-architecture cpu) ("x86_64" ;; Transcribed from GCC's 'host_detect_local_cpu' in driver-i386.c. (or (and (= 6 (cpu-family cpu)) ;the "Pentium Pro" family - (letrec-syntax ((model (syntax-rules (=>) - ((_) #f) - ((_ (candidate => integers ...) rest - ...) - (or (and (= (cpu-model cpu) integers) - candidate) - ... - (model rest ...)))))) - (model ("bonnel" => #x1c #x26) - ("silvermont" => #x37 #x4a #x4d #x5a #x5d) - ("core2" => #x0f #x17 #x1d) - ("nehalem" => #x1a #x1e #x1f #x2e) - ("westmere" => #x25 #x2c #x2f) - ("sandybridge" => #x2a #x2d) - ("ivybridge" => #x3a #x3e) - ("haswell" => #x3c #x3f #x45 #x46) - ("broadwell" => #x3d #x47 #x4f #x56) - ("skylake" => #x4e #x5e #x8e #x9e) - ("skylake-avx512" => #x55) ;TODO: cascadelake - ("knl" => #x57) - ("cannonlake" => #x66) - ("knm" => #x85)))) + (letrec-syntax ((if-flags (syntax-rules (=>) + ((_) + #f) + ((_ (flags ... => name) rest ...) + (if (every (lambda (flag) + (set-contains? (cpu-flags cpu) + flag)) + '(flags ...)) + name + (if-flags rest ...)))))) + + (if-flags ("avx" "avx512vp2intersect" "tsxldtrk" => "sapphirerapids") + ("avx" "avx512vp2intersect" => "tigerlake") + ("avx" "avx512bf16" => "cooperlake") + ("avx" "wbnoinvd" => "icelake-server") + ("avx" "avx512bitalg" => "icelake-client") + ("avx" "avx512vbmi" => "cannonlake") + ("avx" "avx5124vnniw" => "knm") + ("avx" "avx512er" => "knl") + ("avx" "avx512f" => "skylake-avx512") + ("avx" "serialize" => "alderlake") + ("avx" "clflushopt" => "skylake") + ("avx" "adx" => "broadwell") + ("avx" "avx2" => "haswell") + ("avx" => "sandybridge") + ("sse4_2" "gfni" => "tremont") + ("sse4_2" "sgx" => "goldmont-plus") + ("sse4_2" "xsave" => "goldmont") + ("sse4_2" "movbe" => "silvermont") + ("sse4_2" => "nehalem") + ("ssse3" "movbe" => "bonnell") + ("ssse3" => "core2") + ("longmode" => "x86-64")))) ;; Fallback case for non-Intel processors or for Intel processors not ;; recognized above. -- 2.34.0
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Wed, 09 Feb 2022 10:24:02 GMT) Full text and rfc822 format available.Message #11 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Efraim Flashner <efraim <at> flashner.co.il> To: 53895 <at> debbugs.gnu.org Cc: Efraim Flashner <efraim <at> flashner.co.il> Subject: [PATCH 2/5] gnu: cpu: Add detection for AMD CPUs. Date: Wed, 9 Feb 2022 12:21:48 +0200
* guix/cpu.scm <cpu>: Add vendor field. (current-cpu): Also fill in the 'vendor' field. (cpu->gcc-architecture): Add detection logic for AMD CPUs. --- guix/cpu.scm | 60 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/guix/cpu.scm b/guix/cpu.scm index 5bb3fa9d2f..6d44599822 100644 --- a/guix/cpu.scm +++ b/guix/cpu.scm @@ -27,6 +27,7 @@ (define-module (guix cpu) #:export (current-cpu cpu? cpu-architecture + cpu-vendor cpu-family cpu-model cpu-flags @@ -42,9 +43,10 @@ (define-module (guix cpu) ;; CPU description. (define-record-type <cpu> - (cpu architecture family model flags) + (cpu architecture vendor family model flags) cpu? (architecture cpu-architecture) ;string, from 'uname' + (vendor cpu-vendor) ;string (family cpu-family) ;integer (model cpu-model) ;integer (flags cpu-flags)) ;set of strings @@ -58,28 +60,33 @@ (define (prefix? prefix) (call-with-input-file "/proc/cpuinfo" (lambda (port) - (let loop ((family #f) + (let loop ((vendor #f) + (family #f) (model #f)) (match (read-line port) ((? eof-object?) #f) + ((? (prefix? "vendor_id") str) + (match (string-tokenize str) + (("vendor_id" ":" vendor) + (loop vendor family model)))) ((? (prefix? "cpu family") str) (match (string-tokenize str) (("cpu" "family" ":" family) - (loop (string->number family) model)))) + (loop vendor (string->number family) model)))) ((? (prefix? "model") str) (match (string-tokenize str) (("model" ":" model) - (loop family (string->number model))) + (loop vendor family (string->number model))) (_ - (loop family model)))) + (loop vendor family model)))) ((? (prefix? "flags") str) (match (string-tokenize str) (("flags" ":" flags ...) (cpu (utsname:machine (uname)) - family model (list->set flags))))) + vendor family model (list->set flags))))) (_ - (loop family model)))))))) + (loop vendor family model)))))))) (define (cpu->gcc-architecture cpu) "Return the architecture name, suitable for GCC's '-march' flag, that @@ -87,7 +94,8 @@ (define (cpu->gcc-architecture cpu) (match (cpu-architecture cpu) ("x86_64" ;; Transcribed from GCC's 'host_detect_local_cpu' in driver-i386.c. - (or (and (= 6 (cpu-family cpu)) ;the "Pentium Pro" family + (or (and (equal? "GenuineIntel" (cpu-vendor cpu)) + (= 6 (cpu-family cpu)) ;the "Pentium Pro" family (letrec-syntax ((if-flags (syntax-rules (=>) ((_) #f) @@ -122,6 +130,40 @@ (define (cpu->gcc-architecture cpu) ("ssse3" => "core2") ("longmode" => "x86-64")))) + (and (equal? "AuthenticAMD" (cpu-vendor cpu)) + (letrec-syntax ((if-flags (syntax-rules (=>) + ((_) + #f) + ((_ (flags ... => name) rest ...) + (if (every (lambda (flag) + (set-contains? (cpu-flags cpu) + flag)) + '(flags ...)) + name + (if-flags rest ...)))))) + + (when (= 22 (cpu-family cpu)) + (if-flags ("movbe" => "btver2"))) + (when (= 6 (cpu-family cpu)) + (if-flags ("3dnowp" => "athalon"))) + + (if-flags ("vaes" => "znver3") + ("clwb" => "znver2") + ("clzero" => "znver1") + ("avx2" => "bdver4") + ("xsaveopt" => "bdver3") + ("bmi" => "bdver2") + ("xop" => "bdver1") + ("sse4a" "has_ssse3" => "btver1") + ("sse4a" => "amdfam10") + ("sse2" "sse3" => "k8-sse3") + ("longmode" "sse3" => "k8-sse3") + ("sse2" => "k8") + ("longmode" => "k8") + ("mmx" "3dnow" => "k6-3") + ("mmx" => "k6") + (_ => "pentium")))) + ;; Fallback case for non-Intel processors or for Intel processors not ;; recognized above. (letrec-syntax ((if-flags (syntax-rules (=>) @@ -147,7 +189,7 @@ (define (cpu->gcc-architecture cpu) ("ssse3" "movbe" => "bonnell") ("ssse3" => "core2"))) - ;; TODO: Recognize AMD models (bdver*, znver*, etc.)? + ;; TODO: Recognize CENTAUR/CYRIX/NSC? "x86_64")) (architecture -- 2.34.0
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Wed, 09 Feb 2022 10:24:02 GMT) Full text and rfc822 format available.Message #14 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Efraim Flashner <efraim <at> flashner.co.il> To: 53895 <at> debbugs.gnu.org Cc: Efraim Flashner <efraim <at> flashner.co.il> Subject: [PATCH 3/5] gnu: gcc: Add compiler-cpu-architectures for aarch64. Date: Wed, 9 Feb 2022 12:21:49 +0200
* gnu/packages/gcc.scm (%gcc-7.5-aarch64-micro-architectures, %gcc-10-aarch64-micro-architectures): New variables. (gcc-7, gcc-10)[properties]: Add aarch64 compiler-cpu-architectures. --- gnu/packages/gcc.scm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index efa0baeaa1..726c0eed89 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -3,7 +3,7 @@ ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw <at> netris.org> ;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2021 Ricardo Wurmus <rekado <at> elephly.net> ;;; Copyright © 2015 Andreas Enge <andreas <at> enge.fr> -;;; Copyright © 2015, 2016, 2017, 2018, 2020, 2021 Efraim Flashner <efraim <at> flashner.co.il> +;;; Copyright © 2015, 2016, 2017, 2018, 2020, 2021, 2022 Efraim Flashner <efraim <at> flashner.co.il> ;;; Copyright © 2016 Carlos Sánchez de La Lama <csanchezdll <at> gmail.com> ;;; Copyright © 2018 Tobias Geerinckx-Rice <me <at> tobias.gr> ;;; Copyright © 2018, 2020 Marius Bakke <mbakke <at> fastmail.com> @@ -525,6 +525,11 @@ (define-public gcc-6 ,@(package-inputs gcc-4.7))))) +(define %gcc-7.5-aarch64-micro-architectures + ;; Suitable '-march' values for GCC 7.5. + ;; TODO: Allow dynamically adding feature flags. + '("armv8-a" "armv8.1-a" "armv8.2-a" "armv8.3-a")) + (define %gcc-7.5-x86_64-micro-architectures ;; Suitable '-march' values for GCC 7.5 (info "(gcc) x86 Options"). '("core2" "nehalem" "westmere" "sandybridge" "ivybridge" @@ -536,6 +541,12 @@ (define %gcc-7.5-x86_64-micro-architectures "znver1" "btver1" "btver2" "geode")) +(define %gcc-10-aarch64-micro-architectures + ;; Suitable '-march' values for GCC 10. + ;; TODO: Allow dynamically adding feature flags. + (append %gcc-7.5-aarch64-micro-architectures + '("armv8.4-a" "armv8.5-a" "armv8.6-a"))) + (define %gcc-10-x86_64-micro-architectures ;; Suitable '-march' values for GCC 10. (append %gcc-7.5-x86_64-micro-architectures @@ -545,7 +556,6 @@ (define %gcc-10-x86_64-micro-architectures "znver2" "znver3"))) - (define-public gcc-7 (package (inherit gcc-6) @@ -566,6 +576,7 @@ (define-public gcc-7 It also includes runtime support libraries for these languages.") (properties `((compiler-cpu-architectures + ("aarch64" ,@%gcc-7.5-aarch64-micro-architectures) ("x86_64" ,@%gcc-7.5-x86_64-micro-architectures)))))) (define-public gcc-8 @@ -619,6 +630,7 @@ (define-public gcc-10 (snippet gcc-canadian-cross-objdump-snippet))) (properties `((compiler-cpu-architectures + ("aarch64" ,@%gcc-10-aarch64-micro-architectures) ("x86_64" ,@%gcc-10-x86_64-micro-architectures)))))) (define-public gcc-11 -- 2.34.0
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Wed, 09 Feb 2022 10:25:02 GMT) Full text and rfc822 format available.Message #17 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Efraim Flashner <efraim <at> flashner.co.il> To: 53895 <at> debbugs.gnu.org Cc: Efraim Flashner <efraim <at> flashner.co.il> Subject: [PATCH 4/5] gnu: gcc: Add compiler-cpu-architectures for armhf. Date: Wed, 9 Feb 2022 12:21:50 +0200
* gnu/packages/gcc.scm (%gcc-7.5-armhf-micro-architectures, %gcc-10-armhf-micro-architectures): New variables. (gcc-7, gcc-10)[properties]: Add armhf compiler-cpu-architectures. --- gnu/packages/gcc.scm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index 726c0eed89..e0a431a0ff 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -530,6 +530,14 @@ (define %gcc-7.5-aarch64-micro-architectures ;; TODO: Allow dynamically adding feature flags. '("armv8-a" "armv8.1-a" "armv8.2-a" "armv8.3-a")) +(define %gcc-7.5-armhf-micro-architectures + ;; Suitable '-march' values for GCC 7.5. + ;; TODO: Allow dynamically adding feature flags. + '("armv7" "armv7-a" "armv7-m" "armv7-r" "armv7e-m" "armv7ve" + "armv8-a" "armv8-a+crc" "armv8.1-a" "armv8.1-a+crc" + "armv8-m.base" "armv8-m.main" "armv8-m.main+dsp" + "iwmmxt" "iwmmxt2")) + (define %gcc-7.5-x86_64-micro-architectures ;; Suitable '-march' values for GCC 7.5 (info "(gcc) x86 Options"). '("core2" "nehalem" "westmere" "sandybridge" "ivybridge" @@ -547,6 +555,13 @@ (define %gcc-10-aarch64-micro-architectures (append %gcc-7.5-aarch64-micro-architectures '("armv8.4-a" "armv8.5-a" "armv8.6-a"))) +(define %gcc-10-armhf-micro-architectures + ;; Suitable '-march' values for GCC 10. + ;; TODO: Allow dynamically adding feature flags. + (append %gcc-7.5-armhf-micro-architectures + '("armv8.2-a" "armv8.3-a" "armv8.4-a" "armv8.5-a" "armv8.6-a" + "armv8-r" "armv8.1-m.main"))) + (define %gcc-10-x86_64-micro-architectures ;; Suitable '-march' values for GCC 10. (append %gcc-7.5-x86_64-micro-architectures @@ -577,6 +592,7 @@ (define-public gcc-7 (properties `((compiler-cpu-architectures ("aarch64" ,@%gcc-7.5-aarch64-micro-architectures) + ("armhf" ,@%gcc-7.5-armhf-micro-architectures) ("x86_64" ,@%gcc-7.5-x86_64-micro-architectures)))))) (define-public gcc-8 @@ -631,6 +647,7 @@ (define-public gcc-10 (properties `((compiler-cpu-architectures ("aarch64" ,@%gcc-10-aarch64-micro-architectures) + ("armhf" ,@%gcc-10-armhf-micro-architectures) ("x86_64" ,@%gcc-10-x86_64-micro-architectures)))))) (define-public gcc-11 -- 2.34.0
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Wed, 09 Feb 2022 10:25:02 GMT) Full text and rfc822 format available.Message #20 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Efraim Flashner <efraim <at> flashner.co.il> To: 53895 <at> debbugs.gnu.org Cc: Efraim Flashner <efraim <at> flashner.co.il> Subject: [PATCH 5/5] WIP: guix: cpu: Add detection for aarch64 CPUs. Date: Wed, 9 Feb 2022 12:21:51 +0200
* guix/cpu.scm (current-cpu): Extend existing implementation to also read cpuinfo from aarch64 machines. (cpu->gcc-architecture): Add case for aarch64. --- guix/cpu.scm | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/guix/cpu.scm b/guix/cpu.scm index 6d44599822..d4dbd5f6b8 100644 --- a/guix/cpu.scm +++ b/guix/cpu.scm @@ -66,25 +66,47 @@ (define (prefix? prefix) (match (read-line port) ((? eof-object?) #f) + ;; vendor for x86_64 and i686 ((? (prefix? "vendor_id") str) (match (string-tokenize str) (("vendor_id" ":" vendor) (loop vendor family model)))) + ;; vendor for aarch64 and armhf + ((? (prefix? "CPU implementer") str) + (match (string-tokenize str) + (("CPU" "implementer" ":" vendor) + (loop vendor family model)))) + ;; family for x86_64 and i686 ((? (prefix? "cpu family") str) (match (string-tokenize str) (("cpu" "family" ":" family) (loop vendor (string->number family) model)))) + ;; model for x86_64 and i686 ((? (prefix? "model") str) (match (string-tokenize str) (("model" ":" model) (loop vendor family (string->number model))) (_ (loop vendor family model)))) + ;; model for aarch64 and armhf + ((? (prefix? "CPU part") str) + (match (string-tokenize str) + (("CPU" "part" ":" model) + (loop vendor family (string->number (string-append "#x" (string-drop model 2))))) + (_ + (loop vendor family model)))) + ;; flags for x86_64 and i686 ((? (prefix? "flags") str) (match (string-tokenize str) (("flags" ":" flags ...) (cpu (utsname:machine (uname)) vendor family model (list->set flags))))) + ;; flags for aarch64 and armhf + ((? (prefix? "Features") str) + (match (string-tokenize str) + (("Features" ":" flags ...) + (cpu (utsname:machine (uname)) + vendor family model (list->set flags))))) (_ (loop vendor family model)))))))) @@ -192,6 +214,54 @@ (define (cpu->gcc-architecture cpu) ;; TODO: Recognize CENTAUR/CYRIX/NSC? "x86_64")) + ("aarch64" + (pk (cpu-architecture cpu)(cpu-vendor cpu)(cpu-family cpu) (cpu-model cpu)(cpu-flags cpu)) + ;; Currently returns ("aarch64" #f #f #f #<<set> vhash: #<vhash 329666c0 9 pairs> insert: #<procedure %insert (t-5ce36f5c768e728-317 t-5ce36f5c768e728-319)> ref: #<procedure vhash-assoc (key vhash #:optional equal? hash)>>) + ;; Transcribed from GCC's list of aarch64 processors in aarch64-cores.def + (match (cpu-vendor cpu) + ("0x41" + (match (cpu-model cpu) + ((or #xd02 #xd04 #xd03 #xd07 #xd08 #xd09) + "armv8-a") + ((or #xd05 #xd0a #xd0b #xd0e #xd0d #xd41 #xd42 #xd4b #xd46 #xd43 #xd44 #xd41 #xd0c #xd4a) + "armv8.2-a") + (#xd40 + "armv8.4-a") + (#xd15 + "armv8-r") + ((or #xd46 #xd47 #xd48) + "armv9-a"))) + ("0x42" + "armv8.1-a") + ("0x43" + (match (cpu-model cpu) + ((or #x0a0 #x0a1 #x0a2 #x0a3) + "armv8-a") + ((or #x0b0 #x0b1 #x0b2 #x0b3 #x0b4 #x0b5) + "armv8.2-a") + (#x0b8 + "armv8.3-a"))) + ("0x46" + "armv8.2-a") + ("0x48" + "armv8.2-a") + ("0x50" + "armv8-a") + ("0x51" + (match (cpu-model cpu) + (#xC00 + "armv8-a") + (#x516 + "armv8.1-a") + (#xC01 + "armv8.4-a"))) + ("0x53" + "armv8-a") + ("0x68" + "armv8-a") + (_ + "armv8-a")) + "armv8-a") (architecture ;; TODO: AArch64. architecture))) -- 2.34.0
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Wed, 09 Feb 2022 10:36:02 GMT) Full text and rfc822 format available.Message #23 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Ludovic Courtès <ludo <at> gnu.org> To: Efraim Flashner <efraim <at> flashner.co.il> Cc: 53895 <at> debbugs.gnu.org Subject: Re: bug#53895: [PATCH 0/5] More CPU detection Date: Wed, 09 Feb 2022 11:35:22 +0100
Hi! Efraim Flashner <efraim <at> flashner.co.il> skribis: > * guix/cpu.scm (cpu->gcc-architecture): Rewrite detection based on > detected feature flags. [...] > ;; Transcribed from GCC's 'host_detect_local_cpu' in driver-i386.c. > (or (and (= 6 (cpu-family cpu)) ;the "Pentium Pro" family > - (letrec-syntax ((model (syntax-rules (=>) > - ((_) #f) > - ((_ (candidate => integers ...) rest > - ...) > - (or (and (= (cpu-model cpu) integers) > - candidate) > - ... > - (model rest ...)))))) > - (model ("bonnel" => #x1c #x26) > - ("silvermont" => #x37 #x4a #x4d #x5a #x5d) > - ("core2" => #x0f #x17 #x1d) > - ("nehalem" => #x1a #x1e #x1f #x2e) > - ("westmere" => #x25 #x2c #x2f) > - ("sandybridge" => #x2a #x2d) > - ("ivybridge" => #x3a #x3e) > - ("haswell" => #x3c #x3f #x45 #x46) > - ("broadwell" => #x3d #x47 #x4f #x56) > - ("skylake" => #x4e #x5e #x8e #x9e) > - ("skylake-avx512" => #x55) ;TODO: cascadelake > - ("knl" => #x57) > - ("cannonlake" => #x66) > - ("knm" => #x85)))) > + (letrec-syntax ((if-flags (syntax-rules (=>) > + ((_) > + #f) > + ((_ (flags ... => name) rest ...) > + (if (every (lambda (flag) > + (set-contains? (cpu-flags cpu) > + flag)) > + '(flags ...)) > + name > + (if-flags rest ...)))))) > + > + (if-flags ("avx" "avx512vp2intersect" "tsxldtrk" => "sapphirerapids") > + ("avx" "avx512vp2intersect" => "tigerlake") > + ("avx" "avx512bf16" => "cooperlake") > + ("avx" "wbnoinvd" => "icelake-server") > + ("avx" "avx512bitalg" => "icelake-client") > + ("avx" "avx512vbmi" => "cannonlake") In current master, the logic is: if it’s an intel then pick the model ID if that didn’t work then do feature-based detection Here you’re removing the first part (using the Intel model ID) and extending the second part. Perhaps we could extend the second part but still keep the first one? The AMD detection code would have to go before the generic fallback case though. WDYT? Ludo’.
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Wed, 09 Feb 2022 10:44:02 GMT) Full text and rfc822 format available.Message #26 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Ludovic Courtès <ludo <at> gnu.org> To: Efraim Flashner <efraim <at> flashner.co.il> Cc: 53895 <at> debbugs.gnu.org Subject: Re: bug#53895: [PATCH 0/5] More CPU detection Date: Wed, 09 Feb 2022 11:43:21 +0100
Efraim Flashner <efraim <at> flashner.co.il> skribis: > * guix/cpu.scm <cpu>: Add vendor field. > (current-cpu): Also fill in the 'vendor' field. > (cpu->gcc-architecture): Add detection logic for AMD CPUs. [...] > + (and (equal? "AuthenticAMD" (cpu-vendor cpu)) Isn’t that equivalent to (= (cpu-family cpu) some-value)? > + (letrec-syntax ((if-flags (syntax-rules (=>) > + ((_) > + #f) > + ((_ (flags ... => name) rest ...) > + (if (every (lambda (flag) > + (set-contains? (cpu-flags cpu) > + flag)) > + '(flags ...)) > + name > + (if-flags rest ...)))))) > + > + (when (= 22 (cpu-family cpu)) > + (if-flags ("movbe" => "btver2"))) > + (when (= 6 (cpu-family cpu)) > + (if-flags ("3dnowp" => "athalon"))) This has no effect (because ‘if-flags’ returns a value that is ignored since it’s not returned.) What we could do is extend ‘if-flags’ so that it can optionally check for a family number: (if-flags ((family 22) "movbe" => "btver2") …) > + (if-flags ("vaes" => "znver3") > + ("clwb" => "znver2") > + ("clzero" => "znver1") However, the code in driver-i386.c seems to look at model IDs (the big “switch (processor)” thing) and not feature flags. Or am I overlooking something? Thanks, Ludo’.
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Wed, 09 Feb 2022 10:47:01 GMT) Full text and rfc822 format available.Message #29 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Efraim Flashner <efraim <at> flashner.co.il> To: Ludovic Courtès <ludo <at> gnu.org> Cc: 53895 <at> debbugs.gnu.org Subject: Re: bug#53895: [PATCH 0/5] More CPU detection Date: Wed, 9 Feb 2022 12:45:35 +0200
[Message part 1 (text/plain, inline)]
On Wed, Feb 09, 2022 at 11:35:22AM +0100, Ludovic Courtès wrote: > Hi! > > Efraim Flashner <efraim <at> flashner.co.il> skribis: > > > * guix/cpu.scm (cpu->gcc-architecture): Rewrite detection based on > > detected feature flags. > > [...] > > > ;; Transcribed from GCC's 'host_detect_local_cpu' in driver-i386.c. > > (or (and (= 6 (cpu-family cpu)) ;the "Pentium Pro" family > > - (letrec-syntax ((model (syntax-rules (=>) > > - ((_) #f) > > - ((_ (candidate => integers ...) rest > > - ...) > > - (or (and (= (cpu-model cpu) integers) > > - candidate) > > - ... > > - (model rest ...)))))) > > - (model ("bonnel" => #x1c #x26) > > - ("silvermont" => #x37 #x4a #x4d #x5a #x5d) > > - ("core2" => #x0f #x17 #x1d) > > - ("nehalem" => #x1a #x1e #x1f #x2e) > > - ("westmere" => #x25 #x2c #x2f) > > - ("sandybridge" => #x2a #x2d) > > - ("ivybridge" => #x3a #x3e) > > - ("haswell" => #x3c #x3f #x45 #x46) > > - ("broadwell" => #x3d #x47 #x4f #x56) > > - ("skylake" => #x4e #x5e #x8e #x9e) > > - ("skylake-avx512" => #x55) ;TODO: cascadelake > > - ("knl" => #x57) > > - ("cannonlake" => #x66) > > - ("knm" => #x85)))) > > + (letrec-syntax ((if-flags (syntax-rules (=>) > > + ((_) > > + #f) > > + ((_ (flags ... => name) rest ...) > > + (if (every (lambda (flag) > > + (set-contains? (cpu-flags cpu) > > + flag)) > > + '(flags ...)) > > + name > > + (if-flags rest ...)))))) > > + > > + (if-flags ("avx" "avx512vp2intersect" "tsxldtrk" => "sapphirerapids") > > + ("avx" "avx512vp2intersect" => "tigerlake") > > + ("avx" "avx512bf16" => "cooperlake") > > + ("avx" "wbnoinvd" => "icelake-server") > > + ("avx" "avx512bitalg" => "icelake-client") > > + ("avx" "avx512vbmi" => "cannonlake") > > In current master, the logic is: > > if it’s an intel > then pick the model ID > if that didn’t work > then do feature-based detection > > Here you’re removing the first part (using the Intel model ID) and > extending the second part. Perhaps we could extend the second part but > still keep the first one? > > The AMD detection code would have to go before the generic fallback case > though. > > WDYT? > > Ludo’. in gcc-11 driver-i386.c is modified to use the 'vendor' to choose the 'processor', and then using the processor flag it runs through a list of if statements to check feature flags, so that's what I was following. -- Efraim Flashner <efraim <at> flashner.co.il> רנשלפ םירפא GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Wed, 09 Feb 2022 10:55:02 GMT) Full text and rfc822 format available.Message #32 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Efraim Flashner <efraim <at> flashner.co.il> To: Ludovic Courtès <ludo <at> gnu.org> Cc: 53895 <at> debbugs.gnu.org Subject: Re: bug#53895: [PATCH 0/5] More CPU detection Date: Wed, 9 Feb 2022 12:54:14 +0200
[Message part 1 (text/plain, inline)]
On Wed, Feb 09, 2022 at 11:43:21AM +0100, Ludovic Courtès wrote: > Efraim Flashner <efraim <at> flashner.co.il> skribis: > > > * guix/cpu.scm <cpu>: Add vendor field. > > (current-cpu): Also fill in the 'vendor' field. > > (cpu->gcc-architecture): Add detection logic for AMD CPUs. > > [...] > > > + (and (equal? "AuthenticAMD" (cpu-vendor cpu)) > > Isn’t that equivalent to (= (cpu-family cpu) some-value)? It looks to me like 'family' started as the prefix for iX86, so Intel is mostly using family 6, except when a couple of other processors slip in. I wasn't able to find a hard and fast rule for what family AMD typically uses, on my machine its 23. In driver-i386.c it's sort by vendor first: if (vendor == VENDOR_AMD) > > + (letrec-syntax ((if-flags (syntax-rules (=>) > > + ((_) > > + #f) > > + ((_ (flags ... => name) rest ...) > > + (if (every (lambda (flag) > > + (set-contains? (cpu-flags cpu) > > + flag)) > > + '(flags ...)) > > + name > > + (if-flags rest ...)))))) > > + > > + (when (= 22 (cpu-family cpu)) > > + (if-flags ("movbe" => "btver2"))) > > + (when (= 6 (cpu-family cpu)) > > + (if-flags ("3dnowp" => "athalon"))) > > This has no effect (because ‘if-flags’ returns a value that is ignored > since it’s not returned.) > > What we could do is extend ‘if-flags’ so that it can optionally check > for a family number: > > (if-flags ((family 22) "movbe" => "btver2") > …) That sounds like a good idea. > > + (if-flags ("vaes" => "znver3") > > + ("clwb" => "znver2") > > + ("clzero" => "znver1") > > However, the code in driver-i386.c seems to look at model IDs (the big > “switch (processor)” thing) and not feature flags. Or am I overlooking > something? switch (processor) comes after all the AMD chips are sorted. It looks like all of Intel's i686 and x86_64 are PROCESSOR_PENTIUMPRO, while AMD has a separate processor per chip design. The AMD chips are sorted about 90 lines above the switch (processor) line > Thanks, > Ludo’. -- Efraim Flashner <efraim <at> flashner.co.il> רנשלפ םירפא GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Wed, 09 Feb 2022 11:43:01 GMT) Full text and rfc822 format available.Message #35 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Efraim Flashner <efraim <at> flashner.co.il> To: Ludovic Courtès <ludo <at> gnu.org> Cc: 53895 <at> debbugs.gnu.org Subject: Re: bug#53895: [PATCH 0/5] More CPU detection Date: Wed, 9 Feb 2022 13:41:40 +0200
[Message part 1 (text/plain, inline)]
On Wed, Feb 09, 2022 at 11:43:21AM +0100, Ludovic Courtès wrote: > Efraim Flashner <efraim <at> flashner.co.il> skribis: > > > + (letrec-syntax ((if-flags (syntax-rules (=>) > > + ((_) > > + #f) > > + ((_ (flags ... => name) rest ...) > > + (if (every (lambda (flag) > > + (set-contains? (cpu-flags cpu) > > + flag)) > > + '(flags ...)) > > + name > > + (if-flags rest ...)))))) > > + > > + (when (= 22 (cpu-family cpu)) > > + (if-flags ("movbe" => "btver2"))) > > + (when (= 6 (cpu-family cpu)) > > + (if-flags ("3dnowp" => "athalon"))) > > This has no effect (because ‘if-flags’ returns a value that is ignored > since it’s not returned.) > > What we could do is extend ‘if-flags’ so that it can optionally check > for a family number: > > (if-flags ((family 22) "movbe" => "btver2") > …) Another option would be to just move it to the bottom of the if-flags so it should take effect then. -- Efraim Flashner <efraim <at> flashner.co.il> רנשלפ םירפא GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Thu, 10 Feb 2022 20:43:02 GMT) Full text and rfc822 format available.Message #38 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Ludovic Courtès <ludo <at> gnu.org> To: Efraim Flashner <efraim <at> flashner.co.il> Cc: 53895 <at> debbugs.gnu.org Subject: Re: bug#53895: [PATCH 0/5] More CPU detection Date: Thu, 10 Feb 2022 21:42:07 +0100
Hi, Efraim Flashner <efraim <at> flashner.co.il> skribis: > in gcc-11 driver-i386.c is modified to use the 'vendor' to choose the > 'processor', and then using the processor flag it runs through a list of > if statements to check feature flags, so that's what I was following. Oh OK, so maybe it’s all fine after all. Sorry for the confusion! Ludo’.
guix-patches <at> gnu.org
:bug#53895
; Package guix-patches
.
(Thu, 10 Feb 2022 20:43:02 GMT) Full text and rfc822 format available.Message #41 received at 53895 <at> debbugs.gnu.org (full text, mbox):
From: Ludovic Courtès <ludo <at> gnu.org> To: Efraim Flashner <efraim <at> flashner.co.il> Cc: 53895 <at> debbugs.gnu.org Subject: Re: bug#53895: [PATCH 0/5] More CPU detection Date: Thu, 10 Feb 2022 21:42:44 +0100
Efraim Flashner <efraim <at> flashner.co.il> skribis: >> What we could do is extend ‘if-flags’ so that it can optionally check >> for a family number: >> >> (if-flags ((family 22) "movbe" => "btver2") >> …) > > Another option would be to just move it to the bottom of the if-flags so > it should take effect then. Yes, your call! Ludo’.
Efraim Flashner <efraim <at> flashner.co.il>
:Efraim Flashner <efraim <at> flashner.co.il>
:Message #46 received at 53895-done <at> debbugs.gnu.org (full text, mbox):
From: Efraim Flashner <efraim <at> flashner.co.il> To: Ludovic Courtès <ludo <at> gnu.org> Cc: 53895-done <at> debbugs.gnu.org Subject: Re: bug#53895: [PATCH 0/5] More CPU detection Date: Sun, 13 Feb 2022 15:04:26 +0200
[Message part 1 (text/plain, inline)]
On Thu, Feb 10, 2022 at 09:42:44PM +0100, Ludovic Courtès wrote: > Efraim Flashner <efraim <at> flashner.co.il> skribis: > > >> What we could do is extend ‘if-flags’ so that it can optionally check > >> for a family number: > >> > >> (if-flags ((family 22) "movbe" => "btver2") > >> …) > > > > Another option would be to just move it to the bottom of the if-flags so > > it should take effect then. > > Yes, your call! Just moving it to the end didn't end up being enough to make it work, my processor was determined to be <unspecified>. I changed it to an 'or' which seemed to make it work, and my testing seemed to show that it would work (alternating substituting junk and my processor flags to make it obviously one or the other). Thanks for the review and the feedback. And for doing the work in the first place! -- Efraim Flashner <efraim <at> flashner.co.il> אפרים פלשנר GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]
Debbugs Internal Request <help-debbugs <at> gnu.org>
to internal_control <at> debbugs.gnu.org
.
(Mon, 14 Mar 2022 11:24:12 GMT) Full text and rfc822 format available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.