https://github.com/vitumenezes/matrix-multiplication-pthreads-openmp
Matrix multiplication using the parallel programming paradigm (shared memory) in C with Pthreads and OpenMP
https://github.com/vitumenezes/matrix-multiplication-pthreads-openmp
c openmp parallel-programming pthreads shared-memory
Last synced: 8 months ago
JSON representation
Matrix multiplication using the parallel programming paradigm (shared memory) in C with Pthreads and OpenMP
- Host: GitHub
- URL: https://github.com/vitumenezes/matrix-multiplication-pthreads-openmp
- Owner: vitumenezes
- Created: 2019-05-02T17:50:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-12T17:29:55.000Z (over 6 years ago)
- Last Synced: 2025-03-28T14:11:18.218Z (9 months ago)
- Topics: c, openmp, parallel-programming, pthreads, shared-memory
- Language: C
- Homepage:
- Size: 532 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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**.