Message ID | cover.1687247150.git.efraim@flashner.co.il |
---|---|
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 35DF027BBE9; Tue, 20 Jun 2023 08:49:41 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 70E8D27BBE2 for <patchwork@mira.cbaines.net>; Tue, 20 Jun 2023 08:49:40 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1qBW76-00032A-K1; Tue, 20 Jun 2023 03:49:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1qBW6q-0002uF-MT for guix-patches@gnu.org; Tue, 20 Jun 2023 03:49:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1qBW6q-0005Mv-89; Tue, 20 Jun 2023 03:49:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1qBW6n-0004z0-SW; Tue, 20 Jun 2023 03:49:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64188] [PATCH 0/8] More package tuning Resent-From: Efraim Flashner <efraim@flashner.co.il> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: mail@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 20 Jun 2023 07:49:01 +0000 Resent-Message-ID: <handler.64188.B.168724733619140@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64188 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64188@debbugs.gnu.org Cc: Efraim Flashner <efraim@flashner.co.il>, Christopher Baines <mail@cbaines.net>, Josselin Poiret <dev@jpoiret.xyz>, Ludovic =?utf-8?q?Court=C3=A8s?= <ludo@gnu.org>, Mathieu Othacehe <othacehe@gnu.org>, Ricardo Wurmus <rekado@elephly.net>, Simon Tournier <zimon.toutoune@gmail.com>, Tobias Geerinckx-Rice <me@tobias.gr> X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines <mail@cbaines.net>, Josselin Poiret <dev@jpoiret.xyz>, Ludovic =?utf-8?q?Court=C3=A8s?= <ludo@gnu.org>, Mathieu Othacehe <othacehe@gnu.org>, Ricardo Wurmus <rekado@elephly.net>, Simon Tournier <zimon.toutoune@gmail.com>, Tobias Geerinckx-Rice <me@tobias.gr> Received: via spool by submit@debbugs.gnu.org id=B.168724733619140 (code B ref -1); Tue, 20 Jun 2023 07:49:01 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jun 2023 07:48:56 +0000 Received: from localhost ([127.0.0.1]:57930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1qBW6h-0004yc-RD for submit@debbugs.gnu.org; Tue, 20 Jun 2023 03:48:56 -0400 Received: from lists.gnu.org ([209.51.188.17]:48046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <efraim.flashner@gmail.com>) id 1qBW6f-0004yU-RV for submit@debbugs.gnu.org; Tue, 20 Jun 2023 03:48:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <efraim.flashner@gmail.com>) id 1qBW6e-0002tB-JA for guix-patches@gnu.org; Tue, 20 Jun 2023 03:48:52 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <efraim.flashner@gmail.com>) id 1qBW6c-0005K9-5Q for guix-patches@gnu.org; Tue, 20 Jun 2023 03:48:52 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f90bff0f27so19795635e9.1 for <guix-patches@gnu.org>; Tue, 20 Jun 2023 00:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687247328; x=1689839328; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=f7OldnQhFHSp9HzuB7I0ZCDG3go5IzFGreQmQYZzFnM=; b=oAX/ix9w272ZNb/UzYsrxl36GCm3HxyCclSlzkFg25ikEEb3Fa4MkVXBiJUw3nPo+j 8+QoCXbomFjwp/YcEuzTEkPRXV0v8a9KX5hXRtCZAskiES6fCoL3UWYRxCJ3nZYJe84F AehlRL3AIJzyEfbYygcFXJhcrT+6sBMdMacCvcDsU2O3A61DBOtS57o3TuJdTgBPCi88 rFDIU/i6ezzG6VXSpskSFKg07pyBpnXYnkGaB1vO2/M6VccYtKurlr1UBw+5SON/eSVi U9dFBQTtOn2uYjlhMvj9uWz4Rze7+i8Vr+auMDN1oAsoo8/zXlp9mV/RA2f/9LIc3Hak IxyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247328; x=1689839328; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=f7OldnQhFHSp9HzuB7I0ZCDG3go5IzFGreQmQYZzFnM=; b=g9chzeZjaz/DPDvGrdRZVpFOzqmw9MMlczNpW6RbUk0RgZDa3wkzJNTbhTq0cU203F 5yDYZJ1m4oj9888Ii8MrFKZk/DZzr0rsxRHnku1vkdUHhwr/toXqlaJSbgWzDb1sVUMg /nekRjQRL4CtwwIDr7wh3tqsDt9m6hS/cv8ai/T9DH/9G7igCw/2EYgAvRszrRthUFVU mm+svoZzNyJBF9alBWnDO5Lg6h3IbBm3s6q2GxxlEakty0OrVAHFS8S4i0Av2OyWlNDR LwJpxDGxT65oT145fsD2K4x4FcXF+BrP9ZLt8zUAOGiUeMCBhXPc1gAGzoHITAavBLeP 1z7w== X-Gm-Message-State: AC+VfDw9YhoVGQay4asRV2Qz4FZMN9zE8RNTe5vzJKOFnBRYdDiAAg/W mT+cNze7qEyAeUWDMPTMfx+qAAnzAXUx/A== X-Google-Smtp-Source: ACHHUZ6tQb7GnuqaXT8QAQSptqTXBq0dk1H1wOnlgCFSeZub9qmyIuXJmE4eD2mHhuj7tGGnWLqhSw== X-Received: by 2002:a7b:c449:0:b0:3f4:a09f:1877 with SMTP id l9-20020a7bc449000000b003f4a09f1877mr7590457wmi.23.1687247327945; Tue, 20 Jun 2023 00:48:47 -0700 (PDT) Received: from localhost ([188.120.129.124]) by smtp.gmail.com with ESMTPSA id k4-20020a05600c0b4400b003f727764b10sm1674318wmr.4.2023.06.20.00.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 00:48:47 -0700 (PDT) From: Efraim Flashner <efraim@flashner.co.il> Date: Tue, 20 Jun 2023 10:48:46 +0300 Message-Id: <cover.1687247150.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=efraim.flashner@gmail.com; helo=mail-wm1-x32a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches |
Series |
More package tuning
|
|
Message
Efraim Flashner
June 20, 2023, 7:48 a.m. UTC
with gcc-11, gcc gained support for using -march=x86_64-v{1,2,3,4}, which I'm calling 'generic options,' as opposed to the more targeted tuning we have with specific architectures. Unfortunately there doesn't seem to be a way to map our current architectures to these ones, making it harder to swap between them. The best I've found is that any architecture which can use the Haswell architecture optimizations can also use x86_64-v3. I suppose we could create a mapping so that, as a fallback, anything haswell or higher would use x86_64-v3, anything else would use x86_64-v1. This would help with --tune=native. For the second patch, 'Add inexact cpu matching,' I'm unsure about needing to check for the avx512f flag; I don't have any hardware to test with. Patches 3 and 4 I tested on my machine (with commenting out the AMD branch) and it successfully decided I should use x86_64-v3. go cpu tuning targets: I mostly used the chart¹ on the go website, and I also checked the source code for go-1.18. I put in arm{5,6,7} as arm and not armhf since armhf only works with armv7 and with go programs, since they're statically linked, they can just be copied to other machines. The 6th patch, adjusting the transformations to also do go packages, I tested with syncthing. with '--tune' it failed during the added phase, trying to tune for znver2, with '--tune=x86_64-v3' it worked without problems. Having written this out, I think our best bet would be to use a generalized >=haswell -> x86_64-v3, else x86_64-v1, and not worry about individual micro-architectures and specific chipsets. That would ensure '--tune=native' should just work with go packages. As far as tuning go packages, my understanding is that pretty much every non-trivial go package can benefit from tuning. EDIT: I added two more patches on-top of the initial 6 to implement gcc-architecture->generic-architecture and then use it. For patch 7, the other option I had instead of returning gcc-architecture on no-match would be to return "generic". ¹ https://github.com/golang/go/wiki/MinimumRequirements#microarchitecture-support Efraim Flashner (8): gnu: %gcc-11-x86_64-micro-architectures: Add generic options. guix: cpu: Add inexact CPU matching. guix: cpu: Rewrite fallback for x86_64 cpu->gcc-architecture. guix: cpu: Refactor cpu->gcc-architecture. gnu: go: Add CPU tuning targets. transformations: Allow tuning go packages. guix: cpu: Add gcc-architecture->generic-architecture mapping. transformations: Allow autotuning for go packages. gnu/packages/gcc.scm | 4 +- gnu/packages/golang.scm | 23 ++++++- guix/cpu.scm | 128 ++++++++++++++++++++++----------------- guix/transformations.scm | 43 +++++++++++-- 4 files changed, 135 insertions(+), 63 deletions(-) base-commit: d884fc9e2efecfba09af4694f5a13ad7fc6f704f
Comments
Hello Efraim, Efraim Flashner <efraim@flashner.co.il> skribis: > with gcc-11, gcc gained support for using -march=x86_64-v{1,2,3,4}, > which I'm calling 'generic options,' as opposed to the more targeted > tuning we have with specific architectures. I don’t think these x86_64 psABI “architecture levels” should be treated specially: • From the point of view of ‘--tune’, they’re just another value that may be passed to ‘-march’. • My understanding is that those levels don’t match reality: as discussed in the original ‘--tune’ patch¹, CPUs actually produced don’t follow a pattern of strictly including features of one set. They’re really just a simplification to get more memorizable names, but it’s hard to tell whether a given CPU really covers the set of features of a given level. Overall, my take on this would be to add supported levels to ‘%gcc-11-x86_64-micro-architectures’ & co., without going further. WDYT? ¹ https://issues.guix.gnu.org/52283#0-lineno48 [...] > go cpu tuning targets: I mostly used the chart¹ on the go website, and I > also checked the source code for go-1.18. I put in arm{5,6,7} as arm and > not armhf since armhf only works with armv7 and with go programs, since > they're statically linked, they can just be copied to other machines. Now if Go uses those names, (guix cpu) can provide helpers. Thanks, Ludo’.
On Sun, Jun 25, 2023 at 10:47:42PM +0200, Ludovic Courtès wrote: > Hello Efraim, > > Efraim Flashner <efraim@flashner.co.il> skribis: > > > with gcc-11, gcc gained support for using -march=x86_64-v{1,2,3,4}, > > which I'm calling 'generic options,' as opposed to the more targeted > > tuning we have with specific architectures. > > I don’t think these x86_64 psABI “architecture levels” should be treated > specially: > > • From the point of view of ‘--tune’, they’re just another value that > may be passed to ‘-march’. > > • My understanding is that those levels don’t match reality: as > discussed in the original ‘--tune’ patch¹, CPUs actually produced > don’t follow a pattern of strictly including features of one set. > They’re really just a simplification to get more memorizable names, > but it’s hard to tell whether a given CPU really covers the set of > features of a given level. They're also useful for glibc-hwcaps, so that we could build each package multiple times and install libraries built for the psABI levels into $prefix/lib/glibc-hwcaps/x86-64-v[234]/, but I agree that, for our uses so far, they're not really useful. > Overall, my take on this would be to add supported levels to > ‘%gcc-11-x86_64-micro-architectures’ & co., without going further. > > WDYT? I could see keeping the code from cpu->generic-architecture (renamed cpu->psABI) either as a non-exported function or simply moved into the fallback for x86_64. > ¹ https://issues.guix.gnu.org/52283#0-lineno48 > > [...] > > > go cpu tuning targets: I mostly used the chart¹ on the go website, and I > > also checked the source code for go-1.18. I put in arm{5,6,7} as arm and > > not armhf since armhf only works with armv7 and with go programs, since > > they're statically linked, they can just be copied to other machines. > > Now if Go uses those names, (guix cpu) can provide helpers. Go also uses power8 and power9 as PPC64(le) options, so that's also a possible use-case I was trying to also prepare for. That was my plan for the gcc-architecture->generic-architecture function, to allow for --tune to work without needing to pass different values to different packages.
I hope I've addressed the comments with this patch series. I've changed the language to use psabi or to refer to 'generalized optimizations'. The go adaptations for tuning are now part of build-system-with-tuning-compiler, with an adjustment made to (also) check the psabi listing when it comes to the go compiler. Efraim Flashner (7): gnu: %gcc-11-x86_64-micro-architectures: Add psabi entries. guix: cpu: Add generalized CPU matching. guix: cpu: Rewrite fallback for x86_64 cpu->gcc-architecture. guix: cpu: Refactor cpu->gcc-architecture. guix: cpu: Add gcc-architecture->micro-architecture-level mapping. gnu: go: Add CPU tuning targets. transformations: Allow tuning go packages. gnu/packages/gcc.scm | 5 +- gnu/packages/golang.scm | 23 ++++++- guix/cpu.scm | 130 ++++++++++++++++++++++----------------- guix/transformations.scm | 37 +++++++++-- 4 files changed, 133 insertions(+), 62 deletions(-) base-commit: e85593b36b3874227ba812f47113441928c0f0c1