The purpose of this project is to implement parallel algorithms using OpenMP and CUDA. The source code files address different exercise problems. This project was part of a course I did in my 9th semester.
To use the files in this repository, you will need the following:
- GCC in order to run openMP files.
- NVDIA Cuda Toolkit in order to run CUDA files.
To get started with this project, follow these steps:
-
Clone this repository to your local machine.
-
Compile the source code file using the appropriate compiler and compile flags.
For openMP:
gcc file.c -o file -fopenmp
For CUDA:
nvcc file.cu -o file
-
Run the executable file generated by the compilation process.
./file
This repository contains the following files:
- Source_Code_1.c
- Source_Code_2A.c
- Source_Code_2B_1.c
- Source_Code_2B_2.c
- Source_Code_2B_3.c
A matrix A(NxN) is called "strictly dominating diagonal" if for each row of 'i' it is true that:
|π’ππ| > β |π΄ππ| where j=0β¦N-1 i<>j
- Check (in parallel) whether the matrix A is strictly diagonally dominated.
- If this is the case, calculate in parallel (use OpenMP's reduction clause appropriately at this point) the maximum (m) in absolute value element of the diagonal of
Ξ (m = max(|π’ππ|), i=0β¦N-1)
- Then based on this (m) make (in parallel) a new table B(ΓΏxN) (which it will print at the end on the screen) where:
π΅ππ = m β |π΄ππ| Ξ³ΞΉΞ± i<>j ΞΊΞ±ΞΉ π΅ππ = m Ξ³ΞΉΞ± i=j
- For the above table B , it is also requested to calculate in parallel (and print on the screen) its minimum value element using the reduction clause.
Write a program in OpenMP that sorts a sequence of N integers A[0β¦N-1] in parallel, according to the recursive sorting algorithm 'multisort'.
Write a program in CUDA to calculate the 2-D convolution. Specifically, given a 2-D register A, to calculate its new value at position (i,j) both the current value of that specific position and the values of all its neighboring elements (9 values in total) are used, each of which is multiplied by a "weight". The calculation is shown in the figure below. For the new register A' that will result from the calculations, it is also requested to find the minimum value (min) of the elements of its diagonal.
Aβ(i, j) = c11 β A(i - 1, j - 1) + c12 β A(i, j - 1) + c13 β A(i + 1, j - 1) +
c21 β A(i - 1, j) + c22 β A(i, j) + c23 β A(i + 1, j) +
c31 β A(i - 1, j + 1) + c32 β A(i, j + 1) + c33 β A(i + 1, j + 1)
Write a program in CUDA that, given a 2-D register A of dimensions NxM and a vector x of size M, is asked to compute the expression
A^T * A * x
that is the product of the inverse of the register times the original register times the vector x. For limiting the number of transactions and the intermediate storage space that required for the calculation, the A β x calculation is performed first.
Write a CUDA program that, given a 2-D matrix A, calculates the covariance matrix of A as follows:
- For each column of register A calculates the average of the elements of the column.
- From each element of a column of register A subtracts the average of the corresponding column calculated in the previous step.
- Multiplies the A register of the previous step by the inverse of this register. Because the resulting register is symmetric, it is sufficient to calculate either the upper or lower triangular part of the result.
This is a university project so you can not contribute.
- [University of West Attica] - Provided the exersice
- [Achilleas Pappas] - Wrote the code
This project is licensed by University of West Attica as is a part of a university course. Do not redistribute.
Thank you to University of West Attica and my professors for providing the resources and knowledge to complete this project.