-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Drop `auto_ptr` * Drop `raw_storage_iterator` * Move `temporary_buffer` into its own file * Move `compressed_pair` into its own file * Move `unique_ptr` into its own file * Move `destruct_n` helper to its own file * Drop `swap_allocator` * Drop `temp_value` * Move `builtin_new_allocator` to its own file * Drop `noexcept_move_assign_container` * Move uninitialized algorithms into their own file * Drop `shared_ptr` * Drop legacy pointer safety features * Cleanup `<memory>` * Fix allocator traits * Fix merge issue * Silence issues with `is_constant_evaluated()` not being used currently * Some MSVC fixes * Fix is_constant_evaluated() in unique ptr tests * Try more fixes * drop HIDE_FROM_ABI * Disable test that ICEs icc * Fix issues around device operator new * Fix exception handling in uninitialized algorithm tests * Fix uninitialized construct
- Loading branch information
Showing
91 changed files
with
9,901 additions
and
4,265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of libcu++, the C++ Standard Library for your entire system, | ||
// under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCUDACXX___ALGORITHM_UNWRAP_RANGE_H | ||
#define _LIBCUDACXX___ALGORITHM_UNWRAP_RANGE_H | ||
|
||
#include <cuda/std/detail/__config> | ||
|
||
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) | ||
# pragma GCC system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) | ||
# pragma clang system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) | ||
# pragma system_header | ||
#endif // no system header | ||
|
||
#include <cuda/std/__algorithm/unwrap_iter.h> | ||
#include <cuda/std/__concepts/constructible.h> | ||
#include <cuda/std/__iterator/concepts.h> | ||
#include <cuda/std/__iterator/next.h> | ||
#include <cuda/std/__utility/declval.h> | ||
#include <cuda/std/__utility/move.h> | ||
#include <cuda/std/__utility/pair.h> | ||
|
||
_LIBCUDACXX_BEGIN_NAMESPACE_STD | ||
|
||
// __unwrap_range and __rewrap_range are used to unwrap ranges which may have different iterator and sentinel types. | ||
// __unwrap_iter and __rewrap_iter don't work for this, because they assume that the iterator and sentinel have | ||
// the same type. __unwrap_range tries to get two iterators and then forward to __unwrap_iter. | ||
|
||
#if _CCCL_STD_VER >= 2020 | ||
template <class _Iter, class _Sent> | ||
struct __unwrap_range_impl | ||
{ | ||
inline _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY static constexpr auto | ||
__unwrap(_Iter __first, _Sent __sent) | ||
requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter> | ||
{ | ||
auto __last = ranges::next(__first, __sent); | ||
return pair{_CUDA_VSTD::__unwrap_iter(_CUDA_VSTD::move(__first)), | ||
_CUDA_VSTD::__unwrap_iter(_CUDA_VSTD::move(__last))}; | ||
} | ||
|
||
inline _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY static constexpr auto | ||
__unwrap(_Iter __first, _Sent __last) | ||
{ | ||
return pair{_CUDA_VSTD::move(__first), _CUDA_VSTD::move(__last)}; | ||
} | ||
|
||
inline _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY static constexpr auto | ||
__rewrap(_Iter __orig_iter, decltype(_CUDA_VSTD::__unwrap_iter(_CUDA_VSTD::move(__orig_iter))) __iter) | ||
requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter> | ||
{ | ||
return _CUDA_VSTD::__rewrap_iter(_CUDA_VSTD::move(__orig_iter), _CUDA_VSTD::move(__iter)); | ||
} | ||
|
||
inline _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY static constexpr auto | ||
__rewrap(const _Iter&, _Iter __iter) | ||
requires(!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) ) | ||
{ | ||
return __iter; | ||
} | ||
}; | ||
|
||
template <class _Iter> | ||
struct __unwrap_range_impl<_Iter, _Iter> | ||
{ | ||
inline _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY static constexpr auto | ||
__unwrap(_Iter __first, _Iter __last) | ||
{ | ||
return pair{_CUDA_VSTD::__unwrap_iter(_CUDA_VSTD::move(__first)), | ||
_CUDA_VSTD::__unwrap_iter(_CUDA_VSTD::move(__last))}; | ||
} | ||
|
||
inline _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY static constexpr auto | ||
__rewrap(_Iter __orig_iter, decltype(_CUDA_VSTD::__unwrap_iter(__orig_iter)) __iter) | ||
{ | ||
return _CUDA_VSTD::__rewrap_iter(_CUDA_VSTD::move(__orig_iter), _CUDA_VSTD::move(__iter)); | ||
} | ||
}; | ||
|
||
template <class _Iter, class _Sent> | ||
inline _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr auto __unwrap_range(_Iter __first, _Sent __last) | ||
{ | ||
return __unwrap_range_impl<_Iter, _Sent>::__unwrap(_CUDA_VSTD::move(__first), _CUDA_VSTD::move(__last)); | ||
} | ||
|
||
template <class _Sent, class _Iter, class _Unwrapped> | ||
inline _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr _Iter | ||
__rewrap_range(_Iter __orig_iter, _Unwrapped __iter) | ||
{ | ||
return __unwrap_range_impl<_Iter, _Sent>::__rewrap(_CUDA_VSTD::move(__orig_iter), _CUDA_VSTD::move(__iter)); | ||
} | ||
#else // ^^^ C++20 ^^^ / vvv C++17 vvv | ||
template <class _Iter, class _Unwrapped = decltype(_CUDA_VSTD::__unwrap_iter(_CUDA_VSTD::declval<_Iter>()))> | ||
inline _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _CCCL_CONSTEXPR_CXX14 pair<_Unwrapped, _Unwrapped> | ||
__unwrap_range(_Iter __first, _Iter __last) | ||
{ | ||
return _CUDA_VSTD::make_pair( | ||
_CUDA_VSTD::__unwrap_iter(_CUDA_VSTD::move(__first)), _CUDA_VSTD::__unwrap_iter(_CUDA_VSTD::move(__last))); | ||
} | ||
|
||
template <class _Iter, class _Unwrapped> | ||
inline _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _CCCL_CONSTEXPR_CXX14 _Iter | ||
__rewrap_range(_Iter __orig_iter, _Unwrapped __iter) | ||
{ | ||
return _CUDA_VSTD::__rewrap_iter(_CUDA_VSTD::move(__orig_iter), _CUDA_VSTD::move(__iter)); | ||
} | ||
#endif // _CCCL_STD_VER <= 2017 | ||
|
||
_LIBCUDACXX_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCUDACXX___ALGORITHM_UNWRAP_RANGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
libcudacxx/include/cuda/std/__memory/builtin_new_allocator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of libcu++, the C++ Standard Library for your entire system, | ||
// under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCUDACXX___MEMORY_BUILTIN_NEW_ALLOCATOR_H | ||
#define _LIBCUDACXX___MEMORY_BUILTIN_NEW_ALLOCATOR_H | ||
|
||
#include <cuda/std/detail/__config> | ||
|
||
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) | ||
# pragma GCC system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) | ||
# pragma clang system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) | ||
# pragma system_header | ||
#endif // no system header | ||
|
||
#include <cuda/std/__memory/unique_ptr.h> | ||
#include <cuda/std/cstddef> | ||
#include <cuda/std/detail/libcxx/include/new> | ||
|
||
_LIBCUDACXX_BEGIN_NAMESPACE_STD | ||
|
||
// __builtin_new_allocator -- A non-templated helper for allocating and | ||
// deallocating memory using __builtin_operator_new and | ||
// __builtin_operator_delete. It should be used in preference to | ||
// `std::allocator<T>` to avoid additional instantiations. | ||
struct __builtin_new_allocator | ||
{ | ||
struct __builtin_new_deleter | ||
{ | ||
typedef void* pointer_type; | ||
|
||
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr explicit __builtin_new_deleter( | ||
size_t __size, size_t __align) noexcept | ||
: __size_(__size) | ||
, __align_(__align) | ||
{} | ||
|
||
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY void operator()(void* __p) const noexcept | ||
{ | ||
_CUDA_VSTD::__libcpp_deallocate(__p, __size_, __align_); | ||
} | ||
|
||
private: | ||
size_t __size_; | ||
size_t __align_; | ||
}; | ||
|
||
typedef unique_ptr<void, __builtin_new_deleter> __holder_t; | ||
|
||
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY static __holder_t __allocate_bytes(size_t __s, size_t __align) | ||
{ | ||
return __holder_t(_CUDA_VSTD::__libcpp_allocate(__s, __align), __builtin_new_deleter(__s, __align)); | ||
} | ||
|
||
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY static void | ||
__deallocate_bytes(void* __p, size_t __s, size_t __align) noexcept | ||
{ | ||
_CUDA_VSTD::__libcpp_deallocate(__p, __s, __align); | ||
} | ||
|
||
template <class _Tp> | ||
_LIBCUDACXX_NODEBUG_TYPE _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY static __holder_t | ||
__allocate_type(size_t __n) | ||
{ | ||
return __allocate_bytes(__n * sizeof(_Tp), _LIBCUDACXX_ALIGNOF(_Tp)); | ||
} | ||
|
||
template <class _Tp> | ||
_LIBCUDACXX_NODEBUG_TYPE _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY static void | ||
__deallocate_type(void* __p, size_t __n) noexcept | ||
{ | ||
__deallocate_bytes(__p, __n * sizeof(_Tp), _LIBCUDACXX_ALIGNOF(_Tp)); | ||
} | ||
}; | ||
|
||
_LIBCUDACXX_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCUDACXX___MEMORY_BUILTIN_NEW_ALLOCATOR_H |
Oops, something went wrong.