Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Matrix Multiplication

C implementation and performance comparison of several matrix multiplication algorithms, including OpenBLAS cblas\_dgemm and custom optimized implementations using cache blocking and AVX2/FMA instructions.

## Requirements

### Linux / WSL

Install Clang and OpenBLAS:

sudo apt update

sudo apt install clang libopenblas-dev

Check that the compiler is available:

clang --version

### Windows

Install:

* LLVM/Clang

* A Windows-compatible OpenBLAS installation

The OpenBLAS installation should contain:


openblas/

├── include/

│   └── cblas.h

└── lib/

    └── libopenblas.a

Place the openblas directory in the project root.

OpenBLAS binaries are not included in this repository. They should be installed separately for the target platform.

## Build

### Linux / WSL

make OUTPUT\_JSON=1

This generates:


lab6

Run:

./lab6

### Windows

From PowerShell:

make OUTPUT\_JSON=1

This generates:


lab6.exe

Run:

.\\lab6.exe

## Clean

Linux / WSL:

make clean

Windows:

make clean

## Output

The program reports the execution time and GFLOP/s of each matrix multiplication implementation.

It also checks the numerical correctness of the custom implementations against the OpenBLAS cblas\_dgemm result.

Example:


cblas\_dgemm Matrix Multiplication

time spend = ... us, GFLOP/s = ...



OptimizedMM2: time spend = ... us, GFLOP/s = ...

Correctness:pass



optimizedMM3: time spend = ... us, GFLOP/s = ...

Correctness:pass



optimizedMM4: time spend = ... us, GFLOP/s = ...

Correctness:pass

When OUTPUT\_JSON=1 is specified, profiling information is also written to:


Result.json

Result.json is generated locally and is not tracked by Git.

## Implementations

The project contains several matrix multiplication implementations:

* Basic ijk matrix multiplication

* ikj loop ordering

* Blocked matrix multiplication

* Optimized blocked multiplication

* AVX2/FMA optimized multiplication

* OpenBLAS cblas\_dgemm as the reference implementation

The optimized implementations use 64-byte aligned memory and AVX2/FMA intrinsics where applicable.

## Platform Support

The project supports:

* Windows

* Linux

* WSL

The Makefile automatically selects platform-specific compiler and linker options.

About

C matrix multiplication lab comparing OpenBLAS with custom optimized implementations using cache blocking and AVX2/FMA.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages