From 54b01378c9fc76789b8f64b00be7f0ec80243316 Mon Sep 17 00:00:00 2001 From: "Boyarinov, Konstantin" Date: Fri, 20 Dec 2024 05:26:12 -0800 Subject: [PATCH] Add new deduction guides and test --- include/oneapi/tbb/blocked_nd_range.h | 40 +++++++-- .../conformance_blocked_nd_range.cpp | 81 +++++++++++++------ 2 files changed, 89 insertions(+), 32 deletions(-) diff --git a/include/oneapi/tbb/blocked_nd_range.h b/include/oneapi/tbb/blocked_nd_range.h index d2691ce19f..89ffb3c110 100644 --- a/include/oneapi/tbb/blocked_nd_range.h +++ b/include/oneapi/tbb/blocked_nd_range.h @@ -47,17 +47,10 @@ namespace d1 { */ template> -<<<<<<< HEAD:include/oneapi/tbb/blocked_rangeNd.h -class blocked_rangeNd_impl; - -template -class blocked_rangeNd_impl> { -======= class blocked_nd_range_impl; template class blocked_nd_range_impl> { ->>>>>>> origin/rarutyun/blocked_range_nd_class:include/oneapi/tbb/blocked_nd_range.h public: //! Type of a value. using value_type = Value; @@ -154,6 +147,39 @@ class blocked_nd_range : public blocked_nd_range_impl { using base::base; }; +#if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT +template 0)>, + typename = std::enable_if_t<(... && std::is_same_v)>, + typename = std::enable_if_t<(N0 == 2 || N0 == 3) && (... && (Ns == 2 || Ns == 3))>> +blocked_nd_range(const Value (&)[N0], const Values (&... dim)[Ns]) +-> blocked_nd_range; + +template )>> +blocked_nd_range(blocked_range, blocked_range...) +-> blocked_nd_range; + +template > +blocked_nd_range(const Value (&)[N]) +-> blocked_nd_range; + +template +blocked_nd_range(const Value (&)[N], typename blocked_nd_range::size_type) +-> blocked_nd_range; + +template +blocked_nd_range(blocked_nd_range, oneapi::tbb::split) +-> blocked_nd_range; + +template +blocked_nd_range(blocked_nd_range, oneapi::tbb::proportional_split) +-> blocked_nd_range; + +#endif // __TBB_CPP17_DEDUCTION_GUIDES_PRESENT + } // namespace d1 } // namespace detail diff --git a/test/conformance/conformance_blocked_nd_range.cpp b/test/conformance/conformance_blocked_nd_range.cpp index 1cd0b0d9fe..545edaf26d 100644 --- a/test/conformance/conformance_blocked_nd_range.cpp +++ b/test/conformance/conformance_blocked_nd_range.cpp @@ -296,35 +296,66 @@ TEST_CASE("blocked_nd_range proportional splitting") { //! Testing blocked_rangeNd deduction guides //! \brief \ref interface TEST_CASE("blocked_rangeNd deduction guides") { + using oneapi::tbb::blocked_nd_range; + std::vector v; using iterator = typename decltype(v)::iterator; - oneapi::tbb::blocked_range br(0, 100); - - oneapi::tbb::blocked_rangeNd r1({v.begin(), v.end()}); - static_assert(std::is_same>::value); - - oneapi::tbb::blocked_rangeNd r2({v.begin(), v.end()}, {v.begin(), v.end()}); - static_assert(std::is_same>::value); - - oneapi::tbb::blocked_rangeNd r3({0, 100}, {0, 100}, {0, 100}, {0, 100}); - static_assert(std::is_same>::value); - - oneapi::tbb::blocked_rangeNd r4(br); - static_assert(std::is_same>::value); + oneapi::tbb::blocked_range dim_range(0, 100); - oneapi::tbb::blocked_rangeNd r5(br, br, br); - static_assert(std::is_same>::value); + blocked_nd_range source_range(dim_range, dim_range); - oneapi::tbb::blocked_rangeNd rc(r1); - static_assert(std::is_same::value); - - oneapi::tbb::blocked_rangeNd rm(std::move(r2)); - static_assert(std::is_same::value); + { + blocked_nd_range range(dim_range, dim_range, dim_range); + static_assert(std::is_same_v>); + } + { + blocked_nd_range range({v.begin(), v.end()}, {v.begin(), v.end()}); + static_assert(std::is_same_v>); + } + { + blocked_nd_range range({0, 100}, {0, 100, 5}, {0, 100}, {0, 100, 5}); + static_assert(std::is_same_v>); + } + { + blocked_nd_range range({100}); + static_assert(std::is_same_v>); + } + { + blocked_nd_range range({100}, 5); + static_assert(std::is_same_v>); + } + { + blocked_nd_range range({100, 200}, 5); + static_assert(std::is_same_v>); + } + { + blocked_nd_range range({100, 200, 300}, 5); + static_assert(std::is_same_v>); + } + { + blocked_nd_range range({100, 200, 300, 400}); + static_assert(std::is_same_v>); + } + { + blocked_nd_range range({100, 200, 300, 400}, 5); + static_assert(std::is_same_v>); + } + { + blocked_nd_range range(source_range, oneapi::tbb::split{}); + static_assert(std::is_same_v); + } + { + blocked_nd_range range(source_range, oneapi::tbb::proportional_split{1, 3}); + static_assert(std::is_same_v); + } + { + blocked_nd_range range(source_range); + static_assert(std::is_same_v); + } + { + blocked_nd_range range(std::move(source_range)); + static_assert(std::is_same_v); + } } #endif // __TBB_CPP17_DEDUCTION_GUIDES_PRESENT