Whetstone benchmark DP for ARM Cortex M7 - ST Nucleo-144 STM32F7xx

Dependencies:   mbed

Committer:
JovanEps
Date:
Wed Jan 04 13:56:34 2017 +0000
Revision:
2:5344c9a43a9e
Parent:
1:be78b18b8347
Final Whetstone Bench

Who changed what in which revision?

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