[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/07: guix: cpu: Add generalized CPU matching.
From: |
guix-commits |
Subject: |
02/07: guix: cpu: Add generalized CPU matching. |
Date: |
Wed, 12 Jul 2023 09:51:28 -0400 (EDT) |
efraim pushed a commit to branch master
in repository guix.
commit cb0cab2db05cc0264e7ed66f9b6336ed9b0eae64
Author: Efraim Flashner <efraim@flashner.co.il>
AuthorDate: Mon Jun 19 16:42:28 2023 +0300
guix: cpu: Add generalized CPU matching.
* guix/cpu.scm (cpu->micro-architecture-level): New variable.
---
guix/cpu.scm | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/guix/cpu.scm b/guix/cpu.scm
index 45e1abeed7..3fc12327ed 100644
--- a/guix/cpu.scm
+++ b/guix/cpu.scm
@@ -285,3 +285,36 @@ corresponds to CPU, a record as returned by 'current-cpu'."
(architecture
;; TODO: More architectures
architecture)))
+
+(define (cpu->micro-architecture-level cpu)
+ "Return a micro-architecture name, suitable for generalized optimizations
that
+correspond roughly 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)))
- branch master updated (f2f27c4952 -> 691b97aed9), guix-commits, 2023/07/12
- 03/07: guix: cpu: Rewrite fallback for x86_64 cpu->gcc-architecture., guix-commits, 2023/07/12
- 02/07: guix: cpu: Add generalized CPU matching.,
guix-commits <=
- 07/07: transformations: Allow tuning go packages., guix-commits, 2023/07/12
- 05/07: guix: cpu: Add gcc-architecture->micro-architecture-level mapping., guix-commits, 2023/07/12
- 04/07: guix: cpu: Refactor cpu->gcc-architecture., guix-commits, 2023/07/12
- 06/07: gnu: go: Add CPU tuning targets., guix-commits, 2023/07/12
- 01/07: gnu: %gcc-11-x86_64-micro-architectures: Add psabi entries., guix-commits, 2023/07/12