Giter Club home page Giter Club logo

matrix-multiplication-pthreads-openmp's Introduction

Matrix Calculation With Parallel Programming Using Pthreads and OpenMP (Shared Memory)

Programs built for the subject "Special Topics in Internet of Things" of the bachelor's degree in information technology - BTI of the Federal University of Rio Grande do Norte - UFRN.

The problem

The work requires the multiplication between two matrices A and B resulting in a matrix C. By definition, the matrices must be squares, that is, the number of rows is equal to the number of columns. Both the serial implementation and the parallel implementation were made.

The solutions

Serial

The serial program is easy to understand, and some comments were made to improve that.

To run:

Compilation: gcc -g -Wall -o serial_matrix serial_matrix_calc.c

Execution: ./serial_matrix SZ_OF_PROBLEM

SZ_OF_PROBLEM is a int that represents the number of lines of the matrix.

Parallel

The parallel implementation was constructed so that each thread created individually calculates a random element of the array C. For this, an auxiliary structure (stack) was created. The elements (pairs x and y) are drawn and stacked so that the threads remove them. This removal occurs in a critical region controlled by a Mutex, in the case of the implementation in pthread.

To run:

Compilation: gcc -g -Wall -o matrix matrix_calc.c -lpthread

Execution: ./matrix SZ_OF_THREADS SZ_OF_PROBLEM

SZ_OF_PROBLEM is a int that represents the number of lines of the matrix.
SZ_OF_THREADS is a int that represents the number of threads used.

Scripts and outputs

Two scripts were created to atutomate programs. The run-time outputs will ve in the time_de_exec.txt and time_de_exec_serial.txt.

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.