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
David Cazier
CGoGN
Commits
1b8ad6f6
Commit
1b8ad6f6
authored
Feb 09, 2011
by
sylvain thery
Browse files
Merge branch 'CGoGN_MT' of
ssh://ingenis.u-strasbg.fr/home/thery/Dev/CGoGN
into CGoGN_MT
parents
23fc0820
a573b38f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/tuto_mt.cpp
View file @
1b8ad6f6
...
...
@@ -665,6 +665,10 @@ public:
typename
PFP
::
VEC3
n2
=
Algo
::
Geometry
::
vertexNormal
<
PFP
>
(
this
->
m_map
,
this
->
m_map
.
phi1
(
d
),
m_positions
);
typename
PFP
::
VEC3
n3
=
Algo
::
Geometry
::
vertexNormal
<
PFP
>
(
this
->
m_map
,
this
->
m_map
.
phi_1
(
d
),
m_positions
);
typename
PFP
::
VEC3
n
=
n1
+
n2
+
n3
;
n1
=
Algo
::
Geometry
::
vertexNormal
<
PFP
>
(
this
->
m_map
,
d
,
m_positions
);
n2
=
Algo
::
Geometry
::
vertexNormal
<
PFP
>
(
this
->
m_map
,
this
->
m_map
.
phi1
(
d
),
m_positions
);
n3
=
Algo
::
Geometry
::
vertexNormal
<
PFP
>
(
this
->
m_map
,
this
->
m_map
.
phi_1
(
d
),
m_positions
);
n
+=
n1
+
n2
+
n3
;
n
.
normalize
();
m_normals
[
d
]
=
n
;
// m_normals[d] = Algo::Geometry::vertexNormal<PFP>(this->m_map, d, m_positions);
...
...
@@ -717,32 +721,26 @@ int main(int argc, char **argv)
std
::
cout
<<
" linear "
<<
seconds
<<
"sec"
<<
std
::
endl
;
t1
=
glutGet
(
GLUT_ELAPSED_TIME
);
Algo
::
Geometry
::
computeNormalVertices
<
PFP
>
(
myMap
,
position
,
normal
,
SelectorTrue
());
t2
=
glutGet
(
GLUT_ELAPSED_TIME
);
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
std
::
cout
<<
" compute direct "
<<
seconds
<<
"sec"
<<
std
::
endl
;
//
t1 = glutGet(GLUT_ELAPSED_TIME);
//
Algo::Geometry::computeNormalVertices<PFP>(myMap,position,normal,SelectorTrue());
//
t2 = glutGet(GLUT_ELAPSED_TIME);
//
seconds = (t2 - t1) / 1000.0f;
//
std::cout << " compute direct "<< seconds << "sec" << std::endl;
TestFunctor
<
PFP
>
tf2
(
myMap
,
position
,
normal2
);
t1
=
glutGet
(
GLUT_ELAPSED_TIME
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
4
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
4
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
4
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
4
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
4
,
1024
);
t2
=
glutGet
(
GLUT_ELAPSED_TIME
);
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
std
::
cout
<<
" parallel 4 "
<<
seconds
<<
"sec"
<<
std
::
endl
;
std
::
cout
<<
" parallel 4
, 1024
"
<<
seconds
<<
"sec"
<<
std
::
endl
;
t1
=
glutGet
(
GLUT_ELAPSED_TIME
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
4
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
4
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
4
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
4
,
8192
);
t2
=
glutGet
(
GLUT_ELAPSED_TIME
);
...
...
@@ -752,9 +750,6 @@ int main(int argc, char **argv)
t1
=
glutGet
(
GLUT_ELAPSED_TIME
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
8
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
8
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
8
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
8
,
8192
);
t2
=
glutGet
(
GLUT_ELAPSED_TIME
);
...
...
@@ -765,21 +760,6 @@ int main(int argc, char **argv)
t1
=
glutGet
(
GLUT_ELAPSED_TIME
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
16
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
16
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
16
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
16
,
8192
);
t2
=
glutGet
(
GLUT_ELAPSED_TIME
);
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
std
::
cout
<<
" parallel 16/8192 "
<<
seconds
<<
"sec"
<<
std
::
endl
;
t1
=
glutGet
(
GLUT_ELAPSED_TIME
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
32
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
32
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
32
,
8192
);
Algo
::
Parallel
::
foreach_cell
<
PFP
>
(
myMap
,
VERTEX_ORBIT
,
tf2
,
32
,
8192
);
t2
=
glutGet
(
GLUT_ELAPSED_TIME
);
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
...
...
README.TXT
View file @
1b8ad6f6
Dépendences Linux:
installer les paquets suivants:
cmake libXi-dev libXmu-dev freeglut3-dev libdevil-dev libglew-dev libgmp3-dev libxml2-dev libboost-dev
cmake libXi-dev libXmu-dev freeglut3-dev libdevil-dev libglew-dev libgmp3-dev libxml2-dev libboost-dev
lizip-dev
Pour compiler CGoGN:
...
...
include/Algo/Geometry/normal.hpp
View file @
1b8ad6f6
...
...
@@ -108,6 +108,26 @@ void computeNormalFaces(typename PFP::MAP& map, const typename PFP::TVEC3& posit
}
}
template
<
typename
PFP
>
class
computeNormalVerticesFunctor
:
public
FunctorMap
<
typename
PFP
::
MAP
>
{
protected:
typename
PFP
::
MAP
&
m_map
;
const
typename
PFP
::
TVEC3
&
m_position
;
typename
PFP
::
TVEC3
&
m_normal
;
public:
computeNormalVerticesFunctor
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
normal
)
:
m_map
(
map
),
m_position
(
position
),
m_normal
(
normal
)
{}
bool
operator
()(
Dart
d
)
{
m_normal
[
d
]
=
vertexNormal
<
PFP
>
(
m_map
,
d
,
m_position
)
;
return
false
;
}
};
template
<
typename
PFP
>
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
...
...
include/Algo/Parallel/parallel_foreach.h
View file @
1b8ad6f6
...
...
@@ -44,7 +44,7 @@ namespace Parallel
* @param map the map
* @param orbit the orbit (VERTEX_ORBIT/EDGE_ORBIT/FACE_ORBIT/..
* @param func the functor to apply
* @param nbth number of thread to use
((use twice as threads of processor)
* @param nbth number of thread to use
* @param szbuff size of buffers to store darts in each thread (default is 8192, use less for lower memory consumsion)
* @param good a selector
*/
...
...
@@ -66,6 +66,20 @@ template <typename PFP>
void
foreach_cell
(
typename
PFP
::
MAP
&
map
,
unsigned
int
cell
,
FunctorType
&
func
,
unsigned
int
nbth
,
unsigned
int
szbuff
=
8192
,
const
FunctorSelect
&
good
=
SelectorTrue
());
/**
* Traverse darts of a map in parallel
* Functor application must be independant
* @param map the map
* @param func the functor to apply
* @param nbth number of thread to use
* @param szbuff size of buffers to store darts in each thread (default is 8192, use less for lower memory consumsion)
* @param good a selector
*/
template
<
typename
PFP
>
void
foreach_dart
(
typename
PFP
::
MAP
&
map
,
FunctorType
&
func
,
unsigned
int
nbth
,
unsigned
int
szbuff
=
8192
,
const
FunctorSelect
&
good
=
SelectorTrue
());
}
}
// end namespace
}
...
...
include/Algo/Parallel/parallel_foreach.hpp
View file @
1b8ad6f6
...
...
@@ -232,6 +232,78 @@ void foreach_cell(typename PFP::MAP& map, unsigned int cell, FunctorType& func,
}
template
<
typename
PFP
>
void
foreach_dart
(
typename
PFP
::
MAP
&
map
,
FunctorType
&
func
,
unsigned
int
nbth
,
unsigned
int
szbuff
,
const
FunctorSelect
&
good
)
{
std
::
vector
<
Dart
>
vd
[
nbth
];
boost
::
thread
*
threads
[
nbth
];
Dart
d
=
map
.
begin
();
// nbth new functions, new thread (with good darts !)
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
vd
[
i
].
reserve
(
szbuff
);
// fill each vd buffers with 4096 darts
unsigned
int
nb
=
0
;
while
((
d
!=
map
.
end
())
&&
(
nb
<
nbth
*
szbuff
)
)
{
if
(
good
(
d
))
{
vd
[
nb
%
nbth
].
push_back
(
d
);
nb
++
;
}
map
.
next
(
d
);
}
boost
::
barrier
sync1
(
nbth
+
1
);
boost
::
barrier
sync2
(
nbth
+
1
);
bool
finished
=
false
;
// lauch threads
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
threads
[
i
]
=
new
boost
::
thread
(
ThreadFunctor
(
func
,
vd
[
i
],
sync1
,
sync2
,
finished
));
// and continue to traverse the map
std
::
vector
<
Dart
>
tempo
[
nbth
];
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
tempo
[
i
].
reserve
(
szbuff
);
while
(
d
!=
map
.
end
())
{
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
tempo
[
i
].
clear
();
unsigned
int
nb
=
0
;
while
((
d
!=
map
.
end
())
&&
(
nb
<
nbth
*
szbuff
)
)
{
if
(
good
(
d
))
{
tempo
[
nb
%
nbth
].
push_back
(
d
);
nb
++
;
}
map
.
next
(
d
);
}
sync1
.
wait
();
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
vd
[
i
].
swap
(
tempo
[
i
]);
sync2
.
wait
();
}
sync1
.
wait
();
finished
=
true
;
sync2
.
wait
();
//wait for all theads to be finished
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
{
threads
[
i
]
->
join
();
delete
threads
[
i
];
}
}
}
}
// end namespace
}
...
...
src/Topology/generic/genericmap.cpp
View file @
1b8ad6f6
...
...
@@ -69,7 +69,8 @@ GenericMap::GenericMap()
{
m_attribs
[
i
].
setRegistry
(
m_attributes_registry_map
)
;
m_embeddings
[
i
]
=
NULL
;
m_markerTables
[
i
][
0
]
=
NULL
;
for
(
unsigned
int
j
=
0
;
j
<
NBTHREAD
;
++
j
)
m_markerTables
[
i
][
j
]
=
NULL
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment