mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +03:00
0024157: Parallelization of assembly part of BO
New metod was implemented to class BOPAlgo_Builder - method: void BOPAlgo_Builder::SetRunParallel(const Standard_Boolean theFlag) The method sets the flag of parallel processing if <theFlag> is true the parallel processing is switched on if <theFlag> is false the parallel processing is switched off - method: Standard_Boolean BOPAlgo_Builder::RunParallel()const The method returns the flag of parallel processing Class BOPTest was changed - static function: Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a) The optional parameters [ -s -t ] have been added to the command line of the command 'bbuild': bbuild r [-s -t] -s : builds the result using serial procesing -t : show the wall time
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <BOPTest.ixx>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <NCollection_IncAllocator.hxx>
|
||||
|
||||
@@ -39,6 +40,73 @@
|
||||
#include <BOPTest_Objects.hxx>
|
||||
|
||||
//
|
||||
#ifdef HAVE_TBB
|
||||
#include <BOPCol_TBB.hxx>
|
||||
//=======================================================================
|
||||
//class : BOPTime_Chronometer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
class BOPTime_Chronometer {
|
||||
public:
|
||||
BOPTime_Chronometer() {
|
||||
}
|
||||
//
|
||||
~BOPTime_Chronometer() {
|
||||
}
|
||||
//
|
||||
void Start() {
|
||||
myT0 = tick_count::now();
|
||||
}
|
||||
//
|
||||
void Stop() {
|
||||
myTime=(tick_count::now() - myT0).seconds();
|
||||
}
|
||||
//
|
||||
double Time() const{
|
||||
return myTime;
|
||||
};
|
||||
//
|
||||
protected:
|
||||
tick_count myT0;
|
||||
double myTime;
|
||||
};
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
#else
|
||||
#include <OSD_Chronometer.hxx>
|
||||
//=======================================================================
|
||||
//class : BOPTime_Chronometer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
class BOPTime_Chronometer {
|
||||
public:
|
||||
BOPTime_Chronometer() {
|
||||
}
|
||||
//
|
||||
~BOPTime_Chronometer() {
|
||||
}
|
||||
//
|
||||
void Start() {
|
||||
myChronometer.Reset();
|
||||
myChronometer.Start();
|
||||
}
|
||||
//
|
||||
void Stop() {
|
||||
myChronometer.Stop();
|
||||
myChronometer.Show(myTime);
|
||||
}
|
||||
//
|
||||
double Time() const{
|
||||
return myTime;
|
||||
};
|
||||
//
|
||||
protected:
|
||||
OSD_Chronometer myChronometer;
|
||||
double myTime;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**);
|
||||
static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**);
|
||||
static Standard_Integer bbop (Draw_Interpretor&, Standard_Integer, const char**);
|
||||
@@ -56,7 +124,7 @@ static Standard_Integer bclear (Draw_Interpretor&, Standard_Integer, const cha
|
||||
const char* g = "Partition commands";
|
||||
// Commands
|
||||
theCommands.Add("bfillds" , "use bfillds" , __FILE__, bfillds , g);
|
||||
theCommands.Add("bbuild" , "use bbuild r" , __FILE__, bbuild, g);
|
||||
theCommands.Add("bbuild" , " use bbuild r [-s -t]" , __FILE__, bbuild, g);
|
||||
theCommands.Add("bbop" , "use bbop r op" , __FILE__, bbop, g);
|
||||
theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
|
||||
}
|
||||
@@ -127,15 +195,14 @@ Standard_Integer bfillds(Draw_Interpretor& di, Standard_Integer n, const char**
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : bbuild
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n!=2) {
|
||||
di << " Use bbuild r\n";
|
||||
if (n<2) {
|
||||
di << " use bbuild r [-s -t]\n";
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
@@ -145,9 +212,14 @@ Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
char buf[32];
|
||||
Standard_Integer iErr;
|
||||
char buf[128];
|
||||
Standard_Boolean bRunParallel, bShowTime;
|
||||
Standard_Integer i, iErr;
|
||||
|
||||
BOPTime_Chronometer aChrono;
|
||||
BOPCol_ListIteratorOfListOfShape aIt;
|
||||
//
|
||||
|
||||
//
|
||||
BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
|
||||
//
|
||||
@@ -168,7 +240,22 @@ Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a
|
||||
aBuilder.AddArgument(aS);
|
||||
}
|
||||
//
|
||||
aBuilder.PerformWithFiller(aPF);
|
||||
bShowTime=Standard_False;
|
||||
bRunParallel=Standard_True;
|
||||
for (i=2; i<n; ++i) {
|
||||
if (!strcmp(a[i], "-s")) {
|
||||
bRunParallel=Standard_False;
|
||||
}
|
||||
else if (!strcmp(a[i], "-t")) {
|
||||
bShowTime=Standard_True;
|
||||
}
|
||||
}
|
||||
aBuilder.SetRunParallel(bRunParallel);
|
||||
//
|
||||
//
|
||||
aChrono.Start();
|
||||
//
|
||||
aBuilder.PerformWithFiller(aPF);
|
||||
iErr=aBuilder.ErrorStatus();
|
||||
if (iErr) {
|
||||
Sprintf(buf, " error: %d\n", iErr);
|
||||
@@ -176,6 +263,16 @@ Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
aChrono.Stop();
|
||||
//
|
||||
if (bShowTime) {
|
||||
Standard_Real aTime;
|
||||
//
|
||||
aTime=aChrono.Time();
|
||||
Sprintf(buf, " Tps: %7.2lf\n", aTime);
|
||||
di << buf;
|
||||
}
|
||||
//
|
||||
const TopoDS_Shape& aR=aBuilder.Shape();
|
||||
if (aR.IsNull()) {
|
||||
di << " null shape\n";
|
||||
|
Reference in New Issue
Block a user