diff --git a/launch_alg_bench.py b/launch_alg_bench.py index dbf27ab..05a48f0 100755 --- a/launch_alg_bench.py +++ b/launch_alg_bench.py @@ -3,6 +3,8 @@ import subprocess from datetime import datetime ################ HELPER FUNCTIONS ################ + + def load_template(template_path: str): output_template = "" with open(template_path, "r") as handle: @@ -14,6 +16,7 @@ def write_batch(batch_fpath: str, batch_content: str): with open(batch_fpath, "w") as handle: _ = handle.write(batch_content) + ################### SETUP DIRS ################### output_dir = os.getcwd()+"/output/" err_dir = os.getcwd()+"/error/" diff --git a/results-and-plotting/.DS_Store b/results-and-plotting/.DS_Store new file mode 100644 index 0000000..01904e7 Binary files /dev/null and b/results-and-plotting/.DS_Store differ diff --git a/results-and-plotting/plots/allgather_algcomp.png b/results-and-plotting/plots/allgather_algcomp.png new file mode 100644 index 0000000..2699d85 Binary files /dev/null and b/results-and-plotting/plots/allgather_algcomp.png differ diff --git a/results-and-plotting/plots/allgather_algcomp_log.png b/results-and-plotting/plots/allgather_algcomp_log.png new file mode 100644 index 0000000..a332063 Binary files /dev/null and b/results-and-plotting/plots/allgather_algcomp_log.png differ diff --git a/results-and-plotting/plots/allreduce_algcomp.png b/results-and-plotting/plots/allreduce_algcomp.png new file mode 100644 index 0000000..c882dbb Binary files /dev/null and b/results-and-plotting/plots/allreduce_algcomp.png differ diff --git a/results-and-plotting/plots/allreduce_algcomp_log.png b/results-and-plotting/plots/allreduce_algcomp_log.png new file mode 100644 index 0000000..f48a5bb Binary files /dev/null and b/results-and-plotting/plots/allreduce_algcomp_log.png differ diff --git a/results-and-plotting/plots/alltoall_algcomp.png b/results-and-plotting/plots/alltoall_algcomp.png new file mode 100644 index 0000000..8a820fa Binary files /dev/null and b/results-and-plotting/plots/alltoall_algcomp.png differ diff --git a/results-and-plotting/plots/alltoall_algcomp_log.png b/results-and-plotting/plots/alltoall_algcomp_log.png new file mode 100644 index 0000000..d3da787 Binary files /dev/null and b/results-and-plotting/plots/alltoall_algcomp_log.png differ diff --git a/results-and-plotting/plots/bcast_algcomp.png b/results-and-plotting/plots/bcast_algcomp.png new file mode 100644 index 0000000..13747db Binary files /dev/null and b/results-and-plotting/plots/bcast_algcomp.png differ diff --git a/results-and-plotting/plots/bcast_algcomp_log.png b/results-and-plotting/plots/bcast_algcomp_log.png new file mode 100644 index 0000000..efac70d Binary files /dev/null and b/results-and-plotting/plots/bcast_algcomp_log.png differ diff --git a/results-and-plotting/plots/gather_algcomp.png b/results-and-plotting/plots/gather_algcomp.png new file mode 100644 index 0000000..fe83df0 Binary files /dev/null and b/results-and-plotting/plots/gather_algcomp.png differ diff --git a/results-and-plotting/plots/gather_algcomp_log.png b/results-and-plotting/plots/gather_algcomp_log.png new file mode 100644 index 0000000..1924cb0 Binary files /dev/null and b/results-and-plotting/plots/gather_algcomp_log.png differ diff --git a/results-and-plotting/plots/reduce_algcomp.png b/results-and-plotting/plots/reduce_algcomp.png new file mode 100644 index 0000000..30b9f2d Binary files /dev/null and b/results-and-plotting/plots/reduce_algcomp.png differ diff --git a/results-and-plotting/plots/reduce_algcomp_log.png b/results-and-plotting/plots/reduce_algcomp_log.png new file mode 100644 index 0000000..9ff8f33 Binary files /dev/null and b/results-and-plotting/plots/reduce_algcomp_log.png differ diff --git a/results-and-plotting/plots/reduce_scatter_algcomp.png b/results-and-plotting/plots/reduce_scatter_algcomp.png new file mode 100644 index 0000000..26f32fa Binary files /dev/null and b/results-and-plotting/plots/reduce_scatter_algcomp.png differ diff --git a/results-and-plotting/plots/reduce_scatter_algcomp_log.png b/results-and-plotting/plots/reduce_scatter_algcomp_log.png new file mode 100644 index 0000000..72fa2ae Binary files /dev/null and b/results-and-plotting/plots/reduce_scatter_algcomp_log.png differ diff --git a/results-and-plotting/plots/scatter_algcomp.png b/results-and-plotting/plots/scatter_algcomp.png new file mode 100644 index 0000000..53c0971 Binary files /dev/null and b/results-and-plotting/plots/scatter_algcomp.png differ diff --git a/results-and-plotting/plots/scatter_algcomp_log.png b/results-and-plotting/plots/scatter_algcomp_log.png new file mode 100644 index 0000000..fb612d5 Binary files /dev/null and b/results-and-plotting/plots/scatter_algcomp_log.png differ diff --git a/results-and-plotting/python/scripts/plot_alg.py b/results-and-plotting/python/scripts/plot_alg.py new file mode 100644 index 0000000..c15b897 --- /dev/null +++ b/results-and-plotting/python/scripts/plot_alg.py @@ -0,0 +1,104 @@ +from matplotlib.ticker import FuncFormatter +import pandas as pd +import matplotlib.pyplot as plt +import numpy as np +from matplotlib.lines import Line2D +from enum import Enum + + +class columns (): + benchmark_type = 'benchmark_type' + proc_num = 'proc_num' + msg_size_bytes = 'msg_size_bytes' + repetitions = 'repetitions' + t_min_usec = 't_min_usec' + t_max_usec = 't_max_usec' + t_avg_usec = 't_avg_usec' + mpi_datatype = 'mpi_datatype' + mpi_red_datatype = 'mpi_red_datatype' + mpi_red_op = 'mpi_red_op' + creation_time = 'creation_time' + n_nodes = 'n_nodes' + off_cache_flag = 'off_cache_flag' + algorithm = 'algorithm' + + +class collectives(Enum): + Bcast = 'Bcast' + Reduce = 'Reduce' + Allreduce = 'Allreduce' + Alltoall = 'Alltoall' + Scatter = 'Scatter' + Reduce_scatter = 'Reduce_scatter' + Allgather = 'Allgather' + Gather = 'Gather' + + +data_file = "./data/data_04_11_25_algs.csv" + +df_multinode = pd.read_csv(data_file, delimiter=',') +df_multinode.fillna(0, inplace=True) +df_multinode = df_multinode[df_multinode[columns.off_cache_flag] == 50] +for c in collectives: + + df_single = df_multinode[df_multinode[columns.benchmark_type] + == c.value] + df_single = df_single[df_single[columns.msg_size_bytes] > 1000] + df_single = df_single[[columns.proc_num, columns.msg_size_bytes, + columns.t_avg_usec, columns.algorithm]] + + df_gather_best = df_single.loc[ # pyright: ignore + df_single.groupby([columns.msg_size_bytes, columns.proc_num])[ # pyright: ignore + columns.t_avg_usec].idxmin() + ].reset_index(drop=True) + + df_gather_best = df_gather_best[df_gather_best[columns.msg_size_bytes] > 2**17] + + pivot_best = df_gather_best.pivot(index=columns.msg_size_bytes, # pyright: ignore + columns=columns.proc_num, values=columns.t_avg_usec) + + X = pivot_best.columns.values # proc_num + Y = pivot_best.index.values # msg_size_bytes + X, Y = np.meshgrid(X, Y) # pyright: ignore + Z = pivot_best.values + + alg_pivot = df_gather_best.pivot( + index=columns.msg_size_bytes, + columns=columns.proc_num, + values=columns.algorithm + ) + + algorithms = alg_pivot.values.flatten() + unique_algs = sorted(pd.unique(algorithms[~pd.isna(algorithms)])) + color_map = {alg: i for i, alg in enumerate(unique_algs)} + color_values = np.array([color_map.get(a, np.nan) for a in algorithms]) + + fig = plt.figure(figsize=(16, 9)) + ax = fig.add_subplot(111, projection='3d') + surf = ax.plot_wireframe(X, Y, Z, + color='black', linewidths=1) + surf_points = ax.scatter(X, + Y, Z, c=color_values, cmap='viridis', s=20, depthshade=False) # pyright: ignore + + handles = [ + Line2D([0], [0], + marker='o', color='w', + label=alg, + markerfacecolor=plt.cm.viridis( + color_map[alg] / max(len(unique_algs)-1, 1)), + markersize=8) + for alg in unique_algs + ] + + ax.legend(handles=handles, title="Algorithm", loc='upper right') + ax.set_xlabel("Process Count") + ax.set_ylabel("Message Size [B]") + ax.set_zlabel("Average Time [μs]") + ax.set_title(f"{c.value}") + ax.set_xticks(pivot_best.columns.values) # pyright: ignore + ax.set_xticklabels(pivot_best.columns.values) + ax.set_yticks(Y[:, 0]) + ymin, ymax = ax.get_ylim() + ax.set_ylim(ymin*0.8, ymax) # 30% more space at top + ax.set_yticklabels([f"$2^{{{int(np.log2(v))}}}$" for v in Y[:, 0]]) + plt.savefig(f"./plots/{c.value.lower()}_algcomp.png") diff --git a/results-and-plotting/python/scripts/plot_alg_log.py b/results-and-plotting/python/scripts/plot_alg_log.py new file mode 100644 index 0000000..ac09e6e --- /dev/null +++ b/results-and-plotting/python/scripts/plot_alg_log.py @@ -0,0 +1,127 @@ +from matplotlib.ticker import FuncFormatter +import pandas as pd +import matplotlib.pyplot as plt +import numpy as np +from matplotlib.lines import Line2D +from enum import Enum + + +class columns (): + benchmark_type = 'benchmark_type' + proc_num = 'proc_num' + msg_size_bytes = 'msg_size_bytes' + repetitions = 'repetitions' + t_min_usec = 't_min_usec' + t_max_usec = 't_max_usec' + t_avg_usec = 't_avg_usec' + mpi_datatype = 'mpi_datatype' + mpi_red_datatype = 'mpi_red_datatype' + mpi_red_op = 'mpi_red_op' + creation_time = 'creation_time' + n_nodes = 'n_nodes' + off_cache_flag = 'off_cache_flag' + algorithm = 'algorithm' + + +class collectives(Enum): + Bcast = 'Bcast' + Reduce = 'Reduce' + Allreduce = 'Allreduce' + Alltoall = 'Alltoall' + Scatter = 'Scatter' + Reduce_scatter = 'Reduce_scatter' + Allgather = 'Allgather' + Gather = 'Gather' + + +def log_notation(val, pos): + return f" $1e{int(val)}$" if val != 0 else "1" + + +def log2_notation(val, pos): + return "$2^{"+str(int(val))+"}$" if val != 0 else "1" + + +data_file = "./data/data_04_11_25_algs.csv" + +df_multinode = pd.read_csv(data_file, delimiter=',') +df_multinode.fillna(0, inplace=True) +df_multinode = df_multinode[df_multinode[columns.off_cache_flag] == 50] +for c in collectives: + + df_single = df_multinode[df_multinode[columns.benchmark_type] + == c.value] + df_single = df_single[df_single[columns.msg_size_bytes] > 1000] + df_single = df_single[[columns.proc_num, columns.msg_size_bytes, + columns.t_avg_usec, columns.algorithm]] + + df_gather_best = df_single.loc[ # pyright: ignore + df_single.groupby([columns.msg_size_bytes, columns.proc_num])[ # pyright: ignore + columns.t_avg_usec].idxmin() + ].reset_index(drop=True) + + df_gather_worst = df_single.loc[ # pyright: ignore + df_single.groupby([columns.msg_size_bytes, columns.proc_num])[ # pyright: ignore + columns.t_avg_usec].idxmax() + ].reset_index(drop=True) + # df_gather_select = df_gather_select[df_gather_select[columns.msg_size_bytes] > 2**17] + + pivot_best = df_gather_best.pivot(index=columns.msg_size_bytes, # pyright: ignore + columns=columns.proc_num, values=columns.t_avg_usec) + pivot_worst = df_gather_worst.pivot(index=columns.msg_size_bytes, # pyright: ignore + columns=columns.proc_num, values=columns.t_avg_usec) + + X = pivot_best.columns.values # proc_num + Y = pivot_best.index.values # msg_size_bytes + X, Y = np.meshgrid(X, Y) # pyright: ignore + Z = pivot_best.values + + X_w = pivot_worst.columns.values # proc_num + Y_w = pivot_worst.index.values # msg_size_bytes + X_w, Y_w = np.meshgrid(X_w, Y_w) # pyright: ignore + Z_w = pivot_worst.values + + alg_pivot = df_gather_best.pivot( + index=columns.msg_size_bytes, + columns=columns.proc_num, + values=columns.algorithm + ) + + algorithms = alg_pivot.values.flatten() + unique_algs = sorted(pd.unique(algorithms[~pd.isna(algorithms)])) + color_map = {alg: i for i, alg in enumerate(unique_algs)} + color_values = np.array([color_map.get(a, np.nan) for a in algorithms]) + + fig = plt.figure(figsize=(16, 9)) + ax = fig.add_subplot(111, projection='3d') + surf = ax.plot_wireframe(X, np.log2(Y), np.log(Z), + color='black', linewidths=1) + surf = ax.plot_wireframe(X_w, np.log2( + Y_w), np.log(Z_w), color='gray', linewidths=0.3) + + surf_points = ax.scatter(X, np.log2( + Y), np.log(Z), c=color_values, cmap='viridis', s=20, depthshade=False) # pyright: ignore + + surf_points = ax.scatter(X_w, np.log2( + Y_w), np.log(Z_w), c='gray', alpha=0.2, s=20, depthshade=False) # pyright: ignore + + handles = [ + Line2D([0], [0], + marker='o', color='w', + label=alg, + markerfacecolor=plt.cm.viridis( + color_map[alg] / max(len(unique_algs)-1, 1)), + markersize=8) + for alg in unique_algs + ] + + ax.legend(handles=handles, title="Algorithm", loc='upper right') + ax.set_xlabel("Process Count") + ax.set_ylabel("Message Size [B] (log2)") + ax.set_zlabel("Average Time [μs] (log10)") + ax.set_title(f"{c.value}") + ax.set_xticks(pivot_best.columns.values) # pyright: ignore + ax.set_xticklabels(pivot_best.columns.values) + ax.yaxis.set_major_formatter(FuncFormatter(log2_notation)) + ax.zaxis.set_major_formatter(FuncFormatter(log_notation)) + plt.savefig(f"./plots/{c.value.lower()}_algcomp_log.png")