首页 > 解决方案 > 并行使用 Eigen LeastSquaresConjugateGradient

问题描述

我正在尝试使用 Eigen 库的 LeastSquaresConjugateGradient 求解 Ax=b 形式的线性方程组,并且 A 是稀疏矩阵。

LeastSquaresConjugateGradient < SparseMatrix < double >> 求解器;

求解器.计算(一);

x = 求解器.solve(b);

原则上它工作得很好。但我想将它用于相当大的矩阵,因此并行运行它会很好。Eigen 文档仅提到将以下几行放在首位。

omp_set_num_threads(2);

setNbThreads(2);

此外,文档指出 LeastSquaresConjugateGradient 例程应该并行工作。

我还通过 export OMP_NUM_THREADS=2 设置了 bash 中的线程数

但是我仍然没有获得任何性能提升。我究竟做错了什么??

标签: openmpeigen3linear-equation

解决方案


推荐阅读