[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#64188] [PATCH 2/8] guix: cpu: Add inexact CPU matching.
From: |
Efraim Flashner |
Subject: |
[bug#64188] [PATCH 2/8] guix: cpu: Add inexact CPU matching. |
Date: |
Tue, 20 Jun 2023 10:51:03 +0300 |
* guix/cpu.scm (cpu->generic-architecture): New variable.
---
guix/cpu.scm | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/guix/cpu.scm b/guix/cpu.scm
index 45e1abeed7..e6102e3d14 100644
--- a/guix/cpu.scm
+++ b/guix/cpu.scm
@@ -32,7 +32,8 @@ (define-module (guix cpu)
cpu-model
cpu-flags
- cpu->gcc-architecture))
+ cpu->gcc-architecture
+ cpu->generic-architecture))
;;; Commentary:
;;;
@@ -285,3 +286,36 @@ (define (cpu->gcc-architecture cpu)
(architecture
;; TODO: More architectures
architecture)))
+
+(define (cpu->generic-architecture cpu)
+ "Return the architecture name, suitable for inexact architecture
optimizations,
+that corresponds to CPU, a record as returned by 'current-cpu'."
+ (match (cpu-architecture cpu)
+ ("x86_64"
+ (or (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
+ ;;
https://gitlab.com/x86-psABIs/x86-64-ABI/-/blob/master/x86-64-ABI/low-level-sys-info.tex
+ ;; v4: AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL
+ ;; v3: AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, OSXSAVE
+ ;; v2: CMPXCHG16B, LAHF, SAHF, POPCNT, SSE3, SSE4.1, SSE4.2, SSSE3
+ ("avx512f" "avx512bw" "abx512cd" "abx512dq" "avx512vl"
+ "avx" "avx2" "bmi1" "bmi2" "f16c" "fma" "movbe"
+ "popcnt" "sse3" "sse4_1" "sse4_2" "ssse3" => "x86_64-v4")
+ ("avx" "avx2" "bmi1" "bmi2" "f16c" "fma" "movbe"
+ "popcnt" "sse3" "sse4_1" "sse4_2" "ssse3" => "x86_64-v3")
+ ("popcnt" "sse3" "sse4_1" "sse4_2" "ssse3" => "x86_64-v2")
+ (_ => "x86_64-v1")))
+ "x86_64-v1"))
+ (architecture
+ ;; TODO: More architectures
+ architecture)))
--
Efraim Flashner <efraim@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
- [bug#64188] [PATCH 0/8] More package tuning, Efraim Flashner, 2023/06/20
- [bug#64188] [PATCH 1/8] gnu: %gcc-11-x86_64-micro-architectures: Add generic options., Efraim Flashner, 2023/06/20
- [bug#64188] [PATCH 5/8] gnu: go: Add CPU tuning targets., Efraim Flashner, 2023/06/20
- [bug#64188] [PATCH 2/8] guix: cpu: Add inexact CPU matching.,
Efraim Flashner <=
- [bug#64188] [PATCH 3/8] guix: cpu: Rewrite fallback for x86_64 cpu->gcc-architecture., Efraim Flashner, 2023/06/20
- [bug#64188] [PATCH 6/8] transformations: Allow tuning go packages., Efraim Flashner, 2023/06/20
- [bug#64188] [PATCH 7/8] guix: cpu: Add gcc-architecture->generic-architecture mapping., Efraim Flashner, 2023/06/20
- [bug#64188] [PATCH 4/8] guix: cpu: Refactor cpu->gcc-architecture., Efraim Flashner, 2023/06/20
- [bug#64188] [PATCH 8/8] transformations: Allow autotuning for go packages., Efraim Flashner, 2023/06/20
- [bug#64188] [PATCH 0/8] More package tuning, Ludovic Courtès, 2023/06/25