Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

partial fix for iterator traits and tags #1685

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions testing/iterator_categories.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <thrust/iterator/detail/iterator_category_with_system_and_traversal.h>
#include <thrust/iterator/iterator_categories.h>
#include <thrust/iterator/iterator_traits.h>

template <class IteratorCategory>
using _category_to_system_t =
typename thrust::detail::iterator_category_to_system<IteratorCategory>::type;

static_assert(std::is_same<thrust::device_system_tag, _category_to_system_t<thrust::output_device_iterator_tag>>::value, "");
static_assert(std::is_same<thrust::device_system_tag, _category_to_system_t<thrust::input_device_iterator_tag>>::value, "");
// static_assert(std::is_same<thrust::device_system_tag, _category_to_system_t<thrust::forward_device_iterator_tag>>::value, ""); // Still broken
// static_assert(std::is_same<thrust::device_system_tag, _category_to_system_t<thrust::bidirectional_device_iterator_tag>>::value, ""); // Still broken
// static_assert(std::is_same<thrust::device_system_tag, _category_to_system_t<thrust::random_access_device_iterator_tag>>::value, ""); // Still broken

static_assert(std::is_same<thrust::host_system_tag, _category_to_system_t<thrust::output_host_iterator_tag>>::value, "");
static_assert(std::is_same<thrust::host_system_tag, _category_to_system_t<thrust::input_host_iterator_tag>>::value, "");
static_assert(std::is_same<thrust::host_system_tag, _category_to_system_t<thrust::forward_host_iterator_tag>>::value, "");
static_assert(std::is_same<thrust::host_system_tag, _category_to_system_t<thrust::bidirectional_host_iterator_tag>>::value, "");
static_assert(std::is_same<thrust::host_system_tag, _category_to_system_t<thrust::random_access_host_iterator_tag>>::value, "");

// static_assert(!std::is_convertible<thrust::input_device_iterator_tag, thrust::input_host_iterator_tag>::value, ""); // Still broken
static_assert(!std::is_convertible<thrust::input_host_iterator_tag, thrust::input_device_iterator_tag>::value, "");
18 changes: 9 additions & 9 deletions thrust/iterator/detail/iterator_category_to_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ template <typename> struct device_iterator_category_to_backend_system;
// we should just specialize this metafunction for iterator_category_with_system_and_traversal
template<typename Category>
struct iterator_category_to_system
// convertible to host iterator?
// convertible to device iterator?
: eval_if<
or_<
is_convertible<Category, thrust::input_host_iterator_tag>,
is_convertible<Category, thrust::output_host_iterator_tag>
is_convertible<Category, thrust::input_device_iterator_tag>,
is_convertible<Category, thrust::output_device_iterator_tag>
>::value,

detail::identity_<thrust::host_system_tag>,
// convertible to device iterator?
detail::identity_<thrust::device_system_tag>,

// convertible to host iterator?
eval_if<
or_<
is_convertible<Category, thrust::input_device_iterator_tag>,
is_convertible<Category, thrust::output_device_iterator_tag>
is_convertible<Category, thrust::input_host_iterator_tag>,
is_convertible<Category, thrust::output_host_iterator_tag>
>::value,

detail::identity_<thrust::device_system_tag>,
detail::identity_<thrust::host_system_tag>,

// unknown system
detail::identity_<void>
Expand Down
16 changes: 8 additions & 8 deletions thrust/iterator/detail/iterator_category_to_traversal.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,23 @@ template <typename Category>

template<typename Category>
struct category_to_traversal
// check for host system
// check for device system
: eval_if<
or_<
is_convertible<Category, thrust::input_host_iterator_tag>,
is_convertible<Category, thrust::output_host_iterator_tag>
is_convertible<Category, thrust::input_device_iterator_tag>,
is_convertible<Category, thrust::output_device_iterator_tag>
>::value,

host_system_category_to_traversal<Category>,
device_system_category_to_traversal<Category>,

// check for device system
// check for host system
eval_if<
or_<
is_convertible<Category, thrust::input_device_iterator_tag>,
is_convertible<Category, thrust::output_device_iterator_tag>
is_convertible<Category, thrust::input_host_iterator_tag>,
is_convertible<Category, thrust::output_host_iterator_tag>
>::value,

device_system_category_to_traversal<Category>,
host_system_category_to_traversal<Category>,

// unknown category
detail::identity_<void>
Expand Down