Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #126745

Re: Aligned Issue when malloc()

From Egor <egor@ruby.local>
Newsgroups comp.lang.c
Subject Re: Aligned Issue when malloc()
Date 2018-02-15 19:35 +0200
Organization Aioe.org NNTP Server
Message-ID <cvsgle-dac.ln1@ruby.opensrc.club> (permalink)
References (3 earlier) <oqieC.14584$RQ3.6328@fx02.iad> <3c97f1c7-9830-b7b2-9400-6551596eaa81@verizon.net> <3c435029-fc0c-4753-ab8e-8e81342ea09e@googlegroups.com> <pan0le-i1a.ln1@ruby.opensrc.club> <fd4834cc-971c-4c3c-8832-c831fa36501a@googlegroups.com>

Show all headers | View raw


supercat@casperkitty.com wrote:
> The fact that an 80-bit type is large enough to hold all integer types is
> certainly convenient, but a bigger issue is that if wants to evaluate
> something like
> 
>    a = b+c+d;
> 
> using values of type "double" on a system without an FPU, the system will
> waste a fair amount of time normalizing the mantissa of (b+c), then shifting
> and packing the mantissa and exponent to cram everything into an 8-byte
> "double", and then unpacking the value that it had just spent time packing.
> Having a type that can hold (b+c) without a normalizing or packing step
> before adding d will yield computations which are not only more accurate but
> also *faster*.
> 
> A point which language designers and compiler writers miss, however, is that
> extra-precision intermediate types are a good thing only if there is a type
> in the language which can actually hold them.  Storage efficiency won't
> usually matter, since most values should be stored using "double", but given
> an expression like:
> 
>    (x-y)*(x-y);
> 
> it should be possible for the programmer to eliminate the redundant
> expression (x-y) without affecting the computed result.  Platforms which
> use 80-bit computations but make "long double" only 64 bits violate that
> principle.

It's okay to use long doubles for temp variables, but I can't imagine a
scenario where you'd need to store intermediate computation in an
aligned array allocated by malloc, hence why I think that proper
alignment of long doubles is not an important matter.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Aligned Issue when malloc() hwding <m@amastigote.com> - 2018-02-06 01:17 -0800
  Re: Aligned Issue when malloc() Ian Collins <ian-news@hotmail.com> - 2018-02-06 22:41 +1300
  Re: Aligned Issue when malloc() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-02-06 11:52 +0000
    Re: Aligned Issue when malloc() hwding <m@amastigote.com> - 2018-02-06 04:35 -0800
      Re: Aligned Issue when malloc() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-02-06 13:48 +0000
        Re: Aligned Issue when malloc() "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-02-06 12:55 -0800
      Re: Aligned Issue when malloc() Richard Damon <Richard@Damon-Family.org> - 2018-02-06 08:52 -0500
        Re: Aligned Issue when malloc() "James R. Kuyper" <jameskuyper@verizon.net> - 2018-02-06 09:59 -0500
          Re: Aligned Issue when malloc() supercat@casperkitty.com - 2018-02-06 07:20 -0800
            Re: Aligned Issue when malloc() Robert Wessel <robertwessel2@yahoo.com> - 2018-02-06 11:50 -0600
            Re: Aligned Issue when malloc() Keith Thompson <kst-u@mib.org> - 2018-02-06 11:34 -0800
            Re: Aligned Issue when malloc() Egor <egor@ruby.local> - 2018-02-09 16:20 +0200
              Re: Aligned Issue when malloc() supercat@casperkitty.com - 2018-02-15 08:56 -0800
                Re: Aligned Issue when malloc() Egor <egor@ruby.local> - 2018-02-15 19:35 +0200
                Re: Aligned Issue when malloc() supercat@casperkitty.com - 2018-02-15 11:27 -0800
                Re: Aligned Issue when malloc() Egor <egor@ruby.local> - 2018-02-16 02:48 +0200
                Re: Aligned Issue when malloc() supercat@casperkitty.com - 2018-02-16 08:49 -0800
      Re: Aligned Issue when malloc() "James R. Kuyper" <jameskuyper@verizon.net> - 2018-02-06 09:41 -0500

csiph-web