Download dir - Oracle Documentation

Transcript
2.50
5%
10%
15%
20%
2.00
1.50
1.00
0.50
0.00
2
1
FIGURE 4-5
3
4
5
6
7
8
Speedup Curve with Overheads
Gustafson’s Law
Amdahls Law can be misleading for predicting parallel speedups in real problems.
The fraction of time spent in sequential sections of the program sometimes depends
on the problem size. That is, by scaling the problem size, you may improve the
chances of speedup. The following example demonstrates this.
CODE EXAMPLE 4-12
Scaling the Problem Size May Improve Chances of Speedup
/*
* initialize the arrays
*/
for (i=0; i < n; i++) {
for (j=0; j < n; j++) {
a[i][j] = 0.0;
b[i][j] = ...
c[i][j] = ...
}
}
/*
* matrix multiply
*/
for (i=0; i < n; i++) {
for(j=0; j < n; j++) {
for (k=0; k < n; k++) {
a[i][j] = b[i][k]*c[k][j];
}
}
}
114
C User’s Guide • May 2000