Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hurstel
CGoGN
Commits
a573b38f
Commit
a573b38f
authored
Feb 09, 2011
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update //
parent
31c9ff1a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
121 additions
and
34 deletions
+121
-34
Apps/Tuto/tuto_mt.cpp
Apps/Tuto/tuto_mt.cpp
+11
-31
README.TXT
README.TXT
+1
-1
include/Algo/Geometry/normal.hpp
include/Algo/Geometry/normal.hpp
+20
-0
include/Algo/Parallel/parallel_foreach.h
include/Algo/Parallel/parallel_foreach.h
+15
-1
include/Algo/Parallel/parallel_foreach.hpp
include/Algo/Parallel/parallel_foreach.hpp
+72
-0
src/Topology/generic/genericmap.cpp
src/Topology/generic/genericmap.cpp
+2
-1
No files found.
Apps/Tuto/tuto_mt.cpp
View file @
a573b38f
...
...
@@ -666,6 +666,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);
...
...
@@ -718,32 +722,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
);
...
...
@@ -753,9 +751,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
);
...
...
@@ -766,21 +761,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 @
a573b38f
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 @
a573b38f
...
...
@@ -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 @
a573b38f
...
...
@@ -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 @
a573b38f
...
...
@@ -228,6 +228,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 @
a573b38f
...
...
@@ -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
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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