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


Groups > comp.lang.forth > #59586

Re: matrix multiplication

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: matrix multiplication
Date 2017-05-20 10:21 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2017May20.122135@mips.complang.tuwien.ac.at> (permalink)
References <de96ca50-66d1-4518-a2a5-103dac0bebfb@googlegroups.com> <39defc56-99d0-42d7-8242-c16df26ca409@googlegroups.com> <2017May19.171325@mips.complang.tuwien.ac.at> <2017May19.192659@mips.complang.tuwien.ac.at>

Show all headers | View raw


anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>Results for a 500x500 matrix multiply on a Core i5-6600K:
>>
>>Forth-94 Forth-2012 Forth-2012 Forth-94 Forth-94 
>>Myneni  Myneni/Ertl     Ertl   Rees/Ertl   pahihu 
>>109966M     107831M    1046M       1202M    1517M vfxlin Ndp387.fth
>>  2986M       2260M    2220M       2945M    2764M gforth-fast
>>  4028M       4076M    4844M       5067M    5017M SwiftForth HW stack, no WAIT
>>
>>I don't know what in this code slows down VFX so much.

Found it.  The problem was that my benchmark uses FLOATS/FLOAT+, while
Krishna Myneni's code uses DFLOATS/DFLOAT+.  This worked ok on Gforth
and SwiftForth where floats and dfloats have the same size, but on VFX
the sizes are different, so the FP items processed by the matrix
multiplication code were not the intended FP items.  My guess is that
a significant number of them were denormal numbers and other
exceptional cases that are not processed fast by the FPU.

I fixed it by converting Krishna Myneni's code to use FLOATS and
FLOAT+, and voila:

Forth-94 Forth-2012 F-2012 Forth-2012 Forth-94 Forth-94 
Myneni  Myneni/Ertl Myneni+   Ertl   Rees/Ertl   pahihu 
  1770M       1252M  1170M   1046M       1202M    1517M vfxlin Ndp387.fth
  2986M       2260M  2152M   2220M       2945M    2764M gforth-fast
  4028M       4076M  4077M   4844M       5067M    5017M SwiftForth ...

The Myneni+ variant adds Stephen Pelc' suggestion of using SWAP FLOAT+
SWAP instead of >R FLOAT+ R>.

- 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

matrix multiplication krishna.myneni@ccreweb.org - 2017-05-17 15:13 -0700
  Re: matrix multiplication stephen@mpeforth.com (Stephen Pelc) - 2017-05-17 22:31 +0000
    Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-17 15:39 -0700
      Re: matrix multiplication rickman <gnuarm@gmail.com> - 2017-05-18 03:22 -0400
        Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-18 00:29 -0700
          Re: matrix multiplication rickman <gnuarm@gmail.com> - 2017-05-18 03:48 -0400
          Re: matrix multiplication anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-18 08:42 +0000
  Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-18 00:25 -0700
    Re: matrix multiplication anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-19 15:13 +0000
      Re: matrix multiplication anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-19 17:26 +0000
        Re: matrix multiplication Alex <alex@rivadpm.com> - 2017-05-19 18:56 +0100
        Re: matrix multiplication Paul Rubin <no.email@nospam.invalid> - 2017-05-19 21:48 -0700
        Re: matrix multiplication anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-20 10:21 +0000
          Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-20 06:12 -0700
          Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-20 09:47 -0700
            Re: matrix multiplication Paul Rubin <no.email@nospam.invalid> - 2017-05-20 15:31 -0700
              Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-21 04:46 -0700
                Re: matrix multiplication mhx@iae.nl - 2017-05-21 13:41 -0700
                Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-21 15:32 -0700
            Re: matrix multiplication anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-21 07:19 +0000
              Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-21 05:10 -0700
                Re: matrix multiplication anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-21 14:29 +0000
                Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-21 09:17 -0700
      Re: matrix multiplication stephen@mpeforth.com (Stephen Pelc) - 2017-05-19 20:54 +0000
      Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-19 14:33 -0700
        Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-19 16:12 -0700
        Re: matrix multiplication anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-20 14:48 +0000
    Re: matrix multiplication krishna.myneni@ccreweb.org - 2017-05-19 18:38 -0700

csiph-web