On Monday, March 28, 2016 at 5:10:57 PM UTC-7, Richard Maine wrote:
> <
campbe...@gmail.com> wrote:
> > How did it become acceptable for gFortran to store real*10 in 16 bytes ?
> To the extent that your "acceptable" means "acceptable to the standard",
> i.e. standard conforming, the standard has allowed things like that from
> day one. Storage alignment requirements are distinct from precision
> requirements. Many examples of mismatches between the two have existed.
Day one gave 36 bit REAL and 16 bit INTEGER in 36 bit words on the 704,
so yes not all bits were used.
> As noted elsewhere, I have used multiple compilers that stored 80-bit
> real values with 128-bit alignment. No, gFortran is not the only one.
> A simillar case is that old Microsoft compilers used to store 16-bit
> integers with 32-bit alognment. The 32-bit alignment was so that they
> matched the storage used for reals as required by the standard, and the
> 16 bits was because that was faster for some processors of the day (yes,
> it was a while ago). If I recall correctly, details of this could be
> controlled by compiler switches.
Pretty much all compilers I knew for 16 bit minicomputers, such
as the PDP-11, used 16 bits for INTEGER, and 32 bits for REAL.
With 64K (or often only 16K or 32K) you don't waste bits.
The compilers likely have an option to generate 32 bit integers,
and use only 16 of the bits. I never knew anyone to use the option.
The DEC PDP-11 compilers have INTEGER*2 and INTEGER*4, both
holding, as well as I remember, 16 bit integers.
> To the extent that your "acceptable" means something more along the
> lines of useful to users, I'd suggest that the existance of hardware
> that supports 8-bit reals is pretty solid evidence that there is use for
> such things. There is a lot of such hardware from multiple vendors. Many
> applications need something a bit more than 64 bits, but don't need a
> full 128 bits.
> As to why those 80-bit reals are often aligned on 128-bit boundaries,
> Glenn mentioned that is is sometimes more efficient to use that
> alignment, and there is even some hardware that literally cannot deal
> with data not aligned on at least 4-byte boundaries.
Pretty common for RISC processors.
In the Fortran 66 days, it was believed that COMMON didn't
allow padding. Compilers generated unaligned variables,
and then fixed up the alignment exception at run-time.
Fortunately, that has changed.
> Plus, the Fortran standard requires the 128-bit alignment for doubles if
> single is 64 bits. Yes, there are vendors who do pay attention to the
> standard. And in the other direction, the standard tends to be
> influenced by needs of vendors and users. The standard requires double
> to have exactly twice the storage of single, but only requires that its
> precision be "greater"; how much greater is deliberately left
> unspecified.
DOUBLE PRECISION is required to be twice as large, though I don't
believe that the standard requires a specific alignment for it.
(They could be 128 bits big, but only need 64 bit alignment.)
I was always disappointed that 128 bit floating point hardware,
and software to support it, was so rare.
Early in my Fortran programming (maybe my second program),
I tried to compute square roots with QSQRT. It seems that only
the more expensive H extended compiler supported them.
I had the manual, but no access to the compiler.
IBM supported REAL*16 back to the 360/85, and on all
S/370 and successor models. (Except that divide, DXR,
was done in software. IBM did studies to show that it was
rare enough that software was fast enough. In ESA/390
years, hardware DXR was finally added.)
The VAX architecture includes H-float, but it is an optional extra
charge microcode option on most processors.
The 11/730, low end machine, has as standard.
Numerically, as calculations get larger, there is
more need for intermediates with extra precision.
The 8087 temporary real came from the IEEE standard attempt to allow
for extra precision for intermediate values.
128 bit floating point is an optional feature of RISC V.
It will be interesting to see how many implement it.