From 5d8172e1900aee409e4817760a3bfe15ca657071 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Thu, 24 Dec 2020 05:10:11 +0100 Subject: [PATCH] GCS: Improve documentation about debug ====================================== Explicitly indicate that if parameter diagnosis must be silent=false in order to debug, then the lauch policy during the debug must be set to deferred in order to avoid concurrent access to Base::Console which is not thread-safe. --- src/Mod/Sketcher/App/planegcs/GCS.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Mod/Sketcher/App/planegcs/GCS.cpp b/src/Mod/Sketcher/App/planegcs/GCS.cpp index 7fffe4fb09..97ac7f6413 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.cpp +++ b/src/Mod/Sketcher/App/planegcs/GCS.cpp @@ -3923,6 +3923,12 @@ SolverReportingManager::Manager().LogToFile("GCS::System::diagnose()\n"); // questions remain open: // https://stackoverflow.com/questions/49009771/getting-rows-transpositions-with-sparse-qr // https://forum.kde.org/viewtopic.php?f=74&t=151239 + // + // + // Implementation below: + // + // Two QR decompositions are used below. One for diagnosis of constraints and a second one for diagnosis of parameters, i.e. + // to identify whether the parameter is fully constraint (independent) or not (i.e. it is dependent). // QR decomposition method selection: SparseQR vs DenseQR @@ -3946,9 +3952,11 @@ SolverReportingManager::Manager().LogToFile("GCS::System::diagnose()\n"); // nows if it can run the task in parallel or is oversubscribed and should deferred it. // 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. Care to call the thread with silent=true, unless the present thread - // does not use Base::Console, as it is not thread-safe to use them in both at the same time. + // does not use Base::Console, or the lauch policy is set to std::lauch::deferred policy,, as it is not thread-safe to use them + // in both at the same time. // // identifyDependentParametersDenseQR(J, jacobianconstraintmap, pdiagnoselist, true) + // auto fut = std::async(&System::identifyDependentParametersDenseQR,this,J,jacobianconstraintmap, pdiagnoselist, true); makeDenseQRDecomposition( J, jacobianconstraintmap, qrJT, rank, R); @@ -3999,10 +4007,14 @@ SolverReportingManager::Manager().LogToFile("GCS::System::diagnose()\n"); // nows if it can run the task in parallel or is oversubscribed and should deferred it. // 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. Care to call the thread with silent=true, unless the present thread - // does not use Base::Console, as it is not thread-safe to use them in both at the same time. + // does not use Base::Console, or the lauch policy is set to std::lauch::deferred policy,, as it is not thread-safe to use them + // in both at the same time. // // identifyDependentParametersSparseQR(J, jacobianconstraintmap, pdiagnoselist, true) - auto fut = std::async(&System::identifyDependentParametersSparseQR,this,J,jacobianconstraintmap, pdiagnoselist, true); + // + // Debug: + // auto fut = std::async(std::launch::deferred,&System::identifyDependentParametersSparseQR,this,J,jacobianconstraintmap, pdiagnoselist, false); + auto fut = std::async(&System::identifyDependentParametersSparseQR,this,J,jacobianconstraintmap, pdiagnoselist, false); makeSparseQRDecomposition( J, jacobianconstraintmap, SqrJT, rank, R); @@ -4243,7 +4255,7 @@ void System::identifyDependentParameters( T & qrJ, #ifdef _GCS_DEBUG if(!silent) - SolverReportingManager::Manager().LogMatrix("Rparams", Rparams); + SolverReportingManager::Manager().LogMatrix("Rparams_nonzeros_over_pilot", Rparams); #endif pDependentParametersGroups.resize(qrJ.cols()-rank); for (int j=rank; j < qrJ.cols(); j++) {