Course


MKL Matrix Multiplication

Learn how to do MKL Matrix Multiplication.

MKL Matrix

Intel MKL provides several routines for multiplying matrices. The most widely used is the dgemm routine, which calculates the product of double precision matrices. The dgemm routine can perform several calculations. For example, you can perform this operation with the transpose or conjugate transpose of A and B . The complete details of capabilities of the dgemm routine and all of its arguments can be found in the cblas_?gemm topic in the Intel Math Kernel Library Developer Reference .

C (GCC 9.2.0)
  • Input  

This exercise illustrates how to call the dgemm routine. An actual application would make use of the result of the matrix multiplication.

This call to the dgemm routine multiplies the matrices:

cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
           m, n, k, alpha, A, k, B, n, beta, C, n);

The arguments provide options for how Intel MKL performs the operation. In this case:

  • CblasRowMajor Indicates that the matrices are stored in row major order, with the elements of each row of the matrix stored contiguously as shown in the figure above.

  • CblasNoTrans Enumeration type indicating that the matrices A and B should not be transposed or conjugate transposed before multiplication.

Source credit: Intel

C++ Scientific Programming