From 38f693213b0b89b6fb80a8365ad7472fc1039807 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Tue, 10 May 2022 15:49:11 -0700 Subject: [PATCH 1/2] partial fix for iterator traits and tags --- testing/regression/CMakeLists.txt | 4 ++++ ...or_category_to_system_returns_wrong_tag.cu | 22 +++++++++++++++++++ .../detail/iterator_category_to_system.h | 20 ++++++++--------- .../detail/iterator_category_to_traversal.h | 16 +++++++------- 4 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 testing/regression/gh_902__iterator_category_to_system_returns_wrong_tag.cu diff --git a/testing/regression/CMakeLists.txt b/testing/regression/CMakeLists.txt index eea8b3a45..6c180839c 100644 --- a/testing/regression/CMakeLists.txt +++ b/testing/regression/CMakeLists.txt @@ -1,3 +1,7 @@ +if ("thrust" IN_LIST THRUST_TARGETS) + thrust_add_test(test_target "regression.gh_902__iterator_category_to_system_returns_wrong_tag" "gh_902__iterator_category_to_system_returns_wrong_tag.cu" "thrust") +endif() + # # Disabled as these test names are too long for CMAKE_OBJECT_PATH_MAX. # We should integrate these with the other unit tests. diff --git a/testing/regression/gh_902__iterator_category_to_system_returns_wrong_tag.cu b/testing/regression/gh_902__iterator_category_to_system_returns_wrong_tag.cu new file mode 100644 index 000000000..7f4ad9f1b --- /dev/null +++ b/testing/regression/gh_902__iterator_category_to_system_returns_wrong_tag.cu @@ -0,0 +1,22 @@ +#include +#include +#include + +template +using _category_to_system_t = + typename thrust::detail::iterator_category_to_system::type; + +static_assert(std::is_same>::value); +static_assert(std::is_same>::value); +// static_assert(std::is_same>::value); +// static_assert(std::is_same>::value); +// static_assert(std::is_same>::value); + +static_assert(std::is_same>::value); +static_assert(std::is_same>::value); +static_assert(std::is_same>::value); +static_assert(std::is_same>::value); +static_assert(std::is_same>::value); + +// static_assert(!std::is_convertible::value); +static_assert(!std::is_convertible::value); diff --git a/thrust/iterator/detail/iterator_category_to_system.h b/thrust/iterator/detail/iterator_category_to_system.h index e6103b539..f8f209396 100644 --- a/thrust/iterator/detail/iterator_category_to_system.h +++ b/thrust/iterator/detail/iterator_category_to_system.h @@ -38,24 +38,24 @@ template struct device_iterator_category_to_backend_system; // we should just specialize this metafunction for iterator_category_with_system_and_traversal template struct iterator_category_to_system - // convertible to host iterator? + // convertible to device iterator? : eval_if< or_< - is_convertible, - is_convertible + is_convertible, + is_convertible >::value, - detail::identity_, - - // convertible to device iterator? + detail::identity_, + + // convertible to host iterator? eval_if< or_< - is_convertible, - is_convertible + is_convertible, + is_convertible >::value, - detail::identity_, - + detail::identity_, + // unknown system detail::identity_ > // if device diff --git a/thrust/iterator/detail/iterator_category_to_traversal.h b/thrust/iterator/detail/iterator_category_to_traversal.h index d8c736c50..e3675163c 100644 --- a/thrust/iterator/detail/iterator_category_to_traversal.h +++ b/thrust/iterator/detail/iterator_category_to_traversal.h @@ -88,23 +88,23 @@ template template struct category_to_traversal - // check for host system + // check for device system : eval_if< or_< - is_convertible, - is_convertible + is_convertible, + is_convertible >::value, - host_system_category_to_traversal, + device_system_category_to_traversal, - // check for device system + // check for host system eval_if< or_< - is_convertible, - is_convertible + is_convertible, + is_convertible >::value, - device_system_category_to_traversal, + host_system_category_to_traversal, // unknown category detail::identity_ From 5e1ef886008f9f0dfaaa627016e4c2ab784767c6 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Fri, 13 May 2022 14:25:41 -0700 Subject: [PATCH 2/2] review feedback --- ...ns_wrong_tag.cu => iterator_categories.cu} | 24 +++++++++---------- testing/regression/CMakeLists.txt | 4 ---- .../detail/iterator_category_to_system.h | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) rename testing/{regression/gh_902__iterator_category_to_system_returns_wrong_tag.cu => iterator_categories.cu} (63%) diff --git a/testing/regression/gh_902__iterator_category_to_system_returns_wrong_tag.cu b/testing/iterator_categories.cu similarity index 63% rename from testing/regression/gh_902__iterator_category_to_system_returns_wrong_tag.cu rename to testing/iterator_categories.cu index 7f4ad9f1b..2d249dba4 100644 --- a/testing/regression/gh_902__iterator_category_to_system_returns_wrong_tag.cu +++ b/testing/iterator_categories.cu @@ -6,17 +6,17 @@ template using _category_to_system_t = typename thrust::detail::iterator_category_to_system::type; -static_assert(std::is_same>::value); -static_assert(std::is_same>::value); -// static_assert(std::is_same>::value); -// static_assert(std::is_same>::value); -// static_assert(std::is_same>::value); +static_assert(std::is_same>::value, ""); +static_assert(std::is_same>::value, ""); +// static_assert(std::is_same>::value, ""); // Still broken +// static_assert(std::is_same>::value, ""); // Still broken +// static_assert(std::is_same>::value, ""); // Still broken -static_assert(std::is_same>::value); -static_assert(std::is_same>::value); -static_assert(std::is_same>::value); -static_assert(std::is_same>::value); -static_assert(std::is_same>::value); +static_assert(std::is_same>::value, ""); +static_assert(std::is_same>::value, ""); +static_assert(std::is_same>::value, ""); +static_assert(std::is_same>::value, ""); +static_assert(std::is_same>::value, ""); -// static_assert(!std::is_convertible::value); -static_assert(!std::is_convertible::value); +// static_assert(!std::is_convertible::value, ""); // Still broken +static_assert(!std::is_convertible::value, ""); diff --git a/testing/regression/CMakeLists.txt b/testing/regression/CMakeLists.txt index 6c180839c..eea8b3a45 100644 --- a/testing/regression/CMakeLists.txt +++ b/testing/regression/CMakeLists.txt @@ -1,7 +1,3 @@ -if ("thrust" IN_LIST THRUST_TARGETS) - thrust_add_test(test_target "regression.gh_902__iterator_category_to_system_returns_wrong_tag" "gh_902__iterator_category_to_system_returns_wrong_tag.cu" "thrust") -endif() - # # Disabled as these test names are too long for CMAKE_OBJECT_PATH_MAX. # We should integrate these with the other unit tests. diff --git a/thrust/iterator/detail/iterator_category_to_system.h b/thrust/iterator/detail/iterator_category_to_system.h index f8f209396..cbb9b4380 100644 --- a/thrust/iterator/detail/iterator_category_to_system.h +++ b/thrust/iterator/detail/iterator_category_to_system.h @@ -55,7 +55,7 @@ template >::value, detail::identity_, - + // unknown system detail::identity_ > // if device