From abcc5d07dcb53ea4017e0bff7088115648a7181b Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Fri, 21 Feb 2020 00:28:02 +0000 Subject: [PATCH] updating scaling routine --- tests/population/scaling/plot_scaling_new.py | 75 ++++++++++++++++++++ tests/population/scaling/scaling_script.py | 2 +- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 tests/population/scaling/plot_scaling_new.py diff --git a/tests/population/scaling/plot_scaling_new.py b/tests/population/scaling/plot_scaling_new.py new file mode 100644 index 000000000..2535811ef --- /dev/null +++ b/tests/population/scaling/plot_scaling_new.py @@ -0,0 +1,75 @@ +import matplotlib +import os +import matplotlib.pyplot as plt +import pandas as pd +import numpy as np +import json + +scaling_result_dir = 'scaling_results' + + +result_jsons = [] +result_jsons.append(os.path.join(os.path.abspath(scaling_result_dir), 'david-Lenovo-IdeaPad-S340-14IWL_100_systems.json')) + + + +fig, ax1 = plt.subplots() +ax2 = ax1.twinx() +for jsonfile in result_jsons: + print(jsonfile) + + with open(jsonfile, 'r') as f: + result_data = json.loads(f.read()) + + # Get linear data + linear_data = result_data['linear'] + linear_mean = np.mean(linear_data) + linear_stdev = np.std(linear_data) + + cpus = [] + mp_speedups = [] + mp_efficiencies = [] + stddevs = [] + + for amt_cpus in result_data['mp']: + # Get mp data + mp_data = result_data['mp'][amt_cpus] + mp_mean = np.mean(mp_data) + mp_stdev = np.std(mp_data) + + # Calc and append info + amt_cpus = int(amt_cpus) + speedup = linear_mean/mp_mean + efficiency = speedup/int(amt_cpus) + + cpus.append(amt_cpus) + mp_speedups.append(speedup) + mp_efficiencies.append(efficiency) + stddevs.append(mp_stdev) + + # Plot + ax1.errorbar( + cpus, + mp_speedups, + stddevs, + linestyle="None", + marker="^", + label="Speed up & efficiency of {} systems".format(result_data['amt_systems']), + ) + + +ax1.set_title( + "Speed up ratio vs amount of cores for different amounts of systems on {}".format( + 'name_testcase' + ) +) +ax1.set_xlabel("Amount of cores used") +ax1.set_ylabel("Speed up ratio (time_linear/time_parallel)") + +ax1.set_xlim(0, max(cpus) + 4) +# ax1.set_ylim(0, max_speedup + 2) +ax2.set_ylim(0, 1) + +ax1.grid() +ax1.legend(loc=4) +plt.show() diff --git a/tests/population/scaling/scaling_script.py b/tests/population/scaling/scaling_script.py index 2b64d3f42..2e537af10 100644 --- a/tests/population/scaling/scaling_script.py +++ b/tests/population/scaling/scaling_script.py @@ -31,7 +31,7 @@ for i in range(1, int(amount_of_cpus/stepsize) + 1 ): amt_repeats = 5 resolution = {'M_1': 10, 'per': 10} -total_systems = np.prod([el for el in resolution.values()]) +total_systems = int(np.prod([el for el in resolution.values()])) result_dir = 'scaling_results' -- GitLab