Skip to content

Commit ee514fd

Browse files
committed
add some doc
1 parent 8ae6025 commit ee514fd

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

stan/math/rev/functor/map_rect_concurrent.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ map_rect_concurrent(
4545
};
4646

4747
#ifdef STAN_THREADS
48+
// we must use task isolation as described here:
49+
// https://software.intel.com/content/www/us/en/develop/documentation/tbb-documentation/top/intel-threading-building-blocks-developer-guide/task-isolation.html
50+
// this is to ensure that the thread local AD tape ressource is
51+
// not being modified from a different task which may happen
52+
// whenever this function is being used itself in a parallel
53+
// context (like running multiple chains for Stan)
4854
tbb::this_task_arena::isolate( [&]{
4955
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, num_jobs),
5056
[&](const tbb::blocked_range<size_t>& r) {

stan/math/rev/functor/reduce_sum.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ struct reduce_sum_impl<ReduceFunction, require_var_t<ReturnType>, ReturnType,
250250
std::forward<Vec>(vmapped),
251251
std::forward<Args>(args)...);
252252

253+
// we must use task isolation as described here:
254+
// https://software.intel.com/content/www/us/en/develop/documentation/tbb-documentation/top/intel-threading-building-blocks-developer-guide/task-isolation.html
255+
// this is to ensure that the thread local AD tape ressource is
256+
// not being modified from a different task which may happen
257+
// whenever this function is being used itself in a parallel
258+
// context (like running multiple chains for Stan)
253259
tbb::this_task_arena::isolate( [&]{
254260
if (auto_partitioning) {
255261
tbb::parallel_reduce(

0 commit comments

Comments
 (0)