1 | /* Author : Rick van der Zwet
|
---|
2 | * S-number : 0433373
|
---|
3 | * Version : $Id: README.txt 217 2007-09-10 19:35:36Z rick $
|
---|
4 | * Copyright : FreeBSD Licence
|
---|
5 | */
|
---|
6 |
|
---|
7 | =Assignment 1=
|
---|
8 | ==Static instructions==
|
---|
9 | We could define static instructions into groups:
|
---|
10 | * Loop 1 : 18
|
---|
11 | * Loop 2 : 30
|
---|
12 | -------------------------------------------------
|
---|
13 | TOTAL : 58
|
---|
14 |
|
---|
15 | ==Dynamic instructions==
|
---|
16 | Dynatic instructions into groups
|
---|
17 | * Initial intructions : 0
|
---|
18 | * Intructions loop 1 init : 2
|
---|
19 | * Intructions loop 1 main : (3 + 13) * 20 + 4
|
---|
20 | ** *20 cause 20 times loop
|
---|
21 | ** +4 cause of the last compare (including jump)
|
---|
22 | * Intructions loop 2 init : 4
|
---|
23 | * Intructions loop 2 main : (3 + 22) * 20 + 4
|
---|
24 | ** *20 cause 20 times loop
|
---|
25 | ** +4 cause of the last compare (including jump)
|
---|
26 | -------------------------------------------------
|
---|
27 | TOTAL : 834
|
---|
28 |
|
---|
29 | ==Data accesses==
|
---|
30 | * Loop 1 : 1 + 1 * 21 + 5 * 20
|
---|
31 | * init, compare, inner loop
|
---|
32 | * Loop 2 : 2 + 1 * 21 + 8 * 20
|
---|
33 | * init, compare, inner loop
|
---|
34 | -------------------------------------------------
|
---|
35 | TOTAL : 305
|
---|
36 |
|
---|
37 |
|
---|
38 | =Optimalisation=
|
---|
39 |
|
---|
40 | The most easy way to kill all dynamic instructions will be calculating
|
---|
41 | the final result and write the results into the memory and registery
|
---|
42 | directly, meaning at the end
|
---|
43 | for i = 1 .. 20
|
---|
44 | B[i] = i
|
---|
45 | A[i] = B[i-1] + C
|
---|
46 | C = 42
|
---|
47 | i = 20
|
---|
48 | $2 = 20 (last value of i, last loop compare)
|
---|
49 | $3 = 0 (last loop compare)
|
---|
50 | $4 = 42
|
---|
51 |
|
---|
52 | ==Static intructions==
|
---|
53 | * Number of intructions will be: 84
|
---|
54 |
|
---|
55 | ==Dynamic instructions==
|
---|
56 | * Dynamic intructions eq to static intructions as we define all
|
---|
57 | results directly: 84
|
---|
58 |
|
---|
59 | ==Data accesses==
|
---|
60 | * Cause we also have some references to the registery not all calls are
|
---|
61 | data accesses, the count stops at:
|
---|
62 | * B = 19
|
---|
63 | * A1 = 2
|
---|
64 | * A = 18
|
---|
65 | * C = 1
|
---|
66 | * i = 1
|
---|
67 | ----------
|
---|
68 | TOTAL = 41
|
---|
69 |
|
---|
70 | ==Speedup==
|
---|
71 | Dynamic count old: 834
|
---|
72 | Dynamic count new: 84
|
---|
73 | Speedup in execution time: 1 / (84/834) = 9.93
|
---|
74 | quote Van Thieu Vu, why we do not use the Amdahl law over here
|
---|
75 | Here we calculate the performance gain of an optimized program while the
|
---|
76 | Amdahl's law which you mentioned is used to calculate the performance gain
|
---|
77 | of an improved computer. In your case, the speedup is 1/(84/834).
|
---|
78 |
|
---|
79 |
|
---|
80 |
|
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|