'An exception occurred when I use Eigen::PardisoLU with cmake
I am trying to use Eigen::pardisoLU but I have no output. This is my cmakelists.txt:
cmake_minimum_required(VERSION 3.9)
project(my_test_project)
aux_source_directory(. SRCS)
add_definitions(-DEIGEN_USE_MKL_ALL)
add_definitions(-DMKL_LP64)
add_executable(my_test ${SRCS})
target_include_directories(my_test
PRIVATE
"./eigen/eigen-3.4.0"
"C:/Program Files (x86)/Intel/oneAPI/mkl/2022.0.3/include"
"./")
file(GLOB LIBS "C:/Program Files (x86)/Intel/oneAPI/mkl/2022.0.3/lib/intel64/*.lib")
target_link_libraries(my_test ${LIBS})
In cmake file I have add the include directories and libs I need. The path is corrrect. This is my test function:
#include <Eigen/Dense>
#include <iostream>
#include <Eigen/Sparse>
#include <Eigen/PardisoSupport>
using namespace Eigen;
using namespace std;
void sparseTest()
{
int cols = 3;
int rows = 3;
unsigned int nonzeros_num = 3;
vector<Triplet<double>> tripletList;
tripletList.reserve(nonzeros_num);
SparseMatrix<double> b(rows, 1);
for (int i = 0; i < nonzeros_num; i++)
{
tripletList.push_back(Triplet<double>(i, i, i + 1));
b.insert(i, 0) = i + 1;
}
SparseMatrix<double> mat(rows, cols);
mat.setFromTriplets(tripletList.begin(), tripletList.end());
mat.makeCompressed();
b.makeCompressed();
cout << mat << endl;
cout << b << endl;
PardisoLU<SparseMatrix<double>> solver;
//SparseLU<SparseMatrix<double>> solver;
solver.compute(mat);
SparseMatrix<double> result(3, 1);
result = solver.solve(b);
cout << result << endl;
}
When I make this project. An exception occurred in the "PardisoSupport.h" saying "module not found"
I have add all .lib to my project, so why the exception occurred?
Then I try in this way: I have modified my cmakelists.txt like this:
cmake_minimum_required(VERSION 3.9)
project(my_test_project)
aux_source_directory(. SRCS)
#add_definitions(-DEIGEN_USE_MKL_ALL)
#add_definitions(-DMKL_LP64)
add_executable(my_test ${SRCS})
target_include_directories(my_test
PRIVATE
"./eigen/eigen-3.4.0"
"C:/Program Files (x86)/Intel/oneAPI/mkl/2022.0.3/include"
"./")
file(GLOB REQUIRES_LIBS "D:/VSCodeData/LU/lib/*.lib")
target_link_libraries(my_test ${REQUIRES_LIBS} )
Instead of linking all libs files, I just copy these libs to my libraries linking directory and link them:
mkl_intel_lp64.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib
Then I use visual studio to make it, and There will be a error that "can not find libiomp5md.dll ", so I find this .dll file in the "C:\Program Files (x86)\Intel\oneAPI\compiler\2022.0.3\windows\redist\intel64_win\compiler" and copy it to my .exe directory. After all these steps it works well finally.
So I think I can not link all libs in the mkl install directories. Now my new question is what .lib and .dll files I need in my project and how to know it. I have linked libiomp5md.lib in my target but why I also need the libiomp5md.dll?
There are other .dll libraries in this file:
C:\Program Files (x86)\Intel\oneAPI\compiler\2022.0.3\windows\redist\intel64_win\compiler
how these .dll can be used?
This is my output in debug mode:
Nonzero entries:
(1,0) (2,1) (3,2)
Outer pointers: 0 1 2 $
1 0 0
0 2 0
0 0 3
Nonzero entries: (1,0) (2,1) (3,2)
Outer pointers: 0 $
1
2
3
Nonzero entries: (1,0) (1,1) (1,2)
Outer pointers: 0 $
1
1
1
It indicated it works well.
Solution 1:[1]
To anyone who is looking into this question, here is the summary of the discussion:
what .lib and .dll files I need in my project and how to know it.
To find the required libraries for your application in which you are using MKL functionalities, one can always take help from the MKL link line advisor tool, here is the link https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html#gs.ypos1l
how can I modify the number of CPU's cores..Can I change it that use more or less CPU cores
By default, Intel MKL uses the number of threads equal to the number of physical cores on the system and yes you can control the number of cores by changing the value of MKL_NUM_THREADS or OMP_NUM_THREADS environment variables. This link probably helps you to find full details https://www.intel.com/content/www/us/en/develop/documentation/onemkl-windows-developer-guide/top/managing-performance-and-memory/improving-performance-with-threading/techniques-to-set-the-number-of-threads.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Vidyalatha_Intel |