Giter VIP home page Giter VIP logo

alternativeparallelquicksort's Introduction

Alternative Parallel Quicksort

This was a university project for high performance and parallel computing with the challenge of implementing and optimizing an alternative parallel quicksort algorithm in C. While OpenMPI would have trivialized the implementation, the only allowed choices where Pthreads or OpenMP and unfortunately OpenMP does not offer the required low-level control over individual threads, so it had to be Pthreads.

Instead of adding more threads in each iteration/recursion (with e.g. OpenMP Tasks) as one would do for a trivial parallelisation of quicksort, this algorithm focuses on splitting the data up, sorting the chunks locally, and then merging them back up. It is more closely related to a Merge-Splitting-Sort as presented by Selim G. Akl in Parallel Sorting Algorithms but please check the report for details.

The merge process requires low-level synchronization of the threads but fine-graining the barriers allows for processes to pick up other threads when their current thread is waiting. Furthermore, the serial operations of the program have been operations in terms of arithmetics, memory, caching, and vectorization.

Generate Test Data

$ make generator
$ mkdir -p INPUT_DIR
$ ./generator N INPUT_DIR DIST SEED
  • N = input size
  • INPUT_DIR = directory to store file
  • DIST = distribution 0. Randomly ordered integers from 0 to N -1
    1. Random integers
    2. Sorted integers from 0 to N - 1
    3. Sorted integers from N - 1 to 0
  • SEED = random seed, 0: current time

or

$ make generate N=.. INPUT_DIR=.. DIST=.. SEED=..

Compile

gcc quicksort.c -o quicksort -Wall -O3 -ffast-math -march=native -lpthread

optional flags:

  • -DCHECK_SORTED: checks if the output array is sorted
  • -DCHECK_COMPLETE: checks if output[i] == i (do not use for Random Int Distribution)

or

$ make (-DCHECK_SORTED) (-DCHECK_COMPLETE)

Run

$ ./quicksort N F T S
  • N = Input size
  • F = Binary file containing N integers
  • T = Number of threads
  • S = pivot strategy
    1. select the median of the local array of the first thread in each group
    2. select the mean value of all local medians in each group
    3. select the mean value of the center two medians in each group

or

$ make run N=.. F=.. T=.. S=..

alternativeparallelquicksort's People

Contributors

tobi208 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.