bscpkgs/garlic/fig/nbody/test.R

103 lines
2.2 KiB
R
Raw Normal View History

2020-10-16 15:55:52 +02:00
library(ggplot2)
library(dplyr)
library(scales)
2020-10-23 10:53:39 +02:00
library(jsonlite)
2020-10-16 15:55:52 +02:00
2020-10-23 10:53:39 +02:00
args=commandArgs(trailingOnly=TRUE)
2020-10-16 15:55:52 +02:00
2020-10-23 10:53:39 +02:00
# 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()
particles = unique(dataset$config.particles)
# We only need the nblocks and time
df = select(dataset, config.nblocks, config.hw.cpusPerSocket, time) %>%
rename(nblocks=config.nblocks,
cpusPerSocket=config.hw.cpusPerSocket)
df = df %>% mutate(blocksPerCpu = nblocks / cpusPerSocket)
df$nblocks = as.factor(df$nblocks)
2020-10-16 15:55:52 +02:00
# Normalize the time by the median
2020-10-23 10:53:39 +02:00
D=group_by(df, nblocks) %>%
mutate(tnorm = time / median(time) - 1)
2020-10-23 10:53:39 +02:00
bs_unique = unique(df$nblocks)
nbs=length(bs_unique)
print(D)
2020-10-23 10:53:39 +02:00
ppi=300
h=5
w=5
png("box.png", width=w*ppi, height=h*ppi, res=ppi)
#
#
#
2020-10-23 10:53:39 +02:00
# Create the plot with the normalized time vs nblocks
2020-10-27 10:49:00 +01:00
p = ggplot(data=D, aes(x=nblocks, y=tnorm)) +
2020-10-16 15:55:52 +02:00
# Labels
2020-10-27 10:49:00 +01:00
labs(x="Blocks", y="Normalized time",
2020-10-23 10:53:39 +02:00
title=sprintf("Nbody normalized time. Particles=%d", particles),
subtitle=input_file) +
2020-10-16 15:55:52 +02:00
# Center the title
#theme(plot.title = element_text(hjust = 0.5)) +
# Black and white mode (useful for printing)
#theme_bw() +
2020-10-23 10:53:39 +02:00
# Add the maximum allowed error lines
2020-10-27 10:49:00 +01:00
#geom_hline(yintercept=c(-0.01, 0.01),
# linetype="dashed", color="red") +
2020-10-16 15:55:52 +02:00
2020-10-23 10:53:39 +02:00
# Draw boxplots
geom_boxplot() +
2020-10-16 15:55:52 +02:00
2020-10-27 10:49:00 +01:00
#scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) +
2020-10-16 15:55:52 +02:00
2020-10-23 10:53:39 +02:00
theme_bw() +
theme(plot.subtitle=element_text(size=8)) +
theme(legend.position = c(0.85, 0.85)) #+
# Place each variant group in one separate plot
#facet_wrap(~jemalloc)
2020-10-16 15:55:52 +02:00
# Render the plot
print(p)
2020-10-23 10:53:39 +02:00
## Save the png image
dev.off()
#
2020-10-23 10:53:39 +02:00
png("scatter.png", width=w*ppi, height=h*ppi, res=ppi)
#
2020-10-23 10:53:39 +02:00
## Create the plot with the normalized time vs nblocks
2020-10-27 10:49:00 +01:00
p = ggplot(D, aes(x=nblocks, y=time)) +
2020-10-23 10:53:39 +02:00
2020-10-27 10:49:00 +01:00
labs(x="Blocks", y="Time (s)",
2020-10-23 10:53:39 +02:00
title=sprintf("Nbody granularity. Particles=%d", particles),
subtitle=input_file) +
theme_bw() +
theme(plot.subtitle=element_text(size=8)) +
theme(legend.position = c(0.5, 0.88)) +
2020-10-27 10:49:00 +01:00
geom_point(shape=21, size=3) # +
#scale_y_continuous(trans=log2_trans())
2020-10-23 10:53:39 +02:00
# Render the plot
print(p)
2020-10-16 15:55:52 +02:00
# Save the png image
2020-10-23 10:53:39 +02:00
dev.off()