1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0025748: Parallel version of progress indicator

Progress indication mechanism is refactored to support incrementing progress within multithreaded algorithms.

The class Message_ProgressIndicator is only an interface to the user application.
It accumulates the progress provided by progress scopes.
The counter is protected by mutex for thread-safety.

The new class Message_ProgressScope replacing Message_ProgressSentry should be used to advance the progress.
The scopes are nested to each other to reflect the nested nature of operations.
The new class Message_ProgressRange should be used to pass the progress to sub-scopes.

All OCCT algorithms involving progress indication have been updated to new API.

Improvements in Draw_ProgressIndicator:
- Separate console mode has been added in order to make possible to put the progress into std::cout instead
  or in addition to the draw interpreter, instead of trigger option "-tclOutput".
- Treatment of Ctrl-Break signal has been added.
  Now any operation can be aborted by Ctrl-C or Ctrl-Break keystroke.

Added new test case 'perf fclasses progr_par' for testing of parallel work of the progress.
This commit is contained in:
msv
2020-07-10 14:19:31 +03:00
committed by abv
parent 99289bed0a
commit 7e785937b3
271 changed files with 3701 additions and 3149 deletions

View File

@@ -23,8 +23,8 @@
math_Gauss::math_Gauss(const math_Matrix& A,
const Standard_Real MinPivot,
const Handle(Message_ProgressIndicator) & aProgress)
: LU (1, A.RowNumber(), 1, A.ColNumber()),
const Message_ProgressRange& theProgress)
: LU (1, A.RowNumber(), 1, A.ColNumber()),
Index(1, A.RowNumber()),
D (0.0),
Done (Standard_False)
@@ -35,7 +35,7 @@ math_Gauss::math_Gauss(const math_Matrix& A,
Index,
D,
MinPivot,
aProgress);
theProgress);
if(!Error) {
Done = Standard_True;
}

View File

@@ -27,12 +27,12 @@
#include <Standard_Real.hxx>
#include <math_Vector.hxx>
#include <Standard_OStream.hxx>
#include <Message_ProgressRange.hxx>
class math_NotSquare;
class Standard_DimensionError;
class StdFail_NotDone;
class math_Matrix;
class Message_ProgressIndicator;
//! This class implements the Gauss LU decomposition (Crout algorithm)
//! with partial pivoting (rows interchange) of a square matrix and
@@ -55,7 +55,7 @@ public:
//! Exception NotSquare is raised if A is not a square matrix.
Standard_EXPORT math_Gauss(const math_Matrix& A,
const Standard_Real MinPivot = 1.0e-20,
const Handle(Message_ProgressIndicator) & aProgress = Handle(Message_ProgressIndicator)());
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Returns true if the computations are successful, otherwise returns false
Standard_Boolean IsDone() const { return Done; }

View File

@@ -33,11 +33,11 @@
#include <Standard_Failure.hxx>
#include <Standard_NotImplemented.hxx>
#include <Message_ProgressSentry.hxx>
#include <math_Vector.hxx>
#include <math_IntegerVector.hxx>
#include <math_Matrix.hxx>
#include <Message_ProgressScope.hxx>
namespace {
static inline Standard_Real PYTHAG (const Standard_Real a, const Standard_Real b)
@@ -177,7 +177,7 @@ Standard_Integer LU_Decompose(math_Matrix& a,
Standard_Real& d,
math_Vector& vv,
Standard_Real TINY,
const Handle(Message_ProgressIndicator) & aProgress) {
const Message_ProgressRange& theProgress) {
Standard_Integer i, imax=0, j, k;
Standard_Real big, dum, sum, temp;
@@ -185,7 +185,7 @@ Standard_Integer LU_Decompose(math_Matrix& a,
Standard_Integer n = a.RowNumber();
d = 1.0;
Message_ProgressSentry aPSentry(aProgress, "", 0, n, 1);
Message_ProgressScope aPS(theProgress, "", n);
for(i = 1; i <= n; i++) {
big = 0.0;
@@ -197,7 +197,7 @@ Standard_Integer LU_Decompose(math_Matrix& a,
vv(i) = 1.0 / big;
}
for(j = 1; j <= n && aPSentry.More(); j++, aPSentry.Next()) {
for(j = 1; j <= n && aPS.More(); j++, aPS.Next()) {
for(i = 1; i < j; i++) {
sum = a(i,j);
for(k = 1; k < i; k++)
@@ -250,10 +250,10 @@ Standard_Integer LU_Decompose(math_Matrix& a,
math_IntegerVector& indx,
Standard_Real& d,
Standard_Real TINY,
const Handle(Message_ProgressIndicator) & aProgress) {
const Message_ProgressRange& theProgress) {
math_Vector vv(1, a.RowNumber());
return LU_Decompose(a, indx, d, vv, TINY, aProgress);
return LU_Decompose(a, indx, d, vv, TINY, theProgress);
}
void LU_Solve(const math_Matrix& a,

View File

@@ -19,11 +19,11 @@
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
#include <Standard_Handle.hxx>
#include <Message_ProgressRange.hxx>
class math_IntegerVector;
class math_Vector;
class math_Matrix;
class Message_ProgressIndicator;
const Standard_Integer math_Status_UserAborted = -1;
const Standard_Integer math_Status_OK = 0;
@@ -32,10 +32,10 @@ const Standard_Integer math_Status_ArgumentError = 2;
const Standard_Integer math_Status_NoConvergence = 3;
Standard_EXPORT Standard_Integer LU_Decompose(math_Matrix& a,
math_IntegerVector& indx,
Standard_Real& d,
Standard_Real TINY = 1.0e-20,
const Handle(Message_ProgressIndicator) & aProgress = Handle(Message_ProgressIndicator)());
math_IntegerVector& indx,
Standard_Real& d,
Standard_Real TINY = 1.0e-20,
const Message_ProgressRange& theProgress = Message_ProgressRange());
// Given a matrix a(1..n, 1..n), this routine computes its LU decomposition,
// The matrix a is replaced by this LU decomposition and the vector indx(1..n)
@@ -44,11 +44,11 @@ Standard_EXPORT Standard_Integer LU_Decompose(math_Matrix& a,
// interchanges was even or odd.
Standard_EXPORT Standard_Integer LU_Decompose(math_Matrix& a,
math_IntegerVector& indx,
Standard_Real& d,
math_Vector& vv,
Standard_Real TINY = 1.0e-30,
const Handle(Message_ProgressIndicator) & aProgress = Handle(Message_ProgressIndicator)());
math_IntegerVector& indx,
Standard_Real& d,
math_Vector& vv,
Standard_Real TINY = 1.0e-30,
const Message_ProgressRange& theProgress = Message_ProgressRange());
// Idem to the previous LU_Decompose function. But the input Vector vv(1..n) is
// used internally as a scratch area.