From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 7C45D3885C31 for ; Fri, 14 Jan 2022 21:30:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7C45D3885C31 Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-509-Wp6qDBjeMqaP-PY_p_eOeg-1; Fri, 14 Jan 2022 16:30:47 -0500 X-MC-Unique: Wp6qDBjeMqaP-PY_p_eOeg-1 Received: by mail-yb1-f198.google.com with SMTP id p135-20020a25748d000000b00611f5308717so2869926ybc.2 for ; Fri, 14 Jan 2022 13:30:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CJ3S1hxKRH++ks4pZK2J/JuBj4ePVNQwoVf/6BTJKfs=; b=IZmrqJz0dJUw5F/mBK9N+Zrl/55RN/3Tn9xkF1K5ZhZ+wQalT5U+LaqheA0Y7Cbi1g b/ockSXyZUxkT5+6Fn58Ff1Ngge0u9yRIuIpoZ6JIbFk2+iqpbZ7AZ27tEq4YJ19PdZo kr/naHYAwIII8JhZWfcXjNENb3RanGuKQ0xKeRGnp6ettJAVq+1orcU4bCDgsPriXoUx ZPiHgp06uYIvB9PI6NHqdnXl579I7b1z83yf+9aQWxYJXJy/M2jQc3T1b4BROW58ya+C 551kdvaiMAA9roMzCaeXKL+B7yBPGT4eow1HhW5OhDFyvtQRSee3lTT73W14PG+ee9/p M9NQ== X-Gm-Message-State: AOAM530ODAeFbizUQ8hmop3Dc6VqhPFz08S5oMdVdOYVYWJPhkKtYTaY 87atZwZhi5gdJ6a3PJOYNaTgVu2S3sVn5eQ0EYKL5ITcVxaPr0nT5ZfbfRppMAUckr78D9odY5W XYOjD/TMw+7TAsUoPOtOONaositC1ZJY= X-Received: by 2002:a25:bfcb:: with SMTP id q11mr16324594ybm.253.1642195846675; Fri, 14 Jan 2022 13:30:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwCzvG73gZjEj4FYmlsRwHky+dhgCCyHIGKNVFxb32nk2B0K3iXQrAZzJu7x1KekXN4YOo6KMq/rYdi6PALtQ= X-Received: by 2002:a25:bfcb:: with SMTP id q11mr16324561ybm.253.1642195846312; Fri, 14 Jan 2022 13:30:46 -0800 (PST) MIME-Version: 1.0 References: <270527782.u9WJ3AIrlG@excalibur> <2210452.fJnDbHsrEp@excalibur> <3005875.unVi0tRuQf@excalibur> In-Reply-To: <3005875.unVi0tRuQf@excalibur> From: Jonathan Wakely Date: Fri, 14 Jan 2022 21:30:34 +0000 Message-ID: Subject: Re: [PATCH 11/11] libstdc++: Fix ODR issues with different -m flags To: Matthias Kretz Cc: gcc Patches , "libstdc++" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2022 21:30:57 -0000 On Mon, 15 Nov 2021 at 08:57, Matthias Kretz wrote: > ping. OK to push? > Sorry for the delay - this is OK for trunk. > On Tuesday, 8 June 2021 14:12:23 CET Matthias Kretz wrote: > > From: Matthias Kretz > > > > Explicitly support use of the stdx::simd implementation in situations > > where the user links TUs that were compiled with different -m flags. In > > general, this is always a (quasi) ODR violation for inline functions > > because at least codegen may differ in important ways. However, in the > > resulting executable only one (unspecified which one) of them might be > > used. For simd we want to support users to compile code multiple times, > > with different -m flags and have a runtime dispatch to the TU matching > > the target CPU. But if internal functions are not inlined this may lead > > to unexpected performance loss or execution of illegal instructions. > > Therefore, inline functions that are not marked as always_inline must > > use an additional template parameter somewhere in their name, to > > disambiguate between the different -m translations. > > > > Signed-off-by: Matthias Kretz > > > > libstdc++-v3/ChangeLog: > > > > * include/experimental/bits/simd.h: Move feature detection bools > > and add __have_avx512bitalg, __have_avx512vbmi2, > > __have_avx512vbmi, __have_avx512ifma, __have_avx512cd, > > __have_avx512vnni, __have_avx512vpopcntdq. > > (__detail::__machine_flags): New function which returns a unique > > uint64 depending on relevant -m and -f flags. > > (__detail::__odr_helper): New type alias for either an anonymous > > type or a type specialized with the __machine_flags number. > > (_SimdIntOperators): Change template parameters from _Impl to > > _Tp, _Abi because _Impl now has an __odr_helper parameter which > > may be _OdrEnforcer from the anonymous namespace, which makes > > for a bad base class. > > (many): Either add __odr_helper template parameter or mark as > > always_inline. > > * include/experimental/bits/simd_detail.h: Add defines for > > AVX512BITALG, AVX512VBMI2, AVX512VBMI, AVX512IFMA, AVX512CD, > > AVX512VNNI, AVX512VPOPCNTDQ, and AVX512VP2INTERSECT. > > * include/experimental/bits/simd_builtin.h: Add __odr_helper > > template parameter or mark as always_inline. > > * include/experimental/bits/simd_fixed_size.h: Ditto. > > * include/experimental/bits/simd_math.h: Ditto. > > * include/experimental/bits/simd_scalar.h: Ditto. > > * include/experimental/bits/simd_neon.h: Add __odr_helper > > template parameter. > > * include/experimental/bits/simd_ppc.h: Ditto. > > * include/experimental/bits/simd_x86.h: Ditto. > > --- > > libstdc++-v3/include/experimental/bits/simd.h | 380 ++++++++++++------ > > .../include/experimental/bits/simd_builtin.h | 41 +- > > .../include/experimental/bits/simd_detail.h | 40 ++ > > .../experimental/bits/simd_fixed_size.h | 39 +- > > .../include/experimental/bits/simd_math.h | 45 ++- > > .../include/experimental/bits/simd_neon.h | 4 +- > > .../include/experimental/bits/simd_ppc.h | 4 +- > > .../include/experimental/bits/simd_scalar.h | 71 +++- > > .../include/experimental/bits/simd_x86.h | 4 +- > > 9 files changed, 440 insertions(+), 188 deletions(-) > > -- > =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > Dr. Matthias Kretz https://mattkretz.github.io > GSI Helmholtz Centre for Heavy Ion Research https://gsi.de > std=E2=82=93::simd > =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > > > >