Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- vllm/lib/libcrypto.a +3 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/algorithm_wrapper.h +37 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/allocator_traits.h +350 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/allocator_traits.inl +370 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/copy_construct_range.h +45 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/copy_construct_range.inl +242 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/destroy_range.h +39 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/destroy_range.inl +137 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/fill_construct_range.h +39 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/fill_construct_range.inl +99 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/malloc_allocator.h +53 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/malloc_allocator.inl +68 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/no_throw_allocator.h +76 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/tagged_allocator.h +102 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/tagged_allocator.inl +86 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/temporary_allocator.h +79 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/temporary_allocator.inl +81 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/value_initialize_range.h +39 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/value_initialize_range.inl +98 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/catrig.h +875 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/cexp.h +195 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/cexpf.h +173 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/clogf.h +210 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/csinh.h +226 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/csinhf.h +166 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/ctanh.h +208 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/ctanhf.h +133 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config.h +31 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/compiler.h +119 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/compiler_fence.h +79 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/config.h +45 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/cpp_compatibility.h +61 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/cpp_dialect.h +100 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/device_system.h +55 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/global_workarounds.h +36 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/host_system.h +52 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/memory_resource.h +44 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/namespace.h +162 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/simple_defines.h +43 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/copy.h +72 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/copy.inl +123 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/copy_if.h +62 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/copy_if.inl +98 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/count.h +56 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/dependencies_aware_execution_policy.h +85 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/device_malloc.inl +60 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/distance.inl +43 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/execute_with_allocator.h +122 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/extrema.inl +172 -0
.gitattributes
CHANGED
|
@@ -1769,3 +1769,4 @@ vllm/lib/python3.10/site-packages/cupy/_core/flags.cpython-310-x86_64-linux-gnu.
|
|
| 1769 |
vllm/lib/python3.10/site-packages/cupy/_core/_accelerator.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1770 |
vllm/lib/python3.10/site-packages/cupy/_core/_fusion_kernel.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1771 |
vllm/lib/libcrypto.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 1769 |
vllm/lib/python3.10/site-packages/cupy/_core/_accelerator.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1770 |
vllm/lib/python3.10/site-packages/cupy/_core/_fusion_kernel.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1771 |
vllm/lib/libcrypto.so filter=lfs diff=lfs merge=lfs -text
|
| 1772 |
+
vllm/lib/libcrypto.a filter=lfs diff=lfs merge=lfs -text
|
vllm/lib/libcrypto.a
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6a24a0e923980a3ecf86ea44854f64a05ff75ed5b1e4ee1ebbbb8a043073a1b1
|
| 3 |
+
size 11086938
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/algorithm_wrapper.h
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2020 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// When a compiler uses Thrust as part of its implementation of Standard C++
|
| 30 |
+
// algorithms, a cycle of included files may result when Thrust code tries to
|
| 31 |
+
// use a standard algorithm. Having a macro that is defined only when Thrust
|
| 32 |
+
// is including an algorithms-related header gives the compiler a chance to
|
| 33 |
+
// detect and break the cycle of includes.
|
| 34 |
+
|
| 35 |
+
#define THRUST_INCLUDING_ALGORITHMS_HEADER
|
| 36 |
+
#include <algorithm>
|
| 37 |
+
#undef THRUST_INCLUDING_ALGORITHMS_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/allocator_traits.h
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2018 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
// allocator_traits::rebind_alloc and allocator::rebind_traits are from libc++,
|
| 18 |
+
// dual licensed under the MIT and the University of Illinois Open Source
|
| 19 |
+
// Licenses.
|
| 20 |
+
|
| 21 |
+
#pragma once
|
| 22 |
+
|
| 23 |
+
#include <thrust/detail/config.h>
|
| 24 |
+
|
| 25 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 26 |
+
# pragma GCC system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 28 |
+
# pragma clang system_header
|
| 29 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 30 |
+
# pragma system_header
|
| 31 |
+
#endif // no system header
|
| 32 |
+
|
| 33 |
+
#include <thrust/detail/memory_wrapper.h>
|
| 34 |
+
#include <thrust/detail/type_traits.h>
|
| 35 |
+
#include <thrust/detail/type_traits/has_member_function.h>
|
| 36 |
+
#include <thrust/detail/type_traits/has_nested_type.h>
|
| 37 |
+
#include <thrust/detail/type_traits/pointer_traits.h>
|
| 38 |
+
|
| 39 |
+
THRUST_NAMESPACE_BEGIN
|
| 40 |
+
namespace detail
|
| 41 |
+
{
|
| 42 |
+
|
| 43 |
+
// forward declaration for has_member_system
|
| 44 |
+
template <typename Alloc>
|
| 45 |
+
struct allocator_system;
|
| 46 |
+
|
| 47 |
+
namespace allocator_traits_detail
|
| 48 |
+
{
|
| 49 |
+
|
| 50 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_value_type, value_type)
|
| 51 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_pointer, pointer)
|
| 52 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_const_pointer, const_pointer)
|
| 53 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_reference, reference)
|
| 54 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_const_reference, const_reference)
|
| 55 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_void_pointer, void_pointer)
|
| 56 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_const_void_pointer, const_void_pointer)
|
| 57 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_difference_type, difference_type)
|
| 58 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_size_type, size_type)
|
| 59 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_propagate_on_container_copy_assignment, propagate_on_container_copy_assignment)
|
| 60 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_propagate_on_container_move_assignment, propagate_on_container_move_assignment)
|
| 61 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_propagate_on_container_swap, propagate_on_container_swap)
|
| 62 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_system_type, system_type)
|
| 63 |
+
__THRUST_DEFINE_HAS_NESTED_TYPE(has_is_always_equal, is_always_equal)
|
| 64 |
+
__THRUST_DEFINE_HAS_MEMBER_FUNCTION(has_member_system_impl, system)
|
| 65 |
+
|
| 66 |
+
template <typename Alloc, typename U>
|
| 67 |
+
struct has_rebind
|
| 68 |
+
{
|
| 69 |
+
using yes_type = char;
|
| 70 |
+
using no_type = int;
|
| 71 |
+
|
| 72 |
+
template <typename S>
|
| 73 |
+
static yes_type test(typename S::template rebind<U>::other*);
|
| 74 |
+
template <typename S>
|
| 75 |
+
static no_type test(...);
|
| 76 |
+
|
| 77 |
+
static bool const value = sizeof(test<U>(0)) == sizeof(yes_type);
|
| 78 |
+
|
| 79 |
+
using type = thrust::detail::integral_constant<bool, value>;
|
| 80 |
+
};
|
| 81 |
+
|
| 82 |
+
_CCCL_SUPPRESS_DEPRECATED_PUSH
|
| 83 |
+
|
| 84 |
+
// The following fields of std::allocator have been deprecated (since C++17).
|
| 85 |
+
// There's no way to detect it other than explicit specialization.
|
| 86 |
+
#if _CCCL_STD_VER >= 2017
|
| 87 |
+
# define THRUST_SPECIALIZE_DEPRECATED(trait_name) \
|
| 88 |
+
template <typename T> \
|
| 89 |
+
struct trait_name<std::allocator<T>> : false_type \
|
| 90 |
+
{};
|
| 91 |
+
|
| 92 |
+
THRUST_SPECIALIZE_DEPRECATED(has_is_always_equal)
|
| 93 |
+
THRUST_SPECIALIZE_DEPRECATED(has_pointer)
|
| 94 |
+
THRUST_SPECIALIZE_DEPRECATED(has_const_pointer)
|
| 95 |
+
THRUST_SPECIALIZE_DEPRECATED(has_reference)
|
| 96 |
+
THRUST_SPECIALIZE_DEPRECATED(has_const_reference)
|
| 97 |
+
|
| 98 |
+
# undef THRUST_SPECIALIZE_DEPRECATED
|
| 99 |
+
|
| 100 |
+
template <typename T, typename U>
|
| 101 |
+
struct has_rebind<std::allocator<T>, U> : false_type
|
| 102 |
+
{};
|
| 103 |
+
#endif
|
| 104 |
+
|
| 105 |
+
template <typename T>
|
| 106 |
+
struct nested_pointer
|
| 107 |
+
{
|
| 108 |
+
using type = typename T::pointer;
|
| 109 |
+
};
|
| 110 |
+
|
| 111 |
+
template <typename T>
|
| 112 |
+
struct nested_const_pointer
|
| 113 |
+
{
|
| 114 |
+
using type = typename T::const_pointer;
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
+
template <typename T>
|
| 118 |
+
struct nested_reference
|
| 119 |
+
{
|
| 120 |
+
using type = typename T::reference;
|
| 121 |
+
};
|
| 122 |
+
|
| 123 |
+
template <typename T>
|
| 124 |
+
struct nested_const_reference
|
| 125 |
+
{
|
| 126 |
+
using type = typename T::const_reference;
|
| 127 |
+
};
|
| 128 |
+
|
| 129 |
+
template <typename T>
|
| 130 |
+
struct nested_void_pointer
|
| 131 |
+
{
|
| 132 |
+
using type = typename T::void_pointer;
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
template <typename T>
|
| 136 |
+
struct nested_const_void_pointer
|
| 137 |
+
{
|
| 138 |
+
using type = typename T::const_void_pointer;
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
template <typename T>
|
| 142 |
+
struct nested_difference_type
|
| 143 |
+
{
|
| 144 |
+
using type = typename T::difference_type;
|
| 145 |
+
};
|
| 146 |
+
|
| 147 |
+
template <typename T>
|
| 148 |
+
struct nested_size_type
|
| 149 |
+
{
|
| 150 |
+
using type = typename T::size_type;
|
| 151 |
+
};
|
| 152 |
+
|
| 153 |
+
template <typename T>
|
| 154 |
+
struct nested_propagate_on_container_copy_assignment
|
| 155 |
+
{
|
| 156 |
+
using type = typename T::propagate_on_container_copy_assignment;
|
| 157 |
+
};
|
| 158 |
+
|
| 159 |
+
template <typename T>
|
| 160 |
+
struct nested_propagate_on_container_move_assignment
|
| 161 |
+
{
|
| 162 |
+
using type = typename T::propagate_on_container_move_assignment;
|
| 163 |
+
};
|
| 164 |
+
|
| 165 |
+
template <typename T>
|
| 166 |
+
struct nested_propagate_on_container_swap
|
| 167 |
+
{
|
| 168 |
+
using type = typename T::propagate_on_container_swap;
|
| 169 |
+
};
|
| 170 |
+
|
| 171 |
+
template <typename T>
|
| 172 |
+
struct nested_is_always_equal
|
| 173 |
+
{
|
| 174 |
+
using type = typename T::is_always_equal;
|
| 175 |
+
};
|
| 176 |
+
|
| 177 |
+
template <typename T>
|
| 178 |
+
struct nested_system_type
|
| 179 |
+
{
|
| 180 |
+
using type = typename T::system_type;
|
| 181 |
+
};
|
| 182 |
+
|
| 183 |
+
template <typename Alloc>
|
| 184 |
+
struct has_member_system
|
| 185 |
+
{
|
| 186 |
+
using system_type = typename allocator_system<Alloc>::type;
|
| 187 |
+
|
| 188 |
+
using type = typename has_member_system_impl<Alloc, system_type&()>::type;
|
| 189 |
+
static const bool value = type::value;
|
| 190 |
+
};
|
| 191 |
+
|
| 192 |
+
_CCCL_SUPPRESS_DEPRECATED_POP
|
| 193 |
+
|
| 194 |
+
template <class Alloc, class U, bool = has_rebind<Alloc, U>::value>
|
| 195 |
+
struct rebind_alloc
|
| 196 |
+
{
|
| 197 |
+
using type = typename Alloc::template rebind<U>::other;
|
| 198 |
+
};
|
| 199 |
+
|
| 200 |
+
template <template <typename, typename...> class Alloc, typename T, typename... Args, typename U>
|
| 201 |
+
struct rebind_alloc<Alloc<T, Args...>, U, true>
|
| 202 |
+
{
|
| 203 |
+
using type = typename Alloc<T, Args...>::template rebind<U>::other;
|
| 204 |
+
};
|
| 205 |
+
|
| 206 |
+
template <template <typename, typename...> class Alloc, typename T, typename... Args, typename U>
|
| 207 |
+
struct rebind_alloc<Alloc<T, Args...>, U, false>
|
| 208 |
+
{
|
| 209 |
+
using type = Alloc<U, Args...>;
|
| 210 |
+
};
|
| 211 |
+
|
| 212 |
+
} // namespace allocator_traits_detail
|
| 213 |
+
|
| 214 |
+
template <typename Alloc>
|
| 215 |
+
struct allocator_traits
|
| 216 |
+
{
|
| 217 |
+
using allocator_type = Alloc;
|
| 218 |
+
|
| 219 |
+
using value_type = typename allocator_type::value_type;
|
| 220 |
+
|
| 221 |
+
using pointer = typename eval_if<allocator_traits_detail::has_pointer<allocator_type>::value,
|
| 222 |
+
allocator_traits_detail::nested_pointer<allocator_type>,
|
| 223 |
+
identity_<value_type*>>::type;
|
| 224 |
+
|
| 225 |
+
private:
|
| 226 |
+
template <typename T>
|
| 227 |
+
struct rebind_pointer
|
| 228 |
+
{
|
| 229 |
+
using type = typename pointer_traits<pointer>::template rebind<T>::other;
|
| 230 |
+
};
|
| 231 |
+
|
| 232 |
+
public:
|
| 233 |
+
using const_pointer =
|
| 234 |
+
typename eval_if<allocator_traits_detail::has_const_pointer<allocator_type>::value,
|
| 235 |
+
allocator_traits_detail::nested_const_pointer<allocator_type>,
|
| 236 |
+
rebind_pointer<const value_type>>::type;
|
| 237 |
+
|
| 238 |
+
using void_pointer =
|
| 239 |
+
typename eval_if<allocator_traits_detail::has_void_pointer<allocator_type>::value,
|
| 240 |
+
allocator_traits_detail::nested_void_pointer<allocator_type>,
|
| 241 |
+
rebind_pointer<void>>::type;
|
| 242 |
+
|
| 243 |
+
using const_void_pointer =
|
| 244 |
+
typename eval_if<allocator_traits_detail::has_const_void_pointer<allocator_type>::value,
|
| 245 |
+
allocator_traits_detail::nested_const_void_pointer<allocator_type>,
|
| 246 |
+
rebind_pointer<const void>>::type;
|
| 247 |
+
|
| 248 |
+
using difference_type =
|
| 249 |
+
typename eval_if<allocator_traits_detail::has_difference_type<allocator_type>::value,
|
| 250 |
+
allocator_traits_detail::nested_difference_type<allocator_type>,
|
| 251 |
+
pointer_difference<pointer>>::type;
|
| 252 |
+
|
| 253 |
+
using size_type = typename eval_if<allocator_traits_detail::has_size_type<allocator_type>::value,
|
| 254 |
+
allocator_traits_detail::nested_size_type<allocator_type>,
|
| 255 |
+
::cuda::std::make_unsigned<difference_type>>::type;
|
| 256 |
+
|
| 257 |
+
using propagate_on_container_copy_assignment =
|
| 258 |
+
typename eval_if<allocator_traits_detail::has_propagate_on_container_copy_assignment<allocator_type>::value,
|
| 259 |
+
allocator_traits_detail::nested_propagate_on_container_copy_assignment<allocator_type>,
|
| 260 |
+
identity_<false_type>>::type;
|
| 261 |
+
|
| 262 |
+
using propagate_on_container_move_assignment =
|
| 263 |
+
typename eval_if<allocator_traits_detail::has_propagate_on_container_move_assignment<allocator_type>::value,
|
| 264 |
+
allocator_traits_detail::nested_propagate_on_container_move_assignment<allocator_type>,
|
| 265 |
+
identity_<false_type>>::type;
|
| 266 |
+
|
| 267 |
+
using propagate_on_container_swap =
|
| 268 |
+
typename eval_if<allocator_traits_detail::has_propagate_on_container_swap<allocator_type>::value,
|
| 269 |
+
allocator_traits_detail::nested_propagate_on_container_swap<allocator_type>,
|
| 270 |
+
identity_<false_type>>::type;
|
| 271 |
+
|
| 272 |
+
using is_always_equal =
|
| 273 |
+
typename eval_if<allocator_traits_detail::has_is_always_equal<allocator_type>::value,
|
| 274 |
+
allocator_traits_detail::nested_is_always_equal<allocator_type>,
|
| 275 |
+
::cuda::std::is_empty<allocator_type>>::type;
|
| 276 |
+
|
| 277 |
+
using system_type =
|
| 278 |
+
typename eval_if<allocator_traits_detail::has_system_type<allocator_type>::value,
|
| 279 |
+
allocator_traits_detail::nested_system_type<allocator_type>,
|
| 280 |
+
thrust::iterator_system<pointer>>::type;
|
| 281 |
+
|
| 282 |
+
// XXX rebind and rebind_traits are alias templates
|
| 283 |
+
// and so are omitted while c++11 is unavailable
|
| 284 |
+
|
| 285 |
+
template <typename U>
|
| 286 |
+
using rebind_alloc = typename allocator_traits_detail::rebind_alloc<allocator_type, U>::type;
|
| 287 |
+
|
| 288 |
+
template <typename U>
|
| 289 |
+
using rebind_traits = allocator_traits<rebind_alloc<U>>;
|
| 290 |
+
|
| 291 |
+
// We define this nested type alias for compatibility with the C++03-style
|
| 292 |
+
// rebind_* mechanisms.
|
| 293 |
+
using other = allocator_traits;
|
| 294 |
+
|
| 295 |
+
// Deprecated std::allocator aliases that we need:
|
| 296 |
+
using reference = typename thrust::detail::pointer_traits<pointer>::reference;
|
| 297 |
+
using const_reference = typename thrust::detail::pointer_traits<const_pointer>::reference;
|
| 298 |
+
|
| 299 |
+
inline _CCCL_HOST_DEVICE static pointer allocate(allocator_type& a, size_type n);
|
| 300 |
+
|
| 301 |
+
inline _CCCL_HOST_DEVICE static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint);
|
| 302 |
+
|
| 303 |
+
inline _CCCL_HOST_DEVICE static void deallocate(allocator_type& a, pointer p, size_type n) noexcept;
|
| 304 |
+
|
| 305 |
+
// XXX should probably change T* to pointer below and then relax later
|
| 306 |
+
|
| 307 |
+
template <typename T>
|
| 308 |
+
inline _CCCL_HOST_DEVICE static void construct(allocator_type& a, T* p);
|
| 309 |
+
|
| 310 |
+
template <typename T, typename Arg1>
|
| 311 |
+
inline _CCCL_HOST_DEVICE static void construct(allocator_type& a, T* p, const Arg1& arg1);
|
| 312 |
+
|
| 313 |
+
template <typename T, typename... Args>
|
| 314 |
+
inline _CCCL_HOST_DEVICE static void construct(allocator_type& a, T* p, Args&&... args);
|
| 315 |
+
|
| 316 |
+
template <typename T>
|
| 317 |
+
inline _CCCL_HOST_DEVICE static void destroy(allocator_type& a, T* p) noexcept;
|
| 318 |
+
|
| 319 |
+
inline _CCCL_HOST_DEVICE static size_type max_size(const allocator_type& a);
|
| 320 |
+
}; // end allocator_traits
|
| 321 |
+
|
| 322 |
+
// we consider a type an allocator if T::value_type exists
|
| 323 |
+
// it doesn't make much sense (containers, which are not allocators, will fulfill this requirement),
|
| 324 |
+
// but allocator_traits is specified to work for any type with that nested alias
|
| 325 |
+
template <typename T>
|
| 326 |
+
struct is_allocator : allocator_traits_detail::has_value_type<T>
|
| 327 |
+
{};
|
| 328 |
+
|
| 329 |
+
// XXX consider moving this non-standard functionality inside allocator_traits
|
| 330 |
+
template <typename Alloc>
|
| 331 |
+
struct allocator_system
|
| 332 |
+
{
|
| 333 |
+
// the type of the allocator's system
|
| 334 |
+
using type = typename eval_if<allocator_traits_detail::has_system_type<Alloc>::value,
|
| 335 |
+
allocator_traits_detail::nested_system_type<Alloc>,
|
| 336 |
+
thrust::iterator_system<typename allocator_traits<Alloc>::pointer>>::type;
|
| 337 |
+
|
| 338 |
+
// the type that get returns
|
| 339 |
+
using get_result_type =
|
| 340 |
+
typename eval_if<allocator_traits_detail::has_member_system<Alloc>::value,
|
| 341 |
+
::cuda::std::add_lvalue_reference<type>,
|
| 342 |
+
identity_<type>>::type;
|
| 343 |
+
|
| 344 |
+
_CCCL_HOST_DEVICE inline static get_result_type get(Alloc& a);
|
| 345 |
+
};
|
| 346 |
+
|
| 347 |
+
} // namespace detail
|
| 348 |
+
THRUST_NAMESPACE_END
|
| 349 |
+
|
| 350 |
+
#include <thrust/detail/allocator/allocator_traits.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/allocator_traits.inl
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2018 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/allocator/allocator_traits.h>
|
| 29 |
+
#include <thrust/detail/integer_traits.h>
|
| 30 |
+
#include <thrust/detail/memory_wrapper.h>
|
| 31 |
+
#include <thrust/detail/type_deduction.h>
|
| 32 |
+
#include <thrust/detail/type_traits/is_call_possible.h>
|
| 33 |
+
|
| 34 |
+
#include <new>
|
| 35 |
+
|
| 36 |
+
THRUST_NAMESPACE_BEGIN
|
| 37 |
+
namespace detail
|
| 38 |
+
{
|
| 39 |
+
|
| 40 |
+
// std::allocator's member functions are deprecated in C++17 and removed in
|
| 41 |
+
// C++20, so we can't just use the generic implementation for allocator_traits
|
| 42 |
+
// that calls the allocator's member functions.
|
| 43 |
+
// Instead, specialize allocator_traits for std::allocator and defer to
|
| 44 |
+
// std::allocator_traits<std::allocator> and let the STL do whatever it needs
|
| 45 |
+
// to for the current c++ version. Manually forward the calls to suppress
|
| 46 |
+
// host/device warnings.
|
| 47 |
+
template <typename T>
|
| 48 |
+
struct allocator_traits<std::allocator<T>> : public std::allocator_traits<std::allocator<T>>
|
| 49 |
+
{
|
| 50 |
+
private:
|
| 51 |
+
using superclass = std::allocator_traits<std::allocator<T>>;
|
| 52 |
+
|
| 53 |
+
public:
|
| 54 |
+
using allocator_type = typename superclass::allocator_type;
|
| 55 |
+
using value_type = typename superclass::value_type;
|
| 56 |
+
using pointer = typename superclass::pointer;
|
| 57 |
+
using const_pointer = typename superclass::const_pointer;
|
| 58 |
+
using void_pointer = typename superclass::void_pointer;
|
| 59 |
+
using const_void_pointer = typename superclass::const_void_pointer;
|
| 60 |
+
using difference_type = typename superclass::difference_type;
|
| 61 |
+
using size_type = typename superclass::size_type;
|
| 62 |
+
using propagate_on_container_swap = typename superclass::propagate_on_container_swap;
|
| 63 |
+
using propagate_on_container_copy_assignment = typename superclass::propagate_on_container_copy_assignment;
|
| 64 |
+
using propagate_on_container_move_assignment = typename superclass::propagate_on_container_move_assignment;
|
| 65 |
+
|
| 66 |
+
// std::allocator_traits added this in C++17, but thrust::allocator_traits defines
|
| 67 |
+
// it unconditionally.
|
| 68 |
+
using is_always_equal =
|
| 69 |
+
typename eval_if<allocator_traits_detail::has_is_always_equal<allocator_type>::value,
|
| 70 |
+
allocator_traits_detail::nested_is_always_equal<allocator_type>,
|
| 71 |
+
::cuda::std::is_empty<allocator_type>>::type;
|
| 72 |
+
|
| 73 |
+
// std::allocator_traits doesn't provide these, but
|
| 74 |
+
// thrust::detail::allocator_traits does. These used to be part of the
|
| 75 |
+
// std::allocator API but were deprecated in C++17.
|
| 76 |
+
using reference = typename thrust::detail::pointer_traits<pointer>::reference;
|
| 77 |
+
using const_reference = typename thrust::detail::pointer_traits<const_pointer>::reference;
|
| 78 |
+
|
| 79 |
+
template <typename U>
|
| 80 |
+
using rebind_alloc = std::allocator<U>;
|
| 81 |
+
template <typename U>
|
| 82 |
+
using rebind_traits = allocator_traits<std::allocator<U>>;
|
| 83 |
+
|
| 84 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 85 |
+
_CCCL_HOST_DEVICE static pointer allocate(allocator_type& a, size_type n)
|
| 86 |
+
{
|
| 87 |
+
return superclass::allocate(a, n);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 91 |
+
_CCCL_HOST_DEVICE static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint)
|
| 92 |
+
{
|
| 93 |
+
return superclass::allocate(a, n, hint);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 97 |
+
_CCCL_HOST_DEVICE static void deallocate(allocator_type& a, pointer p, size_type n) noexcept
|
| 98 |
+
{
|
| 99 |
+
superclass::deallocate(a, p, n);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 103 |
+
template <typename U, typename... Args>
|
| 104 |
+
_CCCL_HOST_DEVICE static void construct(allocator_type& a, U* p, Args&&... args)
|
| 105 |
+
{
|
| 106 |
+
superclass::construct(a, p, THRUST_FWD(args)...);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 110 |
+
template <typename U>
|
| 111 |
+
_CCCL_HOST_DEVICE static void destroy(allocator_type& a, U* p) noexcept
|
| 112 |
+
{
|
| 113 |
+
superclass::destroy(a, p);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 117 |
+
_CCCL_HOST_DEVICE static size_type max_size(const allocator_type& a)
|
| 118 |
+
{
|
| 119 |
+
return superclass::max_size(a);
|
| 120 |
+
}
|
| 121 |
+
};
|
| 122 |
+
|
| 123 |
+
namespace allocator_traits_detail
|
| 124 |
+
{
|
| 125 |
+
|
| 126 |
+
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_allocate_with_hint_impl, allocate)
|
| 127 |
+
|
| 128 |
+
template <typename Alloc>
|
| 129 |
+
class has_member_allocate_with_hint
|
| 130 |
+
{
|
| 131 |
+
using pointer = typename allocator_traits<Alloc>::pointer;
|
| 132 |
+
using size_type = typename allocator_traits<Alloc>::size_type;
|
| 133 |
+
using const_void_pointer = typename allocator_traits<Alloc>::const_void_pointer;
|
| 134 |
+
|
| 135 |
+
public:
|
| 136 |
+
using type = typename has_member_allocate_with_hint_impl<Alloc, pointer(size_type, const_void_pointer)>::type;
|
| 137 |
+
static const bool value = type::value;
|
| 138 |
+
};
|
| 139 |
+
|
| 140 |
+
template <typename Alloc>
|
| 141 |
+
_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_allocate_with_hint<Alloc>::value,
|
| 142 |
+
typename allocator_traits<Alloc>::pointer>
|
| 143 |
+
allocate(Alloc& a,
|
| 144 |
+
typename allocator_traits<Alloc>::size_type n,
|
| 145 |
+
typename allocator_traits<Alloc>::const_void_pointer hint)
|
| 146 |
+
{
|
| 147 |
+
return a.allocate(n, hint);
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
template <typename Alloc>
|
| 151 |
+
_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_allocate_with_hint<Alloc>::value,
|
| 152 |
+
typename allocator_traits<Alloc>::pointer>
|
| 153 |
+
allocate(Alloc& a, typename allocator_traits<Alloc>::size_type n, typename allocator_traits<Alloc>::const_void_pointer)
|
| 154 |
+
{
|
| 155 |
+
return a.allocate(n);
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_construct1_impl, construct)
|
| 159 |
+
|
| 160 |
+
template <typename Alloc, typename T>
|
| 161 |
+
struct has_member_construct1 : has_member_construct1_impl<Alloc, void(T*)>
|
| 162 |
+
{};
|
| 163 |
+
|
| 164 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 165 |
+
template <typename Alloc, typename T>
|
| 166 |
+
inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_construct1<Alloc, T>::value> construct(Alloc& a, T* p)
|
| 167 |
+
{
|
| 168 |
+
a.construct(p);
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 172 |
+
template <typename Alloc, typename T>
|
| 173 |
+
inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_construct1<Alloc, T>::value> construct(Alloc&, T* p)
|
| 174 |
+
{
|
| 175 |
+
::new (static_cast<void*>(p)) T();
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_construct2_impl, construct)
|
| 179 |
+
|
| 180 |
+
template <typename Alloc, typename T, typename Arg1>
|
| 181 |
+
struct has_member_construct2 : has_member_construct2_impl<Alloc, void(T*, const Arg1&)>
|
| 182 |
+
{};
|
| 183 |
+
|
| 184 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 185 |
+
template <typename Alloc, typename T, typename Arg1>
|
| 186 |
+
inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_construct2<Alloc, T, Arg1>::value>
|
| 187 |
+
construct(Alloc& a, T* p, const Arg1& arg1)
|
| 188 |
+
{
|
| 189 |
+
a.construct(p, arg1);
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 193 |
+
template <typename Alloc, typename T, typename Arg1>
|
| 194 |
+
inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_construct2<Alloc, T, Arg1>::value>
|
| 195 |
+
construct(Alloc&, T* p, const Arg1& arg1)
|
| 196 |
+
{
|
| 197 |
+
::new (static_cast<void*>(p)) T(arg1);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_constructN_impl, construct)
|
| 201 |
+
|
| 202 |
+
template <typename Alloc, typename T, typename... Args>
|
| 203 |
+
struct has_member_constructN : has_member_constructN_impl<Alloc, void(T*, Args...)>
|
| 204 |
+
{};
|
| 205 |
+
|
| 206 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 207 |
+
template <typename Alloc, typename T, typename... Args>
|
| 208 |
+
inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_constructN<Alloc, T, Args...>::value>
|
| 209 |
+
construct(Alloc& a, T* p, Args&&... args)
|
| 210 |
+
{
|
| 211 |
+
a.construct(p, THRUST_FWD(args)...);
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 215 |
+
template <typename Alloc, typename T, typename... Args>
|
| 216 |
+
inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_constructN<Alloc, T, Args...>::value>
|
| 217 |
+
construct(Alloc&, T* p, Args&&... args)
|
| 218 |
+
{
|
| 219 |
+
::new (static_cast<void*>(p)) T(THRUST_FWD(args)...);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_destroy_impl, destroy)
|
| 223 |
+
|
| 224 |
+
template <typename Alloc, typename T>
|
| 225 |
+
struct has_member_destroy : has_member_destroy_impl<Alloc, void(T*)>
|
| 226 |
+
{};
|
| 227 |
+
|
| 228 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 229 |
+
template <typename Alloc, typename T>
|
| 230 |
+
inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_destroy<Alloc, T>::value> destroy(Alloc& a, T* p)
|
| 231 |
+
{
|
| 232 |
+
a.destroy(p);
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 236 |
+
template <typename Alloc, typename T>
|
| 237 |
+
inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_destroy<Alloc, T>::value> destroy(Alloc&, T* p)
|
| 238 |
+
{
|
| 239 |
+
p->~T();
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_max_size_impl, max_size)
|
| 243 |
+
|
| 244 |
+
template <typename Alloc>
|
| 245 |
+
class has_member_max_size
|
| 246 |
+
{
|
| 247 |
+
using size_type = typename allocator_traits<Alloc>::size_type;
|
| 248 |
+
|
| 249 |
+
public:
|
| 250 |
+
using type = typename has_member_max_size_impl<Alloc, size_type()>::type;
|
| 251 |
+
static const bool value = type::value;
|
| 252 |
+
};
|
| 253 |
+
|
| 254 |
+
template <typename Alloc>
|
| 255 |
+
_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_max_size<Alloc>::value, typename allocator_traits<Alloc>::size_type>
|
| 256 |
+
max_size(const Alloc& a)
|
| 257 |
+
{
|
| 258 |
+
return a.max_size();
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
template <typename Alloc>
|
| 262 |
+
_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_max_size<Alloc>::value,
|
| 263 |
+
typename allocator_traits<Alloc>::size_type>
|
| 264 |
+
max_size(const Alloc&)
|
| 265 |
+
{
|
| 266 |
+
using size_type = typename allocator_traits<Alloc>::size_type;
|
| 267 |
+
return thrust::detail::integer_traits<size_type>::const_max;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
template <typename Alloc>
|
| 271 |
+
_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_system<Alloc>::value, typename allocator_system<Alloc>::type&>
|
| 272 |
+
system(Alloc& a)
|
| 273 |
+
{
|
| 274 |
+
// return the allocator's system
|
| 275 |
+
return a.system();
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
template <typename Alloc>
|
| 279 |
+
_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_system<Alloc>::value, typename allocator_system<Alloc>::type>
|
| 280 |
+
system(Alloc&)
|
| 281 |
+
{
|
| 282 |
+
// return a copy of a value-initialized system
|
| 283 |
+
return typename allocator_system<Alloc>::type();
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
} // namespace allocator_traits_detail
|
| 287 |
+
|
| 288 |
+
template <typename Alloc>
|
| 289 |
+
_CCCL_HOST_DEVICE typename allocator_traits<Alloc>::pointer
|
| 290 |
+
allocator_traits<Alloc>::allocate(Alloc& a, typename allocator_traits<Alloc>::size_type n)
|
| 291 |
+
{
|
| 292 |
+
struct workaround_warnings
|
| 293 |
+
{
|
| 294 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 295 |
+
static _CCCL_HOST_DEVICE typename allocator_traits<Alloc>::pointer
|
| 296 |
+
allocate(Alloc& a, typename allocator_traits<Alloc>::size_type n)
|
| 297 |
+
{
|
| 298 |
+
return a.allocate(n);
|
| 299 |
+
}
|
| 300 |
+
};
|
| 301 |
+
|
| 302 |
+
return workaround_warnings::allocate(a, n);
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
template <typename Alloc>
|
| 306 |
+
_CCCL_HOST_DEVICE typename allocator_traits<Alloc>::pointer allocator_traits<Alloc>::allocate(
|
| 307 |
+
Alloc& a, typename allocator_traits<Alloc>::size_type n, typename allocator_traits<Alloc>::const_void_pointer hint)
|
| 308 |
+
{
|
| 309 |
+
return allocator_traits_detail::allocate(a, n, hint);
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
template <typename Alloc>
|
| 313 |
+
_CCCL_HOST_DEVICE void allocator_traits<Alloc>::deallocate(
|
| 314 |
+
Alloc& a, typename allocator_traits<Alloc>::pointer p, typename allocator_traits<Alloc>::size_type n) noexcept
|
| 315 |
+
{
|
| 316 |
+
struct workaround_warnings
|
| 317 |
+
{
|
| 318 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 319 |
+
static _CCCL_HOST_DEVICE void deallocate(
|
| 320 |
+
Alloc& a, typename allocator_traits<Alloc>::pointer p, typename allocator_traits<Alloc>::size_type n) noexcept
|
| 321 |
+
{
|
| 322 |
+
return a.deallocate(p, n);
|
| 323 |
+
}
|
| 324 |
+
};
|
| 325 |
+
|
| 326 |
+
return workaround_warnings::deallocate(a, p, n);
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
template <typename Alloc>
|
| 330 |
+
template <typename T>
|
| 331 |
+
_CCCL_HOST_DEVICE void allocator_traits<Alloc>::construct(allocator_type& a, T* p)
|
| 332 |
+
{
|
| 333 |
+
return allocator_traits_detail::construct(a, p);
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
template <typename Alloc>
|
| 337 |
+
template <typename T, typename Arg1>
|
| 338 |
+
_CCCL_HOST_DEVICE void allocator_traits<Alloc>::construct(allocator_type& a, T* p, const Arg1& arg1)
|
| 339 |
+
{
|
| 340 |
+
return allocator_traits_detail::construct(a, p, arg1);
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
template <typename Alloc>
|
| 344 |
+
template <typename T, typename... Args>
|
| 345 |
+
_CCCL_HOST_DEVICE void allocator_traits<Alloc>::construct(allocator_type& a, T* p, Args&&... args)
|
| 346 |
+
{
|
| 347 |
+
return allocator_traits_detail::construct(a, p, THRUST_FWD(args)...);
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
template <typename Alloc>
|
| 351 |
+
template <typename T>
|
| 352 |
+
_CCCL_HOST_DEVICE void allocator_traits<Alloc>::destroy(allocator_type& a, T* p) noexcept
|
| 353 |
+
{
|
| 354 |
+
return allocator_traits_detail::destroy(a, p);
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
template <typename Alloc>
|
| 358 |
+
_CCCL_HOST_DEVICE typename allocator_traits<Alloc>::size_type allocator_traits<Alloc>::max_size(const allocator_type& a)
|
| 359 |
+
{
|
| 360 |
+
return allocator_traits_detail::max_size(a);
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
template <typename Alloc>
|
| 364 |
+
_CCCL_HOST_DEVICE typename allocator_system<Alloc>::get_result_type allocator_system<Alloc>::get(Alloc& a)
|
| 365 |
+
{
|
| 366 |
+
return allocator_traits_detail::system(a);
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
} // namespace detail
|
| 370 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/copy_construct_range.h
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/execution_policy.h>
|
| 29 |
+
|
| 30 |
+
THRUST_NAMESPACE_BEGIN
|
| 31 |
+
namespace detail
|
| 32 |
+
{
|
| 33 |
+
|
| 34 |
+
template <typename System, typename Allocator, typename InputIterator, typename Pointer>
|
| 35 |
+
_CCCL_HOST_DEVICE Pointer copy_construct_range(
|
| 36 |
+
thrust::execution_policy<System>& from_system, Allocator& a, InputIterator first, InputIterator last, Pointer result);
|
| 37 |
+
|
| 38 |
+
template <typename System, typename Allocator, typename InputIterator, typename Size, typename Pointer>
|
| 39 |
+
_CCCL_HOST_DEVICE Pointer copy_construct_range_n(
|
| 40 |
+
thrust::execution_policy<System>& from_system, Allocator& a, InputIterator first, Size n, Pointer result);
|
| 41 |
+
|
| 42 |
+
} // namespace detail
|
| 43 |
+
THRUST_NAMESPACE_END
|
| 44 |
+
|
| 45 |
+
#include <thrust/detail/allocator/copy_construct_range.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/copy_construct_range.inl
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/advance.h>
|
| 29 |
+
#include <thrust/detail/allocator/allocator_traits.h>
|
| 30 |
+
#include <thrust/detail/copy.h>
|
| 31 |
+
#include <thrust/detail/memory_wrapper.h>
|
| 32 |
+
#include <thrust/detail/type_traits/pointer_traits.h>
|
| 33 |
+
#include <thrust/distance.h>
|
| 34 |
+
#include <thrust/for_each.h>
|
| 35 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 36 |
+
#include <thrust/iterator/zip_iterator.h>
|
| 37 |
+
#include <thrust/tuple.h>
|
| 38 |
+
|
| 39 |
+
THRUST_NAMESPACE_BEGIN
|
| 40 |
+
namespace detail
|
| 41 |
+
{
|
| 42 |
+
namespace allocator_traits_detail
|
| 43 |
+
{
|
| 44 |
+
|
| 45 |
+
template <typename Allocator, typename InputType, typename OutputType>
|
| 46 |
+
struct copy_construct_with_allocator
|
| 47 |
+
{
|
| 48 |
+
Allocator& a;
|
| 49 |
+
|
| 50 |
+
_CCCL_HOST_DEVICE copy_construct_with_allocator(Allocator& a)
|
| 51 |
+
: a(a)
|
| 52 |
+
{}
|
| 53 |
+
|
| 54 |
+
template <typename Tuple>
|
| 55 |
+
inline _CCCL_HOST_DEVICE void operator()(Tuple t)
|
| 56 |
+
{
|
| 57 |
+
const InputType& in = thrust::get<0>(t);
|
| 58 |
+
OutputType& out = thrust::get<1>(t);
|
| 59 |
+
|
| 60 |
+
allocator_traits<Allocator>::construct(a, &out, in);
|
| 61 |
+
}
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
// we need to use allocator_traits<Allocator>::construct() to
|
| 65 |
+
// copy construct a T if either:
|
| 66 |
+
// 1. Allocator has a 2-argument construct() member or
|
| 67 |
+
// 2. T has a non-trivial copy constructor
|
| 68 |
+
template <typename Allocator, typename T>
|
| 69 |
+
struct needs_copy_construct_via_allocator
|
| 70 |
+
: integral_constant<bool,
|
| 71 |
+
(has_member_construct2<Allocator, T, T>::value
|
| 72 |
+
|| !::cuda::std::is_trivially_copy_constructible<T>::value)>
|
| 73 |
+
{};
|
| 74 |
+
|
| 75 |
+
// we know that std::allocator::construct's only effect is to call T's
|
| 76 |
+
// copy constructor, so we needn't consider or use its construct() member for copy construction
|
| 77 |
+
template <typename U, typename T>
|
| 78 |
+
struct needs_copy_construct_via_allocator<std::allocator<U>, T>
|
| 79 |
+
: integral_constant<bool, !::cuda::std::is_trivially_copy_constructible<T>::value>
|
| 80 |
+
{};
|
| 81 |
+
|
| 82 |
+
// XXX it's regrettable that this implementation is copied almost
|
| 83 |
+
// exactly from system::detail::generic::uninitialized_copy
|
| 84 |
+
// perhaps generic::uninitialized_copy could call this routine
|
| 85 |
+
// with a default allocator
|
| 86 |
+
template <typename Allocator, typename FromSystem, typename ToSystem, typename InputIterator, typename Pointer>
|
| 87 |
+
_CCCL_HOST_DEVICE enable_if_convertible_t<FromSystem, ToSystem, Pointer> uninitialized_copy_with_allocator(
|
| 88 |
+
Allocator& a,
|
| 89 |
+
const thrust::execution_policy<FromSystem>&,
|
| 90 |
+
const thrust::execution_policy<ToSystem>& to_system,
|
| 91 |
+
InputIterator first,
|
| 92 |
+
InputIterator last,
|
| 93 |
+
Pointer result)
|
| 94 |
+
{
|
| 95 |
+
// zip up the iterators
|
| 96 |
+
using IteratorTuple = thrust::tuple<InputIterator, Pointer>;
|
| 97 |
+
using ZipIterator = thrust::zip_iterator<IteratorTuple>;
|
| 98 |
+
|
| 99 |
+
ZipIterator begin = thrust::make_zip_iterator(thrust::make_tuple(first, result));
|
| 100 |
+
ZipIterator end = begin;
|
| 101 |
+
|
| 102 |
+
// get a zip_iterator pointing to the end
|
| 103 |
+
const typename thrust::iterator_difference<InputIterator>::type n = thrust::distance(first, last);
|
| 104 |
+
thrust::advance(end, n);
|
| 105 |
+
|
| 106 |
+
// create a functor
|
| 107 |
+
using InputType = typename iterator_traits<InputIterator>::value_type;
|
| 108 |
+
using OutputType = typename iterator_traits<Pointer>::value_type;
|
| 109 |
+
|
| 110 |
+
// do the for_each
|
| 111 |
+
// note we use to_system to dispatch the for_each
|
| 112 |
+
thrust::for_each(to_system, begin, end, copy_construct_with_allocator<Allocator, InputType, OutputType>(a));
|
| 113 |
+
|
| 114 |
+
// return the end of the output range
|
| 115 |
+
return thrust::get<1>(end.get_iterator_tuple());
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
// XXX it's regrettable that this implementation is copied almost
|
| 119 |
+
// exactly from system::detail::generic::uninitialized_copy_n
|
| 120 |
+
// perhaps generic::uninitialized_copy_n could call this routine
|
| 121 |
+
// with a default allocator
|
| 122 |
+
template <typename Allocator, typename FromSystem, typename ToSystem, typename InputIterator, typename Size, typename Pointer>
|
| 123 |
+
_CCCL_HOST_DEVICE enable_if_convertible_t<FromSystem, ToSystem, Pointer> uninitialized_copy_with_allocator_n(
|
| 124 |
+
Allocator& a,
|
| 125 |
+
const thrust::execution_policy<FromSystem>&,
|
| 126 |
+
const thrust::execution_policy<ToSystem>& to_system,
|
| 127 |
+
InputIterator first,
|
| 128 |
+
Size n,
|
| 129 |
+
Pointer result)
|
| 130 |
+
{
|
| 131 |
+
// zip up the iterators
|
| 132 |
+
using IteratorTuple = thrust::tuple<InputIterator, Pointer>;
|
| 133 |
+
using ZipIterator = thrust::zip_iterator<IteratorTuple>;
|
| 134 |
+
|
| 135 |
+
ZipIterator begin = thrust::make_zip_iterator(thrust::make_tuple(first, result));
|
| 136 |
+
|
| 137 |
+
// create a functor
|
| 138 |
+
using InputType = typename iterator_traits<InputIterator>::value_type;
|
| 139 |
+
using OutputType = typename iterator_traits<Pointer>::value_type;
|
| 140 |
+
|
| 141 |
+
// do the for_each_n
|
| 142 |
+
// note we use to_system to dispatch the for_each_n
|
| 143 |
+
ZipIterator end =
|
| 144 |
+
thrust::for_each_n(to_system, begin, n, copy_construct_with_allocator<Allocator, InputType, OutputType>(a));
|
| 145 |
+
|
| 146 |
+
// return the end of the output range
|
| 147 |
+
return thrust::get<1>(end.get_iterator_tuple());
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
template <typename Allocator, typename FromSystem, typename ToSystem, typename InputIterator, typename Pointer>
|
| 151 |
+
_CCCL_HOST_DEVICE typename disable_if_convertible<FromSystem, ToSystem, Pointer>::type uninitialized_copy_with_allocator(
|
| 152 |
+
Allocator&,
|
| 153 |
+
const thrust::execution_policy<FromSystem>& from_system,
|
| 154 |
+
const thrust::execution_policy<ToSystem>& to_system,
|
| 155 |
+
InputIterator first,
|
| 156 |
+
InputIterator last,
|
| 157 |
+
Pointer result)
|
| 158 |
+
{
|
| 159 |
+
// the systems aren't trivially interoperable
|
| 160 |
+
// just call two_system_copy and hope for the best
|
| 161 |
+
return thrust::detail::two_system_copy(from_system, to_system, first, last, result);
|
| 162 |
+
} // end uninitialized_copy_with_allocator()
|
| 163 |
+
|
| 164 |
+
template <typename Allocator, typename FromSystem, typename ToSystem, typename InputIterator, typename Size, typename Pointer>
|
| 165 |
+
_CCCL_HOST_DEVICE typename disable_if_convertible<FromSystem, ToSystem, Pointer>::type
|
| 166 |
+
uninitialized_copy_with_allocator_n(
|
| 167 |
+
Allocator&,
|
| 168 |
+
const thrust::execution_policy<FromSystem>& from_system,
|
| 169 |
+
const thrust::execution_policy<ToSystem>& to_system,
|
| 170 |
+
InputIterator first,
|
| 171 |
+
Size n,
|
| 172 |
+
Pointer result)
|
| 173 |
+
{
|
| 174 |
+
// the systems aren't trivially interoperable
|
| 175 |
+
// just call two_system_copy_n and hope for the best
|
| 176 |
+
return thrust::detail::two_system_copy_n(from_system, to_system, first, n, result);
|
| 177 |
+
} // end uninitialized_copy_with_allocator_n()
|
| 178 |
+
|
| 179 |
+
template <typename FromSystem, typename Allocator, typename InputIterator, typename Pointer>
|
| 180 |
+
_CCCL_HOST_DEVICE
|
| 181 |
+
typename disable_if<needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value,
|
| 182 |
+
Pointer>::type
|
| 183 |
+
copy_construct_range(thrust::execution_policy<FromSystem>& from_system,
|
| 184 |
+
Allocator& a,
|
| 185 |
+
InputIterator first,
|
| 186 |
+
InputIterator last,
|
| 187 |
+
Pointer result)
|
| 188 |
+
{
|
| 189 |
+
// just call two_system_copy
|
| 190 |
+
return thrust::detail::two_system_copy(from_system, allocator_system<Allocator>::get(a), first, last, result);
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
template <typename FromSystem, typename Allocator, typename InputIterator, typename Size, typename Pointer>
|
| 194 |
+
_CCCL_HOST_DEVICE
|
| 195 |
+
typename disable_if<needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value,
|
| 196 |
+
Pointer>::type
|
| 197 |
+
copy_construct_range_n(
|
| 198 |
+
thrust::execution_policy<FromSystem>& from_system, Allocator& a, InputIterator first, Size n, Pointer result)
|
| 199 |
+
{
|
| 200 |
+
// just call two_system_copy_n
|
| 201 |
+
return thrust::detail::two_system_copy_n(from_system, allocator_system<Allocator>::get(a), first, n, result);
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
template <typename FromSystem, typename Allocator, typename InputIterator, typename Pointer>
|
| 205 |
+
_CCCL_HOST_DEVICE ::cuda::std::
|
| 206 |
+
enable_if_t<needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value, Pointer>
|
| 207 |
+
copy_construct_range(thrust::execution_policy<FromSystem>& from_system,
|
| 208 |
+
Allocator& a,
|
| 209 |
+
InputIterator first,
|
| 210 |
+
InputIterator last,
|
| 211 |
+
Pointer result)
|
| 212 |
+
{
|
| 213 |
+
return uninitialized_copy_with_allocator(a, from_system, allocator_system<Allocator>::get(a), first, last, result);
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
template <typename FromSystem, typename Allocator, typename InputIterator, typename Size, typename Pointer>
|
| 217 |
+
_CCCL_HOST_DEVICE ::cuda::std::
|
| 218 |
+
enable_if_t<needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value, Pointer>
|
| 219 |
+
copy_construct_range_n(
|
| 220 |
+
thrust::execution_policy<FromSystem>& from_system, Allocator& a, InputIterator first, Size n, Pointer result)
|
| 221 |
+
{
|
| 222 |
+
return uninitialized_copy_with_allocator_n(a, from_system, allocator_system<Allocator>::get(a), first, n, result);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
} // namespace allocator_traits_detail
|
| 226 |
+
|
| 227 |
+
template <typename System, typename Allocator, typename InputIterator, typename Pointer>
|
| 228 |
+
_CCCL_HOST_DEVICE Pointer copy_construct_range(
|
| 229 |
+
thrust::execution_policy<System>& from_system, Allocator& a, InputIterator first, InputIterator last, Pointer result)
|
| 230 |
+
{
|
| 231 |
+
return allocator_traits_detail::copy_construct_range(from_system, a, first, last, result);
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
template <typename System, typename Allocator, typename InputIterator, typename Size, typename Pointer>
|
| 235 |
+
_CCCL_HOST_DEVICE Pointer copy_construct_range_n(
|
| 236 |
+
thrust::execution_policy<System>& from_system, Allocator& a, InputIterator first, Size n, Pointer result)
|
| 237 |
+
{
|
| 238 |
+
return allocator_traits_detail::copy_construct_range_n(from_system, a, first, n, result);
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
} // namespace detail
|
| 242 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/destroy_range.h
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
THRUST_NAMESPACE_BEGIN
|
| 30 |
+
namespace detail
|
| 31 |
+
{
|
| 32 |
+
|
| 33 |
+
template <typename Allocator, typename Pointer, typename Size>
|
| 34 |
+
_CCCL_HOST_DEVICE inline void destroy_range(Allocator& a, Pointer p, Size n) noexcept;
|
| 35 |
+
|
| 36 |
+
} // namespace detail
|
| 37 |
+
THRUST_NAMESPACE_END
|
| 38 |
+
|
| 39 |
+
#include <thrust/detail/allocator/destroy_range.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/destroy_range.inl
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2021 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
#include <thrust/detail/allocator/allocator_traits.h>
|
| 30 |
+
#include <thrust/detail/allocator/destroy_range.h>
|
| 31 |
+
#include <thrust/detail/memory_wrapper.h>
|
| 32 |
+
#include <thrust/detail/type_traits/pointer_traits.h>
|
| 33 |
+
#include <thrust/for_each.h>
|
| 34 |
+
|
| 35 |
+
THRUST_NAMESPACE_BEGIN
|
| 36 |
+
namespace detail
|
| 37 |
+
{
|
| 38 |
+
namespace allocator_traits_detail
|
| 39 |
+
{
|
| 40 |
+
|
| 41 |
+
// destroy_range has three cases:
|
| 42 |
+
// if Allocator has an effectful member function destroy:
|
| 43 |
+
// 1. destroy via the allocator
|
| 44 |
+
// else
|
| 45 |
+
// 2. if T has a non-trivial destructor, destroy the range without using the allocator
|
| 46 |
+
// 3. if T has a trivial destructor, do a no-op
|
| 47 |
+
|
| 48 |
+
template <typename Allocator, typename T>
|
| 49 |
+
struct has_effectful_member_destroy : has_member_destroy<Allocator, T>
|
| 50 |
+
{};
|
| 51 |
+
|
| 52 |
+
// std::allocator::destroy's only effect is to invoke its argument's destructor
|
| 53 |
+
template <typename U, typename T>
|
| 54 |
+
struct has_effectful_member_destroy<std::allocator<U>, T> : thrust::detail::false_type
|
| 55 |
+
{};
|
| 56 |
+
|
| 57 |
+
// case 1: Allocator has an effectful 1-argument member function "destroy"
|
| 58 |
+
template <typename Allocator, typename Pointer>
|
| 59 |
+
struct enable_if_destroy_range_case1
|
| 60 |
+
: ::cuda::std::enable_if<has_effectful_member_destroy<Allocator, typename pointer_element<Pointer>::type>::value>
|
| 61 |
+
{};
|
| 62 |
+
|
| 63 |
+
// case 2: Allocator has no member function "destroy", but T has a non-trivial destructor
|
| 64 |
+
template <typename Allocator, typename Pointer>
|
| 65 |
+
struct enable_if_destroy_range_case2
|
| 66 |
+
: ::cuda::std::enable_if<!has_effectful_member_destroy<Allocator, typename pointer_element<Pointer>::type>::value
|
| 67 |
+
&& !::cuda::std::is_trivially_destructible<typename pointer_element<Pointer>::type>::value>
|
| 68 |
+
{};
|
| 69 |
+
|
| 70 |
+
// case 3: Allocator has no member function "destroy", and T has a trivial destructor
|
| 71 |
+
template <typename Allocator, typename Pointer>
|
| 72 |
+
struct enable_if_destroy_range_case3
|
| 73 |
+
: ::cuda::std::enable_if<!has_effectful_member_destroy<Allocator, typename pointer_element<Pointer>::type>::value
|
| 74 |
+
&& ::cuda::std::is_trivially_destructible<typename pointer_element<Pointer>::type>::value>
|
| 75 |
+
{};
|
| 76 |
+
|
| 77 |
+
template <typename Allocator>
|
| 78 |
+
struct destroy_via_allocator
|
| 79 |
+
{
|
| 80 |
+
Allocator& a;
|
| 81 |
+
|
| 82 |
+
_CCCL_HOST_DEVICE destroy_via_allocator(Allocator& a) noexcept
|
| 83 |
+
: a(a)
|
| 84 |
+
{}
|
| 85 |
+
|
| 86 |
+
template <typename T>
|
| 87 |
+
inline _CCCL_HOST_DEVICE void operator()(T& x) noexcept
|
| 88 |
+
{
|
| 89 |
+
allocator_traits<Allocator>::destroy(a, &x);
|
| 90 |
+
}
|
| 91 |
+
};
|
| 92 |
+
|
| 93 |
+
// destroy_range case 1: destroy via allocator
|
| 94 |
+
template <typename Allocator, typename Pointer, typename Size>
|
| 95 |
+
_CCCL_HOST_DEVICE typename enable_if_destroy_range_case1<Allocator, Pointer>::type
|
| 96 |
+
destroy_range(Allocator& a, Pointer p, Size n) noexcept
|
| 97 |
+
{
|
| 98 |
+
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, destroy_via_allocator<Allocator>(a));
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
// we must prepare for His coming
|
| 102 |
+
struct gozer
|
| 103 |
+
{
|
| 104 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 105 |
+
template <typename T>
|
| 106 |
+
inline _CCCL_HOST_DEVICE void operator()(T& x) noexcept
|
| 107 |
+
{
|
| 108 |
+
x.~T();
|
| 109 |
+
}
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
// destroy_range case 2: destroy without the allocator
|
| 113 |
+
template <typename Allocator, typename Pointer, typename Size>
|
| 114 |
+
_CCCL_HOST_DEVICE typename enable_if_destroy_range_case2<Allocator, Pointer>::type
|
| 115 |
+
destroy_range(Allocator& a, Pointer p, Size n) noexcept
|
| 116 |
+
{
|
| 117 |
+
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, gozer());
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
// destroy_range case 3: no-op
|
| 121 |
+
template <typename Allocator, typename Pointer, typename Size>
|
| 122 |
+
_CCCL_HOST_DEVICE typename enable_if_destroy_range_case3<Allocator, Pointer>::type
|
| 123 |
+
destroy_range(Allocator&, Pointer, Size) noexcept
|
| 124 |
+
{
|
| 125 |
+
// no op
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
} // namespace allocator_traits_detail
|
| 129 |
+
|
| 130 |
+
template <typename Allocator, typename Pointer, typename Size>
|
| 131 |
+
_CCCL_HOST_DEVICE void destroy_range(Allocator& a, Pointer p, Size n) noexcept
|
| 132 |
+
{
|
| 133 |
+
return allocator_traits_detail::destroy_range(a, p, n);
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
} // namespace detail
|
| 137 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/fill_construct_range.h
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
THRUST_NAMESPACE_BEGIN
|
| 30 |
+
namespace detail
|
| 31 |
+
{
|
| 32 |
+
|
| 33 |
+
template <typename Allocator, typename Pointer, typename Size, typename T>
|
| 34 |
+
_CCCL_HOST_DEVICE inline void fill_construct_range(Allocator& a, Pointer p, Size n, const T& value);
|
| 35 |
+
|
| 36 |
+
} // namespace detail
|
| 37 |
+
THRUST_NAMESPACE_END
|
| 38 |
+
|
| 39 |
+
#include <thrust/detail/allocator/fill_construct_range.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/fill_construct_range.inl
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/allocator/allocator_traits.h>
|
| 29 |
+
#include <thrust/detail/memory_wrapper.h>
|
| 30 |
+
#include <thrust/detail/type_traits.h>
|
| 31 |
+
#include <thrust/detail/type_traits/pointer_traits.h>
|
| 32 |
+
#include <thrust/for_each.h>
|
| 33 |
+
#include <thrust/uninitialized_fill.h>
|
| 34 |
+
|
| 35 |
+
THRUST_NAMESPACE_BEGIN
|
| 36 |
+
namespace detail
|
| 37 |
+
{
|
| 38 |
+
namespace allocator_traits_detail
|
| 39 |
+
{
|
| 40 |
+
|
| 41 |
+
// fill_construct_range has 2 cases:
|
| 42 |
+
// if Allocator has an effectful member function construct:
|
| 43 |
+
// 1. construct via the allocator
|
| 44 |
+
// else
|
| 45 |
+
// 2. construct via uninitialized_fill
|
| 46 |
+
|
| 47 |
+
template <typename Allocator, typename T, typename Arg1>
|
| 48 |
+
struct has_effectful_member_construct2 : has_member_construct2<Allocator, T, Arg1>
|
| 49 |
+
{};
|
| 50 |
+
|
| 51 |
+
// std::allocator::construct's only effect is to invoke placement new
|
| 52 |
+
template <typename U, typename T, typename Arg1>
|
| 53 |
+
struct has_effectful_member_construct2<std::allocator<U>, T, Arg1> : thrust::detail::false_type
|
| 54 |
+
{};
|
| 55 |
+
|
| 56 |
+
template <typename Allocator, typename Arg1>
|
| 57 |
+
struct construct2_via_allocator
|
| 58 |
+
{
|
| 59 |
+
Allocator& a;
|
| 60 |
+
Arg1 arg;
|
| 61 |
+
|
| 62 |
+
_CCCL_HOST_DEVICE construct2_via_allocator(Allocator& a, const Arg1& arg)
|
| 63 |
+
: a(a)
|
| 64 |
+
, arg(arg)
|
| 65 |
+
{}
|
| 66 |
+
|
| 67 |
+
template <typename T>
|
| 68 |
+
inline _CCCL_HOST_DEVICE void operator()(T& x)
|
| 69 |
+
{
|
| 70 |
+
allocator_traits<Allocator>::construct(a, &x, arg);
|
| 71 |
+
}
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
template <typename Allocator, typename Pointer, typename Size, typename T>
|
| 75 |
+
_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<
|
| 76 |
+
has_effectful_member_construct2<Allocator, typename pointer_element<Pointer>::type, T>::value>
|
| 77 |
+
fill_construct_range(Allocator& a, Pointer p, Size n, const T& value)
|
| 78 |
+
{
|
| 79 |
+
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, construct2_via_allocator<Allocator, T>(a, value));
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
template <typename Allocator, typename Pointer, typename Size, typename T>
|
| 83 |
+
_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<
|
| 84 |
+
!has_effectful_member_construct2<Allocator, typename pointer_element<Pointer>::type, T>::value>
|
| 85 |
+
fill_construct_range(Allocator& a, Pointer p, Size n, const T& value)
|
| 86 |
+
{
|
| 87 |
+
thrust::uninitialized_fill_n(allocator_system<Allocator>::get(a), p, n, value);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
} // namespace allocator_traits_detail
|
| 91 |
+
|
| 92 |
+
template <typename Alloc, typename Pointer, typename Size, typename T>
|
| 93 |
+
_CCCL_HOST_DEVICE void fill_construct_range(Alloc& a, Pointer p, Size n, const T& value)
|
| 94 |
+
{
|
| 95 |
+
return allocator_traits_detail::fill_construct_range(a, p, n, value);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
} // namespace detail
|
| 99 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/malloc_allocator.h
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/allocator/tagged_allocator.h>
|
| 29 |
+
#include <thrust/detail/type_traits/pointer_traits.h>
|
| 30 |
+
|
| 31 |
+
THRUST_NAMESPACE_BEGIN
|
| 32 |
+
namespace detail
|
| 33 |
+
{
|
| 34 |
+
|
| 35 |
+
template <typename T, typename System, typename Pointer>
|
| 36 |
+
class malloc_allocator : public thrust::detail::tagged_allocator<T, System, Pointer>
|
| 37 |
+
{
|
| 38 |
+
private:
|
| 39 |
+
using super_t = thrust::detail::tagged_allocator<T, System, Pointer>;
|
| 40 |
+
|
| 41 |
+
public:
|
| 42 |
+
using pointer = typename super_t::pointer;
|
| 43 |
+
using size_type = typename super_t::size_type;
|
| 44 |
+
|
| 45 |
+
pointer allocate(size_type cnt);
|
| 46 |
+
|
| 47 |
+
void deallocate(pointer p, size_type n) noexcept;
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
} // namespace detail
|
| 51 |
+
THRUST_NAMESPACE_END
|
| 52 |
+
|
| 53 |
+
#include <thrust/detail/allocator/malloc_allocator.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/malloc_allocator.inl
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/allocator/malloc_allocator.h>
|
| 29 |
+
#include <thrust/detail/malloc_and_free.h>
|
| 30 |
+
#include <thrust/detail/raw_pointer_cast.h>
|
| 31 |
+
#include <thrust/system/detail/bad_alloc.h>
|
| 32 |
+
#include <thrust/system/detail/generic/select_system.h>
|
| 33 |
+
|
| 34 |
+
THRUST_NAMESPACE_BEGIN
|
| 35 |
+
namespace detail
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
template <typename T, typename System, typename Pointer>
|
| 39 |
+
typename malloc_allocator<T, System, Pointer>::pointer
|
| 40 |
+
malloc_allocator<T, System, Pointer>::allocate(typename malloc_allocator<T, System, Pointer>::size_type cnt)
|
| 41 |
+
{
|
| 42 |
+
using thrust::system::detail::generic::select_system;
|
| 43 |
+
|
| 44 |
+
// XXX should use a hypothetical thrust::static_pointer_cast here
|
| 45 |
+
System system;
|
| 46 |
+
|
| 47 |
+
pointer result = thrust::malloc<T>(select_system(system), cnt);
|
| 48 |
+
|
| 49 |
+
if (result.get() == 0)
|
| 50 |
+
{
|
| 51 |
+
throw thrust::system::detail::bad_alloc("malloc_allocator::allocate: malloc failed");
|
| 52 |
+
} // end if
|
| 53 |
+
|
| 54 |
+
return result;
|
| 55 |
+
} // end malloc_allocator::allocate()
|
| 56 |
+
|
| 57 |
+
template <typename T, typename System, typename Pointer>
|
| 58 |
+
void malloc_allocator<T, System, Pointer>::deallocate(typename malloc_allocator<T, System, Pointer>::pointer p,
|
| 59 |
+
typename malloc_allocator<T, System, Pointer>::size_type) noexcept
|
| 60 |
+
{
|
| 61 |
+
using thrust::system::detail::generic::select_system;
|
| 62 |
+
|
| 63 |
+
System system;
|
| 64 |
+
thrust::free(select_system(system), p);
|
| 65 |
+
} // end malloc_allocator
|
| 66 |
+
|
| 67 |
+
} // namespace detail
|
| 68 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/no_throw_allocator.h
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
#include <nv/target>
|
| 30 |
+
|
| 31 |
+
THRUST_NAMESPACE_BEGIN
|
| 32 |
+
namespace detail
|
| 33 |
+
{
|
| 34 |
+
|
| 35 |
+
template <typename BaseAllocator>
|
| 36 |
+
struct no_throw_allocator : BaseAllocator
|
| 37 |
+
{
|
| 38 |
+
private:
|
| 39 |
+
using super_t = BaseAllocator;
|
| 40 |
+
|
| 41 |
+
public:
|
| 42 |
+
inline _CCCL_HOST_DEVICE no_throw_allocator(const BaseAllocator& other = BaseAllocator())
|
| 43 |
+
: super_t(other)
|
| 44 |
+
{}
|
| 45 |
+
|
| 46 |
+
template <typename U>
|
| 47 |
+
struct rebind
|
| 48 |
+
{
|
| 49 |
+
using other = no_throw_allocator<typename super_t::template rebind<U>::other>;
|
| 50 |
+
}; // end rebind
|
| 51 |
+
|
| 52 |
+
_CCCL_HOST_DEVICE void deallocate(typename super_t::pointer p, typename super_t::size_type n) noexcept
|
| 53 |
+
{
|
| 54 |
+
NV_IF_TARGET(
|
| 55 |
+
NV_IS_HOST,
|
| 56 |
+
(try { super_t::deallocate(p, n); } // end try
|
| 57 |
+
catch (...){
|
| 58 |
+
// catch anything
|
| 59 |
+
} // end catch
|
| 60 |
+
),
|
| 61 |
+
(super_t::deallocate(p, n);));
|
| 62 |
+
} // end deallocate()
|
| 63 |
+
|
| 64 |
+
inline _CCCL_HOST_DEVICE bool operator==(no_throw_allocator const& other)
|
| 65 |
+
{
|
| 66 |
+
return super_t::operator==(other);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
inline _CCCL_HOST_DEVICE bool operator!=(no_throw_allocator const& other)
|
| 70 |
+
{
|
| 71 |
+
return super_t::operator!=(other);
|
| 72 |
+
}
|
| 73 |
+
}; // end no_throw_allocator
|
| 74 |
+
|
| 75 |
+
} // namespace detail
|
| 76 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/tagged_allocator.h
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/type_traits/pointer_traits.h>
|
| 29 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 30 |
+
|
| 31 |
+
THRUST_NAMESPACE_BEGIN
|
| 32 |
+
namespace detail
|
| 33 |
+
{
|
| 34 |
+
|
| 35 |
+
template <typename T, typename Tag, typename Pointer>
|
| 36 |
+
class tagged_allocator;
|
| 37 |
+
|
| 38 |
+
template <typename Tag, typename Pointer>
|
| 39 |
+
class tagged_allocator<void, Tag, Pointer>
|
| 40 |
+
{
|
| 41 |
+
public:
|
| 42 |
+
using value_type = void;
|
| 43 |
+
using pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<void>::other;
|
| 44 |
+
using const_pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<const void>::other;
|
| 45 |
+
using size_type = std::size_t;
|
| 46 |
+
using difference_type = typename thrust::detail::pointer_traits<Pointer>::difference_type;
|
| 47 |
+
using system_type = Tag;
|
| 48 |
+
|
| 49 |
+
template <typename U>
|
| 50 |
+
struct rebind
|
| 51 |
+
{
|
| 52 |
+
using other = tagged_allocator<U, Tag, Pointer>;
|
| 53 |
+
}; // end rebind
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
template <typename T, typename Tag, typename Pointer>
|
| 57 |
+
class tagged_allocator
|
| 58 |
+
{
|
| 59 |
+
public:
|
| 60 |
+
using value_type = T;
|
| 61 |
+
using pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<T>::other;
|
| 62 |
+
using const_pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<const T>::other;
|
| 63 |
+
using reference = typename thrust::iterator_reference<pointer>::type;
|
| 64 |
+
using const_reference = typename thrust::iterator_reference<const_pointer>::type;
|
| 65 |
+
using size_type = std::size_t;
|
| 66 |
+
using difference_type = typename thrust::detail::pointer_traits<pointer>::difference_type;
|
| 67 |
+
using system_type = Tag;
|
| 68 |
+
|
| 69 |
+
template <typename U>
|
| 70 |
+
struct rebind
|
| 71 |
+
{
|
| 72 |
+
using other = tagged_allocator<U, Tag, Pointer>;
|
| 73 |
+
}; // end rebind
|
| 74 |
+
|
| 75 |
+
_CCCL_HOST_DEVICE inline tagged_allocator();
|
| 76 |
+
|
| 77 |
+
_CCCL_HOST_DEVICE inline tagged_allocator(const tagged_allocator&);
|
| 78 |
+
|
| 79 |
+
template <typename U, typename OtherPointer>
|
| 80 |
+
_CCCL_HOST_DEVICE inline tagged_allocator(const tagged_allocator<U, Tag, OtherPointer>&);
|
| 81 |
+
|
| 82 |
+
_CCCL_HOST_DEVICE inline ~tagged_allocator();
|
| 83 |
+
|
| 84 |
+
_CCCL_HOST_DEVICE pointer address(reference x) const;
|
| 85 |
+
|
| 86 |
+
_CCCL_HOST_DEVICE const_pointer address(const_reference x) const;
|
| 87 |
+
|
| 88 |
+
size_type max_size() const;
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
template <typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
|
| 92 |
+
_CCCL_HOST_DEVICE bool
|
| 93 |
+
operator==(const tagged_allocator<T1, Pointer1, Tag>&, const tagged_allocator<T2, Pointer2, Tag>&);
|
| 94 |
+
|
| 95 |
+
template <typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
|
| 96 |
+
_CCCL_HOST_DEVICE bool
|
| 97 |
+
operator!=(const tagged_allocator<T1, Pointer1, Tag>&, const tagged_allocator<T2, Pointer2, Tag>&);
|
| 98 |
+
|
| 99 |
+
} // namespace detail
|
| 100 |
+
THRUST_NAMESPACE_END
|
| 101 |
+
|
| 102 |
+
#include <thrust/detail/allocator/tagged_allocator.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/tagged_allocator.inl
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/allocator/tagged_allocator.h>
|
| 29 |
+
|
| 30 |
+
#include <limits>
|
| 31 |
+
|
| 32 |
+
THRUST_NAMESPACE_BEGIN
|
| 33 |
+
namespace detail
|
| 34 |
+
{
|
| 35 |
+
|
| 36 |
+
template <typename T, typename Tag, typename Pointer>
|
| 37 |
+
_CCCL_HOST_DEVICE tagged_allocator<T, Tag, Pointer>::tagged_allocator()
|
| 38 |
+
{}
|
| 39 |
+
|
| 40 |
+
template <typename T, typename Tag, typename Pointer>
|
| 41 |
+
_CCCL_HOST_DEVICE tagged_allocator<T, Tag, Pointer>::tagged_allocator(const tagged_allocator<T, Tag, Pointer>&)
|
| 42 |
+
{}
|
| 43 |
+
|
| 44 |
+
template <typename T, typename Tag, typename Pointer>
|
| 45 |
+
template <typename U, typename OtherPointer>
|
| 46 |
+
_CCCL_HOST_DEVICE tagged_allocator<T, Tag, Pointer>::tagged_allocator(const tagged_allocator<U, Tag, OtherPointer>&)
|
| 47 |
+
{}
|
| 48 |
+
|
| 49 |
+
template <typename T, typename Tag, typename Pointer>
|
| 50 |
+
_CCCL_HOST_DEVICE tagged_allocator<T, Tag, Pointer>::~tagged_allocator()
|
| 51 |
+
{}
|
| 52 |
+
|
| 53 |
+
template <typename T, typename Tag, typename Pointer>
|
| 54 |
+
_CCCL_HOST_DEVICE typename tagged_allocator<T, Tag, Pointer>::pointer
|
| 55 |
+
tagged_allocator<T, Tag, Pointer>::address(reference x) const
|
| 56 |
+
{
|
| 57 |
+
return &x;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
template <typename T, typename Tag, typename Pointer>
|
| 61 |
+
_CCCL_HOST_DEVICE typename tagged_allocator<T, Tag, Pointer>::const_pointer
|
| 62 |
+
tagged_allocator<T, Tag, Pointer>::address(const_reference x) const
|
| 63 |
+
{
|
| 64 |
+
return &x;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
template <typename T, typename Tag, typename Pointer>
|
| 68 |
+
typename tagged_allocator<T, Tag, Pointer>::size_type tagged_allocator<T, Tag, Pointer>::max_size() const
|
| 69 |
+
{
|
| 70 |
+
return (std::numeric_limits<size_type>::max)() / sizeof(T);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
template <typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
|
| 74 |
+
_CCCL_HOST_DEVICE bool operator==(const tagged_allocator<T1, Pointer1, Tag>&, const tagged_allocator<T2, Pointer2, Tag>&)
|
| 75 |
+
{
|
| 76 |
+
return true;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
template <typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
|
| 80 |
+
_CCCL_HOST_DEVICE bool operator!=(const tagged_allocator<T1, Pointer1, Tag>&, const tagged_allocator<T2, Pointer2, Tag>&)
|
| 81 |
+
{
|
| 82 |
+
return false;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
} // namespace detail
|
| 86 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/temporary_allocator.h
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/allocator/allocator_traits.h>
|
| 29 |
+
#include <thrust/detail/allocator/tagged_allocator.h>
|
| 30 |
+
#include <thrust/detail/execution_policy.h>
|
| 31 |
+
#include <thrust/memory.h>
|
| 32 |
+
#include <thrust/pair.h>
|
| 33 |
+
|
| 34 |
+
THRUST_NAMESPACE_BEGIN
|
| 35 |
+
namespace detail
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
// XXX the pointer parameter given to tagged_allocator should be related to
|
| 39 |
+
// the type of the expression get_temporary_buffer(system, n).first
|
| 40 |
+
// without decltype, compromise on pointer<T,System>
|
| 41 |
+
template <typename T, typename System>
|
| 42 |
+
class temporary_allocator : public thrust::detail::tagged_allocator<T, System, thrust::pointer<T, System>>
|
| 43 |
+
{
|
| 44 |
+
private:
|
| 45 |
+
using super_t = thrust::detail::tagged_allocator<T, System, thrust::pointer<T, System>>;
|
| 46 |
+
|
| 47 |
+
System& m_system;
|
| 48 |
+
|
| 49 |
+
public:
|
| 50 |
+
using pointer = typename super_t::pointer;
|
| 51 |
+
using size_type = typename super_t::size_type;
|
| 52 |
+
|
| 53 |
+
inline _CCCL_HOST_DEVICE temporary_allocator(const temporary_allocator& other)
|
| 54 |
+
: super_t()
|
| 55 |
+
, m_system(other.m_system)
|
| 56 |
+
{}
|
| 57 |
+
|
| 58 |
+
inline _CCCL_HOST_DEVICE explicit temporary_allocator(thrust::execution_policy<System>& system)
|
| 59 |
+
: super_t()
|
| 60 |
+
, m_system(thrust::detail::derived_cast(system))
|
| 61 |
+
{}
|
| 62 |
+
|
| 63 |
+
_CCCL_HOST_DEVICE pointer allocate(size_type cnt);
|
| 64 |
+
|
| 65 |
+
_CCCL_HOST_DEVICE void deallocate(pointer p, size_type n) noexcept;
|
| 66 |
+
|
| 67 |
+
_CCCL_HOST_DEVICE inline System& system()
|
| 68 |
+
{
|
| 69 |
+
return m_system;
|
| 70 |
+
} // end system()
|
| 71 |
+
|
| 72 |
+
private:
|
| 73 |
+
using pointer_and_size = thrust::pair<pointer, size_type>;
|
| 74 |
+
}; // end temporary_allocator
|
| 75 |
+
|
| 76 |
+
} // namespace detail
|
| 77 |
+
THRUST_NAMESPACE_END
|
| 78 |
+
|
| 79 |
+
#include <thrust/detail/allocator/temporary_allocator.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/temporary_allocator.inl
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/allocator/temporary_allocator.h>
|
| 29 |
+
#include <thrust/detail/temporary_buffer.h>
|
| 30 |
+
#include <thrust/system/detail/bad_alloc.h>
|
| 31 |
+
|
| 32 |
+
#include <cassert>
|
| 33 |
+
|
| 34 |
+
#include <nv/target>
|
| 35 |
+
|
| 36 |
+
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
|
| 37 |
+
# if (defined(_NVHPC_CUDA) || defined(__CUDA_ARCH__))
|
| 38 |
+
# include <thrust/system/cuda/detail/terminate.h>
|
| 39 |
+
# endif // NVCC device pass or NVC++
|
| 40 |
+
#endif // CUDA
|
| 41 |
+
|
| 42 |
+
THRUST_NAMESPACE_BEGIN
|
| 43 |
+
namespace detail
|
| 44 |
+
{
|
| 45 |
+
|
| 46 |
+
template <typename T, typename System>
|
| 47 |
+
_CCCL_HOST_DEVICE typename temporary_allocator<T, System>::pointer
|
| 48 |
+
temporary_allocator<T, System>::allocate(typename temporary_allocator<T, System>::size_type cnt)
|
| 49 |
+
{
|
| 50 |
+
pointer_and_size result = thrust::get_temporary_buffer<T>(system(), cnt);
|
| 51 |
+
|
| 52 |
+
// handle failure
|
| 53 |
+
if (result.second < cnt)
|
| 54 |
+
{
|
| 55 |
+
// deallocate and throw
|
| 56 |
+
// note that we pass cnt to deallocate, not a value derived from result.second
|
| 57 |
+
deallocate(result.first, cnt);
|
| 58 |
+
|
| 59 |
+
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
|
| 60 |
+
NV_IF_TARGET(NV_IS_HOST,
|
| 61 |
+
(throw thrust::system::detail::bad_alloc("temporary_buffer::allocate: get_temporary_buffer failed");),
|
| 62 |
+
( // NV_IS_DEVICE
|
| 63 |
+
thrust::system::cuda::detail::terminate_with_message("temporary_buffer::allocate: "
|
| 64 |
+
"get_temporary_buffer failed");));
|
| 65 |
+
#else
|
| 66 |
+
throw thrust::system::detail::bad_alloc("temporary_buffer::allocate: get_temporary_buffer failed");
|
| 67 |
+
#endif
|
| 68 |
+
} // end if
|
| 69 |
+
|
| 70 |
+
return result.first;
|
| 71 |
+
} // end temporary_allocator::allocate()
|
| 72 |
+
|
| 73 |
+
template <typename T, typename System>
|
| 74 |
+
_CCCL_HOST_DEVICE void temporary_allocator<T, System>::deallocate(
|
| 75 |
+
typename temporary_allocator<T, System>::pointer p, typename temporary_allocator<T, System>::size_type n) noexcept
|
| 76 |
+
{
|
| 77 |
+
return thrust::return_temporary_buffer(system(), p, n);
|
| 78 |
+
} // end temporary_allocator
|
| 79 |
+
|
| 80 |
+
} // namespace detail
|
| 81 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/value_initialize_range.h
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
THRUST_NAMESPACE_BEGIN
|
| 30 |
+
namespace detail
|
| 31 |
+
{
|
| 32 |
+
|
| 33 |
+
template <typename Allocator, typename Pointer, typename Size>
|
| 34 |
+
_CCCL_HOST_DEVICE inline void value_initialize_range(Allocator& a, Pointer p, Size n);
|
| 35 |
+
|
| 36 |
+
} // namespace detail
|
| 37 |
+
THRUST_NAMESPACE_END
|
| 38 |
+
|
| 39 |
+
#include <thrust/detail/allocator/value_initialize_range.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/allocator/value_initialize_range.inl
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/allocator/allocator_traits.h>
|
| 29 |
+
#include <thrust/detail/type_traits.h>
|
| 30 |
+
#include <thrust/detail/type_traits/pointer_traits.h>
|
| 31 |
+
#include <thrust/for_each.h>
|
| 32 |
+
#include <thrust/uninitialized_fill.h>
|
| 33 |
+
|
| 34 |
+
THRUST_NAMESPACE_BEGIN
|
| 35 |
+
namespace detail
|
| 36 |
+
{
|
| 37 |
+
namespace allocator_traits_detail
|
| 38 |
+
{
|
| 39 |
+
|
| 40 |
+
template <typename Allocator>
|
| 41 |
+
struct construct1_via_allocator
|
| 42 |
+
{
|
| 43 |
+
Allocator& a;
|
| 44 |
+
|
| 45 |
+
_CCCL_HOST_DEVICE construct1_via_allocator(Allocator& a)
|
| 46 |
+
: a(a)
|
| 47 |
+
{}
|
| 48 |
+
|
| 49 |
+
template <typename T>
|
| 50 |
+
inline _CCCL_HOST_DEVICE void operator()(T& x)
|
| 51 |
+
{
|
| 52 |
+
allocator_traits<Allocator>::construct(a, &x);
|
| 53 |
+
}
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
// we need to construct T via the allocator if...
|
| 57 |
+
template <typename Allocator, typename T>
|
| 58 |
+
struct needs_default_construct_via_allocator
|
| 59 |
+
: ::cuda::std::disjunction<has_member_construct1<Allocator, T>, // if the Allocator does something interesting
|
| 60 |
+
// or if T's default constructor does something
|
| 61 |
+
// interesting
|
| 62 |
+
thrust::detail::not_<::cuda::std::is_trivially_default_constructible<T>>>
|
| 63 |
+
{};
|
| 64 |
+
|
| 65 |
+
// we know that std::allocator::construct's only effect is to call T's
|
| 66 |
+
// default constructor, so we needn't use it for default construction
|
| 67 |
+
// unless T's constructor does something interesting
|
| 68 |
+
template <typename U, typename T>
|
| 69 |
+
struct needs_default_construct_via_allocator<std::allocator<U>, T>
|
| 70 |
+
: thrust::detail::not_<::cuda::std::is_trivially_default_constructible<T>>
|
| 71 |
+
{};
|
| 72 |
+
|
| 73 |
+
template <typename Allocator, typename Pointer, typename Size>
|
| 74 |
+
_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<
|
| 75 |
+
needs_default_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value>
|
| 76 |
+
value_initialize_range(Allocator& a, Pointer p, Size n)
|
| 77 |
+
{
|
| 78 |
+
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, construct1_via_allocator<Allocator>(a));
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
template <typename Allocator, typename Pointer, typename Size>
|
| 82 |
+
_CCCL_HOST_DEVICE
|
| 83 |
+
typename disable_if<needs_default_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value>::type
|
| 84 |
+
value_initialize_range(Allocator& a, Pointer p, Size n)
|
| 85 |
+
{
|
| 86 |
+
thrust::uninitialized_fill_n(allocator_system<Allocator>::get(a), p, n, typename pointer_element<Pointer>::type());
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
} // namespace allocator_traits_detail
|
| 90 |
+
|
| 91 |
+
template <typename Allocator, typename Pointer, typename Size>
|
| 92 |
+
_CCCL_HOST_DEVICE void value_initialize_range(Allocator& a, Pointer p, Size n)
|
| 93 |
+
{
|
| 94 |
+
return allocator_traits_detail::value_initialize_range(a, p, n);
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
} // namespace detail
|
| 98 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/catrig.h
ADDED
|
@@ -0,0 +1,875 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
* Copyright 2013 Filipe RNC Maia
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
/*-
|
| 19 |
+
* Copyright (c) 2012 Stephen Montgomery-Smith <stephen@FreeBSD.ORG>
|
| 20 |
+
* All rights reserved.
|
| 21 |
+
*
|
| 22 |
+
* Redistribution and use in source and binary forms, with or without
|
| 23 |
+
* modification, are permitted provided that the following conditions
|
| 24 |
+
* are met:
|
| 25 |
+
* 1. Redistributions of source code must retain the above copyright
|
| 26 |
+
* notice, this list of conditions and the following disclaimer.
|
| 27 |
+
* 2. Redistributions in binary form must reproduce the above copyright
|
| 28 |
+
* notice, this list of conditions and the following disclaimer in the
|
| 29 |
+
* documentation and/or other materials provided with the distribution.
|
| 30 |
+
*
|
| 31 |
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
| 32 |
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 33 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
| 34 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
| 35 |
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 36 |
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
| 37 |
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
| 38 |
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| 39 |
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
| 40 |
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
| 41 |
+
* SUCH DAMAGE.
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
/*
|
| 45 |
+
* Adapted from FreeBSD by Filipe Maia <filipe.c.maia@gmail.com>:
|
| 46 |
+
* freebsd/lib/msun/src/catrig.c
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
#pragma once
|
| 50 |
+
|
| 51 |
+
#include <thrust/detail/config.h>
|
| 52 |
+
|
| 53 |
+
#include <thrust/complex.h>
|
| 54 |
+
#include <thrust/detail/complex/math_private.h>
|
| 55 |
+
|
| 56 |
+
#include <cfloat>
|
| 57 |
+
#include <cmath>
|
| 58 |
+
|
| 59 |
+
THRUST_NAMESPACE_BEGIN
|
| 60 |
+
namespace detail
|
| 61 |
+
{
|
| 62 |
+
namespace complex
|
| 63 |
+
{
|
| 64 |
+
|
| 65 |
+
using thrust::complex;
|
| 66 |
+
|
| 67 |
+
_CCCL_HOST_DEVICE inline void raise_inexact()
|
| 68 |
+
{
|
| 69 |
+
const volatile float tiny = 7.888609052210118054117286e-31; /* 0x1p-100; */
|
| 70 |
+
// needs the volatile to prevent compiler from ignoring it
|
| 71 |
+
volatile float junk = 1 + tiny;
|
| 72 |
+
(void) junk;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
_CCCL_HOST_DEVICE inline complex<double> clog_for_large_values(complex<double> z);
|
| 76 |
+
|
| 77 |
+
/*
|
| 78 |
+
* Testing indicates that all these functions are accurate up to 4 ULP.
|
| 79 |
+
* The functions casin(h) and cacos(h) are about 2.5 times slower than asinh.
|
| 80 |
+
* The functions catan(h) are a little under 2 times slower than atanh.
|
| 81 |
+
*
|
| 82 |
+
* The code for casinh, casin, cacos, and cacosh comes first. The code is
|
| 83 |
+
* rather complicated, and the four functions are highly interdependent.
|
| 84 |
+
*
|
| 85 |
+
* The code for catanh and catan comes at the end. It is much simpler than
|
| 86 |
+
* the other functions, and the code for these can be disconnected from the
|
| 87 |
+
* rest of the code.
|
| 88 |
+
*/
|
| 89 |
+
|
| 90 |
+
/*
|
| 91 |
+
* ================================
|
| 92 |
+
* | casinh, casin, cacos, cacosh |
|
| 93 |
+
* ================================
|
| 94 |
+
*/
|
| 95 |
+
|
| 96 |
+
/*
|
| 97 |
+
* The algorithm is very close to that in "Implementing the complex arcsine
|
| 98 |
+
* and arccosine functions using exception handling" by T. E. Hull, Thomas F.
|
| 99 |
+
* Fairgrieve, and Ping Tak Peter Tang, published in ACM Transactions on
|
| 100 |
+
* Mathematical Software, Volume 23 Issue 3, 1997, Pages 299-335,
|
| 101 |
+
* http://dl.acm.org/citation.cfm?id=275324.
|
| 102 |
+
*
|
| 103 |
+
* Throughout we use the convention z = x + I*y.
|
| 104 |
+
*
|
| 105 |
+
* casinh(z) = sign(x)*log(A+sqrt(A*A-1)) + I*asin(B)
|
| 106 |
+
* where
|
| 107 |
+
* A = (|z+I| + |z-I|) / 2
|
| 108 |
+
* B = (|z+I| - |z-I|) / 2 = y/A
|
| 109 |
+
*
|
| 110 |
+
* These formulas become numerically unstable:
|
| 111 |
+
* (a) for Re(casinh(z)) when z is close to the line segment [-I, I] (that
|
| 112 |
+
* is, Re(casinh(z)) is close to 0);
|
| 113 |
+
* (b) for Im(casinh(z)) when z is close to either of the intervals
|
| 114 |
+
* [I, I*infinity) or (-I*infinity, -I] (that is, |Im(casinh(z))| is
|
| 115 |
+
* close to PI/2).
|
| 116 |
+
*
|
| 117 |
+
* These numerical problems are overcome by defining
|
| 118 |
+
* f(a, b) = (hypot(a, b) - b) / 2 = a*a / (hypot(a, b) + b) / 2
|
| 119 |
+
* Then if A < A_crossover, we use
|
| 120 |
+
* log(A + sqrt(A*A-1)) = log1p((A-1) + sqrt((A-1)*(A+1)))
|
| 121 |
+
* A-1 = f(x, 1+y) + f(x, 1-y)
|
| 122 |
+
* and if B > B_crossover, we use
|
| 123 |
+
* asin(B) = atan2(y, sqrt(A*A - y*y)) = atan2(y, sqrt((A+y)*(A-y)))
|
| 124 |
+
* A-y = f(x, y+1) + f(x, y-1)
|
| 125 |
+
* where without loss of generality we have assumed that x and y are
|
| 126 |
+
* non-negative.
|
| 127 |
+
*
|
| 128 |
+
* Much of the difficulty comes because the intermediate computations may
|
| 129 |
+
* produce overflows or underflows. This is dealt with in the paper by Hull
|
| 130 |
+
* et al by using exception handling. We do this by detecting when
|
| 131 |
+
* computations risk underflow or overflow. The hardest part is handling the
|
| 132 |
+
* underflows when computing f(a, b).
|
| 133 |
+
*
|
| 134 |
+
* Note that the function f(a, b) does not appear explicitly in the paper by
|
| 135 |
+
* Hull et al, but the idea may be found on pages 308 and 309. Introducing the
|
| 136 |
+
* function f(a, b) allows us to concentrate many of the clever tricks in this
|
| 137 |
+
* paper into one function.
|
| 138 |
+
*/
|
| 139 |
+
|
| 140 |
+
/*
|
| 141 |
+
* Function f(a, b, hypot_a_b) = (hypot(a, b) - b) / 2.
|
| 142 |
+
* Pass hypot(a, b) as the third argument.
|
| 143 |
+
*/
|
| 144 |
+
_CCCL_HOST_DEVICE inline double f(double a, double b, double hypot_a_b)
|
| 145 |
+
{
|
| 146 |
+
if (b < 0)
|
| 147 |
+
{
|
| 148 |
+
return ((hypot_a_b - b) / 2);
|
| 149 |
+
}
|
| 150 |
+
if (b == 0)
|
| 151 |
+
{
|
| 152 |
+
return (a / 2);
|
| 153 |
+
}
|
| 154 |
+
return (a * a / (hypot_a_b + b) / 2);
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
/*
|
| 158 |
+
* All the hard work is contained in this function.
|
| 159 |
+
* x and y are assumed positive or zero, and less than RECIP_EPSILON.
|
| 160 |
+
* Upon return:
|
| 161 |
+
* rx = Re(casinh(z)) = -Im(cacos(y + I*x)).
|
| 162 |
+
* B_is_usable is set to 1 if the value of B is usable.
|
| 163 |
+
* If B_is_usable is set to 0, sqrt_A2my2 = sqrt(A*A - y*y), and new_y = y.
|
| 164 |
+
* If returning sqrt_A2my2 has potential to result in an underflow, it is
|
| 165 |
+
* rescaled, and new_y is similarly rescaled.
|
| 166 |
+
*/
|
| 167 |
+
_CCCL_HOST_DEVICE inline void
|
| 168 |
+
do_hard_work(double x, double y, double* rx, int* B_is_usable, double* B, double* sqrt_A2my2, double* new_y)
|
| 169 |
+
{
|
| 170 |
+
double R, S, A; /* A, B, R, and S are as in Hull et al. */
|
| 171 |
+
double Am1, Amy; /* A-1, A-y. */
|
| 172 |
+
const double A_crossover = 10; /* Hull et al suggest 1.5, but 10 works better */
|
| 173 |
+
const double FOUR_SQRT_MIN = 5.966672584960165394632772e-154; /* =0x1p-509; >= 4 * sqrt(DBL_MIN) */
|
| 174 |
+
const double B_crossover = 0.6417; /* suggested by Hull et al */
|
| 175 |
+
|
| 176 |
+
R = hypot(x, y + 1); /* |z+I| */
|
| 177 |
+
S = hypot(x, y - 1); /* |z-I| */
|
| 178 |
+
|
| 179 |
+
/* A = (|z+I| + |z-I|) / 2 */
|
| 180 |
+
A = (R + S) / 2;
|
| 181 |
+
/*
|
| 182 |
+
* Mathematically A >= 1. There is a small chance that this will not
|
| 183 |
+
* be so because of rounding errors. So we will make certain it is
|
| 184 |
+
* so.
|
| 185 |
+
*/
|
| 186 |
+
if (A < 1)
|
| 187 |
+
{
|
| 188 |
+
A = 1;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
if (A < A_crossover)
|
| 192 |
+
{
|
| 193 |
+
/*
|
| 194 |
+
* Am1 = fp + fm, where fp = f(x, 1+y), and fm = f(x, 1-y).
|
| 195 |
+
* rx = log1p(Am1 + sqrt(Am1*(A+1)))
|
| 196 |
+
*/
|
| 197 |
+
if (y == 1 && x < DBL_EPSILON * DBL_EPSILON / 128)
|
| 198 |
+
{
|
| 199 |
+
/*
|
| 200 |
+
* fp is of order x^2, and fm = x/2.
|
| 201 |
+
* A = 1 (inexactly).
|
| 202 |
+
*/
|
| 203 |
+
*rx = sqrt(x);
|
| 204 |
+
}
|
| 205 |
+
else if (x >= DBL_EPSILON * fabs(y - 1))
|
| 206 |
+
{
|
| 207 |
+
/*
|
| 208 |
+
* Underflow will not occur because
|
| 209 |
+
* x >= DBL_EPSILON^2/128 >= FOUR_SQRT_MIN
|
| 210 |
+
*/
|
| 211 |
+
Am1 = f(x, 1 + y, R) + f(x, 1 - y, S);
|
| 212 |
+
*rx = log1p(Am1 + sqrt(Am1 * (A + 1)));
|
| 213 |
+
}
|
| 214 |
+
else if (y < 1)
|
| 215 |
+
{
|
| 216 |
+
/*
|
| 217 |
+
* fp = x*x/(1+y)/4, fm = x*x/(1-y)/4, and
|
| 218 |
+
* A = 1 (inexactly).
|
| 219 |
+
*/
|
| 220 |
+
*rx = x / sqrt((1 - y) * (1 + y));
|
| 221 |
+
}
|
| 222 |
+
else
|
| 223 |
+
{ /* if (y > 1) */
|
| 224 |
+
/*
|
| 225 |
+
* A-1 = y-1 (inexactly).
|
| 226 |
+
*/
|
| 227 |
+
*rx = log1p((y - 1) + sqrt((y - 1) * (y + 1)));
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
else
|
| 231 |
+
{
|
| 232 |
+
*rx = log(A + sqrt(A * A - 1));
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
*new_y = y;
|
| 236 |
+
|
| 237 |
+
if (y < FOUR_SQRT_MIN)
|
| 238 |
+
{
|
| 239 |
+
/*
|
| 240 |
+
* Avoid a possible underflow caused by y/A. For casinh this
|
| 241 |
+
* would be legitimate, but will be picked up by invoking atan2
|
| 242 |
+
* later on. For cacos this would not be legitimate.
|
| 243 |
+
*/
|
| 244 |
+
*B_is_usable = 0;
|
| 245 |
+
*sqrt_A2my2 = A * (2 / DBL_EPSILON);
|
| 246 |
+
*new_y = y * (2 / DBL_EPSILON);
|
| 247 |
+
return;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
/* B = (|z+I| - |z-I|) / 2 = y/A */
|
| 251 |
+
*B = y / A;
|
| 252 |
+
*B_is_usable = 1;
|
| 253 |
+
|
| 254 |
+
if (*B > B_crossover)
|
| 255 |
+
{
|
| 256 |
+
*B_is_usable = 0;
|
| 257 |
+
/*
|
| 258 |
+
* Amy = fp + fm, where fp = f(x, y+1), and fm = f(x, y-1).
|
| 259 |
+
* sqrt_A2my2 = sqrt(Amy*(A+y))
|
| 260 |
+
*/
|
| 261 |
+
if (y == 1 && x < DBL_EPSILON / 128)
|
| 262 |
+
{
|
| 263 |
+
/*
|
| 264 |
+
* fp is of order x^2, and fm = x/2.
|
| 265 |
+
* A = 1 (inexactly).
|
| 266 |
+
*/
|
| 267 |
+
*sqrt_A2my2 = sqrt(x) * sqrt((A + y) / 2);
|
| 268 |
+
}
|
| 269 |
+
else if (x >= DBL_EPSILON * fabs(y - 1))
|
| 270 |
+
{
|
| 271 |
+
/*
|
| 272 |
+
* Underflow will not occur because
|
| 273 |
+
* x >= DBL_EPSILON/128 >= FOUR_SQRT_MIN
|
| 274 |
+
* and
|
| 275 |
+
* x >= DBL_EPSILON^2 >= FOUR_SQRT_MIN
|
| 276 |
+
*/
|
| 277 |
+
Amy = f(x, y + 1, R) + f(x, y - 1, S);
|
| 278 |
+
*sqrt_A2my2 = sqrt(Amy * (A + y));
|
| 279 |
+
}
|
| 280 |
+
else if (y > 1)
|
| 281 |
+
{
|
| 282 |
+
/*
|
| 283 |
+
* fp = x*x/(y+1)/4, fm = x*x/(y-1)/4, and
|
| 284 |
+
* A = y (inexactly).
|
| 285 |
+
*
|
| 286 |
+
* y < RECIP_EPSILON. So the following
|
| 287 |
+
* scaling should avoid any underflow problems.
|
| 288 |
+
*/
|
| 289 |
+
*sqrt_A2my2 = x * (4 / DBL_EPSILON / DBL_EPSILON) * y / sqrt((y + 1) * (y - 1));
|
| 290 |
+
*new_y = y * (4 / DBL_EPSILON / DBL_EPSILON);
|
| 291 |
+
}
|
| 292 |
+
else
|
| 293 |
+
{ /* if (y < 1) */
|
| 294 |
+
/*
|
| 295 |
+
* fm = 1-y >= DBL_EPSILON, fp is of order x^2, and
|
| 296 |
+
* A = 1 (inexactly).
|
| 297 |
+
*/
|
| 298 |
+
*sqrt_A2my2 = sqrt((1 - y) * (1 + y));
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
/*
|
| 304 |
+
* casinh(z) = z + O(z^3) as z -> 0
|
| 305 |
+
*
|
| 306 |
+
* casinh(z) = sign(x)*clog(sign(x)*z) + O(1/z^2) as z -> infinity
|
| 307 |
+
* The above formula works for the imaginary part as well, because
|
| 308 |
+
* Im(casinh(z)) = sign(x)*atan2(sign(x)*y, fabs(x)) + O(y/z^3)
|
| 309 |
+
* as z -> infinity, uniformly in y
|
| 310 |
+
*/
|
| 311 |
+
_CCCL_HOST_DEVICE inline complex<double> casinh(complex<double> z)
|
| 312 |
+
{
|
| 313 |
+
double x, y, ax, ay, rx, ry, B, sqrt_A2my2, new_y;
|
| 314 |
+
int B_is_usable;
|
| 315 |
+
complex<double> w;
|
| 316 |
+
const double RECIP_EPSILON = 1.0 / DBL_EPSILON;
|
| 317 |
+
const double m_ln2 = 6.9314718055994531e-1; /* 0x162e42fefa39ef.0p-53 */
|
| 318 |
+
x = z.real();
|
| 319 |
+
y = z.imag();
|
| 320 |
+
ax = fabs(x);
|
| 321 |
+
ay = fabs(y);
|
| 322 |
+
|
| 323 |
+
if (isnan(x) || isnan(y))
|
| 324 |
+
{
|
| 325 |
+
/* casinh(+-Inf + I*NaN) = +-Inf + I*NaN */
|
| 326 |
+
if (isinf(x))
|
| 327 |
+
{
|
| 328 |
+
return (complex<double>(x, y + y));
|
| 329 |
+
}
|
| 330 |
+
/* casinh(NaN + I*+-Inf) = opt(+-)Inf + I*NaN */
|
| 331 |
+
if (isinf(y))
|
| 332 |
+
{
|
| 333 |
+
return (complex<double>(y, x + x));
|
| 334 |
+
}
|
| 335 |
+
/* casinh(NaN + I*0) = NaN + I*0 */
|
| 336 |
+
if (y == 0)
|
| 337 |
+
{
|
| 338 |
+
return (complex<double>(x + x, y));
|
| 339 |
+
}
|
| 340 |
+
/*
|
| 341 |
+
* All other cases involving NaN return NaN + I*NaN.
|
| 342 |
+
* C99 leaves it optional whether to raise invalid if one of
|
| 343 |
+
* the arguments is not NaN, so we opt not to raise it.
|
| 344 |
+
*/
|
| 345 |
+
return (complex<double>(x + 0.0 + (y + 0.0), x + 0.0 + (y + 0.0)));
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
if (ax > RECIP_EPSILON || ay > RECIP_EPSILON)
|
| 349 |
+
{
|
| 350 |
+
/* clog...() will raise inexact unless x or y is infinite. */
|
| 351 |
+
if (signbit(x) == 0)
|
| 352 |
+
{
|
| 353 |
+
w = clog_for_large_values(z) + m_ln2;
|
| 354 |
+
}
|
| 355 |
+
else
|
| 356 |
+
{
|
| 357 |
+
w = clog_for_large_values(-z) + m_ln2;
|
| 358 |
+
}
|
| 359 |
+
return (complex<double>(copysign(w.real(), x), copysign(w.imag(), y)));
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
/* Avoid spuriously raising inexact for z = 0. */
|
| 363 |
+
if (x == 0 && y == 0)
|
| 364 |
+
{
|
| 365 |
+
return (z);
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
/* All remaining cases are inexact. */
|
| 369 |
+
raise_inexact();
|
| 370 |
+
|
| 371 |
+
const double SQRT_6_EPSILON = 3.6500241499888571e-8; /* 0x13988e1409212e.0p-77 */
|
| 372 |
+
if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4)
|
| 373 |
+
{
|
| 374 |
+
return (z);
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
do_hard_work(ax, ay, &rx, &B_is_usable, &B, &sqrt_A2my2, &new_y);
|
| 378 |
+
if (B_is_usable)
|
| 379 |
+
{
|
| 380 |
+
ry = asin(B);
|
| 381 |
+
}
|
| 382 |
+
else
|
| 383 |
+
{
|
| 384 |
+
ry = atan2(new_y, sqrt_A2my2);
|
| 385 |
+
}
|
| 386 |
+
return (complex<double>(copysign(rx, x), copysign(ry, y)));
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
/*
|
| 390 |
+
* casin(z) = reverse(casinh(reverse(z)))
|
| 391 |
+
* where reverse(x + I*y) = y + I*x = I*conj(z).
|
| 392 |
+
*/
|
| 393 |
+
_CCCL_HOST_DEVICE inline complex<double> casin(complex<double> z)
|
| 394 |
+
{
|
| 395 |
+
complex<double> w = casinh(complex<double>(z.imag(), z.real()));
|
| 396 |
+
|
| 397 |
+
return (complex<double>(w.imag(), w.real()));
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
/*
|
| 401 |
+
* cacos(z) = PI/2 - casin(z)
|
| 402 |
+
* but do the computation carefully so cacos(z) is accurate when z is
|
| 403 |
+
* close to 1.
|
| 404 |
+
*
|
| 405 |
+
* cacos(z) = PI/2 - z + O(z^3) as z -> 0
|
| 406 |
+
*
|
| 407 |
+
* cacos(z) = -sign(y)*I*clog(z) + O(1/z^2) as z -> infinity
|
| 408 |
+
* The above formula works for the real part as well, because
|
| 409 |
+
* Re(cacos(z)) = atan2(fabs(y), x) + O(y/z^3)
|
| 410 |
+
* as z -> infinity, uniformly in y
|
| 411 |
+
*/
|
| 412 |
+
_CCCL_HOST_DEVICE inline complex<double> cacos(complex<double> z)
|
| 413 |
+
{
|
| 414 |
+
double x, y, ax, ay, rx, ry, B, sqrt_A2mx2, new_x;
|
| 415 |
+
int sx, sy;
|
| 416 |
+
int B_is_usable;
|
| 417 |
+
complex<double> w;
|
| 418 |
+
const double pio2_hi = 1.5707963267948966e0; /* 0x1921fb54442d18.0p-52 */
|
| 419 |
+
const volatile double pio2_lo = 6.1232339957367659e-17; /* 0x11a62633145c07.0p-106 */
|
| 420 |
+
const double m_ln2 = 6.9314718055994531e-1; /* 0x162e42fefa39ef.0p-53 */
|
| 421 |
+
|
| 422 |
+
x = z.real();
|
| 423 |
+
y = z.imag();
|
| 424 |
+
sx = signbit(x);
|
| 425 |
+
sy = signbit(y);
|
| 426 |
+
ax = fabs(x);
|
| 427 |
+
ay = fabs(y);
|
| 428 |
+
|
| 429 |
+
if (isnan(x) || isnan(y))
|
| 430 |
+
{
|
| 431 |
+
/* cacos(+-Inf + I*NaN) = NaN + I*opt(-)Inf */
|
| 432 |
+
if (isinf(x))
|
| 433 |
+
{
|
| 434 |
+
return (complex<double>(y + y, -infinity<double>()));
|
| 435 |
+
}
|
| 436 |
+
/* cacos(NaN + I*+-Inf) = NaN + I*-+Inf */
|
| 437 |
+
if (isinf(y))
|
| 438 |
+
{
|
| 439 |
+
return (complex<double>(x + x, -y));
|
| 440 |
+
}
|
| 441 |
+
/* cacos(0 + I*NaN) = PI/2 + I*NaN with inexact */
|
| 442 |
+
if (x == 0)
|
| 443 |
+
{
|
| 444 |
+
return (complex<double>(pio2_hi + pio2_lo, y + y));
|
| 445 |
+
}
|
| 446 |
+
/*
|
| 447 |
+
* All other cases involving NaN return NaN + I*NaN.
|
| 448 |
+
* C99 leaves it optional whether to raise invalid if one of
|
| 449 |
+
* the arguments is not NaN, so we opt not to raise it.
|
| 450 |
+
*/
|
| 451 |
+
return (complex<double>(x + 0.0 + (y + 0), x + 0.0 + (y + 0)));
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
const double RECIP_EPSILON = 1.0 / DBL_EPSILON;
|
| 455 |
+
if (ax > RECIP_EPSILON || ay > RECIP_EPSILON)
|
| 456 |
+
{
|
| 457 |
+
/* clog...() will raise inexact unless x or y is infinite. */
|
| 458 |
+
w = clog_for_large_values(z);
|
| 459 |
+
rx = fabs(w.imag());
|
| 460 |
+
ry = w.real() + m_ln2;
|
| 461 |
+
if (sy == 0)
|
| 462 |
+
{
|
| 463 |
+
ry = -ry;
|
| 464 |
+
}
|
| 465 |
+
return (complex<double>(rx, ry));
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
/* Avoid spuriously raising inexact for z = 1. */
|
| 469 |
+
if (x == 1.0 && y == 0.0)
|
| 470 |
+
{
|
| 471 |
+
return (complex<double>(0, -y));
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
/* All remaining cases are inexact. */
|
| 475 |
+
raise_inexact();
|
| 476 |
+
|
| 477 |
+
const double SQRT_6_EPSILON = 3.6500241499888571e-8; /* 0x13988e1409212e.0p-77 */
|
| 478 |
+
if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4)
|
| 479 |
+
{
|
| 480 |
+
return (complex<double>(pio2_hi - (x - pio2_lo), -y));
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
do_hard_work(ay, ax, &ry, &B_is_usable, &B, &sqrt_A2mx2, &new_x);
|
| 484 |
+
if (B_is_usable)
|
| 485 |
+
{
|
| 486 |
+
if (sx == 0)
|
| 487 |
+
{
|
| 488 |
+
rx = acos(B);
|
| 489 |
+
}
|
| 490 |
+
else
|
| 491 |
+
{
|
| 492 |
+
rx = acos(-B);
|
| 493 |
+
}
|
| 494 |
+
}
|
| 495 |
+
else
|
| 496 |
+
{
|
| 497 |
+
if (sx == 0)
|
| 498 |
+
{
|
| 499 |
+
rx = atan2(sqrt_A2mx2, new_x);
|
| 500 |
+
}
|
| 501 |
+
else
|
| 502 |
+
{
|
| 503 |
+
rx = atan2(sqrt_A2mx2, -new_x);
|
| 504 |
+
}
|
| 505 |
+
}
|
| 506 |
+
if (sy == 0)
|
| 507 |
+
{
|
| 508 |
+
ry = -ry;
|
| 509 |
+
}
|
| 510 |
+
return (complex<double>(rx, ry));
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
/*
|
| 514 |
+
* cacosh(z) = I*cacos(z) or -I*cacos(z)
|
| 515 |
+
* where the sign is chosen so Re(cacosh(z)) >= 0.
|
| 516 |
+
*/
|
| 517 |
+
_CCCL_HOST_DEVICE inline complex<double> cacosh(complex<double> z)
|
| 518 |
+
{
|
| 519 |
+
complex<double> w;
|
| 520 |
+
double rx, ry;
|
| 521 |
+
|
| 522 |
+
w = cacos(z);
|
| 523 |
+
rx = w.real();
|
| 524 |
+
ry = w.imag();
|
| 525 |
+
/* cacosh(NaN + I*NaN) = NaN + I*NaN */
|
| 526 |
+
if (isnan(rx) && isnan(ry))
|
| 527 |
+
{
|
| 528 |
+
return (complex<double>(ry, rx));
|
| 529 |
+
}
|
| 530 |
+
/* cacosh(NaN + I*+-Inf) = +Inf + I*NaN */
|
| 531 |
+
/* cacosh(+-Inf + I*NaN) = +Inf + I*NaN */
|
| 532 |
+
if (isnan(rx))
|
| 533 |
+
{
|
| 534 |
+
return (complex<double>(fabs(ry), rx));
|
| 535 |
+
}
|
| 536 |
+
/* cacosh(0 + I*NaN) = NaN + I*NaN */
|
| 537 |
+
if (isnan(ry))
|
| 538 |
+
{
|
| 539 |
+
return (complex<double>(ry, ry));
|
| 540 |
+
}
|
| 541 |
+
return (complex<double>(fabs(ry), copysign(rx, z.imag())));
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
/*
|
| 545 |
+
* Optimized version of clog() for |z| finite and larger than ~RECIP_EPSILON.
|
| 546 |
+
*/
|
| 547 |
+
_CCCL_HOST_DEVICE inline complex<double> clog_for_large_values(complex<double> z)
|
| 548 |
+
{
|
| 549 |
+
double x, y;
|
| 550 |
+
double ax, ay, t;
|
| 551 |
+
const double m_e = 2.7182818284590452e0; /* 0x15bf0a8b145769.0p-51 */
|
| 552 |
+
|
| 553 |
+
x = z.real();
|
| 554 |
+
y = z.imag();
|
| 555 |
+
ax = fabs(x);
|
| 556 |
+
ay = fabs(y);
|
| 557 |
+
if (ax < ay)
|
| 558 |
+
{
|
| 559 |
+
t = ax;
|
| 560 |
+
ax = ay;
|
| 561 |
+
ay = t;
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
/*
|
| 565 |
+
* Avoid overflow in hypot() when x and y are both very large.
|
| 566 |
+
* Divide x and y by E, and then add 1 to the logarithm. This depends
|
| 567 |
+
* on E being larger than sqrt(2).
|
| 568 |
+
* Dividing by E causes an insignificant loss of accuracy; however
|
| 569 |
+
* this method is still poor since it is unnecessarily slow.
|
| 570 |
+
*/
|
| 571 |
+
if (ax > DBL_MAX / 2)
|
| 572 |
+
{
|
| 573 |
+
return (complex<double>(log(hypot(x / m_e, y / m_e)) + 1, atan2(y, x)));
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
/*
|
| 577 |
+
* Avoid overflow when x or y is large. Avoid underflow when x or
|
| 578 |
+
* y is small.
|
| 579 |
+
*/
|
| 580 |
+
const double QUARTER_SQRT_MAX = 5.966672584960165394632772e-154; /* = 0x1p509; <= sqrt(DBL_MAX) / 4 */
|
| 581 |
+
const double SQRT_MIN = 1.491668146240041348658193e-154; /* = 0x1p-511; >= sqrt(DBL_MIN) */
|
| 582 |
+
if (ax > QUARTER_SQRT_MAX || ay < SQRT_MIN)
|
| 583 |
+
{
|
| 584 |
+
return (complex<double>(log(hypot(x, y)), atan2(y, x)));
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
return (complex<double>(log(ax * ax + ay * ay) / 2, atan2(y, x)));
|
| 588 |
+
}
|
| 589 |
+
|
| 590 |
+
/*
|
| 591 |
+
* =================
|
| 592 |
+
* | catanh, catan |
|
| 593 |
+
* =================
|
| 594 |
+
*/
|
| 595 |
+
|
| 596 |
+
/*
|
| 597 |
+
* sum_squares(x,y) = x*x + y*y (or just x*x if y*y would underflow).
|
| 598 |
+
* Assumes x*x and y*y will not overflow.
|
| 599 |
+
* Assumes x and y are finite.
|
| 600 |
+
* Assumes y is non-negative.
|
| 601 |
+
* Assumes fabs(x) >= DBL_EPSILON.
|
| 602 |
+
*/
|
| 603 |
+
_CCCL_HOST_DEVICE inline double sum_squares(double x, double y)
|
| 604 |
+
{
|
| 605 |
+
const double SQRT_MIN = 1.491668146240041348658193e-154; /* = 0x1p-511; >= sqrt(DBL_MIN) */
|
| 606 |
+
/* Avoid underflow when y is small. */
|
| 607 |
+
if (y < SQRT_MIN)
|
| 608 |
+
{
|
| 609 |
+
return (x * x);
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
return (x * x + y * y);
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
/*
|
| 616 |
+
* real_part_reciprocal(x, y) = Re(1/(x+I*y)) = x/(x*x + y*y).
|
| 617 |
+
* Assumes x and y are not NaN, and one of x and y is larger than
|
| 618 |
+
* RECIP_EPSILON. We avoid unwarranted underflow. It is important to not use
|
| 619 |
+
* the code creal(1/z), because the imaginary part may produce an unwanted
|
| 620 |
+
* underflow.
|
| 621 |
+
* This is only called in a context where inexact is always raised before
|
| 622 |
+
* the call, so no effort is made to avoid or force inexact.
|
| 623 |
+
*/
|
| 624 |
+
_CCCL_HOST_DEVICE inline double real_part_reciprocal(double x, double y)
|
| 625 |
+
{
|
| 626 |
+
double scale;
|
| 627 |
+
uint32_t hx, hy;
|
| 628 |
+
int32_t ix, iy;
|
| 629 |
+
|
| 630 |
+
/*
|
| 631 |
+
* This code is inspired by the C99 document n1124.pdf, Section G.5.1,
|
| 632 |
+
* example 2.
|
| 633 |
+
*/
|
| 634 |
+
get_high_word(hx, x);
|
| 635 |
+
ix = hx & 0x7ff00000;
|
| 636 |
+
get_high_word(hy, y);
|
| 637 |
+
iy = hy & 0x7ff00000;
|
| 638 |
+
// #define BIAS (DBL_MAX_EXP - 1)
|
| 639 |
+
const int BIAS = DBL_MAX_EXP - 1;
|
| 640 |
+
/* XXX more guard digits are useful iff there is extra precision. */
|
| 641 |
+
// #define CUTOFF (DBL_MANT_DIG / 2 + 1) /* just half or 1 guard digit */
|
| 642 |
+
const int CUTOFF = (DBL_MANT_DIG / 2 + 1);
|
| 643 |
+
if (ix - iy >= CUTOFF << 20 || isinf(x))
|
| 644 |
+
{
|
| 645 |
+
return (1 / x); /* +-Inf -> +-0 is special */
|
| 646 |
+
}
|
| 647 |
+
if (iy - ix >= CUTOFF << 20)
|
| 648 |
+
{
|
| 649 |
+
return (x / y / y); /* should avoid double div, but hard */
|
| 650 |
+
}
|
| 651 |
+
if (ix <= (BIAS + DBL_MAX_EXP / 2 - CUTOFF) << 20)
|
| 652 |
+
{
|
| 653 |
+
return (x / (x * x + y * y));
|
| 654 |
+
}
|
| 655 |
+
scale = 1;
|
| 656 |
+
set_high_word(scale, 0x7ff00000 - ix); /* 2**(1-ilogb(x)) */
|
| 657 |
+
x *= scale;
|
| 658 |
+
y *= scale;
|
| 659 |
+
return (x / (x * x + y * y) * scale);
|
| 660 |
+
}
|
| 661 |
+
|
| 662 |
+
/*
|
| 663 |
+
* catanh(z) = log((1+z)/(1-z)) / 2
|
| 664 |
+
* = log1p(4*x / |z-1|^2) / 4
|
| 665 |
+
* + I * atan2(2*y, (1-x)*(1+x)-y*y) / 2
|
| 666 |
+
*
|
| 667 |
+
* catanh(z) = z + O(z^3) as z -> 0
|
| 668 |
+
*
|
| 669 |
+
* catanh(z) = 1/z + sign(y)*I*PI/2 + O(1/z^3) as z -> infinity
|
| 670 |
+
* The above formula works for the real part as well, because
|
| 671 |
+
* Re(catanh(z)) = x/|z|^2 + O(x/z^4)
|
| 672 |
+
* as z -> infinity, uniformly in x
|
| 673 |
+
*/
|
| 674 |
+
_CCCL_HOST_DEVICE inline complex<double> catanh(complex<double> z)
|
| 675 |
+
{
|
| 676 |
+
double x, y, ax, ay, rx, ry;
|
| 677 |
+
const volatile double pio2_lo = 6.1232339957367659e-17; /* 0x11a62633145c07.0p-106 */
|
| 678 |
+
const double pio2_hi = 1.5707963267948966e0; /* 0x1921fb54442d18.0p-52 */
|
| 679 |
+
|
| 680 |
+
x = z.real();
|
| 681 |
+
y = z.imag();
|
| 682 |
+
ax = fabs(x);
|
| 683 |
+
ay = fabs(y);
|
| 684 |
+
|
| 685 |
+
/* This helps handle many cases. */
|
| 686 |
+
if (y == 0 && ax <= 1)
|
| 687 |
+
{
|
| 688 |
+
return (complex<double>(atanh(x), y));
|
| 689 |
+
}
|
| 690 |
+
|
| 691 |
+
/* To ensure the same accuracy as atan(), and to filter out z = 0. */
|
| 692 |
+
if (x == 0)
|
| 693 |
+
{
|
| 694 |
+
return (complex<double>(x, atan(y)));
|
| 695 |
+
}
|
| 696 |
+
|
| 697 |
+
if (isnan(x) || isnan(y))
|
| 698 |
+
{
|
| 699 |
+
/* catanh(+-Inf + I*NaN) = +-0 + I*NaN */
|
| 700 |
+
if (isinf(x))
|
| 701 |
+
{
|
| 702 |
+
return (complex<double>(copysign(0.0, x), y + y));
|
| 703 |
+
}
|
| 704 |
+
/* catanh(NaN + I*+-Inf) = sign(NaN)0 + I*+-PI/2 */
|
| 705 |
+
if (isinf(y))
|
| 706 |
+
{
|
| 707 |
+
return (complex<double>(copysign(0.0, x), copysign(pio2_hi + pio2_lo, y)));
|
| 708 |
+
}
|
| 709 |
+
/*
|
| 710 |
+
* All other cases involving NaN return NaN + I*NaN.
|
| 711 |
+
* C99 leaves it optional whether to raise invalid if one of
|
| 712 |
+
* the arguments is not NaN, so we opt not to raise it.
|
| 713 |
+
*/
|
| 714 |
+
return (complex<double>(x + 0.0 + (y + 0), x + 0.0 + (y + 0)));
|
| 715 |
+
}
|
| 716 |
+
|
| 717 |
+
const double RECIP_EPSILON = 1.0 / DBL_EPSILON;
|
| 718 |
+
if (ax > RECIP_EPSILON || ay > RECIP_EPSILON)
|
| 719 |
+
{
|
| 720 |
+
return (complex<double>(real_part_reciprocal(x, y), copysign(pio2_hi + pio2_lo, y)));
|
| 721 |
+
}
|
| 722 |
+
|
| 723 |
+
const double SQRT_3_EPSILON = 2.5809568279517849e-8; /* 0x1bb67ae8584caa.0p-78 */
|
| 724 |
+
if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2)
|
| 725 |
+
{
|
| 726 |
+
/*
|
| 727 |
+
* z = 0 was filtered out above. All other cases must raise
|
| 728 |
+
* inexact, but this is the only only that needs to do it
|
| 729 |
+
* explicitly.
|
| 730 |
+
*/
|
| 731 |
+
raise_inexact();
|
| 732 |
+
return (z);
|
| 733 |
+
}
|
| 734 |
+
|
| 735 |
+
const double m_ln2 = 6.9314718055994531e-1; /* 0x162e42fefa39ef.0p-53 */
|
| 736 |
+
if (ax == 1 && ay < DBL_EPSILON)
|
| 737 |
+
{
|
| 738 |
+
rx = (m_ln2 - log(ay)) / 2;
|
| 739 |
+
}
|
| 740 |
+
else
|
| 741 |
+
{
|
| 742 |
+
rx = log1p(4 * ax / sum_squares(ax - 1, ay)) / 4;
|
| 743 |
+
}
|
| 744 |
+
|
| 745 |
+
if (ax == 1)
|
| 746 |
+
{
|
| 747 |
+
ry = atan2(2.0, -ay) / 2;
|
| 748 |
+
}
|
| 749 |
+
else if (ay < DBL_EPSILON)
|
| 750 |
+
{
|
| 751 |
+
ry = atan2(2 * ay, (1 - ax) * (1 + ax)) / 2;
|
| 752 |
+
}
|
| 753 |
+
else
|
| 754 |
+
{
|
| 755 |
+
ry = atan2(2 * ay, (1 - ax) * (1 + ax) - ay * ay) / 2;
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
return (complex<double>(copysign(rx, x), copysign(ry, y)));
|
| 759 |
+
}
|
| 760 |
+
|
| 761 |
+
/*
|
| 762 |
+
* catan(z) = reverse(catanh(reverse(z)))
|
| 763 |
+
* where reverse(x + I*y) = y + I*x = I*conj(z).
|
| 764 |
+
*/
|
| 765 |
+
_CCCL_HOST_DEVICE inline complex<double> catan(complex<double> z)
|
| 766 |
+
{
|
| 767 |
+
complex<double> w = catanh(complex<double>(z.imag(), z.real()));
|
| 768 |
+
return (complex<double>(w.imag(), w.real()));
|
| 769 |
+
}
|
| 770 |
+
|
| 771 |
+
} // namespace complex
|
| 772 |
+
|
| 773 |
+
} // namespace detail
|
| 774 |
+
|
| 775 |
+
template <typename ValueType>
|
| 776 |
+
_CCCL_HOST_DEVICE inline complex<ValueType> acos(const complex<ValueType>& z)
|
| 777 |
+
{
|
| 778 |
+
const complex<ValueType> ret = thrust::asin(z);
|
| 779 |
+
const ValueType pi = ValueType(3.14159265358979323846);
|
| 780 |
+
return complex<ValueType>(pi / 2 - ret.real(), -ret.imag());
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
template <typename ValueType>
|
| 784 |
+
_CCCL_HOST_DEVICE inline complex<ValueType> asin(const complex<ValueType>& z)
|
| 785 |
+
{
|
| 786 |
+
const complex<ValueType> i(0, 1);
|
| 787 |
+
return -i * asinh(i * z);
|
| 788 |
+
}
|
| 789 |
+
|
| 790 |
+
template <typename ValueType>
|
| 791 |
+
_CCCL_HOST_DEVICE inline complex<ValueType> atan(const complex<ValueType>& z)
|
| 792 |
+
{
|
| 793 |
+
const complex<ValueType> i(0, 1);
|
| 794 |
+
return -i * thrust::atanh(i * z);
|
| 795 |
+
}
|
| 796 |
+
|
| 797 |
+
template <typename ValueType>
|
| 798 |
+
_CCCL_HOST_DEVICE inline complex<ValueType> acosh(const complex<ValueType>& z)
|
| 799 |
+
{
|
| 800 |
+
thrust::complex<ValueType> ret(
|
| 801 |
+
(z.real() - z.imag()) * (z.real() + z.imag()) - ValueType(1.0), ValueType(2.0) * z.real() * z.imag());
|
| 802 |
+
ret = thrust::sqrt(ret);
|
| 803 |
+
if (z.real() < ValueType(0.0))
|
| 804 |
+
{
|
| 805 |
+
ret = -ret;
|
| 806 |
+
}
|
| 807 |
+
ret += z;
|
| 808 |
+
ret = thrust::log(ret);
|
| 809 |
+
if (ret.real() < ValueType(0.0))
|
| 810 |
+
{
|
| 811 |
+
ret = -ret;
|
| 812 |
+
}
|
| 813 |
+
return ret;
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
+
template <typename ValueType>
|
| 817 |
+
_CCCL_HOST_DEVICE inline complex<ValueType> asinh(const complex<ValueType>& z)
|
| 818 |
+
{
|
| 819 |
+
return thrust::log(thrust::sqrt(z * z + ValueType(1)) + z);
|
| 820 |
+
}
|
| 821 |
+
|
| 822 |
+
template <typename ValueType>
|
| 823 |
+
_CCCL_HOST_DEVICE inline complex<ValueType> atanh(const complex<ValueType>& z)
|
| 824 |
+
{
|
| 825 |
+
ValueType imag2 = z.imag() * z.imag();
|
| 826 |
+
ValueType n = ValueType(1.0) + z.real();
|
| 827 |
+
n = imag2 + n * n;
|
| 828 |
+
|
| 829 |
+
ValueType d = ValueType(1.0) - z.real();
|
| 830 |
+
d = imag2 + d * d;
|
| 831 |
+
complex<ValueType> ret(ValueType(0.25) * (std::log(n) - std::log(d)), 0);
|
| 832 |
+
|
| 833 |
+
d = ValueType(1.0) - z.real() * z.real() - imag2;
|
| 834 |
+
|
| 835 |
+
ret.imag(ValueType(0.5) * std::atan2(ValueType(2.0) * z.imag(), d));
|
| 836 |
+
return ret;
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
template <>
|
| 840 |
+
_CCCL_HOST_DEVICE inline complex<double> acos(const complex<double>& z)
|
| 841 |
+
{
|
| 842 |
+
return detail::complex::cacos(z);
|
| 843 |
+
}
|
| 844 |
+
|
| 845 |
+
template <>
|
| 846 |
+
_CCCL_HOST_DEVICE inline complex<double> asin(const complex<double>& z)
|
| 847 |
+
{
|
| 848 |
+
return detail::complex::casin(z);
|
| 849 |
+
}
|
| 850 |
+
|
| 851 |
+
template <>
|
| 852 |
+
_CCCL_HOST_DEVICE inline complex<double> atan(const complex<double>& z)
|
| 853 |
+
{
|
| 854 |
+
return detail::complex::catan(z);
|
| 855 |
+
}
|
| 856 |
+
|
| 857 |
+
template <>
|
| 858 |
+
_CCCL_HOST_DEVICE inline complex<double> acosh(const complex<double>& z)
|
| 859 |
+
{
|
| 860 |
+
return detail::complex::cacosh(z);
|
| 861 |
+
}
|
| 862 |
+
|
| 863 |
+
template <>
|
| 864 |
+
_CCCL_HOST_DEVICE inline complex<double> asinh(const complex<double>& z)
|
| 865 |
+
{
|
| 866 |
+
return detail::complex::casinh(z);
|
| 867 |
+
}
|
| 868 |
+
|
| 869 |
+
template <>
|
| 870 |
+
_CCCL_HOST_DEVICE inline complex<double> atanh(const complex<double>& z)
|
| 871 |
+
{
|
| 872 |
+
return detail::complex::catanh(z);
|
| 873 |
+
}
|
| 874 |
+
|
| 875 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/cexp.h
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
* Copyright 2013 Filipe RNC Maia
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
/*-
|
| 19 |
+
* Copyright (c) 2011 David Schultz <das@FreeBSD.ORG>
|
| 20 |
+
* All rights reserved.
|
| 21 |
+
*
|
| 22 |
+
* Redistribution and use in source and binary forms, with or without
|
| 23 |
+
* modification, are permitted provided that the following conditions
|
| 24 |
+
* are met:
|
| 25 |
+
* 1. Redistributions of source code must retain the above copyright
|
| 26 |
+
* notice, this list of conditions and the following disclaimer.
|
| 27 |
+
* 2. Redistributions in binary form must reproduce the above copyright
|
| 28 |
+
* notice, this list of conditions and the following disclaimer in the
|
| 29 |
+
* documentation and/or other materials provided with the distribution.
|
| 30 |
+
*
|
| 31 |
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
| 32 |
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 33 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
| 34 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
| 35 |
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 36 |
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
| 37 |
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
| 38 |
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| 39 |
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
| 40 |
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
| 41 |
+
* SUCH DAMAGE.
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
/* adapted from FreeBSD:
|
| 45 |
+
* lib/msun/src/s_cexp.c
|
| 46 |
+
* lib/msun/src/k_exp.c
|
| 47 |
+
*
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#pragma once
|
| 51 |
+
|
| 52 |
+
#include <thrust/detail/config.h>
|
| 53 |
+
|
| 54 |
+
#include <thrust/complex.h>
|
| 55 |
+
#include <thrust/detail/complex/math_private.h>
|
| 56 |
+
|
| 57 |
+
THRUST_NAMESPACE_BEGIN
|
| 58 |
+
namespace detail
|
| 59 |
+
{
|
| 60 |
+
namespace complex
|
| 61 |
+
{
|
| 62 |
+
/*
|
| 63 |
+
* Compute exp(x), scaled to avoid spurious overflow. An exponent is
|
| 64 |
+
* returned separately in 'expt'.
|
| 65 |
+
*
|
| 66 |
+
* Input: ln(DBL_MAX) <= x < ln(2 * DBL_MAX / DBL_MIN_DENORM) ~= 1454.91
|
| 67 |
+
* Output: 2**1023 <= y < 2**1024
|
| 68 |
+
*/
|
| 69 |
+
_CCCL_HOST_DEVICE inline double frexp_exp(double x, int* expt)
|
| 70 |
+
{
|
| 71 |
+
const uint32_t k = 1799; /* constant for reduction */
|
| 72 |
+
const double kln2 = 1246.97177782734161156; /* k * ln2 */
|
| 73 |
+
|
| 74 |
+
double exp_x;
|
| 75 |
+
uint32_t hx;
|
| 76 |
+
|
| 77 |
+
/*
|
| 78 |
+
* We use exp(x) = exp(x - kln2) * 2**k, carefully chosen to
|
| 79 |
+
* minimize |exp(kln2) - 2**k|. We also scale the exponent of
|
| 80 |
+
* exp_x to MAX_EXP so that the result can be multiplied by
|
| 81 |
+
* a tiny number without losing accuracy due to denormalization.
|
| 82 |
+
*/
|
| 83 |
+
exp_x = exp(x - kln2);
|
| 84 |
+
get_high_word(hx, exp_x);
|
| 85 |
+
*expt = (hx >> 20) - (0x3ff + 1023) + k;
|
| 86 |
+
set_high_word(exp_x, (hx & 0xfffff) | ((0x3ff + 1023) << 20));
|
| 87 |
+
return (exp_x);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
_CCCL_HOST_DEVICE inline complex<double> ldexp_cexp(complex<double> z, int expt)
|
| 91 |
+
{
|
| 92 |
+
double x, y, exp_x, scale1, scale2;
|
| 93 |
+
int ex_expt, half_expt;
|
| 94 |
+
|
| 95 |
+
x = z.real();
|
| 96 |
+
y = z.imag();
|
| 97 |
+
exp_x = frexp_exp(x, &ex_expt);
|
| 98 |
+
expt += ex_expt;
|
| 99 |
+
|
| 100 |
+
/*
|
| 101 |
+
* Arrange so that scale1 * scale2 == 2**expt. We use this to
|
| 102 |
+
* compensate for scalbn being horrendously slow.
|
| 103 |
+
*/
|
| 104 |
+
half_expt = expt / 2;
|
| 105 |
+
insert_words(scale1, (0x3ff + half_expt) << 20, 0);
|
| 106 |
+
half_expt = expt - half_expt;
|
| 107 |
+
insert_words(scale2, (0x3ff + half_expt) << 20, 0);
|
| 108 |
+
|
| 109 |
+
return (complex<double>(cos(y) * exp_x * scale1 * scale2, sin(y) * exp_x * scale1 * scale2));
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
_CCCL_HOST_DEVICE inline complex<double> cexp(const complex<double>& z)
|
| 113 |
+
{
|
| 114 |
+
double x, y, exp_x;
|
| 115 |
+
uint32_t hx, hy, lx, ly;
|
| 116 |
+
|
| 117 |
+
const uint32_t exp_ovfl = 0x40862e42, /* high bits of MAX_EXP * ln2 ~= 710 */
|
| 118 |
+
cexp_ovfl = 0x4096b8e4; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
|
| 119 |
+
|
| 120 |
+
x = z.real();
|
| 121 |
+
y = z.imag();
|
| 122 |
+
|
| 123 |
+
extract_words(hy, ly, y);
|
| 124 |
+
hy &= 0x7fffffff;
|
| 125 |
+
|
| 126 |
+
/* cexp(x + I 0) = exp(x) + I 0 */
|
| 127 |
+
if ((hy | ly) == 0)
|
| 128 |
+
{
|
| 129 |
+
return (complex<double>(exp(x), y));
|
| 130 |
+
}
|
| 131 |
+
extract_words(hx, lx, x);
|
| 132 |
+
/* cexp(0 + I y) = cos(y) + I sin(y) */
|
| 133 |
+
if (((hx & 0x7fffffff) | lx) == 0)
|
| 134 |
+
{
|
| 135 |
+
return (complex<double>(cos(y), sin(y)));
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
if (hy >= 0x7ff00000)
|
| 139 |
+
{
|
| 140 |
+
if (lx != 0 || (hx & 0x7fffffff) != 0x7ff00000)
|
| 141 |
+
{
|
| 142 |
+
/* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */
|
| 143 |
+
return (complex<double>(y - y, y - y));
|
| 144 |
+
}
|
| 145 |
+
else if (hx & 0x80000000)
|
| 146 |
+
{
|
| 147 |
+
/* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */
|
| 148 |
+
return (complex<double>(0.0, 0.0));
|
| 149 |
+
}
|
| 150 |
+
else
|
| 151 |
+
{
|
| 152 |
+
/* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */
|
| 153 |
+
return (complex<double>(x, y - y));
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
if (hx >= exp_ovfl && hx <= cexp_ovfl)
|
| 158 |
+
{
|
| 159 |
+
/*
|
| 160 |
+
* x is between 709.7 and 1454.3, so we must scale to avoid
|
| 161 |
+
* overflow in exp(x).
|
| 162 |
+
*/
|
| 163 |
+
return (ldexp_cexp(z, 0));
|
| 164 |
+
}
|
| 165 |
+
else
|
| 166 |
+
{
|
| 167 |
+
/*
|
| 168 |
+
* Cases covered here:
|
| 169 |
+
* - x < exp_ovfl and exp(x) won't overflow (common case)
|
| 170 |
+
* - x > cexp_ovfl, so exp(x) * s overflows for all s > 0
|
| 171 |
+
* - x = +-Inf (generated by exp())
|
| 172 |
+
* - x = NaN (spurious inexact exception from y)
|
| 173 |
+
*/
|
| 174 |
+
exp_x = std::exp(x);
|
| 175 |
+
return (complex<double>(exp_x * cos(y), exp_x * sin(y)));
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
} // namespace complex
|
| 180 |
+
|
| 181 |
+
} // namespace detail
|
| 182 |
+
|
| 183 |
+
template <typename ValueType>
|
| 184 |
+
_CCCL_HOST_DEVICE inline complex<ValueType> exp(const complex<ValueType>& z)
|
| 185 |
+
{
|
| 186 |
+
return polar(std::exp(z.real()), z.imag());
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
template <>
|
| 190 |
+
_CCCL_HOST_DEVICE inline complex<double> exp(const complex<double>& z)
|
| 191 |
+
{
|
| 192 |
+
return detail::complex::cexp(z);
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/cexpf.h
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
* Copyright 2013 Filipe RNC Maia
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
/*-
|
| 19 |
+
* Copyright (c) 2011 David Schultz <das@FreeBSD.ORG>
|
| 20 |
+
* All rights reserved.
|
| 21 |
+
*
|
| 22 |
+
* Redistribution and use in source and binary forms, with or without
|
| 23 |
+
* modification, are permitted provided that the following conditions
|
| 24 |
+
* are met:
|
| 25 |
+
* 1. Redistributions of source code must retain the above copyright
|
| 26 |
+
* notice, this list of conditions and the following disclaimer.
|
| 27 |
+
* 2. Redistributions in binary form must reproduce the above copyright
|
| 28 |
+
* notice, this list of conditions and the following disclaimer in the
|
| 29 |
+
* documentation and/or other materials provided with the distribution.
|
| 30 |
+
*
|
| 31 |
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
| 32 |
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 33 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
| 34 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
| 35 |
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 36 |
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
| 37 |
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
| 38 |
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| 39 |
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
| 40 |
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
| 41 |
+
* SUCH DAMAGE.
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
/* adapted from FreeBSD:
|
| 45 |
+
* lib/msun/src/s_cexpf.c
|
| 46 |
+
* lib/msun/src/k_exp.c
|
| 47 |
+
*
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#pragma once
|
| 51 |
+
|
| 52 |
+
#include <thrust/detail/config.h>
|
| 53 |
+
|
| 54 |
+
#include <thrust/complex.h>
|
| 55 |
+
#include <thrust/detail/complex/math_private.h>
|
| 56 |
+
|
| 57 |
+
THRUST_NAMESPACE_BEGIN
|
| 58 |
+
namespace detail
|
| 59 |
+
{
|
| 60 |
+
namespace complex
|
| 61 |
+
{
|
| 62 |
+
|
| 63 |
+
_CCCL_HOST_DEVICE inline float frexp_expf(float x, int* expt)
|
| 64 |
+
{
|
| 65 |
+
const uint32_t k = 235; /* constant for reduction */
|
| 66 |
+
const float kln2 = 162.88958740F; /* k * ln2 */
|
| 67 |
+
|
| 68 |
+
// should this be a double instead?
|
| 69 |
+
float exp_x;
|
| 70 |
+
uint32_t hx;
|
| 71 |
+
|
| 72 |
+
exp_x = expf(x - kln2);
|
| 73 |
+
get_float_word(hx, exp_x);
|
| 74 |
+
*expt = (hx >> 23) - (0x7f + 127) + k;
|
| 75 |
+
set_float_word(exp_x, (hx & 0x7fffff) | ((0x7f + 127) << 23));
|
| 76 |
+
return (exp_x);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
_CCCL_HOST_DEVICE inline complex<float> ldexp_cexpf(complex<float> z, int expt)
|
| 80 |
+
{
|
| 81 |
+
float x, y, exp_x, scale1, scale2;
|
| 82 |
+
int ex_expt, half_expt;
|
| 83 |
+
|
| 84 |
+
x = z.real();
|
| 85 |
+
y = z.imag();
|
| 86 |
+
exp_x = frexp_expf(x, &ex_expt);
|
| 87 |
+
expt += ex_expt;
|
| 88 |
+
|
| 89 |
+
half_expt = expt / 2;
|
| 90 |
+
set_float_word(scale1, (0x7f + half_expt) << 23);
|
| 91 |
+
half_expt = expt - half_expt;
|
| 92 |
+
set_float_word(scale2, (0x7f + half_expt) << 23);
|
| 93 |
+
|
| 94 |
+
return (complex<float>(std::cos(y) * exp_x * scale1 * scale2, std::sin(y) * exp_x * scale1 * scale2));
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
_CCCL_HOST_DEVICE inline complex<float> cexpf(const complex<float>& z)
|
| 98 |
+
{
|
| 99 |
+
float x, y, exp_x;
|
| 100 |
+
uint32_t hx, hy;
|
| 101 |
+
|
| 102 |
+
const uint32_t exp_ovfl = 0x42b17218, /* MAX_EXP * ln2 ~= 88.722839355 */
|
| 103 |
+
cexp_ovfl = 0x43400074; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
|
| 104 |
+
|
| 105 |
+
x = z.real();
|
| 106 |
+
y = z.imag();
|
| 107 |
+
|
| 108 |
+
get_float_word(hy, y);
|
| 109 |
+
hy &= 0x7fffffff;
|
| 110 |
+
|
| 111 |
+
/* cexp(x + I 0) = exp(x) + I 0 */
|
| 112 |
+
if (hy == 0)
|
| 113 |
+
{
|
| 114 |
+
return (complex<float>(std::exp(x), y));
|
| 115 |
+
}
|
| 116 |
+
get_float_word(hx, x);
|
| 117 |
+
/* cexp(0 + I y) = cos(y) + I sin(y) */
|
| 118 |
+
if ((hx & 0x7fffffff) == 0)
|
| 119 |
+
{
|
| 120 |
+
return (complex<float>(std::cos(y), std::sin(y)));
|
| 121 |
+
}
|
| 122 |
+
if (hy >= 0x7f800000)
|
| 123 |
+
{
|
| 124 |
+
if ((hx & 0x7fffffff) != 0x7f800000)
|
| 125 |
+
{
|
| 126 |
+
/* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */
|
| 127 |
+
return (complex<float>(y - y, y - y));
|
| 128 |
+
}
|
| 129 |
+
else if (hx & 0x80000000)
|
| 130 |
+
{
|
| 131 |
+
/* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */
|
| 132 |
+
return (complex<float>(0.0, 0.0));
|
| 133 |
+
}
|
| 134 |
+
else
|
| 135 |
+
{
|
| 136 |
+
/* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */
|
| 137 |
+
return (complex<float>(x, y - y));
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
if (hx >= exp_ovfl && hx <= cexp_ovfl)
|
| 142 |
+
{
|
| 143 |
+
/*
|
| 144 |
+
* x is between 88.7 and 192, so we must scale to avoid
|
| 145 |
+
* overflow in expf(x).
|
| 146 |
+
*/
|
| 147 |
+
return (ldexp_cexpf(z, 0));
|
| 148 |
+
}
|
| 149 |
+
else
|
| 150 |
+
{
|
| 151 |
+
/*
|
| 152 |
+
* Cases covered here:
|
| 153 |
+
* - x < exp_ovfl and exp(x) won't overflow (common case)
|
| 154 |
+
* - x > cexp_ovfl, so exp(x) * s overflows for all s > 0
|
| 155 |
+
* - x = +-Inf (generated by exp())
|
| 156 |
+
* - x = NaN (spurious inexact exception from y)
|
| 157 |
+
*/
|
| 158 |
+
exp_x = std::exp(x);
|
| 159 |
+
return (complex<float>(exp_x * std::cos(y), exp_x * std::sin(y)));
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
} // namespace complex
|
| 164 |
+
|
| 165 |
+
} // namespace detail
|
| 166 |
+
|
| 167 |
+
template <>
|
| 168 |
+
_CCCL_HOST_DEVICE inline complex<float> exp(const complex<float>& z)
|
| 169 |
+
{
|
| 170 |
+
return detail::complex::cexpf(z);
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/clogf.h
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2021 NVIDIA Corporation
|
| 3 |
+
* Copyright 2013 Filipe RNC Maia
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
/*-
|
| 19 |
+
* Copyright (c) 2012 Stephen Montgomery-Smith <stephen@FreeBSD.ORG>
|
| 20 |
+
* All rights reserved.
|
| 21 |
+
*
|
| 22 |
+
* Redistribution and use in source and binary forms, with or without
|
| 23 |
+
* modification, are permitted provided that the following conditions
|
| 24 |
+
* are met:
|
| 25 |
+
* 1. Redistributions of source code must retain the above copyright
|
| 26 |
+
* notice, this list of conditions and the following disclaimer.
|
| 27 |
+
* 2. Redistributions in binary form must reproduce the above copyright
|
| 28 |
+
* notice, this list of conditions and the following disclaimer in the
|
| 29 |
+
* documentation and/or other materials provided with the distribution.
|
| 30 |
+
*
|
| 31 |
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
| 32 |
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 33 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
| 34 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
| 35 |
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 36 |
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
| 37 |
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
| 38 |
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| 39 |
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
| 40 |
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
| 41 |
+
* SUCH DAMAGE.
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
/* adapted from FreeBSDs msun:*/
|
| 45 |
+
|
| 46 |
+
#pragma once
|
| 47 |
+
|
| 48 |
+
#include <thrust/detail/config.h>
|
| 49 |
+
|
| 50 |
+
#include <thrust/complex.h>
|
| 51 |
+
#include <thrust/detail/complex/math_private.h>
|
| 52 |
+
|
| 53 |
+
THRUST_NAMESPACE_BEGIN
|
| 54 |
+
namespace detail
|
| 55 |
+
{
|
| 56 |
+
namespace complex
|
| 57 |
+
{
|
| 58 |
+
|
| 59 |
+
using thrust::complex;
|
| 60 |
+
|
| 61 |
+
/* round down to 8 = 24/3 bits */
|
| 62 |
+
_CCCL_HOST_DEVICE inline float trim(float x)
|
| 63 |
+
{
|
| 64 |
+
uint32_t hx;
|
| 65 |
+
get_float_word(hx, x);
|
| 66 |
+
hx &= 0xffff0000;
|
| 67 |
+
float ret;
|
| 68 |
+
set_float_word(ret, hx);
|
| 69 |
+
return ret;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
_CCCL_HOST_DEVICE inline complex<float> clogf(const complex<float>& z)
|
| 73 |
+
{
|
| 74 |
+
// Adapted from FreeBSDs msun
|
| 75 |
+
float x, y;
|
| 76 |
+
float ax, ay;
|
| 77 |
+
float x0, y0, x1, y1, x2, y2, t, hm1;
|
| 78 |
+
float val[12];
|
| 79 |
+
int i, sorted;
|
| 80 |
+
const float e = 2.7182818284590452354f;
|
| 81 |
+
|
| 82 |
+
x = z.real();
|
| 83 |
+
y = z.imag();
|
| 84 |
+
|
| 85 |
+
/* Handle NaNs using the general formula to mix them right. */
|
| 86 |
+
if (x != x || y != y)
|
| 87 |
+
{
|
| 88 |
+
return (complex<float>(std::log(norm(z)), std::atan2(y, x)));
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
ax = std::abs(x);
|
| 92 |
+
ay = std::abs(y);
|
| 93 |
+
if (ax < ay)
|
| 94 |
+
{
|
| 95 |
+
t = ax;
|
| 96 |
+
ax = ay;
|
| 97 |
+
ay = t;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/*
|
| 101 |
+
* To avoid unnecessary overflow, if x and y are very large, divide x
|
| 102 |
+
* and y by M_E, and then add 1 to the logarithm. This depends on
|
| 103 |
+
* M_E being larger than sqrt(2).
|
| 104 |
+
* There is a potential loss of accuracy caused by dividing by M_E,
|
| 105 |
+
* but this case should happen extremely rarely.
|
| 106 |
+
*/
|
| 107 |
+
// For high values of ay -> hypotf(FLT_MAX,ay) = inf
|
| 108 |
+
// We expect that for values at or below ay = 1e34f this should not happen
|
| 109 |
+
if (ay > 1e34f)
|
| 110 |
+
{
|
| 111 |
+
return (complex<float>(std::log(hypotf(x / e, y / e)) + 1.0f, std::atan2(y, x)));
|
| 112 |
+
}
|
| 113 |
+
if (ax == 1.f)
|
| 114 |
+
{
|
| 115 |
+
if (ay < 1e-19f)
|
| 116 |
+
{
|
| 117 |
+
return (complex<float>((ay * 0.5f) * ay, std::atan2(y, x)));
|
| 118 |
+
}
|
| 119 |
+
return (complex<float>(log1pf(ay * ay) * 0.5f, std::atan2(y, x)));
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/*
|
| 123 |
+
* Because atan2 and hypot conform to C99, this also covers all the
|
| 124 |
+
* edge cases when x or y are 0 or infinite.
|
| 125 |
+
*/
|
| 126 |
+
if (ax < 1e-6f || ay < 1e-6f || ax > 1e6f || ay > 1e6f)
|
| 127 |
+
{
|
| 128 |
+
return (complex<float>(std::log(hypotf(x, y)), std::atan2(y, x)));
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/*
|
| 132 |
+
* From this point on, we don't need to worry about underflow or
|
| 133 |
+
* overflow in calculating ax*ax or ay*ay.
|
| 134 |
+
*/
|
| 135 |
+
|
| 136 |
+
/* Some easy cases. */
|
| 137 |
+
|
| 138 |
+
if (ax >= 1.0f)
|
| 139 |
+
{
|
| 140 |
+
return (complex<float>(log1pf((ax - 1.f) * (ax + 1.f) + ay * ay) * 0.5f, atan2(y, x)));
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
if (ax * ax + ay * ay <= 0.7f)
|
| 144 |
+
{
|
| 145 |
+
return (complex<float>(std::log(ax * ax + ay * ay) * 0.5f, std::atan2(y, x)));
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
/*
|
| 149 |
+
* Take extra care so that ULP of real part is small if hypot(x,y) is
|
| 150 |
+
* moderately close to 1.
|
| 151 |
+
*/
|
| 152 |
+
|
| 153 |
+
x0 = trim(ax);
|
| 154 |
+
ax = ax - x0;
|
| 155 |
+
x1 = trim(ax);
|
| 156 |
+
x2 = ax - x1;
|
| 157 |
+
y0 = trim(ay);
|
| 158 |
+
ay = ay - y0;
|
| 159 |
+
y1 = trim(ay);
|
| 160 |
+
y2 = ay - y1;
|
| 161 |
+
|
| 162 |
+
val[0] = x0 * x0;
|
| 163 |
+
val[1] = y0 * y0;
|
| 164 |
+
val[2] = 2 * x0 * x1;
|
| 165 |
+
val[3] = 2 * y0 * y1;
|
| 166 |
+
val[4] = x1 * x1;
|
| 167 |
+
val[5] = y1 * y1;
|
| 168 |
+
val[6] = 2 * x0 * x2;
|
| 169 |
+
val[7] = 2 * y0 * y2;
|
| 170 |
+
val[8] = 2 * x1 * x2;
|
| 171 |
+
val[9] = 2 * y1 * y2;
|
| 172 |
+
val[10] = x2 * x2;
|
| 173 |
+
val[11] = y2 * y2;
|
| 174 |
+
|
| 175 |
+
/* Bubble sort. */
|
| 176 |
+
|
| 177 |
+
do
|
| 178 |
+
{
|
| 179 |
+
sorted = 1;
|
| 180 |
+
for (i = 0; i < 11; i++)
|
| 181 |
+
{
|
| 182 |
+
if (val[i] < val[i + 1])
|
| 183 |
+
{
|
| 184 |
+
sorted = 0;
|
| 185 |
+
t = val[i];
|
| 186 |
+
val[i] = val[i + 1];
|
| 187 |
+
val[i + 1] = t;
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
} while (!sorted);
|
| 191 |
+
|
| 192 |
+
hm1 = -1;
|
| 193 |
+
for (i = 0; i < 12; i++)
|
| 194 |
+
{
|
| 195 |
+
hm1 += val[i];
|
| 196 |
+
}
|
| 197 |
+
return (complex<float>(0.5f * log1pf(hm1), atan2(y, x)));
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
} // namespace complex
|
| 201 |
+
|
| 202 |
+
} // namespace detail
|
| 203 |
+
|
| 204 |
+
template <>
|
| 205 |
+
_CCCL_HOST_DEVICE inline complex<float> log(const complex<float>& z)
|
| 206 |
+
{
|
| 207 |
+
return detail::complex::clogf(z);
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/csinh.h
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
* Copyright 2013 Filipe RNC Maia
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
/*-
|
| 19 |
+
* Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
|
| 20 |
+
* All rights reserved.
|
| 21 |
+
*
|
| 22 |
+
* Redistribution and use in source and binary forms, with or without
|
| 23 |
+
* modification, are permitted provided that the following conditions
|
| 24 |
+
* are met:
|
| 25 |
+
* 1. Redistributions of source code must retain the above copyright
|
| 26 |
+
* notice unmodified, this list of conditions, and the following
|
| 27 |
+
* disclaimer.
|
| 28 |
+
* 2. Redistributions in binary form must reproduce the above copyright
|
| 29 |
+
* notice, this list of conditions and the following disclaimer in the
|
| 30 |
+
* documentation and/or other materials provided with the distribution.
|
| 31 |
+
*
|
| 32 |
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
| 33 |
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
| 34 |
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
| 35 |
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 36 |
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
| 37 |
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 38 |
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 39 |
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 40 |
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
| 41 |
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
/* adapted from FreeBSD:
|
| 45 |
+
* lib/msun/src/s_csinh.c
|
| 46 |
+
*/
|
| 47 |
+
|
| 48 |
+
#pragma once
|
| 49 |
+
|
| 50 |
+
#include <thrust/detail/config.h>
|
| 51 |
+
|
| 52 |
+
#include <thrust/complex.h>
|
| 53 |
+
#include <thrust/detail/complex/cexp.h>
|
| 54 |
+
#include <thrust/detail/complex/math_private.h>
|
| 55 |
+
|
| 56 |
+
THRUST_NAMESPACE_BEGIN
|
| 57 |
+
namespace detail
|
| 58 |
+
{
|
| 59 |
+
namespace complex
|
| 60 |
+
{
|
| 61 |
+
|
| 62 |
+
using thrust::complex;
|
| 63 |
+
|
| 64 |
+
_CCCL_HOST_DEVICE inline complex<double> csinh(const complex<double>& z)
|
| 65 |
+
{
|
| 66 |
+
double x, y, h;
|
| 67 |
+
uint32_t hx, hy, ix, iy, lx, ly;
|
| 68 |
+
const double huge = 8.98846567431157953864652595395e+307; // 0x1p1023;
|
| 69 |
+
|
| 70 |
+
x = z.real();
|
| 71 |
+
y = z.imag();
|
| 72 |
+
|
| 73 |
+
extract_words(hx, lx, x);
|
| 74 |
+
extract_words(hy, ly, y);
|
| 75 |
+
|
| 76 |
+
ix = 0x7fffffff & hx;
|
| 77 |
+
iy = 0x7fffffff & hy;
|
| 78 |
+
|
| 79 |
+
/* Handle the nearly-non-exceptional cases where x and y are finite. */
|
| 80 |
+
if (ix < 0x7ff00000 && iy < 0x7ff00000)
|
| 81 |
+
{
|
| 82 |
+
if ((iy | ly) == 0)
|
| 83 |
+
{
|
| 84 |
+
return (complex<double>(sinh(x), y));
|
| 85 |
+
}
|
| 86 |
+
if (ix < 0x40360000) /* small x: normal case */
|
| 87 |
+
{
|
| 88 |
+
return (complex<double>(sinh(x) * cos(y), cosh(x) * sin(y)));
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/* |x| >= 22, so cosh(x) ~= exp(|x|) */
|
| 92 |
+
if (ix < 0x40862e42)
|
| 93 |
+
{
|
| 94 |
+
/* x < 710: exp(|x|) won't overflow */
|
| 95 |
+
h = exp(fabs(x)) * 0.5;
|
| 96 |
+
return (complex<double>(copysign(h, x) * cos(y), h * sin(y)));
|
| 97 |
+
}
|
| 98 |
+
else if (ix < 0x4096bbaa)
|
| 99 |
+
{
|
| 100 |
+
/* x < 1455: scale to avoid overflow */
|
| 101 |
+
complex<double> z_ = ldexp_cexp(complex<double>(fabs(x), y), -1);
|
| 102 |
+
return (complex<double>(z_.real() * copysign(1.0, x), z_.imag()));
|
| 103 |
+
}
|
| 104 |
+
else
|
| 105 |
+
{
|
| 106 |
+
/* x >= 1455: the result always overflows */
|
| 107 |
+
h = huge * x;
|
| 108 |
+
return (complex<double>(h * cos(y), h * h * sin(y)));
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
/*
|
| 113 |
+
* sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN.
|
| 114 |
+
* The sign of 0 in the result is unspecified. Choice = normally
|
| 115 |
+
* the same as dNaN. Raise the invalid floating-point exception.
|
| 116 |
+
*
|
| 117 |
+
* sinh(+-0 +- I NaN) = sign(d(+-0, NaN))0 + I d(NaN).
|
| 118 |
+
* The sign of 0 in the result is unspecified. Choice = normally
|
| 119 |
+
* the same as d(NaN).
|
| 120 |
+
*/
|
| 121 |
+
if ((ix | lx) == 0 && iy >= 0x7ff00000)
|
| 122 |
+
{
|
| 123 |
+
return (complex<double>(copysign(0.0, x * (y - y)), y - y));
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
/*
|
| 127 |
+
* sinh(+-Inf +- I 0) = +-Inf + I +-0.
|
| 128 |
+
*
|
| 129 |
+
* sinh(NaN +- I 0) = d(NaN) + I +-0.
|
| 130 |
+
*/
|
| 131 |
+
if ((iy | ly) == 0 && ix >= 0x7ff00000)
|
| 132 |
+
{
|
| 133 |
+
if (((hx & 0xfffff) | lx) == 0)
|
| 134 |
+
{
|
| 135 |
+
return (complex<double>(x, y));
|
| 136 |
+
}
|
| 137 |
+
return (complex<double>(x, copysign(0.0, y)));
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
/*
|
| 141 |
+
* sinh(x +- I Inf) = dNaN + I dNaN.
|
| 142 |
+
* Raise the invalid floating-point exception for finite nonzero x.
|
| 143 |
+
*
|
| 144 |
+
* sinh(x + I NaN) = d(NaN) + I d(NaN).
|
| 145 |
+
* Optionally raises the invalid floating-point exception for finite
|
| 146 |
+
* nonzero x. Choice = don't raise (except for signaling NaNs).
|
| 147 |
+
*/
|
| 148 |
+
if (ix < 0x7ff00000 && iy >= 0x7ff00000)
|
| 149 |
+
{
|
| 150 |
+
return (complex<double>(y - y, x * (y - y)));
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/*
|
| 154 |
+
* sinh(+-Inf + I NaN) = +-Inf + I d(NaN).
|
| 155 |
+
* The sign of Inf in the result is unspecified. Choice = normally
|
| 156 |
+
* the same as d(NaN).
|
| 157 |
+
*
|
| 158 |
+
* sinh(+-Inf +- I Inf) = +Inf + I dNaN.
|
| 159 |
+
* The sign of Inf in the result is unspecified. Choice = always +.
|
| 160 |
+
* Raise the invalid floating-point exception.
|
| 161 |
+
*
|
| 162 |
+
* sinh(+-Inf + I y) = +-Inf cos(y) + I Inf sin(y)
|
| 163 |
+
*/
|
| 164 |
+
if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0)
|
| 165 |
+
{
|
| 166 |
+
if (iy >= 0x7ff00000)
|
| 167 |
+
{
|
| 168 |
+
return (complex<double>(x * x, x * (y - y)));
|
| 169 |
+
}
|
| 170 |
+
return (complex<double>(x * cos(y), infinity<double>() * sin(y)));
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
/*
|
| 174 |
+
* sinh(NaN + I NaN) = d(NaN) + I d(NaN).
|
| 175 |
+
*
|
| 176 |
+
* sinh(NaN +- I Inf) = d(NaN) + I d(NaN).
|
| 177 |
+
* Optionally raises the invalid floating-point exception.
|
| 178 |
+
* Choice = raise.
|
| 179 |
+
*
|
| 180 |
+
* sinh(NaN + I y) = d(NaN) + I d(NaN).
|
| 181 |
+
* Optionally raises the invalid floating-point exception for finite
|
| 182 |
+
* nonzero y. Choice = don't raise (except for signaling NaNs).
|
| 183 |
+
*/
|
| 184 |
+
return (complex<double>((x * x) * (y - y), (x + x) * (y - y)));
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
_CCCL_HOST_DEVICE inline complex<double> csin(complex<double> z)
|
| 188 |
+
{
|
| 189 |
+
/* csin(z) = -I * csinh(I * z) */
|
| 190 |
+
z = csinh(complex<double>(-z.imag(), z.real()));
|
| 191 |
+
return (complex<double>(z.imag(), -z.real()));
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
} // namespace complex
|
| 195 |
+
|
| 196 |
+
} // namespace detail
|
| 197 |
+
|
| 198 |
+
template <typename ValueType>
|
| 199 |
+
_CCCL_HOST_DEVICE inline complex<ValueType> sin(const complex<ValueType>& z)
|
| 200 |
+
{
|
| 201 |
+
const ValueType re = z.real();
|
| 202 |
+
const ValueType im = z.imag();
|
| 203 |
+
return complex<ValueType>(std::sin(re) * std::cosh(im), std::cos(re) * std::sinh(im));
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
template <typename ValueType>
|
| 207 |
+
_CCCL_HOST_DEVICE inline complex<ValueType> sinh(const complex<ValueType>& z)
|
| 208 |
+
{
|
| 209 |
+
const ValueType re = z.real();
|
| 210 |
+
const ValueType im = z.imag();
|
| 211 |
+
return complex<ValueType>(std::sinh(re) * std::cos(im), std::cosh(re) * std::sin(im));
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
template <>
|
| 215 |
+
_CCCL_HOST_DEVICE inline complex<double> sin(const complex<double>& z)
|
| 216 |
+
{
|
| 217 |
+
return detail::complex::csin(z);
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
template <>
|
| 221 |
+
_CCCL_HOST_DEVICE inline complex<double> sinh(const complex<double>& z)
|
| 222 |
+
{
|
| 223 |
+
return detail::complex::csinh(z);
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/csinhf.h
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
* Copyright 2013 Filipe RNC Maia
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
/*-
|
| 19 |
+
* Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
|
| 20 |
+
* All rights reserved.
|
| 21 |
+
*
|
| 22 |
+
* Redistribution and use in source and binary forms, with or without
|
| 23 |
+
* modification, are permitted provided that the following conditions
|
| 24 |
+
* are met:
|
| 25 |
+
* 1. Redistributions of source code must retain the above copyright
|
| 26 |
+
* notice unmodified, this list of conditions, and the following
|
| 27 |
+
* disclaimer.
|
| 28 |
+
* 2. Redistributions in binary form must reproduce the above copyright
|
| 29 |
+
* notice, this list of conditions and the following disclaimer in the
|
| 30 |
+
* documentation and/or other materials provided with the distribution.
|
| 31 |
+
*
|
| 32 |
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
| 33 |
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
| 34 |
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
| 35 |
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 36 |
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
| 37 |
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 38 |
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 39 |
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 40 |
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
| 41 |
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
/* adapted from FreeBSD:
|
| 45 |
+
* lib/msun/src/s_csinhf.c
|
| 46 |
+
*/
|
| 47 |
+
|
| 48 |
+
#pragma once
|
| 49 |
+
|
| 50 |
+
#include <thrust/detail/config.h>
|
| 51 |
+
|
| 52 |
+
#include <thrust/complex.h>
|
| 53 |
+
#include <thrust/detail/complex/cexp.h>
|
| 54 |
+
#include <thrust/detail/complex/cexpf.h>
|
| 55 |
+
#include <thrust/detail/complex/math_private.h>
|
| 56 |
+
|
| 57 |
+
THRUST_NAMESPACE_BEGIN
|
| 58 |
+
namespace detail
|
| 59 |
+
{
|
| 60 |
+
namespace complex
|
| 61 |
+
{
|
| 62 |
+
|
| 63 |
+
using thrust::complex;
|
| 64 |
+
|
| 65 |
+
_CCCL_HOST_DEVICE inline complex<float> csinhf(const complex<float>& z)
|
| 66 |
+
{
|
| 67 |
+
float x, y, h;
|
| 68 |
+
uint32_t hx, hy, ix, iy;
|
| 69 |
+
|
| 70 |
+
const float huge = 1.70141183460469231731687303716e+38; // 0x1p127;
|
| 71 |
+
|
| 72 |
+
x = z.real();
|
| 73 |
+
y = z.imag();
|
| 74 |
+
|
| 75 |
+
get_float_word(hx, x);
|
| 76 |
+
get_float_word(hy, y);
|
| 77 |
+
|
| 78 |
+
ix = 0x7fffffff & hx;
|
| 79 |
+
iy = 0x7fffffff & hy;
|
| 80 |
+
|
| 81 |
+
if (ix < 0x7f800000 && iy < 0x7f800000)
|
| 82 |
+
{
|
| 83 |
+
if (iy == 0)
|
| 84 |
+
{
|
| 85 |
+
return (complex<float>(sinhf(x), y));
|
| 86 |
+
}
|
| 87 |
+
if (ix < 0x41100000) /* small x: normal case */
|
| 88 |
+
{
|
| 89 |
+
return (complex<float>(sinhf(x) * cosf(y), coshf(x) * sinf(y)));
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/* |x| >= 9, so cosh(x) ~= exp(|x|) */
|
| 93 |
+
if (ix < 0x42b17218)
|
| 94 |
+
{
|
| 95 |
+
/* x < 88.7: expf(|x|) won't overflow */
|
| 96 |
+
h = expf(fabsf(x)) * 0.5f;
|
| 97 |
+
return (complex<float>(copysignf(h, x) * cosf(y), h * sinf(y)));
|
| 98 |
+
}
|
| 99 |
+
else if (ix < 0x4340b1e7)
|
| 100 |
+
{
|
| 101 |
+
/* x < 192.7: scale to avoid overflow */
|
| 102 |
+
complex<float> z_ = ldexp_cexpf(complex<float>(fabsf(x), y), -1);
|
| 103 |
+
return (complex<float>(z_.real() * copysignf(1.0f, x), z_.imag()));
|
| 104 |
+
}
|
| 105 |
+
else
|
| 106 |
+
{
|
| 107 |
+
/* x >= 192.7: the result always overflows */
|
| 108 |
+
h = huge * x;
|
| 109 |
+
return (complex<float>(h * cosf(y), h * h * sinf(y)));
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
if (ix == 0 && iy >= 0x7f800000)
|
| 114 |
+
{
|
| 115 |
+
return (complex<float>(copysignf(0, x * (y - y)), y - y));
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
if (iy == 0 && ix >= 0x7f800000)
|
| 119 |
+
{
|
| 120 |
+
if ((hx & 0x7fffff) == 0)
|
| 121 |
+
{
|
| 122 |
+
return (complex<float>(x, y));
|
| 123 |
+
}
|
| 124 |
+
return (complex<float>(x, copysignf(0.0f, y)));
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
if (ix < 0x7f800000 && iy >= 0x7f800000)
|
| 128 |
+
{
|
| 129 |
+
return (complex<float>(y - y, x * (y - y)));
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0)
|
| 133 |
+
{
|
| 134 |
+
if (iy >= 0x7f800000)
|
| 135 |
+
{
|
| 136 |
+
return (complex<float>(x * x, x * (y - y)));
|
| 137 |
+
}
|
| 138 |
+
return (complex<float>(x * cosf(y), infinity<float>() * sinf(y)));
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
return (complex<float>((x * x) * (y - y), (x + x) * (y - y)));
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
_CCCL_HOST_DEVICE inline complex<float> csinf(complex<float> z)
|
| 145 |
+
{
|
| 146 |
+
z = csinhf(complex<float>(-z.imag(), z.real()));
|
| 147 |
+
return (complex<float>(z.imag(), -z.real()));
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
} // namespace complex
|
| 151 |
+
|
| 152 |
+
} // namespace detail
|
| 153 |
+
|
| 154 |
+
template <>
|
| 155 |
+
_CCCL_HOST_DEVICE inline complex<float> sin(const complex<float>& z)
|
| 156 |
+
{
|
| 157 |
+
return detail::complex::csinf(z);
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
template <>
|
| 161 |
+
_CCCL_HOST_DEVICE inline complex<float> sinh(const complex<float>& z)
|
| 162 |
+
{
|
| 163 |
+
return detail::complex::csinhf(z);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/ctanh.h
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
* Copyright 2013 Filipe RNC Maia
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
/*-
|
| 19 |
+
* Copyright (c) 2011 David Schultz
|
| 20 |
+
* All rights reserved.
|
| 21 |
+
*
|
| 22 |
+
* Redistribution and use in source and binary forms, with or without
|
| 23 |
+
* modification, are permitted provided that the following conditions
|
| 24 |
+
* are met:
|
| 25 |
+
* 1. Redistributions of source code must retain the above copyright
|
| 26 |
+
* notice unmodified, this list of conditions, and the following
|
| 27 |
+
* disclaimer.
|
| 28 |
+
* 2. Redistributions in binary form must reproduce the above copyright
|
| 29 |
+
* notice, this list of conditions and the following disclaimer in the
|
| 30 |
+
* documentation and/or other materials provided with the distribution.
|
| 31 |
+
*
|
| 32 |
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
| 33 |
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
| 34 |
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
| 35 |
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 36 |
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
| 37 |
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 38 |
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 39 |
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 40 |
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
| 41 |
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
/*
|
| 45 |
+
* Adapted from FreeBSD by Filipe Maia <filipe.c.maia@gmail.com>:
|
| 46 |
+
* freebsd/lib/msun/src/s_ctanh.c
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
/*
|
| 50 |
+
* Hyperbolic tangent of a complex argument z = x + i y.
|
| 51 |
+
*
|
| 52 |
+
* The algorithm is from:
|
| 53 |
+
*
|
| 54 |
+
* W. Kahan. Branch Cuts for Complex Elementary Functions or Much
|
| 55 |
+
* Ado About Nothing's Sign Bit. In The State of the Art in
|
| 56 |
+
* Numerical Analysis, pp. 165 ff. Iserles and Powell, eds., 1987.
|
| 57 |
+
*
|
| 58 |
+
* Method:
|
| 59 |
+
*
|
| 60 |
+
* Let t = tan(x)
|
| 61 |
+
* beta = 1/cos^2(y)
|
| 62 |
+
* s = sinh(x)
|
| 63 |
+
* rho = cosh(x)
|
| 64 |
+
*
|
| 65 |
+
* We have:
|
| 66 |
+
*
|
| 67 |
+
* tanh(z) = sinh(z) / cosh(z)
|
| 68 |
+
*
|
| 69 |
+
* sinh(x) cos(y) + i cosh(x) sin(y)
|
| 70 |
+
* = ---------------------------------
|
| 71 |
+
* cosh(x) cos(y) + i sinh(x) sin(y)
|
| 72 |
+
*
|
| 73 |
+
* cosh(x) sinh(x) / cos^2(y) + i tan(y)
|
| 74 |
+
* = -------------------------------------
|
| 75 |
+
* 1 + sinh^2(x) / cos^2(y)
|
| 76 |
+
*
|
| 77 |
+
* beta rho s + i t
|
| 78 |
+
* = ----------------
|
| 79 |
+
* 1 + beta s^2
|
| 80 |
+
*
|
| 81 |
+
* Modifications:
|
| 82 |
+
*
|
| 83 |
+
* I omitted the original algorithm's handling of overflow in tan(x) after
|
| 84 |
+
* verifying with nearpi.c that this can't happen in IEEE single or double
|
| 85 |
+
* precision. I also handle large x differently.
|
| 86 |
+
*/
|
| 87 |
+
|
| 88 |
+
#pragma once
|
| 89 |
+
|
| 90 |
+
#include <thrust/detail/config.h>
|
| 91 |
+
|
| 92 |
+
#include <thrust/complex.h>
|
| 93 |
+
#include <thrust/detail/complex/math_private.h>
|
| 94 |
+
|
| 95 |
+
#include <cmath>
|
| 96 |
+
|
| 97 |
+
THRUST_NAMESPACE_BEGIN
|
| 98 |
+
namespace detail
|
| 99 |
+
{
|
| 100 |
+
namespace complex
|
| 101 |
+
{
|
| 102 |
+
|
| 103 |
+
using thrust::complex;
|
| 104 |
+
|
| 105 |
+
_CCCL_HOST_DEVICE inline complex<double> ctanh(const complex<double>& z)
|
| 106 |
+
{
|
| 107 |
+
double x, y;
|
| 108 |
+
double t, beta, s, rho, denom;
|
| 109 |
+
uint32_t hx, ix, lx;
|
| 110 |
+
|
| 111 |
+
x = z.real();
|
| 112 |
+
y = z.imag();
|
| 113 |
+
|
| 114 |
+
extract_words(hx, lx, x);
|
| 115 |
+
ix = hx & 0x7fffffff;
|
| 116 |
+
|
| 117 |
+
/*
|
| 118 |
+
* ctanh(NaN + i 0) = NaN + i 0
|
| 119 |
+
*
|
| 120 |
+
* ctanh(NaN + i y) = NaN + i NaN for y != 0
|
| 121 |
+
*
|
| 122 |
+
* The imaginary part has the sign of x*sin(2*y), but there's no
|
| 123 |
+
* special effort to get this right.
|
| 124 |
+
*
|
| 125 |
+
* ctanh(+-Inf +- i Inf) = +-1 +- 0
|
| 126 |
+
*
|
| 127 |
+
* ctanh(+-Inf + i y) = +-1 + 0 sin(2y) for y finite
|
| 128 |
+
*
|
| 129 |
+
* The imaginary part of the sign is unspecified. This special
|
| 130 |
+
* case is only needed to avoid a spurious invalid exception when
|
| 131 |
+
* y is infinite.
|
| 132 |
+
*/
|
| 133 |
+
if (ix >= 0x7ff00000)
|
| 134 |
+
{
|
| 135 |
+
if ((ix & 0xfffff) | lx) /* x is NaN */
|
| 136 |
+
{
|
| 137 |
+
return (complex<double>(x, (y == 0 ? y : x * y)));
|
| 138 |
+
}
|
| 139 |
+
set_high_word(x, hx - 0x40000000); /* x = copysign(1, x) */
|
| 140 |
+
return (complex<double>(x, copysign(0.0, isinf(y) ? y : sin(y) * cos(y))));
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
/*
|
| 144 |
+
* ctanh(x + i NAN) = NaN + i NaN
|
| 145 |
+
* ctanh(x +- i Inf) = NaN + i NaN
|
| 146 |
+
*/
|
| 147 |
+
if (!isfinite(y))
|
| 148 |
+
{
|
| 149 |
+
return (complex<double>(y - y, y - y));
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
/*
|
| 153 |
+
* ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the
|
| 154 |
+
* approximation sinh^2(huge) ~= exp(2*huge) / 4.
|
| 155 |
+
* We use a modified formula to avoid spurious overflow.
|
| 156 |
+
*/
|
| 157 |
+
if (ix >= 0x40360000)
|
| 158 |
+
{ /* x >= 22 */
|
| 159 |
+
double exp_mx = exp(-fabs(x));
|
| 160 |
+
return (complex<double>(copysign(1.0, x), 4.0 * sin(y) * cos(y) * exp_mx * exp_mx));
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
/* Kahan's algorithm */
|
| 164 |
+
t = tan(y);
|
| 165 |
+
beta = 1.0 + t * t; /* = 1 / cos^2(y) */
|
| 166 |
+
s = sinh(x);
|
| 167 |
+
rho = sqrt(1.0 + s * s); /* = cosh(x) */
|
| 168 |
+
denom = 1.0 + beta * s * s;
|
| 169 |
+
return (complex<double>((beta * rho * s) / denom, t / denom));
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
_CCCL_HOST_DEVICE inline complex<double> ctan(complex<double> z)
|
| 173 |
+
{
|
| 174 |
+
/* ctan(z) = -I * ctanh(I * z) */
|
| 175 |
+
z = ctanh(complex<double>(-z.imag(), z.real()));
|
| 176 |
+
return (complex<double>(z.imag(), -z.real()));
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
} // namespace complex
|
| 180 |
+
|
| 181 |
+
} // namespace detail
|
| 182 |
+
|
| 183 |
+
template <typename ValueType>
|
| 184 |
+
_CCCL_HOST_DEVICE inline complex<ValueType> tan(const complex<ValueType>& z)
|
| 185 |
+
{
|
| 186 |
+
return sin(z) / cos(z);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
template <typename ValueType>
|
| 190 |
+
_CCCL_HOST_DEVICE inline complex<ValueType> tanh(const complex<ValueType>& z)
|
| 191 |
+
{
|
| 192 |
+
// This implementation seems better than the simple sin/cos
|
| 193 |
+
return (thrust::exp(ValueType(2) * z) - ValueType(1)) / (thrust::exp(ValueType(2) * z) + ValueType(1));
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
template <>
|
| 197 |
+
_CCCL_HOST_DEVICE inline complex<double> tan(const complex<double>& z)
|
| 198 |
+
{
|
| 199 |
+
return detail::complex::ctan(z);
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
template <>
|
| 203 |
+
_CCCL_HOST_DEVICE inline complex<double> tanh(const complex<double>& z)
|
| 204 |
+
{
|
| 205 |
+
return detail::complex::ctanh(z);
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/complex/ctanhf.h
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
* Copyright 2013 Filipe RNC Maia
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
/*-
|
| 19 |
+
* Copyright (c) 2011 David Schultz
|
| 20 |
+
* All rights reserved.
|
| 21 |
+
*
|
| 22 |
+
* Redistribution and use in source and binary forms, with or without
|
| 23 |
+
* modification, are permitted provided that the following conditions
|
| 24 |
+
* are met:
|
| 25 |
+
* 1. Redistributions of source code must retain the above copyright
|
| 26 |
+
* notice unmodified, this list of conditions, and the following
|
| 27 |
+
* disclaimer.
|
| 28 |
+
* 2. Redistributions in binary form must reproduce the above copyright
|
| 29 |
+
* notice, this list of conditions and the following disclaimer in the
|
| 30 |
+
* documentation and/or other materials provided with the distribution.
|
| 31 |
+
*
|
| 32 |
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
| 33 |
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
| 34 |
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
| 35 |
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 36 |
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
| 37 |
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 38 |
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 39 |
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 40 |
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
| 41 |
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
/*
|
| 45 |
+
* Adapted from FreeBSD by Filipe Maia, filipe.c.maia@gmail.com:
|
| 46 |
+
* freebsd/lib/msun/src/s_ctanhf.c
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
/*
|
| 50 |
+
* Hyperbolic tangent of a complex argument z. See ctanh.c for details.
|
| 51 |
+
*/
|
| 52 |
+
|
| 53 |
+
#pragma once
|
| 54 |
+
|
| 55 |
+
#include <thrust/detail/config.h>
|
| 56 |
+
|
| 57 |
+
#include <thrust/complex.h>
|
| 58 |
+
#include <thrust/detail/complex/math_private.h>
|
| 59 |
+
|
| 60 |
+
#include <cmath>
|
| 61 |
+
|
| 62 |
+
THRUST_NAMESPACE_BEGIN
|
| 63 |
+
namespace detail
|
| 64 |
+
{
|
| 65 |
+
namespace complex
|
| 66 |
+
{
|
| 67 |
+
|
| 68 |
+
using thrust::complex;
|
| 69 |
+
|
| 70 |
+
_CCCL_HOST_DEVICE inline complex<float> ctanhf(const complex<float>& z)
|
| 71 |
+
{
|
| 72 |
+
float x, y;
|
| 73 |
+
float t, beta, s, rho, denom;
|
| 74 |
+
uint32_t hx, ix;
|
| 75 |
+
|
| 76 |
+
x = z.real();
|
| 77 |
+
y = z.imag();
|
| 78 |
+
|
| 79 |
+
get_float_word(hx, x);
|
| 80 |
+
ix = hx & 0x7fffffff;
|
| 81 |
+
|
| 82 |
+
if (ix >= 0x7f800000)
|
| 83 |
+
{
|
| 84 |
+
if (ix & 0x7fffff)
|
| 85 |
+
{
|
| 86 |
+
return (complex<float>(x, (y == 0.0f ? y : x * y)));
|
| 87 |
+
}
|
| 88 |
+
set_float_word(x, hx - 0x40000000);
|
| 89 |
+
return (complex<float>(x, copysignf(0, isinf(y) ? y : sinf(y) * cosf(y))));
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
if (!isfinite(y))
|
| 93 |
+
{
|
| 94 |
+
return (complex<float>(y - y, y - y));
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
if (ix >= 0x41300000)
|
| 98 |
+
{ /* x >= 11 */
|
| 99 |
+
float exp_mx = expf(-fabsf(x));
|
| 100 |
+
return (complex<float>(copysignf(1.0f, x), 4.0f * sinf(y) * cosf(y) * exp_mx * exp_mx));
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
t = tanf(y);
|
| 104 |
+
beta = 1.0f + t * t;
|
| 105 |
+
s = sinhf(x);
|
| 106 |
+
rho = sqrtf(1.0f + s * s);
|
| 107 |
+
denom = 1.0f + beta * s * s;
|
| 108 |
+
return (complex<float>((beta * rho * s) / denom, t / denom));
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
_CCCL_HOST_DEVICE inline complex<float> ctanf(complex<float> z)
|
| 112 |
+
{
|
| 113 |
+
z = ctanhf(complex<float>(-z.imag(), z.real()));
|
| 114 |
+
return (complex<float>(z.imag(), -z.real()));
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
} // namespace complex
|
| 118 |
+
|
| 119 |
+
} // namespace detail
|
| 120 |
+
|
| 121 |
+
template <>
|
| 122 |
+
_CCCL_HOST_DEVICE inline complex<float> tan(const complex<float>& z)
|
| 123 |
+
{
|
| 124 |
+
return detail::complex::ctanf(z);
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
template <>
|
| 128 |
+
_CCCL_HOST_DEVICE inline complex<float> tanh(const complex<float>& z)
|
| 129 |
+
{
|
| 130 |
+
return detail::complex::ctanhf(z);
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config.h
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
/*! \file config.h
|
| 17 |
+
* \brief Defines platform configuration.
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <thrust/detail/config/config.h> // IWYU pragma: export
|
| 23 |
+
#include <thrust/version.h> // IWYU pragma: export
|
| 24 |
+
|
| 25 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 26 |
+
# pragma GCC system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 28 |
+
# pragma clang system_header
|
| 29 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 30 |
+
# pragma system_header
|
| 31 |
+
#endif // no system header
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/compiler.h
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
/*! \file compiler.h
|
| 18 |
+
* \brief Compiler-specific configuration
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#pragma once
|
| 22 |
+
|
| 23 |
+
// Internal config header that is only included through thrust/detail/config/config.h
|
| 24 |
+
|
| 25 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 26 |
+
# pragma GCC system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 28 |
+
# pragma clang system_header
|
| 29 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 30 |
+
# pragma system_header
|
| 31 |
+
#endif // no system header
|
| 32 |
+
|
| 33 |
+
// enumerate host compilers we know about
|
| 34 |
+
//! deprecated [Since 2.7]
|
| 35 |
+
#define THRUST_HOST_COMPILER_UNKNOWN 0
|
| 36 |
+
//! deprecated [Since 2.7]
|
| 37 |
+
#define THRUST_HOST_COMPILER_MSVC 1
|
| 38 |
+
//! deprecated [Since 2.7]
|
| 39 |
+
#define THRUST_HOST_COMPILER_GCC 2
|
| 40 |
+
//! deprecated [Since 2.7]
|
| 41 |
+
#define THRUST_HOST_COMPILER_CLANG 3
|
| 42 |
+
//! deprecated [Since 2.7]
|
| 43 |
+
#define THRUST_HOST_COMPILER_INTEL 4
|
| 44 |
+
|
| 45 |
+
// enumerate device compilers we know about
|
| 46 |
+
//! deprecated [Since 2.7]
|
| 47 |
+
#define THRUST_DEVICE_COMPILER_UNKNOWN 0
|
| 48 |
+
//! deprecated [Since 2.7]
|
| 49 |
+
#define THRUST_DEVICE_COMPILER_MSVC 1
|
| 50 |
+
//! deprecated [Since 2.7]
|
| 51 |
+
#define THRUST_DEVICE_COMPILER_GCC 2
|
| 52 |
+
//! deprecated [Since 2.7]
|
| 53 |
+
#define THRUST_DEVICE_COMPILER_CLANG 3
|
| 54 |
+
//! deprecated [Since 2.7]
|
| 55 |
+
#define THRUST_DEVICE_COMPILER_NVCC 4
|
| 56 |
+
|
| 57 |
+
// figure out which host compiler we're using
|
| 58 |
+
#if _CCCL_COMPILER(MSVC)
|
| 59 |
+
//! deprecated [Since 2.7]
|
| 60 |
+
# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_MSVC
|
| 61 |
+
//! deprecated [Since 2.7]
|
| 62 |
+
# define THRUST_MSVC_VERSION _MSC_VER
|
| 63 |
+
//! deprecated [Since 2.7]
|
| 64 |
+
# define THRUST_MSVC_VERSION_FULL _MSC_FULL_VER
|
| 65 |
+
#elif _CCCL_COMPILER(ICC)
|
| 66 |
+
//! deprecated [Since 2.7]
|
| 67 |
+
# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_INTEL
|
| 68 |
+
#elif _CCCL_COMPILER(CLANG)
|
| 69 |
+
//! deprecated [Since 2.7]
|
| 70 |
+
# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_CLANG
|
| 71 |
+
//! deprecated [Since 2.7]
|
| 72 |
+
# define THRUST_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
|
| 73 |
+
#elif _CCCL_COMPILER(GCC)
|
| 74 |
+
//! deprecated [Since 2.7]
|
| 75 |
+
# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_GCC
|
| 76 |
+
//! deprecated [Since 2.7]
|
| 77 |
+
# define THRUST_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
| 78 |
+
# if _CCCL_COMPILER(GCC, >=, 5)
|
| 79 |
+
//! deprecated [Since 2.7]
|
| 80 |
+
# define THRUST_MODERN_GCC
|
| 81 |
+
# else
|
| 82 |
+
//! deprecated [Since 2.7]
|
| 83 |
+
# define THRUST_LEGACY_GCC
|
| 84 |
+
# endif
|
| 85 |
+
#else
|
| 86 |
+
//! deprecated [Since 2.7]
|
| 87 |
+
# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_UNKNOWN
|
| 88 |
+
#endif // TRUST_HOST_COMPILER
|
| 89 |
+
|
| 90 |
+
// figure out which device compiler we're using
|
| 91 |
+
#if defined(__CUDACC__) || defined(_NVHPC_CUDA)
|
| 92 |
+
//! deprecated [Since 2.7]
|
| 93 |
+
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_NVCC
|
| 94 |
+
#elif _CCCL_COMPILER(MSVC)
|
| 95 |
+
//! deprecated [Since 2.7]
|
| 96 |
+
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_MSVC
|
| 97 |
+
#elif _CCCL_COMPILER(GCC)
|
| 98 |
+
//! deprecated [Since 2.7]
|
| 99 |
+
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_GCC
|
| 100 |
+
#elif _CCCL_COMPILER(CLANG)
|
| 101 |
+
// CUDA-capable clang should behave similar to NVCC.
|
| 102 |
+
# if defined(__CUDA__)
|
| 103 |
+
//! deprecated [Since 2.7]
|
| 104 |
+
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_NVCC
|
| 105 |
+
# else
|
| 106 |
+
//! deprecated [Since 2.7]
|
| 107 |
+
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_CLANG
|
| 108 |
+
# endif
|
| 109 |
+
#else
|
| 110 |
+
//! deprecated [Since 2.7]
|
| 111 |
+
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_UNKNOWN
|
| 112 |
+
#endif
|
| 113 |
+
|
| 114 |
+
// is the device compiler capable of compiling omp?
|
| 115 |
+
#if defined(_OPENMP) || defined(_NVHPC_STDPAR_OPENMP)
|
| 116 |
+
# define THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE THRUST_TRUE
|
| 117 |
+
#else
|
| 118 |
+
# define THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE THRUST_FALSE
|
| 119 |
+
#endif // _OPENMP
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/compiler_fence.h
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
#include <thrust/detail/preprocessor.h>
|
| 30 |
+
|
| 31 |
+
#if _CCCL_COMPILER(MSVC)
|
| 32 |
+
# pragma message( \
|
| 33 |
+
"warning: The functionality in this header is unsafe, deprecated, and will soon be removed. Use C++11 atomics instead.")
|
| 34 |
+
#else
|
| 35 |
+
#warning The functionality in this header is unsafe, deprecated, and will soon be removed. Use C++11 or C11 atomics instead.
|
| 36 |
+
#endif
|
| 37 |
+
|
| 38 |
+
// msvc case
|
| 39 |
+
#if _CCCL_COMPILER(MSVC)
|
| 40 |
+
|
| 41 |
+
# ifndef _DEBUG
|
| 42 |
+
|
| 43 |
+
# include <intrin.h>
|
| 44 |
+
# pragma intrinsic(_ReadWriteBarrier)
|
| 45 |
+
# define __thrust_compiler_fence() _ReadWriteBarrier()
|
| 46 |
+
# else
|
| 47 |
+
|
| 48 |
+
# define __thrust_compiler_fence() \
|
| 49 |
+
do \
|
| 50 |
+
{ \
|
| 51 |
+
} while (0)
|
| 52 |
+
|
| 53 |
+
# endif // _DEBUG
|
| 54 |
+
|
| 55 |
+
// gcc case
|
| 56 |
+
#elif _CCCL_COMPILER(GCC)
|
| 57 |
+
|
| 58 |
+
# if _CCCL_COMPILER(GCC, >=, 4, 2) // atomic built-ins were introduced ~4.2
|
| 59 |
+
# define __thrust_compiler_fence() __sync_synchronize()
|
| 60 |
+
# else
|
| 61 |
+
// allow the code to compile without any guarantees
|
| 62 |
+
# define __thrust_compiler_fence() \
|
| 63 |
+
do \
|
| 64 |
+
{ \
|
| 65 |
+
} while (0)
|
| 66 |
+
# endif // _CCCL_COMPILER(GCC, >=, 4, 2)
|
| 67 |
+
|
| 68 |
+
// unknown case
|
| 69 |
+
#elif _CCCL_COMPILER(CLANG)
|
| 70 |
+
# define __thrust_compiler_fence() __sync_synchronize()
|
| 71 |
+
#else
|
| 72 |
+
|
| 73 |
+
// allow the code to compile without any guarantees
|
| 74 |
+
# define __thrust_compiler_fence() \
|
| 75 |
+
do \
|
| 76 |
+
{ \
|
| 77 |
+
} while (0)
|
| 78 |
+
|
| 79 |
+
#endif
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/config.h
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
/*! \file config.h
|
| 18 |
+
* \brief Defines platform configuration.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#pragma once
|
| 22 |
+
|
| 23 |
+
// For _CCCL_IMPLICIT_SYSTEM_HEADER
|
| 24 |
+
#include <cuda/__cccl_config> // IWYU pragma: export
|
| 25 |
+
|
| 26 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 27 |
+
# pragma GCC system_header
|
| 28 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 29 |
+
# pragma clang system_header
|
| 30 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 31 |
+
# pragma system_header
|
| 32 |
+
#endif // no system header
|
| 33 |
+
|
| 34 |
+
// NOTE: The order of these #includes matters.
|
| 35 |
+
|
| 36 |
+
#include <thrust/detail/config/compiler.h> // IWYU pragma: export
|
| 37 |
+
#include <thrust/detail/config/cpp_compatibility.h> // IWYU pragma: export
|
| 38 |
+
#include <thrust/detail/config/cpp_dialect.h> // IWYU pragma: export
|
| 39 |
+
#include <thrust/detail/config/simple_defines.h> // IWYU pragma: export
|
| 40 |
+
// host_system.h & device_system.h must be #included as early as possible because other config headers depend on it
|
| 41 |
+
#include <thrust/detail/config/host_system.h> // IWYU pragma: export
|
| 42 |
+
|
| 43 |
+
#include <thrust/detail/config/device_system.h> // IWYU pragma: export
|
| 44 |
+
#include <thrust/detail/config/global_workarounds.h> // IWYU pragma: export
|
| 45 |
+
#include <thrust/detail/config/namespace.h> // IWYU pragma: export
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/cpp_compatibility.h
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2018 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
// Internal config header that is only included through thrust/detail/config/config.h
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// deprecated [Since 2.8.0]
|
| 30 |
+
#define THRUST_NODISCARD _CCCL_NODISCARD
|
| 31 |
+
// deprecated [Since 2.8.0]
|
| 32 |
+
#define THRUST_INLINE_CONSTANT _CCCL_GLOBAL_CONSTANT
|
| 33 |
+
// deprecated [Since 2.8.0]
|
| 34 |
+
#define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr
|
| 35 |
+
|
| 36 |
+
// These definitions were intended for internal use only and are now obsolete.
|
| 37 |
+
// If you relied on them, consider porting your code to use the functionality
|
| 38 |
+
// in libcu++'s <nv/target> header.
|
| 39 |
+
// For a temporary workaround, define THRUST_PROVIDE_LEGACY_ARCH_MACROS to make
|
| 40 |
+
// them available again. These should be considered deprecated and will be
|
| 41 |
+
// fully removed in a future version.
|
| 42 |
+
#ifdef THRUST_PROVIDE_LEGACY_ARCH_MACROS
|
| 43 |
+
# ifndef THRUST_IS_DEVICE_CODE
|
| 44 |
+
# if defined(_NVHPC_CUDA)
|
| 45 |
+
# define THRUST_IS_DEVICE_CODE __builtin_is_device_code()
|
| 46 |
+
# define THRUST_IS_HOST_CODE (!__builtin_is_device_code())
|
| 47 |
+
# define THRUST_INCLUDE_DEVICE_CODE 1
|
| 48 |
+
# define THRUST_INCLUDE_HOST_CODE 1
|
| 49 |
+
# elif defined(__CUDA_ARCH__)
|
| 50 |
+
# define THRUST_IS_DEVICE_CODE 1
|
| 51 |
+
# define THRUST_IS_HOST_CODE 0
|
| 52 |
+
# define THRUST_INCLUDE_DEVICE_CODE 1
|
| 53 |
+
# define THRUST_INCLUDE_HOST_CODE 0
|
| 54 |
+
# else
|
| 55 |
+
# define THRUST_IS_DEVICE_CODE 0
|
| 56 |
+
# define THRUST_IS_HOST_CODE 1
|
| 57 |
+
# define THRUST_INCLUDE_DEVICE_CODE 0
|
| 58 |
+
# define THRUST_INCLUDE_HOST_CODE 1
|
| 59 |
+
# endif
|
| 60 |
+
# endif
|
| 61 |
+
#endif // THRUST_PROVIDE_LEGACY_ARCH_MACROS
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/cpp_dialect.h
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2020 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
/*! \file cpp_dialect.h
|
| 18 |
+
* \brief Detect the version of the C++ standard used by the compiler.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#pragma once
|
| 22 |
+
|
| 23 |
+
#include <thrust/detail/config/config.h>
|
| 24 |
+
|
| 25 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 26 |
+
# pragma GCC system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 28 |
+
# pragma clang system_header
|
| 29 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 30 |
+
# pragma system_header
|
| 31 |
+
#endif // no system header
|
| 32 |
+
|
| 33 |
+
#include <thrust/detail/config/compiler.h> // IWYU pragma: export
|
| 34 |
+
|
| 35 |
+
// Deprecation warnings may be silenced by defining the following macros. These
|
| 36 |
+
// may be combined.
|
| 37 |
+
// - CCCL_IGNORE_DEPRECATED_CPP_DIALECT:
|
| 38 |
+
// Ignore all deprecated C++ dialects and outdated compilers.
|
| 39 |
+
// - CCCL_IGNORE_DEPRECATED_CPP_11:
|
| 40 |
+
// Ignore deprecation warnings when compiling with C++11. C++03 and outdated
|
| 41 |
+
// compilers will still issue warnings.
|
| 42 |
+
// - CCCL_IGNORE_DEPRECATED_CPP_14:
|
| 43 |
+
// Ignore deprecation warnings when compiling with C++14. C++03 and outdated
|
| 44 |
+
// compilers will still issue warnings.
|
| 45 |
+
// - CCCL_IGNORE_DEPRECATED_COMPILER
|
| 46 |
+
// Ignore deprecation warnings when using deprecated compilers. Compiling
|
| 47 |
+
// with C++03, C++11 and C++14 will still issue warnings.
|
| 48 |
+
|
| 49 |
+
#define THRUST_CPP_DIALECT _CCCL_STD_VER
|
| 50 |
+
|
| 51 |
+
// Define THRUST_COMPILER_DEPRECATION macro:
|
| 52 |
+
#if _CCCL_COMPILER(MSVC) || _CCCL_COMPILER(NVRTC)
|
| 53 |
+
# define THRUST_COMP_DEPR_IMPL(msg) _CCCL_PRAGMA(message(__FILE__ ":" _CCCL_TO_STRING(__LINE__) ": warning: " #msg))
|
| 54 |
+
#else // clang / gcc:
|
| 55 |
+
# define THRUST_COMP_DEPR_IMPL(msg) _CCCL_PRAGMA(GCC warning #msg)
|
| 56 |
+
#endif
|
| 57 |
+
|
| 58 |
+
// clang-format off
|
| 59 |
+
#define THRUST_COMPILER_DEPRECATION(REQ) \
|
| 60 |
+
THRUST_COMP_DEPR_IMPL(Thrust requires at least REQ. Define CCCL_IGNORE_DEPRECATED_COMPILER to suppress this message.)
|
| 61 |
+
|
| 62 |
+
#define THRUST_COMPILER_DEPRECATION_SOFT(REQ, CUR) \
|
| 63 |
+
THRUST_COMP_DEPR_IMPL( \
|
| 64 |
+
Thrust requires at least REQ. CUR is deprecated but still supported. CUR support will be removed in a \
|
| 65 |
+
future release. Define CCCL_IGNORE_DEPRECATED_CPP_DIALECT to suppress this message.)
|
| 66 |
+
// clang-format on
|
| 67 |
+
|
| 68 |
+
#ifndef CCCL_IGNORE_DEPRECATED_COMPILER
|
| 69 |
+
|
| 70 |
+
// Compiler checks:
|
| 71 |
+
# if _CCCL_COMPILER(GCC, <, 5)
|
| 72 |
+
THRUST_COMPILER_DEPRECATION(GCC 5.0);
|
| 73 |
+
# elif _CCCL_COMPILER(CLANG, <, 7)
|
| 74 |
+
THRUST_COMPILER_DEPRECATION(Clang 7.0);
|
| 75 |
+
# elif _CCCL_COMPILER(MSVC, <, 19, 10)
|
| 76 |
+
// <2017. Hard upgrade message:
|
| 77 |
+
THRUST_COMPILER_DEPRECATION(MSVC 2019(19.20 / 16.0 / 14.20));
|
| 78 |
+
# elif _CCCL_COMPILER(MSVC2017)
|
| 79 |
+
// >=2017, <2019. Soft deprecation message:
|
| 80 |
+
THRUST_COMPILER_DEPRECATION_SOFT(MSVC 2019(19.20 / 16.0 / 14.20), MSVC 2017);
|
| 81 |
+
# endif
|
| 82 |
+
|
| 83 |
+
#endif // CCCL_IGNORE_DEPRECATED_COMPILER
|
| 84 |
+
|
| 85 |
+
#if _CCCL_STD_VER < 2011
|
| 86 |
+
// <C++11. Hard upgrade message:
|
| 87 |
+
THRUST_COMPILER_DEPRECATION(C++ 17);
|
| 88 |
+
#elif _CCCL_STD_VER == 2011 && !defined(CCCL_IGNORE_DEPRECATED_CPP_11)
|
| 89 |
+
// =C++11. Soft upgrade message:
|
| 90 |
+
THRUST_COMPILER_DEPRECATION_SOFT(C++ 17, C++ 11);
|
| 91 |
+
#elif _CCCL_STD_VER == 2014 && !defined(CCCL_IGNORE_DEPRECATED_CPP_14)
|
| 92 |
+
// =C++14. Soft upgrade message:
|
| 93 |
+
THRUST_COMPILER_DEPRECATION_SOFT(C++ 17, C++ 14);
|
| 94 |
+
#endif // _CCCL_STD_VER >= 2017
|
| 95 |
+
|
| 96 |
+
#undef THRUST_COMPILER_DEPRECATION_SOFT
|
| 97 |
+
#undef THRUST_COMPILER_DEPRECATION
|
| 98 |
+
#undef THRUST_COMP_DEPR_IMPL
|
| 99 |
+
#undef THRUST_COMP_DEPR_IMPL0
|
| 100 |
+
#undef THRUST_COMP_DEPR_IMPL1
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/device_system.h
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
// Internal config header that is only included through thrust/detail/config/config.h
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// reserve 0 for undefined
|
| 30 |
+
#define THRUST_DEVICE_SYSTEM_CUDA 1
|
| 31 |
+
#define THRUST_DEVICE_SYSTEM_OMP 2
|
| 32 |
+
#define THRUST_DEVICE_SYSTEM_TBB 3
|
| 33 |
+
#define THRUST_DEVICE_SYSTEM_CPP 4
|
| 34 |
+
|
| 35 |
+
#ifndef THRUST_DEVICE_SYSTEM
|
| 36 |
+
# define THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_CUDA
|
| 37 |
+
#endif // THRUST_DEVICE_SYSTEM
|
| 38 |
+
|
| 39 |
+
#ifdef THRUST_DEVICE_BACKEND
|
| 40 |
+
# error THRUST_DEVICE_BACKEND is no longer supported; use THRUST_DEVICE_SYSTEM instead.
|
| 41 |
+
#endif // THRUST_DEVICE_BACKEND
|
| 42 |
+
|
| 43 |
+
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
|
| 44 |
+
# define __THRUST_DEVICE_SYSTEM_NAMESPACE cuda
|
| 45 |
+
#elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_OMP
|
| 46 |
+
# define __THRUST_DEVICE_SYSTEM_NAMESPACE omp
|
| 47 |
+
#elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_TBB
|
| 48 |
+
# define __THRUST_DEVICE_SYSTEM_NAMESPACE tbb
|
| 49 |
+
#elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CPP
|
| 50 |
+
# define __THRUST_DEVICE_SYSTEM_NAMESPACE cpp
|
| 51 |
+
#endif
|
| 52 |
+
|
| 53 |
+
// clang-format off
|
| 54 |
+
#define __THRUST_DEVICE_SYSTEM_ROOT thrust/system/__THRUST_DEVICE_SYSTEM_NAMESPACE
|
| 55 |
+
// clang-format on
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/global_workarounds.h
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
// Internal config header that is only included through thrust/detail/config/config.h
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
#include <thrust/detail/config/compiler.h>
|
| 30 |
+
|
| 31 |
+
// XXX workaround gcc 4.8+'s complaints about unused local aliases by silencing them globally
|
| 32 |
+
#if _CCCL_COMPILER(GCC, >=, 4, 8)
|
| 33 |
+
# if defined(__NVCC__) && (CUDART_VERSION >= 6000)
|
| 34 |
+
# pragma GCC diagnostic ignored "-Wunused-local-typedefs"
|
| 35 |
+
# endif // nvcc & cuda 6+
|
| 36 |
+
#endif // gcc 4.8
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/host_system.h
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
// Internal config header that is only included through thrust/detail/config/config.h
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// reserve 0 for undefined
|
| 30 |
+
#define THRUST_HOST_SYSTEM_CPP 1
|
| 31 |
+
#define THRUST_HOST_SYSTEM_OMP 2
|
| 32 |
+
#define THRUST_HOST_SYSTEM_TBB 3
|
| 33 |
+
|
| 34 |
+
#ifndef THRUST_HOST_SYSTEM
|
| 35 |
+
# define THRUST_HOST_SYSTEM THRUST_HOST_SYSTEM_CPP
|
| 36 |
+
#endif // THRUST_HOST_SYSTEM
|
| 37 |
+
|
| 38 |
+
#ifdef THRUST_HOST_BACKEND
|
| 39 |
+
# error THRUST_HOST_BACKEND is no longer supported; use THRUST_HOST_SYSTEM instead.
|
| 40 |
+
#endif // THRUST_HOST_BACKEND
|
| 41 |
+
|
| 42 |
+
#if THRUST_HOST_SYSTEM == THRUST_HOST_SYSTEM_CPP
|
| 43 |
+
# define __THRUST_HOST_SYSTEM_NAMESPACE cpp
|
| 44 |
+
#elif THRUST_HOST_SYSTEM == THRUST_HOST_SYSTEM_OMP
|
| 45 |
+
# define __THRUST_HOST_SYSTEM_NAMESPACE omp
|
| 46 |
+
#elif THRUST_HOST_SYSTEM == THRUST_HOST_SYSTEM_TBB
|
| 47 |
+
# define __THRUST_HOST_SYSTEM_NAMESPACE tbb
|
| 48 |
+
#endif
|
| 49 |
+
|
| 50 |
+
// clang-format off
|
| 51 |
+
#define __THRUST_HOST_SYSTEM_ROOT thrust/system/__THRUST_HOST_SYSTEM_NAMESPACE
|
| 52 |
+
// clang-format on
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/memory_resource.h
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2018 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
#include <thrust/detail/alignment.h>
|
| 30 |
+
#include <thrust/detail/config/cpp_compatibility.h>
|
| 31 |
+
|
| 32 |
+
#include <cstddef>
|
| 33 |
+
|
| 34 |
+
#define THRUST_MR_DEFAULT_ALIGNMENT alignof(THRUST_NS_QUALIFIER::detail::max_align_t)
|
| 35 |
+
|
| 36 |
+
#if _CCCL_STD_VER >= 2017
|
| 37 |
+
# if _CCCL_HAS_INCLUDE(<memory_resource>)
|
| 38 |
+
# define THRUST_MR_STD_MR_HEADER <memory_resource>
|
| 39 |
+
# define THRUST_MR_STD_MR_NS std::pmr
|
| 40 |
+
# elif _CCCL_HAS_INCLUDE(<experimental/memory_resource>)
|
| 41 |
+
# define THRUST_MR_STD_MR_HEADER <experimental/memory_resource>
|
| 42 |
+
# define THRUST_MR_STD_MR_NS std::experimental::pmr
|
| 43 |
+
# endif
|
| 44 |
+
#endif
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/namespace.h
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2021 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
// Internal config header that is only included through thrust/detail/config/config.h
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
#include <thrust/detail/config/device_system.h>
|
| 30 |
+
#include <thrust/version.h>
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* \file namespace.h
|
| 34 |
+
* \brief Utilities that allow `thrust::` to be placed inside an
|
| 35 |
+
* application-specific namespace.
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* \def THRUST_CUB_WRAPPED_NAMESPACE
|
| 40 |
+
* If defined, this value will be used as the name of a namespace that wraps the
|
| 41 |
+
* `thrust::` and `cub::` namespaces.
|
| 42 |
+
* This macro should not be used with any other Thrust namespace macros.
|
| 43 |
+
*/
|
| 44 |
+
#ifdef THRUST_CUB_WRAPPED_NAMESPACE
|
| 45 |
+
# define THRUST_WRAPPED_NAMESPACE THRUST_CUB_WRAPPED_NAMESPACE
|
| 46 |
+
#endif
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* \def THRUST_WRAPPED_NAMESPACE
|
| 50 |
+
* If defined, this value will be used as the name of a namespace that wraps the
|
| 51 |
+
* `thrust::` namespace.
|
| 52 |
+
* If THRUST_CUB_WRAPPED_NAMESPACE is set, this will inherit that macro's value.
|
| 53 |
+
* This macro should not be used with any other Thrust namespace macros.
|
| 54 |
+
*/
|
| 55 |
+
#ifdef THRUST_WRAPPED_NAMESPACE
|
| 56 |
+
# define THRUST_NS_PREFIX \
|
| 57 |
+
namespace THRUST_WRAPPED_NAMESPACE \
|
| 58 |
+
{
|
| 59 |
+
|
| 60 |
+
# define THRUST_NS_POSTFIX }
|
| 61 |
+
|
| 62 |
+
# define THRUST_NS_QUALIFIER ::THRUST_WRAPPED_NAMESPACE::thrust
|
| 63 |
+
#endif
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* \def THRUST_NS_PREFIX
|
| 67 |
+
* This macro is inserted prior to all `namespace thrust { ... }` blocks. It is
|
| 68 |
+
* derived from THRUST_WRAPPED_NAMESPACE, if set, and will be empty otherwise.
|
| 69 |
+
* It may be defined by users, in which case THRUST_NS_PREFIX,
|
| 70 |
+
* THRUST_NS_POSTFIX, and THRUST_NS_QUALIFIER must all be set consistently.
|
| 71 |
+
*/
|
| 72 |
+
#ifndef THRUST_NS_PREFIX
|
| 73 |
+
# define THRUST_NS_PREFIX
|
| 74 |
+
#endif
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* \def THRUST_NS_POSTFIX
|
| 78 |
+
* This macro is inserted following the closing braces of all
|
| 79 |
+
* `namespace thrust { ... }` block. It is defined appropriately when
|
| 80 |
+
* THRUST_WRAPPED_NAMESPACE is set, and will be empty otherwise. It may be
|
| 81 |
+
* defined by users, in which case THRUST_NS_PREFIX, THRUST_NS_POSTFIX, and
|
| 82 |
+
* THRUST_NS_QUALIFIER must all be set consistently.
|
| 83 |
+
*/
|
| 84 |
+
#ifndef THRUST_NS_POSTFIX
|
| 85 |
+
# define THRUST_NS_POSTFIX
|
| 86 |
+
#endif
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* \def THRUST_NS_QUALIFIER
|
| 90 |
+
* This macro is used to qualify members of thrust:: when accessing them from
|
| 91 |
+
* outside of their namespace. By default, this is just `::thrust`, and will be
|
| 92 |
+
* set appropriately when THRUST_WRAPPED_NAMESPACE is defined. This macro may be
|
| 93 |
+
* defined by users, in which case THRUST_NS_PREFIX, THRUST_NS_POSTFIX, and
|
| 94 |
+
* THRUST_NS_QUALIFIER must all be set consistently.
|
| 95 |
+
*/
|
| 96 |
+
#ifndef THRUST_NS_QUALIFIER
|
| 97 |
+
# define THRUST_NS_QUALIFIER ::thrust
|
| 98 |
+
#endif
|
| 99 |
+
|
| 100 |
+
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
|
| 101 |
+
# if defined(THRUST_DISABLE_ABI_NAMESPACE) || defined(THRUST_WRAPPED_NAMESPACE)
|
| 102 |
+
# if !defined(THRUST_WRAPPED_NAMESPACE)
|
| 103 |
+
# if !defined(THRUST_IGNORE_ABI_NAMESPACE_ERROR)
|
| 104 |
+
# error "Disabling ABI namespace is unsafe without wrapping namespace"
|
| 105 |
+
# endif // !defined(THRUST_IGNORE_ABI_NAMESPACE_ERROR)
|
| 106 |
+
# endif // !defined(THRUST_WRAPPED_NAMESPACE)
|
| 107 |
+
# define THRUST_DETAIL_ABI_NS_BEGIN
|
| 108 |
+
# define THRUST_DETAIL_ABI_NS_END
|
| 109 |
+
# else // not defined(THRUST_DISABLE_ABI_NAMESPACE)
|
| 110 |
+
# if defined(_NVHPC_CUDA)
|
| 111 |
+
# define THRUST_DETAIL_ABI_NS_BEGIN \
|
| 112 |
+
inline namespace _CCCL_PP_SPLICE_WITH(_, THRUST, THRUST_VERSION, SM, NV_TARGET_SM_INTEGER_LIST, NVHPC, NS) \
|
| 113 |
+
{
|
| 114 |
+
# define THRUST_DETAIL_ABI_NS_END }
|
| 115 |
+
# else // not defined(_NVHPC_CUDA)
|
| 116 |
+
# define THRUST_DETAIL_ABI_NS_BEGIN \
|
| 117 |
+
inline namespace _CCCL_PP_SPLICE_WITH(_, THRUST, THRUST_VERSION, SM, __CUDA_ARCH_LIST__, NS) \
|
| 118 |
+
{
|
| 119 |
+
# define THRUST_DETAIL_ABI_NS_END }
|
| 120 |
+
# endif // not defined(_NVHPC_CUDA)
|
| 121 |
+
# endif // not defined(THRUST_DISABLE_ABI_NAMESPACE)
|
| 122 |
+
#else // THRUST_DEVICE_SYSTEM != THRUST_DEVICE_SYSTEM_CUDA
|
| 123 |
+
# define THRUST_DETAIL_ABI_NS_BEGIN
|
| 124 |
+
# define THRUST_DETAIL_ABI_NS_END
|
| 125 |
+
#endif // THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* \def THRUST_NAMESPACE_BEGIN
|
| 129 |
+
* This macro is used to open a `thrust::` namespace block, along with any
|
| 130 |
+
* enclosing namespaces requested by THRUST_WRAPPED_NAMESPACE, etc.
|
| 131 |
+
* This macro is defined by Thrust and may not be overridden.
|
| 132 |
+
*/
|
| 133 |
+
#define THRUST_NAMESPACE_BEGIN \
|
| 134 |
+
THRUST_NS_PREFIX \
|
| 135 |
+
namespace thrust \
|
| 136 |
+
{ \
|
| 137 |
+
THRUST_DETAIL_ABI_NS_BEGIN
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* \def THRUST_NAMESPACE_END
|
| 141 |
+
* This macro is used to close a `thrust::` namespace block, along with any
|
| 142 |
+
* enclosing namespaces requested by THRUST_WRAPPED_NAMESPACE, etc.
|
| 143 |
+
* This macro is defined by Thrust and may not be overridden.
|
| 144 |
+
*/
|
| 145 |
+
#define THRUST_NAMESPACE_END \
|
| 146 |
+
THRUST_DETAIL_ABI_NS_END \
|
| 147 |
+
} /* end namespace thrust */ \
|
| 148 |
+
THRUST_NS_POSTFIX
|
| 149 |
+
|
| 150 |
+
// The following is just here to add docs for the thrust namespace:
|
| 151 |
+
|
| 152 |
+
THRUST_NS_PREFIX
|
| 153 |
+
|
| 154 |
+
/*! \namespace thrust
|
| 155 |
+
* \brief \p thrust is the top-level namespace which contains all Thrust
|
| 156 |
+
* functions and types.
|
| 157 |
+
*/
|
| 158 |
+
namespace thrust
|
| 159 |
+
{
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
THRUST_NS_POSTFIX
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/config/simple_defines.h
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
/*! \file simple_defines.h
|
| 18 |
+
* \brief Primitive macros without dependencies.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#pragma once
|
| 22 |
+
|
| 23 |
+
// Internal config header that is only included through thrust/detail/config/config.h
|
| 24 |
+
|
| 25 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 26 |
+
# pragma GCC system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 28 |
+
# pragma clang system_header
|
| 29 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 30 |
+
# pragma system_header
|
| 31 |
+
#endif // no system header
|
| 32 |
+
|
| 33 |
+
#define THRUST_UNKNOWN 0
|
| 34 |
+
#define THRUST_FALSE 0
|
| 35 |
+
#define THRUST_TRUE 1
|
| 36 |
+
|
| 37 |
+
#define THRUST_UNUSED_VAR(expr) \
|
| 38 |
+
do \
|
| 39 |
+
{ \
|
| 40 |
+
(void) (expr); \
|
| 41 |
+
} while (0)
|
| 42 |
+
|
| 43 |
+
#define THRUST_PREVENT_MACRO_SUBSTITUTION
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/copy.h
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/execution_policy.h>
|
| 29 |
+
|
| 30 |
+
THRUST_NAMESPACE_BEGIN
|
| 31 |
+
|
| 32 |
+
template <typename System, typename InputIterator, typename OutputIterator>
|
| 33 |
+
_CCCL_HOST_DEVICE OutputIterator
|
| 34 |
+
copy(const thrust::detail::execution_policy_base<System>& system,
|
| 35 |
+
InputIterator first,
|
| 36 |
+
InputIterator last,
|
| 37 |
+
OutputIterator result);
|
| 38 |
+
|
| 39 |
+
template <typename System, typename InputIterator, typename Size, typename OutputIterator>
|
| 40 |
+
_CCCL_HOST_DEVICE OutputIterator
|
| 41 |
+
copy_n(const thrust::detail::execution_policy_base<System>& system, InputIterator first, Size n, OutputIterator result);
|
| 42 |
+
|
| 43 |
+
template <typename InputIterator, typename OutputIterator>
|
| 44 |
+
OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result);
|
| 45 |
+
|
| 46 |
+
template <typename InputIterator, typename Size, typename OutputIterator>
|
| 47 |
+
OutputIterator copy_n(InputIterator first, Size n, OutputIterator result);
|
| 48 |
+
|
| 49 |
+
namespace detail
|
| 50 |
+
{
|
| 51 |
+
|
| 52 |
+
template <typename FromSystem, typename ToSystem, typename InputIterator, typename OutputIterator>
|
| 53 |
+
_CCCL_HOST_DEVICE OutputIterator two_system_copy(
|
| 54 |
+
const thrust::execution_policy<FromSystem>& from_system,
|
| 55 |
+
const thrust::execution_policy<ToSystem>& two_system,
|
| 56 |
+
InputIterator first,
|
| 57 |
+
InputIterator last,
|
| 58 |
+
OutputIterator result);
|
| 59 |
+
|
| 60 |
+
template <typename FromSystem, typename ToSystem, typename InputIterator, typename Size, typename OutputIterator>
|
| 61 |
+
_CCCL_HOST_DEVICE OutputIterator two_system_copy_n(
|
| 62 |
+
const thrust::execution_policy<FromSystem>& from_system,
|
| 63 |
+
const thrust::execution_policy<ToSystem>& two_system,
|
| 64 |
+
InputIterator first,
|
| 65 |
+
Size n,
|
| 66 |
+
OutputIterator result);
|
| 67 |
+
|
| 68 |
+
} // namespace detail
|
| 69 |
+
|
| 70 |
+
THRUST_NAMESPACE_END
|
| 71 |
+
|
| 72 |
+
#include <thrust/detail/copy.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/copy.inl
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/copy.h>
|
| 29 |
+
#include <thrust/system/detail/adl/copy.h>
|
| 30 |
+
#include <thrust/system/detail/generic/copy.h>
|
| 31 |
+
#include <thrust/system/detail/generic/select_system.h>
|
| 32 |
+
|
| 33 |
+
THRUST_NAMESPACE_BEGIN
|
| 34 |
+
|
| 35 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 36 |
+
template <typename DerivedPolicy, typename InputIterator, typename OutputIterator>
|
| 37 |
+
_CCCL_HOST_DEVICE OutputIterator
|
| 38 |
+
copy(const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
| 39 |
+
InputIterator first,
|
| 40 |
+
InputIterator last,
|
| 41 |
+
OutputIterator result)
|
| 42 |
+
{
|
| 43 |
+
using thrust::system::detail::generic::copy;
|
| 44 |
+
return copy(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, result);
|
| 45 |
+
} // end copy()
|
| 46 |
+
|
| 47 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 48 |
+
template <typename DerivedPolicy, typename InputIterator, typename Size, typename OutputIterator>
|
| 49 |
+
_CCCL_HOST_DEVICE OutputIterator copy_n(
|
| 50 |
+
const thrust::detail::execution_policy_base<DerivedPolicy>& exec, InputIterator first, Size n, OutputIterator result)
|
| 51 |
+
{
|
| 52 |
+
using thrust::system::detail::generic::copy_n;
|
| 53 |
+
return copy_n(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, n, result);
|
| 54 |
+
} // end copy_n()
|
| 55 |
+
|
| 56 |
+
namespace detail
|
| 57 |
+
{
|
| 58 |
+
|
| 59 |
+
_CCCL_EXEC_CHECK_DISABLE // because we might call e.g. std::ostream_iterator's constructor
|
| 60 |
+
template <typename System1, typename System2, typename InputIterator, typename OutputIterator>
|
| 61 |
+
_CCCL_HOST_DEVICE OutputIterator two_system_copy(
|
| 62 |
+
const thrust::execution_policy<System1>& system1,
|
| 63 |
+
const thrust::execution_policy<System2>& system2,
|
| 64 |
+
InputIterator first,
|
| 65 |
+
InputIterator last,
|
| 66 |
+
OutputIterator result)
|
| 67 |
+
{
|
| 68 |
+
using thrust::system::detail::generic::select_system;
|
| 69 |
+
|
| 70 |
+
return thrust::copy(
|
| 71 |
+
select_system(thrust::detail::derived_cast(thrust::detail::strip_const(system1)),
|
| 72 |
+
thrust::detail::derived_cast(thrust::detail::strip_const(system2))),
|
| 73 |
+
first,
|
| 74 |
+
last,
|
| 75 |
+
result);
|
| 76 |
+
} // end two_system_copy()
|
| 77 |
+
|
| 78 |
+
_CCCL_EXEC_CHECK_DISABLE // because we might call e.g. std::ostream_iterator's constructor
|
| 79 |
+
template <typename System1, typename System2, typename InputIterator, typename Size, typename OutputIterator>
|
| 80 |
+
_CCCL_HOST_DEVICE OutputIterator two_system_copy_n(
|
| 81 |
+
const thrust::execution_policy<System1>& system1,
|
| 82 |
+
const thrust::execution_policy<System2>& system2,
|
| 83 |
+
InputIterator first,
|
| 84 |
+
Size n,
|
| 85 |
+
OutputIterator result)
|
| 86 |
+
{
|
| 87 |
+
using thrust::system::detail::generic::select_system;
|
| 88 |
+
|
| 89 |
+
return thrust::copy_n(
|
| 90 |
+
select_system(thrust::detail::derived_cast(thrust::detail::strip_const(system1)),
|
| 91 |
+
thrust::detail::derived_cast(thrust::detail::strip_const(system2))),
|
| 92 |
+
first,
|
| 93 |
+
n,
|
| 94 |
+
result);
|
| 95 |
+
} // end two_system_copy_n()
|
| 96 |
+
|
| 97 |
+
} // namespace detail
|
| 98 |
+
|
| 99 |
+
template <typename InputIterator, typename OutputIterator>
|
| 100 |
+
OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result)
|
| 101 |
+
{
|
| 102 |
+
using System1 = typename thrust::iterator_system<InputIterator>::type;
|
| 103 |
+
using System2 = typename thrust::iterator_system<OutputIterator>::type;
|
| 104 |
+
|
| 105 |
+
System1 system1;
|
| 106 |
+
System2 system2;
|
| 107 |
+
|
| 108 |
+
return thrust::detail::two_system_copy(system1, system2, first, last, result);
|
| 109 |
+
} // end copy()
|
| 110 |
+
|
| 111 |
+
template <typename InputIterator, typename Size, typename OutputIterator>
|
| 112 |
+
OutputIterator copy_n(InputIterator first, Size n, OutputIterator result)
|
| 113 |
+
{
|
| 114 |
+
using System1 = typename thrust::iterator_system<InputIterator>::type;
|
| 115 |
+
using System2 = typename thrust::iterator_system<OutputIterator>::type;
|
| 116 |
+
|
| 117 |
+
System1 system1;
|
| 118 |
+
System2 system2;
|
| 119 |
+
|
| 120 |
+
return thrust::detail::two_system_copy_n(system1, system2, first, n, result);
|
| 121 |
+
} // end copy_n()
|
| 122 |
+
|
| 123 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/copy_if.h
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/execution_policy.h>
|
| 29 |
+
|
| 30 |
+
THRUST_NAMESPACE_BEGIN
|
| 31 |
+
|
| 32 |
+
template <typename DerivedPolicy, typename InputIterator, typename OutputIterator, typename Predicate>
|
| 33 |
+
_CCCL_HOST_DEVICE OutputIterator copy_if(
|
| 34 |
+
const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
| 35 |
+
InputIterator first,
|
| 36 |
+
InputIterator last,
|
| 37 |
+
OutputIterator result,
|
| 38 |
+
Predicate pred);
|
| 39 |
+
|
| 40 |
+
template <typename DerivedPolicy,
|
| 41 |
+
typename InputIterator1,
|
| 42 |
+
typename InputIterator2,
|
| 43 |
+
typename OutputIterator,
|
| 44 |
+
typename Predicate>
|
| 45 |
+
_CCCL_HOST_DEVICE OutputIterator copy_if(
|
| 46 |
+
const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
| 47 |
+
InputIterator1 first,
|
| 48 |
+
InputIterator1 last,
|
| 49 |
+
InputIterator2 stencil,
|
| 50 |
+
OutputIterator result,
|
| 51 |
+
Predicate pred);
|
| 52 |
+
|
| 53 |
+
template <typename InputIterator, typename OutputIterator, typename Predicate>
|
| 54 |
+
OutputIterator copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
|
| 55 |
+
|
| 56 |
+
template <typename InputIterator1, typename InputIterator2, typename OutputIterator, typename Predicate>
|
| 57 |
+
OutputIterator
|
| 58 |
+
copy_if(InputIterator1 first, InputIterator1 last, InputIterator2 stencil, OutputIterator result, Predicate pred);
|
| 59 |
+
|
| 60 |
+
THRUST_NAMESPACE_END
|
| 61 |
+
|
| 62 |
+
#include <thrust/detail/copy_if.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/copy_if.inl
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/copy_if.h>
|
| 29 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 30 |
+
#include <thrust/system/detail/adl/copy_if.h>
|
| 31 |
+
#include <thrust/system/detail/generic/copy_if.h>
|
| 32 |
+
#include <thrust/system/detail/generic/select_system.h>
|
| 33 |
+
|
| 34 |
+
THRUST_NAMESPACE_BEGIN
|
| 35 |
+
|
| 36 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 37 |
+
template <typename DerivedPolicy, typename InputIterator, typename OutputIterator, typename Predicate>
|
| 38 |
+
_CCCL_HOST_DEVICE OutputIterator copy_if(
|
| 39 |
+
const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
| 40 |
+
InputIterator first,
|
| 41 |
+
InputIterator last,
|
| 42 |
+
OutputIterator result,
|
| 43 |
+
Predicate pred)
|
| 44 |
+
{
|
| 45 |
+
using thrust::system::detail::generic::copy_if;
|
| 46 |
+
return copy_if(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, result, pred);
|
| 47 |
+
} // end copy_if()
|
| 48 |
+
|
| 49 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 50 |
+
template <typename DerivedPolicy,
|
| 51 |
+
typename InputIterator1,
|
| 52 |
+
typename InputIterator2,
|
| 53 |
+
typename OutputIterator,
|
| 54 |
+
typename Predicate>
|
| 55 |
+
_CCCL_HOST_DEVICE OutputIterator copy_if(
|
| 56 |
+
const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
| 57 |
+
InputIterator1 first,
|
| 58 |
+
InputIterator1 last,
|
| 59 |
+
InputIterator2 stencil,
|
| 60 |
+
OutputIterator result,
|
| 61 |
+
Predicate pred)
|
| 62 |
+
{
|
| 63 |
+
using thrust::system::detail::generic::copy_if;
|
| 64 |
+
return copy_if(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, stencil, result, pred);
|
| 65 |
+
} // end copy_if()
|
| 66 |
+
|
| 67 |
+
template <typename InputIterator, typename OutputIterator, typename Predicate>
|
| 68 |
+
OutputIterator copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred)
|
| 69 |
+
{
|
| 70 |
+
using thrust::system::detail::generic::select_system;
|
| 71 |
+
|
| 72 |
+
using System1 = typename thrust::iterator_system<InputIterator>::type;
|
| 73 |
+
using System2 = typename thrust::iterator_system<OutputIterator>::type;
|
| 74 |
+
|
| 75 |
+
System1 system1;
|
| 76 |
+
System2 system2;
|
| 77 |
+
|
| 78 |
+
return thrust::copy_if(select_system(system1, system2), first, last, result, pred);
|
| 79 |
+
} // end copy_if()
|
| 80 |
+
|
| 81 |
+
template <typename InputIterator1, typename InputIterator2, typename OutputIterator, typename Predicate>
|
| 82 |
+
OutputIterator
|
| 83 |
+
copy_if(InputIterator1 first, InputIterator1 last, InputIterator2 stencil, OutputIterator result, Predicate pred)
|
| 84 |
+
{
|
| 85 |
+
using thrust::system::detail::generic::select_system;
|
| 86 |
+
|
| 87 |
+
using System1 = typename thrust::iterator_system<InputIterator1>::type;
|
| 88 |
+
using System2 = typename thrust::iterator_system<InputIterator2>::type;
|
| 89 |
+
using System3 = typename thrust::iterator_system<OutputIterator>::type;
|
| 90 |
+
|
| 91 |
+
System1 system1;
|
| 92 |
+
System2 system2;
|
| 93 |
+
System3 system3;
|
| 94 |
+
|
| 95 |
+
return thrust::copy_if(select_system(system1, system2, system3), first, last, stencil, result, pred);
|
| 96 |
+
} // end copy_if()
|
| 97 |
+
|
| 98 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/count.h
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/execution_policy.h>
|
| 29 |
+
|
| 30 |
+
THRUST_NAMESPACE_BEGIN
|
| 31 |
+
|
| 32 |
+
template <typename DerivedPolicy, typename InputIterator, typename EqualityComparable>
|
| 33 |
+
_CCCL_HOST_DEVICE typename thrust::iterator_traits<InputIterator>::difference_type
|
| 34 |
+
count(const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
| 35 |
+
InputIterator first,
|
| 36 |
+
InputIterator last,
|
| 37 |
+
const EqualityComparable& value);
|
| 38 |
+
|
| 39 |
+
template <typename DerivedPolicy, typename InputIterator, typename Predicate>
|
| 40 |
+
_CCCL_HOST_DEVICE typename thrust::iterator_traits<InputIterator>::difference_type
|
| 41 |
+
count_if(const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
| 42 |
+
InputIterator first,
|
| 43 |
+
InputIterator last,
|
| 44 |
+
Predicate pred);
|
| 45 |
+
|
| 46 |
+
template <typename InputIterator, typename EqualityComparable>
|
| 47 |
+
typename thrust::iterator_traits<InputIterator>::difference_type
|
| 48 |
+
count(InputIterator first, InputIterator last, const EqualityComparable& value);
|
| 49 |
+
|
| 50 |
+
template <typename InputIterator, typename Predicate>
|
| 51 |
+
typename thrust::iterator_traits<InputIterator>::difference_type
|
| 52 |
+
count_if(InputIterator first, InputIterator last, Predicate pred);
|
| 53 |
+
|
| 54 |
+
THRUST_NAMESPACE_END
|
| 55 |
+
|
| 56 |
+
#include <thrust/detail/count.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/dependencies_aware_execution_policy.h
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2018 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/execute_with_dependencies.h>
|
| 29 |
+
|
| 30 |
+
#include <tuple>
|
| 31 |
+
|
| 32 |
+
_CCCL_SUPPRESS_DEPRECATED_PUSH
|
| 33 |
+
THRUST_NAMESPACE_BEGIN
|
| 34 |
+
|
| 35 |
+
namespace detail
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
template <template <typename> class ExecutionPolicyCRTPBase>
|
| 39 |
+
struct CCCL_DEPRECATED dependencies_aware_execution_policy
|
| 40 |
+
{
|
| 41 |
+
template <typename... Dependencies>
|
| 42 |
+
_CCCL_HOST thrust::detail::execute_with_dependencies<ExecutionPolicyCRTPBase, Dependencies...>
|
| 43 |
+
after(Dependencies&&... dependencies) const
|
| 44 |
+
{
|
| 45 |
+
return {capture_as_dependency(THRUST_FWD(dependencies))...};
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
template <typename... Dependencies>
|
| 49 |
+
_CCCL_HOST thrust::detail::execute_with_dependencies<ExecutionPolicyCRTPBase, Dependencies...>
|
| 50 |
+
after(std::tuple<Dependencies...>& dependencies) const
|
| 51 |
+
{
|
| 52 |
+
return {capture_as_dependency(dependencies)};
|
| 53 |
+
}
|
| 54 |
+
template <typename... Dependencies>
|
| 55 |
+
_CCCL_HOST thrust::detail::execute_with_dependencies<ExecutionPolicyCRTPBase, Dependencies...>
|
| 56 |
+
after(std::tuple<Dependencies...>&& dependencies) const
|
| 57 |
+
{
|
| 58 |
+
return {capture_as_dependency(std::move(dependencies))};
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
template <typename... Dependencies>
|
| 62 |
+
_CCCL_HOST thrust::detail::execute_with_dependencies<ExecutionPolicyCRTPBase, Dependencies...>
|
| 63 |
+
rebind_after(Dependencies&&... dependencies) const
|
| 64 |
+
{
|
| 65 |
+
return {capture_as_dependency(THRUST_FWD(dependencies))...};
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
template <typename... Dependencies>
|
| 69 |
+
_CCCL_HOST thrust::detail::execute_with_dependencies<ExecutionPolicyCRTPBase, Dependencies...>
|
| 70 |
+
rebind_after(std::tuple<Dependencies...>& dependencies) const
|
| 71 |
+
{
|
| 72 |
+
return {capture_as_dependency(dependencies)};
|
| 73 |
+
}
|
| 74 |
+
template <typename... Dependencies>
|
| 75 |
+
_CCCL_HOST thrust::detail::execute_with_dependencies<ExecutionPolicyCRTPBase, Dependencies...>
|
| 76 |
+
rebind_after(std::tuple<Dependencies...>&& dependencies) const
|
| 77 |
+
{
|
| 78 |
+
return {capture_as_dependency(std::move(dependencies))};
|
| 79 |
+
}
|
| 80 |
+
};
|
| 81 |
+
|
| 82 |
+
} // namespace detail
|
| 83 |
+
|
| 84 |
+
_CCCL_SUPPRESS_DEPRECATED_POP
|
| 85 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/device_malloc.inl
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/malloc_and_free.h>
|
| 29 |
+
#include <thrust/device_malloc.h>
|
| 30 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 31 |
+
#include <thrust/system/detail/generic/select_system.h>
|
| 32 |
+
|
| 33 |
+
THRUST_NAMESPACE_BEGIN
|
| 34 |
+
|
| 35 |
+
thrust::device_ptr<void> device_malloc(const std::size_t n)
|
| 36 |
+
{
|
| 37 |
+
using thrust::system::detail::generic::select_system;
|
| 38 |
+
|
| 39 |
+
using system = thrust::iterator_system<thrust::device_ptr<void>>::type;
|
| 40 |
+
|
| 41 |
+
// XXX lower to select_system(system) here
|
| 42 |
+
system s;
|
| 43 |
+
|
| 44 |
+
return thrust::device_ptr<void>(thrust::malloc(s, n).get());
|
| 45 |
+
} // end device_malloc()
|
| 46 |
+
|
| 47 |
+
template <typename T>
|
| 48 |
+
thrust::device_ptr<T> device_malloc(const std::size_t n)
|
| 49 |
+
{
|
| 50 |
+
using thrust::system::detail::generic::select_system;
|
| 51 |
+
|
| 52 |
+
using system = thrust::iterator_system<thrust::device_ptr<void>>::type;
|
| 53 |
+
|
| 54 |
+
// XXX lower to select_system(system) here
|
| 55 |
+
system s;
|
| 56 |
+
|
| 57 |
+
return thrust::device_ptr<T>(thrust::malloc<T>(s, n).get());
|
| 58 |
+
} // end device_malloc()
|
| 59 |
+
|
| 60 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/distance.inl
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
#include <thrust/advance.h>
|
| 30 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 31 |
+
#include <thrust/system/detail/generic/distance.h>
|
| 32 |
+
|
| 33 |
+
THRUST_NAMESPACE_BEGIN
|
| 34 |
+
|
| 35 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 36 |
+
template <typename InputIterator>
|
| 37 |
+
inline _CCCL_HOST_DEVICE typename thrust::iterator_traits<InputIterator>::difference_type
|
| 38 |
+
distance(InputIterator first, InputIterator last)
|
| 39 |
+
{
|
| 40 |
+
return thrust::system::detail::generic::distance(first, last);
|
| 41 |
+
} // end distance()
|
| 42 |
+
|
| 43 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/execute_with_allocator.h
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2018 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
#include <thrust/detail/allocator/allocator_traits.h>
|
| 30 |
+
#include <thrust/detail/execute_with_allocator_fwd.h>
|
| 31 |
+
#include <thrust/detail/integer_math.h>
|
| 32 |
+
#include <thrust/detail/raw_pointer_cast.h>
|
| 33 |
+
#include <thrust/detail/type_traits/pointer_traits.h>
|
| 34 |
+
#include <thrust/pair.h>
|
| 35 |
+
|
| 36 |
+
THRUST_NAMESPACE_BEGIN
|
| 37 |
+
|
| 38 |
+
namespace detail
|
| 39 |
+
{
|
| 40 |
+
|
| 41 |
+
template <typename T, typename Allocator, template <typename> class BaseSystem>
|
| 42 |
+
_CCCL_HOST thrust::pair<T*, std::ptrdiff_t>
|
| 43 |
+
get_temporary_buffer(thrust::detail::execute_with_allocator<Allocator, BaseSystem>& system, std::ptrdiff_t n)
|
| 44 |
+
{
|
| 45 |
+
using naked_allocator = ::cuda::std::remove_reference_t<Allocator>;
|
| 46 |
+
using alloc_traits = typename thrust::detail::allocator_traits<naked_allocator>;
|
| 47 |
+
using void_pointer = typename alloc_traits::void_pointer;
|
| 48 |
+
using size_type = typename alloc_traits::size_type;
|
| 49 |
+
using value_type = typename alloc_traits::value_type;
|
| 50 |
+
|
| 51 |
+
// How many elements of type value_type do we need to accommodate n elements
|
| 52 |
+
// of type T?
|
| 53 |
+
size_type num_elements = divide_ri(sizeof(T) * n, sizeof(value_type));
|
| 54 |
+
|
| 55 |
+
void_pointer ptr = alloc_traits::allocate(system.get_allocator(), num_elements);
|
| 56 |
+
|
| 57 |
+
// Return the pointer and the number of elements of type T allocated.
|
| 58 |
+
return thrust::make_pair(thrust::reinterpret_pointer_cast<T*>(ptr), n);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
template <typename Pointer, typename Allocator, template <typename> class BaseSystem>
|
| 62 |
+
_CCCL_HOST void return_temporary_buffer(
|
| 63 |
+
thrust::detail::execute_with_allocator<Allocator, BaseSystem>& system, Pointer p, std::ptrdiff_t n)
|
| 64 |
+
{
|
| 65 |
+
using naked_allocator = ::cuda::std::remove_reference_t<Allocator>;
|
| 66 |
+
using alloc_traits = typename thrust::detail::allocator_traits<naked_allocator>;
|
| 67 |
+
using pointer = typename alloc_traits::pointer;
|
| 68 |
+
using size_type = typename alloc_traits::size_type;
|
| 69 |
+
using value_type = typename alloc_traits::value_type;
|
| 70 |
+
using T = typename thrust::detail::pointer_traits<Pointer>::element_type;
|
| 71 |
+
|
| 72 |
+
size_type num_elements = divide_ri(sizeof(T) * n, sizeof(value_type));
|
| 73 |
+
|
| 74 |
+
pointer to_ptr = thrust::reinterpret_pointer_cast<pointer>(p);
|
| 75 |
+
alloc_traits::deallocate(system.get_allocator(), to_ptr, num_elements);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
_CCCL_SUPPRESS_DEPRECATED_PUSH
|
| 79 |
+
template <typename T, template <typename> class BaseSystem, typename Allocator, typename... Dependencies>
|
| 80 |
+
CCCL_DEPRECATED _CCCL_HOST thrust::pair<T*, std::ptrdiff_t> get_temporary_buffer(
|
| 81 |
+
thrust::detail::execute_with_allocator_and_dependencies<Allocator, BaseSystem, Dependencies...>& system,
|
| 82 |
+
std::ptrdiff_t n)
|
| 83 |
+
{
|
| 84 |
+
using naked_allocator = ::cuda::std::remove_reference_t<Allocator>;
|
| 85 |
+
using alloc_traits = typename thrust::detail::allocator_traits<naked_allocator>;
|
| 86 |
+
using void_pointer = typename alloc_traits::void_pointer;
|
| 87 |
+
using size_type = typename alloc_traits::size_type;
|
| 88 |
+
using value_type = typename alloc_traits::value_type;
|
| 89 |
+
|
| 90 |
+
// How many elements of type value_type do we need to accommodate n elements
|
| 91 |
+
// of type T?
|
| 92 |
+
size_type num_elements = divide_ri(sizeof(T) * n, sizeof(value_type));
|
| 93 |
+
|
| 94 |
+
void_pointer ptr = alloc_traits::allocate(system.get_allocator(), num_elements);
|
| 95 |
+
|
| 96 |
+
// Return the pointer and the number of elements of type T allocated.
|
| 97 |
+
return thrust::make_pair(thrust::reinterpret_pointer_cast<T*>(ptr), n);
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
template <typename Pointer, template <typename> class BaseSystem, typename Allocator, typename... Dependencies>
|
| 101 |
+
_CCCL_HOST void return_temporary_buffer(
|
| 102 |
+
thrust::detail::execute_with_allocator_and_dependencies<Allocator, BaseSystem, Dependencies...>& system,
|
| 103 |
+
Pointer p,
|
| 104 |
+
std::ptrdiff_t n)
|
| 105 |
+
{
|
| 106 |
+
using naked_allocator = ::cuda::std::remove_reference_t<Allocator>;
|
| 107 |
+
using alloc_traits = typename thrust::detail::allocator_traits<naked_allocator>;
|
| 108 |
+
using pointer = typename alloc_traits::pointer;
|
| 109 |
+
using size_type = typename alloc_traits::size_type;
|
| 110 |
+
using value_type = typename alloc_traits::value_type;
|
| 111 |
+
using T = typename thrust::detail::pointer_traits<Pointer>::element_type;
|
| 112 |
+
|
| 113 |
+
size_type num_elements = divide_ri(sizeof(T) * n, sizeof(value_type));
|
| 114 |
+
|
| 115 |
+
pointer to_ptr = thrust::reinterpret_pointer_cast<pointer>(p);
|
| 116 |
+
alloc_traits::deallocate(system.get_allocator(), to_ptr, num_elements);
|
| 117 |
+
}
|
| 118 |
+
_CCCL_SUPPRESS_DEPRECATED_POP
|
| 119 |
+
|
| 120 |
+
} // namespace detail
|
| 121 |
+
|
| 122 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/detail/extrema.inl
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/extrema.h>
|
| 29 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 30 |
+
#include <thrust/system/detail/adl/extrema.h>
|
| 31 |
+
#include <thrust/system/detail/generic/extrema.h>
|
| 32 |
+
#include <thrust/system/detail/generic/select_system.h>
|
| 33 |
+
|
| 34 |
+
THRUST_NAMESPACE_BEGIN
|
| 35 |
+
|
| 36 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 37 |
+
template <typename DerivedPolicy, typename ForwardIterator>
|
| 38 |
+
_CCCL_HOST_DEVICE ForwardIterator min_element(
|
| 39 |
+
const thrust::detail::execution_policy_base<DerivedPolicy>& exec, ForwardIterator first, ForwardIterator last)
|
| 40 |
+
{
|
| 41 |
+
using thrust::system::detail::generic::min_element;
|
| 42 |
+
return min_element(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last);
|
| 43 |
+
} // end min_element()
|
| 44 |
+
|
| 45 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 46 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename BinaryPredicate>
|
| 47 |
+
_CCCL_HOST_DEVICE ForwardIterator min_element(
|
| 48 |
+
const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
| 49 |
+
ForwardIterator first,
|
| 50 |
+
ForwardIterator last,
|
| 51 |
+
BinaryPredicate comp)
|
| 52 |
+
{
|
| 53 |
+
using thrust::system::detail::generic::min_element;
|
| 54 |
+
return min_element(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, comp);
|
| 55 |
+
} // end min_element()
|
| 56 |
+
|
| 57 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 58 |
+
template <typename DerivedPolicy, typename ForwardIterator>
|
| 59 |
+
_CCCL_HOST_DEVICE ForwardIterator max_element(
|
| 60 |
+
const thrust::detail::execution_policy_base<DerivedPolicy>& exec, ForwardIterator first, ForwardIterator last)
|
| 61 |
+
{
|
| 62 |
+
using thrust::system::detail::generic::max_element;
|
| 63 |
+
return max_element(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last);
|
| 64 |
+
} // end max_element()
|
| 65 |
+
|
| 66 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 67 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename BinaryPredicate>
|
| 68 |
+
_CCCL_HOST_DEVICE ForwardIterator max_element(
|
| 69 |
+
const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
| 70 |
+
ForwardIterator first,
|
| 71 |
+
ForwardIterator last,
|
| 72 |
+
BinaryPredicate comp)
|
| 73 |
+
{
|
| 74 |
+
using thrust::system::detail::generic::max_element;
|
| 75 |
+
return max_element(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, comp);
|
| 76 |
+
} // end max_element()
|
| 77 |
+
|
| 78 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 79 |
+
template <typename DerivedPolicy, typename ForwardIterator>
|
| 80 |
+
_CCCL_HOST_DEVICE thrust::pair<ForwardIterator, ForwardIterator> minmax_element(
|
| 81 |
+
const thrust::detail::execution_policy_base<DerivedPolicy>& exec, ForwardIterator first, ForwardIterator last)
|
| 82 |
+
{
|
| 83 |
+
using thrust::system::detail::generic::minmax_element;
|
| 84 |
+
return minmax_element(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last);
|
| 85 |
+
} // end minmax_element()
|
| 86 |
+
|
| 87 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 88 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename BinaryPredicate>
|
| 89 |
+
_CCCL_HOST_DEVICE thrust::pair<ForwardIterator, ForwardIterator> minmax_element(
|
| 90 |
+
const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
| 91 |
+
ForwardIterator first,
|
| 92 |
+
ForwardIterator last,
|
| 93 |
+
BinaryPredicate comp)
|
| 94 |
+
{
|
| 95 |
+
using thrust::system::detail::generic::minmax_element;
|
| 96 |
+
return minmax_element(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, comp);
|
| 97 |
+
} // end minmax_element()
|
| 98 |
+
|
| 99 |
+
template <typename ForwardIterator>
|
| 100 |
+
ForwardIterator min_element(ForwardIterator first, ForwardIterator last)
|
| 101 |
+
{
|
| 102 |
+
using thrust::system::detail::generic::select_system;
|
| 103 |
+
|
| 104 |
+
using System = typename thrust::iterator_system<ForwardIterator>::type;
|
| 105 |
+
|
| 106 |
+
System system;
|
| 107 |
+
|
| 108 |
+
return thrust::min_element(select_system(system), first, last);
|
| 109 |
+
} // end min_element()
|
| 110 |
+
|
| 111 |
+
template <typename ForwardIterator, typename BinaryPredicate>
|
| 112 |
+
ForwardIterator min_element(ForwardIterator first, ForwardIterator last, BinaryPredicate comp)
|
| 113 |
+
{
|
| 114 |
+
using thrust::system::detail::generic::select_system;
|
| 115 |
+
|
| 116 |
+
using System = typename thrust::iterator_system<ForwardIterator>::type;
|
| 117 |
+
|
| 118 |
+
System system;
|
| 119 |
+
|
| 120 |
+
return thrust::min_element(select_system(system), first, last, comp);
|
| 121 |
+
} // end min_element()
|
| 122 |
+
|
| 123 |
+
template <typename ForwardIterator>
|
| 124 |
+
ForwardIterator max_element(ForwardIterator first, ForwardIterator last)
|
| 125 |
+
{
|
| 126 |
+
using thrust::system::detail::generic::select_system;
|
| 127 |
+
|
| 128 |
+
using System = typename thrust::iterator_system<ForwardIterator>::type;
|
| 129 |
+
|
| 130 |
+
System system;
|
| 131 |
+
|
| 132 |
+
return thrust::max_element(select_system(system), first, last);
|
| 133 |
+
} // end max_element()
|
| 134 |
+
|
| 135 |
+
template <typename ForwardIterator, typename BinaryPredicate>
|
| 136 |
+
ForwardIterator max_element(ForwardIterator first, ForwardIterator last, BinaryPredicate comp)
|
| 137 |
+
{
|
| 138 |
+
using thrust::system::detail::generic::select_system;
|
| 139 |
+
|
| 140 |
+
using System = typename thrust::iterator_system<ForwardIterator>::type;
|
| 141 |
+
|
| 142 |
+
System system;
|
| 143 |
+
|
| 144 |
+
return thrust::max_element(select_system(system), first, last, comp);
|
| 145 |
+
} // end max_element()
|
| 146 |
+
|
| 147 |
+
template <typename ForwardIterator>
|
| 148 |
+
thrust::pair<ForwardIterator, ForwardIterator> minmax_element(ForwardIterator first, ForwardIterator last)
|
| 149 |
+
{
|
| 150 |
+
using thrust::system::detail::generic::select_system;
|
| 151 |
+
|
| 152 |
+
using System = typename thrust::iterator_system<ForwardIterator>::type;
|
| 153 |
+
|
| 154 |
+
System system;
|
| 155 |
+
|
| 156 |
+
return thrust::minmax_element(select_system(system), first, last);
|
| 157 |
+
} // end minmax_element()
|
| 158 |
+
|
| 159 |
+
template <typename ForwardIterator, typename BinaryPredicate>
|
| 160 |
+
thrust::pair<ForwardIterator, ForwardIterator>
|
| 161 |
+
minmax_element(ForwardIterator first, ForwardIterator last, BinaryPredicate comp)
|
| 162 |
+
{
|
| 163 |
+
using thrust::system::detail::generic::select_system;
|
| 164 |
+
|
| 165 |
+
using System = typename thrust::iterator_system<ForwardIterator>::type;
|
| 166 |
+
|
| 167 |
+
System system;
|
| 168 |
+
|
| 169 |
+
return thrust::minmax_element(select_system(system), first, last, comp);
|
| 170 |
+
} // end minmax_element()
|
| 171 |
+
|
| 172 |
+
THRUST_NAMESPACE_END
|