Skip to content

Commit

Permalink
debug iterator difference
Browse files Browse the repository at this point in the history
  • Loading branch information
elstehle committed Jan 12, 2025
1 parent c6430d1 commit f4827ea
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cub/cub/device/device_segmented_sort.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#pragma once

#include <cub/config.cuh>
#include <type_traits>
#include "thrust/iterator/constant_iterator.h"

#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
Expand All @@ -49,6 +50,12 @@
CUB_NAMESPACE_BEGIN


template<typename RefT, typename WrappedItT, typename VanillaItT>
void debug_fail(WrappedItT wrapped, VanillaItT vanilla)
{
static_assert(std::is_same<WrappedItT, void>::value, "Debug...");
}

template <typename Iterator, typename OffsetItT>
class OffsetIteratorT : public THRUST_NS_QUALIFIER::iterator_adaptor<OffsetIteratorT<Iterator, OffsetItT>, Iterator>
{
Expand All @@ -60,16 +67,19 @@ public:
_CCCL_HOST_DEVICE OffsetIteratorT(const Iterator& it, OffsetItT offset_it)
: super_t(it)
, offset_it(offset_it)
, it(it)
{}

// befriend thrust::iterator_core_access to allow it access to the private interface below
friend class THRUST_NS_QUALIFIER::iterator_core_access;

private:
OffsetItT offset_it;
Iterator it;

_CCCL_HOST_DEVICE typename super_t::reference dereference() const
{
debug_fail<typename super_t::reference>(*(this->base() + (*offset_it)), *it);
return *(this->base() + (*offset_it));
}
};
Expand Down

0 comments on commit f4827ea

Please sign in to comment.