A faculty member asks how many cloud servers to rent for a simulation. Help them with Amdahl's law.
Input: first line P minEfficiency — the parallel fraction (0 ≤ P ≤ 1) and the minimum acceptable efficiency in percent. Then one or more server counts N, until the end of input.
For each N print N=… speedup=… efficiency=…% with speedup 1 / ((1 − P) + P / N) (three decimals) and efficiency speedup / N × 100 (one decimal), followed by OK if the efficiency is at least the minimum, otherwise WASTEFUL.
At the end print Max speedup: … (three decimals, 1 / (1 − P), or unlimited if P = 1) and Largest efficient N: … — the largest of the given N that is OK, or none.
Input:
0.9 50
2 4 8 16
Output:
N=2 speedup=1.818 efficiency=90.9% OK
N=4 speedup=3.077 efficiency=76.9% OK
N=8 speedup=4.706 efficiency=58.8% OK
N=16 speedup=6.400 efficiency=40.0% WASTEFUL
Max speedup: 10.000
Largest efficient N: 8