From 5e2a2cbbbb580acec97022e6b069ce4e208e1219 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Mon, 14 Dec 2020 19:37:04 +0100 Subject: [PATCH] GCS: Make QR decompositions for constraints and parameters run asynchronously --- src/Mod/Sketcher/App/planegcs/GCS.cpp | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Mod/Sketcher/App/planegcs/GCS.cpp b/src/Mod/Sketcher/App/planegcs/GCS.cpp index f072d6f3db..10269e3104 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.cpp +++ b/src/Mod/Sketcher/App/planegcs/GCS.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include "GCS.h" #include "qp_eq.h" @@ -3964,20 +3965,23 @@ SolverReportingManager::Manager().LogToFile("GCS::System::diagnose()\n"); #ifdef PROFILE_DIAGNOSE Base::TimeInfo SparseQR_start_time; #endif - int rank = 0; - Eigen::MatrixXd R; - Eigen::SparseQR, Eigen::COLAMDOrdering > SqrJT; - - - makeSparseQRDecomposition( J, jacobianconstraintmap, SqrJT, rank, R); - - int paramsNum = SqrJT.rows(); - int constrNum = SqrJT.cols(); - if (J.rows() > 0) { + int rank = 0; + Eigen::MatrixXd R; + Eigen::SparseQR, Eigen::COLAMDOrdering > SqrJT; + // Here we enforce calculating the two QR decompositions in parallel + // Care to wait() for the future before any prospective detection of conflicting/redundant, because the redundant solve + // modifies pdiagnoselist and it would not be thread-safe + // + // identifyDependentParametersSparseQR(J, jacobianconstraintmap, pdiagnoselist, true) + auto fut = std::async(std::launch::async,&System::identifyDependentParametersSparseQR,this,J,jacobianconstraintmap, pdiagnoselist, true); - // Get dependent parameters - identifyDependentParametersSparseQR(J, jacobianconstraintmap, pdiagnoselist, true); + makeSparseQRDecomposition( J, jacobianconstraintmap, SqrJT, rank, R); + + int paramsNum = SqrJT.rows(); + int constrNum = SqrJT.cols(); + + fut.wait(); // wait for the execution of identifyDependentParametersSparseQR to finish dofs = paramsNum - rank; // unless overconstraint, which will be overridden below