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

0024826: Wrapping of parallelisation algorithms

Simple primitives to parallelize loops type "for" and "foreach" were implemented. The primitives encapsulates complete logic for creating and managing parallel context of loops. Moreover the primitives may be a wrapper for some primitives from 3rd-party library - TBB.

To use it is necessary to implement TBB like interface which is based on functors. For example:

Class Functor
{
public:
  void operator() ([proccesing instance]) const
  {
    //...
  }
};

In the body of the operator () should be implemented thread-safe logic of computations that can be performed in parallel context. If parallelized loop iterates on the collections with direct access by index (such as Vector, Array), it is more efficient to use the primitive ParallelFor (because it has no critical section).

All parts of  OCC code which are using tbb were changed on new primitives.

0024826: Wrapping of parallelisation algorithms

Small fix.
This commit is contained in:
msv
2015-02-05 15:49:35 +03:00
committed by bugmaster
parent a61133c8c7
commit c7b59798ca
34 changed files with 837 additions and 683 deletions

View File

@@ -41,10 +41,9 @@
#include <BOPAlgo_CheckerSI.hxx>
#include <BOPAlgo_ArgumentAnalyzer.hxx>
#include <BOPAlgo_CheckResult.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTest_Chronometer.hxx>
#include <OSD_Timer.hxx>
#include <BOPTest_Objects.hxx>
//
@@ -204,7 +203,7 @@ Standard_Integer bopcheck (Draw_Interpretor& di,
if (!strcmp(a[i], "-t")) {
bShowTime=Standard_True;
}
}
}
//
//aLevel = (n==3) ? Draw::Atoi(a[2]) : aNbInterfTypes-1;
//-------------------------------------------------------------------
@@ -218,7 +217,6 @@ Standard_Integer bopcheck (Draw_Interpretor& di,
BOPAlgo_CheckerSI aChecker;
BOPCol_ListOfShape aLS;
BOPDS_MapIteratorMapOfPassKey aItMPK;
BOPTest_Chronometer aChrono;
//
if (aLevel < (aNbInterfTypes-1)) {
di << "Info:\nThe level of check is set to "
@@ -239,11 +237,13 @@ Standard_Integer bopcheck (Draw_Interpretor& di,
aChecker.SetRunParallel(bRunParallel);
aChecker.SetFuzzyValue(aTol);
//
aChrono.Start();
OSD_Timer aTimer;
aTimer.Start();
//
aChecker.Perform();
//
aChrono.Stop();
aTimer.Stop();
aTimer.Show();
//
iErr=aChecker.ErrorStatus();
//
@@ -316,11 +316,9 @@ Standard_Integer bopcheck (Draw_Interpretor& di,
if (!iCnt) {
di << " This shape seems to be OK." << "\n";
}
if (bShowTime) {
Standard_Real aTime;
//
aTime=aChrono.Time();
Sprintf(buf, " Tps: %7.2lf\n", aTime);
if (bShowTime)
{
Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
di << buf;
}
return 0;
@@ -924,7 +922,7 @@ Standard_Integer xdistef(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if(n < 3) {
if(n < 3) {
di << "use xdistef edge face\n";
return 1;
}

View File

@@ -1,50 +0,0 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef BOPTest_Chronometer_HeaderFile
#define BOPTest_Chronometer_HeaderFile
//
#include <OSD_Timer.hxx>
//=======================================================================
//class : BOPTest_Chronometer
//purpose :
//=======================================================================
class BOPTest_Chronometer {
public:
BOPTest_Chronometer() {
}
//
~BOPTest_Chronometer() {
}
//
void Start() {
myChronometer.Reset();
myChronometer.Start();
}
//
void Stop() {
myChronometer.Stop();
myTime=myChronometer.ElapsedTime();
}
//
double Time() const{
return myTime;
};
//
protected:
OSD_Timer myChronometer;
double myTime;
};
#endif

View File

@@ -35,7 +35,7 @@
#include <BOPTest_DrawableShape.hxx>
#include <BOPTest_Objects.hxx>
#include <BOPTest_Chronometer.hxx>
#include <OSD_Timer.hxx>
static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**);
@@ -76,8 +76,6 @@ Standard_Integer bfillds(Draw_Interpretor& di,
Standard_Real aTol;
BOPCol_ListIteratorOfListOfShape aIt;
BOPCol_ListOfShape aLC;
BOPTest_Chronometer aChrono;
BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
aNbS=aLS.Extent();
if (!aNbS) {
@@ -94,7 +92,7 @@ Standard_Integer bfillds(Draw_Interpretor& di,
if (!strcmp(a[i], "-t")) {
bShowTime=Standard_True;
}
}
}
//
BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools();
//
@@ -107,7 +105,7 @@ Standard_Integer bfillds(Draw_Interpretor& di,
aIt.Initialize(aLT);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aLC.Append(aS);
aLC.Append(aS);
}
//
BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
@@ -116,7 +114,8 @@ Standard_Integer bfillds(Draw_Interpretor& di,
aPF.SetRunParallel(bRunParallel);
aPF.SetFuzzyValue(aTol);
//
aChrono.Start();
OSD_Timer aTimer;
aTimer.Start();
//
aPF.Perform();
iErr=aPF.ErrorStatus();
@@ -126,13 +125,12 @@ Standard_Integer bfillds(Draw_Interpretor& di,
return 0;
}
//
aChrono.Stop();
aTimer.Stop();
aTimer.Show();
//
if (bShowTime) {
Standard_Real aTime;
//
aTime=aChrono.Time();
Sprintf(buf, " Tps: %7.2lf\n", aTime);
if (bShowTime)
{
Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
di << buf;
}
//
@@ -160,8 +158,7 @@ Standard_Integer bbuild(Draw_Interpretor& di,
char buf[128];
Standard_Boolean bRunParallel, bShowTime;
Standard_Integer i, iErr;
BOPTest_Chronometer aChrono;
BOPCol_ListIteratorOfListOfShape aIt;
//
BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
@@ -193,7 +190,8 @@ Standard_Integer bbuild(Draw_Interpretor& di,
aBuilder.SetRunParallel(bRunParallel);
//
//
aChrono.Start();
OSD_Timer aTimer;
aTimer.Start();
//
aBuilder.PerformWithFiller(aPF);
iErr=aBuilder.ErrorStatus();
@@ -203,13 +201,12 @@ Standard_Integer bbuild(Draw_Interpretor& di,
return 0;
}
//
aChrono.Stop();
aTimer.Stop();
aTimer.Show();
//
if (bShowTime) {
Standard_Real aTime;
//
aTime=aChrono.Time();
Sprintf(buf, " Tps: %7.2lf\n", aTime);
if (bShowTime)
{
Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
di << buf;
}
//
@@ -246,7 +243,6 @@ Standard_Integer bbop(Draw_Interpretor& di,
Standard_Integer iErr, iOp, i;
BOPAlgo_Operation aOp;
BOPCol_ListIteratorOfListOfShape aIt;
BOPTest_Chronometer aChrono;
//
iOp=Draw::Atoi(a[2]);
if (iOp<0 || iOp>4) {
@@ -306,7 +302,8 @@ Standard_Integer bbop(Draw_Interpretor& di,
//
pBuilder->SetRunParallel(bRunParallel);
//
aChrono.Start();
OSD_Timer aTimer;
aTimer.Start();
//
pBuilder->PerformWithFiller(aPF);
iErr=pBuilder->ErrorStatus();
@@ -316,13 +313,11 @@ Standard_Integer bbop(Draw_Interpretor& di,
return 0;
}
//
aChrono.Stop();
aTimer.Stop();
aTimer.Show();
//
if (bShowTime) {
Standard_Real aTime;
//
aTime=aChrono.Time();
Sprintf(buf, " Tps: %7.2lf\n", aTime);
Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
di << buf;
}
//

View File

@@ -6,4 +6,3 @@ BOPTest_TolerCommands.cxx
BOPTest_ObjCommands.cxx
BOPTest_APICommands.cxx
BOPTest_OptionCommands.cxx
BOPTest_Chronometer.hxx