From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 2D5C0387089C for ; Wed, 16 Dec 2020 17:34:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2D5C0387089C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=segher@kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 0BGHXiVf021678; Wed, 16 Dec 2020 11:33:44 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 0BGHXheQ021677; Wed, 16 Dec 2020 11:33:43 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 16 Dec 2020 11:33:43 -0600 From: Segher Boessenkool To: "Sven C. Dack" Cc: gcc-help@gcc.gnu.org Subject: Re: L1/L2 cache characteristics and -mtune=znver2 versus run-time detection Message-ID: <20201216173343.GK2672@gate.crashing.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Dec 2020 17:34:46 -0000 On Wed, Dec 16, 2020 at 04:30:00PM +0000, Sven C. Dack via Gcc-help wrote: > Could some of the GCC experts please share their knowledge on this issue? > >I've come across an unexpected behaviour of gcc and wanted to ask for > >help. I've noticed that when I specify '-march=znver2' does gcc use the > >incorrect values for the L1/L2 cache. Only when '-march=native' was used > >and gcc detected the CPU at run-time does it use the correct values. For > >example on a Ryzen 7 3800X (a Zen 2 CPU): -march=native uses cpuid to get the cache info (or in general, looks at the system it is running on). -march=znver2 does not. I do not know if -march=znver2 should use better defaults. > >Why does GCC not use the correct L1/L2 cache values when '-march=znver2' > >or '-mtune=znver2' is specified? Please open a PR? https://gcc.gnu.org/bugs.html . Thanks! Segher