programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: Fpmath.f with Hardward Stack

From: Bill McCarthy <WJMc_at_pobox.com>
Date: Wed, 21 Nov 2001 23:34:43 -0500

On 11/16/2001 at 6:45 PM, Rick VanNorman wrote:

> I've been looking and thinking. I believe I know the
> answer to the problem, but you probably won't like it.

  <forth and c code snipped>

> The issue is the Forth-ness of things: with the hardware
> stack, floating point numbers are being left on the chip
> during API calls of all sorts. In the C code, the expression
> loads the hardware stack from variables, performs the
> calculation, and stores the variables from the hardware
> stack before continuing. I have disassembled quite a bit
> of C code now looking at this and it is universally the case.
> The C compilers guarantee that there is no lingering data
> on the hardware stack anytime an API call is made. This
> also explains why the software stack version works -- nothing
> is left on the hardware stack during context changes.

The C code (from GCC MingW32) is very tight. Here's the
disassembly of the loop from the exe produced:

           X$14:
   DC C9 fmul st(1),st
   49 dec ecx
   79 FB jns X$14

Those 5 bytes are repeated a billion times in the test. I
assume you mean that the C startup code sets up to receive a
signal whenever focus is taken away or given - so it can
save or restore the FP stack.

The public domain forths I have use software stacks. The
trial version of VFX Forth, however, uses the HW stack (in
its Ndp387.fth). I've been testing it all evening and I
can't get it to fail. Of course I could be wrong, but this
instability doesn't appear to be in the "Forth-ness of
things" but in the SwiftForth-ness of things :)

I just received the trial copy of VFX Forth last night. I
ran this billion floating point calculation loop with HW and
SW stack versions of that system. I also ran the C code
version with my two compilers (both use HW stacks). Also I
ran the forth code on two public domain forts: Gforth (and
Gforth-fast) and Win32Forth (both use SW stacks).

With SwiftForth, I ran both the HW and SW versions and my
own modification of Fpmath.f, which inlines many of the FP
code words when HW stack is selected.

The only failures I could get were with the HW stack on
SwiftForth. The software stack version was stable by the
timing was not impressive.

Here's the timing results in seconds, sorted from fastest to
slowest.

   GCC MingW32 6.4
   SwiftForth HW Stack* 8.6
   VFX Forth HW Stack 8.7
   Watcom C 8.9
   SwiftForth HW Stack 15.2
   Gforth-fast 24.0
   VFX Forth SW Stack 36.1
   Gforth 38.1
   Win32Forth 41.8
   SwiftForth SW Stack 121.5

   * Fpmath with inlining

Bill

----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe sftalk" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/sftalk -- check them out!
Search the archives! Visit http://www.forth.com/search for details.
Received on Wed Nov 21 2001 - 20:34:09 PST

This archive was generated by hypermail 2.2.0 : Fri Nov 21 2008 - 03:04:20 PST