From 227a9fb7f3899468468e763c85429730f58e651b Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Mon, 10 Oct 2022 11:13:30 +0200 Subject: [PATCH 1/2] Fix `optional::emplace` Currently we cannot use `optional::value` on device, as that might throw if there is no value stored. However, in `emplace` we know that there must be a value stored, as we have just created it. Consequently, just return `this->_m_value` --- thrust/optional.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thrust/optional.h b/thrust/optional.h index 52008e4f6..5850b6ea0 100644 --- a/thrust/optional.h +++ b/thrust/optional.h @@ -1580,7 +1580,7 @@ class optional : private detail::optional_move_assign_base, *this = nullopt; this->construct(std::forward(args)...); - return value(); + return this->m_value; } /// \group emplace @@ -1594,7 +1594,7 @@ class optional : private detail::optional_move_assign_base, emplace(std::initializer_list il, Args &&... args) { *this = nullopt; this->construct(il, std::forward(args)...); - return value(); + return this->m_value; } /// Swaps this optional with the other. From 8972fa4cf614b2ac062a1df0cac355787974b388 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Mon, 10 Oct 2022 11:19:22 +0200 Subject: [PATCH 2/2] Use `cuda/std/limits` Previously, we would use host `limits`, as it was not available at that time in libcu++. However, libcu++ has gained that support a long time ago so just use that. --- thrust/device_new_allocator.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/thrust/device_new_allocator.h b/thrust/device_new_allocator.h index 645be1c02..c9c6b0e95 100644 --- a/thrust/device_new_allocator.h +++ b/thrust/device_new_allocator.h @@ -25,7 +25,10 @@ #include #include #include -#include + +#include +#include + #include THRUST_NAMESPACE_BEGIN @@ -61,8 +64,8 @@ template /*! \c const reference to allocated element, \c device_reference. */ typedef device_reference const_reference; - /*! Type of allocation size, \c std::size_t. */ - typedef std::size_t size_type; + /*! Type of allocation size, \c ::cuda::std::size_t. */ + typedef ::cuda::std::size_t size_type; /*! Type of allocation difference, \c pointer::difference_type. */ typedef typename pointer::difference_type difference_type; @@ -147,7 +150,7 @@ template __host__ __device__ inline size_type max_size() const { - return std::numeric_limits::max THRUST_PREVENT_MACRO_SUBSTITUTION () / sizeof(T); + return ::cuda::std::numeric_limits::max THRUST_PREVENT_MACRO_SUBSTITUTION () / sizeof(T); } // end max_size() /*! Compares against another \p device_malloc_allocator for equality.