Giter VIP home page Giter VIP logo

juliorodrigues07 / parallel_primes Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5.32 MB

Master-slave parallel implementation to identify prime numbers in an array.

Shell 3.27% Makefile 10.32% C 51.20% Python 35.21%
distributed-computing master-slave openmpi parallel-computing primality-test prime-numbers scatter-gather shared-memory student-project single-program-multiple-data domain-decomposition openmp threads

parallel_primes's Introduction

C99

Identifying Primes with Parallel Computing

Implementation of a master-slave hybrid parallel program (shared and distributed memory) to identify prime numbers in an array, utilizing Open MPI and OpenMP libraries (PAs 1 and 3 from Parallel Computing course - DCOMP - UFSJ).

Requirements

  • GCC compiler:

    sudo apt install gcc
    
  • OpenMP library:

    sudo apt install libomp-dev
    
  • Open MPI library;

  • gprof tool;

  • To install all dependencies:

    ./install_dependencies.sh
    

Optional Requirements

  • Python3 and pip package manager:

    sudo apt install python3 python3-pip build-essential python3-dev
    
  • PyCryptodome library:

    pip install pycryptodomex
    
  • Matplotlib library:

    pip install matplotlib
    
  • seaborn library:

    pip install seaborn
    

Compilation

Execute the following command to compile the source code:

make

Execution

You can alter the parameters, such as the instance file and number of processes in the Makefile. For distributed running, first you may need to gain remote acess to the machines in your network by generating a private key with the following commands:

ssh-keygen
ssh-copy-id <IP_address>
ssh <IP_address>

Also, you may need to change parameters in the hostfile (hosts.txt), such as IP addresses and number of slots (CPU cores).

Sequential

To execute the sequential version with or without profiling, run the following respective commands:

  • Without profiling:

    make sequential
    
  • With profiling (gprof):

    make with_prof
    

OpenMP

  • To execute the program's parallel version with shared memory and OpenMP (You may need to alter the number of threads in the source code - divisors.h), run the following commands:

    make sh_omp
    

Open MPI

Shared

  • Run the following command for executing the program in an unique multicore machine with shared memory:

    make shared_run
    

Distributed

  • Run the following command for executing the program in multiple machines with distributed memory:

    make distributed_run
    

Hybrid (OpenMP and Open MPI)

  • Run the following for executing the parallel program in multiple machines (Distributed memory - MPI | Shared memory - OpenMP):

    make hybrid
    

Optional Running

Instance Generator

Inside instances directory, you can generate your own instances by executing the command using the following template: python3 instance_generator.py --length <number> --quantity <number>

  • Example: Generating an instance file with 10000 numbers, 30 bits long:

    python3 instance_generator.py -l 30 -n 10000
    

Time graphics

Inside plotting directory, you can generate the time graphics presented in this works report by running the following commmand:

python3 times.py

Also, you can generate the graphics that compares execution time between the two libraries (OpenMP and Open MPI) with shared and distributed memory, just by running the following commmand:

python3 benchmark.py

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.