fwi: update strong scaling figure script

This commit is contained in:
Rodrigo Arias Mallo 2021-04-14 17:16:12 +02:00
parent 99c6196734
commit 8ce2a68cd7
2 changed files with 94 additions and 120 deletions

94
garlic/fig/fwi/ss.R Normal file
View File

@ -0,0 +1,94 @@
library(ggplot2)
library(dplyr, warn.conflicts = FALSE)
library(scales)
library(jsonlite)
library(viridis, warn.conflicts = FALSE)
library(stringr)
args = commandArgs(trailingOnly=TRUE)
# Set the input dataset if given in argv[1], or use "input" as default
if (length(args)>0) { input_file = args[1] } else { input_file = "input" }
df = jsonlite::stream_in(file(input_file), verbose=FALSE) %>%
jsonlite::flatten() %>%
select(unit,
config.blocksize,
config.gitBranch,
config.nodes,
time) %>%
rename(blocksize=config.blocksize,
nodes=config.nodes,
gitBranch=config.gitBranch) %>%
# Remove the "garlic/" prefix from the gitBranch
mutate(branch = str_replace(gitBranch, "garlic/", "")) %>%
mutate(time.nodes = time * nodes) %>%
mutate(unit = as.factor(unit)) %>%
mutate(gitBranch = as.factor(gitBranch)) %>%
mutate(branch = as.factor(branch)) %>%
mutate(blocksize = as.factor(blocksize)) %>%
mutate(nodes = as.factor(nodes)) %>%
group_by(unit) %>%
mutate(median.time = median(time)) %>%
mutate(median.time.nodes = median(time.nodes)) %>%
mutate(normalized.time = time / median.time - 1) %>%
ungroup()
dpi = 300
h = 6
w = 6
main_title = "FWI strong scaling"
# ---------------------------------------------------------------------
p = ggplot(df, aes(x=nodes, y=normalized.time)) +
geom_boxplot() +
geom_hline(yintercept=c(-0.01, 0.01), linetype="dashed", color="red") +
theme_bw() +
facet_wrap(branch ~ .) +
labs(x="nodes", y="Normalized time",
title=sprintf("%s: normalized time", main_title),
subtitle=input_file) +
theme(plot.subtitle=element_text(size=8))
ggsave("normalized.time.png", plot=p, width=w, height=h, dpi=dpi)
ggsave("normalized.time.pdf", plot=p, width=w, height=h, dpi=dpi)
# ---------------------------------------------------------------------
p = ggplot(df, aes(x=nodes, y=time, color=gitBranch)) +
geom_point(shape=21, size=3) +
geom_line(aes(y=median.time, group=gitBranch)) +
theme_bw() +
# facet_wrap(branch ~ .) +
labs(y="Time (s)",
title=sprintf("%s: time", main_title),
subtitle=input_file) +
theme(plot.subtitle=element_text(size=8))
ggsave("time.png", plot=p, width=w, height=h, dpi=dpi)
ggsave("time.pdf", plot=p, width=w, height=h, dpi=dpi)
# ---------------------------------------------------------------------
p = ggplot(df, aes(x=nodes, y=time.nodes, color=branch)) +
geom_point(shape=21, size=3) +
geom_line(aes(y=median.time.nodes, group=branch)) +
theme_bw() +
#facet_wrap(branch ~ .) +
labs(x="nodes", y="Time * nodes (s)",
title=sprintf("%s: time * nodes", main_title),
subtitle=input_file) +
theme(plot.subtitle=element_text(size=8))
ggsave("time.nodes.png", plot=p, width=w, height=h, dpi=dpi)
ggsave("time.nodes.pdf", plot=p, width=w, height=h, dpi=dpi)

View File

@ -1,120 +0,0 @@
library(ggplot2)
library(dplyr)
library(scales)
library(jsonlite)
args=commandArgs(trailingOnly=TRUE)
# Read the timetable from args[1]
input_file = "input.json"
if (length(args)>0) { input_file = args[1] }
# Load the dataset in NDJSON format
dataset = jsonlite::stream_in(file(input_file)) %>%
jsonlite::flatten()
# Select block size to display
useBlocksize = 2
# We only need the nblocks and time
df = select(dataset, config.blocksize, config.gitBranch, config.nodes, time) %>%
rename(
blocksize=config.blocksize,
gitBranch=config.gitBranch,
nodes=config.nodes
) %>%
filter(blocksize == useBlocksize | blocksize == 0) %>%
group_by(nodes, gitBranch) %>%
mutate(mtime = median(time)) %>%
mutate(nxmtime = mtime * nodes) %>%
mutate(nxtime = time * nodes) %>%
ungroup()
df$gitBranch = as.factor(df$gitBranch)
df$blocksize = as.factor(df$blocksize)
df$nodes = as.factor(df$nodes)
ppi=300
h=5
w=5
####################################################################
### Line plot (time)
####################################################################
png("time.png", width=w*ppi, height=h*ppi, res=ppi)
p = ggplot(df, aes(x=nodes, y=time, group=gitBranch, color=gitBranch)) +
geom_point() +
geom_line() +
theme_bw() +
labs(x="Nodes", y="Time (s)", title="FWI strong scaling",
subtitle=input_file) +
theme(plot.subtitle=element_text(size=8)) +
theme(legend.position = c(0.6, 0.75))
# Render the plot
print(p)
# Save the png image
dev.off()
####################################################################
### Line plot (time x nodes)
####################################################################
png("nxtime.png", width=w*ppi, height=h*ppi, res=ppi)
p = ggplot(df, aes(x=nodes, y=nxtime, group=gitBranch, color=gitBranch)) +
geom_point() +
geom_line() +
theme_bw() +
labs(x="Nodes", y="Time * Nodes (s)", title="FWI strong scaling",
subtitle=input_file) +
theme(plot.subtitle=element_text(size=8)) +
theme(legend.position = c(0.15, 0.80)) +
theme(legend.text = element_text(size = 7))
# Render the plot
print(p)
# Save the png image
dev.off()
####################################################################
### Line plot (median time)
####################################################################
png("mediantime.png", width=w*ppi, height=h*ppi, res=ppi)
p = ggplot(df, aes(x=nodes, y=mtime, group=gitBranch, color=gitBranch)) +
geom_point() +
geom_line() +
theme_bw() +
labs(x="Nodes", y="Median Time (s)", title="FWI strong scaling",
subtitle=input_file) +
theme(plot.subtitle=element_text(size=8)) +
theme(legend.position = c(0.5, 0.88))
# Render the plot
print(p)
# Save the png image
dev.off()
####################################################################
### Line plot (nodes x median time)
####################################################################
png("nxmtime.png", width=w*ppi, height=h*ppi, res=ppi)
p = ggplot(df, aes(x=nodes, y=nxmtime, group=gitBranch, color=gitBranch)) +
geom_point() +
geom_line() +
theme_bw() +
labs(x="Nodes", y="Median Time * Nodes (s)", title="FWI strong scaling",
subtitle=input_file) +
theme(plot.subtitle=element_text(size=8)) +
theme(legend.position = c(0.5, 0.88))
# Render the plot
print(p)
# Save the png image
dev.off()