Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
fix thread dead lock
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyu-intel committed Mar 15, 2024
1 parent a2f9814 commit 670b1d3
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions bestla/bestla/bestla_parallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,25 @@ class StdThreading : public IThreading {
}

inline void sync(int tidx, int idx = 0) override {
flag[idx].fetch_sub(1);
if (cr->mHybrid) {
Timer_T tm;
tm.start();
while (true) {
if (flag[idx].load() == 0)
break;
else
_mm_pause();
}
thread_time[tidx] -= int(tm.stop());
} else {
while (true) {
if (flag[idx].load() == 0)
break;
else
_mm_pause();
if (mThreadNum > 1) {
flag[idx].fetch_sub(1);
if (cr->mHybrid) {
Timer_T tm;
tm.start();
while (true) {
if (flag[idx].load() == 0)
break;
else
_mm_pause();
}
thread_time[tidx] -= int(tm.stop());
} else {
while (true) {
if (flag[idx].load() == 0)
break;
else
_mm_pause();
}
}
}
}
Expand Down

0 comments on commit 670b1d3

Please sign in to comment.