Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
faust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
faust group
faust
Commits
6d99d43b
Commit
6d99d43b
authored
5 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Fix synchronization issue in Faust::multiply_par_run() (multithreaded product of N factors).
parent
56878960
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/faust_linear_operator/CPU/faust_Transform.hpp
+26
-21
26 additions, 21 deletions
src/faust_linear_operator/CPU/faust_Transform.hpp
with
26 additions
and
21 deletions
src/faust_linear_operator/CPU/faust_Transform.hpp
+
26
−
21
View file @
6d99d43b
...
...
@@ -1130,7 +1130,7 @@ Faust::MatDense<FPP,Cpu> Faust::Transform<FPP,Cpu>::multiply_par(const Faust::Ma
data
[
data_size
-
1
]
=
const_cast
<
Faust
::
MatDense
<
FPP
,
Cpu
>*>
(
&
A
);
for
(
auto
ptr
:
this
->
data
)
{
cout
<<
"fac i="
<<
i
<<
": "
<<
ptr
<<
endl
;
//
cout << "fac i=" << i << ": " << ptr << endl;
if
(
opThis
==
'N'
)
data
[
i
++
]
=
ptr
;
else
...
...
@@ -1208,31 +1208,36 @@ void Faust::multiply_par_run(int nth, int thid, int num_per_th, int data_size, c
sM
->
multiply
(
*
mats
[
thid
],
opThis
);
else
dynamic_cast
<
Faust
::
MatDense
<
FPP
,
Cpu
>*>
(
data
[
i
])
->
multiply
(
*
mats
[
thid
],
opThis
);
data
[
thid
]
=
mats
[
thid
];
// mats[thid]->Display();
// cout << mats[thid]->norm() << endl;
// cout << "thid=" << thid << "mats[thid]=" << mats[thid] << "data[thid]=" << data[thid] << endl;
if
(
tmp2
!=
nullptr
)
delete
tmp2
;
}
{
// mutex block
unique_lock
<
mutex
>
l1
(
barrier_mutex
);
barrier_count
--
;
// string ite_str = i>=0?string(" (ite = ") + to_string(i) + ") ": "";
if
(
barrier_count
>
0
)
{
// the threads wait here for the last one to finish its iteration i
// std::cout << "thread " << thid /*<< ite_str */ << " is waiting on barrier (" << barrier_count << ")." << std::endl;
barrier_cv
.
wait
(
l1
/*, [&barrier_count, &num_threads]{return barrier_count == num_threads;}*/
);
// std::cout << "thread " << thid /*<< ite_str */<<" continues." << std::endl;
}
else
{
// the last thread to finish the iteration i wakes the other to continue the execution
// std::cout << "thread " << thid /*<< ite_str */<< " reinits barrier." << std::endl;
barrier_count
=
start_nth
;
barrier_cv
.
notify_all
();
}
}
#define barrier() \
{ \
unique_lock<mutex> l1(barrier_mutex);
/* mutex block */
\
barrier_count--;\
/* string ite_str = i>=0?string(" (ite = ") + to_string(i) + ") ": "";*/
\
if(barrier_count > 0)\
{\
/* the threads wait here for the last one to finish its iteration i*/
\
/* std::cout << "thread " << thid << ite_str << " is waiting on barrier (" << barrier_count << ")." << std::endl;*/
\
barrier_cv.wait(l1
/*, [&barrier_count, &num_threads]{return barrier_count == num_threads;}*/
);\
/* std::cout << "thread " << thid << ite_str <<" continues." << std::endl;*/
\
}\
else {\
/* the last thread to finish the iteration i wakes the other to continue the execution */
\
/* std::cout << "thread " << thid << ite_str << " reinits barrier." << std::endl;*/
\
barrier_count = start_nth;\
barrier_cv.notify_all();\
}\
}
barrier
();
if
(
thid
<
nth
)
{
data
[
thid
]
=
mats
[
thid
];
}
barrier
();
if
(
nth
>
1
)
{
num_per_th
=
2
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment