Skip to content

Multiplication of two random matrices(n x n) using optimized sequential method and parallel method

Notifications You must be signed in to change notification settings

ChaminW/MatrixMultiply

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 

Repository files navigation

Matrix Multiply

This c++ package demonstrate the multiplication of two random matrices(n x n) using sequential method and parallel method. It measure the average time taken to complete the process for each n value(200 - 2000).

mat_multi_seq.cpp - Sequential matrix multiplication
mat_multi_para.cpp - Parallel matrix multiplication using OpenMP
mat_multi_seq_optimized_1 - Optimized sequential program using transpose
mat_multi_para_optimized_1 - Optimized parallel program using transpose
mat_multi_para_optimized_1.1 - Optimized parallel program using transpose and pointer arrays
mat_multi_seq_para_optimized_2 - Optimized program using Strassen algorithm and Transpose
mat_multi_seq_para_optimized_3 - Optimized program using tiled algorithm and Transpose

Dependencies

This package relies on C / C++ compiler (gcc) and openMP.

Linux

The GNU Compiler Collection may come with your distribution. Run which gcc g++ to find out.
If that command does not output as below, you will require to install it.

/usr/bin/gcc
/usr/bin/g++

For RHEL-based distros, run sudo dnf install gcc gcc-c++.

For Debian-based distros, run sudo apt install gcc g++.

For Arch-based distros, run sudo pacman -S gcc.

Windows

You will require to install MinGW and add it to your PATH.

Mac

You will require to install XCode.

How to execute?

Linux

Sequential versions :

$ g++ mat_multi_seq.cpp -o mat_multi_seq
$ ./mat_multi_seq

Parallel versions:

$ g++ -fopenmp mat_multi_seq.cpp -o mat_multi_seq
$ ./mat_multi_seq

Windows

Sequential versions :

g++ mat_multi_seq.cpp -o mat_multi_seq
mat_multi_seq

Parallel versions:

g++ -fopenmp mat_multi_seq.cpp -o mat_multi_seq
mat_multi_seq

Both parallelized and optimized versions can be executed as above. Upon execution, the execution times and the calculated speed up values will be displayed.

Note

The mat_multi_seq_para_optimized_2.cpp file containing optimizing using Strassen algorithm can be supplied with a suitable integer threshold value at runtime as follows

mat_multi_seq_para_optimized_2 threshold-value

The default threshold value is 128.

About

Multiplication of two random matrices(n x n) using optimized sequential method and parallel method

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages