Download Intel(R) Math Kernel Library for Linux* OS User's Guide
Transcript
Language-specific Usage Options
6
{
int n, inca = 1, incb = 1, i;
complex16 a[N], b[N], c;
n = N;
for( i = 0; i < n; i++ ){
a[i].re = (double)i; a[i].im = (double)i * 2.0;
b[i].re = (double)(n - i); b[i].im = (double)i * 2.0;
}
cblas_zdotc_sub(n, a, inca, b, incb,&c );
printf( "The complex dot product is: ( %6.2f, %6.2f)\n", c.re, c.im );
}
Support for Boost uBLAS Matrix-matrix Multiplication
If you are used to uBLAS, you can perform BLAS matrix-matrix multiplication in C++ using the Intel(R) Math
Kernel Library (Intel(R) MKL) substitution of Boost uBLAS functions. uBLAS is the Boost C++ open-source library
that provides BLAS functionality for dense, packed, and sparse matrices. The library uses an expression template
technique for passing expressions as function arguments, which enables evaluating vector and matrix expressions
in one pass without temporary matrices. uBLAS provides two modes:
• Debug (safe) mode, default.
Checks types and conformance.
• Release (fast) mode.
Does not check types and conformance. To enable this mode, use the NDEBUG preprocessor symbol.
The documentation for the Boost uBLAS is available at www.boost.org.
Intel MKL provides overloaded prod() functions for substituting uBLAS dense matrix-matrix multiplication with
the Intel MKL gemm calls. Though these functions break uBLAS expression templates and introduce temporary
matrices, the performance advantage can be considerable for matrix sizes that are not too small (roughly, over
50).
You do not need to change your source code to use the functions. To call them:
• Include the header file mkl_boost_ublas_matrix_prod.hpp in your code (from the Intel MKL include
directory)
• Add appropriate Intel MKL libraries to the link line.
The list of expressions that are substituted follows:
prod( m1, m2 )
prod( trans(m1), m2 )
prod( trans(conj(m1)), m2 )
prod( conj(trans(m1)), m2 )
prod( m1, trans(m2) )
prod( trans(m1), trans(m2) )
prod( trans(conj(m1)), trans(m2) )
prod( conj(trans(m1)), trans(m2) )
prod( m1, trans(conj(m2)) )
prod( trans(m1), trans(conj(m2)) )
69