From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by sourceware.org (Postfix) with ESMTPS id A68133853835 for ; Thu, 6 Oct 2022 02:46:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A68133853835 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-qk1-x72c.google.com with SMTP id i3so294991qkl.3 for ; Wed, 05 Oct 2022 19:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=6CfBURkjyLlHy1Dab5geVGmsGERfMosDQ7oIts7Indw=; b=iEbuC7zXTxTsJp5pVoZQnO4i82vB5JCa9YXhXnJlHLfLXFddqyTfwpsXbgeJQoR6Jp 3V8CdbBN2t1OUx0OhB2Mrjx0x5lVdGwVnmIhP6+1KA7F/HDtsQg1B0ckYWFpEE/4qmS/ iFhp+Lmyu9g+xR+cB+ME56KUzTYepkWtw1+fS3CVV8XhHAzZs/IPbTRXx28R89d23sLA JB2jeqZgyrob6TiUFHRAzIJ0Wx+huauMiI6FcUdCkauFmjovkDLL5Z8SiPQo6VSmIanM ufBXdSJgeGagyCSkl641WG0DaaB1CySnuiRoYn9GsEjABnoB7khWXqp/yldKMI8K+/vH WqKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=6CfBURkjyLlHy1Dab5geVGmsGERfMosDQ7oIts7Indw=; b=1FfXiTnv/G4r9+frZxgIJrkhWgkIN4Mi5YqChJZDdTPx+1d0ydX2hZ8Nn2yZ+6EaZE ld8RE8AnIQ8I5rFrXs7nZ81eqPcA06hnVgku38aypCIfOTizkSJD+mAi/HmgMJD35LXp d285G60Tc2Ub59ge5W5FZwgqRwCL6iZDh4bYXwRepAM7YrHQXH9i2lODMZPYsadlSSI7 lCKr3Wem+MW31v0N4PXjzKZw/YInCpFHJxRkHAhU7QwhvDq84vSgiDmbagiNBbSiLO4w 14G2/exw784xbp1RurIf18VbQuKkjl1ztI5bl2G+A8QCq7wa9LuDQKbT0lbPRBtiNRHX fwFw== X-Gm-Message-State: ACrzQf2TXnElwE4HUC6Eh69k6REy+9FAo77HUJ/xfWIDSLoyJhpcuiRa bhxCu3kfq4fjCJuhyS9Z4pJfTzgm0ywA3kuJq7UUXHR+zMrKS8hmFKmg5C4YHVglL+Niw9jMxFg NcCSJSZTAHnq326lh/4sv6yuswTphxS51HVAfWz1NLh9ZqOvHteM9rTvCd7YcJjLwcnLL X-Google-Smtp-Source: AMsMyM5N7gPLnBNu/H9vD2Wnxu6Ec/pzAe9FOt99G13yaNqlo8quj/pIhZLyYU99rqo4Iy33oM+USw== X-Received: by 2002:a05:620a:15a1:b0:6cc:f925:7c89 with SMTP id f1-20020a05620a15a100b006ccf9257c89mr1775299qkk.319.1665024368467; Wed, 05 Oct 2022 19:46:08 -0700 (PDT) Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com. [209.85.219.174]) by smtp.gmail.com with ESMTPSA id d6-20020a05620a240600b006cbc40f4b36sm19624162qkn.39.2022.10.05.19.46.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Oct 2022 19:46:08 -0700 (PDT) Received: by mail-yb1-f174.google.com with SMTP id n74so718331yba.11 for ; Wed, 05 Oct 2022 19:46:07 -0700 (PDT) X-Received: by 2002:a25:b94:0:b0:6be:6765:7e5 with SMTP id 142-20020a250b94000000b006be676507e5mr2601308ybl.561.1665024367638; Wed, 05 Oct 2022 19:46:07 -0700 (PDT) MIME-Version: 1.0 References: <20221005035446.30054-1-palmer@rivosinc.com> In-Reply-To: From: Andrew Waterman Date: Wed, 5 Oct 2022 19:45:56 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] RISC-V: Default to tuning for the thead-c906 To: Kito Cheng Cc: Andrew Pinski , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: I agree with Kito; I don't support merging this patch. My reasoning is twofold: - The default settings should be fairly neutral, avoiding codegen that severely disadvantages some targets. Misaligned memory accesses are certainly a problematic case in that respect. (And it's highly asymmetric: the perf upside for implementations that do support this feature is much lower than the perf downside for implementations that don't.) I haven't reviewed the rest of the C906 tuning decisions, but I'd raise the same concern if any of them are similarly non-neutral. - Both the RISC-V ISA spec and the more recent RVA22 profile spec explicitly caution about the perf impacts of such a tuning decision. The RVA22 profile spec goes further to explicitly state that standard software distributions should not do what this patch does. https://github.com/riscv/riscv-profiles/commit/b09dc934e8cb8c1dfb7ddead8bdf509408e94609#diff-01b3848d5e44a205fafe2a7b93dbf353138763b76110bb833b7eeee1ac4afe5bR593-R595 Andrew On Wed, Oct 5, 2022 at 6:59 PM Kito Cheng via Gcc-patches wrote: > > -1 for this, default enable fast unaligned access could cause many > problems, and lots of RISC-V cores > don't support HW unaligned access (Rocket-base RISC-V core, most > SiFive core, and most Andes core IIRC), > change this to default means package from RISC-V linux distro might > contain unaligned access by default. > > The default one should be the safest option, in case people really > want that, they could use --with-tune and > --with-arch to change that. > > > On Wed, Oct 5, 2022 at 1:57 PM Andrew Pinski via Gcc-patches > wrote: > > > > On Tue, Oct 4, 2022 at 8:55 PM Palmer Dabbelt wrote: > > > > > > The C906 is by far the most widely available RISC-V processor, so let's > > > default to tuning for it. > > > > > > gcc/ChangeLog > > > > > > * config/riscv/riscv.h (RISCV_TUNE_STRING_DEFAULT): Change to > > > thead-c906. > > > * doc/invoke.texi (RISC-V -mtune): Change the default to > > > thead-c906. > > > > > > --- > > > > I am ok with this as --with-tune and --with-arch works as ways of > > changing the default still. > > > > Thanks, > > Andrew > > > > > > > > This has come up a handful of times, most recently during the Cauldron. > > > It seems like a grey area to me: we're changing the behavior of some > > > command-line arguments (ie, everything that doesn't specify -mtune), but > > > we sort of change that anyway as the tuning parameters change between > > > releases. > > > > > > I'm not really seeing much of a precedent from the other ports. It > > > looks like aarch64 sort of changed the default in 02fdbd5beb0 > > > ("[AArch64] [-mtune cleanup 2/5] Tune for Cortex-A53 by default.") but I > > > think at that point -mtune=generic and -mtune=cortex-a53 were equivalent > > > so I'm not sure that counts. I can't quite sort out if the default x86 > > > tuning has ever changed, but the tuning parameters have changed. I > > > don't see any way around having the tuning parameters change as they're > > > pretty tightly coupled to the GCC internals, but changing to a different > > > tuning target is a bit bigger of a change. > > > > > > We also have a bit of a special case here: -mtune is in theory only a > > > performance issue, but this change will emit a lot more misaligned > > > accesses and we've seen those trigger bugs in the trap handlers before. > > > Those bugs are elsewhere so it's sort of not a GCC problem, but I'm sure > > > there's still users out there with broken firmware and this may cause > > > visible fallout. We can just tell those users their systems were always > > > broken, but that's never a fun way to do things. > > > > > > I figured the easiest way to talk about this would be to just send the > > > patch, but I definitely don't plan on committing it without some > > > discussion. > > > --- > > > gcc/config/riscv/riscv.h | 2 +- > > > gcc/doc/invoke.texi | 2 +- > > > 2 files changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h > > > index 363113c6511..1d9379fa5ee 100644 > > > --- a/gcc/config/riscv/riscv.h > > > +++ b/gcc/config/riscv/riscv.h > > > @@ -40,7 +40,7 @@ along with GCC; see the file COPYING3. If not see > > > #endif > > > > > > #ifndef RISCV_TUNE_STRING_DEFAULT > > > -#define RISCV_TUNE_STRING_DEFAULT "rocket" > > > +#define RISCV_TUNE_STRING_DEFAULT "thead-c906" > > > #endif > > > > > > extern const char *riscv_expand_arch (int argc, const char **argv); > > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > > > index e0c2c57c9b2..2a9ea3455f6 100644 > > > --- a/gcc/doc/invoke.texi > > > +++ b/gcc/doc/invoke.texi > > > @@ -28529,7 +28529,7 @@ particular CPU name. Permissible values for this option are: @samp{rocket}, > > > @samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}. > > > > > > When @option{-mtune=} is not specified, use the setting from @option{-mcpu}, > > > -the default is @samp{rocket} if both are not specified. > > > +the default is @samp{thead-c906} if both are not specified. > > > > > > The @samp{size} choice is not intended for use by end-users. This is used > > > when @option{-Os} is specified. It overrides the instruction cost info > > > -- > > > 2.34.1 > > >