Giter Site home page Giter Site logo

aidevnn / intelgemm Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 22 KB

GEneral Matrix Multiplication with Intel Compiler and his powerfull Autoparallelization and Autovectorization

License: MIT License

C++ 100.00%
cpp intel-compiler parallelization vectorization matrix-multiplication intel-mkl-library

intelgemm's Introduction

IntelGemm

GEneral Matrix Multiplication with Intel Compiler and his powerfull Autoparallelization and Autovectorization

void MatMul0(int m, int n, int k, float* a, float* b, float* c) {
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < n; ++j) {
			for (int k0 = 0; k0 < k; ++k0) {
				c[i * n + j] += a[i * k + k0] * b[k0 * n + j];
			}
		}
	}
}

void MatMul1(int m, int n, int k, float* a, float* b, float* c) {
	for (int i = 0; i < m; ++i) {
		for (int k0 = 0; k0 < k; ++k0) {
			for (int j = 0; j < n; ++j) {
				c[i * n + j] += a[i * k + k0] * b[k0 * n + j];
			}
		}
	}
}

void MatMul2(int m, int n, int k, float* a, float* b, float* c) {
	cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k, 1.0f, a, k, b, n, 0.0f, c, n);
}

The Output

HelloWorld Intel MKL Gemm
Matrix[2 3] A
     0    -4     4
     7     2    -4

Matrix[3 4] B
    -3    -2    -3    -2
    -3     4    -9     3
   -10    -5     8    -3

Matrix[2 4] A x B meth0
   -28   -36    68   -24
    13    14   -71     4

Matrix[2 4] A x B meth1
   -28   -36    68   -24
    13    14   -71     4

Matrix[2 4] A x B meth2
   -28   -36    68   -24
    13    14   -71     4

Start Bench M=1920 N=2560 and K=1280
Bench method 0
TIME    97.63 ms
TIME    95.18 ms
TIME    91.10 ms
TIME    89.63 ms
TIME    88.26 ms
Bench method 1
TIME    88.22 ms
TIME    88.36 ms
TIME    89.07 ms
TIME    86.03 ms
TIME    88.58 ms
Bench method 2
TIME    89.54 ms
TIME    92.78 ms
TIME    91.48 ms
TIME    91.43 ms
TIME    92.41 ms
End.
Start Bench M=3840 N=5120 and K=2560
Bench method 0
TIME   675.68 ms
TIME   668.07 ms
TIME   674.81 ms
TIME   677.28 ms
TIME   673.65 ms
Bench method 1
TIME   669.31 ms
TIME   666.31 ms
TIME   673.02 ms
TIME   665.42 ms
TIME   696.23 ms
Bench method 2
TIME   704.99 ms
TIME   688.36 ms
TIME   675.51 ms
TIME   676.15 ms
TIME   677.55 ms
End.

intelgemm's People

Contributors

aidevnn avatar

Stargazers

 avatar

Watchers

 avatar  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.