Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doxygen/parallelism_support/threading_tbb.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ By default stan-math builds only the main `tbb` library by defining the `makefil
TBB_LIBRARIES=tbb
```

The Intel TBB provides in addition to the main library memory allocators which are specifically designed to speedup threaded programs. These speedups have so far only been observed on MacOS systems for Stan programs such that on MacOS the default is set to
The Intel TBB provides in addition to the main library memory allocators which are specifically designed to speedup threaded programs. These can be enabled with

```
TBB_LIBRARIES=tbb tbbmalloc tbbmalloc_proxy
```

Users may override the default choices by defining `TBB_LIBRARIES` in the `make/local` file manually. Please refer to the [pull request](https://github.com/stan-dev/math/pull/1376) which merged the Intel TBB for further details on the performance evaluations.
Previously this was the default on MacOS, but on MacOS `tbbmalloc_proxy` registers a process-wide malloc zone which can crash host processes (such as Julia, Python, or R) that load a Stan model as a shared library. See [issue #3425](https://github.com/stan-dev/math/issues/3425) for details.

Users may override the default choice by defining `TBB_LIBRARIES` in the `make/local` file manually. Please refer to the [pull request](https://github.com/stan-dev/math/pull/1376) which merged the Intel TBB for further details on the performance evaluations.

# Requirements

Expand Down
15 changes: 7 additions & 8 deletions make/compiler_flags
Original file line number Diff line number Diff line change
Expand Up @@ -272,21 +272,20 @@ endif
# Sets up TBB CXXFLAGS_TBB and LDFLAGS_TBB to compile and link to TBB
#
# The tbbmalloc and tbbmalloc_proxy libraries are optionally included
# as targets. By default these are included on MacOS only. This behavior
# can be altered by explicitly setting the TBB_LIBRARIES variable which
# should contain "tbb" or "tbb tbbmalloc tbbmalloc_proxy". Setting the
# as targets. By default they are not included on any platform. On MacOS
# tbbmalloc_proxy registers a process-wide malloc zone that can crash host
# processes (Julia, Python, R) which load Stan as a shared library, see
# https://github.com/stan-dev/math/issues/3425. This behavior can be
# altered by explicitly setting the TBB_LIBRARIES variable which should
# contain "tbb" or "tbb tbbmalloc tbbmalloc_proxy". Setting the
# TBB_LIBRARIES variable overrides the default.

TBB_BIN ?= $(MATH)lib/tbb
TBB_RELATIVE_PATH ?= ../$(notdir $(TBB))
TBB_BIN_ABSOLUTE_PATH = $(abspath $(TBB_BIN))
TBB_ABSOLUTE_PATH = $(abspath $(TBB))

ifeq ($(OS),Darwin)
TBB_LIBRARIES ?= tbb tbbmalloc tbbmalloc_proxy
else
TBB_LIBRARIES ?= tbb
endif
TBB_LIBRARIES ?= tbb

ifdef TBB_LIB

Expand Down
Loading