File indexing completed on 2026-04-09 07:48:46
0001
0002
0003 import os, numpy as np
0004 import matplotlib.pyplot as plt
0005 SIZE = np.array([1280, 720])
0006
0007
0008 class Amdahl(object):
0009 """
0010 https://en.wikipedia.org/wiki/Amdahl%27s_law
0011
0012
0013 1
0014 -------------------
0015 (1 - p) + p/F
0016
0017 """
0018 @classmethod
0019 def Overall_Speedup(cls, F, p):
0020 """
0021 :param F: parallel speedup
0022 :param p: parallel fraction
0023 """
0024 return 1./( (1-p) + p/F )
0025
0026
0027 if __name__ == '__main__':
0028
0029 fig, ax = plt.subplots(1, figsize=SIZE/100. )
0030 fig.suptitle("~/opticks/ana/amdahl.sh : Overall Speedup for Parallel Fractions, p ")
0031
0032 F = np.linspace( 1, 10000 , 10000 )
0033 PARALLEL_FRACTION = np.array([0.99, 0.985, 0.98, 0.97, 0.95, 0.90])
0034
0035 COLORS = ["red","green","blue", "cyan", "magenta", "black", "yellow" ]
0036
0037 for i, p in enumerate(PARALLEL_FRACTION):
0038 color = COLORS[i%len(COLORS)]
0039 ax.plot( F, Amdahl.Overall_Speedup(F, p), label="p,1-p,1/(1-p): %5.3f %5.3f %5.3f " % (p, 1-p, 1/(1.-p) ), color=color )
0040 ax.hlines( 1/(1.-p), xmin=F[0], xmax=F[-1], linestyle="dashed", color=color )
0041 pass
0042
0043 ax.axvspan(100, 1000, alpha=0.1, color='blue')
0044 ax.set_xscale('log')
0045 ax.set_ylabel("Overall Speedup (para frac. 0.90 -> 0.99)", fontsize=20 )
0046 ax.set_xlabel("Parallelized Speedup", fontsize=20 )
0047 ax.legend()
0048
0049 fig.show()
0050
0051
0052