Commit d07b6528 authored by Ondrej Mosnáček's avatar Ondrej Mosnáček

Add benchmark scripts

parent 244e582e
#!/bin/bash
dirname="$(dirname "$0")"
bench_id="$1"
src_dir="$2"
if [ -z "$bench_id" ]; then
echo "ERROR: Bench ID not specified!" 1>&2
exit 1
fi
shift 2
max_memory="$1"
batch_size="$2"
samples="$3"
if [ -z "$max_memory" ]; then
echo "ERROR: Max memory not specified!" 1>&2
exit 1
fi
if [ -z "$batch_size" ]; then
echo "ERROR: Batch size not specified!" 1>&2
exit 1
fi
if [ -z "$samples" ]; then
echo "ERROR: Sample count not specified!" 1>&2
exit 1
fi
shift 3
for commit in $@; do
(cd "$src_dir" && git checkout "$commit") || exit 1
make || exit 1
"$dirname/run-benchmark.sh" "$max_memory" "$batch_size" "$samples" \
| tee "bench-$bench_id-$commit.csv" || exit 1
done
#!/usr/bin/Rscript
require(ggplot2)
require(scales)
NS_PER_SEC <- 1000 * 1000 * 1000
theme_set(theme_gray(base_size = 10))
GRAPH_WIDTH_CM <- 10
GRAPH_HEIGHT_CM <- 6
save_graph <- function(name, plot) {
ggsave(paste0(name, '.pdf'), plot, width = GRAPH_WIDTH_CM, height = GRAPH_HEIGHT_CM, scale = 2.3, units = 'cm')
}
args <- commandArgs(trailingOnly = TRUE)
bench_id <- args[1]
commits <- args[2:length(args)]
data <- data.frame()
for (commit in commits) {
file <- paste0('bench-', bench_id, '-', commit, '.csv')
file_data <- read.csv(file)
data <- rbind(data, data.frame(Commit=commit, Mode=file_data$mode, Kernel.mode=file_data$kernel, Version=file_data$version, Type=file_data$type, t_cost=file_data$t_cost, m_cost=file_data$m_cost, lanes=file_data$lanes, ns_per_hash=file_data$ns_per_hash))
}
data$nph_normalized <- data$ns_per_hash / (data$m_cost * data$t_cost)
data$hashes_per_second <- NS_PER_SEC / data$ns_per_hash
data$hps_normalized <- data$m_cost * data$t_cost * data$hashes_per_second
make_plots_hps <- function(mode, kernel, type) {
data_b <- data[data$m_cost >= 4096 & data$Mode == mode & data$Kernel.mode == kernel & data$Version == 'v1.3' & data$Type == paste0('Argon2', type),]
data_b_f_t_cost <- data_b$t_cost %in% c(1, 2, 4, 8, 16)
data_b_f_m_cost <- data_b$m_cost %in% c(4096, 16384, 65536, 262144, 1048576)
prefix <- paste0('plot-', bench_id, '-', mode, '-', kernel, '-argon2', type)
save_graph(paste0(prefix, '-t_cost'),
ggplot(data_b[data_b_f_m_cost,], aes(x=t_cost, y=hps_normalized, group=Commit, colour=Commit)) +
geom_line() +
scale_y_continuous(labels=comma) +
facet_grid(lanes~m_cost, labeller=label_both) +
xlab('t_cost') + ylab('Hashes per second (normalized)'))
save_graph(paste0(prefix, '-m_cost'),
ggplot(data_b[data_b_f_t_cost,], aes(x=m_cost, y=hps_normalized, group=Commit, colour=Commit)) +
geom_line() +
scale_x_log10() +
scale_y_continuous(labels=comma) +
facet_grid(t_cost~lanes, labeller=label_both) +
xlab('m_cost (log scale)') + ylab('Hashes per second (normalized)'))
save_graph(paste0(prefix, '-lanes'),
ggplot(data_b[data_b_f_t_cost & data_b_f_m_cost,], aes(x=lanes, y=hps_normalized, group=Commit, colour=Commit)) +
geom_line() +
scale_y_continuous(labels=comma) +
facet_grid(t_cost~m_cost, labeller=label_both) +
xlab('lanes') + ylab('Hashes per second (normalized)'))
}
for (mode in c('opencl', 'cuda')) {
for (kernel in c('by-segment', 'oneshot')) {
for (type in c('i', 'd')) {
make_plots_hps(mode, kernel, type)
}
}
}
#!/bin/bash
max_memory="$1"
batch_size="$2"
samples="$3"
if [ -z "$max_memory" ]; then
echo "ERROR: Maximum memory must be specified!" 1>&2
exit 1
fi
if [ -z "$batch_size" ]; then
batch_size=256
fi
if [ -z "$samples" ]; then
samples=5
fi
echo "mode,kernel,version,type,t_cost,m_cost,lanes,ns_per_hash"
for mode in opencl cuda; do
for kernel in by-segment oneshot; do
for version in 1.3 1.0; do
for type in i d; do
for (( m_cost = 64; m_cost <= $(( $max_memory / $batch_size )); m_cost *= 4 )); do
for (( t_cost = 1; t_cost <= 16; t_cost *= 2 )); do
for (( lanes = 1; lanes <= 8; lanes *= 2 )); do
ns_per_hash=$(./argon2-gpu-bench -m $mode -k $kernel -b $batch_size -T $t_cost -M $m_cost -L $lanes -o ns-per-hash --output-mode mean -s $samples)
echo "$mode,$kernel,v$version,Argon2$type,$t_cost,$m_cost,$lanes,$ns_per_hash"
done
done
done
done
done
done
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment