blob: 0cbb1c9e22bd2979c546f06021184aeaac4951ad [file] [log] [blame]
Austin Schuh9049e202022-02-20 17:34:16 -08001.. _linear_system_solvers_installation :
2
3Linear System Solvers
4======================
5
6The linear system solver is a core part of the OSQP algorithm.
7Depending on the problem instance, different linear system solvers can greatly speedup or reduce the computation time of OSQP.
8To set the preferred linear system solver, see :ref:`linear_system_solvers_setting`.
9
10Dynamic shared library loading
11------------------------------
12OSQP dynamically loads the shared libraries related to the selected external solver. Thus, there is no need to link it at compile time.
13The only requirement is that the shared library related to the solver is in the library path of the operating system
14
15+------------------+---------------------------+----------------+
16| Operating system | Path variable | Extension |
17+==================+===========================+================+
18| Linux | :code:`LD_LIBRARY_PATH` | :code:`.so` |
19+------------------+---------------------------+----------------+
20| Mac | :code:`DYLD_LIBRARY_PATH` | :code:`.dylib` |
21+------------------+---------------------------+----------------+
22| Windows | :code:`PATH` | :code:`.dll` |
23+------------------+---------------------------+----------------+
24
25
26
27
28
29QDLDL
30---------------
31OSQP comes with `QDLDL <https://github.com/osqp/qdldl>`_ internally installed.
32It does not require any external shared library.
33QDLDL is a sparse direct solver that works well for most small to medium sized problems.
34However, it becomes not really efficient for large scale problems since it is not multi-threaded.
35
36
37MKL Pardiso
38-----------
39`MKL Pardiso <https://software.intel.com/en-us/mkl-developer-reference-fortran-intel-mkl-pardiso-parallel-direct-sparse-solver-interface>`_ is an efficient multi-threaded linear system solver that works well for large scale problems part of the Intel Math Kernel Library.
40Intel offers `free lincenses <https://software.intel.com/en-us/articles/free-mkl>`_ for MKL for most non-commercial applications.
41
42Install with MKL
43^^^^^^^^^^^^^^^^
44We can install MKL Pardiso by using the standard `MKL installer <https://software.intel.com/en-us/mkl>`_.
45The main library to be loaded is called :code:`libmkl_rt`.
46To add it, together with its dependencies, to your path, just execute the automatic MKL script.
47
48+------------------+------------------------------------------------+
49| Operating system | Script |
50+==================+================================================+
51| Linux | :code:`source $MKLROOT/bin/mklvars.sh intel64` |
52+------------------+------------------------------------------------+
53| Mac | :code:`source $MKLROOT/bin/mklvars.sh intel64` |
54+------------------+------------------------------------------------+
55| Windows | :code:`%MKLROOT%\mklvars.bat intel64` |
56+------------------+------------------------------------------------+
57
58where :code:`MKLROOT` is the MKL installation directory.
59
60Install with Anaconda
61^^^^^^^^^^^^^^^^^^^^^
62`Anaconda Python distribution <https://www.anaconda.com/download/>`_ comes with the intel MKL libraries preinstalled including MKL Pardiso.
63To use this version, the Anaconda libraries folders have to be in your system path.
64Anaconda environments should add them automatically so in most cases you do not have to do anything. If you get an error where OSQP cannot find MKL, you can add the right path by adding the output from the following command to your path variable:
65
66.. code::
67
68 echo "`ls -rd ${CONDA_ROOT}/pkgs/*/ | grep mkl-2 | head -n 1`lib:`ls -rd ${CONDA_ROOT}/pkgs/*/ | grep intel-openmp- | head -n 1`lib"
69
70
71where :code:`ANACONDA_ROOT` is the root of your anaconda installation.
72