From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id xrfPJPSYA2KitQAAgWs5BA (envelope-from ) for ; Wed, 09 Feb 2022 11:35:32 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id COFPHPSYA2I0cgAAG6o9tA (envelope-from ) for ; Wed, 09 Feb 2022 11:35:32 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CE635473EB for ; Wed, 9 Feb 2022 11:35:31 +0100 (CET) Received: from localhost ([::1]:45230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHkJu-0003lV-GN for larch@yhetil.org; Wed, 09 Feb 2022 05:35:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHk7q-0002D2-Qy for guix-patches@gnu.org; Wed, 09 Feb 2022 05:23:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:56058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHk7p-0001aI-Ug for guix-patches@gnu.org; Wed, 09 Feb 2022 05:23:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHk7p-000810-QF for guix-patches@gnu.org; Wed, 09 Feb 2022 05:23:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53895] [PATCH 1/5] guix: cpu: Rewrite based on feature flags. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Feb 2022 10:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53895 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53895@debbugs.gnu.org Cc: Efraim Flashner Received: via spool by 53895-submit@debbugs.gnu.org id=B53895.164440215630768 (code B ref 53895); Wed, 09 Feb 2022 10:23:01 +0000 Received: (at 53895) by debbugs.gnu.org; 9 Feb 2022 10:22:36 +0000 Received: from localhost ([127.0.0.1]:49955 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk7P-00080B-RA for submit@debbugs.gnu.org; Wed, 09 Feb 2022 05:22:36 -0500 Received: from flashner.co.il ([178.62.234.194]:50034) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk7O-0007zy-4O for 53895@debbugs.gnu.org; Wed, 09 Feb 2022 05:22:34 -0500 Received: from localhost (unknown [37.46.46.251]) by flashner.co.il (Postfix) with ESMTPSA id 394FB403CD; Wed, 9 Feb 2022 10:22:28 +0000 (UTC) From: Efraim Flashner Date: Wed, 9 Feb 2022 12:21:47 +0200 Message-Id: <848868e0ad4427a976bec55968f82a3469009fb9.1644401681.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.34.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1644402932; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=AfRjSu0VMohmEL3sPPDE3K8H9kTLP3HGpdaLW4lVT3M=; b=BEhpS132pIFZHplEvtcEjw0P3mboZfshQJXI8O74cOqMcDWvbCXIe81SzdsKSDtnFeuXip ESMCfNKv00mBXEUGjxXwxBuhXIGvZ9A5vguVYpXbOw97QFpCB/OMBnsUl6nzJJwl16Ac2D jZ73/fNb9RZjAU5xpR0Y3L6bcZeF1TZx9PHsuA9snGXoKMNnSnZky1mKLGLXjw0GxeI35T f86BHO0cZhyJorkBxXcaK7KsVwqKp0wVigfPAbHXEcPtdWPH9cPNbzTnCOihOc0SZn7YWK 86+Vad7jr0E0P6wyMQIUkIFOostr4gpeVwFKgCLks6Tagk1Dyi7kAXCSRNRjkA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644402932; a=rsa-sha256; cv=none; b=r+i/JR4yk3y6IS4h2hsJ8YnqiCKD56Bm9KmrfCYpMs/K4lzbszIlnsEKq+Jb73kV5VEJqD nxRNBhXMH6JLkBJGXd3WVespgjVM16oUnVF7xBsHecCc2D/jl4l8syi84pLTuMnP0gJg8Y YR09KsSRuDpt5l+bx8HOSghug34K6eh+Jym5gYgN49b5xlp+O7SyYcBpYqL1gLaPIkVCOT OJveA2JIIC8f/uoAKXbbMK1xXhl13BtZl1SE+PYYR2tIAcYiopLK/xcIQlAuVukJbtGl5L ggid/xuv36JlCwVL08dAyJ/1kBXfTpbsTbKSnpcvcaPmBM5ReLib1HmCE0GAXg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.63 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: CE635473EB X-Spam-Score: -2.63 X-Migadu-Scanner: scn0.migadu.com X-TUID: jdxxNR7D91fK * 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 +;;; Copyright © 2022 Efraim Flashner ;;; ;;; 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