Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Pitiot
CGoGN
Commits
333cfee2
Commit
333cfee2
authored
Oct 05, 2012
by
Sylvain Thery
Browse files
remove CGoGN thread & current_thread parameter everywhere
parent
e1d6adb5
Changes
13
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/tuto_mt.cpp
View file @
333cfee2
...
...
@@ -39,7 +39,7 @@
#include
"Algo/Modelisation/polyhedron.h"
#include
"Algo/Parallel/parallel_foreach.h"
#include
"Algo/Parallel/cgogn_thread.h"
#include
"Utils/cgognStream.h"
#include
"Utils/chrono.h"
...
...
@@ -63,28 +63,6 @@ VertexAttribute<PFP::VEC3> normal;
template
<
typename
XXX
>
class
ThreadNormals
:
public
Algo
::
Parallel
::
CGoGNThread
<
typename
XXX
::
MAP
>
{
protected:
VertexAttribute
<
typename
XXX
::
VEC3
>&
m_positions
;
VertexAttribute
<
typename
XXX
::
VEC3
>&
m_normals
;
public:
ThreadNormals
(
typename
XXX
::
MAP
&
map
,
VertexAttribute
<
typename
XXX
::
VEC3
>&
pos
,
VertexAttribute
<
typename
XXX
::
VEC3
>&
norm
,
unsigned
int
th
)
:
Algo
::
Parallel
::
CGoGNThread
<
typename
XXX
::
MAP
>
(
map
,
th
),
m_positions
(
pos
),
m_normals
(
norm
)
{}
void
operator
()()
{
Algo
::
Geometry
::
computeNormalVertices
<
XXX
>
(
this
->
m_map
,
m_positions
,
m_normals
,
SelectorTrue
(),
this
->
tid
());
}
};
void
MyQT
::
cb_initGL
()
{
Utils
::
GLSLShader
::
setCurrentOGLVersion
(
2
);
...
...
@@ -109,9 +87,7 @@ void MyQT::cb_initGL()
m_lines
->
setScale
(
2.0
f
);
m_lines
->
setColor
(
Geom
::
Vec4f
(
0.0
f
,
1.0
f
,
0.2
f
,
0.0
f
));
CGoGNout
<<
"Je calcule les normales en meme temps que les primitives"
<<
CGoGNendl
;
boost
::
thread
thread1
(
ThreadNormals
<
PFP
>
(
myMap
,
position
,
normal
,
1
));
Algo
::
Geometry
::
computeNormalVertices
<
PFP
>
(
myMap
,
position
,
normal
)
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL2
::
LINES
);
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL2
::
POINTS
);
...
...
@@ -119,8 +95,6 @@ void MyQT::cb_initGL()
registerShader
(
m_shader
);
registerShader
(
m_lines
);
// on attend la fin du thread pour etre sur que normal est a jour
thread1
.
join
();
m_normalVBO
->
updateData
(
normal
);
}
...
...
include/Algo/Geometry/area.hpp
View file @
333cfee2
...
...
@@ -178,10 +178,10 @@ public:
};
template
<
typename
PFP
>
void
computeAreaFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
REAL
>&
area
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
void
computeAreaFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
REAL
>&
area
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
)
{
FunctorConvexFaceArea
<
PFP
>
funct
(
map
,
position
,
area
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
funct
,
nbth
,
false
,
select
);
}
...
...
@@ -202,10 +202,10 @@ public:
};
template
<
typename
PFP
>
void
computeOneRingAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
>&
area
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
void
computeOneRingAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
>&
area
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
)
{
FunctorConvexFaceArea
<
PFP
>
funct
(
map
,
position
,
area
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
false
,
select
);
}
...
...
@@ -227,10 +227,10 @@ public:
};
template
<
typename
PFP
>
void
computeVoronoiAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
>&
area
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
void
computeVoronoiAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
>&
area
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
)
{
FunctorConvexFaceArea
<
PFP
>
funct
(
map
,
position
,
area
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
false
,
select
);
}
...
...
include/Algo/Geometry/centroid.h
View file @
333cfee2
...
...
@@ -136,17 +136,17 @@ namespace Parallel
template
<
typename
PFP
>
void
computeCentroidVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
template
<
typename
PFP
>
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
template
<
typename
PFP
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
}
}
// namespace Geometry
...
...
include/Algo/Geometry/centroid.hpp
View file @
333cfee2
...
...
@@ -134,10 +134,10 @@ public:
template
<
typename
PFP
>
void
computeCentroidVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
const
FunctorSelect
&
select
,
unsigned
int
nbth
)
{
FunctorComputeCentroidVolumes
<
PFP
>
funct
(
map
,
position
,
vol_centroid
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VOLUME
>
(
map
,
funct
,
nbth
,
true
,
select
,
current_thread
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VOLUME
>
(
map
,
funct
,
nbth
,
true
,
select
);
}
...
...
include/Algo/Geometry/curvature.h
View file @
333cfee2
...
...
@@ -133,7 +133,7 @@ void computeCurvatureVertices_NormalCycles(
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmax
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Knormal
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
template
<
typename
PFP
>
void
computeCurvatureVertices_QuadraticFitting
(
...
...
@@ -144,7 +144,7 @@ void computeCurvatureVertices_QuadraticFitting(
VertexAttribute
<
typename
PFP
::
REAL
>&
kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmax
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmin
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
);
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
);
}
// namespace Parallel
...
...
include/Algo/Geometry/curvature.hpp
View file @
333cfee2
...
...
@@ -436,7 +436,7 @@ void computeCurvatureVertices_NormalCycles(
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmax
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Knormal
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
const
FunctorSelect
&
select
,
unsigned
int
nbth
)
{
// WAHOO BIG PROBLEM WITH LAZZY EMBEDDING !!!
if
(
!
map
.
template
isOrbitEmbedded
<
VERTEX
>())
...
...
@@ -456,7 +456,7 @@ void computeCurvatureVertices_NormalCycles(
}
FunctorComputeCurvatureVertices_NormalCycles
<
PFP
>
funct
(
map
,
radius
,
position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
true
,
select
,
current_thread
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
true
,
select
);
}
...
...
@@ -503,10 +503,10 @@ void computeCurvatureVertices_QuadraticFitting(
VertexAttribute
<
typename
PFP
::
REAL
>&
kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmax
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmin
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
const
FunctorSelect
&
select
,
unsigned
int
nbth
)
{
FunctorComputeCurvatureVertices_QuadraticFitting
<
PFP
>
funct
(
map
,
position
,
normal
,
kmax
,
kmin
,
Kmax
,
Kmin
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
true
,
select
,
current_thread
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
true
,
select
);
}
}
// namespace Parallel
...
...
include/Algo/Geometry/normal.h
View file @
333cfee2
...
...
@@ -71,11 +71,11 @@ void computeNormalVertices(typename PFP::MAP& map, const VertexAttribute<typenam
namespace
Parallel
{
template
<
typename
PFP
>
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
template
<
typename
PFP
>
void
computeNormalFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_normal
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
thread
=
0
)
;
void
computeNormalFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_normal
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
}
...
...
include/Algo/Geometry/normal.hpp
View file @
333cfee2
...
...
@@ -187,10 +187,10 @@ public:
};
template
<
typename
PFP
>
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
)
{
FunctorComputeNormalVertices
<
PFP
>
funct
(
map
,
position
,
normal
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
false
,
select
);
}
...
...
@@ -211,10 +211,10 @@ public:
};
template
<
typename
PFP
>
void
computeNormalFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
void
computeNormalFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
)
{
FunctorComputeNormalFaces
<
PFP
>
funct
(
map
,
position
,
normal
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
funct
,
nbth
,
false
,
select
);
}
...
...
@@ -236,10 +236,10 @@ public:
template
<
typename
PFP
>
void
computeAnglesBetweenNormalsOnEdges
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
EdgeAttribute
<
typename
PFP
::
REAL
>&
angles
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
void
computeAnglesBetweenNormalsOnEdges
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
EdgeAttribute
<
typename
PFP
::
REAL
>&
angles
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
)
{
FunctorComputeAngleBetweenNormalsOnEdge
<
PFP
>
funct
(
map
,
position
,
angles
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
EDGE
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
EDGE
>
(
map
,
funct
,
nbth
,
false
,
select
);
}
}
// endnamespace Parallel
...
...
include/Algo/Geometry/volume.h
View file @
333cfee2
...
...
@@ -52,7 +52,7 @@ typename PFP::REAL totalVolume(typename PFP::MAP& map, const VertexAttribute<typ
namespace
Parallel
{
template
<
typename
PFP
>
typename
PFP
::
REAL
totalVolume
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
typename
PFP
::
REAL
totalVolume
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
}
...
...
include/Algo/Geometry/volume.hpp
View file @
333cfee2
...
...
@@ -156,7 +156,7 @@ public:
template
<
typename
PFP
>
typename
PFP
::
REAL
totalVolume
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
typename
PFP
::
REAL
totalVolume
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
)
{
if
(
nbth
==
0
)
nbth
=
Algo
::
Parallel
::
optimalNbThreads
();
...
...
@@ -170,7 +170,7 @@ typename PFP::REAL totalVolume(typename PFP::MAP& map, const VertexAttribute<typ
double
total
=
0.0
;
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VOLUME
>
(
map
,
functs
,
true
,
select
,
current_thread
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VOLUME
>
(
map
,
functs
,
true
,
select
);
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
{
...
...
include/Algo/Parallel/cgogn_thread.h
deleted
100644 → 0
View file @
e1d6adb5
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __PARALLEL_THREAD__
#define __PARALLEL_THREAD__
namespace
CGoGN
{
namespace
Algo
{
namespace
Parallel
{
/**
* Class to encapsulate algorithm in a boost thread
* Usage:
* - Define a class MyCGoGNThread that inherit from CGoGNThread
* - call with boost::thread cgt1(MyCGoGNThread(map,1, ...);
* - wait to finish: cgt1.join();
*
* TODO: write a CGoGNThread version of "all" algorithm
*/
template
<
typename
MAP
>
class
CGoGNThread
{
protected:
MAP
&
m_map
;
unsigned
int
m_threadId
;
unsigned
int
tid
()
{
return
m_threadId
;
}
public:
CGoGNThread
(
MAP
&
map
,
unsigned
int
th
)
:
m_map
(
map
),
m_threadId
(
th
)
{}
virtual
~
CGoGNThread
()
{}
/**
* to implement with algo to execute (use m_threadId)
*/
virtual
void
operator
()()
=
0
;
};
}
// namespace Parallel
}
// namespace Algo
}
// namespace CGoGN
#endif
include/Algo/Parallel/parallel_foreach.h
View file @
333cfee2
...
...
@@ -106,7 +106,7 @@ void setNbCore(unsigned int nb);
* @param good a selector
*/
template
<
typename
MAP
,
unsigned
int
ORBIT
>
void
foreach_cell
(
MAP
&
map
,
std
::
vector
<
FunctorMapThreaded
<
MAP
>*>&
funcs
,
bool
needMarkers
=
false
,
const
FunctorSelect
&
good
=
allDarts
,
unsigned
int
currentThread
=
0
);
void
foreach_cell
(
MAP
&
map
,
std
::
vector
<
FunctorMapThreaded
<
MAP
>*>&
funcs
,
bool
needMarkers
=
false
,
const
FunctorSelect
&
good
=
allDarts
);
/**
* Traverse cells of a map in parallel. Use quick traversal, cell markers or dart markers if available !
...
...
@@ -118,7 +118,7 @@ void foreach_cell(MAP& map, std::vector<FunctorMapThreaded<MAP>*>& funcs, bool n
* @param good a selector
*/
template
<
typename
MAP
,
unsigned
int
ORBIT
>
void
foreach_cell
(
MAP
&
map
,
FunctorMapThreaded
<
MAP
>&
func
,
unsigned
int
nbth
=
0
,
bool
needMarkers
=
false
,
const
FunctorSelect
&
good
=
allDarts
,
unsigned
int
currentThread
=
0
);
void
foreach_cell
(
MAP
&
map
,
FunctorMapThreaded
<
MAP
>&
func
,
unsigned
int
nbth
=
0
,
bool
needMarkers
=
false
,
const
FunctorSelect
&
good
=
allDarts
);
/**
...
...
@@ -131,7 +131,7 @@ void foreach_cell(MAP& map, FunctorMapThreaded<MAP>& func, unsigned int nbth = 0
* @param good a selector
*/
template
<
typename
MAP
,
unsigned
int
ORBIT
>
void
foreach_cell_all_thread
(
MAP
&
map
,
std
::
vector
<
FunctorMapThreaded
<
MAP
>*>&
funcs
,
bool
needMarkers
=
false
,
const
FunctorSelect
&
good
=
allDarts
,
unsigned
int
currentThread
=
0
);
void
foreach_cell_all_thread
(
MAP
&
map
,
std
::
vector
<
FunctorMapThreaded
<
MAP
>*>&
funcs
,
bool
needMarkers
=
false
,
const
FunctorSelect
&
good
=
allDarts
);
/**
...
...
include/Algo/Parallel/parallel_foreach.hpp
View file @
333cfee2
...
...
@@ -127,7 +127,7 @@ inline unsigned int optimalNbThreads(NbParam p)
template
<
typename
MAP
,
unsigned
int
ORBIT
>
void
foreach_cell
(
MAP
&
map
,
FunctorMapThreaded
<
MAP
>&
func
,
unsigned
int
nbth
,
bool
needMarkers
,
const
FunctorSelect
&
good
,
unsigned
int
currentThread
)
void
foreach_cell
(
MAP
&
map
,
FunctorMapThreaded
<
MAP
>&
func
,
unsigned
int
nbth
,
bool
needMarkers
,
const
FunctorSelect
&
good
)
{
if
(
nbth
==
0
)
nbth
=
optimalNbThreads
();
...
...
@@ -150,7 +150,7 @@ void foreach_cell(MAP& map, FunctorMapThreaded<MAP>& func, unsigned int nbth, bo
funcs
.
push_back
(
func
.
duplicate
());
}
foreach_cell
<
MAP
,
ORBIT
>
(
map
,
funcs
,
needMarkers
,
good
,
currentThread
);
foreach_cell
<
MAP
,
ORBIT
>
(
map
,
funcs
,
needMarkers
,
good
);
if
(
!
shared
)
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
...
...
@@ -158,7 +158,7 @@ void foreach_cell(MAP& map, FunctorMapThreaded<MAP>& func, unsigned int nbth, bo
}
template
<
typename
MAP
,
unsigned
int
ORBIT
>
void
foreach_cell
(
MAP
&
map
,
std
::
vector
<
FunctorMapThreaded
<
MAP
>*>&
funcs
,
bool
needMarkers
,
const
FunctorSelect
&
good
,
unsigned
int
currentThread
)
void
foreach_cell
(
MAP
&
map
,
std
::
vector
<
FunctorMapThreaded
<
MAP
>*>&
funcs
,
bool
needMarkers
,
const
FunctorSelect
&
good
)
{
unsigned
int
nbth
=
funcs
.
size
();
...
...
@@ -198,7 +198,7 @@ void foreach_cell(MAP& map, std::vector<FunctorMapThreaded<MAP>*>& funcs, bool n
{
if
(
map
.
template
isOrbitEmbedded
<
ORBIT
>())
{
cmark
=
new
CellMarker
<
ORBIT
>
(
map
,
currentThread
)
;
cmark
=
new
CellMarker
<
ORBIT
>
(
map
)
;
d
=
map
.
begin
();
unsigned
int
nb
=
0
;
...
...
@@ -215,7 +215,7 @@ void foreach_cell(MAP& map, std::vector<FunctorMapThreaded<MAP>*>& funcs, bool n
}
else
{
dmark
=
new
DartMarker
(
map
,
currentThread
)
;
dmark
=
new
DartMarker
(
map
)
;
d
=
map
.
begin
();
unsigned
int
nb
=
0
;
while
((
d
!=
map
.
end
())
&&
(
nb
<
nbth
*
SIZE_BUFFER_THREAD
)
)
...
...
@@ -657,232 +657,11 @@ void foreach_cell2Pass(MAP& map, FunctorMapThreaded<MAP>& funcFront, FunctorMapT
delete
funcs
[
i
];
}
//
//
//template <typename MAP>
//void Foreach<MAP>::Foreach(MAP& map, unsigned int nbth):
//m_nbth(nbth)
//{
// if (m_nbth == 0)
// m_nbth = optimalNbThreads();
//
// m_funcs.reserve(m_nbth);
//
// m_vd = new std::vector<Dart>[2*nbth];
// for (unsigned int i = 0; i < 2*nbth; ++i)
// m_vd[i].reserve(SIZE_BUFFER_THREAD);
//}
//
//template <typename MAP>
//Foreach<MAP>::~Foreach(MAP& map, unsigned int nbth)
//{
// delete[] m_vd;
//}
//
//
//template <typename MAP>
//void Foreach<MAP>:: clearFunctors()
//{
// m_funcs.clear();
//}
//
//template <typename MAP>
//void Foreach<MAP>:: addFunctor(FunctorMapThreaded<MAP>* funcPtr)
//{
// m_funcs.push_back(funcPtr);
//}
//
//template <typename MAP>
//template<typename T>
//T* Foreach<MAP>::getFunctor(unsigned int i)
//{
// assert(i < m_funcs.size());
// return dynamic_cast<T*>(m_funcs[i]);
//}
//
//
//template <typename MAP>
//template <unsigned int ORBIT>
//void Foreach<MAP>::traverseCell<ORBIT>(bool needMarkers, const FunctorSelect& good, unsigned int currentThread)
//{
// assert(m_funcs.size() == m_nbth);
//
// boost::thread** threads = new boost::thread*[m_nbth];
//
// AttributeContainer* cont = NULL;
// DartMarker* dmark = NULL;
// CellMarker<ORBIT>* cmark = NULL;
// AttributeMultiVector<Dart>* quickTraversal = m_map.template getQuickTraversal<ORBIT>() ;
//
// // fill each vd buffers with SIZE_BUFFER_THREAD darts
// Dart d;
// unsigned int di=0;
//
// if(quickTraversal != NULL)
// {
// cont = &(m_map.template getAttributeContainer<ORBIT>()) ;
//
// di = cont->begin();
// unsigned int nb = 0;
// while ((di != cont->end()) && (nb < m_nbth*SIZE_BUFFER_THREAD) )
// {
// d = quickTraversal->operator[](di);
// if (good(d))
// {
// m_vd[nb%m_nbth].push_back(d);
// nb++;
// }
// cont->next(di);
// }
// }
// else
// {
// if(m_map.template isOrbitEmbedded<ORBIT>())
// {
// cmark = new CellMarker<ORBIT>(m_map, currentThread) ;
//
// d = m_map.begin();
// unsigned int nb = 0;
// while ((d != m_map.end()) && (nb < m_nbth*SIZE_BUFFER_THREAD) )
// {
// if (good(d) && (!m_map.isBoundaryMarked(d)) && (!cmark->isMarked(d)))
// {
// cmark->mark(d);
// m_vd[nb%m_nbth].push_back(d);
// nb++;
// }
// m_map.next(d);
// }
// }
// else
// {
// dmark = new DartMarker(m_map, currentThread) ;
// d = m_map.begin();
// unsigned int nb = 0;
// while ((d != m_map.end()) && (nb < m_nbth*SIZE_BUFFER_THREAD) )
// {
// if (good(d) && (!m_map.isBoundaryMarked(d)) && (!dmark->isMarked(d)))
// {
// dmark->markOrbit<ORBIT>(d);
// m_vd[nb%m_nbth].push_back(d);
// nb++;
// }
// m_map.next(d);
// }
// }
// }
//
// boost::barrier sync1(m_nbth+1);
// boost::barrier sync2(m_nbth+1);
// bool finished=false;
// // lauch threads
// if (needMarkers)
// {
// unsigned int nbth_prec = m_map.getNbThreadMarkers();
// if (nbth_prec < m_nbth+1)
// m_map.addThreadMarker(m_nbth+1-nbth_prec);
// }
//
// for (unsigned int i = 0; i < m_nbth; ++i)
// threads[i] = new boost::thread(ThreadFunction<MAP>(m_funcs[i], m_vd[i],sync1,sync2, finished,1+i));
//
//
// if (cont)
// {
// while (di != cont->end())
// {
// for (unsigned int i = 0; i < m_nbth; ++i)
// m_vd[m_nbth+i].clear();
// unsigned int nb = 0;
// while ((di != cont->end()) && (nb < m_nbth*SIZE_BUFFER_THREAD) )
// {
// d = quickTraversal->operator[](di);
// if (good(d))
// {
// m_vd[m_nbth + nb%m_nbth].push_back(d);
// nb++;
// }
// cont->next(di);
// }
// sync1.wait();
// for (unsigned int i = 0; i < m_nbth; ++i)
// m_vd[i].swap(m_vd[m_nbth+i]);
// sync2.wait();
// }
// }
// else if (cmark)
// {
// while (d != m_map.end())
// {
// for (unsigned int i = 0; i < m_nbth; ++i)
// m_vd[m_nbth+i].clear();
// unsigned int nb = 0;
// while ((d != m_map.end()) && (nb < m_nbth*SIZE_BUFFER_THREAD) )
// {
// if (good(d) && (!m_map.isBoundaryMarked(d)) && (!cmark->isMarked(d)))
// {
// cmark->mark(d);
// m_vd[m_nbth+nb%m_nbth].push_back(d);
// nb++;
// }
// m_map.next(d);
// }
// sync1.wait();
// for (unsigned int i = 0; i < m_nbth; ++i)
// m_vd[i].swap(m_vd[m_nbth+i]);
// sync2.wait();
// }
// }