Skip to content
Snippets Groups Projects
storage-benchmark.sbatch 1.58 KiB
Newer Older
  • Learn to ignore specific revisions
  • Åke Sandgren's avatar
    Åke Sandgren committed
    #!/bin/bash
    
    #SBATCH -J arrh-storage-benchmark
    
    usage() {
    
    Sebastian Thorarensen's avatar
    Sebastian Thorarensen committed
        echo "Usage: sbatch -N <number of nodes> --cpus-per-task=<threads per node> storage-benchmark.sbatch [ sequential <blocksize> | iops | meta ] <bytes or files per thread> <directory>"
    
        exit 2
    }
    
    info() {
        echo "storage-benchmark.sbatch:" "$@"
    }
    
    ##
    ## Argument handling
    ##
    
    MODE=$1
    
    Sebastian Thorarensen's avatar
    Sebastian Thorarensen committed
    if [ "$MODE" = sequential ]
    
    then
        BLOCKSIZE=$2
        shift
    elif [ "$MODE" = iops ] || [ "$MODE" = meta ]
    then :
    else usage
    fi
    
    
    Sebastian Thorarensen's avatar
    Sebastian Thorarensen committed
    BYTES_OR_FILES=$2
    if [ -z "$BYTES_OR_FILES" ]
    then usage
    fi
    
    DIRECTORY=$3
    
    if [ -z "$DIRECTORY" ]
    then usage
    fi
    
    
    Åke Sandgren's avatar
    Åke Sandgren committed
    mkdir -p $DIRECTORY
    
    
    NNODES=$SLURM_NNODES
    THREADS=$SLURM_CPUS_PER_TASK
    HOSTS=$(scontrol show hostnames | tr '\n' ',')
    
    info "Mode: $MODE"
    if [ "$BLOCKSIZE" ]
    
    Sebastian Thorarensen's avatar
    Sebastian Thorarensen committed
    then info "Blocksize: $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 &
    
    Sebastian Thorarensen's avatar
    Sebastian Thorarensen committed
    sleep 10  # wait for services to start
    
    
    info "Starting storage benchmark"
    echo
    
    
    Sebastian Thorarensen's avatar
    Sebastian Thorarensen committed
    if [ "$MODE" = sequential ]
    
    then
    
        elbencho --hosts "$HOSTS" --rotatehosts=1 -t "$THREADS" \
    
    Sebastian Thorarensen's avatar
    Sebastian Thorarensen committed
    	-w -r -b "$BLOCKSIZE" -s "$BYTES_OR_FILES" -n 0 -F "$DIRECTORY"
    
    
    elif [ "$MODE" = iops ]
    then
    
        elbencho --hosts "$HOSTS" --rotatehosts=1 -t "$THREADS" \
    
    Sebastian Thorarensen's avatar
    Sebastian Thorarensen committed
    	-w -r -b 4K -s "$BYTES_OR_FILES" -n 0 -F --rand "$DIRECTORY"
    
    
    elif [ "$MODE" = meta ]
    then
    
        elbencho --hosts "$HOSTS" --rotatehosts=1 -t "$THREADS" \
    
    Sebastian Thorarensen's avatar
    Sebastian Thorarensen committed
    	-d -w --stat -F -N "$BYTES_OR_FILES" -D "$DIRECTORY"
    
    
    fi
    
    echo
    info "Benchmark done"
    
    elbencho --hosts "$HOSTS" --quit
    
    Åke Sandgren's avatar
    Åke Sandgren committed
    
    wait