Skip to content

Commit

Permalink
define XTENSOR_TBB_THRESHOLD
Browse files Browse the repository at this point in the history
use tbb threshold in assignment
  • Loading branch information
adriendelsalle committed Nov 9, 2021
1 parent 26e3cc5 commit 11851f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 13 additions & 3 deletions include/xtensor/xassign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,20 @@ namespace xt
}

#if defined(XTENSOR_USE_TBB)
tbb::parallel_for(align_begin, align_end, simd_size, [&e1, &e2](size_t i)
if (size >= XTENSOR_TBB_THRESHOLD)
{
e1.template store_simd<lhs_align_mode>(i, e2.template load_simd<rhs_align_mode, value_type>(i));
});
tbb::parallel_for(align_begin, align_end, simd_size, [&e1, &e2](size_t i)
{
e1.template store_simd<lhs_align_mode>(i, e2.template load_simd<rhs_align_mode, value_type>(i));
});
}
else
{
for (size_type i = align_begin; i < align_end; i += simd_size)
{
e1.template store_simd<lhs_align_mode>(i, e2.template load_simd<rhs_align_mode, value_type>(i));
}
}
#elif defined(XTENSOR_USE_OPENMP)
if (size >= XTENSOR_OPENMP_TRESHOLD)
{
Expand Down
4 changes: 4 additions & 0 deletions include/xtensor/xtensor_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
#define XTENSOR_OPENMP_TRESHOLD 0
#endif

#ifndef XTENSOR_TBB_THRESHOLD
#define XTENSOR_TBB_THRESHOLD 0
#endif

#ifndef XTENSOR_SELECT_ALIGN
#define XTENSOR_SELECT_ALIGN(T) (XTENSOR_DEFAULT_ALIGNMENT != 0 ? XTENSOR_DEFAULT_ALIGNMENT : alignof(T))
#endif
Expand Down

0 comments on commit 11851f9

Please sign in to comment.