Skip to content

Commit

Permalink
[FEA]: Do not version vocabulary types in thrust
Browse files Browse the repository at this point in the history
We have issues with the internal versioning of thrust types that may end up in a public API.

As we utilize cuda architectures for an internal namespace etc those types turn out to be different between host and device TUs.

Therefore, put types inte a plain unversioned namespace

Addresses NVIDIA#1262
  • Loading branch information
miscco committed Feb 8, 2024
1 parent 5288c38 commit b233ac7
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 25 deletions.
4 changes: 2 additions & 2 deletions thrust/testing/unittest/testframework.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class custom_numeric
}
};

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN

template <>
struct numeric_limits<custom_numeric> : numeric_limits<int> {};
Expand All @@ -245,7 +245,7 @@ class integer_traits<custom_numeric>

} // namespace detail

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END

typedef unittest::type_list<char,
signed char,
Expand Down
4 changes: 2 additions & 2 deletions thrust/thrust/complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <cuda/std/complex>
#include <cuda/std/type_traits>

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN

/*! \addtogroup numerics
* \{
Expand Down Expand Up @@ -604,7 +604,7 @@ template <typename T>
struct is_complex<::std::complex<T>> : public thrust::true_type
{};

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END

/*! \} // complex_numbers
*/
Expand Down
21 changes: 21 additions & 0 deletions thrust/thrust/detail/config/namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,27 @@
} /* end namespace thrust */ \
THRUST_NS_POSTFIX

/**
* \def THRUST_PLAIN_NAMESPACE_BEGIN
* This macro is used to open a `thrust::` namespace block, without the
* inline namespace requested by THRUST_DETAIL_ABI_NS_BEGIN.
* This macro is defined by Thrust and may not be overridden.
*/
#define THRUST_PLAIN_NAMESPACE_BEGIN \
THRUST_NS_PREFIX \
namespace thrust \
{

/**
* \def THRUST_PLAIN_NAMESPACE_END
* This macro is used to close a `thrust::` namespace block, without the
* inline namespace requested by THRUST_DETAIL_ABI_NS_END.
* This macro is defined by Thrust and may not be overridden.
*/
#define THRUST_PLAIN_NAMESPACE_END \
} /* end namespace thrust */ \
THRUST_NS_POSTFIX

// The following is just here to add docs for the thrust namespace:

THRUST_NS_PREFIX
Expand Down
4 changes: 2 additions & 2 deletions thrust/thrust/detail/numeric_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

//#include <stdint.h> // for intmax_t (not provided on MSVS 2005)

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN

namespace detail
{
Expand Down Expand Up @@ -134,4 +134,4 @@ numeric_distance(Number x, Number y)

} // end detail

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END
4 changes: 2 additions & 2 deletions thrust/thrust/detail/vector_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <initializer_list>
#include <vector>

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN

namespace detail
{
Expand Down Expand Up @@ -630,7 +630,7 @@ template<typename T1, typename Alloc1,
bool operator!=(const std::vector<T1,Alloc1>& lhs,
const detail::vector_base<T2,Alloc2>& rhs);

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END

#include <thrust/detail/vector_base.inl>

4 changes: 2 additions & 2 deletions thrust/thrust/detail/vector_base.inl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include <stdexcept>

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN

namespace detail
{
Expand Down Expand Up @@ -1373,5 +1373,5 @@ bool operator!=(const std::vector<T1,Alloc1>& lhs,
return !(lhs == rhs);
}

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END

4 changes: 2 additions & 2 deletions thrust/thrust/device_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <vector>
#include <utility>

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN

/*! \addtogroup containers Containers
* \{
Expand Down Expand Up @@ -516,4 +516,4 @@ template<typename T, typename Alloc>
/*! \} // containres
*/

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END
4 changes: 2 additions & 2 deletions thrust/thrust/host_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <vector>
#include <utility>

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN

/*! \addtogroup container_classes Container Classes
* \addtogroup host_containers Host Containers
Expand Down Expand Up @@ -539,4 +539,4 @@ template<typename T, typename Alloc>
/*! \}
*/

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END
4 changes: 2 additions & 2 deletions thrust/thrust/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include <thrust/detail/config.h>
#include <thrust/detail/type_traits.h>

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN

template <typename T>
struct numeric_limits : std::numeric_limits<T> {};

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END
5 changes: 2 additions & 3 deletions thrust/thrust/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ THRUST_NAMESPACE_BEGIN
: std::is_trivially_copy_constructible<T>{};
#endif
}
THRUST_NAMESPACE_END
#endif

#define THRUST_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
Expand Down Expand Up @@ -171,7 +170,7 @@ THRUST_NAMESPACE_END
#define THRUST_OPTIONAL_CPP11_CONSTEXPR constexpr
#endif

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN

#ifndef THRUST_MONOSTATE_INPLACE_MUTEX
#define THRUST_MONOSTATE_INPLACE_MUTEX
Expand Down Expand Up @@ -2864,7 +2863,7 @@ template <class T> class optional<T &> {
T *m_value;
};

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END

namespace std {
// TODO SFINAE
Expand Down
4 changes: 2 additions & 2 deletions thrust/thrust/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include <cuda/std/utility>

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN

/*! \addtogroup utility
* \{
Expand Down Expand Up @@ -87,4 +87,4 @@ using ::cuda::std::make_pair;
/*! \} // utility
*/

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END
4 changes: 2 additions & 2 deletions thrust/thrust/tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

#include <tuple>

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN


// define null_type for backwards compatability
Expand Down Expand Up @@ -154,7 +154,7 @@ using ::cuda::std::tie;
/*! \} // utility
*/

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END

_LIBCUDACXX_BEGIN_NAMESPACE_STD

Expand Down
4 changes: 2 additions & 2 deletions thrust/thrust/universal_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include __THRUST_DEVICE_SYSTEM_VECTOR_HEADER
#undef __THRUST_DEVICE_SYSTEM_VECTOR_HEADER

THRUST_NAMESPACE_BEGIN
THRUST_PLAIN_NAMESPACE_BEGIN

/*! \addtogroup containers Containers
* \{
Expand All @@ -60,4 +60,4 @@ using thrust::system::__THRUST_DEVICE_SYSTEM_NAMESPACE::universal_vector;
/*! \} // containers
*/

THRUST_NAMESPACE_END
THRUST_PLAIN_NAMESPACE_END

0 comments on commit b233ac7

Please sign in to comment.