bscpkgs/garlic/fig/osu/latency.R

77 lines
2.7 KiB
R
Raw Normal View History

2021-02-24 00:52:48 +08:00
library(ggplot2)
2021-03-03 19:37:46 +08:00
library(dplyr, warn.conflicts = FALSE)
2021-02-24 00:52:48 +08:00
library(scales)
library(jsonlite)
2021-04-09 22:02:28 +08:00
library(stringr)
2021-02-24 00:52:48 +08:00
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
2021-03-03 19:37:46 +08:00
dataset = jsonlite::stream_in(file(input_file), verbose=FALSE) %>%
2021-02-24 00:52:48 +08:00
jsonlite::flatten()
# We only need the nblocks and time
df = select(dataset, config.unitName, config.nodes, config.ntasksPerNode, config.cpusPerTask, size, latency) %>%
2021-04-09 22:02:28 +08:00
rename(unitName=config.unitName) %>%
mutate(unitName=str_replace(unitName, "osu-latency-", ""))
2021-02-24 00:52:48 +08:00
nodes = unique(df$config.nodes)
tasksPerNode = unique(df$config.ntasksPerNode)
cpusPerTask = unique(df$config.cpusPerTask)
2021-02-24 00:52:48 +08:00
df$unitName = as.factor(df$unitName)
df$sizeFactor = as.factor(df$size)
2021-03-03 19:37:46 +08:00
df = group_by(df, unitName, sizeFactor) %>%
mutate(medianLatency = median(latency)) %>%
ungroup()
2021-02-24 00:52:48 +08:00
breaks = 10^(-10:10)
minor_breaks <- rep(1:9, 21)*(10^rep(-10:10, each=9))
2021-04-09 22:02:28 +08:00
ppi=300
h=3
w=6
p = ggplot(data=df, aes(x=size, y=medianLatency)) +
labs(x="Message size", y="Median latency (µs)",
#title=sprintf("OSU benchmark: osu_latency", nodes, tasksPerNode, cpusPerTask),
subtitle=gsub("-", "\uad", input_file)) +
geom_line(aes(linetype=unitName)) +
geom_point(aes(shape=unitName), size=2) +
scale_y_log10(breaks = breaks, minor_breaks = minor_breaks) +
2021-04-09 22:02:28 +08:00
scale_x_continuous(trans=log2_trans(),
labels=label_bytes("auto_binary"),
n.breaks = 12)+
scale_shape_discrete(name = "MPI version") +
scale_linetype_discrete(name = "MPI version") +
2021-02-24 00:52:48 +08:00
theme_bw() +
2021-04-09 22:02:28 +08:00
theme(plot.subtitle = element_text(size=8, family="mono")) +
theme(legend.justification = c(0,1), legend.position = c(0.01, 0.99)) +
theme(axis.text.x = element_text(angle=-45, hjust=0))
2021-02-24 00:52:48 +08:00
2021-04-09 22:02:28 +08:00
ggsave("median-lines.png", plot=p, width=w, height=h, dpi=ppi)
ggsave("median-lines.pdf", plot=p, width=w, height=h, dpi=ppi)
2021-03-03 19:37:46 +08:00
2021-04-09 22:02:28 +08:00
p = ggplot(data=df, aes(x=size, y=latency)) +
2021-03-03 19:37:46 +08:00
labs(x="Size (bytes)", y="Latency (us)",
2021-04-09 22:02:28 +08:00
#title=sprintf("OSU benchmark: osu_latency", nodes, tasksPerNode, cpusPerTask),
subtitle=input_file) +
geom_line(aes(y=medianLatency, linetype=unitName, group=unitName)) +
geom_point(aes(shape=unitName), size=2) +
2021-03-03 19:37:46 +08:00
scale_y_log10(breaks = breaks, minor_breaks = minor_breaks) +
2021-04-09 22:02:28 +08:00
scale_x_continuous(trans=log2_trans(),
labels=label_bytes("auto_binary"),
breaks=unique(df$size),
minor_breaks=NULL) +
2021-03-03 19:37:46 +08:00
theme_bw() +
2021-04-09 22:02:28 +08:00
theme(plot.subtitle = element_text(color="gray50")) +
theme(axis.text.x = element_text(angle=-45, hjust=0)) +
2021-03-03 19:37:46 +08:00
theme(legend.position = c(0.2, 0.8))
2021-02-24 00:52:48 +08:00
2021-04-09 22:02:28 +08:00
ggsave("latency.png", plot=p, width=w, height=h, dpi=ppi)
ggsave("latency.pdf", plot=p, width=w, height=h, dpi=ppi)