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.133.124]) by sourceware.org (Postfix) with ESMTP id 3A9D13835406 for ; Tue, 27 Apr 2021 09:46:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3A9D13835406 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-264-hfJgyhRINk2rDTPGPmYwCA-1; Tue, 27 Apr 2021 05:46:51 -0400 X-MC-Unique: hfJgyhRINk2rDTPGPmYwCA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3EEE0501FB; Tue, 27 Apr 2021 09:46:50 +0000 (UTC) Received: from localhost (unknown [10.33.36.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id D480A687FA; Tue, 27 Apr 2021 09:46:49 +0000 (UTC) Date: Tue, 27 Apr 2021 10:46:48 +0100 From: Jonathan Wakely To: Matthias Kretz Cc: libstdc++@gcc.gnu.org Subject: Re: [RFC] Add gnu::diagnose_as attribute Message-ID: <20210427094648.GL3008@redhat.com> References: <14205410.xuKvIAzr1H@excalibur> MIME-Version: 1.0 In-Reply-To: <14205410.xuKvIAzr1H@excalibur> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: Tue, 27 Apr 2021 09:46:56 -0000 On 23/04/21 17:16 +0200, Matthias Kretz wrote: >Hi, > >before requesting comments on the implementation of this patch, I'd like to >know if there's interest in making use of it at all. > >In a nutshell, this solves the problem of bad signal-to-noise ratio with TS >implementations and potentially implementation-internal types. > >I've been using the diagnose_as attribute on my parallelism_v2 simd >implementation for two months now, and it significantly improved my >productivity. Like this: > >namespace std _GLIBCXX_VISIBILITY(default) >{ > _GLIBCXX_BEGIN_NAMESPACE_VERSION > namespace experimental > { > inline namespace parallelism_v2 [[__gnu__::__diagnose_as__("stdₓ")]] > { > namespace simd_abi [[__gnu__::__diagnose_as__("simd_abi")]] > { > struct [[__gnu__::__diagnose_as__("scalar")]] _Scalar; > using scalar = _Scalar; > > template > struct [[__gnu__::__diagnose_as__("fixed_size")]] _Fixed; > template > using fixed_size = _Fixed<_Np>; >[...] > >Effects: >1. __PRETTY_FUNCTION__ in my test output: > > PASS: void invoke_test(int) [with V = stdₓ::simdsimd_abi::_VecBuiltin<16> >; = stdₓ::simdsimd_abi::_VecBuiltin<16> >] > > instead of > > PASS: void invoke_test(int) [with V = >std::experimental::parallelism_v2::simdstd::experimental::parallelism_v2::simd_abi::_VecBuiltin<16> >; parameter-1-2> = std::experimental::parallelism_v2::simdstd::experimental::parallelism_v2::simd_abi::_VecBuiltin<16> >] > >2. Error messages: > > required from 'static constexpr stdₓ::_SimdWrapper<_Tp, _Np> >stdₓ::_SimdImplBuiltin<_Abi, >>::_S_fma(stdₓ::_SimdWrapper<_Tp, _Np>, stdₓ::_SimdWrapper<_Tp, _Np>, >stdₓ::_SimdWrapper<_Tp, _Np>) [with _Tp = double; long unsigned int _Np = 2; >_Abi = simd_abi::_VecBuiltin<16>; = >stdₓ::__detail::_MachineFlagsTemplate<31, 9>]' > > instead of > > required from 'static constexpr >std::experimental::parallelism_v2::_SimdWrapper<_Tp, _Np> >std::experimental::parallelism_v2::_SimdImplBuiltin<_Abi, parameter-1-2> >::_S_fma(std::experimental::parallelism_v2::_SimdWrapper<_Tp, >_Np>, std::experimental::parallelism_v2::_SimdWrapper<_Tp, _Np>, >std::experimental::parallelism_v2::_SimdWrapper<_Tp, _Np>) [with _Tp = double; >long unsigned int _Np = 2; _Abi = >std::experimental::parallelism_v2::simd_abi::_VecBuiltin<16>; parameter-1-2> = >std::experimental::parallelism_v2::__detail::_MachineFlagsTemplate<31, 9>]' > > >Since the main user of the attribute would be the standard library (I >believe), this patch only makes sense to pursue if there's interest in using >it in libstdc++. I'd like to use it for stdₓ::simd. Would you accept such a I think it's a great idea and would like to use it for all the TS implementations where there is some inline namespace that the user doesn't care about. std::experimental::fundamentals_v1:: would be much better as just std::experimental::, or something like std::[LFTS]::. My gut feeling is that something that isn't valid C++ syntax would make it clear you can't just copy&paste the qualified-name from the diagnostics to the code, so some identifier in square brackets would work. But I'm willing to be persuaded that doesn't matter. >patch? I guess using unicode in the alias name would not be acceptable, >though? I'm not wild about the UTF-8 characters, but we could define a macro for the attribute, and have: #if _GLIBCXX_SHOW_FANCY_NAMES # define _GLIBCXX_STDX [[__gnu__::__diagnose_as__ ("std\u2093")]] #else # define _GLIBCXX_STDX [[__gnu__::__diagnose_as__ ("std::[exp]")]] #endif (The universal character name ensures the header can still be used with -finput-charset=ascii and similar, but still prints "stdₓ" in the diagnostic.)