-
Notifications
You must be signed in to change notification settings - Fork 758
partial fix for iterator traits and tags #1685
base: main
Are you sure you want to change the base?
Conversation
run tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks safe to me, but there are some style/test issues to clean up before this goes in.
testing/regression/gh_902__iterator_category_to_system_returns_wrong_tag.cu
Outdated
Show resolved
Hide resolved
testing/regression/gh_902__iterator_category_to_system_returns_wrong_tag.cu
Outdated
Show resolved
Hide resolved
@allisonvacanti I see you tagged this with "2.0" milestone, but this is a change that is safe to make in the 1.X series, IMO. |
It would be, but the RC is already out. We only restart the RC process to add fixes for regressions. |
run tests |
I suppose if an iterator had @allisonvacanti, do any iterators use |
Yes -- this tag is used by iterators that aren't backed by actual memory (e.g
This should be fine. The device system is typically faster than the host system, so this is the preferred behavior. If an algorithm takes an |
Is this ready to merge? |
I ... think so? I can rebase, retest and commit if all looks good. |
run tests |
Hm that one is strange:
There is nothing in this PR that could have triggered this |
The symptoms of this problem are described in NVIDIA/cccl#705. Really, there are two problems with the way Thrust's iterator tags are currently defined:
The
*_device_*
iterator tags are erroneously convertible the*_host_*
tags. That's because the*_host_*
tags are simply type aliases for the standard iterator tags, which the*_device_*
tags inherit from.Because of the way the device iterator tags are defined (with
iterator_category_with_system_and_traversal
) there is no relationship between the different device tags. We would expect (and much of the code does) thatthrust::forward_device_iterator_tag
is convertible tothrust::input_device_iterator_tag
, but that is sadly not true.The two traits,
iterator_category_to_system
anditerator_category_to_traversal
, are first checking whether the category is convertible to a host iterator tag. That is trivially true even for the device tags because of (1); as a result, device tags appear to have the "host" system, which is incorrect.This PR offers the simplest, least intrusive, and sadly partial fix to the problem reported in NVIDIA/cccl#705. It changes the two traits so that they first check for convertibility to the device tag. This gets the answer correctly in more cases than currently.
I think I know how to fix this properly, but not without potentially breaking some code, so I'm submitting this PR now as a stop-gap.