From patchwork Tue Jun 20 07:48:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 975 Return-Path: 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 ; 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 ) 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 ) 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 ) 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 ) 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 Original-Sender: "Debbugs-submit" 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: 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 , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice 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 ) 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 ) 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 ) 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 ) 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 ; 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 Date: Tue, 20 Jun 2023 10:48:46 +0300 Message-Id: X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 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