Giter VIP home page Giter VIP logo

rbga / cuda-merge-and-bitonic-sort Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 0.0 13 KB

Efficient implementations of Merge Sort and Bitonic Sort algorithms using CUDA for GPU parallel processing, resulting in accelerated sorting of large arrays. Includes both CPU and GPU versions, along with a performance comparison.

Cuda 100.00%
algorithm-implementation array-sorting bitonic-sort cplusplus cuda cuda-cpp gpgpu gpu-acceleration gpu-computing gpu-parallelism

cuda-merge-and-bitonic-sort's Introduction

CUDA Merge and Bitonic Sort

This project provides efficient implementations of Merge Sort and Bitonic Sort algorithms using CUDA, enabling fast sorting of large arrays through GPU parallel processing. The project includes both CPU and GPU versions of the algorithms, along with a performance comparison to showcase the benefits of using CUDA for sorting tasks.

Table of Contents

Introduction

Sorting large datasets efficiently is a common computational challenge. Merge Sort and Bitonic Sort are well-known sorting algorithms that can be implemented using parallel processing techniques, such as those provided by CUDA, to achieve significant speedup compared to traditional CPU-based sorting methods.

This project aims to provide an easy-to-use CUDA-based implementation of Merge Sort and Bitonic Sort, enabling users to sort large arrays efficiently on compatible NVIDIA GPUs.

Merge Sort

Merge Sort is a popular divide-and-conquer sorting algorithm that efficiently sorts an array by recursively dividing it into two halves, sorting each half, and then merging the sorted halves to produce the final sorted array.

Bitonic Sort

Bitonic Sort is an efficient parallel sorting algorithm that requires the input size to be a power of 2. It is based on the concept of bitonic sequences, which are sequences that first monotonically increase and then monotonically decrease or vice versa. The algorithm recursively builds a bitonic sequence, and then repeatedly merges bitonic sequences to achieve sorting.

Implementation

The project contains the following implementations:

  • CPU Merge Sort: This is a traditional CPU-based implementation of the Merge Sort algorithm using a recursive approach.

  • GPU Merge Sort: The GPU version of Merge Sort that uses CUDA to achieve parallelism. It utilizes CUDA kernels to perform sorting operations on the GPU.

  • CPU Bitonic Sort: A CPU-based implementation of the Bitonic Sort algorithm. It requires the input size to be a power of 2.

  • GPU Bitonic Sort: The GPU version of Bitonic Sort that takes advantage of CUDA parallelism. Like the GPU Merge Sort, it uses CUDA kernels for sorting on the GPU.

Performance Comparison

The performance comparison section presents benchmark results of the CPU and GPU implementations for both Merge Sort and Bitonic Sort. It measures the execution time for each approach and demonstrates the potential speedup gained by using CUDA on compatible GPUs.

Requirements

To run this project, you need the following:

  • A compatible NVIDIA GPU with CUDA support.
  • NVIDIA CUDA Toolkit installed on your system.
  • C++ compiler with CUDA support (e.g., NVCC).

Usage

  1. Clone or download the project repository to your local machine.
  2. Ensure you have met the requirements mentioned in the previous section.
  3. Compile the source files using the appropriate C++ compiler with CUDA support.
  4. Run the compiled executable to sort arrays using either Merge Sort or Bitonic Sort.
  5. The program will provide sorted arrays and performance timings for both CPU and GPU implementations.

Contributing

Contributions to this project are welcome. If you find any issues or have improvements to suggest, feel free to open an issue or create a pull request.

License

This project is licensed under the MIT License. You are free to use, modify, and distribute the code as per the terms of the license.

Outputs

image Testing the inputs and Merge Sort with a Small Array image Testing Bitonic Sort with a Small Array image Merge Sort CPU vs GPU performance for a large Array image Bitonic Sort CPU vs GPU performance for a large Array.

Clearly Bitonic Sort performs well in a Parallel Computation while Merge Sort performs well in a linear computation.

cuda-merge-and-bitonic-sort's People

Contributors

rbga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  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.