Document:         MMXspeed.txt
File Group:       Classic Benchmarks
Creation Date:    30 September 1997
Revision Date:    14 October 1997

Title:            MMX Instruction Speed Tests
Keywords:         BENCHMARK PERFORMANCE MMX  

Abstract:         This document contains details of pre-compiled C
                  programs that measure MMX instruction execution speeds.
                  Windows 95/NT, OS/2 and DOS versions are supplied. The
                  main purposes are to identify that MMX facilities are
                  available and to produce performance ratings that can
                  be used for broad non-application dependent comparisons. 

Note:             The programs are still under test and should be treated
                  as beta test software.  Please submit feedback directly
                  to Roy, or as a posting in Section 12 message board.

                  The programs have been tested via Windows 95, DOS and
                  OS/2 Warp 3 on a PC with a 200 MHz Intel MMX CPU.

Contributor:      Roy_Longbottom@compuserve.com

Changes           The DOS version is now 1.1. Version 1 was found to
                  be slow when running with extended parameters.
 

MMX INSTRUCTION SPEED TESTS

0.  SUMMARY

The tests were compiled using Watcom C/C++ 11 which has MMX facilities. The 
program runs five pairs of routines containing MMX instructions compare, 
multiply/add, pack, shift and or. The pairs comprise one using standard 
Watcom macros and one with extended macros that contain far more MMX 
instructions. A final test, with less dependency on cache/memory speeds, 
executes all MMX instructions. Speed ratings in terms of Millions of 
Operations Per Second (MOPS) are produced and data transfer rates in 
MegaBytes per Second (MB/S). The latter can be compared with MEMSPEED 
results. The default version uses 8 KB of memory to fit within a L1 cache 
but run time parameters can be used to force data transfers from L2 cache 
or RAM. Running time should be less than two minutes for the default 
version but can be longer with larger memory demands. The program uses a 
Watcom function to detect whether MMX features are available and, where 
not, an appropriate message is displayed. Note that this facility did
not work on a Cyrix CPU but produced a system generated invalid operation 
code message.

Pre-compiled versions MMXNT95.EXE, MMXOS2.EXE and MMXDOS.EXE are provided 
for Windows 95 or NT, OS/2 and MS DOS. Windows 3.1 users can run the DOS 
version. Results are displayed as the program is running and saved in file 
MMXRES.TXT which should appear in the same directory as the EXE files. A 
run time option allows a user defined log file to be used as an 
alternative. The DOS version requires DOS4GW.EXE the protected run-time 
program.

Before running, all other applications should be closed. To run, click on 
the appropriate EXE icon or enter the program name (and optional run time 
parameters) at the command prompt. The most consistent speed measurements 
are likely to be produced when the PC is booted directly with DOS.

Results should be sent to Roy_Longbottom@compuserve.com and details of the 
system under test should be included. The configuration details can be 
provided via program SYSTEMxx.EXE as supplied with the Classic Benchmarks. 


1.  INTRODUCTION

With the introduction of MMX CPU instructions, it was considered 
appropriate to produce a simple synthetic benchmark to complement the 
Classic Benchmarks and other performance tests in the Library.

After reading various reports indicating that assembly language programming 
was necessary to obtain the best performance via MMX and noting that 
compilers were available with MMX capabilities, firstly, I upgraded my 
Watcom compiler to Version 11 which has the new facilities. After some 
experimentation, I decided to include the following in the benchmark:

  1. identification whether MMX facilities are in a particular CPU; 

  2. use of standard compiler facilities;

  3. using the in-line assembler to produce enhanced performance;

  4. measurement of a range of different functions;

5. production of execution speeds where some comparison with speed
   via conventional instructions might be possible;

  6. production of data transfer rates that can be compared with
     those from the memory speed test (MEMSPEED);

  7. producing a default version using data in L1 cache for maximum
     speed;

  8. inclusion of optional run time parameters for a user defined log
     file and data in L2 cache or RAM.


2.  MMX INSTRUCTIONS

There are more than 40 MMX instructions for load, pack/unpack, 
add/subtract/multiply, or/and/xor, shift right/left, compare and control. 
These operate on eight 64 bit registers (mm0 to mm7). Some execute in the 
conventional manner on all 64 bits. Others use Single Instruction Multiple 
Data (SIMD) operation, executing the same type of instruction on 2, 4 or 8 
independent sets of data (32 bits, 16 bits or 8 bits long). Examples used 
in the benchmark are described later.

  
3.  PROGRAM DETAILS

The program manipulates two data arrays a[] and b[] each declared as 131072 
(128K) elements of 64 bits but only 512 elements (2 x 4 Kbytes) are used 
with the default parameters to try to ensure that data is in the L1 cache 
for maximum speed of operation.

MMX facilities in the compiler are in the form of macros. Assembly code for 
the first one used is:

              #pragma aux (__m_binary) _m_pcmpeqb =	\
                     ".586"			\
                     "movq      mm0,[eax]"	\
                     "movq      mm1,[edx]"	\
                     "pcmpeqb   mm0,mm1"	\
                     "movq      [esi],mm0"	

The two movq instructions load the input data into registers mmo and mm1. 
The pcmpeqb instruction compares each byte independently for equal. If the 
respective bytes of m1 are equal to the respective bytes of m0, the 
respective bytes of the result m0 are set to all ones, otherwise they are 
set to all zeros. The last movq returns the result.


TEST LOOP 1

With associated overheads of calling such routines, performance 
expectations are relatively poor. To minimise further overheads due to loop 
control, the loops in the C++ program are partially unrolled with the 
following format for timing purposes:


            timea = millisecs();
            
            for (i=0; i<n3; i++)
              {
                for (m=0; m<ki; m=m+4)
                 {
                    a[m  ] =   _m_pcmpeqb( a[m  ], b[m  ]); 
                    a[m+1] =   _m_pcmpeqb( a[m+1], b[m+1]);
                    a[m+2] =   _m_pcmpeqb( a[m+2], b[m+2]);
                    a[m+3] =   _m_pcmpeqb( a[m+3], b[m+3]);
                 }
              }
        
             _m_empty();
            
             timeb = millisecs() - timea;

The n3 value is adjusted via calibration to produce an execution time of 
about 5 seconds. The default value of ki is 512. The _m_empty macro is 
executed to switch off MMX operation to allow the 64 bit registers to be 
used for normal floating point operation.

Loops 3, 5, 7 and 9 have the same format.

TEST LOOP 2

In order to speed up operations, the inner loop is given an 8 word 
increment with one call to an extended macro. This loads the eight MMX 
registers with values from a[], values from b[] are loaded and compared 
with the results stored to a[]. As can be seen from the results, this can 
produce a speed up factor of more than six times, compared with loop 1.


            for (i=0; i<n3; i++)
              {
                for (m=0; m<ki; m=m+8)
                 {
                     cmpb8toa( a[m  ], b[m  ]);
                 }   
              }


         #pragma aux (__m_binary) cmpb8toa =   \
              ".586"                   \
              "movq    mm0,[eax]"      \
              "movq    mm1,[eax+8]"    \
              "movq    mm2,[eax+16]"   \
              "movq    mm3,[eax+24]"   \
              "movq    mm4,[eax+32]"   \
              "movq    mm5,[eax+40]"   \
              "movq    mm6,[eax+48]"   \
              "movq    mm7,[eax+56]"   \        
              "pcmpeqb mm0,[edx]"      \
              "pcmpeqb mm1,[edx+8]"    \
              "pcmpeqb mm2,[edx+16]"   \
              "pcmpeqb mm3,[edx+24]"   \
              "pcmpeqb mm4,[edx+32]"   \
              "pcmpeqb mm5,[edx+40]"   \
              "pcmpeqb mm6,[edx+48]"   \
              "pcmpeqb mm7,[edx+56]"   \            
              "movq    [eax],mm0"      \
              "movq    [eax+8],mm1"    \
              "movq    [eax+16],mm2"   \
              "movq    [eax+24],mm3"   \
              "movq    [eax+32],mm4"   \
              "movq    [eax+40],mm5"   \
              "movq    [eax+48],mm6"   \
              "movq    [eax+56],mm7" 


Loops 4, 6 and 8 have the same format.


LOOPS 3 and 4

These use the multiply and add instruction pmaddwd. For this, the signed 
16-bit words of m1 are multiplied with the respective signed 16-bit words 
of m2.  The 32-bit intermediate results are summed by pairs producing two 
32-bit integers.

           MM[63-32] = M1[63-48] x M2[63-48]
                     + M1[47-32] x M2[47-32]
           MM[31-0]  = M1[31-16] x M2[31-16]
                     + M1[15-0]  x M2[15-0]


LOOPS 5 and 6

These use the pack bytes instruction packuswb.

Convert signed packed words into unsigned packed bytes by packing (with 
unsigned saturation) the low-order bytes of the signed word elements from 
m1 and m2 into the respective unsigned bytes of the result.  If the signed 
values in the word elements of m1 and m2 are too large to be represented in 
an unsigned byte, the result elements are clamped to 0xff.

      
                 m2                         m1
     -------------------------  -------------------------

     |b7 b6|b5 b4|b3 b2|b1 b0|  |b7 b6|b5 b4|b3 b2|b1 b0|
     -------------------------  -------------------------
        |     |     |     |        |     |     |     |
        |     |     |     `--.  .--'     |     |     |
        |     |     `-----.  |  |  .-----'     |     |
        |     `--------.  |  |  |  |  .--------'     |
        `-----------.  |  |  |  |  |  |  .-----------'
                    |  |  |  |  |  |  |  |
                    V  V  V  V  V  V  V  V
                   -------------------------
                   |b7|b6|b5|b4|b3|b2|b1|b0|
                   -------------------------
                          result


LOOPS 7 and 8

These use the shift right macro psrawi (psraw instruction). For this, the 
16-bit signed words in m are each independently shifted to the right by the 
scalar shift count. The high-order bits of each element are filled with the 
initial value of the sign bit of each element. The particular format used 
in test 8 uses a constant shift value ( psraw    mm0,15 etc.).

Whereas the previous tests load 16 bytes and effectively execute 8 
instructions per operation, this loads 8 bytes and effectively executes 4 
instructions.


LOOPS 9 and 10

These use the or instruction por which executes a bit-wise logical OR 
between 64-bit operands. This could be interpreted as the equivalent of 
eight single byte OR instructions or two of 32 bits.


LOOP 11

This extended macro executes 42 register to register instructions (all that 
can use this format, I think). For these, the average MMX instruction 
executes the equivalent of about 4.5 conventional instructions.

As shown in the results, the 200 MHz MMX Pentium achieves more that 210 
million operations per second which could be said to equate to around 950 
million conventional operations per second.


4.  DISPLAYED RESULTS

When the program is running, the results are displayed using the following 
format. The MOPS calculations are derived from Passes (outer loop) x Array 
Dimension (inner loop) / 1,000,000 / Run Time Seconds. The megabytes per 
second (MB/S) column is calculated as MOPS x bytes read (16, 8 psrawi). The 
eight bytes written are not included.

The following is for a home built PC with a Pentium MMX 200 MHz CPU, 
Micronics TX mainboard, 32 MB SDRAM and 512 KB pipeline burst cache, via 
Windows 95, running MMXNT95.EXE.


       MMX Speed Test Win95/NT Version 1 Tue Sep 30 10:06:05 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 512 64 bit words x 2, log file MMXres.txt

Test                        Passes   Secs     MOPS     MB/S    Result

Compare bytes pcmpeqb  M     80000   4.88     8.39    134.3  ff0000ff
Compare bytes pcmpeqb  E    495867   4.89    51.92    830.7  ff0000ff
Multiply add  pmaddwd  M     78048   5.17     7.73    123.7  00000020
Multiply add  pmaddwd  E    506756   4.95    52.42    838.7  00000020
Pack bytes    packuswb M     81632   5.00     8.36    133.7  efffff00
Pack bytes    packuswb E    506756   4.95    52.42    838.7  efffff00
Shift right   psrawi   M     90140   4.95     9.32     74.6  ffffffff
Shift right   psrawi   E    528169   4.95    54.63    437.0  ffffffff
Or 64 bits    por      M     83116   5.00     8.51    136.2  fff0f0ff
Or 64 bits    por      E    506756   4.94    52.52    840.4  fff0f0ff
42 ops plus moves      E     48854   4.95   212.23           ffffffff


The following is via MMXDOS.EXE on the same PC with a clean boot via DOS 
6.2. Except for the first loop, which is probably influenced by initial 
cache set up, other results are slightly faster due to not having 
interference from the Operating System. 


       MMX Speed Test DOS Version 1 Tue Sep 30 10:48:49 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 512 64 bit words x 2, log file MMXres.txt

Test                        Passes   Secs     MOPS     MB/S    Result

Compare bytes pcmpeqb  M     80808   4.95     8.36    133.7  ff0000ff
Compare bytes pcmpeqb  E    524475   5.05    53.17    850.8  ff0000ff
Multiply add  pmaddwd  M     78048   5.11     7.82    125.1  00000020
Multiply add  pmaddwd  E    521739   5.06    52.79    844.7  00000020
Pack bytes    packuswb M     81632   4.95     8.44    135.1  efffff00
Pack bytes    packuswb E    506756   4.89    53.06    848.9  efffff00
Shift right   psrawi   M     93430   5.11     9.36     74.9  ffffffff
Shift right   psrawi   E    521739   4.84    55.19    441.5  ffffffff
Or 64 bits    por      M     80808   4.83     8.57    137.1  fff0f0ff
Or 64 bits    por      E    506756   4.89    53.06    848.9  fff0f0ff
42 ops plus moves      E     50393   5.05   214.58           ffffffff



The following is via MMXOS2.EXE and OS/2 Warp 3, showing a similar 
variation in results to Windows 95.


       MMX Speed Test OS/2 Version 1 Tue Sep 30 10:52:40 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 512 64 bit words x 2, log file MMXres.txt

Test                        Passes   Secs     MOPS     MB/S    Result

Compare bytes pcmpeqb  M     80000   4.94     8.29    132.7  ff0000ff
Compare bytes pcmpeqb  E    510204   5.00    52.24    835.9  ff0000ff
Multiply add  pmaddwd  M     75471   5.00     7.73    123.7  00000020
Multiply add  pmaddwd  E    520833   5.12    52.08    833.3  00000020
Pack bytes    packuswb M     82474   5.03     8.39    134.3  efffff00
Pack bytes    packuswb E    500000   5.03    50.89    814.3  efffff00
Shift right   psrawi   M     90909   5.00     9.31     74.5  ffffffff
Shift right   psrawi   E    531914   5.06    53.82    430.6  ffffffff
Or 64 bits    por      M     82474   5.00     8.45    135.1  fff0f0ff
Or 64 bits    por      E    490196   4.81    52.18    834.9  fff0f0ff
42 ops plus moves      E     48854   4.94   212.66           ffffffff



5.  RESULTS FILE

Results are appended to file MMXRES.TXT which should appear in the same 
directory as the EXE file. The results are in the same format as above.


6.  RUNNING INSTRUCTIONS

The programs can be run by clicking on the icon for the EXE file and by 
executing MMXDOS.EXE, MMXNT95.EXE or MMXOS2.EXE from a command line prompt. 
If MMX facilities are not available the program should display:


       MMX Speed Test DOS Version 1 Tue Sep 30 10:48:49 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 512 64 bit words x 2, log file MMXres.txt

        Program will not run. MMX facilities not detected.

                  Press any key to close.

The detection facility appears to work with Intel processors but the 
program stopped with a system generated invalid operation code indication 
when run on a Cyrix CPU. 


7.  OPTIONAL RUN TIME PARAMETERS

One to three run time parameters can be included in the command that 
executes the program with the following format:

                  MMXxxxx CN 
                  MMXxxxx CN LF 
            or    MMXxxxx CN LF DIM

 Where MMXxxxx is the EXE file name   MMXNT95, MMXDOS or MMXOS2

       CN       = C or Close (default) to close Window at end
            or    N or NoClose don't close, leave display

       LF       = user defined log file, default MMXRES.TXT

       DIM      = array dimension (64 bits each), default and
                  minimum value 512, maximum 131072 to use 2 MB 
                  of memory.

Examples using default parameters and others are:

              MMXNT95 Close MMXres.txt 512

              MMXNT95 Close MyLog.doc 1024

              MMXNT95 NoClose Biglog 131072

These commands can also be included in a BAT file (CMD file OS/2). This is 
useful for multiple runs with different array dimensions or where the 
preference is to click on icons but use alternative parameters.

A BAT file with the following commands was used to produce the results in 
Appendix 1:

         MMXNT95 Close MMXmany.txt 1000
         MMXNT95 Close MMXmany.txt 2000
         MMXNT95 Close MMXmany.txt 4000
         MMXNT95 Close MMXmany.txt 8000
         MMXNT95 Close MMXmany.txt 16000
         MMXNT95 Close MMXmany.txt 32000
         MMXNT95 Close MMXmany.txt 64000
         MMXNT95 Close MMXmany.txt 128000
 

8.  HELP FACILITY

If the program is executed with the wrong first parameter (e.g. MMXNT95 x - 
or ? /h etc.), the parameter options are displayed, plus an example set of 
results as above.



9. SUBMITTING RESULTS

Results should be sent to Roy_Longbottom@compuserve.com and the following 
information on the system under test should be included.

               PC Supplier/model 
               CPU chip           
               Clock MHz        
               Cache size           
               Chipset & H/W Options  (including RAM size and type)
               OS/DOS version       
               Run by (name)        
               Company/Location 
               E-Mail address 

The configuration details can be provided via program SYSTEMxx.EXE as 
supplied with the Classic Benchmarks. 


APPENDIX 1 RESULTS WITH INCREASING MEMORY DEMANDS

The following results use  16000, 32000, 64000, 128000, 256000, 512000, 
1024000 and 2048000 bytes for data to show the effects on performance of 
exceeding the L1 cache (16 KB) and L2 cache (512 KB) capacity. The MB/S 
figures can be compared with those obtained via MEMSPEED (MDTRNT95.EXE). 
See later for sample MEMSPEED results on the same PC.


       MMX Speed Test Win95/NT Version 1 Tue Sep 30 14:59:14 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 1000 64 bit words x 2, log file MMXmany.txt

Test                        Passes   Secs     MOPS     MB/S    Result

Compare bytes pcmpeqb  M     40251   4.89     8.23    131.7  ff0000ff
Compare bytes pcmpeqb  E    247933   5.05    49.10    785.5  ff0000ff
Multiply add  pmaddwd  M     39024   5.11     7.64    122.2  00000020
Multiply add  pmaddwd  E    247933   5.11    48.52    776.3  00000020
Pack bytes    packuswb M     41558   5.00     8.31    133.0  efffff00
Pack bytes    packuswb E    247933   5.11    48.52    776.3  efffff00
Shift right   psrawi   M     46376   4.99     9.29     74.4  ffffffff
Shift right   psrawi   E    272727   4.95    55.10    440.8  ffffffff
Or 64 bits    por      M     41558   4.99     8.33    133.3  fff0f0ff
Or 64 bits    por      E    247933   5.10    48.61    777.8  fff0f0ff
42 ops plus moves      E     25396   5.00   213.33           ffffffff

       MMX Speed Test Win95/NT Version 1 Tue Sep 30 15:00:36 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 2000 64 bit words x 2, log file MMXmany.txt

Test                        Passes   Secs     MOPS     MB/S    Result

Compare bytes pcmpeqb  M     13223   4.78     5.53     88.5  ff0000ff
Compare bytes pcmpeqb  E     27272   5.00    10.91    174.5  ff0000ff
Multiply add  pmaddwd  M     13913   5.17     5.38     86.1  00000020
Multiply add  pmaddwd  E     27522   5.00    11.01    176.1  00000020
Pack bytes    packuswb M     13913   4.95     5.62     89.9  efffff00
Pack bytes    packuswb E     27272   5.00    10.91    174.5  efffff00
Shift right   psrawi   M     23357   5.05     9.25     74.0  ffffffff
Shift right   psrawi   E    130434   5.00    52.17    417.4  ffffffff
Or 64 bits    por      M     14545   5.16     5.64     90.2  fff0f0ff
Or 64 bits    por      E     27272   4.99    10.93    174.9  fff0f0ff
42 ops plus moves      E     12598   4.99   212.07           ffffffff

       MMX Speed Test Win95/NT Version 1 Tue Sep 30 15:01:53 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 4000 64 bit words x 2, log file MMXmany.txt

Test                        Passes   Secs     MOPS     MB/S    Result

Compare bytes pcmpeqb  M      7272   5.22     5.57     89.2  ff0000ff
Compare bytes pcmpeqb  E     14423   5.28    10.93    174.8  ff0000ff
Multiply add  pmaddwd  M      6464   4.78     5.41     86.5  00000020
Multiply add  pmaddwd  E     13636   4.94    11.04    176.7  00000020
Pack bytes    packuswb M      7356   5.28     5.57     89.2  efffff00
Pack bytes    packuswb E     13636   4.94    11.04    176.7  efffff00
Shift right   psrawi   M     10000   4.99     8.02     64.1  ffffffff
Shift right   psrawi   E     21897   5.00    17.52    140.1  ffffffff
Or 64 bits    por      M      7272   5.16     5.64     90.2  fff0f0ff
Or 64 bits    por      E     13636   4.94    11.04    176.7  fff0f0ff
42 ops plus moves      E      5818   5.05   193.55           ffffffff

       MMX Speed Test Win95/NT Version 1 Tue Sep 30 15:03:11 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 8000 64 bit words x 2, log file MMXmany.txt

Test                        Passes   Secs     MOPS     MB/S    Result

Compare bytes pcmpeqb  M      3440   5.11     5.39     86.2  ff0000ff
Compare bytes pcmpeqb  E      6465   4.89    10.58    169.2  ff0000ff
Multiply add  pmaddwd  M      3265   4.95     5.28     84.4  00000020
Multiply add  pmaddwd  E      6521   5.00    10.43    166.9  00000020
Pack bytes    packuswb M      3404   4.94     5.51     88.2  efffff00
Pack bytes    packuswb E      6521   5.00    10.43    166.9  efffff00
Shift right   psrawi   M      5039   5.05     7.98     63.9  ffffffff
Shift right   psrawi   E     11363   5.22    17.41    139.3  ffffffff
Or 64 bits    por      M      3404   4.94     5.51     88.2  fff0f0ff
Or 64 bits    por      E      6521   5.00    10.43    166.9  fff0f0ff
42 ops plus moves      E      2935   5.06   194.89           ffffffff

       MMX Speed Test Win95/NT Version 1 Tue Sep 30 15:04:27 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 16000 64 bit words x 2, log file MMXmany.txt

Test                        Passes   Secs     MOPS     MB/S    Result

Compare bytes pcmpeqb  M      1616   5.11     5.06     81.0  ff0000ff
Compare bytes pcmpeqb  E      2976   5.05     9.43    150.9  ff0000ff
Multiply add  pmaddwd  M      1616   5.16     5.01     80.2  00000020
Multiply add  pmaddwd  E      2976   5.06     9.41    150.6  00000020
Pack bytes    packuswb M      1632   5.00     5.22     83.6  efffff00
Pack bytes    packuswb E      2840   4.83     9.41    150.5  efffff00
Shift right   psrawi   M      2424   5.05     7.68     61.4  ffffffff
Shift right   psrawi   E      4870   4.94    15.77    126.2  ffffffff
Or 64 bits    por      M      1616   5.00     5.17     82.7  fff0f0ff
Or 64 bits    por      E      2976   5.05     9.43    150.9  fff0f0ff
42 ops plus moves      E      1467   5.06   194.83           ffffffff

       MMX Speed Test Win95/NT Version 1 Tue Sep 30 15:05:40 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 32000 64 bit words x 2, log file MMXmany.txt

Test                        Passes   Secs     MOPS     MB/S    Result

Compare bytes pcmpeqb  M       769   5.00     4.92     78.7  ff0000ff
Compare bytes pcmpeqb  E      1394   5.00     8.92    142.7  ff0000ff
Multiply add  pmaddwd  M       769   5.11     4.82     77.1  00000020
Multiply add  pmaddwd  E      1394   5.00     8.92    142.7  00000020
Pack bytes    packuswb M       808   5.11     5.06     81.0  efffff00
Pack bytes    packuswb E      1425   5.05     9.03    144.5  efffff00
Shift right   psrawi   M      1221   5.11     7.65     61.2  ffffffff
Shift right   psrawi   E      2435   4.95    15.74    125.9  ffffffff
Or 64 bits    por      M       808   5.16     5.01     80.2  fff0f0ff
Or 64 bits    por      E      1388   4.94     8.99    143.9  fff0f0ff
42 ops plus moves      E       695   4.95   188.70           ffffffff

       MMX Speed Test Win95/NT Version 1 Tue Sep 30 15:06:55 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 64000 64 bit words x 2, log file MMXmany.txt

Test                        Passes   Secs     MOPS     MB/S    Result

Compare bytes pcmpeqb  M       297   4.95     3.84     61.4  ff0000ff
Compare bytes pcmpeqb  E       750   8.13     5.90     94.5  ff0000ff
Multiply add  pmaddwd  M       296   5.05     3.75     60.0  00000020
Multiply add  pmaddwd  E       750   8.19     5.86     93.8  00000020
Pack bytes    packuswb M       304   5.00     3.89     62.3  efffff00
Pack bytes    packuswb E       750   8.13     5.90     94.5  efffff00
Shift right   psrawi   M       563   5.00     7.21     57.7  ffffffff
Shift right   psrawi   E      1035   5.06    13.09    104.7  ffffffff
Or 64 bits    por      M       304   4.99     3.90     62.4  fff0f0ff
Or 64 bits    por      E       750   8.13     5.90     94.5  fff0f0ff
42 ops plus moves      E       316   5.00   169.88           ffffffff

       MMX Speed Test Win95/NT Version 1 Tue Sep 30 15:08:22 1997
                 Copyright (C) 1997, Roy Longbottom

  Via Watcom Version 11, M = Standard Macros, E = Extended Macros

   Array Dimensions 128000 64 bit words x 2, log file MMXmany.txt

Test                        Passes   Secs     MOPS     MB/S    Result

Compare bytes pcmpeqb  M       160   5.71     3.59     57.4  ff0000ff
Compare bytes pcmpeqb  E       750  19.01     5.05     80.8  ff0000ff
Multiply add  pmaddwd  M       160   6.26     3.27     52.3  00000020
Multiply add  pmaddwd  E       750  18.94     5.07     81.1  00000020
Pack bytes    packuswb M       160   6.10     3.36     53.7  efffff00
Pack bytes    packuswb E       750  19.06     5.04     80.6  efffff00
Shift right   psrawi   M       234   4.94     6.06     48.5  ffffffff
Shift right   psrawi   E       750   9.78     9.82     78.5  ffffffff
Or 64 bits    por      M       160   6.04     3.39     54.3  fff0f0ff
Or 64 bits    por      E       750  19.00     5.05     80.8  fff0f0ff
42 ops plus moves      E       160   5.88   146.29           ffffffff


The following shows memory throughput megabytes per second for the compare 
function via MMXNT95 and MDTRNT95 (MEMSPEED) on the same 200 MHz MMX, SDRAM 
PC. The C code used for MMXSPEED is similar to that for the last three 
columns. With integer operations, the MMX functions clearly uses a higher 
bandwidth when data is in L1 cache. Again for the last column and L1 cache 
results, normal integer calculations execute one arithmetic operation per 8 
bytes read whereas the MMX has an effective execution rate of one operation 
per 2 bytes read. Taking into account MB/S, this suggests that certain 
operations using small numbers might be eight times faster with MMX. 

         MMXSPEED                     MEMSPEED

            MMX        s=s+x[m]*y[m]          x[m]=x[m]+y[m]
    1000 pcmpeqb               Int +y[m]
   Bytes 64 bits    Dble    Sngl     Int    Dble    Sngl     Int
    Used    MB/S    MB/S    MB/S    MB/S    MB/S    MB/S    MB/S

       4     N/A     562     301     351     655     332     406  L1
       8     831     572     302     351     664     333     406
      16     785     533     293     340     628     324     391
      32     175     234     169     192     157     162     157  L2
      64     175     183     164     191     132     158     156
     128     169     179     157     185     130     152     152
     256     151     188     140     146     135     133     120
     512     143     164     119     132     121     112     110
    1024      95     123     102     109      94      93      88  RAM
    2048      81     114      95     102      88      85      82
