From nobody Mon Nov 06 12:41:25 2023 X-Original-To: toolchain@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SP9vT22sZz50fRb for ; Mon, 6 Nov 2023 12:41:25 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SP9vT00gNz4lV9 for ; Mon, 6 Nov 2023 12:41:25 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699274485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=exsOhmDqSdXSz4kwZlFbvVBe/J6QixL5YvADVcRTT4c=; b=adJ4/B9bHEfRvpHdVFKZZGuDqleWDUGtMT20igBrE9gJYw2ezyZCDJ7702OFwMvTG8FkZV xcyStihrCA1xuhelOpQaXWIi7nXHpiV3JYTj0jpw7+SSIg1JF8tp9OgGB4sWAHEblsUd0N +d6qT4BQWj96DCrkFgYfXL5wB42dStjIW/faz+gS6Bh2R+r0VdC5aWRsTENj50avPqMtnj 09U4ZOcPwA1LV78ncDJDK44/5z6YpgcE40SbmPZtwLLyuJXRAcbML0j97iPgOK15TRRXmy 6kKdqJf7/e7vqdNV1+Bj1ouEAj68iNxz6sqiprp6o2lF3DxluKcT3SwPKtRX6Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699274485; a=rsa-sha256; cv=none; b=FjHkpKlkdxkCis3Pv8GcHQRCe8xPP096wLhyG0JKKFXfv9uTIND1bcThbZpSG8XCvo1emx +fR/bNsLqfeZt7zFJRo+cg5vGodZ1bBajs6eMsPcZ0fy/9+kphfJxuBURBooarxzsZeq1M ehoCmsgfAaqwslVlxJ9reY/ikQ0CNsPx3T6B0yUxmPpEDNcHxUWB2MsmZFR6QcOoa/btKy Qyx1/q6CRnEJEUdJHWLhzVMo7DnAOZzYP5HfXcc8DsrqQ9g7MSqKoGqo0Ma6j1+GhnIotq C/hfLDFH4mRN7tZc/5JwIM9wkvzng1TsigeosTTykWQMTnEj3q9IAZvD5jmnHg== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SP9vS6DMYz16kt for ; Mon, 6 Nov 2023 12:41:24 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 3A6CfOYR074933 for ; Mon, 6 Nov 2023 12:41:24 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 3A6CfO1C074923 for toolchain@FreeBSD.org; Mon, 6 Nov 2023 12:41:24 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: toolchain@FreeBSD.org Subject: [Bug 274927] Toolchain fails on the __sync_val_compare_and_swap function without -march=native (port biology/seqwish) Date: Mon, 06 Nov 2023 12:41:25 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 13.2-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: dim@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: toolchain@FreeBSD.org X-Bugzilla-Flags: 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: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Maintenance of FreeBSD s integrated toolchain List-Archive: https://lists.freebsd.org/archives/freebsd-toolchain List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-toolchain@freebsd.org X-BeenThere: freebsd-toolchain@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D274927 --- Comment #8 from Dimitry Andric --- These are all called via seqwish::DisjointSets::unite() (which is in=20 https://github.com/ekg/seqwish/blob/master/src/dset64-gccAtomic.hpp): 0000000000000000 : 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp ... 43: e8 00 00 00 00 call 48 44: R_X86_64_PLT32=20=20=20=20=20 __sync_val_compare_and_swap_16-0x4 The file has a comment about this: * The implementation in shasta/src/dset64.hpp uses std::atomic<__uint128_t> * for lock-free synchronization. * On older GCC versions, std::atomic<__uint128_t> is lock-free * if compilation is done with -mcx16, which enables the use of the * 16-byte (128 bit) compare-and-swap instruction, CMPXCHG16B. * * Unfortunately, on newer GCC versions, this is no longer true * because of gcc bug 80878: * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D80878 * * As a result, there was a significant performance loss in * versions of Shasta built with gcc 7, * which is used by default on Ubuntu 18.04, when using * machines with large number of virtual processors. * * It is unlikely that this gcc bug will ever be fixed, * and to avoid this performance loss this implementation * uses gcc primitive __sync_bool_compare_and_swap instead * for lock-free synchronization. When compilation * is done with -mcx16 and optimization turned on, * this primitive uses the CMPXCHG16B instruction * and results in optimal speed. * * The CMPXCHG16B instruction is available on most modern 64-bit x86 processors. * Some older processors that don't implement this instruction * will crash with an "Illegal instruction" error * upon attempting to run this code. However __sync_bool_compare_and_swap is usually provided by a compiler libr= ary such as libgcc or libcompiler-rt. I don't think we have this function for 1= 28 bit integers, though. As noted in the comment, the code should be compiled with -mxc16 for optimal performance. Processors which do not support CMPXCHG16B are quite ancient n= ow. --=20 You are receiving this mail because: You are the assignee for the bug.=