======================================== Matrix-Matrix Product with C++ and ublas [TOC] ======================================== Computing a matrix-matrix product $C = AB$ for a $m\times n$ matrix $C$, $m \times k$ matrix $A$ and $k \times n$ matrix $B$. All kept very simple ... Compile and Run Benchmark ========================= For a quick benchmark we limit $m$ to $500$ with `-DM_MAX=500`: ---- SHELL (path=session1,hostname=heim) --------------------------------------- g++ -Ofast -mavx -Wall -DNDEBUG -std=c++11 -DM_MAX=500 -I ../boost_1_60_0 matprod.cc ./a.out -------------------------------------------------------------------------------- The columns in the output are: - Dimension $m$. The program uses $m=n=k$ but you can adjust that. - Time elapsed using `ublas::axpy_prod` to compute $C_1 = AB$. - Time elapsed using the matrix-matrix product from `gemm.hpp` to compute $C_2 = AB$. - The difference $\|C_1 - C_2\|_1$. Note that this will in general not be exactly zero because of roundoff errors. Main Program with Benchmark and Test ==================================== :import: session1/matprod.cc Core Function for Matrix-Matrix Produkt ======================================= :import: session1/gemm.hpp Benchmark Results ================= ---- SHELL (path=session1,hostname=heim) --------------------------------------- cat /proc/cpuinfo g++ -Ofast -mavx -Wall -DNDEBUG -std=c++11 -I ../boost_1_60_0 matprod.cc ./a.out > report.session1 cat report.session1 gnuplot plot.session1.mflops gnuplot plot.session1.time gnuplot plot.session1.time_log -------------------------------------------------------------------------------- MFLOPS ------ ---- IMAGE ----------------------- session1/bench.session1.mflops.svg ---------------------------------- Time ---- ---- IMAGE ----------------------- session1/bench.session1.time.svg ---------------------------------- Time with Logarithmic scale --------------------------- ---- IMAGE ------------------------- session1/bench.session1.time_log.svg ------------------------------------ :navigate: next -> doc:session2/page01