GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - cermi29/ParallelStableSort: A parallel stable sort using arbitrary extra memory

BranchesTags
Open more actions menu

Latest commit

 

History

7 Commits
7 Commits

Folders and files

NameName
Last commit message
Last commit date
images
images
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
hybridsort.h
hybridsort.h
 
 

Repository files navigation

Parallel Stable Sort

This repository contains a parallel stable sort using arbitrary extra memory written in C++. It combines classic mergesort, insertion sort and an in-place merging method described in [1]. It is able to utilize varying sizes of element buffers ranging from no buffer at all to the classic buffer with same length as input (or half the input length in sequential version). Though it degrades to using no buffer if specified length would not bring a speedup (generally at least a fraction of $\sqrt{n}$ is needed, where $n$ is the length of the input). The code is parallelized using OpenMP.

Performance

What follows is a brief showcase of what performance to expect. Tests were done on a machine with 2x Xeon E5-2620 v2 (12 cores, 24 threads) using a randomly sorted array of $10^8$ integers.

Single thread performance compared with std::stable_sort from STL:

Algorithm: Out-place mergesort std::stable_sort In-place mergesort
Time: 9.698 s 10.750 s 15.692 s

Sequential time based on buffer size:

Parallel time using 24 threads based on buffer size (x stands for minimum buffer size to be used by 1 thread):

Out-place mergesort parallel speedup:

In-place mergesort parallel speedup:

Usage Example

#include "hybridsort.h"
…
std::vector<int> vec;
…
HybridSort(vec.begin(), vec.end()); // by default sorts with extra buffer of elements with length equal to end - begin
HybridSort(vec.begin(), vec.end(), compare_func); // sorts while using compare_func to compare elements
HybridSort(vec.begin(), vec.end(), std::less<>(), 0); // sorts with no extra memory buffer
HybridSort(vec.begin(), vec.end(), std::less<>(), -1LL); // sorts with maximum extra memory buffer
HybridSort(vec.begin(), vec.end(), std::less<>(), 1000, 4); // sorts with a buffer of 1000 elements using 4 threads

References

[1] Kim, PS., Kutzner, A. (2008). Ratio Based Stable In-Place Merging. In: Agrawal, M., Du, D., Duan, Z., Li, A. (eds) Theory and Applications of Models of Computation. TAMC 2008. Lecture Notes in Computer Science, vol 4978. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-79228-4_22

About

A parallel stable sort using arbitrary extra memory

Topics

in-placeinsertion-sortinsertionsortmergemerge-sortmergesortopenmpparallel-sortparallel-sortingsortsortingsorting-algorithmssorting-algorithms-implementedstable-sortstable-sorting

Resources

Readme
GPL-3.0 license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.