--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4111d349-b11d-45a4-aa06-d871d8efb20e%40isocpp.org.
One issue with the current C++ Standard is that it does not allow cstdint to define anything other than 8/16/32/64/max, whereas the C Standard does. So an implementation cannot currently define a std::uint128_t but could define a uint128_t.The C Standard mentions the possibility of non-power-of-2 sizes, calling out uint24_t as an example. (Trivia: uint24_t would actually be a sensible type on an eZ80.)The C++ Standard ought to do the same as the C Standard. We also should get a proposal for std::uint_t<N> and such.A separate problem with something like uint128_t is that it breaks the definition of uintmax_t. We can't change uintmax_t on an existing platform, because that's a breaking change. And if uint128_t exists and is larger than uintmax_t, what does that mean?
Since you are asking specifically for 128 bit integers, I believe the right choice would be to just add int128_t and uint128_t alias (to unspecified types) into <cstdint>. Since the presence of most of the aliases in that header is already conditionally provided, it should not be a burden to implementations. The only problem in this area is that we should consider deprecating intmax_t and uintmax_t. Other discussions have pointed that it was a bad idea to introduce them, since an implementation can’t change its definition without potentially breaking binary compatibility.
- There is widespread consensus that intmax_t et al should reflect the largest basic integer type. And therefore it wouldn't change.
- I'm going to propose that C implements http://wg21.link/P0539 A Proposal to add wide_int Template Class directly into the C language.
- Probably a dramatically simplified subset of the proposed syntax in http://wg21.link/P0989 Standardizing Extended Integers would be proposed.
From: Barry Revzin Sent: Thursday, October 4, 2018 8:34 AM To: ISO C++ Standard - Future Proposals Reply To: std-pr...@isocpp.org Subject: [std-proposals] Re: 128 bit integers |
I had noticed the first of April date, and most of the proposal is obviously terrible. However there are some good ideas in there, and I'm going to propose them for standardisation. Niall
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/869310a4-67f1-4594-8157-e33ae7d7e0f3%40isocpp.org.
If you're collecting related papers, you might want to mention P0539 which is a 100% serious paper.
WG21 is currently proceeding down a library-based path for implementing extended precision integers (https://wg21.link/P0539), but my issue with it is that it is very hard to get the compiler to predictably generate optimal code with a library only solution. In particular, compilers fail to spot when they can use carry-adds or carry-multiplies from hints provided by generic C or C++ code. This is why I have become convinced we need a language based implementation so compilers know exactly what they are supposed to do. Hence me coming here to WG14.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b5d854b4-c24e-4a3f-8fcc-3c793527b791%40isocpp.org.
Does your proposal address _Atomic in C, and atomic<integral> in C++? I want to be sure that no-one is laboring under conflicting assumptions here, even when it means stating the (apparently) obvious.
On Friday, October 5, 2018 at 2:18:30 PM UTC+1, John McFarlane wrote:If you're collecting related papers, you might want to mention P0539 which is a 100% serious paper.My C proposal paper is actually a direct response to P0539, and it discusses what I think are showstopper problems with that paper, and why we need a language solution instead. As I wrote:WG21 is currently proceeding down a library-based path for implementing extended precision integers (https://wg21.link/P0539), but my issue with it is that it is very hard to get the compiler to predictably generate optimal code with a library only solution. In particular, compilers fail to spot when they can use carry-adds or carry-multiplies from hints provided by generic C or C++ code. This is why I have become convinced we need a language based implementation so compilers know exactly what they are supposed to do. Hence me coming here to WG14.
On Friday, October 5, 2018 at 6:10:37 PM UTC+1, Alisdair Meredith wrote:Does your proposal address _Atomic in C, and atomic<integral> in C++? I want to be sure that no-one is laboring under conflicting assumptions here, even when it means stating the (apparently) obvious.Do bear in mind that my proposal is a generalised wide integer proposal for C. So, P0539, but at the C language level.
What about having 'intrinsics' for carry-adds, carry-multiplies and other operations (saturating and wrapping ops for example)?
I was wondering why the C standard allows implementations to optionally add intN_t and uintN_t for any N (including 128 and non-powers-of-two like 24), but C++ only mentions 8, 16, 32 and 64. Is there a strong rationale for that? Would it hurt to explicitly allow those "exotic" integer types to be conditionally-supported in C++ also?
Does your proposal address _Atomic in C, and atomic<integral> in C++? I want to be sure that no-one is laboring under conflicting assumptions here, even when it means stating the (apparently) obvious.
I was wondering why the C standard allows implementations to optionally add intN_t and uintN_t for any N (including 128 and non-powers-of-two like 24), but C++ only mentions 8, 16, 32 and 64. Is there a strong rationale for that? Would it hurt to explicitly allow those "exotic" integer types to be conditionally-supported in C++ also?C and C++ are required to define "least" and "fast" forms of various bit sized integers, and only if the architecture permits exactly 8, 16, 32 and 64 bits does it define typedefs for those.
On Friday, October 5, 2018 at 2:18:30 PM UTC+1, John McFarlane wrote:If you're collecting related papers, you might want to mention P0539 which is a 100% serious paper.My C proposal paper is actually a direct response to P0539, and it discusses what I think are showstopper problems with that paper, and why we need a language solution instead. As I wrote:WG21 is currently proceeding down a library-based path for implementing extended precision integers (https://wg21.link/P0539), but my issue with it is that it is very hard to get the compiler to predictably generate optimal code with a library only solution. In particular, compilers fail to spot when they can use carry-adds or carry-multiplies from hints provided by generic C or C++ code. This is why I have become convinced we need a language based implementation so compilers know exactly what they are supposed to do. Hence me coming here to WG14.
Current proposal being discussed on the WG14 reflector looks as follows:1. For any integer type excluding _Bool (char, short, int, long, long long), one may extend it into an extended arithmetic type by annotating it with "_Wide(N)":- _Wide(4) int- long long _Wide(2)This simply tells the compiler to emit the add-with-carry or multiply-with-carries instructions necessary to increase the precision of the specified arithmetic type. And before anyone asks, yes it is legal to widen small types:- _Wide(2) short (NOT an int)- _Wide(4) char (NOT an int)2. These wide integer types are not integral types, and thus do not affect intmax_t etc. ABI remains unchanged.3. As the compiler knows the size of these at compile time, and that they will always be some twos power multiple of an integral type, implementation cost for compiler vendors is straightforward. *Optimising* them is hard, but then so is optimisation in any case.4. These extended types would have the same ABI as a struct of however many of their integral type e.g. _Wide(4) long int has the same ABI as struct { long int[4] }. So they'll get passed mostly by reference, whatever the current calling convention says. Nothing changes for the calling convention.
5. My current feeling is that these wide arithmetic types should have the alignment of their integral type but doubled as necessary. This enables them to "stand in" for types hardware available on bigger CPUs. It also enables SIMD vectorisation by optimisers - AVX-512 CPUs can do 8x 128-bit integer adds four times faster than with the scalar instructions for example.
I'm not sure why you think that implementers are restricted to supplying pure-library solutions or why using something like the free functions in P0103 would not solve this. Do you go into any more detail about the reasons you don't think a library solution is practical for C++?
That would seem to imply they have 4 sign bits but presumably they don't, right?
5. My current feeling is that these wide arithmetic types should have the alignment of their integral type but doubled as necessary. This enables them to "stand in" for types hardware available on bigger CPUs. It also enables SIMD vectorisation by optimisers - AVX-512 CPUs can do 8x 128-bit integer adds four times faster than with the scalar instructions for example.Are you only aiming for powers of two? That's another way in which this would differ from P0539.
What about having 'intrinsics' for carry-adds, carry-multiplies and other operations (saturating and wrapping ops for example)?Firstly, I am unaware of any precedent for that sort of intrinsic in either C or C++. It seems too specific for standardisation to me, but maybe I'm wrong.
Secondly, such a thing would be rather hardware dependent. For example RISC V has no carry flag, and thus no carry based arithmetic. So kinda hard to standardise such support.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/bf21d232-2924-45bc-b114-365a53ecf256%40isocpp.org.
>
> According to my interpretation of the C and C++ standards, if the implementation has a integer types of exactly N bits, it is allowed to provide intN_t and uintN_t aliases in C11 for any N, but it can do so in C++11/14/17 only if N = 8, 16, 32, 64. For example, paragraph 7.20.1.1/2 in C11 explicitly mentions the possibility to have a uint24_t type. Under this interpretation, an implementation may provide int128_t and uint128_t types in C but not in C++. I find this strange. Am I missing something?
>
Please take a look at
http://cplusplus.github.io/LWG/lwg-active.html#2820
which should solve the current deviation between C and C++ (at least
that seems to be the intention).