/* Author : Rick van der Zwet * S-number : 0433373 * Version : $Id: README.txt 217 2007-09-10 19:35:36Z rick $ * Copyright : FreeBSD Licence */ =Assignment 1= ==Static instructions== We could define static instructions into groups: * Loop 1 : 18 * Loop 2 : 30 ------------------------------------------------- TOTAL : 58 ==Dynamic instructions== Dynatic instructions into groups * Initial intructions : 0 * Intructions loop 1 init : 2 * Intructions loop 1 main : (3 + 13) * 20 + 4 ** *20 cause 20 times loop ** +4 cause of the last compare (including jump) * Intructions loop 2 init : 4 * Intructions loop 2 main : (3 + 22) * 20 + 4 ** *20 cause 20 times loop ** +4 cause of the last compare (including jump) ------------------------------------------------- TOTAL : 834 ==Data accesses== * Loop 1 : 1 + 1 * 21 + 5 * 20 * init, compare, inner loop * Loop 2 : 2 + 1 * 21 + 8 * 20 * init, compare, inner loop ------------------------------------------------- TOTAL : 305 =Optimalisation= The most easy way to kill all dynamic instructions will be calculating the final result and write the results into the memory and registery directly, meaning at the end for i = 1 .. 20 B[i] = i A[i] = B[i-1] + C C = 42 i = 20 $2 = 20 (last value of i, last loop compare) $3 = 0 (last loop compare) $4 = 42 ==Static intructions== * Number of intructions will be: 84 ==Dynamic instructions== * Dynamic intructions eq to static intructions as we define all results directly: 84 ==Data accesses== * Cause we also have some references to the registery not all calls are data accesses, the count stops at: * B = 19 * A1 = 2 * A = 18 * C = 1 * i = 1 ---------- TOTAL = 41 ==Speedup== Dynamic count old: 834 Dynamic count new: 84 Speedup in execution time: 1 / (84/834) = 9.93 quote Van Thieu Vu, why we do not use the Amdahl law over here Here we calculate the performance gain of an optimized program while the Amdahl's law which you mentioned is used to calculate the performance gain of an improved computer. In your case, the speedup is 1/(84/834).