A small, self-checking C++17 example that solves a real nonsymmetric sparse linear system with Intel oneMKL PARDISO.
The example demonstrates:
- zero-based CSR storage;
MKL_INTfor LP64/ILP64 portability;pardisoinitparameter initialization;- the combined analysis/factorization/solve phase (
phase = 13); - the required release phase (
phase = -1); - verification against a manufactured exact solution.
- CMake 3.18 or newer;
- a C++17 compiler;
- Intel oneAPI MKL with its CMake package available.
Source the oneAPI environment first when using a standard installation:
source /opt/intel/oneapi/setvars.shgit clone https://github.com/2002WYT/mkl-pardiso-minimal-example.git
cd mkl-pardiso-minimal-example
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
ctest --test-dir build --output-on-failureRun directly:
./build/mkl_pardiso_exampleExpected output is a solution close to five ones and a relative solution error near machine precision.
LP64 is the default:
cmake -S . -B build -DMKL_INTERFACE=lp64For 64-bit sparse indices, configure a separate build with the ILP64 interface:
cmake -S . -B build-ilp64 -DMKL_INTERFACE=ilp64
cmake --build build-ilp64 -j
ctest --test-dir build-ilp64 --output-on-failureThe source uses MKL_INT throughout, so its index type follows the selected oneMKL interface.
The example defaults to sequential oneMKL for a deterministic minimal dependency set. Select a threaded layer at configure time when needed:
cmake -S . -B build-threaded \
-DMKL_THREADING=intel_thread \
-DCMAKE_BUILD_TYPE=Release[1 0 2 2 0]
[0 1 0 0 3]
[0 0 1 2 0]
[0 0 0 1 0]
[0 0 0 0 2]
The right-hand side is constructed as b = A * 1, making the expected solution known before PARDISO runs.
This repository intentionally stays minimal. It currently demonstrates real nonsymmetric matrices (mtype = 11) stored in memory. Matrix Market parsing, symmetric matrix types, and complex arithmetic are good extensions but are not part of this small smoke test.
The repository does not yet declare a software license; public visibility alone does not grant reuse rights.