From 680f233e6ad36cd59fad782b3d59248426531651 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sun, 7 Jul 2024 20:39:57 +0800 Subject: [PATCH] avoid thrust copy --- src/utilities/include/par.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/utilities/include/par.h b/src/utilities/include/par.h index 70751e20b..e95ae916f 100644 --- a/src/utilities/include/par.h +++ b/src/utilities/include/par.h @@ -174,9 +174,30 @@ STL_DYNAMIC_BACKEND_VOID(uninitialized_fill) STL_DYNAMIC_BACKEND_VOID(uninitialized_copy) STL_DYNAMIC_BACKEND_VOID(stable_sort) STL_DYNAMIC_BACKEND_VOID(fill) -STL_DYNAMIC_BACKEND_VOID(copy) STL_DYNAMIC_BACKEND_VOID(inclusive_scan) -STL_DYNAMIC_BACKEND_VOID(copy_n) + +// there are some issues with thrust copy +template +OutputIterator copy(ExecutionPolicy policy, InputIterator first, + InputIterator last, OutputIterator result) { +#if MANIFOLD_PAR == 'T' && \ + (TBB_INTERFACE_VERSION >= 10000 && __has_include()) + if (policy == ExecutionPolicy::Par) + return std::copy(std::execution::par_unseq, first, last, result); +#endif + return std::copy(first, last, result); +} + +template +OutputIterator copy_n(ExecutionPolicy policy, InputIterator first, size_t n, + OutputIterator result) { +#if MANIFOLD_PAR == 'T' && \ + (TBB_INTERFACE_VERSION >= 10000 && __has_include()) + if (policy == ExecutionPolicy::Par) + return std::copy_n(std::execution::par_unseq, first, n, result); +#endif + return std::copy_n(first, n, result); +} // void implies that the user have to specify the return type in the template // argument, as we are unable to deduce it