Skip to content

University project of the Parallel Computing course. There are two challenges that are solved using parallel computing techniques and two famous frameworks: OpenMP and CUDA.

Notifications You must be signed in to change notification settings

PoliMI-HPC-E-notes-projects-AndreVale69/Parallel-Computing-Challenges

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Challenges of Parallel Computing - OpenMP and CUDA

OpenMP CUDA

Description

The repository contains a set of challenges to be solved using parallel computing techniques. The challenges are designed to be solved using the OpenMP and CUDA frameworks.

The challenges are part of the Parallel Computing course at the Politecnico di Milano.

The challenges fall into two main categories:

  • Challenge 1 - OpenMP. This challenge is designed to parallelize the Merge Sort algorithm using the OpenMP framework.
  • Challenge 2 - CUDA. The goal of this challenge is to parallelize the 2D convolution algorithm using the CUDA framework. Two solutions are proposed: a naive solution using the GPU and an advanced solution using shared memory (tiling technique).

How to run the code

Of course, you need to have the OpenMP and CUDA frameworks installed on your machine to run the following code. You will also need a compatible GPU to run the CUDA code (otherwise you can use the Google Colab).

If you have CLion installed, this is a simple story. Just open the project and run the code using the provided CMakeLists.txt file.

Otherwise, you can compile the code using the command line.

  1. Compile the CMakeFiles:
    cd Parallel-Computing-Challenges # repository folder
    cmake . # where the CMakeLists.txt file is located
  2. Compile all the challenges using the following commands:
    # assuming you are in the repository folder where the CMakeLists.txt file is located
    make -f ./Makefile -C . all
  3. And finally, run the compiled code:
    # assuming you are in the repository folder where the CMakeLists.txt file is located
    ./openmp-parallel-mergesort 1000 # where 1000 is the size of the array to be sorted
    export MASK_SIZE=3 && export MATRIX_HEIGHT=100 && export MATRIX_WIDTH=100 && ./cuda-2d-convolution
    # and so on...
  4. Clean the compiled files:
    # assuming you are in the repository folder where the CMakeLists.txt file is located
    make -f ./Makefile -C . clean

You can also compile just one of the challenges using the following commands:

  1. Compile the CMakeFiles:
    cd Parallel-Computing-Challenges
    cmake .
  2. Compile only one of the challenges using the following commands:
    # assuming you are in the repository folder where the CMakeLists.txt file is located
    make -f ./Makefile -C . openmp-parallel-mergesort
    or
    # assuming you are in the repository folder where the CMakeLists.txt file is located
    make -f ./Makefile -C . cuda-2d-convolution
  3. And finally, run the compiled code:
    ./openmp-parallel-mergesort 1000
    or
    export MASK_SIZE=3 && export MATRIX_HEIGHT=100 && export MATRIX_WIDTH=100 && ./cuda-2d-convolution

The names of the executables are available in the CMakeLists.txt file. However, here is a list of available programs: