diff --git a/docs/source/benchmarking.rst b/docs/source/benchmarking.rst new file mode 100644 index 00000000..db5c96ff --- /dev/null +++ b/docs/source/benchmarking.rst @@ -0,0 +1,30 @@ +.. _benchmarking: + +************ +Benchmarking +************ + +This section provides information and results from performance benchmarking of gprMax. + +How to benchmark? +================= + +The following simple model is an example (found in the ``tests/benchmarking`` sub-package) that can be used to benchmark gprMax on your own system. The model contains a simple source in free space. + +.. literalinclude:: ../../tests/benchmarking/bench_100x100x100.in + :language: none + :linenos: + + + + +Results +======= + +Mac OS X +-------- + +.. figure:: ../../tests/benchmarking/results/MacOSX/Darwin-15.3.0-x86_64-i386-64bit.png + :width: 600px + + Execution time and speed-up factor plots for gprMax (v3b21) and GprMax (v2). \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index 4c519e7b..a6ecb909 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -54,5 +54,6 @@ gprMax User Guide comparisons_analytical comparisons_numerical + benchmarking references diff --git a/tests/benchmarking/bench_100x100x100.in b/tests/benchmarking/bench_100x100x100.in new file mode 100644 index 00000000..81e0c18d --- /dev/null +++ b/tests/benchmarking/bench_100x100x100.in @@ -0,0 +1,9 @@ +#domain: 0.1 0.1 0.1 +#dx_dy_dz: 0.001 0.001 0.001 +#time_window: 3e-9 + +#num_threads: 1 + +#waveform: gaussiandotnorm 1 900e6 MySource +#hertzian_dipole: x 0.05 0.05 0.05 MySource +#rx: 0.05 0.05 0.05 \ No newline at end of file diff --git a/tests/benchmarking/bench_150x150x150.in b/tests/benchmarking/bench_150x150x150.in new file mode 100644 index 00000000..74592874 --- /dev/null +++ b/tests/benchmarking/bench_150x150x150.in @@ -0,0 +1,9 @@ +#domain: 0.15 0.15 0.15 +#dx_dy_dz: 0.001 0.001 0.001 +#time_window: 3e-9 + +#num_threads: 4 + +#waveform: gaussiandotnorm 1 900e6 MySource +#hertzian_dipole: x 0.05 0.05 0.05 MySource +#rx: 0.05 0.05 0.05 \ No newline at end of file diff --git a/tests/benchmarking/bench_empty.in b/tests/benchmarking/bench_empty.in deleted file mode 100644 index e68d191e..00000000 --- a/tests/benchmarking/bench_empty.in +++ /dev/null @@ -1,4 +0,0 @@ -#domain: 0.1 0.1 0.1 -#dx_dy_dz: 0.001 0.001 0.001 -#time_window: 3e-9 -#num_threads: 4 \ No newline at end of file diff --git a/tests/benchmarking/plot_speedup.py b/tests/benchmarking/plot_speedup.py new file mode 100644 index 00000000..5ec61414 --- /dev/null +++ b/tests/benchmarking/plot_speedup.py @@ -0,0 +1,73 @@ +import os, platform, psutil +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.gridspec as gridspec + +moduledirectory = os.path.dirname(os.path.abspath(__file__)) + +# Machine identifier +platformID = platform.platform() +platformlongID = 'iMac (Retina 5K, 27-inch, Late 2014); 4GHz Intel Core i7; Mac OS X 10.11.3' + +# Nmber of physical CPU cores on machine +phycores = psutil.cpu_count(logical=False) + +# Number of threads (0 signifies serial compiled code) +threads = np.array([0, 1, 2, 4]) + +# 100 x 100 x 100 cell model execution times (seconds) +bench1 = np.array([40, 48, 37, 32]) +bench1c = np.array([76, 77, 46, 32]) + +# 150 x 150 x 150 cell model execution times (seconds) +bench2 = np.array([108, 133, 93, 75]) +bench2c = np.array([220, 220, 132, 94]) + +# Plot colours from http://tools.medialab.sciences-po.fr/iwanthue/index.php +colors = ['#5CB7C6', '#E60D30', '#A21797', '#A3B347'] + +fig, ax = plt.subplots(num=platformID, figsize=(20, 10), facecolor='w', edgecolor='w') +fig.suptitle(platformlongID) +gs = gridspec.GridSpec(1, 2, hspace=0.5) +ax = plt.subplot(gs[0, 0]) +ax.plot(threads, bench1, color=colors[1], marker='.', ms=10, lw=2, label='1e6 cells (gprMax v3b21)') +ax.plot(threads, bench1c, color=colors[0], marker='.', ms=10, lw=2, label='1e6 cells (gprMax v2)') +ax.plot(threads, bench2, color=colors[1], marker='.', ms=10, lw=2, ls='--', label='3.375e6 cells (gprMax v3b21)') +ax.plot(threads, bench2c, color=colors[0], marker='.', ms=10, lw=2, ls='--', label='3.375e6 cells (gprMax v2)') + +ax.set_xlabel('Number of threads') +ax.set_ylabel('Time [s]') +ax.grid() + +legend = ax.legend(loc=1) +frame = legend.get_frame() +frame.set_edgecolor('white') + +ax.set_xlim([0, phycores]) +ax.set_xticks(threads) +ax.set_ylim(top=ax.get_ylim()[1] * 1.1) + +ax = plt.subplot(gs[0, 1]) +ax.plot(threads, bench1[1] / bench1, color=colors[1], marker='.', ms=10, lw=2, label='1e6 cells (gprMax v3b21)') +ax.plot(threads, bench1c[1] / bench1c, color=colors[0], marker='.', ms=10, lw=2, label='1e6 cells (gprMax v2)') +ax.plot(threads, bench2[1] / bench2, color=colors[1], marker='.', ms=10, lw=2, ls='--', label='3.375e6 cells (gprMax v3b21)') +ax.plot(threads, bench2c[1] / bench2c, color=colors[0], marker='.', ms=10, lw=2, ls='--', label='3.375e6 cells (gprMax v2)') + +ax.set_xlabel('Number of threads') +ax.set_ylabel('Speed-up factor') +ax.grid() + +legend = ax.legend(loc=1) +frame = legend.get_frame() +frame.set_edgecolor('white') + +ax.set_xlim([0, phycores]) +ax.set_xticks(threads) +ax.set_ylim(top=ax.get_ylim()[1] * 1.1) + +# Save a pdf of the plot +fig.savefig(os.path.join(moduledirectory, platformID + '.png'), dpi=150, format='png', bbox_inches='tight', pad_inches=0.1) + +plt.show() + + diff --git a/tests/benchmarking/results/MacOSX/Darwin-15.3.0-x86_64-i386-64bit.png b/tests/benchmarking/results/MacOSX/Darwin-15.3.0-x86_64-i386-64bit.png new file mode 100644 index 00000000..70979034 Binary files /dev/null and b/tests/benchmarking/results/MacOSX/Darwin-15.3.0-x86_64-i386-64bit.png differ