Commit ebace77
authored
[SYCL] Fix deadlock in Scheduler on Windows (#1703)
There was a deadlock in Scheduler on Windows only. This deadlock happens in implementation of std::shared_timed_mutex of MSVC's C++ std library.
The deadlock on Windows happens because lock ordering is not specified in C++ spec when we do lock and lock_shared simultaneously, and lock and lock_shared both wait.
It can be fixed in 2 ways:
1. upgrade DPC++ runtime to C++17 and change std::shared_timed_mutex to std::shared_mutex, there will be no deadlock on Windows out of the box. No regression on Linux.
2. implement spinlock
We can't upgrade to C++17 yet, so spinlock was implemented. It fixed the deadlock on Windows. But it creates another deadlock, this time on Linux only in implementation of lock and shared_lock in pthread. To fix this, added #ifdef _WIN32 to separate Windows and Linux parts of code.
Signed-off-by: Dmitry Vodopyanov <[email protected]>1 parent ae3fd5c commit ebace77
2 files changed
+36
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
101 | | - | |
| 102 | + | |
| 103 | + | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| |||
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
157 | | - | |
| 159 | + | |
| 160 | + | |
158 | 161 | | |
159 | 162 | | |
160 | 163 | | |
| |||
169 | 172 | | |
170 | 173 | | |
171 | 174 | | |
172 | | - | |
| 175 | + | |
| 176 | + | |
173 | 177 | | |
174 | 178 | | |
175 | 179 | | |
| |||
216 | 220 | | |
217 | 221 | | |
218 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
219 | 242 | | |
220 | 243 | | |
221 | 244 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
433 | 440 | | |
434 | 441 | | |
435 | 442 | | |
| |||
687 | 694 | | |
688 | 695 | | |
689 | 696 | | |
| 697 | + | |
| 698 | + | |
690 | 699 | | |
691 | 700 | | |
692 | 701 | | |
| |||
0 commit comments