Skip to content

Commit

Permalink
Update graphics to work with different machines
Browse files Browse the repository at this point in the history
  • Loading branch information
nirogu committed Nov 9, 2023
1 parent 097be8d commit 272e8a6
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 29 deletions.
101 changes: 72 additions & 29 deletions graphics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Imports
from argparse import ArgumentParser
from os import path

Expand All @@ -6,86 +7,128 @@
import seaborn as sns
from matplotlib.colors import LogNorm

# Parse execution arguments
parser = ArgumentParser(description="Create graphics from the experiments data.")
parser.add_argument(
"input_file",
help="CSV file to be read and processed. Should be output of launcher.py",
"input_files",
help="CSV files to be read and processed. Should be outputs of launcher.py, from different machines",
nargs="+",
)
parser.add_argument(
"-o", "--out", help="Folder where the images will be saved", required=True
)
parser.add_argument("out_folder", help="Folder where the images will be saved")
args = parser.parse_args()
input_files = args.input_files
out_folder = args.out

# Read the data in every csv input and combine into single dataframe
data = []
for input_file in input_files:
partial_data = pd.read_csv(input_file)
partial_data["Machine"] = input_file.split(".")[0]
data.append(partial_data)
data = pd.concat(data, ignore_index=True)

input_file = args.input_file
data = pd.read_csv(input_file)
# Transform time from microseconds to seconds
data["Time (secs)"] = data["Time"] * 10**-6
# Fix machine names to agree with aws documentation
data["Machine"] = data.apply(lambda x: x["Machine"].replace("_", "."), axis=1)
# Obtain list of unique machines and algorithms
machines = data["Machine"].unique()
algorithms = data["Algorithm"].unique()
num_machines = len(machines)
num_algorithms = len(algorithms)

algorithms = ["row-column", "row-row"]
protocols = ["OpenMP", "MPI"]
fig, ax = plt.subplots(2, 2)
fig.set_size_inches(10, 10)
# Create matplotlib figure to plot time heatmap
fig, ax = plt.subplots(num_machines, num_algorithms)
fig_width = 12
fig.set_size_inches(fig_width, 3 * fig_width // 2)
ax_idx = 0
for protocol in protocols:
# Iterate over every machine and algorithm combination
for machine in machines:
for algorithm in algorithms:
position = divmod(ax_idx, 2)
heatmap = data.query(f"Algorithm == '{algorithm}' and Protocol == '{protocol}'")
# Obtain axis position in figure
position = divmod(ax_idx, num_algorithms)
# Create time heatmap, with matrix vs threads dimensions
heatmap = data.query(f"Algorithm == '{algorithm}' and Machine == '{machine}'")
heatmap = heatmap.pivot_table(
values="Time (secs)",
index="Matrix_Size",
columns="N_Threads",
aggfunc="mean",
)
sns.heatmap(heatmap, norm=LogNorm(), ax=ax[*position])
ax[*position].set_title(f"Protocol={protocol} | Algorithm={algorithm}")
ax[*position].set_title(f"Machine={machine} | Algorithm={algorithm}")
ax_idx += 1
fig.suptitle("Time (secs) for every threads-size combination", fontsize="x-large")
plt.savefig(path.join(args.out_folder, "size-threads-time.png"))
fig.suptitle(
"Time (secs) for every threads-size combination", fontsize="xx-large", x=0.5, y=0.92
)
# Save figure
plt.savefig(path.join(out_folder, "size-threads-time.png"))
# Clear figure
plt.clf()
plt.cla()

# Define data subset with max number of threads and matrix size
data_size2k_threads20 = data.query("Matrix_Size == 2000 and N_Threads == 20")
algorithms = ["row-column", "row-row"]
protocols = ["OpenMP", "MPI"]
fig, ax = plt.subplots(2, 2)
fig.set_size_inches(12, 12)
# Create matplotlib figure to plot time heatmap
fig, ax = plt.subplots(num_machines, num_algorithms)
fig_width = 12
fig.set_size_inches(fig_width, 3 * fig_width // 2)
ax_idx = 0
for protocol in protocols:
# Iterate over every machine and algorithm combination
for machine in machines:
for algorithm in algorithms:
position = divmod(ax_idx, 2)
# Obtain axis position in figure
position = divmod(ax_idx, num_algorithms)
# Create time distribution plot as violinplot
dist = data_size2k_threads20.query(
f"Algorithm == '{algorithm}' and Protocol == '{protocol}'"
f"Algorithm == '{algorithm}' and Machine == '{machine}'"
)
sns.violinplot(dist, y="Time (secs)", inner="quart", ax=ax[*position])
ax[*position].set_title(f"Protocol={protocol} | Algorithm={algorithm}")
ax[*position].set_title(f"Machine={machine} | Algorithm={algorithm}")
ax_idx += 1
fig.suptitle(
"Time (secs) distribution for Matrix_Size=2000, N_Threads=20", fontsize="x-large"
"Time (secs) distribution for Matrix_Size=2000, N_Threads=20",
fontsize="xx-large",
x=0.5,
y=0.92,
)
plt.savefig(path.join(args.out_folder, "distribution.png"))
# Save figure
plt.savefig(path.join(out_folder, "distribution.png"))
# Clear figure
plt.clf()
plt.cla()

# Plot threads vs time lineplots
ax = sns.relplot(
data,
x="N_Threads",
y="Time (secs)",
hue="Matrix_Size",
row="Protocol",
row="Machine",
col="Algorithm",
palette="plasma",
kind="line",
)
plt.savefig(path.join(args.out_folder, "threads-time.png"))
# Save figure
plt.savefig(path.join(out_folder, "threads-time.png"))
# Clear figure
plt.clf()
plt.cla()

# Plot matrix_size vs time lineplots
data["N_Threads"] = data["N_Threads"].astype(str)
ax = sns.relplot(
data,
x="Matrix_Size",
y="Time (secs)",
hue="N_Threads",
row="Protocol",
row="Machine",
col="Algorithm",
palette="plasma",
kind="line",
)
plt.savefig(path.join(args.out_folder, "size-time.png"))
# Save figure
plt.savefig(path.join(out_folder, "size-time.png"))
# Program end
Binary file modified img/distribution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/size-threads-time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/size-time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/threads-time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 272e8a6

Please sign in to comment.