#include <givaro/givconfig.h>
Givaro::GivaroMain givaroMain;
- /* TODO - fix conditionals once TBB 2021 support is added (#2105) */
- #if 1 /* TBB 2020 */
+ #ifdef HAVE_TBB2021
+ #include <tbb/version.h>
+ #else /* TBB 2020 */
#include <tbb/tbb_stddef.h>
#define TBB_VERSION_STRING \\
(stringize(TBB_VERSION_MAJOR) \".\" stringize(TBB_VERSION_MINOR))
- #else /* TBB 2021 */
- #include <tbb/version.h>
#endif
#include <Eigen/Core>
// can't do this loop as a range-based for loop since we are adding to it
// during the for loop
// process each element in mReducersTodo
+#ifdef HAVE_TBB2021
+ tbb::parallel_for_each(mReducersTodo.begin(), mReducersTodo.end(),
+ [&](const PreRow& prerow, PreRowFeeder& feeder)
+ {
+ auto& data = threadData.local();
+ processPreRow(prerow,
+ data.rowsVector,
+ *data.memoryBlock,
+ &feeder);
+ });
+#else /*TBB 2020*/
tbb::parallel_do(mReducersTodo.begin(), mReducersTodo.end(),
[&](const PreRow& prerow, PreRowFeeder& feeder)
{
*data.memoryBlock,
&feeder);
});
+#endif /* HAVE_TBB2021 */
// combine the thread local rows into mRows
for (const auto& data : threadData)
#ifndef __nc_f4_hpp__
#define __nc_f4_hpp__
+#include "M2/config.h"
+
#include <tbb/queuing_mutex.h> // for queuing_mutex
#include <tbb/null_mutex.h> // for null_mutex
-#include <tbb/parallel_do.h> // for parallel_do_feeder
+#ifdef HAVE_TBB2021
+#include <tbb/parallel_for_each.h> // for feeder
+#else /*TBB 2020*/
+#include <tbb/parallel_do.h> // for parallel_do_feeder
+#endif /*HAVE_TBB2021*/
#include <tbb/concurrent_unordered_map.h> // for concurrent_unordered_map
//#include <tbb/concurrent_vector.h> // for concurrent_vector (no longer needed)
// unfortunately we must use the GC allocator here for now
using RowsVector = std::vector<Row,gc_allocator<Row>>;
//using RowsVector = tbb::concurrent_vector<Row>;
-
+#ifdef HAVE_TBB2021
+ using PreRowFeeder = tbb::feeder<PreRow>;
+#else /* TBB 2020 */
using PreRowFeeder = tbb::parallel_do_feeder<PreRow>;
+#endif /* HAVE_TBB2021 */
// The pair in this unordered_map is (i,j) where:
// i is the column number
// j is the row that reduces it
AC_LANG(C++)
AC_CHECK_HEADER(tbb/tbb.h,
[AC_SEARCH_LIBS(TBB_runtime_interface_version,"tbb",
- LIBTBB=$ac_cv_search_TBB_runtime_interface_version
- HAVE_LIBTBB=yes,
+ [LIBTBB=$ac_cv_search_TBB_runtime_interface_version
+ HAVE_LIBTBB=yes
+ AC_CHECK_HEADER(tbb/version.h,[AC_DEFINE(HAVE_TBB2021,[],[TBB version at least 2021])])
+ ],
[AC_MSG_ERROR([tbb library not found])])],
[AC_MSG_ERROR([tbb include file (tbb.h) not found])])
AC_LANG(C)
/* Define to `unsigned int' if <sys/types.h> does not define. */
#cmakedefine size_t ${CMAKE_HOST_SYSTEM}
+#cmakedefine HAVE_TBB2021
+
#endif /* _M2_CONFIG_H */