Compiling with MKL

When building solver from source (here, intended to use on a cluster), there is a sign that “mkl” is supported, though I do not find any further information in the MFiX documention. Is it worth the effort to try to build with this cuntionality? Are there any obvious advantages?

Hi Kjetil -

MKL is Intel’s Math Kernel Library. The advantage of using it would be a potential speed improvement, especially on Intel hardware. As far as I know, nobody has benchmarked this recently, so I don’t know whether any speedup would actually be observed.

Looking at the source code, there’s only one place (in main.f) with an #ifdef MKL so I don’t think setting this will make any difference in practice. It might be a remnant in the solver of something that has been removed. You might get MKL by default if you build with ifort.

MKL contains a number of optimized numerical libraries including BLAS, LAPACK, and ScaLAPACK. MFiX does use BLAS, but instead of depending on an external BLAS library, we have a BLAS.f in the source directory

!  Software: Netlib BLAS (Basic Linear Algebra Subprograms)            !
!  Version: 3.5.0                                                      !
!  Date: November 2013                                                 !
!  License: public domain                                              !

so without some modification of the build scripts, you’ll be using this version instead of whatever is installed on your platform, MKL or not.

I’m not sure how much effort I’d put into building with MKL, but if you try it I’d like to hear how it works out.

If you’re looking for performance, I think the simplest thing you can do is compile with -march=native (if you are using GCC), this produces machine code which is non-portable but optimized for your particular CPU. Without this flag (or some other compiler flags to specify CPU type) the compiler emits very generic x86 code that doesn’t assume any of the vectorized SMID operations (required for fast media encoding/decoding) that have become extremely common in the last 2 decades - I mean SSE, SSE2, etc. I’ve found that -O3 -march=native can give significant speedup on the solver. I’ve been thinking about making this the default, or enabling a “Turbo” option for build_mfixsolver that will turn this on. The only problem is if you try to run the solver on a machine with different CPU version you might need to recompile.

– Charles