Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

matmul after installing MKL

grant1
Beginner
1,360 Views
Hi. If I have a bunch of code that uses "matmul" intrinsic for matrix multiplication, and then install MKL, does the compiler detect the presence of MKL and use it? Same flavour of question for operations like adding matrices and vectors using built in "+" operator, etc... Thanks smiley [:-)]
0 Kudos
4 Replies
TimP
Honored Contributor III
1,360 Views

gfortran 4.3 (a beta version) has an option on linux which uses MKL or the liketo implement MATMUL, if you set the appropriate options. I don't know of other compilers which do that. The MATMUL implementation which comes with a compiler is likely to be more efficient than MKL, for small matrices. Thus, gfortran has a threshold which can be set for cases where matrix size can be estimated at compile time, so as to implement a degree of automatic decision on whether to use MKL. If an argument of MATMUL is a TRANSPOSE, the compiler can consolidate the operations so as to avoid additional data movement.

I don't believe gfortran on Windows can be made compatible with MKL or other commercial libraries. It would be possible to usethe gfortran MATMUL BLAS calling mechanism with ?GEMM compiledby gfortran.

Addition of matrices and vectorsshould be done more efficiently in line by a good vectorizing compiler.

0 Kudos
grant8
Beginner
1,360 Views
Sorry, I left out information in my question. I am meaning specifically with Intel Fortran compiler. I'm hoping that the Intel compiler knows enough about MKL to be able to always do what's best for me, without me needing to make a case-by-case decision about whether I would be better off calling the MKL or using vanilla MATMUL. Is that true?
0 Kudos
TimP
Honored Contributor III
1,360 Views

No, I doubt there are any such plans for ifort. If you can make a case that implementing the gfortran compatible feature I mentioned would be useful, you should file a feature request on premier.intel.com.

Cray compilers (possiblyasrecently as SGI Origin)had capability equivalent to what you describe, but it seems that major applications did not depend on it. Even the Polyhedron benchmarks have matrix multiplication written out, e.g. as a loop of dot products, where it is a major performance factor. As ifortoptimization isstrongly influenced by existing practice, use of MATMUL in critical applications would be needed to motivate such optimizations.

0 Kudos
Intel_C_Intel
Employee
1,360 Views

Currently the Intel compilers know nothing about MKL and its functions. Any support for matmult comes from libraries written separately from MKL. One of the reasons for this is that matmult has to work with all data types where MKL supports only 32-bit and 64-bit floating point arithmetic.

Bruce

0 Kudos
Reply