Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CGoGN
CGoGN
Commits
78b25edf
Commit
78b25edf
authored
Sep 04, 2014
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolve MT bug
parent
1b7ac321
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
10 deletions
+29
-10
include/Topology/generic/genericmap.h
include/Topology/generic/genericmap.h
+5
-2
include/Topology/generic/genericmap.hpp
include/Topology/generic/genericmap.hpp
+15
-3
include/Topology/generic/traversor/traversorCell.hpp
include/Topology/generic/traversor/traversorCell.hpp
+9
-5
No files found.
include/Topology/generic/genericmap.h
View file @
78b25edf
...
...
@@ -100,12 +100,15 @@ public:
/// compute thread index in the table of thread
inline
unsigned
int
getCurrentThreadIndex
()
const
;
/// add
a thread to the table of thread
inline
void
addThreadId
(
const
std
::
thread
::
id
&
id
);
/// add
place for n new threads in the table of thread return index of first
inline
unsigned
int
addEmptyThreadIds
(
unsigned
int
n
);
/// remove the n last added threads from table
inline
void
popThreadIds
(
unsigned
int
nb
);
/// get ref to jth threadId for updating (in thread)
inline
std
::
thread
::
id
&
getThreadId
(
unsigned
int
j
);
protected:
/**
...
...
include/Topology/generic/genericmap.hpp
View file @
78b25edf
...
...
@@ -38,14 +38,21 @@ inline unsigned int GenericMap::getCurrentThreadIndex() const
while
(
id
!=
m_thread_ids
[
i
])
{
i
++
;
assert
(
i
<
<
m_thread_ids
.
size
());
assert
(
i
<
m_thread_ids
.
size
());
}
return
i
;
}
inline
void
GenericMap
::
addThreadId
(
const
std
::
thread
::
id
&
id
)
//inline void GenericMap::addThreadId(const std::thread::id& id)
//{
// m_thread_ids.push_back(id);
//}
inline
unsigned
int
GenericMap
::
addEmptyThreadIds
(
unsigned
int
n
)
{
m_thread_ids
.
push_back
(
id
);
unsigned
int
nb
=
m_thread_ids
.
size
();
m_thread_ids
.
resize
(
nb
+
n
);
return
nb
;
}
inline
void
GenericMap
::
popThreadIds
(
unsigned
int
nb
)
...
...
@@ -55,6 +62,11 @@ inline void GenericMap::popThreadIds(unsigned int nb)
m_thread_ids
.
pop_back
();
}
inline
std
::
thread
::
id
&
GenericMap
::
getThreadId
(
unsigned
int
j
)
{
return
m_thread_ids
[
j
];
}
/****************************************
* BUFFERS MANAGEMENT *
...
...
include/Topology/generic/traversor/traversorCell.hpp
View file @
78b25edf
...
...
@@ -660,10 +660,10 @@ protected:
bool
&
m_finished
;
unsigned
int
m_id
;
FUNC
m_lambda
;
std
::
thread
::
id
&
m_threadId
;
// ref on thread::id in table of threads in genericMap for init at operator()
public:
ThreadFunction
(
FUNC
func
,
std
::
vector
<
CELL
>&
vd
,
Utils
::
Barrier
&
s1
,
Utils
::
Barrier
&
s2
,
bool
&
finished
,
unsigned
int
id
)
:
m_cells
(
vd
),
m_sync1
(
s1
),
m_sync2
(
s2
),
m_finished
(
finished
),
m_id
(
id
),
m_lambda
(
func
)
ThreadFunction
(
FUNC
func
,
std
::
vector
<
CELL
>&
vd
,
Utils
::
Barrier
&
s1
,
Utils
::
Barrier
&
s2
,
bool
&
finished
,
unsigned
int
id
,
std
::
thread
::
id
&
threadId
)
:
m_cells
(
vd
),
m_sync1
(
s1
),
m_sync2
(
s2
),
m_finished
(
finished
),
m_id
(
id
),
m_lambda
(
func
)
,
m_threadId
(
threadId
)
{
}
...
...
@@ -672,6 +672,9 @@ public:
void
operator
()()
{
// first thing to do set the thread id in genericMap
m_threadId
=
std
::
this_thread
::
get_id
();
while
(
!
m_finished
)
{
for
(
typename
std
::
vector
<
CELL
>::
const_iterator
it
=
m_cells
.
begin
();
it
!=
m_cells
.
end
();
++
it
)
...
...
@@ -710,11 +713,12 @@ void foreach_cell_tmpl(MAP& map, FUNC func, unsigned int nbth)
std
::
thread
**
threads
=
new
std
::
thread
*
[
nbth
];
ThreadFunction
<
ORBIT
,
FUNC
>**
tfs
=
new
ThreadFunction
<
ORBIT
,
FUNC
>*
[
nbth
];
// add place for nbth new threads in the table of threadId in genericmap
unsigned
int
firstThread
=
map
.
addEmptyThreadIds
(
nbth
);
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
{
tfs
[
i
]
=
new
ThreadFunction
<
ORBIT
,
FUNC
>
(
func
,
vd
[
i
],
sync1
,
sync2
,
finished
,
1
+
i
);
tfs
[
i
]
=
new
ThreadFunction
<
ORBIT
,
FUNC
>
(
func
,
vd
[
i
],
sync1
,
sync2
,
finished
,
1
+
i
,
map
.
getThreadId
(
firstThread
+
i
)
);
threads
[
i
]
=
new
std
::
thread
(
std
::
ref
(
*
(
tfs
[
i
])
)
);
map
.
addThreadId
(
threads
[
i
]
->
get_id
());
}
// and continue to traverse the map
...
...
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