|
| 1 | +# libopenblas |
| 2 | + |
| 3 | +libopenblas is a fairly low-level library, and can get pulled in transitively |
| 4 | +via dependencies. e.g., [tgen](https://github.com/shadow/tgen) uses libigraph, |
| 5 | +which links against liblapack, which links against blas. |
| 6 | + |
| 7 | +## Deadlocks due to `sched_yield` loops |
| 8 | + |
| 9 | +libopenblas, when compiled with pthread support, makes extensive use of |
| 10 | +spin-waiting in `sched_yield`-loops, which currently result in deadlock under |
| 11 | +Shadow. |
| 12 | + |
| 13 | +There are several known workarounds: |
| 14 | + |
| 15 | +* Use a different implementation of libblas. e.g. on Ubuntu, there are several |
| 16 | + alternative packages that can [provide |
| 17 | + libblas](https://packages.ubuntu.com/hirsute/libblas.so.3). In particular, |
| 18 | + [libblas3](https://packages.ubuntu.com/hirsute/libblas3) doesn't have this issue. |
| 19 | + |
| 20 | +* Install libopenblas compiled without pthread support. e.g. on Ubuntu this can |
| 21 | + be obtained by installing |
| 22 | + [libopenblas0-serial](https://packages.ubuntu.com/hirsute/libopenblas0-serial) |
| 23 | + instead of |
| 24 | + [libopenblas0-pthread](https://packages.ubuntu.com/hirsute/libopenblas0-pthread). |
| 25 | + |
| 26 | +* Configure libopenblas to not use threads at runtime. This can be done by |
| 27 | + setting the environment variable `OPENBLAS_NUM_THREADS=1`, in the process's |
| 28 | + [environment](https://shadow.github.io/docs/guide/shadow_config_spec.html#hostshostnameprocessesenvironment) |
| 29 | + attribute in the Shadow config. |
| 30 | + |
| 31 | +See also: |
| 32 | + |
| 33 | +* [libopenblas deadlocks](https://github.com/shadow/shadow/issues/1788) |
| 34 | +* [sched\_yield loops](https://github.com/shadow/shadow/issues/1792) |
0 commit comments