Giter Site home page Giter Site logo

saadarazzaq / odd-even-sorting Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 7 KB

Used MPI OpenMP for Parallel Distributed Computing ๐Ÿ’ป

Home Page: https://www.youtube.com/watch?v=bkfCrj-rBjU

C 100.00%
beginner-friendly mpi odd-even-sort openmp parallel-computing parallel-distributed-computing well-documented well-commented-code

odd-even-sorting's Introduction

Odd-Even-Sorting

Introduction

This MPI (Message Passing Interface) program implements the Odd-Even Sort algorithm to efficiently sort an array of integers in parallel across multiple processes. The Odd-Even Sort is a parallel sorting algorithm that works by iteratively comparing and swapping neighboring elements.

Compilation

To compile the program, use the following command:

mpicc -o odd_even_sort odd_even_sort.c -lm

Here,

  • mpicc is the MPI compiler wrapper.
  • -o odd_even_sort specifies the output executable name.
  • odd_even_sort.c is the source code file.
  • -lm is used to link the math library (required for rand() function).

Execution

To execute the program, use the mpirun command:

mpirun -np <num_processes> ./odd_even_sort <number_of_elements>

Here,

  • <num_processes> is the number of MPI processes you want to run.
  • <number_of_elements> is the total number of elements to be sorted.

For example, to run the program with 4 MPI processes and 1000 elements:

mpirun -np 4 ./odd_even_sort 1000

Program Logic

  1. Each MPI process generates a local array of random integers.
  2. The local arrays are sorted individually using qsort.
  3. Processes exchange elements during Odd and Even phases using MPI communication.
  4. The compareSplit function is used to merge the elements based on the process rank.
  5. The sorting process is repeated for a number of iterations equal to the number of processes.

Note

- Ensure that MPI is properly installed on your system.

- Adjust the compilation and execution commands based on your MPI setup.

- The program expects a command-line argument for the number of elements.

Example Compilation:

mpicc -o odd_even_sort odd_even_sort.c -lm
mpirun -np 4 ./odd_even_sort 1000

This will run the program with 4 MPI processes, sorting an array of 1000 elements.

Feel free to modify the program or instructions based on your specific requirements and environment.

Made with ๐Ÿ’– by Saad and Wasif

odd-even-sorting's People

Contributors

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