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

Commit

Permalink
Deprecate TexRefInputIterator (Replacement: TexObjInputIterator).
Browse files Browse the repository at this point in the history
This class uses deprecated texture management CUDART APIs. The
"Obj"-flavor uses non-deprecated CUDART APIs.
  • Loading branch information
alliepiper committed Jun 9, 2021
1 parent 967db42 commit f919860
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 27 deletions.
4 changes: 2 additions & 2 deletions cub/agent/agent_spmv_orig.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include "../thread/thread_operators.cuh"
#include "../iterator/cache_modified_input_iterator.cuh"
#include "../iterator/counting_input_iterator.cuh"
#include "../iterator/tex_ref_input_iterator.cuh"
#include "../iterator/tex_obj_input_iterator.cuh"

/// Optional outer namespace(s)
CUB_NS_PREFIX
Expand Down Expand Up @@ -109,7 +109,7 @@ struct SpmvParams
ValueT alpha; ///< Alpha multiplicand
ValueT beta; ///< Beta addend-multiplicand

TexRefInputIterator<ValueT, 66778899, OffsetT> t_vector_x;
TexObjInputIterator<ValueT, OffsetT> t_vector_x;
};


Expand Down
2 changes: 1 addition & 1 deletion cub/iterator/tex_obj_input_iterator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace cub {
* - Compatible with Thrust API v1.7 or newer.
*
* \par Snippet
* The code snippet below illustrates the use of \p TexRefInputIterator to
* The code snippet below illustrates the use of \p TexObjInputIterator to
* dereference a device array of doubles through texture cache.
* \par
* \code
Expand Down
69 changes: 46 additions & 23 deletions cub/iterator/tex_ref_input_iterator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@
#include "../util_debug.cuh"
#include "../config.cuh"

// This class needs to go through a deprecation cycle and be removed, as the
// underlying cudaBindTexture / cudaUnbindTexture APIs are deprecated.
// See issue NVIDIA/cub#191.
// Turn off deprecation warnings when compiling this file until then.
#if CUB_HOST_COMPILER == CUB_HOST_COMPILER_MSVC
#pragma warning(disable:4996)
#elif CUB_HOST_COMPILER == CUB_HOST_COMPILER_GCC || \
CUB_HOST_COMPILER == CUB_HOST_COMPILER_CLANG
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

#if (CUDART_VERSION >= 5050) || defined(DOXYGEN_ACTIVE) // This iterator is compatible with CUDA 5.5 and newer

#if (THRUST_VERSION >= 100700) // This iterator is compatible with Thrust API 1.7 and newer
Expand All @@ -79,8 +67,21 @@ namespace {

/// Global texture reference specialized by type
template <typename T>
struct IteratorTexRef
struct CUB_DEPRECATED IteratorTexRef
{

// This class uses the deprecated cudaBindTexture / cudaUnbindTexture APIs.
// See issue NVIDIA/cub#191.
// Turn off deprecation warnings when compiling class implementation in favor
// of deprecating TexRefInputIterator instead.
#if CUB_HOST_COMPILER == CUB_HOST_COMPILER_MSVC
#pragma warning(disable:4996)
#elif CUB_HOST_COMPILER == CUB_HOST_COMPILER_GCC || \
CUB_HOST_COMPILER == CUB_HOST_COMPILER_CLANG
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

/// And by unique ID
template <int UNIQUE_ID>
struct TexId
Expand Down Expand Up @@ -143,6 +144,13 @@ template <typename T>
template <int UNIQUE_ID>
typename IteratorTexRef<T>::template TexId<UNIQUE_ID>::TexRef IteratorTexRef<T>::template TexId<UNIQUE_ID>::ref = 0;

// Re-enable deprecation warnings:
#if CUB_HOST_COMPILER == CUB_HOST_COMPILER_MSVC
#pragma warning(default:4996)
#elif CUB_HOST_COMPILER == CUB_HOST_COMPILER_GCC || \
CUB_HOST_COMPILER == CUB_HOST_COMPILER_CLANG
#pragma GCC diagnostic pop
#endif

} // Anonymous namespace

Expand All @@ -161,6 +169,9 @@ typename IteratorTexRef<T>::template TexId<UNIQUE_ID>::TexRef IteratorTexRef<T>:
/**
* \brief A random-access input wrapper for dereferencing array values through texture cache. Uses older Tesla/Fermi-style texture references.
*
* \deprecated [Since 1.13.0] The CUDA texture management APIs used by
* TexRefInputIterator are deprecated. Use cub::TexObjInputIterator instead.
*
* \par Overview
* - TexRefInputIterator wraps a native device pointer of type <tt>ValueType*</tt>. References
* to elements are to be loaded through texture cache.
Expand All @@ -176,7 +187,6 @@ typename IteratorTexRef<T>::template TexId<UNIQUE_ID>::TexRef IteratorTexRef<T>:
* created by the host thread and used by a top-level kernel (i.e. the one which is launched
* from the host).
* - Compatible with Thrust API v1.7 or newer.
* - Compatible with CUDA toolkit v5.5 or newer.
*
* \par Snippet
* The code snippet below illustrates the use of \p TexRefInputIterator to
Expand Down Expand Up @@ -212,8 +222,21 @@ template <
typename T,
int UNIQUE_ID,
typename OffsetT = ptrdiff_t>
class TexRefInputIterator
class CUB_DEPRECATED TexRefInputIterator
{

// This class uses the deprecated cudaBindTexture / cudaUnbindTexture APIs.
// See issue NVIDIA/cub#191.
// Turn off deprecation warnings when compiling class implementation in favor
// of deprecating TexRefInputIterator instead.
#if CUB_HOST_COMPILER == CUB_HOST_COMPILER_MSVC
#pragma warning(disable:4996)
#elif CUB_HOST_COMPILER == CUB_HOST_COMPILER_GCC || \
CUB_HOST_COMPILER == CUB_HOST_COMPILER_CLANG
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

public:

// Required iterator traits
Expand Down Expand Up @@ -379,6 +402,14 @@ public:
return os;
}

// Re-enable deprecation warnings:
#if CUB_HOST_COMPILER == CUB_HOST_COMPILER_MSVC
#pragma warning(default:4996)
#elif CUB_HOST_COMPILER == CUB_HOST_COMPILER_GCC || \
CUB_HOST_COMPILER == CUB_HOST_COMPILER_CLANG
#pragma GCC diagnostic pop
#endif

};


Expand All @@ -389,11 +420,3 @@ public:
CUB_NS_POSTFIX // Optional outer namespace(s)

#endif // CUDART_VERSION

// Re-enable deprecation warnings:
#if CUB_HOST_COMPILER == CUB_HOST_COMPILER_MSVC
#pragma warning(default:4996)
#elif CUB_HOST_COMPILER == CUB_HOST_COMPILER_GCC || \
CUB_HOST_COMPILER == CUB_HOST_COMPILER_CLANG
#pragma GCC diagnostic pop
#endif
2 changes: 1 addition & 1 deletion test/test_iterator.cu
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ void TestTexTransform()
h_reference[7] = op(h_data[0]); // Value at offset 0;

// Create and bind texture iterator
typedef TexRefInputIterator<T, __LINE__> TextureIterator;
typedef TexObjInputIterator<T> TextureIterator;

TextureIterator d_tex_itr;
CubDebugExit(d_tex_itr.BindTexture((CastT*) d_data, sizeof(T) * TEST_VALUES));
Expand Down

0 comments on commit f919860

Please sign in to comment.