Parallel performance of a simple Python code¶
Here is a summary of the results from running the `mpi.py´ program.
# Convert to NumPy arrays
nprocDW = np.array(nprocDW)
tsecDW = np.array(tsecDW)
nprocLT = np.array(nprocLT)
tsecLT = np.array(tsecLT)
nprocLC = np.array(nprocLC)
tsecLC = np.array(tsecLC)
nprocTV = np.array(nprocTV)
tsecTV = np.array(tsecTV)
nprocTL = np.array(nprocTL)
tsecTL = np.array(tsecTL)
nprocYW = np.array(nprocYW)
tsecYW = np.array(tsecYW)
# Plot data
f, (ax1, ax2) = plt.subplots(1, 2)
ax1.plot(nprocDW, tsecDW, 'o', label='User 1')
ax1.plot(nprocLT, tsecLT, 'o', label='User 2')
ax1.plot(nprocLC, tsecLC, 'o', label='User 3')
ax1.plot(nprocTV, tsecTV, 'o', label='User 4')
ax1.plot(nprocTL, tsecTL, 'o', label='User 5')
ax1.plot(nprocYW, tsecYW, 'o', label='User 6')
ax1.set_xlabel('Number of cores')
ax1.set_ylabel('Calculation time [s]')
ax1.set_title('Raw parallel performance')
ax1.legend()
# Find bounds for reference parallel performance line
minx = min(nprocDW.min(), nprocLT.min(), nprocLC.min(), nprocTV.min(), nprocTL.min(), nprocYW.min())
miny = min(tsecDW.min(), tsecLT.min(), tsecLC.min(), tsecTV.min(), tsecTL.min(), tsecYW.min())
maxy = max(tsecDW.max(), tsecLT.max(), tsecLC.max(), tsecTV.max(), tsecTL.max(), tsecYW.max())
maxx = minx + (maxy - miny)
ax2.plot([np.log2(minx), np.log2(maxx)], [np.log2(maxy), np.log2(miny)], 'k--', label='Perfect parallelization')
ax2.plot(np.log2(nprocDW), np.log2(tsecDW), 'o', label='User 1')
ax2.plot(np.log2(nprocLT), np.log2(tsecLT), 'o', label='User 2')
ax2.plot(np.log2(nprocLC), np.log2(tsecLC), 'o', label='User 3')
ax2.plot(np.log2(nprocTV), np.log2(tsecTV), 'o', label='User 4')
ax2.plot(np.log2(nprocTL), np.log2(tsecTL), 'o', label='User 5')
ax2.plot(np.log2(nprocYW), np.log2(tsecYW), 'o', label='User 6')
ax2.axis('equal')
ax2.set_xlabel('log$_{2}$(Number of cores)')
ax2.set_ylabel('log$_{2}$(Calculation time) [s]')
ax2.set_title('Log$_{2}$ parallel performance')
ax2.legend()