From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E41B63858296; Wed, 25 Oct 2023 13:21:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E41B63858296 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1698240114; bh=BX0vx8dr836eeyMBmREY2bIzatS789YQ6eQOwl565qQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XHGWdiEZNOfVycCwLdf62XpuvjHI2+geYCjilKmS4EOurzmRqXQnnA7LSS/UeIfxh GbymuE1ZmaWdKfvpHkzBX3CEVYlkeTNAzF2IytTIiE6d4wBQSF1U+ttpENlblVBRVs 4sG2jZXGaIkAg2L0vA0PDnGRYO1b7FSnO4fD101k= From: "bmerry at sarao dot ac.za" To: glibc-bugs@sourceware.org Subject: [Bug string/30995] Zen 4: sub-optimal memcpy on very large copies Date: Wed, 25 Oct 2023 13:21:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: string X-Bugzilla-Version: 2.38 X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: bmerry at sarao dot ac.za X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30995 --- Comment #3 from Bruce Merry --- > To avoid evicting higher-level, shared cashes, it is usually beneficial t= o switch from REP MOVSB to non-temporal stores at a certain point even thou= gh it impacts single-thread performance. >From what I can tell, REP MOVSB on Zen 4 already does this for large copies= . I base that off using AMD uProf to read the DRAM bandwidth counters while run= ning the copy benchmark. When copying 1GB with a single REP MOVSB, the read and write counters match the rate of data transfer (no read-for-ownership overhead). When breaking the copy into smaller pieces (less than 32MB), the read counter is roughly double the transfer rate due to read-for-ownership. I've tried running the benchmark on all 32 cores of the CPU; in this case glibc's memcpy is about 5% faster than using REP MOVSB (and my simple AVX512 streaming copy with a linear access pattern gets pretty much the same performance as REP MOVSB in this case). So you're correct that there is a trade-off, but being 5% faster when bandwidth-limited but 30% slower on a single core (as well as using more space in icache) doesn't seem like a gre= at tradeoff (I appreciate that trying to write a memcpy that works well across= a wide range of hardware is no easy task though). --=20 You are receiving this mail because: You are on the CC list for the bug.=