I have recently implemented 2 versions of parallel mergesort using OpenMP which can be found here.

The first step of analyzing the performance was writing a basic shell script to automate the running of tests: run-experiements.sh. It can be found in the root directory of the merge-sort-sections and merge-sort-tasks directories.


run-experiments.sh

#!/bin/bash

thresh=128          # threshold at which sort reverts to insertion
arr_size=$((2**32)) # num of integer elements
num_tests=6         # num of different tests (threads = [2, 4, ... , 2**(num_tests - 1])
num_runs=10         # number of runs/thread count
num_threads=1       # init to 1

for (( i = 1; i <= ${num_tests} * ${num_runs}; i++ ))
do
    if ! ((i % ${num_runs})); then
       num_threads=$((num_threads * 2))
    fi
       ./omp_mergesort ${arr_size} ${thresh} ${num_threads} >> omp-tasks-${num_threads}-${thresh}.txt && wait
done

The && waitis necessary so that the script will wait until the previous run has completed before spawning another instance of the mergesort program. The double && ensures that the program returned an exit status of zero.


As written, the script above will run a total of 60 experiments: 10 runs each for 6 different numbers of threads (1, 2, 4, 8, 16, 32). Each run with the same amount of threads will have its execution time appended to the end of the appropriate output file. So, in this case, executing run-experiments.sh in the merge-sort-tasks directory will cause 6 different files to be created, the first being named omp-tasks-1-128.txt, followed by omp-tasks-2-128.txt, and so on.


Check in next week for some results analysis.