From 14211c98952c3921e7ee360c7f6fc23d58f249bd Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 3 Mar 2021 12:37:46 +0100 Subject: [PATCH] osu: use ggsave and reduce verbosity --- garlic/fig/osu/bw.R | 41 +++++++++++++++++++++++++++------------- garlic/fig/osu/latency.R | 37 ++++++++++++++++++++++++------------ 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/garlic/fig/osu/bw.R b/garlic/fig/osu/bw.R index 6744dbc..d81a894 100644 --- a/garlic/fig/osu/bw.R +++ b/garlic/fig/osu/bw.R @@ -1,5 +1,5 @@ library(ggplot2) -library(dplyr) +library(dplyr, warn.conflicts = FALSE) library(scales) library(jsonlite) @@ -10,7 +10,7 @@ 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)) %>% +dataset = jsonlite::stream_in(file(input_file), verbose=FALSE) %>% jsonlite::flatten() # We only need the nblocks and time @@ -23,11 +23,9 @@ cpusPerTask = unique(df$config.cpusPerTask) df$unitName = as.factor(df$unitName) df$sizeFactor = as.factor(df$size) -ppi=300 -h=8 -w=12 - -png("bw.png", width=w*ppi, height=h*ppi, res=ppi) +df = group_by(df, unitName, sizeFactor) %>% + mutate(medianBw = median(bw)) %>% + ungroup() breaks = 10^(-10:10) minor_breaks <- rep(1:9, 21)*(10^rep(-10:10, each=9)) @@ -39,12 +37,29 @@ p = ggplot(data=df, aes(x=size, y=bw)) + subtitle=input_file) + geom_boxplot(aes(color=unitName, group=interaction(unitName, sizeFactor))) + scale_x_continuous(trans=log2_trans()) + - scale_y_log10(breaks = breaks, minor_breaks = minor_breaks) + + #scale_y_log10(breaks = breaks, minor_breaks = minor_breaks) + theme_bw() + - theme(legend.position = c(0.15, 0.9)) + theme(legend.position = c(0.8, 0.2)) -# Render the plot -print(p) +ppi=300 +h=4 +w=8 +ggsave("boxplot.pdf", plot=p, width=w, height=h, dpi=ppi) +ggsave("boxplot.png", plot=p, width=w, height=h, dpi=ppi) -## Save the png image -dev.off() +p = ggplot(data=df, aes(x=size, y=medianBw)) + + labs(x="Size (bytes)", y="Bandwidth (MB/s)", + title=sprintf("OSU benchmark: osu_bw", + nodes, tasksPerNode, cpusPerTask), + subtitle=input_file) + + geom_line(aes(color=unitName, linetype=unitName)) + + geom_point(aes(color=unitName, shape=unitName)) + + geom_hline(yintercept = 100e3 / 8, color="red") + + annotate("text", x = 8, y = (100e3 / 8) * 0.95, label = "12.5GB/s (100Gb/s)") + + scale_x_continuous(trans=log2_trans()) + + #scale_y_log10(breaks = breaks, minor_breaks = minor_breaks) + + theme_bw() + + theme(legend.position = c(0.8, 0.2)) + +ggsave("median-lines.png", plot=p, width=w, height=h, dpi=ppi) +ggsave("median-lines.pdf", plot=p, width=w, height=h, dpi=ppi) diff --git a/garlic/fig/osu/latency.R b/garlic/fig/osu/latency.R index 53e7bb7..a91fc05 100644 --- a/garlic/fig/osu/latency.R +++ b/garlic/fig/osu/latency.R @@ -1,5 +1,5 @@ library(ggplot2) -library(dplyr) +library(dplyr, warn.conflicts = FALSE) library(scales) library(jsonlite) @@ -10,7 +10,7 @@ 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)) %>% +dataset = jsonlite::stream_in(file(input_file), verbose=FALSE) %>% jsonlite::flatten() # We only need the nblocks and time @@ -23,11 +23,9 @@ cpusPerTask = unique(df$config.cpusPerTask) df$unitName = as.factor(df$unitName) df$sizeFactor = as.factor(df$size) -ppi=300 -h=8 -w=12 - -png("latency.png", width=w*ppi, height=h*ppi, res=ppi) +df = group_by(df, unitName, sizeFactor) %>% + mutate(medianLatency = median(latency)) %>% + ungroup() breaks = 10^(-10:10) minor_breaks <- rep(1:9, 21)*(10^rep(-10:10, each=9)) @@ -41,10 +39,25 @@ p = ggplot(data=df, aes(x=size, y=latency)) + scale_x_continuous(trans=log2_trans()) + scale_y_log10(breaks = breaks, minor_breaks = minor_breaks) + theme_bw() + - theme(legend.position = c(0.15, 0.9)) + theme(legend.position = c(0.8, 0.2)) -# Render the plot -print(p) +ppi=300 +h=4 +w=8 +ggsave("boxplot.png", plot=p, width=w, height=h, dpi=ppi) +ggsave("boxplot.pdf", plot=p, width=w, height=h, dpi=ppi) -## Save the png image -dev.off() +p = ggplot(data=df, aes(x=size, y=medianLatency)) + + labs(x="Size (bytes)", y="Latency (us)", + title=sprintf("OSU benchmark: osu_latency", + nodes, tasksPerNode, cpusPerTask), + subtitle=input_file) + + geom_line(aes(color=unitName, linetype=unitName)) + + geom_point(aes(color=unitName, shape=unitName)) + + scale_x_continuous(trans=log2_trans()) + + scale_y_log10(breaks = breaks, minor_breaks = minor_breaks) + + theme_bw() + + theme(legend.position = c(0.2, 0.8)) + +ggsave("median-lines.png", plot=p, width=w, height=h, dpi=ppi) +ggsave("median-lines.pdf", plot=p, width=w, height=h, dpi=ppi)