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


Groups > comp.lang.c > #107160

Re: C Compilers QoI

From BartC <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: C Compilers QoI
Date 2017-03-27 16:23 +0100
Organization A noiseless patient Spider
Message-ID <obbak6$78i$1@dont-email.me> (permalink)
References (18 earlier) <44758230-fa67-426c-8dd7-62cd7b01acb0@googlegroups.com> <ob9cfl$q3q$1@dont-email.me> <a0f7bfaa-b646-4b76-93eb-1ed345ef417f@googlegroups.com> <obapbh$8mh$1@dont-email.me> <62d9295b-5304-4e92-af79-07493227f240@googlegroups.com>

Show all headers | View raw


On 27/03/2017 15:38, supercat@casperkitty.com wrote:
> On Monday, March 27, 2017 at 5:28:59 AM UTC-5, Bart wrote:

>> It's also easier for the user, in the same way that being to write x+=y
>> might have an advantage over x=x+y or x=y+z.
>>
>> (I use the same approach in my dynamic languages, where sort(a) is a
>> function returning a new, sorted copy of a, and isort(a) is a procedure
>> which does an in-place sort of a.)
>
> Would you like C if x=x+y was Undefined Behavior, and achieving such
> semantics *required* the use of x+=y?
>
> If the same machine code would be usable for the in-place and disjoint-
> destination scenarios, would it make sense to require that the code for
> the three-operand form check whether the destination matches one of the
> sources and call a separate function that runs at just the same speed as
> the three-operand form?

I don't get you. Why would x=x+y be undefined behaviour?

Anyway I'm proposing nothing except that the user interface to such 
function allows those two forms. It's an easy way of provided useful 
extra information to whoever has to implement them, and gives a handy 
extra choice to the user, who doesn't need to worry about annotating 
code with optimisation tips that may not match the actual code.

(However, I've implemented both functions in my own language, with a 
poor optimiser but more transparent code, and there was little 
difference, perhaps 5%, between:

   add_vector(a,a,b,n);

and:

   iadd_vector(a,b,n);

Here, it's probably mostly down to the memory throughput. The test used 
n=1 million, arrays of doubles, mostly containing 0.0, and calling each 
1000 times. Testing it with n=1000, and 1 million iterations to keep 
everything in-cache, then the in-place version was 20% faster.)

-- 
bartc

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


Thread

C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 13:01 +0000
  Re: C Compilers QoI mark.bluemel@gmail.com - 2017-03-14 06:16 -0700
  Re: C Compilers QoI already5chosen@yahoo.com - 2017-03-14 06:42 -0700
  Re: C Compilers QoI "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-03-14 06:56 -0700
    Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 15:58 +0000
      Re: C Compilers QoI "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-03-14 09:22 -0700
      Re: C Compilers QoI scott@slp53.sl.home (Scott Lurndal) - 2017-03-14 16:54 +0000
        Re: C Compilers QoI supercat@casperkitty.com - 2017-03-14 10:24 -0700
          Re: C Compilers QoI scott@slp53.sl.home (Scott Lurndal) - 2017-03-14 17:58 +0000
            Re: C Compilers QoI supercat@casperkitty.com - 2017-03-14 14:12 -0700
              Re: C Compilers QoI Robert Wessel <robertwessel2@yahoo.com> - 2017-03-14 16:34 -0500
              Re: C Compilers QoI Robert Wessel <robertwessel2@yahoo.com> - 2017-03-14 17:36 -0500
                Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 23:06 +0000
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-14 16:20 -0700
              Re: C Compilers QoI antispam@math.uni.wroc.pl - 2017-03-15 02:32 +0000
                Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-15 12:49 +0000
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-15 11:56 -0700
                Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-15 23:09 +0000
                Re: C Compilers QoI scott@slp53.sl.home (Scott Lurndal) - 2017-03-16 18:17 +0000
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-16 11:47 -0700
                Re: C Compilers QoI Ian Collins <ian-news@hotmail.com> - 2017-03-17 07:50 +1300
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-16 12:59 -0700
                Re: C Compilers QoI David Brown <david.brown@hesbynett.no> - 2017-03-16 21:24 +0100
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-16 14:23 -0700
                Re: C Compilers QoI Ian Collins <ian-news@hotmail.com> - 2017-03-17 11:30 +1300
                Re: C Compilers QoI Ian Collins <ian-news@hotmail.com> - 2017-03-17 11:38 +1300
                Re: C Compilers QoI Gareth Owen <gwowen@gmail.com> - 2017-03-17 05:07 +0000
                Re: C Compilers QoI Ian Collins <ian-news@hotmail.com> - 2017-03-17 20:26 +1300
                Re: C Compilers QoI Gareth Owen <gwowen@gmail.com> - 2017-03-17 07:59 +0000
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-16 16:14 -0700
                Re: C Compilers QoI Robert Wessel <robertwessel2@yahoo.com> - 2017-03-16 22:54 -0500
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-17 09:01 -0700
                Re: C Compilers QoI Ian Collins <ian-news@hotmail.com> - 2017-03-26 14:16 +1300
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-26 14:19 -0700
                Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-26 22:43 +0100
                Re: C Compilers QoI GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-27 01:28 +0200
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-26 22:07 -0700
                Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-27 11:28 +0100
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-27 07:38 -0700
                Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-27 16:23 +0100
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-27 08:55 -0700
                Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-27 17:01 +0100
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-27 10:03 -0700
                Re: C Compilers QoI GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-27 17:58 +0200
                Re: C Compilers QoI already5chosen@yahoo.com - 2017-03-27 03:54 -0700
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-27 08:46 -0700
                Re: C Compilers QoI scott@slp53.sl.home (Scott Lurndal) - 2017-03-27 17:47 +0000
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-27 11:48 -0700
                Re: C Compilers QoI Robert Wessel <robertwessel2@yahoo.com> - 2017-03-27 15:37 -0500
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-27 14:46 -0700
                Re: C Compilers QoI Robert Wessel <robertwessel2@yahoo.com> - 2017-03-27 20:28 -0500
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-28 01:18 -0700
                Re: C Compilers QoI Robert Wessel <robertwessel2@yahoo.com> - 2017-03-28 18:24 -0500
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-29 07:40 -0700
                Re: C Compilers QoI David Brown <david.brown@hesbynett.no> - 2017-03-29 17:05 +0200
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-29 11:07 -0700
                Re: C Compilers QoI antispam@math.uni.wroc.pl - 2017-03-31 04:04 +0000
                Re: C Compilers QoI bartc <bc@freeuk.com> - 2017-03-31 10:53 +0100
                Re: C Compilers QoI Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-03-31 07:35 -0700
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-31 08:07 -0700
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-31 07:54 -0700
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-31 07:43 -0700
                Re: C Compilers QoI Ian Collins <ian-news@hotmail.com> - 2017-03-17 11:21 +1300
                Re: C Compilers QoI Ian Collins <ian-news@hotmail.com> - 2017-03-17 11:24 +1300
                Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-16 22:15 +0000
                Re: C Compilers QoI scott@slp53.sl.home (Scott Lurndal) - 2017-03-17 12:31 +0000
                Re: C Compilers QoI already5chosen@yahoo.com - 2017-03-16 15:24 -0700
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-16 16:03 -0700
                Re: C Compilers QoI scott@slp53.sl.home (Scott Lurndal) - 2017-03-17 12:39 +0000
                Re: C Compilers QoI already5chosen@yahoo.com - 2017-03-17 08:27 -0700
                Re: C Compilers QoI antispam@math.uni.wroc.pl - 2017-03-16 01:35 +0000
                Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-16 02:18 +0000
                Re: C Compilers QoI antispam@math.uni.wroc.pl - 2017-03-18 00:45 +0000
                Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-18 13:12 +0000
                Re: C Compilers QoI antispam@math.uni.wroc.pl - 2017-03-18 20:31 +0000
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-18 17:31 -0700
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-16 09:22 -0700
          Re: C Compilers QoI Nick Bowler <nbowler@draconx.ca> - 2017-03-24 16:13 +0000
            Re: C Compilers QoI supercat@casperkitty.com - 2017-03-24 12:32 -0700
              Re: C Compilers QoI Robert Wessel <robertwessel2@yahoo.com> - 2017-03-24 22:13 -0500
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-25 13:05 -0700
                Re: C Compilers QoI Robert Wessel <robertwessel2@yahoo.com> - 2017-03-27 15:44 -0500
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-27 14:51 -0700
                Re: C Compilers QoI Robert Wessel <robertwessel2@yahoo.com> - 2017-03-27 20:31 -0500
        Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 17:26 +0000
          Re: C Compilers QoI Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-15 12:02 -0500
  Re: C Compilers QoI David Brown <david.brown@hesbynett.no> - 2017-03-14 15:00 +0100
    Re: C Compilers QoI already5chosen@yahoo.com - 2017-03-14 07:36 -0700
      Re: C Compilers QoI David Brown <david.brown@hesbynett.no> - 2017-03-14 15:57 +0100
      Re: C Compilers QoI Andrey Tarasevich <andreytarasevich@hotmail.com> - 2017-03-14 08:11 -0700
        Re: C Compilers QoI BGB <cr88192@hotmail.com> - 2017-03-29 23:51 -0500
    Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 15:28 +0000
      Re: C Compilers QoI David Brown <david.brown@hesbynett.no> - 2017-03-14 21:41 +0100
  Re: C Compilers QoI Keith Thompson <kst-u@mib.org> - 2017-03-14 09:26 -0700
    Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 18:23 +0000
      Re: C Compilers QoI Keith Thompson <kst-u@mib.org> - 2017-03-14 12:05 -0700
  Re: C Compilers QoI already5chosen@yahoo.com - 2017-03-14 09:35 -0700
    Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 17:08 +0000
      Re: C Compilers QoI already5chosen@yahoo.com - 2017-03-14 10:24 -0700
        Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 17:34 +0000
        Re: C Compilers QoI already5chosen@yahoo.com - 2017-03-14 11:55 -0700
          Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 19:03 +0000
            Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 19:06 +0000
            Re: C Compilers QoI already5chosen@yahoo.com - 2017-03-14 12:10 -0700
              Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 21:14 +0000
                Re: C Compilers QoI already5chosen@yahoo.com - 2017-03-14 14:42 -0700
                Re: C Compilers QoI supercat@casperkitty.com - 2017-03-14 14:53 -0700
                Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 23:20 +0000
                Re: C Compilers QoI antispam@math.uni.wroc.pl - 2017-03-15 02:43 +0000
  Re: C Compilers QoI jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-14 19:39 +0100
    Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-14 19:10 +0000
  Re: C Compilers QoI antispam@math.uni.wroc.pl - 2017-03-14 19:29 +0000
  Re: C Compilers QoI Noob <root@127.0.0.1> - 2017-03-15 09:27 +0100
  Re: C Compilers QoI ed_davis2@yahoo.com - 2017-03-16 15:10 -0700
    Re: C Compilers QoI BartC <bc@freeuk.com> - 2017-03-16 23:19 +0000

csiph-web