Processors tests (floating point)

Sine function Some tests are performed on many different processors from 8086 to modern CPU's. The initial purpose of the tests is the evaluation of my own compiler. But it is only integer tests. Here simple floating point tests presented. They are very simple and may be performed even on many programmable calculators. They calculates the area under half the period of the sine function by using rectangle method, the simplest method of integration.

MS DOS version of my own compiler implements double precision arithmetic on 8087 FPU unit. It also used.

On some systems number of intervals (N) reduced to 106 - 101 and the time is multiplied by 107 /  N. Nubmer of signs after decimal point may be greater than time measurement accuracy.

For calculations with single precision (Real*4) N = 107 is too large and the error of the result is significant (2.023 instead of 2.0), but here the time is determined, not the area.

Sine function calculated by FPU/library call and sum of Maclaurin series. Floating point arithmetic are performed by FPU/library calls and self-written software implementation (possible inefficient).

GCC or BCC compilers are used. On some old compters built-in Basic interpreter are used. It is incorrect to compare the speed of compiled and interpreted code. On new machines the difference can be hundreds of times, on old machines it is much less - from two to five times. This is true for floating point calculations only, for integer calculations the difference are much more.

Thanks to the Yandex Museum for the opportunity to use some old computers - IBM 5150, Apple//e, Sinclair ZX81 and some others.

Source code for first two columns (FPU/Lib and Soft-sin):

#include <stdio.h>
#include <math.h>


#ifdef  REAL8

typedef double real;
#define ERR 1E-16

#else

typedef float  real;
#define ERR 1E-8

#endif


real sin2(real x)
{
  real s = x;
  real a = x;
  real y = x * x;
  real n = 1;
  do
  {
    a    =-a * y / ((n + 1) * (n + 2));
    s   += a;
    n   += 2;
  }
  while (fabs(a) > ERR);

  return s;
}


int main(void)
{
  const real PI = 3.141592653589793238;
  const int  N  = 10000000;

  real       s  = 0.0;
  int        i  = 0;
  while     (i  < N)
  {
    #ifdef SOFT
      s +=   sin2(PI * i / N);
    #else
      #ifdef SINF
        s += sinf(PI * i / N);
      #else
        s += sin (PI * i / N);
      #endif
    #endif

    i++;
  }

  printf("%.16f\n", PI * s / N);

  return 0;
}

Most of the results were obtained on real machines, some were also obtained on emulators. Some of them are correct, others are not:

System/CPU Accuracy N FPU/Lib Soft-sin Soft-all Remark
Core i5-4690S@3200 Real*4 107 0.073 0.155 1.279 SINF, No-div
Core i5-4690S@3200 Real*4 107 0.127 0.231 1.858  
Core i5-4690S@3200 Real*8 107 0.133 0.351 2.523 No-div
Core i5-4690S@3200 Real*8 107 0.133 0.440 5.330  
Core 2 Duo E6850@3000 Real*4 107 0.178 0.532 4.003 SINF
Core 2 Duo E6850@3000 Real*8 107 0.384 1.483 10.207  
Pentium 4@@3000 Real*4 107 0.389 1.128 6.569 SINF
Core i5-4690S@3200 Real*8 107 0.482 1.145 n/a Context 1.4
Core i5-4690S@3200 Real*8 107 0.494 3.076 423.138 BCC 3.1/16 bit, set 87=Y
Elbrus-8S@1300 Real*4 107 0.540 1.300 9.220 SINF
Core i5-4690S@3200 Real*4 107 0.549 2.032 58.502 BCC 3.1/16 bit, set 87=Y
Elbrus-8S@1300 Real*8 107 0.640 2.080 21.560  
Athlon 64-3200+@2000 Real*4 107 0.649 1.248 9.577 SINF
Athlon 64-3200+@2000 Real*8 107 0.657 1.704 16.317  
Pentium 4@@3000 Real*8 107 0.695 2.628 17.786  
Pentium 4@1600 Real*4 107 1.166 1.898 14.766 SINF, No-div
Pentium 4@1600 Real*8 107 1.948 3.107 61.782 No-div
Pentium 4@1600 Real*8 107 1.948 3.755 185.735  
Pentium 4@1600 Real*4 107 1.953 2.564 15.582  
K6@200 Real*4 107 7.526 59.906 218.895 No-div
K6@200 Real*4 107 7.526 101.656 287.384  
K6@200 Real*8 107 7.526 93.104 496.113 No-div
K6@200 Real*8 107 7.526 115.216 1,240.043  
K6@200 Real*4 106 8.789 56.580 782.227 BCC 3.1/16 bit, set 87=Y
K6@200 Real*8 106 9.338 76.355 5,766.724 BCC 3.1/16 bit, set 87=Y
STM32F411RET6@100 Real*4 105 14.700 74.200 288.100 SINF, FPU
Core i5-4690S@3200 Real*4 107 16.864 144.031 58.502 BCC 3.1/16 bit, set 87=N
Core i5-4690S@3200 Real*8 107 16.974 229.614 420.138 BCC 3.1/16 bit, set 87=N
Core i5-4690S@3200 Real*4 106 35.600 150.000 n/a GW-Basic 3.22
Core i5-4690S@3200 Real*8 106 38.100 276.600 n/a GW-Basic 3.22
Am486DX2@66 Real*4 106 80.750 355.957 1,625.200  
Am486DX2@66 Real*8 106 81.848 526.245 6,504.900  
STM32F411RET6@100 Real*4 105 151.400 352.800 288.100 SINF
K6@200 Real*4 106 254.883 1,590.820 782.227 BCC 3.1/16 bit, set 87=N
K6@200 Real*8 106 261.475 2,206.055 5,766.724 BCC 3.1/16 bit, set 87=N
STM32F411RET6@100 Real*8 105 284.800 1,250.400 1,623.600  
STM32F103C8T6@48 Real*4 104 519.000 576.000 675.000  
STM32F103C8T6@48 Real*8 104 624.000 2,239.000 3,217.000  
K6@200 Real*4 105 619.000 3,228.820 n/a GW-Basic 3.22
K6@200 Real*8 105 671.000 5,406.000 n/a GW-Basic 3.22
ATSAMD21G18A-U@48 Real*4 104 1,056.000 1,781.000 2,033.000  
ATmega328P-PU@16 Real*4 104 1,606.000 5,521.000 23,258.000  
ATSAMD21G18A-U@48 Real*8 104 1,965.000 3,077.000 3,762.000  
Am386SX@33 Real*4 104 5,870.000 34,500.000 66,240.000 No-FPU
ATmega328P@16 Real*8 104 n/a n/a 126,253.000  
Am386SX@33 Real*8 104 6,430.000 46,410.000 149,180.000 No-FPU
PCem/IBM 5150/8088@4.77 Real*8 104 7,635.498 42,846.680 n/a 8087/Turbo C 2.0
PCem/IBM 5150/8088@4.77 Real*8 104 15,820.313 47,460.938 n/a 8087/Context 1.3
Am386SX@33 Real*4 104 19,650.000 95,350.000 n/a GW-Basic 3.22
Am386SX@33 Real*8 104 21,750.000 166,600.000 n/a GW-Basic 3.22
PCem/IBM 5150/8088@4.77 Real*8 103 108,764.648 802,551.270 3,094,299.316 Turbo C 2.0
PCem/IBM 5150/8088@4.77 Real*4 103 111,511.231 600,952.145 463,073.305 Turbo C 2.0
PCjs/IBM 5150/8088@4.77 Real*4 102 203,000.000 1,034,000.000 n/a IBM PC Basic C1.00
PCem/IBM 5150/8088@4.77 Real*4 102 281,000.000 1,203,000.000 n/a GW-Basic 3.22
PCjs/IBM 5150/8088@4.77 Real*8 102 309,000.000 2,115,000.000 n/a GW-Basic 3.22
PCem/IBM 5150/8088@4.77 Real*4 102 313,000.000 1,475,000.000 n/a IBM PC Basic C1.10
IBM 5150/8088@4.77 Real*4 102 322,000.000 1,491,000.000 n/a IBM PC Basic C1.10
PCjs/IBM 5150/8088@4.77 Real*8 102 356,000.000 3,172,000.000 n/a IBM PC Basic C1.00
Apple//e/65C02@1 Real*5 102 409,000.000 3,322,000.000 n/a Applesoft BASIC
AppleWin/Apple//e/65C02@1 Real*5 102 413,000.000 3,334,000.000 n/a Applesoft BASIC
PCem/IBM 5150/8088@4.77 Real*8 102 478,000.000 3,806,000.000 n/a IBM PC Basic C1.10, double (#) and integer (%) variables used
IBM 5150/8088@4.77 Real*8 102 503,000.000 4,153,000.000 n/a IBM PC Basic C1.10, double (#) and integer (%) variables used
Sinclair ZX81/Z80@3.25 Real*5 102 593,000.000 2,359,000.000 n/a Sinclair BASIC/Fast mode
Eighty One/Sinclair ZX81/Z80@3.25 Real*5 102 603,000.000 2,394,000.000 n/a Sinclair BASIC/Fast mode
BK-0010-01/К1801ВМ1@3 Real*8 102 997,000.000 2,325,000.000 n/a Vilnius BASIC
Citizen SRP-325G   102 1,982,000.000 26,872,000.000 n/a  
Uniel US-54   102 2,300,000.000 4,091,000.000 n/a Casio FX-3950P clone?
Sinclair ZX81/Z80@3.25 Real*5 102 2,328,000.000 9,428,000.000 n/a Sinclair BASIC/Slow mode
Eighty One/Sinclair ZX81/Z80@3.25 Real*5 102 2,369,000.000 9,569,000.000 n/a Sinclair BASIC/Slow mode
Citizen SRP-265   102 4,253,000.000 n/a n/a Manual restart - no loops/condition jumps
MK-85/KA1013VM1   102 8,950,000.000 25,344,000.000 n/a Turbo mode
Calculators3000/MK-61/K745IK1302-2   101 15,440,000.000 135,380,000.000 n/a  
mk61emuweb/MK-61/K745IK1302-2   101 18,750,000.000 172,590,000.000 n/a  
MK-85/KA1013VM1   102 21,634,000.000 61,338,000.000 n/a  
MK-61/K745IK1302-2   101 64,160,000.000 606,090,000.000 n/a  

Top.Mail.Ru
Сайт создан в системе uCoz