Install the Pardiso MKL module

Chrono::PardisoMKL is an optional module that exposes the direct sparse linear solver Pardiso from the Intel MKL library. The interface to Pardiso is provided by Eigen.

Features

Two Chrono-specific features are implemented:

  • sparsity pattern lock
    In many cases, internal data structures experience minimal changes between timesteps. When this occurs, informing the solver about the consistent sparsity pattern can significantly accelerate matrix assembly.
  • sparsity pattern learner
    The sparsity pattern learning feature acquires the sparsity pattern in advance, in order to speed up matrix assembly. Enabled by default, the sparsity matrix learner identifies the exact matrix sparsity pattern (without actually setting any nonzeros) Look at the API section of this module for more details.

Requirements

This module requires the Intel MKL Library. Note that Intel MKL can be installed stand-alone or as part of the Intel oneAPI Base Toolkit.

ATTENTION!
Eigen3 was not updated to work with oneAPI and MKL 2025.
Intel MKL 2023 is known to work fine with Eigen (and therefore Chrono) on both Linux and Windows.

Building instructions

  1. Follow the guide for the full installation of Chrono, but when running CMake make sure that also the option CH_ENABLE_MODULE_PARDISO_MKL is set to ON.
  2. If prompted, set MKL_DIR to the directory with a CMake configuration file for MKL. Depending on the OS, this will be something like:
    • C:/Program Files (x86)/Intel/oneAPI/mkl/2023.0.0/lib/cmake/mkl (Windows)
    • /opt/intel/oneapi/mkl/latest/lib/cmake/mkl (Linux)
  3. Press 'Configure' again and then 'Generate'
  4. Building this module will produce an additional shared library, called Chrono_pardisomkl, which can be linked to your application.

How to use it

Set up the environment

Before creating executables that can actually leverage the Intel MKL library, you have to make sure that the Intel run-time libraries are available to the executable itself. This is achieved by setting the PATH environmental variable in a proper way. To do so, two options are available:

  • the official method proposed by Intel; this method temporarly sets the PATH variable only from the current command prompt session; this means that, if you run it from Visual Studio or from a new command prompt, this method is difficult/cumbersome for you;
  • the unofficial method, for which the PATH variable is set manually, but once and for all; description follows...

The following unofficial method needs that you set the environmental variable of your system.

  1. Add the following MKL directories to your system PATH (Windows) or LD_LIBRARY_PATH (Linux or MacOS) environment variable, adapting them to your OS and architecture:
    For Windows:
    <install_folder>/Intel/oneAPI/mkl/latest/redist/intel64
    <install_folder>/Intel/oneAPI/compiler/latest/windows/redist/intel64_win/compiler
    or, for older installations:
    <install_folder>/IntelSWTools/compilers_and_libraries/windows/redist/intel64_win/mkl
    <install_folder>/IntelSWTools/compilers_and_libraries/windows/redist/intel64_win/compiler.
    For Linux:
    /opt/intel/oneapi/mkl/latest/lib/intel64
    /opt/intel/oneapi/compiler/2024.0/lib/
  1. Add these system environment variables (both Windows and Linux)
    MKL_INTERFACE_LAYER = LP64
    MKL_THREADING_LAYER = INTEL
    or, more in general, you can have different options, depending on your Architecture and the desired Threading Layer.
  2. reboot your IDE, close any open CMake

By doing this, you will be able to start the MKL-based demos and programs directly from your IDE or just by double-clicking on them.

Set up the code

  • Simply add this snippet anywhere in your code, before running the main simulation loop.
    This will inform Chrono to use the Eigen interface to the Intel MKL Pardiso solver.
    auto mkl_solver = chrono_types::make_shared<ChSolverPardisoMKL>();
    my_system.SetSolver(mkl_solver);
  • (Optional) Turn on the sparsity pattern lock (see chrono::ChSolverPardisoMKL and chrono::ChDirectSolverLS for further details)
    auto mkl_solver = chrono_types::make_shared<ChSolverPardisoMKL>();
    mkl_solver->SetSparsityPatternLock(true);
    my_system.SetSolver(mkl_solver);
  • By default, this solver uses the sparsity pattern learner (see chrono::ChDirectSolverLS) to infer the sparsity pattern before actually loading the non-zero elements. To disable the use of the sparsity pattern learner, call
    mkl_solver->UseSparsityPatternLearner(false);
  • Look at the API section of this module for documentation about classes and functions.

MacOS support

This module cannot be built for Macs with Apple Silicon hardware, Macs with Intel hardware can use it, see here.