Benchmark of DP, SP and Int. Arithmetic operations for ARM Cortex M7 MCU, Nucleo-144 Stm32F746 and Stm32F767 (modified from ddown post at "Arduino for STM32") by Jovan Ivković (JovanEps)

Dependencies:   mbed

Committer:
JovanEps
Date:
Mon Jan 02 02:55:50 2017 +0000
Revision:
1:be78b18b8347
Parent:
0:43b96e9650ef
Child:
2:03cf226a5ba3
Whetstone benchmark DP Final

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JovanEps 0:43b96e9650ef 1 //********************************************************
JovanEps 0:43b96e9650ef 2 //** Nucleo-144 Stm32F746 and Stm32F767 benchmark ******
JovanEps 0:43b96e9650ef 3 //** Jovan Ivkovic - 2016 ******
JovanEps 0:43b96e9650ef 4 //********************************************************
JovanEps 0:43b96e9650ef 5 #include "mbed.h"
JovanEps 0:43b96e9650ef 6 DigitalOut myled(LED1);
JovanEps 0:43b96e9650ef 7 Serial pc(USBTX, USBRX);
JovanEps 0:43b96e9650ef 8 Timer timer;
JovanEps 0:43b96e9650ef 9
JovanEps 0:43b96e9650ef 10 #include <stdlib.h>
JovanEps 0:43b96e9650ef 11 #include <stdio.h>
JovanEps 0:43b96e9650ef 12 #include <string.h>
JovanEps 0:43b96e9650ef 13 #include <math.h>
JovanEps 0:43b96e9650ef 14 /* the following is optional depending on the timing function used */
JovanEps 0:43b96e9650ef 15 #include <time.h>
JovanEps 0:43b96e9650ef 16
JovanEps 0:43b96e9650ef 17 /* map the FORTRAN math functions, etc. to the C versions */
JovanEps 0:43b96e9650ef 18 #define DSIN sin
JovanEps 0:43b96e9650ef 19 #define DCOS cos
JovanEps 0:43b96e9650ef 20 #define DATAN atan
JovanEps 0:43b96e9650ef 21 #define DLOG log
JovanEps 0:43b96e9650ef 22 #define DEXP exp
JovanEps 0:43b96e9650ef 23 #define DSQRT sqrt
JovanEps 0:43b96e9650ef 24 #define IF if
JovanEps 0:43b96e9650ef 25
JovanEps 0:43b96e9650ef 26 /* function prototypes */
JovanEps 0:43b96e9650ef 27 void POUT(long N, long J, long K, double X1, double X2, double X3, double X4);
JovanEps 0:43b96e9650ef 28 void PA(double E[]);
JovanEps 0:43b96e9650ef 29 void P0(void);
JovanEps 0:43b96e9650ef 30 void P3(double X, double Y, double *Z);
JovanEps 0:43b96e9650ef 31 #define USAGE "usage: whetdc [-c] [loops]\n"
JovanEps 0:43b96e9650ef 32
JovanEps 0:43b96e9650ef 33 /*
JovanEps 0:43b96e9650ef 34 COMMON T,T1,T2,E1(4),J,K,L
JovanEps 0:43b96e9650ef 35 */
JovanEps 0:43b96e9650ef 36 double T,T1,T2,E1[5];
JovanEps 0:43b96e9650ef 37 int J,K,L;
JovanEps 1:be78b18b8347 38 int argc = 0; //Mod for nucleo. Change in code below if you want non-default loop count
JovanEps 0:43b96e9650ef 39
JovanEps 1:be78b18b8347 40 //************************************
JovanEps 1:be78b18b8347 41 //** Whetstone 64b-DP **
JovanEps 1:be78b18b8347 42 //** SUB **
JovanEps 1:be78b18b8347 43 //************************************
JovanEps 1:be78b18b8347 44 int Whetstone() // ------------ Metoda -----------
JovanEps 0:43b96e9650ef 45 {
JovanEps 0:43b96e9650ef 46 pc.baud(115200);
JovanEps 0:43b96e9650ef 47 pc.printf("Beginning Whetstone benchmark at ");
JovanEps 0:43b96e9650ef 48
JovanEps 0:43b96e9650ef 49 pc.printf("default 216 MHz ...\n");
JovanEps 0:43b96e9650ef 50 /* used in the FORTRAN version */
JovanEps 0:43b96e9650ef 51 long I;
JovanEps 0:43b96e9650ef 52 long N1, N2, N3, N4, N6, N7, N8, N9, N10, N11;
JovanEps 0:43b96e9650ef 53 double X1,X2,X3,X4,X,Y,Z;
JovanEps 0:43b96e9650ef 54 long LOOP;
JovanEps 0:43b96e9650ef 55 int II, JJ;
JovanEps 0:43b96e9650ef 56
JovanEps 0:43b96e9650ef 57 /* added for this version */
JovanEps 1:be78b18b8347 58 long loopstart = 0;
JovanEps 1:be78b18b8347 59 long startsec,finisec = 0;
JovanEps 0:43b96e9650ef 60 double KIPS;
JovanEps 0:43b96e9650ef 61 int continuous;
JovanEps 0:43b96e9650ef 62
JovanEps 1:be78b18b8347 63 loopstart = 25000; /* 1000 see the note about LOOP below */
JovanEps 0:43b96e9650ef 64 continuous = 0;
JovanEps 0:43b96e9650ef 65
JovanEps 0:43b96e9650ef 66 II = 1; /* start at the first arg (temp use of II here) */
JovanEps 0:43b96e9650ef 67
JovanEps 0:43b96e9650ef 68 LCONT:
JovanEps 0:43b96e9650ef 69 /*
JovanEps 0:43b96e9650ef 70 ********************************************
JovanEps 0:43b96e9650ef 71 * Start benchmark timing at this point.
JovanEps 0:43b96e9650ef 72 ********************************************
JovanEps 0:43b96e9650ef 73 */
JovanEps 0:43b96e9650ef 74 timer.start();
JovanEps 1:be78b18b8347 75 startsec = 0;
JovanEps 1:be78b18b8347 76 finisec = 0;
JovanEps 1:be78b18b8347 77 startsec = timer.read_us();
JovanEps 0:43b96e9650ef 78
JovanEps 0:43b96e9650ef 79 /*
JovanEps 0:43b96e9650ef 80 ********************************************
JovanEps 0:43b96e9650ef 81 * The actual benchmark starts here.
JovanEps 0:43b96e9650ef 82 ********************************************
JovanEps 0:43b96e9650ef 83 */
JovanEps 0:43b96e9650ef 84 T = .499975;
JovanEps 0:43b96e9650ef 85 T1 = 0.50025;
JovanEps 0:43b96e9650ef 86 T2 = 2.0;
JovanEps 0:43b96e9650ef 87 /*
JovanEps 0:43b96e9650ef 88 ********************************************
JovanEps 0:43b96e9650ef 89 * With loopcount LOOP=10, one million Whetstone instructions
JovanEps 0:43b96e9650ef 90 * will be executed in EACH MAJOR LOOP..A MAJOR LOOP IS EXECUTED
JovanEps 0:43b96e9650ef 91 * 'II' TIMES TO INCREASE WALL-CLOCK TIMING ACCURACY.
JovanEps 0:43b96e9650ef 92 *
JovanEps 0:43b96e9650ef 93 * LOOP = 1000;
JovanEps 0:43b96e9650ef 94 */
JovanEps 0:43b96e9650ef 95 LOOP = loopstart;
JovanEps 0:43b96e9650ef 96 II = 1;
JovanEps 0:43b96e9650ef 97 JJ = 1;
JovanEps 0:43b96e9650ef 98
JovanEps 0:43b96e9650ef 99 IILOOP:
JovanEps 0:43b96e9650ef 100 N1 = 0;
JovanEps 0:43b96e9650ef 101 N2 = 12 * LOOP;
JovanEps 0:43b96e9650ef 102 N3 = 14 * LOOP;
JovanEps 0:43b96e9650ef 103 N4 = 345 * LOOP;
JovanEps 0:43b96e9650ef 104 N6 = 210 * LOOP;
JovanEps 0:43b96e9650ef 105 N7 = 32 * LOOP;
JovanEps 0:43b96e9650ef 106 N8 = 899 * LOOP;
JovanEps 0:43b96e9650ef 107 N9 = 616 * LOOP;
JovanEps 0:43b96e9650ef 108 N10 = 0;
JovanEps 0:43b96e9650ef 109 N11 = 93 * LOOP;
JovanEps 0:43b96e9650ef 110 /*
JovanEps 0:43b96e9650ef 111 ********************************************
JovanEps 0:43b96e9650ef 112 * Module 1: Simple identifiers
JovanEps 0:43b96e9650ef 113 ********************************************
JovanEps 0:43b96e9650ef 114 */
JovanEps 0:43b96e9650ef 115 X1 = 1.0;
JovanEps 0:43b96e9650ef 116 X2 = -1.0;
JovanEps 0:43b96e9650ef 117 X3 = -1.0;
JovanEps 0:43b96e9650ef 118 X4 = -1.0;
JovanEps 0:43b96e9650ef 119
JovanEps 1:be78b18b8347 120 for (I = 1; I <= N1; I++)
JovanEps 1:be78b18b8347 121 {
JovanEps 0:43b96e9650ef 122 X1 = (X1 + X2 + X3 - X4) * T;
JovanEps 0:43b96e9650ef 123 X2 = (X1 + X2 - X3 + X4) * T;
JovanEps 0:43b96e9650ef 124 X3 = (X1 - X2 + X3 + X4) * T;
JovanEps 0:43b96e9650ef 125 X4 = (-X1+ X2 + X3 + X4) * T;
JovanEps 0:43b96e9650ef 126 }
JovanEps 0:43b96e9650ef 127 #ifdef PRINTOUT
JovanEps 1:be78b18b8347 128 IF (JJ==II) POUT(N1,N1,N1,X1,X2,X3,X4);
JovanEps 0:43b96e9650ef 129 #endif
JovanEps 0:43b96e9650ef 130
JovanEps 0:43b96e9650ef 131 /*
JovanEps 0:43b96e9650ef 132 ********************************************
JovanEps 0:43b96e9650ef 133 * Module 2: Array elements
JovanEps 0:43b96e9650ef 134 ********************************************
JovanEps 0:43b96e9650ef 135 */
JovanEps 0:43b96e9650ef 136 E1[1] = 1.0;
JovanEps 0:43b96e9650ef 137 E1[2] = -1.0;
JovanEps 0:43b96e9650ef 138 E1[3] = -1.0;
JovanEps 0:43b96e9650ef 139 E1[4] = -1.0;
JovanEps 0:43b96e9650ef 140
JovanEps 1:be78b18b8347 141 for (I = 1; I <= N2; I++)
JovanEps 1:be78b18b8347 142 {
JovanEps 0:43b96e9650ef 143 E1[1] = ( E1[1] + E1[2] + E1[3] - E1[4]) * T;
JovanEps 0:43b96e9650ef 144 E1[2] = ( E1[1] + E1[2] - E1[3] + E1[4]) * T;
JovanEps 0:43b96e9650ef 145 E1[3] = ( E1[1] - E1[2] + E1[3] + E1[4]) * T;
JovanEps 0:43b96e9650ef 146 E1[4] = (-E1[1] + E1[2] + E1[3] + E1[4]) * T;
JovanEps 0:43b96e9650ef 147 }
JovanEps 0:43b96e9650ef 148
JovanEps 0:43b96e9650ef 149 #ifdef PRINTOUT
JovanEps 1:be78b18b8347 150 IF (JJ==II) POUT(N2,N3,N2,E1[1],E1[2],E1[3],E1[4]);
JovanEps 0:43b96e9650ef 151 #endif
JovanEps 0:43b96e9650ef 152
JovanEps 0:43b96e9650ef 153 /*
JovanEps 0:43b96e9650ef 154 ********************************************
JovanEps 0:43b96e9650ef 155 * Module 3: Array as parameter
JovanEps 0:43b96e9650ef 156 ********************************************
JovanEps 0:43b96e9650ef 157 */
JovanEps 0:43b96e9650ef 158 for (I = 1; I <= N3; I++)
JovanEps 1:be78b18b8347 159 {
JovanEps 0:43b96e9650ef 160 PA(E1);
JovanEps 1:be78b18b8347 161 }
JovanEps 0:43b96e9650ef 162 #ifdef PRINTOUT
JovanEps 1:be78b18b8347 163 IF (JJ==II) POUT(N3,N2,N2,E1[1],E1[2],E1[3],E1[4]);
JovanEps 0:43b96e9650ef 164 #endif
JovanEps 0:43b96e9650ef 165
JovanEps 0:43b96e9650ef 166 /*
JovanEps 0:43b96e9650ef 167 ********************************************
JovanEps 0:43b96e9650ef 168 * Module 4: Conditional jumps
JovanEps 0:43b96e9650ef 169 ********************************************
JovanEps 0:43b96e9650ef 170 */
JovanEps 0:43b96e9650ef 171 J = 1;
JovanEps 1:be78b18b8347 172 for (I = 1; I <= N4; I++)
JovanEps 1:be78b18b8347 173 {
JovanEps 0:43b96e9650ef 174 if (J == 1)
JovanEps 0:43b96e9650ef 175 J = 2;
JovanEps 0:43b96e9650ef 176 else
JovanEps 0:43b96e9650ef 177 J = 3;
JovanEps 0:43b96e9650ef 178
JovanEps 0:43b96e9650ef 179 if (J > 2)
JovanEps 0:43b96e9650ef 180 J = 0;
JovanEps 0:43b96e9650ef 181 else
JovanEps 0:43b96e9650ef 182 J = 1;
JovanEps 0:43b96e9650ef 183
JovanEps 0:43b96e9650ef 184 if (J < 1)
JovanEps 0:43b96e9650ef 185 J = 1;
JovanEps 0:43b96e9650ef 186 else
JovanEps 0:43b96e9650ef 187 J = 0;
JovanEps 0:43b96e9650ef 188 }
JovanEps 0:43b96e9650ef 189
JovanEps 0:43b96e9650ef 190 #ifdef PRINTOUT
JovanEps 1:be78b18b8347 191 IF (JJ==II) POUT(N4,J,J,X1,X2,X3,X4);
JovanEps 0:43b96e9650ef 192 #endif
JovanEps 0:43b96e9650ef 193
JovanEps 0:43b96e9650ef 194 /*
JovanEps 0:43b96e9650ef 195 ********************************************
JovanEps 0:43b96e9650ef 196 * Module 5: Omitted
JovanEps 0:43b96e9650ef 197 * Module 6: Integer arithmetic
JovanEps 0:43b96e9650ef 198 ********************************************
JovanEps 0:43b96e9650ef 199 */
JovanEps 0:43b96e9650ef 200
JovanEps 0:43b96e9650ef 201 J = 1;
JovanEps 0:43b96e9650ef 202 K = 2;
JovanEps 0:43b96e9650ef 203 L = 3;
JovanEps 0:43b96e9650ef 204
JovanEps 1:be78b18b8347 205 for (I = 1; I <= N6; I++)
JovanEps 1:be78b18b8347 206 {
JovanEps 0:43b96e9650ef 207 J = J * (K-J) * (L-K);
JovanEps 0:43b96e9650ef 208 K = L * K - (L-J) * K;
JovanEps 0:43b96e9650ef 209 L = (L-K) * (K+J);
JovanEps 0:43b96e9650ef 210 E1[L-1] = J + K + L;
JovanEps 0:43b96e9650ef 211 E1[K-1] = J * K * L;
JovanEps 0:43b96e9650ef 212 }
JovanEps 0:43b96e9650ef 213
JovanEps 0:43b96e9650ef 214 #ifdef PRINTOUT
JovanEps 1:be78b18b8347 215 IF (JJ==II) POUT(N6,J,K,E1[1],E1[2],E1[3],E1[4]);
JovanEps 0:43b96e9650ef 216 #endif
JovanEps 0:43b96e9650ef 217
JovanEps 0:43b96e9650ef 218 /*
JovanEps 0:43b96e9650ef 219 ********************************************
JovanEps 0:43b96e9650ef 220 * Module 7: Trigonometric functions
JovanEps 0:43b96e9650ef 221 ********************************************
JovanEps 0:43b96e9650ef 222 */
JovanEps 0:43b96e9650ef 223 X = 0.5;
JovanEps 0:43b96e9650ef 224 Y = 0.5;
JovanEps 0:43b96e9650ef 225
JovanEps 1:be78b18b8347 226 for (I = 1; I <= N7; I++)
JovanEps 1:be78b18b8347 227 {
JovanEps 0:43b96e9650ef 228 X = T * DATAN(T2*DSIN(X)*DCOS(X)/(DCOS(X+Y)+DCOS(X-Y)-1.0));
JovanEps 0:43b96e9650ef 229 Y = T * DATAN(T2*DSIN(Y)*DCOS(Y)/(DCOS(X+Y)+DCOS(X-Y)-1.0));
JovanEps 0:43b96e9650ef 230 }
JovanEps 0:43b96e9650ef 231
JovanEps 0:43b96e9650ef 232 #ifdef PRINTOUT
JovanEps 0:43b96e9650ef 233 IF (JJ==II)POUT(N7,J,K,X,X,Y,Y);
JovanEps 0:43b96e9650ef 234 #endif
JovanEps 0:43b96e9650ef 235
JovanEps 0:43b96e9650ef 236 /*
JovanEps 0:43b96e9650ef 237 ********************************************
JovanEps 0:43b96e9650ef 238 * Module 8: Procedure calls
JovanEps 0:43b96e9650ef 239 ********************************************
JovanEps 0:43b96e9650ef 240 */
JovanEps 0:43b96e9650ef 241 X = 1.0;
JovanEps 0:43b96e9650ef 242 Y = 1.0;
JovanEps 0:43b96e9650ef 243 Z = 1.0;
JovanEps 0:43b96e9650ef 244
JovanEps 0:43b96e9650ef 245 for (I = 1; I <= N8; I++)
JovanEps 1:be78b18b8347 246 {
JovanEps 0:43b96e9650ef 247 P3(X,Y,&Z);
JovanEps 1:be78b18b8347 248 }
JovanEps 0:43b96e9650ef 249 #ifdef PRINTOUT
JovanEps 0:43b96e9650ef 250 IF (JJ==II)POUT(N8,J,K,X,Y,Z,Z);
JovanEps 0:43b96e9650ef 251 #endif
JovanEps 0:43b96e9650ef 252
JovanEps 0:43b96e9650ef 253 /*
JovanEps 0:43b96e9650ef 254 ********************************************
JovanEps 0:43b96e9650ef 255 * Module 9: Array references
JovanEps 0:43b96e9650ef 256 ********************************************
JovanEps 0:43b96e9650ef 257 */
JovanEps 0:43b96e9650ef 258 J = 1;
JovanEps 0:43b96e9650ef 259 K = 2;
JovanEps 0:43b96e9650ef 260 L = 3;
JovanEps 0:43b96e9650ef 261 E1[1] = 1.0;
JovanEps 0:43b96e9650ef 262 E1[2] = 2.0;
JovanEps 0:43b96e9650ef 263 E1[3] = 3.0;
JovanEps 0:43b96e9650ef 264
JovanEps 0:43b96e9650ef 265 for (I = 1; I <= N9; I++)
JovanEps 1:be78b18b8347 266 {
JovanEps 0:43b96e9650ef 267 P0();
JovanEps 1:be78b18b8347 268 }
JovanEps 0:43b96e9650ef 269 #ifdef PRINTOUT
JovanEps 1:be78b18b8347 270 IF (JJ==II) POUT(N9,J,K,E1[1],E1[2],E1[3],E1[4]);
JovanEps 0:43b96e9650ef 271 #endif
JovanEps 0:43b96e9650ef 272
JovanEps 0:43b96e9650ef 273 /*
JovanEps 0:43b96e9650ef 274 ********************************************
JovanEps 0:43b96e9650ef 275 * Module 10: Integer arithmetic
JovanEps 0:43b96e9650ef 276 ********************************************
JovanEps 0:43b96e9650ef 277 */
JovanEps 0:43b96e9650ef 278 J = 2;
JovanEps 0:43b96e9650ef 279 K = 3;
JovanEps 0:43b96e9650ef 280
JovanEps 1:be78b18b8347 281 for (I = 1; I <= N10; I++)
JovanEps 1:be78b18b8347 282 {
JovanEps 0:43b96e9650ef 283 J = J + K;
JovanEps 0:43b96e9650ef 284 K = J + K;
JovanEps 0:43b96e9650ef 285 J = K - J;
JovanEps 0:43b96e9650ef 286 K = K - J - J;
JovanEps 0:43b96e9650ef 287 }
JovanEps 0:43b96e9650ef 288
JovanEps 0:43b96e9650ef 289 #ifdef PRINTOUT
JovanEps 1:be78b18b8347 290 IF (JJ==II) POUT(N10,J,K,X1,X2,X3,X4);
JovanEps 0:43b96e9650ef 291 #endif
JovanEps 0:43b96e9650ef 292
JovanEps 0:43b96e9650ef 293 /*
JovanEps 0:43b96e9650ef 294 ********************************************
JovanEps 0:43b96e9650ef 295 * Module 11: Standard functions
JovanEps 0:43b96e9650ef 296 ********************************************
JovanEps 0:43b96e9650ef 297 */
JovanEps 0:43b96e9650ef 298 X = 0.75;
JovanEps 0:43b96e9650ef 299
JovanEps 0:43b96e9650ef 300 for (I = 1; I <= N11; I++)
JovanEps 1:be78b18b8347 301 {
JovanEps 0:43b96e9650ef 302 X = DSQRT(DEXP(DLOG(X)/T1));
JovanEps 1:be78b18b8347 303 }
JovanEps 0:43b96e9650ef 304 #ifdef PRINTOUT
JovanEps 1:be78b18b8347 305 IF (JJ==II) POUT(N11,J,K,X,X,X,X);
JovanEps 0:43b96e9650ef 306 #endif
JovanEps 0:43b96e9650ef 307
JovanEps 0:43b96e9650ef 308 /*
JovanEps 0:43b96e9650ef 309 ********************************************
JovanEps 0:43b96e9650ef 310 * THIS IS THE END OF THE MAJOR LOOP.
JovanEps 0:43b96e9650ef 311 ********************************************
JovanEps 0:43b96e9650ef 312 */
JovanEps 0:43b96e9650ef 313 if (++JJ <= II)
JovanEps 0:43b96e9650ef 314 goto IILOOP;
JovanEps 0:43b96e9650ef 315
JovanEps 0:43b96e9650ef 316 /*
JovanEps 0:43b96e9650ef 317 ********************************************
JovanEps 0:43b96e9650ef 318 * Stop benchmark timing at this point.
JovanEps 0:43b96e9650ef 319 ********************************************
JovanEps 0:43b96e9650ef 320 */
JovanEps 0:43b96e9650ef 321 // finisec = time(0);
JovanEps 1:be78b18b8347 322 finisec = timer.read_us();
JovanEps 1:be78b18b8347 323 //timer.reset();
JovanEps 0:43b96e9650ef 324
JovanEps 0:43b96e9650ef 325 /*
JovanEps 0:43b96e9650ef 326 *--------------------------------------------------------------------
JovanEps 0:43b96e9650ef 327 * Performance in Whetstone KIP's per second is given by
JovanEps 0:43b96e9650ef 328 *
JovanEps 0:43b96e9650ef 329 * (100*LOOP*II)/TIME
JovanEps 0:43b96e9650ef 330 *
JovanEps 0:43b96e9650ef 331 * where TIME is in seconds.
JovanEps 0:43b96e9650ef 332 *--------------------------------------------------------------------
JovanEps 0:43b96e9650ef 333 */
JovanEps 0:43b96e9650ef 334 pc.printf(" kraj \n");
JovanEps 0:43b96e9650ef 335 double vreme;
JovanEps 1:be78b18b8347 336 vreme = (finisec - startsec) / 1000000;
JovanEps 0:43b96e9650ef 337
JovanEps 0:43b96e9650ef 338 if (vreme <= 0)
JovanEps 0:43b96e9650ef 339 {
JovanEps 0:43b96e9650ef 340 pc.printf("Insufficient duration- Increase the LOOP count \n");
JovanEps 1:be78b18b8347 341 finisec = 0;
JovanEps 1:be78b18b8347 342 startsec = 0;
JovanEps 0:43b96e9650ef 343 return 1;
JovanEps 0:43b96e9650ef 344 }
JovanEps 0:43b96e9650ef 345
JovanEps 1:be78b18b8347 346 pc.printf("Loops: %ld , \t Iterations: %d, \t Duration: %.3f sec. \n",
JovanEps 0:43b96e9650ef 347 LOOP, II, vreme);
JovanEps 0:43b96e9650ef 348
JovanEps 0:43b96e9650ef 349 KIPS = (100.0 * LOOP * II) / vreme ;
JovanEps 0:43b96e9650ef 350
JovanEps 0:43b96e9650ef 351 // if (KIPS >= 1000.0)
JovanEps 1:be78b18b8347 352 // pc.printf("C Converted Double Precision Whetstones: %.3f MIPS \n\n", KIPS / 1000);
JovanEps 0:43b96e9650ef 353 // else
JovanEps 1:be78b18b8347 354 // pc.printf("C Converted Double Precision Whetstones: %.3f KIPS \n\n", KIPS);
JovanEps 0:43b96e9650ef 355
JovanEps 1:be78b18b8347 356 pc.printf("C Converted Double Precision Whetstones: %.3f MIPS \n\n", KIPS / 1000);
JovanEps 0:43b96e9650ef 357
JovanEps 0:43b96e9650ef 358 if (continuous)
JovanEps 0:43b96e9650ef 359 goto LCONT;
JovanEps 0:43b96e9650ef 360
JovanEps 1:be78b18b8347 361 finisec = 0;
JovanEps 1:be78b18b8347 362 startsec = 0;
JovanEps 0:43b96e9650ef 363 return 1;
JovanEps 0:43b96e9650ef 364 }
JovanEps 0:43b96e9650ef 365
JovanEps 0:43b96e9650ef 366 void PA(double E[])
JovanEps 0:43b96e9650ef 367 {
JovanEps 0:43b96e9650ef 368 J = 0;
JovanEps 0:43b96e9650ef 369
JovanEps 0:43b96e9650ef 370 L10:
JovanEps 0:43b96e9650ef 371 E[1] = ( E[1] + E[2] + E[3] - E[4]) * T;
JovanEps 0:43b96e9650ef 372 E[2] = ( E[1] + E[2] - E[3] + E[4]) * T;
JovanEps 0:43b96e9650ef 373 E[3] = ( E[1] - E[2] + E[3] + E[4]) * T;
JovanEps 0:43b96e9650ef 374 E[4] = (-E[1] + E[2] + E[3] + E[4]) / T2;
JovanEps 0:43b96e9650ef 375 J += 1;
JovanEps 0:43b96e9650ef 376
JovanEps 0:43b96e9650ef 377 if (J < 6)
JovanEps 0:43b96e9650ef 378 goto L10;
JovanEps 0:43b96e9650ef 379 }
JovanEps 0:43b96e9650ef 380
JovanEps 0:43b96e9650ef 381 void P0(void)
JovanEps 0:43b96e9650ef 382 {
JovanEps 0:43b96e9650ef 383 E1[J] = E1[K];
JovanEps 0:43b96e9650ef 384 E1[K] = E1[L];
JovanEps 0:43b96e9650ef 385 E1[L] = E1[J];
JovanEps 0:43b96e9650ef 386 }
JovanEps 0:43b96e9650ef 387
JovanEps 0:43b96e9650ef 388 void P3(double X, double Y, double *Z)
JovanEps 0:43b96e9650ef 389 {
JovanEps 0:43b96e9650ef 390 double X1, Y1;
JovanEps 0:43b96e9650ef 391
JovanEps 0:43b96e9650ef 392 X1 = X;
JovanEps 0:43b96e9650ef 393 Y1 = Y;
JovanEps 0:43b96e9650ef 394 X1 = T * (X1 + Y1);
JovanEps 0:43b96e9650ef 395 Y1 = T * (X1 + Y1);
JovanEps 0:43b96e9650ef 396 *Z = (X1 + Y1) / T2;
JovanEps 0:43b96e9650ef 397 }
JovanEps 0:43b96e9650ef 398
JovanEps 0:43b96e9650ef 399 #ifdef PRINTOUT
JovanEps 0:43b96e9650ef 400 void POUT(long N, long J, long K, double X1, double X2, double X3, double X4)
JovanEps 0:43b96e9650ef 401 {
JovanEps 0:43b96e9650ef 402 pc.printf("%7ld %7ld %7ld %12.4e %12.4e %12.4e %12.4e\n",
JovanEps 0:43b96e9650ef 403 N, J, K, X1, X2, X3, X4);
JovanEps 0:43b96e9650ef 404 }
JovanEps 0:43b96e9650ef 405 #endif
JovanEps 0:43b96e9650ef 406
JovanEps 1:be78b18b8347 407 //*********************************
JovanEps 1:be78b18b8347 408 //** MAIN block **
JovanEps 1:be78b18b8347 409 //*********************************
JovanEps 1:be78b18b8347 410 int main()
JovanEps 1:be78b18b8347 411 {
JovanEps 1:be78b18b8347 412 int rez=0;
JovanEps 0:43b96e9650ef 413 printf("\n My Benchamrk example for Whetstones \n");
JovanEps 0:43b96e9650ef 414
JovanEps 1:be78b18b8347 415 while(1)
JovanEps 1:be78b18b8347 416 {
JovanEps 1:be78b18b8347 417 myled=1-rez;
JovanEps 1:be78b18b8347 418
JovanEps 1:be78b18b8347 419 rez = Whetstone(); //Call of Whetstone banch metod
JovanEps 1:be78b18b8347 420
JovanEps 1:be78b18b8347 421 myled=1-rez;
JovanEps 1:be78b18b8347 422 wait_us(0.3);
JovanEps 1:be78b18b8347 423 }
JovanEps 0:43b96e9650ef 424 }