From f558c1e89424ae0214eabfe19b9df3a179a4a253 Mon Sep 17 00:00:00 2001
From: Sebastian Thorarensen <sebth@nsc.liu.se>
Date: Wed, 25 Sep 2024 12:57:54 +0200
Subject: [PATCH] Put all tests in one script

---
 README                   | 23 +----------
 flash.batch              | 35 -----------------
 hdd.batch                | 35 -----------------
 storage-benchmark.sbatch | 84 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+), 92 deletions(-)
 delete mode 100644 flash.batch
 delete mode 100644 hdd.batch
 create mode 100644 storage-benchmark.sbatch

diff --git a/README b/README
index 45ab03b..f998079 100644
--- a/README
+++ b/README
@@ -1,22 +1 @@
-Running the benchmark
----------------------
-
- 1. Make sure 'elbencho' is in PATH.
-
- 2. sbatch -N <1 up to whatever> hdd.batch   <test directory on filesystem>
-    sbatch -N <1 up to whatever> flash.batch <test directory on filesystem>
-
-
-TODOs
------
-
- - Define the metadata tests.
-
- - Add flags to make elbencho use whatever entropy we want for
-   compression, as suggested by hx.
-
- - We agreed on making block size for the streaming HDD test choosable
-   by the vendor.  Make it an argument instead of hard-coding 1M.
-
- - Discuss if it is OK to hard-code thread count.  Right now it is hard-coded
-   to 16.
+Write instructions here, with and without Slurm!
diff --git a/flash.batch b/flash.batch
deleted file mode 100644
index 86c98f6..0000000
--- a/flash.batch
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-#SBATCH -J arrh-storage-benchmark-flash
-
-usage() {
-    echo >&2 "Usage: sbatch [-N NUMNODES] flash.batch DIRECTORY"
-    echo >&2 "Run benchmark creating, writing, and reading files in DIRECTORY"
-    exit 2
-}
-
-if [ $# -ne 1 ]
-then usage
-fi
-
-NUMTHREADS=16
-
-srun --ntasks-per-node=1 --cpus-per-task="$NUMTHREADS" \
-    elbencho --service --foreground > /dev/null &
-
-sleep 5  # wait for services to start
-
-#
-# Random 4K write/read
-#
-echo 'flash.batch: Random 4K write/read'
-elbencho --hosts "$(scontrol show hostnames | tr '\n' ',')" "$1" \
-    -w -r -t "$NUMTHREADS" -s 4G -b 4K -n 0 -F --rand --rotatehosts=1
-
-#
-# Metadata (creat/stat/unlink)
-#
-echo 'flash.batch: Metadata'
-# to be written
-
-elbencho --hosts "$(scontrol show hostnames | tr '\n' ',')" \
-    --quit
diff --git a/hdd.batch b/hdd.batch
deleted file mode 100644
index 7891b6c..0000000
--- a/hdd.batch
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-#SBATCH -J arrh-storage-benchmark-hdd
-
-usage() {
-    echo >&2 "Usage: sbatch [-N NUMNODES] hdd.batch DIRECTORY"
-    echo >&2 "Run benchmark creating, writing, and reading files in DIRECTORY"
-    exit 2
-}
-
-if [ $# -ne 1 ]
-then usage
-fi
-
-NUMTHREADS=16
-
-srun --ntasks-per-node=1 --cpus-per-task="$NUMTHREADS" \
-    elbencho --service --foreground > /dev/null &
-
-sleep 5  # wait for services to start
-
-#
-# Sequential write/read
-#
-echo 'hdd.batch: Sequential write/read'
-elbencho --hosts "$(scontrol show hostnames | tr '\n' ',')" "$1" \
-    -w -r -t "$NUMTHREADS" -s 4G -b 1M -n 0 -F --rotatehosts=1
-
-#
-# Metadata (creat/stat/unlink)
-#
-echo 'hdd.batch: Metadata'
-# to be written
-
-elbencho --hosts "$(scontrol show hostnames | tr '\n' ',')" \
-    --quit
diff --git a/storage-benchmark.sbatch b/storage-benchmark.sbatch
new file mode 100644
index 0000000..616237e
--- /dev/null
+++ b/storage-benchmark.sbatch
@@ -0,0 +1,84 @@
+#!/bin/sh
+#SBATCH -J arrh-storage-benchmark
+
+usage() {
+    echo "Usage: sbatch -N <number of nodes> --cpus-per-task=<threads per node> storage-benchmark.sbatch [ stream <blocksize> | iops | meta ] <directory>"
+    exit 2
+}
+
+info() {
+    echo "storage-benchmark.sbatch:" "$@"
+}
+
+##
+## Argument handling
+##
+
+MODE=$1
+if [ "$MODE" = stream ]
+then
+    BLOCKSIZE=$2
+    shift
+elif [ "$MODE" = iops ] || [ "$MODE" = meta ]
+then :
+else usage
+fi
+
+DIRECTORY=$2
+if [ -z "$DIRECTORY" ]
+then usage
+fi
+
+NNODES=$SLURM_NNODES
+THREADS=$SLURM_CPUS_PER_TASK
+HOSTS=$(scontrol show hostnames | tr '\n' ',')
+
+info "Mode: $MODE"
+if [ "$BLOCKSIZE" ]
+then info "Block size: $BLOCKSIZE"
+fi
+info "Number of nodes: $NNODES"
+info "Threads per node: $THREADS"
+elbencho --version
+
+##
+## The benchmark
+##
+
+info "Starting service on all nodes"
+srun --ntasks-per-node=1 elbencho --service --foreground > /dev/null &
+sleep 5  # wait for services to start
+
+info "Starting storage benchmark"
+echo
+
+if [ "$MODE" = stream ]
+then
+
+    # 1024 GiB per node
+    SIZE=$((1 * 1024 * 1024 * 1024 / THREADS))
+    elbencho --hosts "$HOSTS" --rotatehosts=1 -t "$THREADS" \
+	-w -r -s "$SIZE"K -b "$BLOCKSIZE" -n 0 -F "$DIRECTORY"
+
+elif [ "$MODE" = iops ]
+then
+
+    # 128 GiB per node
+    SIZE=$((128 * 1024 * 1024 / THREADS))
+    elbencho --hosts "$HOSTS" --rotatehosts=1 -t "$THREADS" \
+	-w -r -s "$SIZE"K -b 4K -n 0 -F --rand "$DIRECTORY"
+
+elif [ "$MODE" = meta ]
+then
+
+    # 10M files per node
+    FILES=$((10000000 / THREADS))
+    elbencho --hosts "$HOSTS" --rotatehosts=1 -t "$THREADS" \
+	-d -w --stat -F -N "$FILES" -D "$DIRECTORY"
+
+fi
+
+echo
+info "Benchmark done"
+
+elbencho --hosts "$HOSTS" --quit
-- 
GitLab