Giter Club home page Giter Club logo

optimizing_matrix's Introduction

HW3: Optimizing Matrix Multiplication

1 Related Things

1-1 ikj method

The technique that uses ikj index in matrix multiplication cannot reduce time complexity. However, the change of steps of calculation can reduce cache miss that actually decreases runtime.

ikj.jpg

1-2 Block Matrix Multiplication

The block matrix multiplication also decreases cache miss by reducing the size of matrix that is multiplied at each time. It applies divide and conquer algorithm to optimize calculation into cache size.

block.jpg

1-3 Strassen Algorithm

Strassen Algorithm is also one of divide and conquer algorithm. Unlike other techniques, Strassen algorithm reduces time complexity from O(n3) to O(n2.807). Although the difference of number can be considered as tiny number, the performance extremely improves when the dataset is large.

Strassen.jpg

In the first step, 7 multiplication and 10 addition/subtractions are used to calculate M values. These M values will be used to calculate final values with only 8 additions/subtractions.

2 Framework

/HW3/matmul$ tree .
.
├── build                       // make file generate objective files to here
│   └── driver.o                // only objective file provided!
├── data                        // Saving data here recommended
├── Makefile                    // Compile, Clean, Format, Submit
├── matmul4096.cmd        		// Command for condor
├── matmul2048.cmd        		// Command for condor
├── result                      // Result from condor
└── src                         // Source Code
    ├── generate.cpp
    ├── matmul.cpp
    └── matmul.h

4 directories, 7 files

3 Result

/HW3/matmul$ ./matmul data/input.txt data/output.txt 1
=====================================
         Matrix Multiplication       
=====================================
The size of Matrix: 4
Sanity Check(0: false, 1: true): 1
=====================================

Read input file(data/input.txt)...
Read output file(data/output.txt)...

Run sanity check for input, output...

matmul_ref took 2.273e-06 sec
Problem(data/input.txt) and 
Solution(data/output.txt) are
Matched!

Run your solution...

matmul_optimal took 0.00172086 sec
Correct

3-1 Actual Result that apply ikj, Strassen and OMP

result.jpg

4 Reference

HW3 Specification

optimizing_matrix's People

Contributors

ljwoo94 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.