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


Groups > comp.lang.forth > #59422

Re: Forth-94 vs. Forth-2012 FP data (long)

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Forth-94 vs. Forth-2012 FP data (long)
Date 2017-05-17 06:51 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2017May17.085155@mips.complang.tuwien.ac.at> (permalink)
References <2017May13.093451@mips.complang.tuwien.ac.at> <a561c81c-8478-4528-ad63-7c3524bef94c@googlegroups.com>

Show all headers | View raw


Joel Rees <joel.rees@gmail.com> writes:
>Sorry, Anton, I didn't know PICK was a Forth-94 thing, so I hadn't 
>read this until today.

I am not sure what you mean by that.  The "Forth-94" in the title
refers to the requirement that programs using FP words must work on
separate-stack systems and on combined-stack systems with any number
of cells per FP item.

>> Here's the code for the Forth-94 and Forth-2012 versions of
>> FAXPY-NOSTRIDE:
>> 
>> \ Forth-94
>> :noname depth >r 0 s>f depth r> - >r fdrop r> ; execute
>> constant FPCELLWIDTH
>> fvariable faxpy-ra \ should be a user variable
>
>Did I put this in a user variable? 

No, you used a cell-based FPICK instead.  FPICK is not a Forth-94
word, so I replaced your use of FPICK with a variable access.
Moreover, Gforth has an FPICK that uses the FP item index as input;
i.e., 1 FPICK is equivalent to FOVER; and I expect that other systems
providing FPICK work the same way.

>If we don't want to see whether the compiler does a nice job with 
>constant expressions we could do this, instead:
>
>2 CELLWIDTH * constant ra_offset
>
>(I forget what you guys call CELLWIDTH.)
>
>> : faxpy-nostride ( ra f_x f_y ucount -- )
>>     \ vy=ra*vx+vy
>>     >r 2>r faxpy-ra f! 2r> r>
>>     0 ?DO ( f_x1 f_y1 )
>>         over f@ faxpy-ra f@ f*
>
>Thus,
>
>         over f@ ra_offset sp@ + f@ f*

SP@ is not Forth-94, either.

>> So VFX works nicely for optimizing the PICKs, DUPs etc. away here,
>
>Indeed. gcc, too.

The source for the gcc faxpy code was a piece of C code (no PICKs or
DUPs), not Forth code.

>This appears to be the with-stride version in C.

Right.

>> VFX Forth-2012    
>
>080C6D78? 
>> FLD   ST             
>Factor?  

fdup

I.e., yes, it's the RA parameter.

>> ADD   [ESP], 01        
>Count the loop.

Update I.

>> ADD   [ESP+04], 01     
>Outer loop? That would be a lot of code flattening going on.

Update max_n-limit+1+i.  This, together with JNO, gives the wraparound
semantics for LOOP that is standard.

>Also, there may be cache issues when the factor is not on a stack.

The item is accessed so often that it stays in the cache.

>> But despite
>> this speedup, the result is still more than tree times slower than the
>> C code, even though the number of instructions is similar.  I.e.,
>> there is still something holding back the out-of-order CPU when
>> running the VFX code.
>
>If ST(1) is not aliased to a floating point register, I can see a good 
>reason for slowdown. I'm not sure if three times makes sense, but at 
>least double. 

ST(1) is a floating-point register.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2017: http://www.euroforth.org/ef17/

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


Thread

Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-13 07:34 +0000
  Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-13 11:16 -0700
    Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-13 11:49 -0700
      Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-13 13:38 -0700
        Re: Forth-94 vs. Forth-2012 FP data (long) mhx@iae.nl - 2017-05-13 15:08 -0700
          Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-14 00:51 -0700
          Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-14 07:32 +0000
            Re: Forth-94 vs. Forth-2012 FP data (long) mhx@iae.nl - 2017-05-14 02:46 -0700
              Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-14 14:57 +0000
                Re: Forth-94 vs. Forth-2012 FP data (long) krishna.myneni@ccreweb.org - 2017-05-15 19:11 -0700
    Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-14 08:14 +0000
  Re: Forth-94 vs. Forth-2012 FP data (long) Paul Rubin <no.email@nospam.invalid> - 2017-05-13 15:58 -0700
    Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-14 07:01 +0000
  Re: Forth-94 vs. Forth-2012 FP data (long) krishna.myneni@ccreweb.org - 2017-05-14 19:04 -0700
    Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-15 06:10 +0000
      Re: Forth-94 vs. Forth-2012 FP data (long) krishna.myneni@ccreweb.org - 2017-05-15 01:49 -0700
        Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-15 14:33 +0000
  Re: Forth-94 vs. Forth-2012 FP data (long) "HAA" <someone@microsoft.com> - 2017-05-15 13:44 +1000
    Re: Forth-94 vs. Forth-2012 FP data (long) Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-15 04:43 -0500
    Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-15 15:03 +0000
      Re: Forth-94 vs. Forth-2012 FP data (long) "HAA" <someone@microsoft.com> - 2017-05-17 00:10 +1000
  Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-16 09:04 -0700
    Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-17 15:54 +0000
      Re: Forth-94 vs. Forth-2012 FP data (long) mhx@iae.nl - 2017-05-17 10:29 -0700
      Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-17 23:53 -0700
        Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-19 02:34 -0700
  Re: Forth-94 vs. Forth-2012 FP data (long) Joel Rees <joel.rees@gmail.com> - 2017-05-16 22:48 -0700
    Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-17 06:51 +0000
      Re: Forth-94 vs. Forth-2012 FP data (long) Joel Rees <joel.rees@gmail.com> - 2017-05-17 09:29 -0700
    Re: Forth-94 vs. Forth-2012 FP data (long) stephen@mpeforth.com (Stephen Pelc) - 2017-05-17 11:07 +0000
      Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-17 15:02 +0000

csiph-web