============== Matrix product [TOC] ============== In BLAS (Basic Linear Algebra Subprograms) the general matrix product performs ---- LATEX ----------------------------------- C \leftarrow \beta C + \alpha A B ---------------------------------------------- which is named *GEMM* (general matrix-matrix product) and where ---- LATEX ----------------------------------- \alpha \in \mathbb{K}, \quad \beta \in \mathbb{K}, \quad A \in \mathbb{K}^{m\times k}, \quad B \in \mathbb{K}^{k\times n}, \quad\text{and} \quad C \in \mathbb{K}^{m\times n} ---------------------------------------------- where $\mathbb{K}$ represents a floating point type, i.e. *double*. Special cases ============= - If $\alpha=0$ or dimension $k=0$ the operation just computes $C \leftarrow \beta C$ and returns. - If $\beta = 0$ then matrix $C$ is allowed to contain Nan (not a number) entries Exercise ======== Below we provide a simple benchmark stub for the GEMM operation. It already contains an implementation that traverses matrices $A$, $B$ and $C$ in row major order: - Make yourself familiar with the provided program: - What storage is used for the matrices. - In its current state the program already compiles (but function dgemm_col is not doing anything so far). Before you start with modifying the code: compile and run it. Make sure you understand the produced output. - Implement dgemm_col such that it traverses all matrices in col major order. - Compile with -O3 and compare the runtime of both GEMM variants and visualize the benchmark with a plot. Stub for the GEMM benchmark =========================== :import: session03/bench_gemm.c :navigate: up -> doc:index back -> doc:session03/page04 next -> doc:session03/page06