Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- miniCUDA124/include/thrust/detail/allocator/fill_construct_range.h +43 -0
- miniCUDA124/include/thrust/detail/allocator/fill_construct_range.inl +122 -0
- miniCUDA124/include/thrust/detail/allocator/malloc_allocator.h +59 -0
- miniCUDA124/include/thrust/detail/allocator/malloc_allocator.inl +73 -0
- miniCUDA124/include/thrust/detail/allocator/no_throw_allocator.h +80 -0
- miniCUDA124/include/thrust/detail/allocator/tagged_allocator.h +108 -0
- miniCUDA124/include/thrust/detail/allocator/tagged_allocator.inl +112 -0
- miniCUDA124/include/thrust/detail/allocator/temporary_allocator.h +92 -0
- miniCUDA124/include/thrust/detail/allocator/temporary_allocator.inl +87 -0
- miniCUDA124/include/thrust/detail/complex/arithmetic.h +311 -0
- miniCUDA124/include/thrust/detail/complex/clogf.h +208 -0
- miniCUDA124/include/thrust/detail/complex/complex.inl +363 -0
- miniCUDA124/include/thrust/detail/complex/cpow.h +65 -0
- miniCUDA124/include/thrust/detail/complex/cproj.h +80 -0
- miniCUDA124/include/thrust/detail/complex/csinh.h +215 -0
- miniCUDA124/include/thrust/detail/complex/csinhf.h +152 -0
- miniCUDA124/include/thrust/detail/complex/csqrt.h +162 -0
- miniCUDA124/include/thrust/detail/complex/csqrtf.h +157 -0
- miniCUDA124/include/thrust/detail/complex/ctanh.h +210 -0
- miniCUDA124/include/thrust/detail/complex/ctanhf.h +134 -0
- miniCUDA124/include/thrust/detail/complex/math_private.h +145 -0
- miniCUDA124/include/thrust/detail/complex/stream.h +82 -0
- miniCUDA124/include/thrust/detail/config/compiler.h +199 -0
- miniCUDA124/include/thrust/detail/config/compiler_fence.h +71 -0
- miniCUDA124/include/thrust/detail/config/config.h +51 -0
- miniCUDA124/include/thrust/detail/config/cpp_compatibility.h +111 -0
- miniCUDA124/include/thrust/detail/config/cpp_dialect.h +150 -0
- miniCUDA124/include/thrust/detail/config/debug.h +42 -0
- miniCUDA124/include/thrust/detail/config/deprecated.h +52 -0
- miniCUDA124/include/thrust/detail/config/device_system.h +54 -0
- miniCUDA124/include/thrust/detail/config/exec_check_disable.h +51 -0
- miniCUDA124/include/thrust/detail/config/forceinline.h +44 -0
- miniCUDA124/include/thrust/detail/config/global_workarounds.h +37 -0
- miniCUDA124/include/thrust/detail/config/host_device.h +52 -0
- miniCUDA124/include/thrust/detail/config/host_system.h +51 -0
- miniCUDA124/include/thrust/detail/config/memory_resource.h +44 -0
- miniCUDA124/include/thrust/detail/config/namespace.h +213 -0
- miniCUDA124/include/thrust/detail/config/simple_defines.h +40 -0
- miniCUDA124/include/thrust/detail/functional/actor.h +159 -0
- miniCUDA124/include/thrust/detail/functional/actor.inl +110 -0
- miniCUDA124/include/thrust/detail/functional/argument.h +82 -0
- miniCUDA124/include/thrust/detail/functional/composite.h +139 -0
- miniCUDA124/include/thrust/detail/functional/operators.h +33 -0
- miniCUDA124/include/thrust/detail/functional/operators/arithmetic_operators.h +444 -0
- miniCUDA124/include/thrust/detail/functional/operators/assignment_operator.h +87 -0
- miniCUDA124/include/thrust/detail/functional/operators/bitwise_operators.h +346 -0
- miniCUDA124/include/thrust/detail/functional/operators/compound_assignment_operators.h +520 -0
- miniCUDA124/include/thrust/detail/functional/operators/logical_operators.h +151 -0
- miniCUDA124/include/thrust/detail/functional/operators/operator_adaptors.h +144 -0
- miniCUDA124/include/thrust/detail/functional/operators/relational_operators.h +330 -0
miniCUDA124/include/thrust/detail/allocator/fill_construct_range.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 |
+
#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 |
+
|
| 34 |
+
template<typename Allocator, typename Pointer, typename Size, typename T>
|
| 35 |
+
__host__ __device__
|
| 36 |
+
inline void fill_construct_range(Allocator &a, Pointer p, Size n, const T &value);
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
} // end detail
|
| 40 |
+
THRUST_NAMESPACE_END
|
| 41 |
+
|
| 42 |
+
#include <thrust/detail/allocator/fill_construct_range.inl>
|
| 43 |
+
|
miniCUDA124/include/thrust/detail/allocator/fill_construct_range.inl
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.h>
|
| 29 |
+
#include <thrust/detail/allocator/allocator_traits.h>
|
| 30 |
+
#include <thrust/detail/type_traits/pointer_traits.h>
|
| 31 |
+
#include <thrust/for_each.h>
|
| 32 |
+
#include <thrust/uninitialized_fill.h>
|
| 33 |
+
#include <thrust/detail/memory_wrapper.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
|
| 49 |
+
: has_member_construct2<Allocator,T,Arg1>
|
| 50 |
+
{};
|
| 51 |
+
|
| 52 |
+
// std::allocator::construct's only effect is to invoke placement new
|
| 53 |
+
template<typename U, typename T, typename Arg1>
|
| 54 |
+
struct has_effectful_member_construct2<std::allocator<U>,T,Arg1>
|
| 55 |
+
: thrust::detail::false_type
|
| 56 |
+
{};
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
template<typename Allocator, typename Arg1>
|
| 60 |
+
struct construct2_via_allocator
|
| 61 |
+
{
|
| 62 |
+
Allocator &a;
|
| 63 |
+
Arg1 arg;
|
| 64 |
+
|
| 65 |
+
__host__ __device__
|
| 66 |
+
construct2_via_allocator(Allocator &a, const Arg1 &arg)
|
| 67 |
+
: a(a), arg(arg)
|
| 68 |
+
{}
|
| 69 |
+
|
| 70 |
+
template<typename T>
|
| 71 |
+
inline __host__ __device__
|
| 72 |
+
void operator()(T &x)
|
| 73 |
+
{
|
| 74 |
+
allocator_traits<Allocator>::construct(a, &x, arg);
|
| 75 |
+
}
|
| 76 |
+
};
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
template<typename Allocator, typename Pointer, typename Size, typename T>
|
| 80 |
+
__host__ __device__
|
| 81 |
+
typename enable_if<
|
| 82 |
+
has_effectful_member_construct2<
|
| 83 |
+
Allocator,
|
| 84 |
+
typename pointer_element<Pointer>::type,
|
| 85 |
+
T
|
| 86 |
+
>::value
|
| 87 |
+
>::type
|
| 88 |
+
fill_construct_range(Allocator &a, Pointer p, Size n, const T &value)
|
| 89 |
+
{
|
| 90 |
+
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, construct2_via_allocator<Allocator,T>(a, value));
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
template<typename Allocator, typename Pointer, typename Size, typename T>
|
| 95 |
+
__host__ __device__
|
| 96 |
+
typename disable_if<
|
| 97 |
+
has_effectful_member_construct2<
|
| 98 |
+
Allocator,
|
| 99 |
+
typename pointer_element<Pointer>::type,
|
| 100 |
+
T
|
| 101 |
+
>::value
|
| 102 |
+
>::type
|
| 103 |
+
fill_construct_range(Allocator &a, Pointer p, Size n, const T &value)
|
| 104 |
+
{
|
| 105 |
+
thrust::uninitialized_fill_n(allocator_system<Allocator>::get(a), p, n, value);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
} // end allocator_traits_detail
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
template<typename Alloc, typename Pointer, typename Size, typename T>
|
| 113 |
+
__host__ __device__
|
| 114 |
+
void fill_construct_range(Alloc &a, Pointer p, Size n, const T &value)
|
| 115 |
+
{
|
| 116 |
+
return allocator_traits_detail::fill_construct_range(a,p,n,value);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
} // end detail
|
| 121 |
+
THRUST_NAMESPACE_END
|
| 122 |
+
|
miniCUDA124/include/thrust/detail/allocator/malloc_allocator.h
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/detail/allocator/tagged_allocator.h>
|
| 30 |
+
|
| 31 |
+
THRUST_NAMESPACE_BEGIN
|
| 32 |
+
namespace detail
|
| 33 |
+
{
|
| 34 |
+
|
| 35 |
+
template<typename T, typename System, typename Pointer>
|
| 36 |
+
class malloc_allocator
|
| 37 |
+
: public thrust::detail::tagged_allocator<
|
| 38 |
+
T, System, Pointer
|
| 39 |
+
>
|
| 40 |
+
{
|
| 41 |
+
private:
|
| 42 |
+
typedef thrust::detail::tagged_allocator<
|
| 43 |
+
T, System, Pointer
|
| 44 |
+
> super_t;
|
| 45 |
+
|
| 46 |
+
public:
|
| 47 |
+
typedef typename super_t::pointer pointer;
|
| 48 |
+
typedef typename super_t::size_type size_type;
|
| 49 |
+
|
| 50 |
+
pointer allocate(size_type cnt);
|
| 51 |
+
|
| 52 |
+
void deallocate(pointer p, size_type n);
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
} // end detail
|
| 56 |
+
THRUST_NAMESPACE_END
|
| 57 |
+
|
| 58 |
+
#include <thrust/detail/allocator/malloc_allocator.inl>
|
| 59 |
+
|
miniCUDA124/include/thrust/detail/allocator/malloc_allocator.inl
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/system/detail/generic/select_system.h>
|
| 30 |
+
#include <thrust/system/detail/bad_alloc.h>
|
| 31 |
+
#include <thrust/detail/raw_pointer_cast.h>
|
| 32 |
+
#include <thrust/detail/malloc_and_free.h>
|
| 33 |
+
|
| 34 |
+
THRUST_NAMESPACE_BEGIN
|
| 35 |
+
namespace detail
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
template<typename T, typename System, typename Pointer>
|
| 40 |
+
typename malloc_allocator<T,System,Pointer>::pointer
|
| 41 |
+
malloc_allocator<T,System,Pointer>
|
| 42 |
+
::allocate(typename malloc_allocator<T,System,Pointer>::size_type cnt)
|
| 43 |
+
{
|
| 44 |
+
using thrust::system::detail::generic::select_system;
|
| 45 |
+
|
| 46 |
+
// XXX should use a hypothetical thrust::static_pointer_cast here
|
| 47 |
+
System system;
|
| 48 |
+
|
| 49 |
+
pointer result = thrust::malloc<T>(select_system(system), cnt);
|
| 50 |
+
|
| 51 |
+
if(result.get() == 0)
|
| 52 |
+
{
|
| 53 |
+
throw thrust::system::detail::bad_alloc("malloc_allocator::allocate: malloc failed");
|
| 54 |
+
} // end if
|
| 55 |
+
|
| 56 |
+
return result;
|
| 57 |
+
} // end malloc_allocator::allocate()
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
template<typename T, typename System, typename Pointer>
|
| 61 |
+
void malloc_allocator<T,System,Pointer>
|
| 62 |
+
::deallocate(typename malloc_allocator<T,System,Pointer>::pointer p, typename malloc_allocator<T,System,Pointer>::size_type)
|
| 63 |
+
{
|
| 64 |
+
using thrust::system::detail::generic::select_system;
|
| 65 |
+
|
| 66 |
+
System system;
|
| 67 |
+
thrust::free(select_system(system), p);
|
| 68 |
+
} // end malloc_allocator
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
} // end detail
|
| 72 |
+
THRUST_NAMESPACE_END
|
| 73 |
+
|
miniCUDA124/include/thrust/detail/allocator/no_throw_allocator.h
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
typedef BaseAllocator super_t;
|
| 40 |
+
|
| 41 |
+
public:
|
| 42 |
+
inline __host__ __device__
|
| 43 |
+
no_throw_allocator(const BaseAllocator &other = BaseAllocator())
|
| 44 |
+
: super_t(other)
|
| 45 |
+
{}
|
| 46 |
+
|
| 47 |
+
template<typename U>
|
| 48 |
+
struct rebind
|
| 49 |
+
{
|
| 50 |
+
typedef no_throw_allocator<typename super_t::template rebind<U>::other> other;
|
| 51 |
+
}; // end rebind
|
| 52 |
+
|
| 53 |
+
__host__ __device__
|
| 54 |
+
void deallocate(typename super_t::pointer p, typename super_t::size_type n)
|
| 55 |
+
{
|
| 56 |
+
NV_IF_TARGET(NV_IS_HOST, (
|
| 57 |
+
try
|
| 58 |
+
{
|
| 59 |
+
super_t::deallocate(p, n);
|
| 60 |
+
} // end try
|
| 61 |
+
catch(...)
|
| 62 |
+
{
|
| 63 |
+
// catch anything
|
| 64 |
+
} // end catch
|
| 65 |
+
), (
|
| 66 |
+
super_t::deallocate(p, n);
|
| 67 |
+
));
|
| 68 |
+
} // end deallocate()
|
| 69 |
+
|
| 70 |
+
inline __host__ __device__
|
| 71 |
+
bool operator==(no_throw_allocator const &other) { return super_t::operator==(other); }
|
| 72 |
+
|
| 73 |
+
inline __host__ __device__
|
| 74 |
+
bool operator!=(no_throw_allocator const &other) { return super_t::operator!=(other); }
|
| 75 |
+
}; // end no_throw_allocator
|
| 76 |
+
|
| 77 |
+
} // end detail
|
| 78 |
+
THRUST_NAMESPACE_END
|
| 79 |
+
|
| 80 |
+
|
miniCUDA124/include/thrust/detail/allocator/tagged_allocator.h
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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> class tagged_allocator;
|
| 36 |
+
|
| 37 |
+
template<typename Tag, typename Pointer>
|
| 38 |
+
class tagged_allocator<void, Tag, Pointer>
|
| 39 |
+
{
|
| 40 |
+
public:
|
| 41 |
+
typedef void value_type;
|
| 42 |
+
typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<void>::other pointer;
|
| 43 |
+
typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<const void>::other const_pointer;
|
| 44 |
+
typedef std::size_t size_type;
|
| 45 |
+
typedef typename thrust::detail::pointer_traits<Pointer>::difference_type difference_type;
|
| 46 |
+
typedef Tag system_type;
|
| 47 |
+
|
| 48 |
+
template<typename U>
|
| 49 |
+
struct rebind
|
| 50 |
+
{
|
| 51 |
+
typedef tagged_allocator<U,Tag,Pointer> other;
|
| 52 |
+
}; // end rebind
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
template<typename T, typename Tag, typename Pointer>
|
| 56 |
+
class tagged_allocator
|
| 57 |
+
{
|
| 58 |
+
public:
|
| 59 |
+
typedef T value_type;
|
| 60 |
+
typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<T>::other pointer;
|
| 61 |
+
typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<const T>::other const_pointer;
|
| 62 |
+
typedef typename thrust::iterator_reference<pointer>::type reference;
|
| 63 |
+
typedef typename thrust::iterator_reference<const_pointer>::type const_reference;
|
| 64 |
+
typedef std::size_t size_type;
|
| 65 |
+
typedef typename thrust::detail::pointer_traits<pointer>::difference_type difference_type;
|
| 66 |
+
typedef Tag system_type;
|
| 67 |
+
|
| 68 |
+
template<typename U>
|
| 69 |
+
struct rebind
|
| 70 |
+
{
|
| 71 |
+
typedef tagged_allocator<U,Tag,Pointer> other;
|
| 72 |
+
}; // end rebind
|
| 73 |
+
|
| 74 |
+
__host__ __device__
|
| 75 |
+
inline tagged_allocator();
|
| 76 |
+
|
| 77 |
+
__host__ __device__
|
| 78 |
+
inline tagged_allocator(const tagged_allocator &);
|
| 79 |
+
|
| 80 |
+
template<typename U, typename OtherPointer>
|
| 81 |
+
__host__ __device__
|
| 82 |
+
inline tagged_allocator(const tagged_allocator<U, Tag, OtherPointer> &);
|
| 83 |
+
|
| 84 |
+
__host__ __device__
|
| 85 |
+
inline ~tagged_allocator();
|
| 86 |
+
|
| 87 |
+
__host__ __device__
|
| 88 |
+
pointer address(reference x) const;
|
| 89 |
+
|
| 90 |
+
__host__ __device__
|
| 91 |
+
const_pointer address(const_reference x) const;
|
| 92 |
+
|
| 93 |
+
size_type max_size() const;
|
| 94 |
+
};
|
| 95 |
+
|
| 96 |
+
template<typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
|
| 97 |
+
__host__ __device__
|
| 98 |
+
bool operator==(const tagged_allocator<T1,Pointer1,Tag> &, const tagged_allocator<T2,Pointer2,Tag> &);
|
| 99 |
+
|
| 100 |
+
template<typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
|
| 101 |
+
__host__ __device__
|
| 102 |
+
bool operator!=(const tagged_allocator<T1,Pointer1,Tag> &, const tagged_allocator<T2,Pointer2,Tag> &);
|
| 103 |
+
|
| 104 |
+
} // end detail
|
| 105 |
+
THRUST_NAMESPACE_END
|
| 106 |
+
|
| 107 |
+
#include <thrust/detail/allocator/tagged_allocator.inl>
|
| 108 |
+
|
miniCUDA124/include/thrust/detail/allocator/tagged_allocator.inl
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <limits>
|
| 30 |
+
|
| 31 |
+
THRUST_NAMESPACE_BEGIN
|
| 32 |
+
namespace detail
|
| 33 |
+
{
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
template<typename T, typename Tag, typename Pointer>
|
| 37 |
+
__host__ __device__
|
| 38 |
+
tagged_allocator<T,Tag,Pointer>
|
| 39 |
+
::tagged_allocator()
|
| 40 |
+
{}
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
template<typename T, typename Tag, typename Pointer>
|
| 44 |
+
__host__ __device__
|
| 45 |
+
tagged_allocator<T,Tag,Pointer>
|
| 46 |
+
::tagged_allocator(const tagged_allocator<T,Tag,Pointer> &)
|
| 47 |
+
{}
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
template<typename T, typename Tag, typename Pointer>
|
| 51 |
+
template<typename U, typename OtherPointer>
|
| 52 |
+
__host__ __device__
|
| 53 |
+
tagged_allocator<T,Tag,Pointer>
|
| 54 |
+
::tagged_allocator(const tagged_allocator<U,Tag,OtherPointer> &)
|
| 55 |
+
{}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
template<typename T, typename Tag, typename Pointer>
|
| 59 |
+
__host__ __device__
|
| 60 |
+
tagged_allocator<T,Tag,Pointer>
|
| 61 |
+
::~tagged_allocator()
|
| 62 |
+
{}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
template<typename T, typename Tag, typename Pointer>
|
| 66 |
+
__host__ __device__
|
| 67 |
+
typename tagged_allocator<T,Tag,Pointer>::pointer
|
| 68 |
+
tagged_allocator<T,Tag,Pointer>
|
| 69 |
+
::address(reference x) const
|
| 70 |
+
{
|
| 71 |
+
return &x;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
template<typename T, typename Tag, typename Pointer>
|
| 76 |
+
__host__ __device__
|
| 77 |
+
typename tagged_allocator<T,Tag,Pointer>::const_pointer
|
| 78 |
+
tagged_allocator<T,Tag,Pointer>
|
| 79 |
+
::address(const_reference x) const
|
| 80 |
+
{
|
| 81 |
+
return &x;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
template<typename T, typename Tag, typename Pointer>
|
| 86 |
+
typename tagged_allocator<T,Tag,Pointer>::size_type
|
| 87 |
+
tagged_allocator<T,Tag,Pointer>
|
| 88 |
+
::max_size() const
|
| 89 |
+
{
|
| 90 |
+
return (std::numeric_limits<size_type>::max)() / sizeof(T);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
template<typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
|
| 95 |
+
__host__ __device__
|
| 96 |
+
bool operator==(const tagged_allocator<T1,Pointer1,Tag> &, const tagged_allocator<T2,Pointer2,Tag> &)
|
| 97 |
+
{
|
| 98 |
+
return true;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
template<typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
|
| 103 |
+
__host__ __device__
|
| 104 |
+
bool operator!=(const tagged_allocator<T1,Pointer1,Tag> &, const tagged_allocator<T2,Pointer2,Tag> &)
|
| 105 |
+
{
|
| 106 |
+
return false;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
} // end detail
|
| 111 |
+
THRUST_NAMESPACE_END
|
| 112 |
+
|
miniCUDA124/include/thrust/detail/allocator/temporary_allocator.h
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/allocator/allocator_traits.h>
|
| 30 |
+
#include <thrust/pair.h>
|
| 31 |
+
#include <thrust/memory.h>
|
| 32 |
+
#include <thrust/detail/execution_policy.h>
|
| 33 |
+
|
| 34 |
+
THRUST_NAMESPACE_BEGIN
|
| 35 |
+
namespace detail
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
// XXX the pointer parameter given to tagged_allocator should be related to
|
| 40 |
+
// the type of the expression get_temporary_buffer(system, n).first
|
| 41 |
+
// without decltype, compromise on pointer<T,System>
|
| 42 |
+
template<typename T, typename System>
|
| 43 |
+
class temporary_allocator
|
| 44 |
+
: public thrust::detail::tagged_allocator<
|
| 45 |
+
T, System, thrust::pointer<T,System>
|
| 46 |
+
>
|
| 47 |
+
{
|
| 48 |
+
private:
|
| 49 |
+
typedef thrust::detail::tagged_allocator<
|
| 50 |
+
T, System, thrust::pointer<T,System>
|
| 51 |
+
> super_t;
|
| 52 |
+
|
| 53 |
+
System &m_system;
|
| 54 |
+
|
| 55 |
+
public:
|
| 56 |
+
typedef typename super_t::pointer pointer;
|
| 57 |
+
typedef typename super_t::size_type size_type;
|
| 58 |
+
|
| 59 |
+
inline __host__ __device__
|
| 60 |
+
temporary_allocator(const temporary_allocator &other) :
|
| 61 |
+
super_t(),
|
| 62 |
+
m_system(other.m_system)
|
| 63 |
+
{}
|
| 64 |
+
|
| 65 |
+
inline __host__ __device__
|
| 66 |
+
explicit temporary_allocator(thrust::execution_policy<System> &system) :
|
| 67 |
+
super_t(),
|
| 68 |
+
m_system(thrust::detail::derived_cast(system))
|
| 69 |
+
{}
|
| 70 |
+
|
| 71 |
+
__host__ __device__
|
| 72 |
+
pointer allocate(size_type cnt);
|
| 73 |
+
|
| 74 |
+
__host__ __device__
|
| 75 |
+
void deallocate(pointer p, size_type n);
|
| 76 |
+
|
| 77 |
+
__host__ __device__
|
| 78 |
+
inline System &system()
|
| 79 |
+
{
|
| 80 |
+
return m_system;
|
| 81 |
+
} // end system()
|
| 82 |
+
|
| 83 |
+
private:
|
| 84 |
+
typedef thrust::pair<pointer, size_type> pointer_and_size;
|
| 85 |
+
}; // end temporary_allocator
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
} // end detail
|
| 89 |
+
THRUST_NAMESPACE_END
|
| 90 |
+
|
| 91 |
+
#include <thrust/detail/allocator/temporary_allocator.inl>
|
| 92 |
+
|
miniCUDA124/include/thrust/detail/allocator/temporary_allocator.inl
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#include <cassert>
|
| 32 |
+
|
| 33 |
+
#include <nv/target>
|
| 34 |
+
|
| 35 |
+
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
|
| 36 |
+
#if (defined(_NVHPC_CUDA) || defined(__CUDA_ARCH__))
|
| 37 |
+
#include <thrust/system/cuda/detail/terminate.h>
|
| 38 |
+
#endif // NVCC device pass or NVC++
|
| 39 |
+
#endif // CUDA
|
| 40 |
+
|
| 41 |
+
THRUST_NAMESPACE_BEGIN
|
| 42 |
+
namespace detail
|
| 43 |
+
{
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
template<typename T, typename System>
|
| 47 |
+
__host__ __device__
|
| 48 |
+
typename temporary_allocator<T,System>::pointer
|
| 49 |
+
temporary_allocator<T,System>
|
| 50 |
+
::allocate(typename temporary_allocator<T,System>::size_type cnt)
|
| 51 |
+
{
|
| 52 |
+
pointer_and_size result = thrust::get_temporary_buffer<T>(system(), cnt);
|
| 53 |
+
|
| 54 |
+
// handle failure
|
| 55 |
+
if(result.second < cnt)
|
| 56 |
+
{
|
| 57 |
+
// deallocate and throw
|
| 58 |
+
// note that we pass cnt to deallocate, not a value derived from result.second
|
| 59 |
+
deallocate(result.first, cnt);
|
| 60 |
+
|
| 61 |
+
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
|
| 62 |
+
NV_IF_TARGET(NV_IS_HOST, (
|
| 63 |
+
throw thrust::system::detail::bad_alloc("temporary_buffer::allocate: get_temporary_buffer failed");
|
| 64 |
+
), ( // NV_IS_DEVICE
|
| 65 |
+
thrust::system::cuda::detail::terminate_with_message("temporary_buffer::allocate: get_temporary_buffer failed");
|
| 66 |
+
));
|
| 67 |
+
#else
|
| 68 |
+
throw thrust::system::detail::bad_alloc("temporary_buffer::allocate: get_temporary_buffer failed");
|
| 69 |
+
#endif
|
| 70 |
+
} // end if
|
| 71 |
+
|
| 72 |
+
return result.first;
|
| 73 |
+
} // end temporary_allocator::allocate()
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
template<typename T, typename System>
|
| 77 |
+
__host__ __device__
|
| 78 |
+
void temporary_allocator<T,System>
|
| 79 |
+
::deallocate(typename temporary_allocator<T,System>::pointer p, typename temporary_allocator<T,System>::size_type n)
|
| 80 |
+
{
|
| 81 |
+
return thrust::return_temporary_buffer(system(), p, n);
|
| 82 |
+
} // end temporary_allocator
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
} // end detail
|
| 86 |
+
THRUST_NAMESPACE_END
|
| 87 |
+
|
miniCUDA124/include/thrust/detail/complex/arithmetic.h
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#pragma once
|
| 19 |
+
|
| 20 |
+
#include <thrust/detail/config.h>
|
| 21 |
+
|
| 22 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 23 |
+
# pragma GCC system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 25 |
+
# pragma clang system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 27 |
+
# pragma system_header
|
| 28 |
+
#endif // no system header
|
| 29 |
+
|
| 30 |
+
#include <thrust/complex.h>
|
| 31 |
+
#include <thrust/detail/complex/c99math.h>
|
| 32 |
+
#include <cfloat>
|
| 33 |
+
#include <cmath>
|
| 34 |
+
|
| 35 |
+
THRUST_NAMESPACE_BEGIN
|
| 36 |
+
|
| 37 |
+
/* --- Binary Arithmetic Operators --- */
|
| 38 |
+
|
| 39 |
+
template <typename T0, typename T1>
|
| 40 |
+
__host__ __device__
|
| 41 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 42 |
+
operator+(const complex<T0>& x, const complex<T1>& y)
|
| 43 |
+
{
|
| 44 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 45 |
+
return complex<T>(x.real() + y.real(), x.imag() + y.imag());
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
template <typename T0, typename T1>
|
| 49 |
+
__host__ __device__
|
| 50 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 51 |
+
operator+(const complex<T0>& x, const T1& y)
|
| 52 |
+
{
|
| 53 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 54 |
+
return complex<T>(x.real() + y, x.imag());
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
template <typename T0, typename T1>
|
| 58 |
+
__host__ __device__
|
| 59 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 60 |
+
operator+(const T0& x, const complex<T1>& y)
|
| 61 |
+
{
|
| 62 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 63 |
+
return complex<T>(x + y.real(), y.imag());
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
template <typename T0, typename T1>
|
| 68 |
+
__host__ __device__
|
| 69 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 70 |
+
operator-(const complex<T0>& x, const complex<T1>& y)
|
| 71 |
+
{
|
| 72 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 73 |
+
return complex<T>(x.real() - y.real(), x.imag() - y.imag());
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
template <typename T0, typename T1>
|
| 77 |
+
__host__ __device__
|
| 78 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 79 |
+
operator-(const complex<T0>& x, const T1& y)
|
| 80 |
+
{
|
| 81 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 82 |
+
return complex<T>(x.real() - y, x.imag());
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
template <typename T0, typename T1>
|
| 86 |
+
__host__ __device__
|
| 87 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 88 |
+
operator-(const T0& x, const complex<T1>& y)
|
| 89 |
+
{
|
| 90 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 91 |
+
return complex<T>(x - y.real(), -y.imag());
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
template <typename T0, typename T1>
|
| 96 |
+
__host__ __device__
|
| 97 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 98 |
+
operator*(const complex<T0>& x, const complex<T1>& y)
|
| 99 |
+
{
|
| 100 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 101 |
+
return complex<T>( x.real() * y.real() - x.imag() * y.imag()
|
| 102 |
+
, x.real() * y.imag() + x.imag() * y.real());
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
template <typename T0, typename T1>
|
| 106 |
+
__host__ __device__
|
| 107 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 108 |
+
operator*(const complex<T0>& x, const T1& y)
|
| 109 |
+
{
|
| 110 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 111 |
+
return complex<T>(x.real() * y, x.imag() * y);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
template <typename T0, typename T1>
|
| 115 |
+
__host__ __device__
|
| 116 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 117 |
+
operator*(const T0& x, const complex<T1>& y)
|
| 118 |
+
{
|
| 119 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 120 |
+
return complex<T>(x * y.real(), x * y.imag());
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
template <typename T0, typename T1>
|
| 125 |
+
__host__ __device__
|
| 126 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 127 |
+
operator/(const complex<T0>& x, const complex<T1>& y)
|
| 128 |
+
{
|
| 129 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 130 |
+
|
| 131 |
+
// Find `abs` by ADL.
|
| 132 |
+
using std::abs;
|
| 133 |
+
|
| 134 |
+
T s = abs(y.real()) + abs(y.imag());
|
| 135 |
+
|
| 136 |
+
T oos = T(1.0) / s;
|
| 137 |
+
|
| 138 |
+
T ars = x.real() * oos;
|
| 139 |
+
T ais = x.imag() * oos;
|
| 140 |
+
T brs = y.real() * oos;
|
| 141 |
+
T bis = y.imag() * oos;
|
| 142 |
+
|
| 143 |
+
s = (brs * brs) + (bis * bis);
|
| 144 |
+
|
| 145 |
+
oos = T(1.0) / s;
|
| 146 |
+
|
| 147 |
+
complex<T> quot( ((ars * brs) + (ais * bis)) * oos
|
| 148 |
+
, ((ais * brs) - (ars * bis)) * oos);
|
| 149 |
+
return quot;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
template <typename T0, typename T1>
|
| 153 |
+
__host__ __device__
|
| 154 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 155 |
+
operator/(const complex<T0>& x, const T1& y)
|
| 156 |
+
{
|
| 157 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 158 |
+
return complex<T>(x.real() / y, x.imag() / y);
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
template <typename T0, typename T1>
|
| 162 |
+
__host__ __device__
|
| 163 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 164 |
+
operator/(const T0& x, const complex<T1>& y)
|
| 165 |
+
{
|
| 166 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 167 |
+
return complex<T>(x) / y;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
/* --- Unary Arithmetic Operators --- */
|
| 173 |
+
|
| 174 |
+
template <typename T>
|
| 175 |
+
__host__ __device__
|
| 176 |
+
complex<T> operator+(const complex<T>& y)
|
| 177 |
+
{
|
| 178 |
+
return y;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
template <typename T>
|
| 182 |
+
__host__ __device__
|
| 183 |
+
complex<T> operator-(const complex<T>& y)
|
| 184 |
+
{
|
| 185 |
+
return y * -T(1);
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
/* --- Other Basic Arithmetic Functions --- */
|
| 190 |
+
|
| 191 |
+
// As std::hypot is only C++11 we have to use the C interface
|
| 192 |
+
template <typename T>
|
| 193 |
+
__host__ __device__
|
| 194 |
+
T abs(const complex<T>& z)
|
| 195 |
+
{
|
| 196 |
+
return hypot(z.real(), z.imag());
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
// XXX Why are we specializing here?
|
| 200 |
+
namespace detail {
|
| 201 |
+
namespace complex {
|
| 202 |
+
|
| 203 |
+
__host__ __device__
|
| 204 |
+
inline float abs(const thrust::complex<float>& z)
|
| 205 |
+
{
|
| 206 |
+
return hypotf(z.real(),z.imag());
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
__host__ __device__
|
| 210 |
+
inline double abs(const thrust::complex<double>& z)
|
| 211 |
+
{
|
| 212 |
+
return hypot(z.real(),z.imag());
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
} // end namespace complex
|
| 216 |
+
} // end namespace detail
|
| 217 |
+
|
| 218 |
+
template <>
|
| 219 |
+
__host__ __device__
|
| 220 |
+
inline float abs(const complex<float>& z)
|
| 221 |
+
{
|
| 222 |
+
return detail::complex::abs(z);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
template <>
|
| 226 |
+
__host__ __device__
|
| 227 |
+
inline double abs(const complex<double>& z)
|
| 228 |
+
{
|
| 229 |
+
return detail::complex::abs(z);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
template <typename T>
|
| 234 |
+
__host__ __device__
|
| 235 |
+
T arg(const complex<T>& z)
|
| 236 |
+
{
|
| 237 |
+
// Find `atan2` by ADL.
|
| 238 |
+
using std::atan2;
|
| 239 |
+
return atan2(z.imag(), z.real());
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
template <typename T>
|
| 244 |
+
__host__ __device__
|
| 245 |
+
complex<T> conj(const complex<T>& z)
|
| 246 |
+
{
|
| 247 |
+
return complex<T>(z.real(), -z.imag());
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
template <typename T>
|
| 252 |
+
__host__ __device__
|
| 253 |
+
T norm(const complex<T>& z)
|
| 254 |
+
{
|
| 255 |
+
return z.real() * z.real() + z.imag() * z.imag();
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
// XXX Why specialize these, we could just rely on ADL.
|
| 259 |
+
template <>
|
| 260 |
+
__host__ __device__
|
| 261 |
+
inline float norm(const complex<float>& z)
|
| 262 |
+
{
|
| 263 |
+
// Find `abs` and `sqrt` by ADL.
|
| 264 |
+
using std::abs;
|
| 265 |
+
using std::sqrt;
|
| 266 |
+
|
| 267 |
+
if (abs(z.real()) < sqrt(FLT_MIN) && abs(z.imag()) < sqrt(FLT_MIN))
|
| 268 |
+
{
|
| 269 |
+
float a = z.real() * 4.0f;
|
| 270 |
+
float b = z.imag() * 4.0f;
|
| 271 |
+
return (a * a + b * b) / 16.0f;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
return z.real() * z.real() + z.imag() * z.imag();
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
template <>
|
| 278 |
+
__host__ __device__
|
| 279 |
+
inline double norm(const complex<double>& z)
|
| 280 |
+
{
|
| 281 |
+
// Find `abs` and `sqrt` by ADL.
|
| 282 |
+
using std::abs;
|
| 283 |
+
using std::sqrt;
|
| 284 |
+
|
| 285 |
+
if (abs(z.real()) < sqrt(DBL_MIN) && abs(z.imag()) < sqrt(DBL_MIN))
|
| 286 |
+
{
|
| 287 |
+
double a = z.real() * 4.0;
|
| 288 |
+
double b = z.imag() * 4.0;
|
| 289 |
+
return (a * a + b * b) / 16.0;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
return z.real() * z.real() + z.imag() * z.imag();
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
template <typename T0, typename T1>
|
| 297 |
+
__host__ __device__
|
| 298 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 299 |
+
polar(const T0& m, const T1& theta)
|
| 300 |
+
{
|
| 301 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 302 |
+
|
| 303 |
+
// Find `cos` and `sin` by ADL.
|
| 304 |
+
using std::cos;
|
| 305 |
+
using std::sin;
|
| 306 |
+
|
| 307 |
+
return complex<T>(m * cos(theta), m * sin(theta));
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
THRUST_NAMESPACE_END
|
| 311 |
+
|
miniCUDA124/include/thrust/detail/complex/clogf.h
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 51 |
+
# pragma GCC system_header
|
| 52 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 53 |
+
# pragma clang system_header
|
| 54 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 55 |
+
# pragma system_header
|
| 56 |
+
#endif // no system header
|
| 57 |
+
|
| 58 |
+
#include <thrust/complex.h>
|
| 59 |
+
#include <thrust/detail/complex/math_private.h>
|
| 60 |
+
|
| 61 |
+
THRUST_NAMESPACE_BEGIN
|
| 62 |
+
namespace detail{
|
| 63 |
+
namespace complex{
|
| 64 |
+
|
| 65 |
+
using thrust::complex;
|
| 66 |
+
|
| 67 |
+
/* round down to 8 = 24/3 bits */
|
| 68 |
+
__host__ __device__ inline
|
| 69 |
+
float trim(float x){
|
| 70 |
+
uint32_t hx;
|
| 71 |
+
get_float_word(hx, x);
|
| 72 |
+
hx &= 0xffff0000;
|
| 73 |
+
float ret;
|
| 74 |
+
set_float_word(ret,hx);
|
| 75 |
+
return ret;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
__host__ __device__ inline
|
| 80 |
+
complex<float> clogf(const complex<float>& z){
|
| 81 |
+
|
| 82 |
+
// Adapted from FreeBSDs msun
|
| 83 |
+
float x, y;
|
| 84 |
+
float ax, ay;
|
| 85 |
+
float x0, y0, x1, y1, x2, y2, t, hm1;
|
| 86 |
+
float val[12];
|
| 87 |
+
int i, sorted;
|
| 88 |
+
const float e = 2.7182818284590452354f;
|
| 89 |
+
|
| 90 |
+
x = z.real();
|
| 91 |
+
y = z.imag();
|
| 92 |
+
|
| 93 |
+
/* Handle NaNs using the general formula to mix them right. */
|
| 94 |
+
if (x != x || y != y){
|
| 95 |
+
return (complex<float>(std::log(norm(z)), std::atan2(y, x)));
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
ax = std::abs(x);
|
| 99 |
+
ay = std::abs(y);
|
| 100 |
+
if (ax < ay) {
|
| 101 |
+
t = ax;
|
| 102 |
+
ax = ay;
|
| 103 |
+
ay = t;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/*
|
| 107 |
+
* To avoid unnecessary overflow, if x and y are very large, divide x
|
| 108 |
+
* and y by M_E, and then add 1 to the logarithm. This depends on
|
| 109 |
+
* M_E being larger than sqrt(2).
|
| 110 |
+
* There is a potential loss of accuracy caused by dividing by M_E,
|
| 111 |
+
* but this case should happen extremely rarely.
|
| 112 |
+
*/
|
| 113 |
+
// For high values of ay -> hypotf(FLT_MAX,ay) = inf
|
| 114 |
+
// We expect that for values at or below ay = 1e34f this should not happen
|
| 115 |
+
if (ay > 1e34f){
|
| 116 |
+
return (complex<float>(std::log(hypotf(x / e, y / e)) + 1.0f, std::atan2(y, x)));
|
| 117 |
+
}
|
| 118 |
+
if (ax == 1.f) {
|
| 119 |
+
if (ay < 1e-19f){
|
| 120 |
+
return (complex<float>((ay * 0.5f) * ay, std::atan2(y, x)));
|
| 121 |
+
}
|
| 122 |
+
return (complex<float>(log1pf(ay * ay) * 0.5f, std::atan2(y, x)));
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
/*
|
| 126 |
+
* Because atan2 and hypot conform to C99, this also covers all the
|
| 127 |
+
* edge cases when x or y are 0 or infinite.
|
| 128 |
+
*/
|
| 129 |
+
if (ax < 1e-6f || ay < 1e-6f || ax > 1e6f || ay > 1e6f){
|
| 130 |
+
return (complex<float>(std::log(hypotf(x, y)), std::atan2(y, x)));
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
/*
|
| 134 |
+
* From this point on, we don't need to worry about underflow or
|
| 135 |
+
* overflow in calculating ax*ax or ay*ay.
|
| 136 |
+
*/
|
| 137 |
+
|
| 138 |
+
/* Some easy cases. */
|
| 139 |
+
|
| 140 |
+
if (ax >= 1.0f){
|
| 141 |
+
return (complex<float>(log1pf((ax-1.f)*(ax+1.f) + ay*ay) * 0.5f, atan2(y, x)));
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
if (ax*ax + ay*ay <= 0.7f){
|
| 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 |
+
|
| 154 |
+
x0 = trim(ax);
|
| 155 |
+
ax = ax-x0;
|
| 156 |
+
x1 = trim(ax);
|
| 157 |
+
x2 = ax-x1;
|
| 158 |
+
y0 = trim(ay);
|
| 159 |
+
ay = ay-y0;
|
| 160 |
+
y1 = trim(ay);
|
| 161 |
+
y2 = ay-y1;
|
| 162 |
+
|
| 163 |
+
val[0] = x0*x0;
|
| 164 |
+
val[1] = y0*y0;
|
| 165 |
+
val[2] = 2*x0*x1;
|
| 166 |
+
val[3] = 2*y0*y1;
|
| 167 |
+
val[4] = x1*x1;
|
| 168 |
+
val[5] = y1*y1;
|
| 169 |
+
val[6] = 2*x0*x2;
|
| 170 |
+
val[7] = 2*y0*y2;
|
| 171 |
+
val[8] = 2*x1*x2;
|
| 172 |
+
val[9] = 2*y1*y2;
|
| 173 |
+
val[10] = x2*x2;
|
| 174 |
+
val[11] = y2*y2;
|
| 175 |
+
|
| 176 |
+
/* Bubble sort. */
|
| 177 |
+
|
| 178 |
+
do {
|
| 179 |
+
sorted = 1;
|
| 180 |
+
for (i=0;i<11;i++) {
|
| 181 |
+
if (val[i] < val[i+1]) {
|
| 182 |
+
sorted = 0;
|
| 183 |
+
t = val[i];
|
| 184 |
+
val[i] = val[i+1];
|
| 185 |
+
val[i+1] = t;
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
} while (!sorted);
|
| 189 |
+
|
| 190 |
+
hm1 = -1;
|
| 191 |
+
for (i=0;i<12;i++){
|
| 192 |
+
hm1 += val[i];
|
| 193 |
+
}
|
| 194 |
+
return (complex<float>(0.5f * log1pf(hm1), atan2(y, x)));
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
} // namespace complex
|
| 198 |
+
|
| 199 |
+
} // namespace detail
|
| 200 |
+
|
| 201 |
+
template <>
|
| 202 |
+
__host__ __device__
|
| 203 |
+
inline complex<float> log(const complex<float>& z){
|
| 204 |
+
return detail::complex::clogf(z);
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
THRUST_NAMESPACE_END
|
| 208 |
+
|
miniCUDA124/include/thrust/detail/complex/complex.inl
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#pragma once
|
| 19 |
+
|
| 20 |
+
#include <thrust/detail/config.h>
|
| 21 |
+
|
| 22 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 23 |
+
# pragma GCC system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 25 |
+
# pragma clang system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 27 |
+
# pragma system_header
|
| 28 |
+
#endif // no system header
|
| 29 |
+
|
| 30 |
+
#include <thrust/complex.h>
|
| 31 |
+
#include <thrust/type_traits/is_trivially_relocatable.h>
|
| 32 |
+
|
| 33 |
+
THRUST_NAMESPACE_BEGIN
|
| 34 |
+
|
| 35 |
+
/* --- Constructors --- */
|
| 36 |
+
|
| 37 |
+
#if THRUST_CPP_DIALECT < 2011
|
| 38 |
+
template <typename T>
|
| 39 |
+
__host__ __device__
|
| 40 |
+
complex<T>::complex()
|
| 41 |
+
{
|
| 42 |
+
real(T());
|
| 43 |
+
imag(T());
|
| 44 |
+
}
|
| 45 |
+
#endif
|
| 46 |
+
|
| 47 |
+
template <typename T>
|
| 48 |
+
__host__ __device__
|
| 49 |
+
complex<T>::complex(const T& re)
|
| 50 |
+
#if THRUST_CPP_DIALECT >= 2011
|
| 51 |
+
// Initialize the storage in the member initializer list using C++ unicorn
|
| 52 |
+
// initialization. This allows `complex<T const>` to work.
|
| 53 |
+
: data{re, T()}
|
| 54 |
+
{}
|
| 55 |
+
#else
|
| 56 |
+
{
|
| 57 |
+
real(re);
|
| 58 |
+
imag(T());
|
| 59 |
+
}
|
| 60 |
+
#endif
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
template <typename T>
|
| 64 |
+
__host__ __device__
|
| 65 |
+
complex<T>::complex(const T& re, const T& im)
|
| 66 |
+
#if THRUST_CPP_DIALECT >= 2011
|
| 67 |
+
// Initialize the storage in the member initializer list using C++ unicorn
|
| 68 |
+
// initialization. This allows `complex<T const>` to work.
|
| 69 |
+
: data{re, im}
|
| 70 |
+
{}
|
| 71 |
+
#else
|
| 72 |
+
{
|
| 73 |
+
real(re);
|
| 74 |
+
imag(im);
|
| 75 |
+
}
|
| 76 |
+
#endif
|
| 77 |
+
|
| 78 |
+
#if THRUST_CPP_DIALECT < 2011
|
| 79 |
+
template <typename T>
|
| 80 |
+
__host__ __device__
|
| 81 |
+
complex<T>::complex(const complex<T>& z)
|
| 82 |
+
{
|
| 83 |
+
real(z.real());
|
| 84 |
+
imag(z.imag());
|
| 85 |
+
}
|
| 86 |
+
#endif
|
| 87 |
+
|
| 88 |
+
template <typename T>
|
| 89 |
+
template <typename U>
|
| 90 |
+
__host__ __device__
|
| 91 |
+
complex<T>::complex(const complex<U>& z)
|
| 92 |
+
#if THRUST_CPP_DIALECT >= 2011
|
| 93 |
+
// Initialize the storage in the member initializer list using C++ unicorn
|
| 94 |
+
// initialization. This allows `complex<T const>` to work.
|
| 95 |
+
// We do a functional-style cast here to suppress conversion warnings.
|
| 96 |
+
: data{T(z.real()), T(z.imag())}
|
| 97 |
+
{}
|
| 98 |
+
#else
|
| 99 |
+
{
|
| 100 |
+
real(T(z.real()));
|
| 101 |
+
imag(T(z.imag()));
|
| 102 |
+
}
|
| 103 |
+
#endif
|
| 104 |
+
|
| 105 |
+
template <typename T>
|
| 106 |
+
__host__ THRUST_STD_COMPLEX_DEVICE
|
| 107 |
+
complex<T>::complex(const std::complex<T>& z)
|
| 108 |
+
#if THRUST_CPP_DIALECT >= 2011
|
| 109 |
+
// Initialize the storage in the member initializer list using C++ unicorn
|
| 110 |
+
// initialization. This allows `complex<T const>` to work.
|
| 111 |
+
: data{THRUST_STD_COMPLEX_REAL(z), THRUST_STD_COMPLEX_IMAG(z)}
|
| 112 |
+
{}
|
| 113 |
+
#else
|
| 114 |
+
{
|
| 115 |
+
real(THRUST_STD_COMPLEX_REAL(z));
|
| 116 |
+
imag(THRUST_STD_COMPLEX_IMAG(z));
|
| 117 |
+
}
|
| 118 |
+
#endif
|
| 119 |
+
|
| 120 |
+
template <typename T>
|
| 121 |
+
template <typename U>
|
| 122 |
+
__host__ THRUST_STD_COMPLEX_DEVICE
|
| 123 |
+
complex<T>::complex(const std::complex<U>& z)
|
| 124 |
+
#if THRUST_CPP_DIALECT >= 2011
|
| 125 |
+
// Initialize the storage in the member initializer list using C++ unicorn
|
| 126 |
+
// initialization. This allows `complex<T const>` to work.
|
| 127 |
+
// We do a functional-style cast here to suppress conversion warnings.
|
| 128 |
+
: data{T(THRUST_STD_COMPLEX_REAL(z)), T(THRUST_STD_COMPLEX_IMAG(z))}
|
| 129 |
+
{}
|
| 130 |
+
#else
|
| 131 |
+
{
|
| 132 |
+
real(T(THRUST_STD_COMPLEX_REAL(z)));
|
| 133 |
+
imag(T(THRUST_STD_COMPLEX_IMAG(z)));
|
| 134 |
+
}
|
| 135 |
+
#endif
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
/* --- Assignment Operators --- */
|
| 140 |
+
|
| 141 |
+
template <typename T>
|
| 142 |
+
__host__ __device__
|
| 143 |
+
complex<T>& complex<T>::operator=(const T& re)
|
| 144 |
+
{
|
| 145 |
+
real(re);
|
| 146 |
+
imag(T());
|
| 147 |
+
return *this;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
#if THRUST_CPP_DIALECT < 2011
|
| 151 |
+
template <typename T>
|
| 152 |
+
__host__ __device__
|
| 153 |
+
complex<T>& complex<T>::operator=(const complex<T>& z)
|
| 154 |
+
{
|
| 155 |
+
real(z.real());
|
| 156 |
+
imag(z.imag());
|
| 157 |
+
return *this;
|
| 158 |
+
}
|
| 159 |
+
#endif
|
| 160 |
+
|
| 161 |
+
template <typename T>
|
| 162 |
+
template <typename U>
|
| 163 |
+
__host__ __device__
|
| 164 |
+
complex<T>& complex<T>::operator=(const complex<U>& z)
|
| 165 |
+
{
|
| 166 |
+
real(T(z.real()));
|
| 167 |
+
imag(T(z.imag()));
|
| 168 |
+
return *this;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
template <typename T>
|
| 172 |
+
__host__ THRUST_STD_COMPLEX_DEVICE
|
| 173 |
+
complex<T>& complex<T>::operator=(const std::complex<T>& z)
|
| 174 |
+
{
|
| 175 |
+
real(THRUST_STD_COMPLEX_REAL(z));
|
| 176 |
+
imag(THRUST_STD_COMPLEX_IMAG(z));
|
| 177 |
+
return *this;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
template <typename T>
|
| 181 |
+
template <typename U>
|
| 182 |
+
__host__ THRUST_STD_COMPLEX_DEVICE
|
| 183 |
+
complex<T>& complex<T>::operator=(const std::complex<U>& z)
|
| 184 |
+
{
|
| 185 |
+
real(T(THRUST_STD_COMPLEX_REAL(z)));
|
| 186 |
+
imag(T(THRUST_STD_COMPLEX_IMAG(z)));
|
| 187 |
+
return *this;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
/* --- Compound Assignment Operators --- */
|
| 193 |
+
|
| 194 |
+
template <typename T>
|
| 195 |
+
template <typename U>
|
| 196 |
+
__host__ __device__
|
| 197 |
+
complex<T>& complex<T>::operator+=(const complex<U>& z)
|
| 198 |
+
{
|
| 199 |
+
*this = *this + z;
|
| 200 |
+
return *this;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
template <typename T>
|
| 204 |
+
template <typename U>
|
| 205 |
+
__host__ __device__
|
| 206 |
+
complex<T>& complex<T>::operator-=(const complex<U>& z)
|
| 207 |
+
{
|
| 208 |
+
*this = *this - z;
|
| 209 |
+
return *this;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
template <typename T>
|
| 213 |
+
template <typename U>
|
| 214 |
+
__host__ __device__
|
| 215 |
+
complex<T>& complex<T>::operator*=(const complex<U>& z)
|
| 216 |
+
{
|
| 217 |
+
*this = *this * z;
|
| 218 |
+
return *this;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
template <typename T>
|
| 222 |
+
template <typename U>
|
| 223 |
+
__host__ __device__
|
| 224 |
+
complex<T>& complex<T>::operator/=(const complex<U>& z)
|
| 225 |
+
{
|
| 226 |
+
*this = *this / z;
|
| 227 |
+
return *this;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
template <typename T>
|
| 231 |
+
template <typename U>
|
| 232 |
+
__host__ __device__
|
| 233 |
+
complex<T>& complex<T>::operator+=(const U& z)
|
| 234 |
+
{
|
| 235 |
+
*this = *this + z;
|
| 236 |
+
return *this;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
template <typename T>
|
| 240 |
+
template <typename U>
|
| 241 |
+
__host__ __device__
|
| 242 |
+
complex<T>& complex<T>::operator-=(const U& z)
|
| 243 |
+
{
|
| 244 |
+
*this = *this - z;
|
| 245 |
+
return *this;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
template <typename T>
|
| 249 |
+
template <typename U>
|
| 250 |
+
__host__ __device__
|
| 251 |
+
complex<T>& complex<T>::operator*=(const U& z)
|
| 252 |
+
{
|
| 253 |
+
*this = *this * z;
|
| 254 |
+
return *this;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
template <typename T>
|
| 258 |
+
template <typename U>
|
| 259 |
+
__host__ __device__
|
| 260 |
+
complex<T>& complex<T>::operator/=(const U& z)
|
| 261 |
+
{
|
| 262 |
+
*this = *this / z;
|
| 263 |
+
return *this;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
/* --- Equality Operators --- */
|
| 269 |
+
|
| 270 |
+
template <typename T0, typename T1>
|
| 271 |
+
__host__ __device__
|
| 272 |
+
bool operator==(const complex<T0>& x, const complex<T1>& y)
|
| 273 |
+
{
|
| 274 |
+
return x.real() == y.real() && x.imag() == y.imag();
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
template <typename T0, typename T1>
|
| 278 |
+
__host__ THRUST_STD_COMPLEX_DEVICE
|
| 279 |
+
bool operator==(const complex<T0>& x, const std::complex<T1>& y)
|
| 280 |
+
{
|
| 281 |
+
return x.real() == THRUST_STD_COMPLEX_REAL(y) && x.imag() == THRUST_STD_COMPLEX_IMAG(y);
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
template <typename T0, typename T1>
|
| 285 |
+
__host__ THRUST_STD_COMPLEX_DEVICE
|
| 286 |
+
bool operator==(const std::complex<T0>& x, const complex<T1>& y)
|
| 287 |
+
{
|
| 288 |
+
return THRUST_STD_COMPLEX_REAL(x) == y.real() && THRUST_STD_COMPLEX_IMAG(x) == y.imag();
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
template <typename T0, typename T1>
|
| 292 |
+
__host__ __device__
|
| 293 |
+
bool operator==(const T0& x, const complex<T1>& y)
|
| 294 |
+
{
|
| 295 |
+
return x == y.real() && y.imag() == T1();
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
template <typename T0, typename T1>
|
| 299 |
+
__host__ __device__
|
| 300 |
+
bool operator==(const complex<T0>& x, const T1& y)
|
| 301 |
+
{
|
| 302 |
+
return x.real() == y && x.imag() == T1();
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
template <typename T0, typename T1>
|
| 306 |
+
__host__ __device__
|
| 307 |
+
bool operator!=(const complex<T0>& x, const complex<T1>& y)
|
| 308 |
+
{
|
| 309 |
+
return !(x == y);
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
template <typename T0, typename T1>
|
| 313 |
+
__host__ THRUST_STD_COMPLEX_DEVICE
|
| 314 |
+
bool operator!=(const complex<T0>& x, const std::complex<T1>& y)
|
| 315 |
+
{
|
| 316 |
+
return !(x == y);
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
template <typename T0, typename T1>
|
| 320 |
+
__host__ THRUST_STD_COMPLEX_DEVICE
|
| 321 |
+
bool operator!=(const std::complex<T0>& x, const complex<T1>& y)
|
| 322 |
+
{
|
| 323 |
+
return !(x == y);
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
template <typename T0, typename T1>
|
| 327 |
+
__host__ __device__
|
| 328 |
+
bool operator!=(const T0& x, const complex<T1>& y)
|
| 329 |
+
{
|
| 330 |
+
return !(x == y);
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
template <typename T0, typename T1>
|
| 334 |
+
__host__ __device__
|
| 335 |
+
bool operator!=(const complex<T0>& x, const T1& y)
|
| 336 |
+
{
|
| 337 |
+
return !(x == y);
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
template <typename T>
|
| 341 |
+
struct proclaim_trivially_relocatable<complex<T> > : thrust::true_type {};
|
| 342 |
+
|
| 343 |
+
THRUST_NAMESPACE_END
|
| 344 |
+
|
| 345 |
+
#include <thrust/detail/complex/arithmetic.h>
|
| 346 |
+
#include <thrust/detail/complex/cproj.h>
|
| 347 |
+
#include <thrust/detail/complex/cexp.h>
|
| 348 |
+
#include <thrust/detail/complex/cexpf.h>
|
| 349 |
+
#include <thrust/detail/complex/clog.h>
|
| 350 |
+
#include <thrust/detail/complex/clogf.h>
|
| 351 |
+
#include <thrust/detail/complex/cpow.h>
|
| 352 |
+
#include <thrust/detail/complex/ccosh.h>
|
| 353 |
+
#include <thrust/detail/complex/ccoshf.h>
|
| 354 |
+
#include <thrust/detail/complex/csinh.h>
|
| 355 |
+
#include <thrust/detail/complex/csinhf.h>
|
| 356 |
+
#include <thrust/detail/complex/ctanh.h>
|
| 357 |
+
#include <thrust/detail/complex/ctanhf.h>
|
| 358 |
+
#include <thrust/detail/complex/csqrt.h>
|
| 359 |
+
#include <thrust/detail/complex/csqrtf.h>
|
| 360 |
+
#include <thrust/detail/complex/catrig.h>
|
| 361 |
+
#include <thrust/detail/complex/catrigf.h>
|
| 362 |
+
#include <thrust/detail/complex/stream.h>
|
| 363 |
+
|
miniCUDA124/include/thrust/detail/complex/cpow.h
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#pragma once
|
| 19 |
+
|
| 20 |
+
#include <thrust/detail/config.h>
|
| 21 |
+
|
| 22 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 23 |
+
# pragma GCC system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 25 |
+
# pragma clang system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 27 |
+
# pragma system_header
|
| 28 |
+
#endif // no system header
|
| 29 |
+
|
| 30 |
+
#include <thrust/complex.h>
|
| 31 |
+
#include <thrust/detail/type_traits.h>
|
| 32 |
+
|
| 33 |
+
THRUST_NAMESPACE_BEGIN
|
| 34 |
+
|
| 35 |
+
template <typename T0, typename T1>
|
| 36 |
+
__host__ __device__
|
| 37 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 38 |
+
pow(const complex<T0>& x, const complex<T1>& y)
|
| 39 |
+
{
|
| 40 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 41 |
+
return exp(log(complex<T>(x)) * complex<T>(y));
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
template <typename T0, typename T1>
|
| 45 |
+
__host__ __device__
|
| 46 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 47 |
+
pow(const complex<T0>& x, const T1& y)
|
| 48 |
+
{
|
| 49 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 50 |
+
return exp(log(complex<T>(x)) * T(y));
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
template <typename T0, typename T1>
|
| 54 |
+
__host__ __device__
|
| 55 |
+
complex<typename detail::promoted_numerical_type<T0, T1>::type>
|
| 56 |
+
pow(const T0& x, const complex<T1>& y)
|
| 57 |
+
{
|
| 58 |
+
typedef typename detail::promoted_numerical_type<T0, T1>::type T;
|
| 59 |
+
// Find `log` by ADL.
|
| 60 |
+
using std::log;
|
| 61 |
+
return exp(log(T(x)) * complex<T>(y));
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
THRUST_NAMESPACE_END
|
| 65 |
+
|
miniCUDA124/include/thrust/detail/complex/cproj.h
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#pragma once
|
| 19 |
+
|
| 20 |
+
#include <thrust/detail/config.h>
|
| 21 |
+
|
| 22 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 23 |
+
# pragma GCC system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 25 |
+
# pragma clang system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 27 |
+
# pragma system_header
|
| 28 |
+
#endif // no system header
|
| 29 |
+
|
| 30 |
+
#include <thrust/complex.h>
|
| 31 |
+
#include <thrust/detail/complex/math_private.h>
|
| 32 |
+
#include <cmath>
|
| 33 |
+
|
| 34 |
+
THRUST_NAMESPACE_BEGIN
|
| 35 |
+
namespace detail{
|
| 36 |
+
namespace complex{
|
| 37 |
+
__host__ __device__
|
| 38 |
+
inline complex<float> cprojf(const complex<float>& z){
|
| 39 |
+
if(!isinf(z.real()) && !isinf(z.imag())){
|
| 40 |
+
return z;
|
| 41 |
+
}else{
|
| 42 |
+
// std::numeric_limits<T>::infinity() doesn't run on the GPU
|
| 43 |
+
return complex<float>(infinity<float>(), copysignf(0.0, z.imag()));
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
__host__ __device__
|
| 48 |
+
inline complex<double> cproj(const complex<double>& z){
|
| 49 |
+
if(!isinf(z.real()) && !isinf(z.imag())){
|
| 50 |
+
return z;
|
| 51 |
+
}else{
|
| 52 |
+
// std::numeric_limits<T>::infinity() doesn't run on the GPU
|
| 53 |
+
return complex<double>(infinity<double>(), copysign(0.0, z.imag()));
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
template <typename T>
|
| 62 |
+
__host__ __device__
|
| 63 |
+
inline thrust::complex<T> proj(const thrust::complex<T>& z){
|
| 64 |
+
return detail::complex::cproj(z);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
template <>
|
| 69 |
+
__host__ __device__
|
| 70 |
+
inline thrust::complex<double> proj(const thrust::complex<double>& z){
|
| 71 |
+
return detail::complex::cproj(z);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
template <>
|
| 75 |
+
__host__ __device__
|
| 76 |
+
inline thrust::complex<float> proj(const thrust::complex<float>& z){
|
| 77 |
+
return detail::complex::cprojf(z);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
THRUST_NAMESPACE_END
|
miniCUDA124/include/thrust/detail/complex/csinh.h
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 49 |
+
#pragma once
|
| 50 |
+
|
| 51 |
+
#include <thrust/detail/config.h>
|
| 52 |
+
|
| 53 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 54 |
+
# pragma GCC system_header
|
| 55 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 56 |
+
# pragma clang system_header
|
| 57 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 58 |
+
# pragma system_header
|
| 59 |
+
#endif // no system header
|
| 60 |
+
|
| 61 |
+
#include <thrust/complex.h>
|
| 62 |
+
#include <thrust/detail/complex/math_private.h>
|
| 63 |
+
|
| 64 |
+
THRUST_NAMESPACE_BEGIN
|
| 65 |
+
namespace detail{
|
| 66 |
+
namespace complex{
|
| 67 |
+
|
| 68 |
+
using thrust::complex;
|
| 69 |
+
|
| 70 |
+
__host__ __device__ inline
|
| 71 |
+
complex<double> csinh(const complex<double>& z){
|
| 72 |
+
double x, y, h;
|
| 73 |
+
uint32_t hx, hy, ix, iy, lx, ly;
|
| 74 |
+
const double huge = 8.98846567431157953864652595395e+307; // 0x1p1023;
|
| 75 |
+
|
| 76 |
+
x = z.real();
|
| 77 |
+
y = z.imag();
|
| 78 |
+
|
| 79 |
+
extract_words(hx, lx, x);
|
| 80 |
+
extract_words(hy, ly, y);
|
| 81 |
+
|
| 82 |
+
ix = 0x7fffffff & hx;
|
| 83 |
+
iy = 0x7fffffff & hy;
|
| 84 |
+
|
| 85 |
+
/* Handle the nearly-non-exceptional cases where x and y are finite. */
|
| 86 |
+
if (ix < 0x7ff00000 && iy < 0x7ff00000) {
|
| 87 |
+
if ((iy | ly) == 0)
|
| 88 |
+
return (complex<double>(sinh(x), y));
|
| 89 |
+
if (ix < 0x40360000) /* small x: normal case */
|
| 90 |
+
return (complex<double>(sinh(x) * cos(y), cosh(x) * sin(y)));
|
| 91 |
+
|
| 92 |
+
/* |x| >= 22, so cosh(x) ~= exp(|x|) */
|
| 93 |
+
if (ix < 0x40862e42) {
|
| 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 |
+
} else if (ix < 0x4096bbaa) {
|
| 98 |
+
/* x < 1455: scale to avoid overflow */
|
| 99 |
+
complex<double> z_ = ldexp_cexp(complex<double>(fabs(x), y), -1);
|
| 100 |
+
return (complex<double>(z_.real() * copysign(1.0, x), z_.imag()));
|
| 101 |
+
} else {
|
| 102 |
+
/* x >= 1455: the result always overflows */
|
| 103 |
+
h = huge * x;
|
| 104 |
+
return (complex<double>(h * cos(y), h * h * sin(y)));
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/*
|
| 109 |
+
* sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN.
|
| 110 |
+
* The sign of 0 in the result is unspecified. Choice = normally
|
| 111 |
+
* the same as dNaN. Raise the invalid floating-point exception.
|
| 112 |
+
*
|
| 113 |
+
* sinh(+-0 +- I NaN) = sign(d(+-0, NaN))0 + I d(NaN).
|
| 114 |
+
* The sign of 0 in the result is unspecified. Choice = normally
|
| 115 |
+
* the same as d(NaN).
|
| 116 |
+
*/
|
| 117 |
+
if ((ix | lx) == 0 && iy >= 0x7ff00000)
|
| 118 |
+
return (complex<double>(copysign(0.0, x * (y - y)), y - y));
|
| 119 |
+
|
| 120 |
+
/*
|
| 121 |
+
* sinh(+-Inf +- I 0) = +-Inf + I +-0.
|
| 122 |
+
*
|
| 123 |
+
* sinh(NaN +- I 0) = d(NaN) + I +-0.
|
| 124 |
+
*/
|
| 125 |
+
if ((iy | ly) == 0 && ix >= 0x7ff00000) {
|
| 126 |
+
if (((hx & 0xfffff) | lx) == 0)
|
| 127 |
+
return (complex<double>(x, y));
|
| 128 |
+
return (complex<double>(x, copysign(0.0, y)));
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/*
|
| 132 |
+
* sinh(x +- I Inf) = dNaN + I dNaN.
|
| 133 |
+
* Raise the invalid floating-point exception for finite nonzero x.
|
| 134 |
+
*
|
| 135 |
+
* sinh(x + I NaN) = d(NaN) + I d(NaN).
|
| 136 |
+
* Optionally raises the invalid floating-point exception for finite
|
| 137 |
+
* nonzero x. Choice = don't raise (except for signaling NaNs).
|
| 138 |
+
*/
|
| 139 |
+
if (ix < 0x7ff00000 && iy >= 0x7ff00000)
|
| 140 |
+
return (complex<double>(y - y, x * (y - y)));
|
| 141 |
+
|
| 142 |
+
/*
|
| 143 |
+
* sinh(+-Inf + I NaN) = +-Inf + I d(NaN).
|
| 144 |
+
* The sign of Inf in the result is unspecified. Choice = normally
|
| 145 |
+
* the same as d(NaN).
|
| 146 |
+
*
|
| 147 |
+
* sinh(+-Inf +- I Inf) = +Inf + I dNaN.
|
| 148 |
+
* The sign of Inf in the result is unspecified. Choice = always +.
|
| 149 |
+
* Raise the invalid floating-point exception.
|
| 150 |
+
*
|
| 151 |
+
* sinh(+-Inf + I y) = +-Inf cos(y) + I Inf sin(y)
|
| 152 |
+
*/
|
| 153 |
+
if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0) {
|
| 154 |
+
if (iy >= 0x7ff00000)
|
| 155 |
+
return (complex<double>(x * x, x * (y - y)));
|
| 156 |
+
return (complex<double>(x * cos(y), infinity<double>() * sin(y)));
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/*
|
| 160 |
+
* sinh(NaN + I NaN) = d(NaN) + I d(NaN).
|
| 161 |
+
*
|
| 162 |
+
* sinh(NaN +- I Inf) = d(NaN) + I d(NaN).
|
| 163 |
+
* Optionally raises the invalid floating-point exception.
|
| 164 |
+
* Choice = raise.
|
| 165 |
+
*
|
| 166 |
+
* sinh(NaN + I y) = d(NaN) + I d(NaN).
|
| 167 |
+
* Optionally raises the invalid floating-point exception for finite
|
| 168 |
+
* nonzero y. Choice = don't raise (except for signaling NaNs).
|
| 169 |
+
*/
|
| 170 |
+
return (complex<double>((x * x) * (y - y), (x + x) * (y - y)));
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
__host__ __device__ inline
|
| 174 |
+
complex<double> csin(complex<double> z){
|
| 175 |
+
/* csin(z) = -I * csinh(I * z) */
|
| 176 |
+
z = csinh(complex<double>(-z.imag(), z.real()));
|
| 177 |
+
return (complex<double>(z.imag(), -z.real()));
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
} // namespace complex
|
| 181 |
+
|
| 182 |
+
} // namespace detail
|
| 183 |
+
|
| 184 |
+
template <typename ValueType>
|
| 185 |
+
__host__ __device__
|
| 186 |
+
inline complex<ValueType> sin(const complex<ValueType>& z){
|
| 187 |
+
const ValueType re = z.real();
|
| 188 |
+
const ValueType im = z.imag();
|
| 189 |
+
return complex<ValueType>(std::sin(re) * std::cosh(im),
|
| 190 |
+
std::cos(re) * std::sinh(im));
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
template <typename ValueType>
|
| 195 |
+
__host__ __device__
|
| 196 |
+
inline complex<ValueType> sinh(const complex<ValueType>& z){
|
| 197 |
+
const ValueType re = z.real();
|
| 198 |
+
const ValueType im = z.imag();
|
| 199 |
+
return complex<ValueType>(std::sinh(re) * std::cos(im),
|
| 200 |
+
std::cosh(re) * std::sin(im));
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
template <>
|
| 204 |
+
__host__ __device__
|
| 205 |
+
inline complex<double> sin(const complex<double>& z){
|
| 206 |
+
return detail::complex::csin(z);
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
template <>
|
| 210 |
+
__host__ __device__
|
| 211 |
+
inline complex<double> sinh(const complex<double>& z){
|
| 212 |
+
return detail::complex::csinh(z);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
THRUST_NAMESPACE_END
|
miniCUDA124/include/thrust/detail/complex/csinhf.h
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 49 |
+
#pragma once
|
| 50 |
+
|
| 51 |
+
#include <thrust/detail/config.h>
|
| 52 |
+
|
| 53 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 54 |
+
# pragma GCC system_header
|
| 55 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 56 |
+
# pragma clang system_header
|
| 57 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 58 |
+
# pragma system_header
|
| 59 |
+
#endif // no system header
|
| 60 |
+
|
| 61 |
+
#include <thrust/complex.h>
|
| 62 |
+
#include <thrust/detail/complex/math_private.h>
|
| 63 |
+
|
| 64 |
+
THRUST_NAMESPACE_BEGIN
|
| 65 |
+
namespace detail{
|
| 66 |
+
namespace complex{
|
| 67 |
+
|
| 68 |
+
using thrust::complex;
|
| 69 |
+
|
| 70 |
+
__host__ __device__ inline
|
| 71 |
+
complex<float> csinhf(const complex<float>& z){
|
| 72 |
+
|
| 73 |
+
float x, y, h;
|
| 74 |
+
uint32_t hx, hy, ix, iy;
|
| 75 |
+
|
| 76 |
+
const float huge = 1.70141183460469231731687303716e+38; //0x1p127;
|
| 77 |
+
|
| 78 |
+
x = z.real();
|
| 79 |
+
y = z.imag();
|
| 80 |
+
|
| 81 |
+
get_float_word(hx, x);
|
| 82 |
+
get_float_word(hy, y);
|
| 83 |
+
|
| 84 |
+
ix = 0x7fffffff & hx;
|
| 85 |
+
iy = 0x7fffffff & hy;
|
| 86 |
+
|
| 87 |
+
if (ix < 0x7f800000 && iy < 0x7f800000) {
|
| 88 |
+
if (iy == 0)
|
| 89 |
+
return (complex<float>(sinhf(x), y));
|
| 90 |
+
if (ix < 0x41100000) /* small x: normal case */
|
| 91 |
+
return (complex<float>(sinhf(x) * cosf(y), coshf(x) * sinf(y)));
|
| 92 |
+
|
| 93 |
+
/* |x| >= 9, so cosh(x) ~= exp(|x|) */
|
| 94 |
+
if (ix < 0x42b17218) {
|
| 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 |
+
} else if (ix < 0x4340b1e7) {
|
| 99 |
+
/* x < 192.7: scale to avoid overflow */
|
| 100 |
+
complex<float> z_ = ldexp_cexpf(complex<float>(fabsf(x), y), -1);
|
| 101 |
+
return (complex<float>(z_.real() * copysignf(1.0f, x), z_.imag()));
|
| 102 |
+
} else {
|
| 103 |
+
/* x >= 192.7: the result always overflows */
|
| 104 |
+
h = huge * x;
|
| 105 |
+
return (complex<float>(h * cosf(y), h * h * sinf(y)));
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
if (ix == 0 && iy >= 0x7f800000)
|
| 110 |
+
return (complex<float>(copysignf(0, x * (y - y)), y - y));
|
| 111 |
+
|
| 112 |
+
if (iy == 0 && ix >= 0x7f800000) {
|
| 113 |
+
if ((hx & 0x7fffff) == 0)
|
| 114 |
+
return (complex<float>(x, y));
|
| 115 |
+
return (complex<float>(x, copysignf(0.0f, y)));
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
if (ix < 0x7f800000 && iy >= 0x7f800000)
|
| 119 |
+
return (complex<float>(y - y, x * (y - y)));
|
| 120 |
+
|
| 121 |
+
if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) {
|
| 122 |
+
if (iy >= 0x7f800000)
|
| 123 |
+
return (complex<float>(x * x, x * (y - y)));
|
| 124 |
+
return (complex<float>(x * cosf(y), infinity<float>() * sinf(y)));
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
return (complex<float>((x * x) * (y - y), (x + x) * (y - y)));
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
__host__ __device__ inline
|
| 131 |
+
complex<float> csinf(complex<float> z){
|
| 132 |
+
z = csinhf(complex<float>(-z.imag(), z.real()));
|
| 133 |
+
return (complex<float>(z.imag(), -z.real()));
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
} // namespace complex
|
| 137 |
+
|
| 138 |
+
} // namespace detail
|
| 139 |
+
|
| 140 |
+
template <>
|
| 141 |
+
__host__ __device__
|
| 142 |
+
inline complex<float> sin(const complex<float>& z){
|
| 143 |
+
return detail::complex::csinf(z);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
template <>
|
| 147 |
+
__host__ __device__
|
| 148 |
+
inline complex<float> sinh(const complex<float>& z){
|
| 149 |
+
return detail::complex::csinhf(z);
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
THRUST_NAMESPACE_END
|
miniCUDA124/include/thrust/detail/complex/csqrt.h
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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) 2007 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 |
+
/*
|
| 45 |
+
* Adapted from FreeBSD by Filipe Maia <filipe.c.maia@gmail.com>:
|
| 46 |
+
* freebsd/lib/msun/src/s_csqrt.c
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
#pragma once
|
| 51 |
+
|
| 52 |
+
#include <thrust/detail/config.h>
|
| 53 |
+
|
| 54 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 55 |
+
# pragma GCC system_header
|
| 56 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 57 |
+
# pragma clang system_header
|
| 58 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 59 |
+
# pragma system_header
|
| 60 |
+
#endif // no system header
|
| 61 |
+
|
| 62 |
+
#include <thrust/complex.h>
|
| 63 |
+
#include <thrust/detail/complex/math_private.h>
|
| 64 |
+
#include <cmath>
|
| 65 |
+
|
| 66 |
+
THRUST_NAMESPACE_BEGIN
|
| 67 |
+
namespace detail{
|
| 68 |
+
namespace complex{
|
| 69 |
+
|
| 70 |
+
using thrust::complex;
|
| 71 |
+
|
| 72 |
+
__host__ __device__ inline
|
| 73 |
+
complex<double> csqrt(const complex<double>& z){
|
| 74 |
+
complex<double> result;
|
| 75 |
+
double a, b;
|
| 76 |
+
double t;
|
| 77 |
+
int scale;
|
| 78 |
+
|
| 79 |
+
/* We risk spurious overflow for components >= DBL_MAX / (1 + sqrt(2)). */
|
| 80 |
+
const double THRESH = 7.446288774449766337959726e+307;
|
| 81 |
+
|
| 82 |
+
a = z.real();
|
| 83 |
+
b = z.imag();
|
| 84 |
+
|
| 85 |
+
/* Handle special cases. */
|
| 86 |
+
if (z == 0.0)
|
| 87 |
+
return (complex<double>(0.0, b));
|
| 88 |
+
if (isinf(b))
|
| 89 |
+
return (complex<double>(infinity<double>(), b));
|
| 90 |
+
if (isnan(a)) {
|
| 91 |
+
t = (b - b) / (b - b); /* raise invalid if b is not a NaN */
|
| 92 |
+
return (complex<double>(a, t)); /* return NaN + NaN i */
|
| 93 |
+
}
|
| 94 |
+
if (isinf(a)) {
|
| 95 |
+
/*
|
| 96 |
+
* csqrt(inf + NaN i) = inf + NaN i
|
| 97 |
+
* csqrt(inf + y i) = inf + 0 i
|
| 98 |
+
* csqrt(-inf + NaN i) = NaN +- inf i
|
| 99 |
+
* csqrt(-inf + y i) = 0 + inf i
|
| 100 |
+
*/
|
| 101 |
+
if (signbit(a))
|
| 102 |
+
return (complex<double>(fabs(b - b), copysign(a, b)));
|
| 103 |
+
else
|
| 104 |
+
return (complex<double>(a, copysign(b - b, b)));
|
| 105 |
+
}
|
| 106 |
+
/*
|
| 107 |
+
* The remaining special case (b is NaN) is handled just fine by
|
| 108 |
+
* the normal code path below.
|
| 109 |
+
*/
|
| 110 |
+
|
| 111 |
+
// DBL_MIN*2
|
| 112 |
+
const double low_thresh = 4.450147717014402766180465e-308;
|
| 113 |
+
scale = 0;
|
| 114 |
+
|
| 115 |
+
if (fabs(a) >= THRESH || fabs(b) >= THRESH) {
|
| 116 |
+
/* Scale to avoid overflow. */
|
| 117 |
+
a *= 0.25;
|
| 118 |
+
b *= 0.25;
|
| 119 |
+
scale = 1;
|
| 120 |
+
}else if (fabs(a) <= low_thresh && fabs(b) <= low_thresh) {
|
| 121 |
+
/* Scale to avoid underflow. */
|
| 122 |
+
a *= 4.0;
|
| 123 |
+
b *= 4.0;
|
| 124 |
+
scale = 2;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
/* Algorithm 312, CACM vol 10, Oct 1967. */
|
| 129 |
+
if (a >= 0.0) {
|
| 130 |
+
t = sqrt((a + hypot(a, b)) * 0.5);
|
| 131 |
+
result = complex<double>(t, b / (2 * t));
|
| 132 |
+
} else {
|
| 133 |
+
t = sqrt((-a + hypot(a, b)) * 0.5);
|
| 134 |
+
result = complex<double>(fabs(b) / (2 * t), copysign(t, b));
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/* Rescale. */
|
| 138 |
+
if (scale == 1)
|
| 139 |
+
return (result * 2.0);
|
| 140 |
+
else if (scale == 2)
|
| 141 |
+
return (result * 0.5);
|
| 142 |
+
else
|
| 143 |
+
return (result);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
} // namespace complex
|
| 147 |
+
|
| 148 |
+
} // namespace detail
|
| 149 |
+
|
| 150 |
+
template <typename ValueType>
|
| 151 |
+
__host__ __device__
|
| 152 |
+
inline complex<ValueType> sqrt(const complex<ValueType>& z){
|
| 153 |
+
return thrust::polar(std::sqrt(thrust::abs(z)),thrust::arg(z)/ValueType(2));
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
template <>
|
| 157 |
+
__host__ __device__
|
| 158 |
+
inline complex<double> sqrt(const complex<double>& z){
|
| 159 |
+
return detail::complex::csqrt(z);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
THRUST_NAMESPACE_END
|
miniCUDA124/include/thrust/detail/complex/csqrtf.h
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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) 2007 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 |
+
/*
|
| 45 |
+
* Adapted from FreeBSD by Filipe Maia <filipe.c.maia@gmail.com>:
|
| 46 |
+
* freebsd/lib/msun/src/s_csqrt.c
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
#pragma once
|
| 51 |
+
|
| 52 |
+
#include <thrust/detail/config.h>
|
| 53 |
+
|
| 54 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 55 |
+
# pragma GCC system_header
|
| 56 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 57 |
+
# pragma clang system_header
|
| 58 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 59 |
+
# pragma system_header
|
| 60 |
+
#endif // no system header
|
| 61 |
+
|
| 62 |
+
#include <thrust/complex.h>
|
| 63 |
+
#include <thrust/detail/complex/math_private.h>
|
| 64 |
+
#include <cmath>
|
| 65 |
+
|
| 66 |
+
THRUST_NAMESPACE_BEGIN
|
| 67 |
+
namespace detail{
|
| 68 |
+
namespace complex{
|
| 69 |
+
|
| 70 |
+
using thrust::complex;
|
| 71 |
+
|
| 72 |
+
__host__ __device__ inline
|
| 73 |
+
complex<float> csqrtf(const complex<float>& z){
|
| 74 |
+
float a = z.real(), b = z.imag();
|
| 75 |
+
float t;
|
| 76 |
+
int scale;
|
| 77 |
+
complex<float> result;
|
| 78 |
+
|
| 79 |
+
/* We risk spurious overflow for components >= FLT_MAX / (1 + sqrt(2)). */
|
| 80 |
+
const float THRESH = 1.40949553037932e+38f;
|
| 81 |
+
|
| 82 |
+
/* Handle special cases. */
|
| 83 |
+
if (z == 0.0f)
|
| 84 |
+
return (complex<float>(0, b));
|
| 85 |
+
if (isinf(b))
|
| 86 |
+
return (complex<float>(infinity<float>(), b));
|
| 87 |
+
if (isnan(a)) {
|
| 88 |
+
t = (b - b) / (b - b); /* raise invalid if b is not a NaN */
|
| 89 |
+
return (complex<float>(a, t)); /* return NaN + NaN i */
|
| 90 |
+
}
|
| 91 |
+
if (isinf(a)) {
|
| 92 |
+
/*
|
| 93 |
+
* csqrtf(inf + NaN i) = inf + NaN i
|
| 94 |
+
* csqrtf(inf + y i) = inf + 0 i
|
| 95 |
+
* csqrtf(-inf + NaN i) = NaN +- inf i
|
| 96 |
+
* csqrtf(-inf + y i) = 0 + inf i
|
| 97 |
+
*/
|
| 98 |
+
if (signbit(a))
|
| 99 |
+
return (complex<float>(fabsf(b - b), copysignf(a, b)));
|
| 100 |
+
else
|
| 101 |
+
return (complex<float>(a, copysignf(b - b, b)));
|
| 102 |
+
}
|
| 103 |
+
/*
|
| 104 |
+
* The remaining special case (b is NaN) is handled just fine by
|
| 105 |
+
* the normal code path below.
|
| 106 |
+
*/
|
| 107 |
+
|
| 108 |
+
/*
|
| 109 |
+
* Unlike in the FreeBSD code we'll avoid using double precision as
|
| 110 |
+
* not all hardware supports it.
|
| 111 |
+
*/
|
| 112 |
+
|
| 113 |
+
// FLT_MIN*2
|
| 114 |
+
const float low_thresh = 2.35098870164458e-38f;
|
| 115 |
+
scale = 0;
|
| 116 |
+
|
| 117 |
+
if (fabsf(a) >= THRESH || fabsf(b) >= THRESH) {
|
| 118 |
+
/* Scale to avoid overflow. */
|
| 119 |
+
a *= 0.25f;
|
| 120 |
+
b *= 0.25f;
|
| 121 |
+
scale = 1;
|
| 122 |
+
}else if (fabsf(a) <= low_thresh && fabsf(b) <= low_thresh) {
|
| 123 |
+
/* Scale to avoid underflow. */
|
| 124 |
+
a *= 4.f;
|
| 125 |
+
b *= 4.f;
|
| 126 |
+
scale = 2;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/* Algorithm 312, CACM vol 10, Oct 1967. */
|
| 130 |
+
if (a >= 0.0f) {
|
| 131 |
+
t = sqrtf((a + hypotf(a, b)) * 0.5f);
|
| 132 |
+
result = complex<float>(t, b / (2.0f * t));
|
| 133 |
+
} else {
|
| 134 |
+
t = sqrtf((-a + hypotf(a, b)) * 0.5f);
|
| 135 |
+
result = complex<float>(fabsf(b) / (2.0f * t), copysignf(t, b));
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
/* Rescale. */
|
| 139 |
+
if (scale == 1)
|
| 140 |
+
return (result * 2.0f);
|
| 141 |
+
else if (scale == 2)
|
| 142 |
+
return (result * 0.5f);
|
| 143 |
+
else
|
| 144 |
+
return (result);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
} // namespace complex
|
| 148 |
+
|
| 149 |
+
} // namespace detail
|
| 150 |
+
|
| 151 |
+
template <>
|
| 152 |
+
__host__ __device__
|
| 153 |
+
inline complex<float> sqrt(const complex<float>& z){
|
| 154 |
+
return detail::complex::csqrtf(z);
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
THRUST_NAMESPACE_END
|
miniCUDA124/include/thrust/detail/complex/ctanh.h
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 93 |
+
# pragma GCC system_header
|
| 94 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 95 |
+
# pragma clang system_header
|
| 96 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 97 |
+
# pragma system_header
|
| 98 |
+
#endif // no system header
|
| 99 |
+
|
| 100 |
+
#include <thrust/complex.h>
|
| 101 |
+
#include <thrust/detail/complex/math_private.h>
|
| 102 |
+
#include <cmath>
|
| 103 |
+
|
| 104 |
+
THRUST_NAMESPACE_BEGIN
|
| 105 |
+
namespace detail{
|
| 106 |
+
namespace complex{
|
| 107 |
+
|
| 108 |
+
using thrust::complex;
|
| 109 |
+
|
| 110 |
+
__host__ __device__ inline
|
| 111 |
+
complex<double> ctanh(const complex<double>& z){
|
| 112 |
+
double x, y;
|
| 113 |
+
double t, beta, s, rho, denom;
|
| 114 |
+
uint32_t hx, ix, lx;
|
| 115 |
+
|
| 116 |
+
x = z.real();
|
| 117 |
+
y = z.imag();
|
| 118 |
+
|
| 119 |
+
extract_words(hx, lx, x);
|
| 120 |
+
ix = hx & 0x7fffffff;
|
| 121 |
+
|
| 122 |
+
/*
|
| 123 |
+
* ctanh(NaN + i 0) = NaN + i 0
|
| 124 |
+
*
|
| 125 |
+
* ctanh(NaN + i y) = NaN + i NaN for y != 0
|
| 126 |
+
*
|
| 127 |
+
* The imaginary part has the sign of x*sin(2*y), but there's no
|
| 128 |
+
* special effort to get this right.
|
| 129 |
+
*
|
| 130 |
+
* ctanh(+-Inf +- i Inf) = +-1 +- 0
|
| 131 |
+
*
|
| 132 |
+
* ctanh(+-Inf + i y) = +-1 + 0 sin(2y) for y finite
|
| 133 |
+
*
|
| 134 |
+
* The imaginary part of the sign is unspecified. This special
|
| 135 |
+
* case is only needed to avoid a spurious invalid exception when
|
| 136 |
+
* y is infinite.
|
| 137 |
+
*/
|
| 138 |
+
if (ix >= 0x7ff00000) {
|
| 139 |
+
if ((ix & 0xfffff) | lx) /* x is NaN */
|
| 140 |
+
return (complex<double>(x, (y == 0 ? y : x * y)));
|
| 141 |
+
set_high_word(x, hx - 0x40000000); /* x = copysign(1, x) */
|
| 142 |
+
return (complex<double>(x, copysign(0.0, isinf(y) ? y : sin(y) * cos(y))));
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
/*
|
| 146 |
+
* ctanh(x + i NAN) = NaN + i NaN
|
| 147 |
+
* ctanh(x +- i Inf) = NaN + i NaN
|
| 148 |
+
*/
|
| 149 |
+
if (!isfinite(y))
|
| 150 |
+
return (complex<double>(y - y, y - y));
|
| 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) { /* x >= 22 */
|
| 158 |
+
double exp_mx = exp(-fabs(x));
|
| 159 |
+
return (complex<double>(copysign(1.0, x),
|
| 160 |
+
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 |
+
__host__ __device__ inline
|
| 173 |
+
complex<double> ctan(complex<double> z){
|
| 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 |
+
|
| 184 |
+
template <typename ValueType>
|
| 185 |
+
__host__ __device__
|
| 186 |
+
inline complex<ValueType> tan(const complex<ValueType>& z){
|
| 187 |
+
return sin(z)/cos(z);
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
template <typename ValueType>
|
| 191 |
+
__host__ __device__
|
| 192 |
+
inline complex<ValueType> tanh(const complex<ValueType>& z){
|
| 193 |
+
// This implementation seems better than the simple sin/cos
|
| 194 |
+
return (thrust::exp(ValueType(2)*z)-ValueType(1))/
|
| 195 |
+
(thrust::exp(ValueType(2)*z)+ValueType(1));
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
template <>
|
| 199 |
+
__host__ __device__
|
| 200 |
+
inline complex<double> tan(const complex<double>& z){
|
| 201 |
+
return detail::complex::ctan(z);
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
template <>
|
| 205 |
+
__host__ __device__
|
| 206 |
+
inline complex<double> tanh(const complex<double>& z){
|
| 207 |
+
return detail::complex::ctanh(z);
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
THRUST_NAMESPACE_END
|
miniCUDA124/include/thrust/detail/complex/ctanhf.h
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 58 |
+
# pragma GCC system_header
|
| 59 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 60 |
+
# pragma clang system_header
|
| 61 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 62 |
+
# pragma system_header
|
| 63 |
+
#endif // no system header
|
| 64 |
+
|
| 65 |
+
#include <thrust/complex.h>
|
| 66 |
+
#include <thrust/detail/complex/math_private.h>
|
| 67 |
+
#include <cmath>
|
| 68 |
+
|
| 69 |
+
THRUST_NAMESPACE_BEGIN
|
| 70 |
+
namespace detail{
|
| 71 |
+
namespace complex{
|
| 72 |
+
|
| 73 |
+
using thrust::complex;
|
| 74 |
+
|
| 75 |
+
__host__ __device__ inline
|
| 76 |
+
complex<float> ctanhf(const complex<float>& z){
|
| 77 |
+
float x, y;
|
| 78 |
+
float t, beta, s, rho, denom;
|
| 79 |
+
uint32_t hx, ix;
|
| 80 |
+
|
| 81 |
+
x = z.real();
|
| 82 |
+
y = z.imag();
|
| 83 |
+
|
| 84 |
+
get_float_word(hx, x);
|
| 85 |
+
ix = hx & 0x7fffffff;
|
| 86 |
+
|
| 87 |
+
if (ix >= 0x7f800000) {
|
| 88 |
+
if (ix & 0x7fffff)
|
| 89 |
+
return (complex<float>(x, (y == 0.0f ? y : x * y)));
|
| 90 |
+
set_float_word(x, hx - 0x40000000);
|
| 91 |
+
return (complex<float>(x,
|
| 92 |
+
copysignf(0, isinf(y) ? y : sinf(y) * cosf(y))));
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
if (!isfinite(y))
|
| 96 |
+
return (complex<float>(y - y, y - y));
|
| 97 |
+
|
| 98 |
+
if (ix >= 0x41300000) { /* x >= 11 */
|
| 99 |
+
float exp_mx = expf(-fabsf(x));
|
| 100 |
+
return (complex<float>(copysignf(1.0f, x),
|
| 101 |
+
4.0f * sinf(y) * cosf(y) * exp_mx * exp_mx));
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
t = tanf(y);
|
| 105 |
+
beta = 1.0f + t * t;
|
| 106 |
+
s = sinhf(x);
|
| 107 |
+
rho = sqrtf(1.0f + s * s);
|
| 108 |
+
denom = 1.0f + beta * s * s;
|
| 109 |
+
return (complex<float>((beta * rho * s) / denom, t / denom));
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
__host__ __device__ inline
|
| 113 |
+
complex<float> ctanf(complex<float> z){
|
| 114 |
+
z = ctanhf(complex<float>(-z.imag(), z.real()));
|
| 115 |
+
return (complex<float>(z.imag(), -z.real()));
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
} // namespace complex
|
| 119 |
+
|
| 120 |
+
} // namespace detail
|
| 121 |
+
|
| 122 |
+
template <>
|
| 123 |
+
__host__ __device__
|
| 124 |
+
inline complex<float> tan(const complex<float>& z){
|
| 125 |
+
return detail::complex::ctanf(z);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
template <>
|
| 129 |
+
__host__ __device__
|
| 130 |
+
inline complex<float> tanh(const complex<float>& z){
|
| 131 |
+
return detail::complex::ctanhf(z);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
THRUST_NAMESPACE_END
|
miniCUDA124/include/thrust/detail/complex/math_private.h
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
* ====================================================
|
| 20 |
+
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
| 21 |
+
*
|
| 22 |
+
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
| 23 |
+
* Permission to use, copy, modify, and distribute this
|
| 24 |
+
* software is freely granted, provided that this notice
|
| 25 |
+
* is preserved.
|
| 26 |
+
* ====================================================
|
| 27 |
+
*/
|
| 28 |
+
|
| 29 |
+
/* adapted from FreeBSD:
|
| 30 |
+
* lib/msun/src/math_private.h
|
| 31 |
+
*/
|
| 32 |
+
#pragma once
|
| 33 |
+
|
| 34 |
+
#include <thrust/detail/config.h>
|
| 35 |
+
|
| 36 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 37 |
+
# pragma GCC system_header
|
| 38 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 39 |
+
# pragma clang system_header
|
| 40 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 41 |
+
# pragma system_header
|
| 42 |
+
#endif // no system header
|
| 43 |
+
|
| 44 |
+
#include <thrust/complex.h>
|
| 45 |
+
#include <thrust/detail/cstdint.h>
|
| 46 |
+
|
| 47 |
+
THRUST_NAMESPACE_BEGIN
|
| 48 |
+
namespace detail{
|
| 49 |
+
namespace complex{
|
| 50 |
+
|
| 51 |
+
using thrust::complex;
|
| 52 |
+
|
| 53 |
+
typedef union
|
| 54 |
+
{
|
| 55 |
+
float value;
|
| 56 |
+
uint32_t word;
|
| 57 |
+
} ieee_float_shape_type;
|
| 58 |
+
|
| 59 |
+
__host__ __device__
|
| 60 |
+
inline void get_float_word(uint32_t & i, float d){
|
| 61 |
+
ieee_float_shape_type gf_u;
|
| 62 |
+
gf_u.value = (d);
|
| 63 |
+
(i) = gf_u.word;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
__host__ __device__
|
| 67 |
+
inline void get_float_word(int32_t & i, float d){
|
| 68 |
+
ieee_float_shape_type gf_u;
|
| 69 |
+
gf_u.value = (d);
|
| 70 |
+
(i) = gf_u.word;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
__host__ __device__
|
| 74 |
+
inline void set_float_word(float & d, uint32_t i){
|
| 75 |
+
ieee_float_shape_type sf_u;
|
| 76 |
+
sf_u.word = (i);
|
| 77 |
+
(d) = sf_u.value;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
// Assumes little endian ordering
|
| 81 |
+
typedef union
|
| 82 |
+
{
|
| 83 |
+
double value;
|
| 84 |
+
struct
|
| 85 |
+
{
|
| 86 |
+
uint32_t lsw;
|
| 87 |
+
uint32_t msw;
|
| 88 |
+
} parts;
|
| 89 |
+
struct
|
| 90 |
+
{
|
| 91 |
+
uint64_t w;
|
| 92 |
+
} xparts;
|
| 93 |
+
} ieee_double_shape_type;
|
| 94 |
+
|
| 95 |
+
__host__ __device__ inline
|
| 96 |
+
void get_high_word(uint32_t & i,double d){
|
| 97 |
+
ieee_double_shape_type gh_u;
|
| 98 |
+
gh_u.value = (d);
|
| 99 |
+
(i) = gh_u.parts.msw;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/* Set the more significant 32 bits of a double from an int. */
|
| 103 |
+
__host__ __device__ inline
|
| 104 |
+
void set_high_word(double & d, uint32_t v){
|
| 105 |
+
ieee_double_shape_type sh_u;
|
| 106 |
+
sh_u.value = (d);
|
| 107 |
+
sh_u.parts.msw = (v);
|
| 108 |
+
(d) = sh_u.value;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
__host__ __device__ inline
|
| 113 |
+
void insert_words(double & d, uint32_t ix0, uint32_t ix1){
|
| 114 |
+
ieee_double_shape_type iw_u;
|
| 115 |
+
iw_u.parts.msw = (ix0);
|
| 116 |
+
iw_u.parts.lsw = (ix1);
|
| 117 |
+
(d) = iw_u.value;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/* Get two 32 bit ints from a double. */
|
| 121 |
+
__host__ __device__ inline
|
| 122 |
+
void extract_words(uint32_t & ix0,uint32_t & ix1, double d){
|
| 123 |
+
ieee_double_shape_type ew_u;
|
| 124 |
+
ew_u.value = (d);
|
| 125 |
+
(ix0) = ew_u.parts.msw;
|
| 126 |
+
(ix1) = ew_u.parts.lsw;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/* Get two 32 bit ints from a double. */
|
| 130 |
+
__host__ __device__ inline
|
| 131 |
+
void extract_words(int32_t & ix0,int32_t & ix1, double d){
|
| 132 |
+
ieee_double_shape_type ew_u;
|
| 133 |
+
ew_u.value = (d);
|
| 134 |
+
(ix0) = ew_u.parts.msw;
|
| 135 |
+
(ix1) = ew_u.parts.lsw;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
} // namespace complex
|
| 139 |
+
|
| 140 |
+
} // namespace detail
|
| 141 |
+
|
| 142 |
+
THRUST_NAMESPACE_END
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
#include <thrust/detail/complex/c99math.h>
|
miniCUDA124/include/thrust/detail/complex/stream.h
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#pragma once
|
| 19 |
+
|
| 20 |
+
#include <thrust/detail/config.h>
|
| 21 |
+
|
| 22 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 23 |
+
# pragma GCC system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 25 |
+
# pragma clang system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 27 |
+
# pragma system_header
|
| 28 |
+
#endif // no system header
|
| 29 |
+
|
| 30 |
+
#include <thrust/complex.h>
|
| 31 |
+
|
| 32 |
+
THRUST_NAMESPACE_BEGIN
|
| 33 |
+
template<typename ValueType,class charT, class traits>
|
| 34 |
+
std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const complex<ValueType>& z)
|
| 35 |
+
{
|
| 36 |
+
os << '(' << z.real() << ',' << z.imag() << ')';
|
| 37 |
+
return os;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
template<typename ValueType, typename charT, class traits>
|
| 41 |
+
std::basic_istream<charT, traits>&
|
| 42 |
+
operator>>(std::basic_istream<charT, traits>& is, complex<ValueType>& z)
|
| 43 |
+
{
|
| 44 |
+
ValueType re, im;
|
| 45 |
+
|
| 46 |
+
charT ch;
|
| 47 |
+
is >> ch;
|
| 48 |
+
|
| 49 |
+
if(ch == '(')
|
| 50 |
+
{
|
| 51 |
+
is >> re >> ch;
|
| 52 |
+
if (ch == ',')
|
| 53 |
+
{
|
| 54 |
+
is >> im >> ch;
|
| 55 |
+
if (ch == ')')
|
| 56 |
+
{
|
| 57 |
+
z = complex<ValueType>(re, im);
|
| 58 |
+
}
|
| 59 |
+
else
|
| 60 |
+
{
|
| 61 |
+
is.setstate(std::ios_base::failbit);
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
else if (ch == ')')
|
| 65 |
+
{
|
| 66 |
+
z = re;
|
| 67 |
+
}
|
| 68 |
+
else
|
| 69 |
+
{
|
| 70 |
+
is.setstate(std::ios_base::failbit);
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
else
|
| 74 |
+
{
|
| 75 |
+
is.putback(ch);
|
| 76 |
+
is >> re;
|
| 77 |
+
z = re;
|
| 78 |
+
}
|
| 79 |
+
return is;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
THRUST_NAMESPACE_END
|
miniCUDA124/include/thrust/detail/config/compiler.h
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#define THRUST_HOST_COMPILER_UNKNOWN 0
|
| 35 |
+
#define THRUST_HOST_COMPILER_MSVC 1
|
| 36 |
+
#define THRUST_HOST_COMPILER_GCC 2
|
| 37 |
+
#define THRUST_HOST_COMPILER_CLANG 3
|
| 38 |
+
#define THRUST_HOST_COMPILER_INTEL 4
|
| 39 |
+
|
| 40 |
+
// enumerate device compilers we know about
|
| 41 |
+
#define THRUST_DEVICE_COMPILER_UNKNOWN 0
|
| 42 |
+
#define THRUST_DEVICE_COMPILER_MSVC 1
|
| 43 |
+
#define THRUST_DEVICE_COMPILER_GCC 2
|
| 44 |
+
#define THRUST_DEVICE_COMPILER_CLANG 3
|
| 45 |
+
#define THRUST_DEVICE_COMPILER_NVCC 4
|
| 46 |
+
|
| 47 |
+
// figure out which host compiler we're using
|
| 48 |
+
// XXX we should move the definition of THRUST_DEPRECATED out of this logic
|
| 49 |
+
#if defined(_MSC_VER)
|
| 50 |
+
#define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_MSVC
|
| 51 |
+
#define THRUST_MSVC_VERSION _MSC_VER
|
| 52 |
+
#define THRUST_MSVC_VERSION_FULL _MSC_FULL_VER
|
| 53 |
+
#elif defined(__ICC)
|
| 54 |
+
#define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_INTEL
|
| 55 |
+
#elif defined(__clang__)
|
| 56 |
+
#define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_CLANG
|
| 57 |
+
#define THRUST_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
|
| 58 |
+
#elif defined(__GNUC__)
|
| 59 |
+
#define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_GCC
|
| 60 |
+
#define THRUST_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
| 61 |
+
#if (THRUST_GCC_VERSION >= 50000)
|
| 62 |
+
#define THRUST_MODERN_GCC
|
| 63 |
+
#else
|
| 64 |
+
#define THRUST_LEGACY_GCC
|
| 65 |
+
#endif
|
| 66 |
+
#else
|
| 67 |
+
#define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_UNKNOWN
|
| 68 |
+
#endif // THRUST_HOST_COMPILER
|
| 69 |
+
|
| 70 |
+
// figure out which device compiler we're using
|
| 71 |
+
#if defined(__CUDACC__) || defined(_NVHPC_CUDA)
|
| 72 |
+
#define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_NVCC
|
| 73 |
+
#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC
|
| 74 |
+
#define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_MSVC
|
| 75 |
+
#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC
|
| 76 |
+
#define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_GCC
|
| 77 |
+
#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG
|
| 78 |
+
// CUDA-capable clang should behave similar to NVCC.
|
| 79 |
+
#if defined(__CUDA__)
|
| 80 |
+
#define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_NVCC
|
| 81 |
+
#else
|
| 82 |
+
#define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_CLANG
|
| 83 |
+
#endif
|
| 84 |
+
#else
|
| 85 |
+
#define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_UNKNOWN
|
| 86 |
+
#endif
|
| 87 |
+
|
| 88 |
+
// is the device compiler capable of compiling omp?
|
| 89 |
+
#if defined(_OPENMP) || defined(_NVHPC_STDPAR_OPENMP)
|
| 90 |
+
#define THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE THRUST_TRUE
|
| 91 |
+
#else
|
| 92 |
+
#define THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE THRUST_FALSE
|
| 93 |
+
#endif // _OPENMP
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
#if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC) && !defined(__CUDA_ARCH__)
|
| 97 |
+
#define THRUST_DISABLE_MSVC_WARNING_BEGIN(x) \
|
| 98 |
+
__pragma(warning(push)) \
|
| 99 |
+
__pragma(warning(disable : x)) \
|
| 100 |
+
/**/
|
| 101 |
+
#define THRUST_DISABLE_MSVC_WARNING_END(x) \
|
| 102 |
+
__pragma(warning(pop)) \
|
| 103 |
+
/**/
|
| 104 |
+
#else
|
| 105 |
+
#define THRUST_DISABLE_MSVC_WARNING_BEGIN(x)
|
| 106 |
+
#define THRUST_DISABLE_MSVC_WARNING_END(x)
|
| 107 |
+
#endif
|
| 108 |
+
|
| 109 |
+
#if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG) && !defined(__CUDA_ARCH__)
|
| 110 |
+
#define THRUST_IGNORE_CLANG_WARNING_IMPL(x) \
|
| 111 |
+
THRUST_PP_STRINGIZE(clang diagnostic ignored x) \
|
| 112 |
+
/**/
|
| 113 |
+
#define THRUST_IGNORE_CLANG_WARNING(x) \
|
| 114 |
+
THRUST_IGNORE_CLANG_WARNING_IMPL(THRUST_PP_STRINGIZE(x)) \
|
| 115 |
+
/**/
|
| 116 |
+
|
| 117 |
+
#define THRUST_DISABLE_CLANG_WARNING_BEGIN(x) \
|
| 118 |
+
_Pragma("clang diagnostic push") \
|
| 119 |
+
_Pragma(THRUST_IGNORE_CLANG_WARNING(x)) \
|
| 120 |
+
/**/
|
| 121 |
+
#define THRUST_DISABLE_CLANG_WARNING_END(x) \
|
| 122 |
+
_Pragma("clang diagnostic pop") \
|
| 123 |
+
/**/
|
| 124 |
+
#else
|
| 125 |
+
#define THRUST_DISABLE_CLANG_WARNING_BEGIN(x)
|
| 126 |
+
#define THRUST_DISABLE_CLANG_WARNING_END(x)
|
| 127 |
+
#endif
|
| 128 |
+
|
| 129 |
+
#if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC) && !defined(__CUDA_ARCH__)
|
| 130 |
+
#define THRUST_IGNORE_GCC_WARNING_IMPL(x) \
|
| 131 |
+
THRUST_PP_STRINGIZE(GCC diagnostic ignored x) \
|
| 132 |
+
/**/
|
| 133 |
+
#define THRUST_IGNORE_GCC_WARNING(x) \
|
| 134 |
+
THRUST_IGNORE_GCC_WARNING_IMPL(THRUST_PP_STRINGIZE(x)) \
|
| 135 |
+
/**/
|
| 136 |
+
|
| 137 |
+
#define THRUST_DISABLE_GCC_WARNING_BEGIN(x) \
|
| 138 |
+
_Pragma("GCC diagnostic push") \
|
| 139 |
+
_Pragma(THRUST_IGNORE_GCC_WARNING(x)) \
|
| 140 |
+
/**/
|
| 141 |
+
#define THRUST_DISABLE_GCC_WARNING_END(x) \
|
| 142 |
+
_Pragma("GCC diagnostic pop") \
|
| 143 |
+
/**/
|
| 144 |
+
#else
|
| 145 |
+
#define THRUST_DISABLE_GCC_WARNING_BEGIN(x)
|
| 146 |
+
#define THRUST_DISABLE_GCC_WARNING_END(x)
|
| 147 |
+
#endif
|
| 148 |
+
|
| 149 |
+
#define THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN \
|
| 150 |
+
THRUST_DISABLE_MSVC_WARNING_BEGIN(4244 4267) \
|
| 151 |
+
/**/
|
| 152 |
+
#define THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END \
|
| 153 |
+
THRUST_DISABLE_MSVC_WARNING_END(4244 4267) \
|
| 154 |
+
/**/
|
| 155 |
+
#define THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING(x) \
|
| 156 |
+
THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN \
|
| 157 |
+
x; \
|
| 158 |
+
THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END \
|
| 159 |
+
/**/
|
| 160 |
+
|
| 161 |
+
#define THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_BEGIN \
|
| 162 |
+
THRUST_DISABLE_MSVC_WARNING_BEGIN(4800) \
|
| 163 |
+
/**/
|
| 164 |
+
#define THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_END \
|
| 165 |
+
THRUST_DISABLE_MSVC_WARNING_END(4800) \
|
| 166 |
+
/**/
|
| 167 |
+
#define THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING(x) \
|
| 168 |
+
THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_BEGIN \
|
| 169 |
+
x; \
|
| 170 |
+
THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_END \
|
| 171 |
+
/**/
|
| 172 |
+
|
| 173 |
+
#define THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_BEGIN \
|
| 174 |
+
THRUST_DISABLE_CLANG_WARNING_BEGIN(-Wself-assign) \
|
| 175 |
+
/**/
|
| 176 |
+
#define THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_END \
|
| 177 |
+
THRUST_DISABLE_CLANG_WARNING_END(-Wself-assign) \
|
| 178 |
+
/**/
|
| 179 |
+
#define THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING(x) \
|
| 180 |
+
THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_BEGIN \
|
| 181 |
+
x; \
|
| 182 |
+
THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_END \
|
| 183 |
+
/**/
|
| 184 |
+
|
| 185 |
+
#define THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_BEGIN \
|
| 186 |
+
THRUST_DISABLE_CLANG_WARNING_BEGIN(-Wreorder) \
|
| 187 |
+
THRUST_DISABLE_GCC_WARNING_BEGIN(-Wreorder) \
|
| 188 |
+
/**/
|
| 189 |
+
#define THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_END \
|
| 190 |
+
THRUST_DISABLE_CLANG_WARNING_END(-Wreorder) \
|
| 191 |
+
THRUST_DISABLE_GCC_WARNING_END(-Wreorder) \
|
| 192 |
+
/**/
|
| 193 |
+
#define THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING(x) \
|
| 194 |
+
THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_BEGIN \
|
| 195 |
+
x; \
|
| 196 |
+
THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_END \
|
| 197 |
+
/**/
|
| 198 |
+
|
| 199 |
+
|
miniCUDA124/include/thrust/detail/config/compiler_fence.h
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// TODO: Enable this or remove this file once nvGRAPH/CUSP migrates off of it.
|
| 32 |
+
//#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC
|
| 33 |
+
// #pragma message("warning: The functionality in this header is unsafe, deprecated, and will soon be removed. Use C++11 or C11 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 THRUST_HOST_COMPILER == THRUST_HOST_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() do {} while (0)
|
| 49 |
+
|
| 50 |
+
#endif // _DEBUG
|
| 51 |
+
|
| 52 |
+
// gcc case
|
| 53 |
+
#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC
|
| 54 |
+
|
| 55 |
+
#if THRUST_GCC_VERSION >= 40200 // atomic built-ins were introduced ~4.2
|
| 56 |
+
#define __thrust_compiler_fence() __sync_synchronize()
|
| 57 |
+
#else
|
| 58 |
+
// allow the code to compile without any guarantees
|
| 59 |
+
#define __thrust_compiler_fence() do {} while (0)
|
| 60 |
+
#endif // THRUST_GCC_VERSION
|
| 61 |
+
|
| 62 |
+
// unknown case
|
| 63 |
+
#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG
|
| 64 |
+
#define __thrust_compiler_fence() __sync_synchronize()
|
| 65 |
+
#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_UNKNOWN
|
| 66 |
+
|
| 67 |
+
// allow the code to compile without any guarantees
|
| 68 |
+
#define __thrust_compiler_fence() do {} while (0)
|
| 69 |
+
|
| 70 |
+
#endif
|
| 71 |
+
|
miniCUDA124/include/thrust/detail/config/config.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>
|
| 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/simple_defines.h>
|
| 37 |
+
#include <thrust/detail/config/compiler.h>
|
| 38 |
+
#include <thrust/detail/config/cpp_dialect.h>
|
| 39 |
+
#include <thrust/detail/config/cpp_compatibility.h>
|
| 40 |
+
#include <thrust/detail/config/deprecated.h>
|
| 41 |
+
// host_system.h & device_system.h must be #included as early as possible
|
| 42 |
+
// because other config headers depend on it
|
| 43 |
+
#include <thrust/detail/config/host_system.h>
|
| 44 |
+
#include <thrust/detail/config/device_system.h>
|
| 45 |
+
#include <thrust/detail/config/host_device.h>
|
| 46 |
+
#include <thrust/detail/config/debug.h>
|
| 47 |
+
#include <thrust/detail/config/forceinline.h>
|
| 48 |
+
#include <thrust/detail/config/exec_check_disable.h>
|
| 49 |
+
#include <thrust/detail/config/global_workarounds.h>
|
| 50 |
+
#include <thrust/detail/config/namespace.h>
|
| 51 |
+
|
miniCUDA124/include/thrust/detail/config/cpp_compatibility.h
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#include <thrust/detail/config/cpp_dialect.h>
|
| 30 |
+
|
| 31 |
+
#include <cstddef>
|
| 32 |
+
|
| 33 |
+
#ifndef __has_cpp_attribute
|
| 34 |
+
# define __has_cpp_attribute(X) 0
|
| 35 |
+
#endif
|
| 36 |
+
|
| 37 |
+
// Trailing return types seem to confuse Doxygen, and cause it to interpret
|
| 38 |
+
// parts of the function's body as new function signatures.
|
| 39 |
+
#if defined(THRUST_DOXYGEN)
|
| 40 |
+
# define THRUST_TRAILING_RETURN(...)
|
| 41 |
+
#else
|
| 42 |
+
# define THRUST_TRAILING_RETURN(...) -> __VA_ARGS__
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#if THRUST_CPP_DIALECT >= 2014 && __has_cpp_attribute(nodiscard)
|
| 46 |
+
# define THRUST_NODISCARD [[nodiscard]]
|
| 47 |
+
#else
|
| 48 |
+
# define THRUST_NODISCARD
|
| 49 |
+
#endif
|
| 50 |
+
|
| 51 |
+
#if THRUST_CPP_DIALECT >= 2017 && __cpp_if_constexpr
|
| 52 |
+
# define THRUST_IF_CONSTEXPR if constexpr
|
| 53 |
+
#else
|
| 54 |
+
# define THRUST_IF_CONSTEXPR if
|
| 55 |
+
#endif
|
| 56 |
+
|
| 57 |
+
// FIXME: Combine THRUST_INLINE_CONSTANT and
|
| 58 |
+
// THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT into one macro when NVCC properly
|
| 59 |
+
// supports `constexpr` globals in host and device code.
|
| 60 |
+
#if defined(__CUDA_ARCH__) || defined(_NVHPC_CUDA)
|
| 61 |
+
// FIXME: Add this when NVCC supports inline variables.
|
| 62 |
+
//# if THRUST_CPP_DIALECT >= 2017
|
| 63 |
+
//# define THRUST_INLINE_CONSTANT inline constexpr
|
| 64 |
+
//# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT inline constexpr
|
| 65 |
+
# if THRUST_CPP_DIALECT >= 2011
|
| 66 |
+
# define THRUST_INLINE_CONSTANT static const __device__
|
| 67 |
+
# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr
|
| 68 |
+
# else
|
| 69 |
+
# define THRUST_INLINE_CONSTANT static const __device__
|
| 70 |
+
# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static const
|
| 71 |
+
# endif
|
| 72 |
+
#else
|
| 73 |
+
// FIXME: Add this when NVCC supports inline variables.
|
| 74 |
+
//# if THRUST_CPP_DIALECT >= 2017
|
| 75 |
+
//# define THRUST_INLINE_CONSTANT inline constexpr
|
| 76 |
+
//# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT inline constexpr
|
| 77 |
+
# if THRUST_CPP_DIALECT >= 2011
|
| 78 |
+
# define THRUST_INLINE_CONSTANT static constexpr
|
| 79 |
+
# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr
|
| 80 |
+
# else
|
| 81 |
+
# define THRUST_INLINE_CONSTANT static const
|
| 82 |
+
# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static const
|
| 83 |
+
# endif
|
| 84 |
+
#endif
|
| 85 |
+
|
| 86 |
+
// These definitions were intended for internal use only and are now obsolete.
|
| 87 |
+
// If you relied on them, consider porting your code to use the functionality
|
| 88 |
+
// in libcu++'s <nv/target> header.
|
| 89 |
+
// For a temporary workaround, define THRUST_PROVIDE_LEGACY_ARCH_MACROS to make
|
| 90 |
+
// them available again. These should be considered deprecated and will be
|
| 91 |
+
// fully removed in a future version.
|
| 92 |
+
#ifdef THRUST_PROVIDE_LEGACY_ARCH_MACROS
|
| 93 |
+
#ifndef THRUST_IS_DEVICE_CODE
|
| 94 |
+
#if defined(_NVHPC_CUDA)
|
| 95 |
+
#define THRUST_IS_DEVICE_CODE __builtin_is_device_code()
|
| 96 |
+
#define THRUST_IS_HOST_CODE (!__builtin_is_device_code())
|
| 97 |
+
#define THRUST_INCLUDE_DEVICE_CODE 1
|
| 98 |
+
#define THRUST_INCLUDE_HOST_CODE 1
|
| 99 |
+
#elif defined(__CUDA_ARCH__)
|
| 100 |
+
#define THRUST_IS_DEVICE_CODE 1
|
| 101 |
+
#define THRUST_IS_HOST_CODE 0
|
| 102 |
+
#define THRUST_INCLUDE_DEVICE_CODE 1
|
| 103 |
+
#define THRUST_INCLUDE_HOST_CODE 0
|
| 104 |
+
#else
|
| 105 |
+
#define THRUST_IS_DEVICE_CODE 0
|
| 106 |
+
#define THRUST_IS_HOST_CODE 1
|
| 107 |
+
#define THRUST_INCLUDE_DEVICE_CODE 0
|
| 108 |
+
#define THRUST_INCLUDE_HOST_CODE 1
|
| 109 |
+
#endif
|
| 110 |
+
#endif
|
| 111 |
+
#endif // THRUST_PROVIDE_LEGACY_ARCH_MACROS
|
miniCUDA124/include/thrust/detail/config/cpp_dialect.h
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>
|
| 34 |
+
|
| 35 |
+
// Deprecation warnings may be silenced by defining the following macros. These
|
| 36 |
+
// may be combined.
|
| 37 |
+
// - THRUST_IGNORE_DEPRECATED_CPP_DIALECT:
|
| 38 |
+
// Ignore all deprecated C++ dialects and outdated compilers.
|
| 39 |
+
// - THRUST_IGNORE_DEPRECATED_CPP_11:
|
| 40 |
+
// Ignore deprecation warnings when compiling with C++11. C++03 and outdated
|
| 41 |
+
// compilers will still issue warnings.
|
| 42 |
+
// - THRUST_IGNORE_DEPRECATED_COMPILER
|
| 43 |
+
// Ignore deprecation warnings when using deprecated compilers. Compiling
|
| 44 |
+
// with C++03 and C++11 will still issue warnings.
|
| 45 |
+
|
| 46 |
+
// Check for the CUB opt-outs as well:
|
| 47 |
+
#if !defined(THRUST_IGNORE_DEPRECATED_CPP_DIALECT) && \
|
| 48 |
+
defined(CUB_IGNORE_DEPRECATED_CPP_DIALECT)
|
| 49 |
+
# define THRUST_IGNORE_DEPRECATED_CPP_DIALECT
|
| 50 |
+
#endif
|
| 51 |
+
#if !defined(THRUST_IGNORE_DEPRECATED_CPP_11) && \
|
| 52 |
+
defined(CUB_IGNORE_DEPRECATED_CPP_11)
|
| 53 |
+
# define THRUST_IGNORE_DEPRECATED_CPP_11
|
| 54 |
+
#endif
|
| 55 |
+
#if !defined(THRUST_IGNORE_DEPRECATED_COMPILER) && \
|
| 56 |
+
defined(CUB_IGNORE_DEPRECATED_COMPILER)
|
| 57 |
+
# define THRUST_IGNORE_DEPRECATED_COMPILER
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
#ifdef THRUST_IGNORE_DEPRECATED_CPP_DIALECT
|
| 61 |
+
# define THRUST_IGNORE_DEPRECATED_CPP_11
|
| 62 |
+
# define THRUST_IGNORE_DEPRECATED_COMPILER
|
| 63 |
+
#endif
|
| 64 |
+
|
| 65 |
+
// Define this to override the built-in detection.
|
| 66 |
+
#ifndef THRUST_CPP_DIALECT
|
| 67 |
+
|
| 68 |
+
// MSVC does not define __cplusplus correctly. _MSVC_LANG is used instead.
|
| 69 |
+
// This macro is only defined in MSVC 2015U3+.
|
| 70 |
+
# ifdef _MSVC_LANG // Do not replace with THRUST_HOST_COMPILER test (see above)
|
| 71 |
+
// MSVC2015 reports C++14 but lacks extended constexpr support. Treat as C++11.
|
| 72 |
+
# if THRUST_MSVC_VERSION < 1910 && _MSVC_LANG > 201103L /* MSVC < 2017 && CPP > 2011 */
|
| 73 |
+
# define THRUST_CPLUSPLUS 201103L /* Fix to 2011 */
|
| 74 |
+
# else
|
| 75 |
+
# define THRUST_CPLUSPLUS _MSVC_LANG /* We'll trust this for now. */
|
| 76 |
+
# endif // MSVC 2015 C++14 fix
|
| 77 |
+
# else
|
| 78 |
+
# define THRUST_CPLUSPLUS __cplusplus
|
| 79 |
+
# endif
|
| 80 |
+
|
| 81 |
+
// Detect current dialect:
|
| 82 |
+
# if THRUST_CPLUSPLUS < 201103L
|
| 83 |
+
# define THRUST_CPP_DIALECT 2003
|
| 84 |
+
# elif THRUST_CPLUSPLUS < 201402L
|
| 85 |
+
# define THRUST_CPP_DIALECT 2011
|
| 86 |
+
# elif THRUST_CPLUSPLUS < 201703L
|
| 87 |
+
# define THRUST_CPP_DIALECT 2014
|
| 88 |
+
# elif THRUST_CPLUSPLUS == 201703L
|
| 89 |
+
# define THRUST_CPP_DIALECT 2017
|
| 90 |
+
# elif THRUST_CPLUSPLUS > 201703L // unknown, but is higher than 2017.
|
| 91 |
+
# define THRUST_CPP_DIALECT 2020
|
| 92 |
+
# endif
|
| 93 |
+
|
| 94 |
+
# undef THRUST_CPLUSPLUS // cleanup
|
| 95 |
+
|
| 96 |
+
#endif // !THRUST_CPP_DIALECT
|
| 97 |
+
|
| 98 |
+
// Define THRUST_COMPILER_DEPRECATION macro:
|
| 99 |
+
#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC
|
| 100 |
+
# define THRUST_COMP_DEPR_IMPL(msg) \
|
| 101 |
+
__pragma(message(__FILE__ ":" THRUST_COMP_DEPR_IMPL0(__LINE__) ": warning: " #msg))
|
| 102 |
+
# define THRUST_COMP_DEPR_IMPL0(x) THRUST_COMP_DEPR_IMPL1(x)
|
| 103 |
+
# define THRUST_COMP_DEPR_IMPL1(x) #x
|
| 104 |
+
#else // clang / gcc:
|
| 105 |
+
# define THRUST_COMP_DEPR_IMPL(msg) THRUST_COMP_DEPR_IMPL0(GCC warning #msg)
|
| 106 |
+
# define THRUST_COMP_DEPR_IMPL0(expr) _Pragma(#expr)
|
| 107 |
+
# define THRUST_COMP_DEPR_IMPL1 /* intentionally blank */
|
| 108 |
+
#endif
|
| 109 |
+
|
| 110 |
+
#define THRUST_COMPILER_DEPRECATION(REQ) \
|
| 111 |
+
THRUST_COMP_DEPR_IMPL(Thrust requires at least REQ. Define THRUST_IGNORE_DEPRECATED_COMPILER to suppress this message.)
|
| 112 |
+
|
| 113 |
+
#define THRUST_COMPILER_DEPRECATION_SOFT(REQ, CUR) \
|
| 114 |
+
THRUST_COMP_DEPR_IMPL(Thrust requires at least REQ. CUR is deprecated but still supported. CUR support will be removed in a future release. Define THRUST_IGNORE_DEPRECATED_CPP_DIALECT to suppress this message.)
|
| 115 |
+
|
| 116 |
+
#ifndef THRUST_IGNORE_DEPRECATED_COMPILER
|
| 117 |
+
|
| 118 |
+
// Compiler checks:
|
| 119 |
+
# if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC && THRUST_GCC_VERSION < 50000
|
| 120 |
+
THRUST_COMPILER_DEPRECATION(GCC 5.0);
|
| 121 |
+
# elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG && THRUST_CLANG_VERSION < 70000
|
| 122 |
+
THRUST_COMPILER_DEPRECATION(Clang 7.0);
|
| 123 |
+
# elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC && THRUST_MSVC_VERSION < 1910
|
| 124 |
+
// <2017. Hard upgrade message:
|
| 125 |
+
THRUST_COMPILER_DEPRECATION(MSVC 2019 (19.20/16.0/14.20));
|
| 126 |
+
# elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC && THRUST_MSVC_VERSION < 1920
|
| 127 |
+
// >=2017, <2019. Soft deprecation message:
|
| 128 |
+
THRUST_COMPILER_DEPRECATION_SOFT(MSVC 2019 (19.20/16.0/14.20), MSVC 2017);
|
| 129 |
+
# endif
|
| 130 |
+
|
| 131 |
+
#endif // THRUST_IGNORE_DEPRECATED_COMPILER
|
| 132 |
+
|
| 133 |
+
#ifndef THRUST_IGNORE_DEPRECATED_DIALECT
|
| 134 |
+
|
| 135 |
+
// Dialect checks:
|
| 136 |
+
# if THRUST_CPP_DIALECT < 2011
|
| 137 |
+
// <C++11. Hard upgrade message:
|
| 138 |
+
THRUST_COMPILER_DEPRECATION(C++14);
|
| 139 |
+
# elif THRUST_CPP_DIALECT == 2011 && !defined(THRUST_IGNORE_DEPRECATED_CPP_11)
|
| 140 |
+
// =C++11. Soft upgrade message:
|
| 141 |
+
THRUST_COMPILER_DEPRECATION_SOFT(C++14, C++11);
|
| 142 |
+
# endif
|
| 143 |
+
|
| 144 |
+
#endif // THRUST_IGNORE_DEPRECATED_DIALECT
|
| 145 |
+
|
| 146 |
+
#undef THRUST_COMPILER_DEPRECATION_SOFT
|
| 147 |
+
#undef THRUST_COMPILER_DEPRECATION
|
| 148 |
+
#undef THRUST_COMP_DEPR_IMPL
|
| 149 |
+
#undef THRUST_COMP_DEPR_IMPL0
|
| 150 |
+
#undef THRUST_COMP_DEPR_IMPL1
|
miniCUDA124/include/thrust/detail/config/debug.h
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#ifndef THRUST_DEBUG
|
| 30 |
+
# ifndef NDEBUG
|
| 31 |
+
# if defined(DEBUG) || defined(_DEBUG)
|
| 32 |
+
# define THRUST_DEBUG 1
|
| 33 |
+
# endif // (DEBUG || _DEBUG)
|
| 34 |
+
# endif // NDEBUG
|
| 35 |
+
#endif // THRUST_DEBUG
|
| 36 |
+
|
| 37 |
+
#if THRUST_DEBUG
|
| 38 |
+
# ifndef __THRUST_SYNCHRONOUS
|
| 39 |
+
# define __THRUST_SYNCHRONOUS 1
|
| 40 |
+
# endif // __THRUST_SYNCHRONOUS
|
| 41 |
+
#endif // THRUST_DEBUG
|
| 42 |
+
|
miniCUDA124/include/thrust/detail/config/deprecated.h
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2018-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 deprecated.h
|
| 18 |
+
* \brief Defines the THRUST_DEPRECATED macro
|
| 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 |
+
#include <thrust/detail/config/compiler.h>
|
| 34 |
+
#include <thrust/detail/config/cpp_dialect.h>
|
| 35 |
+
|
| 36 |
+
#if defined(CUB_IGNORE_DEPRECATED_API) && !defined(THRUST_IGNORE_DEPRECATED_API)
|
| 37 |
+
# define THRUST_IGNORE_DEPRECATED_API
|
| 38 |
+
#endif
|
| 39 |
+
|
| 40 |
+
#ifdef THRUST_IGNORE_DEPRECATED_API
|
| 41 |
+
# define THRUST_DEPRECATED
|
| 42 |
+
#elif THRUST_CPP_DIALECT >= 2014
|
| 43 |
+
# define THRUST_DEPRECATED [[deprecated]]
|
| 44 |
+
#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC
|
| 45 |
+
# define THRUST_DEPRECATED __declspec(deprecated)
|
| 46 |
+
#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG
|
| 47 |
+
# define THRUST_DEPRECATED __attribute__((deprecated))
|
| 48 |
+
#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC
|
| 49 |
+
# define THRUST_DEPRECATED __attribute__((deprecated))
|
| 50 |
+
#else
|
| 51 |
+
# define THRUST_DEPRECATED
|
| 52 |
+
#endif
|
miniCUDA124/include/thrust/detail/config/device_system.h
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#define __THRUST_DEVICE_SYSTEM_ROOT thrust/system/__THRUST_DEVICE_SYSTEM_NAMESPACE
|
| 54 |
+
|
miniCUDA124/include/thrust/detail/config/exec_check_disable.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 exec_check_disable.h
|
| 18 |
+
* \brief Defines __thrust_exec_check_disable__
|
| 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 |
+
// #pragma nv_exec_check_disable is only recognized by NVCC. Having a macro
|
| 34 |
+
// expand to a #pragma (rather than _Pragma) only works with NVCC's compilation
|
| 35 |
+
// model, not with other compilers.
|
| 36 |
+
#if defined(__CUDACC__) && !defined(_NVHPC_CUDA) && \
|
| 37 |
+
!(defined(__CUDA__) && defined(__clang__))
|
| 38 |
+
|
| 39 |
+
#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC
|
| 40 |
+
#define __thrust_exec_check_disable__ __pragma("nv_exec_check_disable")
|
| 41 |
+
#else // MSVC
|
| 42 |
+
#define __thrust_exec_check_disable__ _Pragma("nv_exec_check_disable")
|
| 43 |
+
#endif // MSVC
|
| 44 |
+
|
| 45 |
+
#else
|
| 46 |
+
|
| 47 |
+
#define __thrust_exec_check_disable__
|
| 48 |
+
|
| 49 |
+
#endif
|
| 50 |
+
|
| 51 |
+
|
miniCUDA124/include/thrust/detail/config/forceinline.h
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 forceinline.h
|
| 18 |
+
* \brief Defines __thrust_forceinline__
|
| 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 |
+
#if defined(__CUDACC__) || defined(_NVHPC_CUDA)
|
| 34 |
+
|
| 35 |
+
#define __thrust_forceinline__ __forceinline__
|
| 36 |
+
|
| 37 |
+
#else
|
| 38 |
+
|
| 39 |
+
// TODO add
|
| 40 |
+
|
| 41 |
+
#define __thrust_forceinline__
|
| 42 |
+
|
| 43 |
+
#endif
|
| 44 |
+
|
miniCUDA124/include/thrust/detail/config/global_workarounds.h
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 typedefs by silencing them globally
|
| 32 |
+
#if defined(THRUST_GCC_VERSION) && (THRUST_GCC_VERSION >= 40800)
|
| 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
|
| 37 |
+
|
miniCUDA124/include/thrust/detail/config/host_device.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 |
+
/*! \file host_device.h
|
| 18 |
+
* \brief Defines __host__ and __device__
|
| 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 |
+
// since nvcc defines __host__ and __device__ for us,
|
| 34 |
+
// and only nvcc knows what to do with __host__ and __device__,
|
| 35 |
+
// define them to be the empty string for other compilers
|
| 36 |
+
|
| 37 |
+
#if THRUST_DEVICE_COMPILER != THRUST_DEVICE_COMPILER_NVCC
|
| 38 |
+
|
| 39 |
+
// since __host__ & __device__ might have already be defined, only
|
| 40 |
+
// #define them if not defined already
|
| 41 |
+
// XXX this will break if the client does #include <host_defines.h> later
|
| 42 |
+
|
| 43 |
+
#ifndef __host__
|
| 44 |
+
#define __host__
|
| 45 |
+
#endif // __host__
|
| 46 |
+
|
| 47 |
+
#ifndef __device__
|
| 48 |
+
#define __device__
|
| 49 |
+
#endif // __device__
|
| 50 |
+
|
| 51 |
+
#endif
|
| 52 |
+
|
miniCUDA124/include/thrust/detail/config/host_system.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#define __THRUST_HOST_SYSTEM_ROOT thrust/system/__THRUST_HOST_SYSTEM_NAMESPACE
|
| 51 |
+
|
miniCUDA124/include/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 <cstddef>
|
| 30 |
+
|
| 31 |
+
#include <thrust/detail/alignment.h>
|
| 32 |
+
#include <thrust/detail/config/cpp_compatibility.h>
|
| 33 |
+
|
| 34 |
+
#define THRUST_MR_DEFAULT_ALIGNMENT THRUST_ALIGNOF(THRUST_NS_QUALIFIER::detail::max_align_t)
|
| 35 |
+
|
| 36 |
+
#if THRUST_CPP_DIALECT >= 2017
|
| 37 |
+
# if __has_include(<memory_resource>)
|
| 38 |
+
# define THRUST_MR_STD_MR_HEADER <memory_resource>
|
| 39 |
+
# define THRUST_MR_STD_MR_NS std::pmr
|
| 40 |
+
# elif __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
|
miniCUDA124/include/thrust/detail/config/namespace.h
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// clang-format off
|
| 101 |
+
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
|
| 102 |
+
# if !defined(THRUST_DETAIL_ABI_NS_NAME)
|
| 103 |
+
# define THRUST_DETAIL_COUNT_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, \
|
| 104 |
+
_14, _15, _16, _17, _18, _19, _20, N, ...) \
|
| 105 |
+
N
|
| 106 |
+
# define THRUST_DETAIL_COUNT(...) \
|
| 107 |
+
THRUST_DETAIL_IDENTITY(THRUST_DETAIL_COUNT_N(__VA_ARGS__, 20, 19, 18, 17, 16, 15, 14, 13, 12, \
|
| 108 |
+
11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1))
|
| 109 |
+
# define THRUST_DETAIL_IDENTITY(N) N
|
| 110 |
+
# define THRUST_DETAIL_APPLY(MACRO, ...) THRUST_DETAIL_IDENTITY(MACRO(__VA_ARGS__))
|
| 111 |
+
# define THRUST_DETAIL_ABI_NS_NAME1(P1) \
|
| 112 |
+
THRUST_##P1##_NS
|
| 113 |
+
# define THRUST_DETAIL_ABI_NS_NAME2(P1, P2) \
|
| 114 |
+
THRUST_##P1##_##P2##_NS
|
| 115 |
+
# define THRUST_DETAIL_ABI_NS_NAME3(P1, P2, P3) \
|
| 116 |
+
THRUST_##P1##_##P2##_##P3##_NS
|
| 117 |
+
# define THRUST_DETAIL_ABI_NS_NAME4(P1, P2, P3, P4) \
|
| 118 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_NS
|
| 119 |
+
# define THRUST_DETAIL_ABI_NS_NAME5(P1, P2, P3, P4, P5) \
|
| 120 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_NS
|
| 121 |
+
# define THRUST_DETAIL_ABI_NS_NAME6(P1, P2, P3, P4, P5, P6) \
|
| 122 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_NS
|
| 123 |
+
# define THRUST_DETAIL_ABI_NS_NAME7(P1, P2, P3, P4, P5, P6, P7) \
|
| 124 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_NS
|
| 125 |
+
# define THRUST_DETAIL_ABI_NS_NAME8(P1, P2, P3, P4, P5, P6, P7, P8) \
|
| 126 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_NS
|
| 127 |
+
# define THRUST_DETAIL_ABI_NS_NAME9(P1, P2, P3, P4, P5, P6, P7, P8, P9) \
|
| 128 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_NS
|
| 129 |
+
# define THRUST_DETAIL_ABI_NS_NAME10(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \
|
| 130 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_##P10##_NS
|
| 131 |
+
# define THRUST_DETAIL_ABI_NS_NAME11(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \
|
| 132 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_##P10##_##P11##_NS
|
| 133 |
+
# define THRUST_DETAIL_ABI_NS_NAME12(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \
|
| 134 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_##P10##_##P11##_##P12##_NS
|
| 135 |
+
# define THRUST_DETAIL_ABI_NS_NAME13(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \
|
| 136 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_##P10##_##P11##_##P12##_##P13##_NS
|
| 137 |
+
# define THRUST_DETAIL_ABI_NS_NAME14(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) \
|
| 138 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_##P10##_##P11##_##P12##_##P13##_##P14##_NS
|
| 139 |
+
# define THRUST_DETAIL_ABI_NS_NAME15(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) \
|
| 140 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_##P10##_##P11##_##P12##_##P13##_##P14##_##P15##_NS
|
| 141 |
+
# define THRUST_DETAIL_ABI_NS_NAME16(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16) \
|
| 142 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_##P10##_##P11##_##P12##_##P13##_##P14##_##P15##_##P16##_NS
|
| 143 |
+
# define THRUST_DETAIL_ABI_NS_NAME17(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17) \
|
| 144 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_##P10##_##P11##_##P12##_##P13##_##P14##_##P15##_##P16##_##P17##_NS
|
| 145 |
+
# define THRUST_DETAIL_ABI_NS_NAME18(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18) \
|
| 146 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_##P10##_##P11##_##P12##_##P13##_##P14##_##P15##_##P16##_##P17##_##P18##_NS
|
| 147 |
+
# define THRUST_DETAIL_ABI_NS_NAME19(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19) \
|
| 148 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_##P10##_##P11##_##P12##_##P13##_##P14##_##P15##_##P16##_##P17##_##P18##_##P19##_NS
|
| 149 |
+
# define THRUST_DETAIL_ABI_NS_NAME20(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20) \
|
| 150 |
+
THRUST_##P1##_##P2##_##P3##_##P4##_##P5##_##P6##_##P7##_##P8##_##P9##_##P10##_##P11##_##P12##_##P13##_##P14##_##P15##_##P16##_##P17##_##P18##_##P19##_##P20##_NS
|
| 151 |
+
# define THRUST_DETAIL_DISPATCH(N) THRUST_DETAIL_ABI_NS_NAME ## N
|
| 152 |
+
# define THRUST_DETAIL_ABI_NS_NAME(...) THRUST_DETAIL_IDENTITY(THRUST_DETAIL_APPLY(THRUST_DETAIL_DISPATCH, THRUST_DETAIL_COUNT(__VA_ARGS__))(__VA_ARGS__))
|
| 153 |
+
# endif // !defined(THRUST_DETAIL_ABI_NS_NAME)
|
| 154 |
+
|
| 155 |
+
# if defined(THRUST_DISABLE_ABI_NAMESPACE) || defined(THRUST_WRAPPED_NAMESPACE)
|
| 156 |
+
# if !defined(THRUST_WRAPPED_NAMESPACE)
|
| 157 |
+
# if !defined(THRUST_IGNORE_ABI_NAMESPACE_ERROR)
|
| 158 |
+
# error "Disabling ABI namespace is unsafe without wrapping namespace"
|
| 159 |
+
# endif // !defined(THRUST_IGNORE_ABI_NAMESPACE_ERROR)
|
| 160 |
+
# endif // !defined(THRUST_WRAPPED_NAMESPACE)
|
| 161 |
+
# define THRUST_DETAIL_ABI_NS_BEGIN
|
| 162 |
+
# define THRUST_DETAIL_ABI_NS_END
|
| 163 |
+
# else // not defined(THRUST_DISABLE_ABI_NAMESPACE)
|
| 164 |
+
# if defined(_NVHPC_CUDA)
|
| 165 |
+
# define THRUST_DETAIL_ABI_NS_BEGIN inline namespace THRUST_DETAIL_ABI_NS_NAME(THRUST_VERSION, NV_TARGET_SM_INTEGER_LIST) {
|
| 166 |
+
# define THRUST_DETAIL_ABI_NS_END }
|
| 167 |
+
# else // not defined(_NVHPC_CUDA)
|
| 168 |
+
# define THRUST_DETAIL_ABI_NS_BEGIN inline namespace THRUST_DETAIL_ABI_NS_NAME(THRUST_VERSION, __CUDA_ARCH_LIST__) {
|
| 169 |
+
# define THRUST_DETAIL_ABI_NS_END }
|
| 170 |
+
# endif // not defined(_NVHPC_CUDA)
|
| 171 |
+
# endif // not defined(THRUST_DISABLE_ABI_NAMESPACE)
|
| 172 |
+
#else // THRUST_DEVICE_SYSTEM != THRUST_DEVICE_SYSTEM_CUDA
|
| 173 |
+
# define THRUST_DETAIL_ABI_NS_BEGIN
|
| 174 |
+
# define THRUST_DETAIL_ABI_NS_END
|
| 175 |
+
#endif // THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
|
| 176 |
+
// clang-format on
|
| 177 |
+
|
| 178 |
+
/**
|
| 179 |
+
* \def THRUST_NAMESPACE_BEGIN
|
| 180 |
+
* This macro is used to open a `thrust::` namespace block, along with any
|
| 181 |
+
* enclosing namespaces requested by THRUST_WRAPPED_NAMESPACE, etc.
|
| 182 |
+
* This macro is defined by Thrust and may not be overridden.
|
| 183 |
+
*/
|
| 184 |
+
#define THRUST_NAMESPACE_BEGIN \
|
| 185 |
+
THRUST_NS_PREFIX \
|
| 186 |
+
namespace thrust \
|
| 187 |
+
{ \
|
| 188 |
+
THRUST_DETAIL_ABI_NS_BEGIN
|
| 189 |
+
|
| 190 |
+
/**
|
| 191 |
+
* \def THRUST_NAMESPACE_END
|
| 192 |
+
* This macro is used to close a `thrust::` namespace block, along with any
|
| 193 |
+
* enclosing namespaces requested by THRUST_WRAPPED_NAMESPACE, etc.
|
| 194 |
+
* This macro is defined by Thrust and may not be overridden.
|
| 195 |
+
*/
|
| 196 |
+
#define THRUST_NAMESPACE_END \
|
| 197 |
+
THRUST_DETAIL_ABI_NS_END \
|
| 198 |
+
} /* end namespace thrust */ \
|
| 199 |
+
THRUST_NS_POSTFIX
|
| 200 |
+
|
| 201 |
+
// The following is just here to add docs for the thrust namespace:
|
| 202 |
+
|
| 203 |
+
THRUST_NS_PREFIX
|
| 204 |
+
|
| 205 |
+
/*! \namespace thrust
|
| 206 |
+
* \brief \p thrust is the top-level namespace which contains all Thrust
|
| 207 |
+
* functions and types.
|
| 208 |
+
*/
|
| 209 |
+
namespace thrust
|
| 210 |
+
{
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
THRUST_NS_POSTFIX
|
miniCUDA124/include/thrust/detail/config/simple_defines.h
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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) do { (void)(expr); } while (0)
|
| 38 |
+
|
| 39 |
+
#define THRUST_PREVENT_MACRO_SUBSTITUTION
|
| 40 |
+
|
miniCUDA124/include/thrust/detail/functional/actor.h
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Portions of this code are derived from
|
| 18 |
+
//
|
| 19 |
+
// Manjunath Kudlur's Carbon library
|
| 20 |
+
//
|
| 21 |
+
// and
|
| 22 |
+
//
|
| 23 |
+
// Based on Boost.Phoenix v1.2
|
| 24 |
+
// Copyright (c) 2001-2002 Joel de Guzman
|
| 25 |
+
|
| 26 |
+
#pragma once
|
| 27 |
+
|
| 28 |
+
#include <thrust/detail/config.h>
|
| 29 |
+
|
| 30 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 31 |
+
# pragma GCC system_header
|
| 32 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 33 |
+
# pragma clang system_header
|
| 34 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 35 |
+
# pragma system_header
|
| 36 |
+
#endif // no system header
|
| 37 |
+
#include <thrust/tuple.h>
|
| 38 |
+
#include <thrust/detail/functional/value.h>
|
| 39 |
+
#include <thrust/detail/functional/composite.h>
|
| 40 |
+
#include <thrust/detail/functional/operators/assignment_operator.h>
|
| 41 |
+
#include <thrust/detail/raw_reference_cast.h>
|
| 42 |
+
#include <thrust/detail/type_traits/result_of_adaptable_function.h>
|
| 43 |
+
|
| 44 |
+
THRUST_NAMESPACE_BEGIN
|
| 45 |
+
namespace detail
|
| 46 |
+
{
|
| 47 |
+
namespace functional
|
| 48 |
+
{
|
| 49 |
+
|
| 50 |
+
// eval_ref<T> is
|
| 51 |
+
// - T when T is a subclass of thrust::reference
|
| 52 |
+
// - T& otherwise
|
| 53 |
+
// This is used to let thrust::references pass through actor evaluations.
|
| 54 |
+
template <typename T>
|
| 55 |
+
using eval_ref = typename std::conditional<
|
| 56 |
+
thrust::detail::is_wrapped_reference<T>::value, T, T&>::type;
|
| 57 |
+
|
| 58 |
+
template<typename Action, typename Env>
|
| 59 |
+
struct apply_actor
|
| 60 |
+
{
|
| 61 |
+
typedef typename Action::template result<Env>::type type;
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
template<typename Eval>
|
| 65 |
+
struct actor
|
| 66 |
+
: Eval
|
| 67 |
+
{
|
| 68 |
+
typedef Eval eval_type;
|
| 69 |
+
|
| 70 |
+
__host__ __device__
|
| 71 |
+
constexpr actor();
|
| 72 |
+
|
| 73 |
+
__host__ __device__
|
| 74 |
+
actor(const Eval &base);
|
| 75 |
+
|
| 76 |
+
template <typename... Ts>
|
| 77 |
+
__host__ __device__
|
| 78 |
+
typename apply_actor<eval_type, thrust::tuple<eval_ref<Ts>...>>::type
|
| 79 |
+
operator()(Ts&&... ts) const;
|
| 80 |
+
|
| 81 |
+
template<typename T>
|
| 82 |
+
__host__ __device__
|
| 83 |
+
typename assign_result<Eval,T>::type
|
| 84 |
+
operator=(const T &_1) const;
|
| 85 |
+
}; // end actor
|
| 86 |
+
|
| 87 |
+
// in general, as_actor should turn things into values
|
| 88 |
+
template<typename T>
|
| 89 |
+
struct as_actor
|
| 90 |
+
{
|
| 91 |
+
typedef value<T> type;
|
| 92 |
+
|
| 93 |
+
static inline __host__ __device__ type convert(const T &x)
|
| 94 |
+
{
|
| 95 |
+
return val(x);
|
| 96 |
+
} // end convert()
|
| 97 |
+
}; // end as_actor
|
| 98 |
+
|
| 99 |
+
// specialization for things which are already actors
|
| 100 |
+
template<typename Eval>
|
| 101 |
+
struct as_actor<actor<Eval> >
|
| 102 |
+
{
|
| 103 |
+
typedef actor<Eval> type;
|
| 104 |
+
|
| 105 |
+
static inline __host__ __device__ const type &convert(const actor<Eval> &x)
|
| 106 |
+
{
|
| 107 |
+
return x;
|
| 108 |
+
} // end convert()
|
| 109 |
+
}; // end as_actor
|
| 110 |
+
|
| 111 |
+
template<typename T>
|
| 112 |
+
typename as_actor<T>::type
|
| 113 |
+
__host__ __device__
|
| 114 |
+
make_actor(const T &x)
|
| 115 |
+
{
|
| 116 |
+
return as_actor<T>::convert(x);
|
| 117 |
+
} // end make_actor()
|
| 118 |
+
|
| 119 |
+
} // end functional
|
| 120 |
+
|
| 121 |
+
// provide specializations for result_of for nullary, unary, and binary invocations of actor
|
| 122 |
+
template<typename Eval>
|
| 123 |
+
struct result_of_adaptable_function<
|
| 124 |
+
thrust::detail::functional::actor<Eval>()
|
| 125 |
+
>
|
| 126 |
+
{
|
| 127 |
+
typedef typename thrust::detail::functional::apply_actor<
|
| 128 |
+
thrust::detail::functional::actor<Eval>,
|
| 129 |
+
thrust::tuple<>
|
| 130 |
+
>::type type;
|
| 131 |
+
}; // end result_of
|
| 132 |
+
|
| 133 |
+
template<typename Eval, typename Arg1>
|
| 134 |
+
struct result_of_adaptable_function<
|
| 135 |
+
thrust::detail::functional::actor<Eval>(Arg1)
|
| 136 |
+
>
|
| 137 |
+
{
|
| 138 |
+
typedef typename thrust::detail::functional::apply_actor<
|
| 139 |
+
thrust::detail::functional::actor<Eval>,
|
| 140 |
+
thrust::tuple<Arg1>
|
| 141 |
+
>::type type;
|
| 142 |
+
}; // end result_of
|
| 143 |
+
|
| 144 |
+
template<typename Eval, typename Arg1, typename Arg2>
|
| 145 |
+
struct result_of_adaptable_function<
|
| 146 |
+
thrust::detail::functional::actor<Eval>(Arg1,Arg2)
|
| 147 |
+
>
|
| 148 |
+
{
|
| 149 |
+
typedef typename thrust::detail::functional::apply_actor<
|
| 150 |
+
thrust::detail::functional::actor<Eval>,
|
| 151 |
+
thrust::tuple<Arg1,Arg2>
|
| 152 |
+
>::type type;
|
| 153 |
+
}; // end result_of
|
| 154 |
+
|
| 155 |
+
} // end detail
|
| 156 |
+
THRUST_NAMESPACE_END
|
| 157 |
+
|
| 158 |
+
#include <thrust/detail/functional/actor.inl>
|
| 159 |
+
|
miniCUDA124/include/thrust/detail/functional/actor.inl
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Portions of this code are derived from
|
| 18 |
+
//
|
| 19 |
+
// Manjunath Kudlur's Carbon library
|
| 20 |
+
//
|
| 21 |
+
// and
|
| 22 |
+
//
|
| 23 |
+
// Based on Boost.Phoenix v1.2
|
| 24 |
+
// Copyright (c) 2001-2002 Joel de Guzman
|
| 25 |
+
|
| 26 |
+
#pragma once
|
| 27 |
+
|
| 28 |
+
#include <thrust/detail/config.h>
|
| 29 |
+
|
| 30 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 31 |
+
# pragma GCC system_header
|
| 32 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 33 |
+
# pragma clang system_header
|
| 34 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 35 |
+
# pragma system_header
|
| 36 |
+
#endif // no system header
|
| 37 |
+
#include <thrust/detail/functional/composite.h>
|
| 38 |
+
#include <thrust/detail/functional/operators/assignment_operator.h>
|
| 39 |
+
#include <thrust/functional.h>
|
| 40 |
+
#include <thrust/type_traits/logical_metafunctions.h>
|
| 41 |
+
|
| 42 |
+
#include <type_traits>
|
| 43 |
+
|
| 44 |
+
THRUST_NAMESPACE_BEGIN
|
| 45 |
+
|
| 46 |
+
namespace detail
|
| 47 |
+
{
|
| 48 |
+
namespace functional
|
| 49 |
+
{
|
| 50 |
+
|
| 51 |
+
template<typename Eval>
|
| 52 |
+
__host__ __device__
|
| 53 |
+
constexpr actor<Eval>
|
| 54 |
+
::actor()
|
| 55 |
+
: eval_type()
|
| 56 |
+
{}
|
| 57 |
+
|
| 58 |
+
template<typename Eval>
|
| 59 |
+
__host__ __device__
|
| 60 |
+
actor<Eval>
|
| 61 |
+
::actor(const Eval &base)
|
| 62 |
+
: eval_type(base)
|
| 63 |
+
{}
|
| 64 |
+
|
| 65 |
+
// actor::operator() needs to construct a tuple of references to its
|
| 66 |
+
// arguments. To make this work with thrust::reference<T>, we need to
|
| 67 |
+
// detect thrust proxy references and store them as T rather than T&.
|
| 68 |
+
// This check ensures that the forwarding references passed into
|
| 69 |
+
// actor::operator() are either:
|
| 70 |
+
// - T&& if and only if T is a thrust::reference<U>, or
|
| 71 |
+
// - T& for any other types.
|
| 72 |
+
// This struct provides a nicer diagnostic for when these conditions aren't
|
| 73 |
+
// met.
|
| 74 |
+
template <typename T>
|
| 75 |
+
using actor_check_ref_type =
|
| 76 |
+
::cuda::std::integral_constant<bool,
|
| 77 |
+
( std::is_lvalue_reference<T>::value ||
|
| 78 |
+
thrust::detail::is_wrapped_reference<T>::value )>;
|
| 79 |
+
|
| 80 |
+
template <typename... Ts>
|
| 81 |
+
using actor_check_ref_types =
|
| 82 |
+
thrust::conjunction<actor_check_ref_type<Ts>...>;
|
| 83 |
+
|
| 84 |
+
template<typename Eval>
|
| 85 |
+
template<typename... Ts>
|
| 86 |
+
__host__ __device__
|
| 87 |
+
typename apply_actor<typename actor<Eval>::eval_type,
|
| 88 |
+
thrust::tuple<eval_ref<Ts>...>>::type
|
| 89 |
+
actor<Eval>::operator()(Ts&&... ts) const
|
| 90 |
+
{
|
| 91 |
+
static_assert(actor_check_ref_types<Ts...>::value,
|
| 92 |
+
"Actor evaluations only support rvalue references to "
|
| 93 |
+
"thrust::reference subclasses.");
|
| 94 |
+
using tuple_type = thrust::tuple<eval_ref<Ts>...>;
|
| 95 |
+
return eval_type::eval(tuple_type(THRUST_FWD(ts)...));
|
| 96 |
+
} // end actor<Eval>::operator()
|
| 97 |
+
|
| 98 |
+
template<typename Eval>
|
| 99 |
+
template<typename T>
|
| 100 |
+
__host__ __device__
|
| 101 |
+
typename assign_result<Eval,T>::type
|
| 102 |
+
actor<Eval>
|
| 103 |
+
::operator=(const T& _1) const
|
| 104 |
+
{
|
| 105 |
+
return do_assign(*this,_1);
|
| 106 |
+
} // end actor::operator=()
|
| 107 |
+
|
| 108 |
+
} // end functional
|
| 109 |
+
} // end detail
|
| 110 |
+
THRUST_NAMESPACE_END
|
miniCUDA124/include/thrust/detail/functional/argument.h
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Portions of this code are derived from
|
| 18 |
+
//
|
| 19 |
+
// Manjunath Kudlur's Carbon library
|
| 20 |
+
//
|
| 21 |
+
// and
|
| 22 |
+
//
|
| 23 |
+
// Based on Boost.Phoenix v1.2
|
| 24 |
+
// Copyright (c) 2001-2002 Joel de Guzman
|
| 25 |
+
|
| 26 |
+
#pragma once
|
| 27 |
+
|
| 28 |
+
#include <thrust/detail/config.h>
|
| 29 |
+
|
| 30 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 31 |
+
# pragma GCC system_header
|
| 32 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 33 |
+
# pragma clang system_header
|
| 34 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 35 |
+
# pragma system_header
|
| 36 |
+
#endif // no system header
|
| 37 |
+
#include <thrust/tuple.h>
|
| 38 |
+
|
| 39 |
+
THRUST_NAMESPACE_BEGIN
|
| 40 |
+
namespace detail
|
| 41 |
+
{
|
| 42 |
+
namespace functional
|
| 43 |
+
{
|
| 44 |
+
|
| 45 |
+
template<unsigned int i, typename Env>
|
| 46 |
+
struct argument_helper
|
| 47 |
+
{
|
| 48 |
+
typedef typename thrust::tuple_element<i,Env>::type type;
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
template<unsigned int i>
|
| 52 |
+
struct argument_helper<i,thrust::tuple<>>
|
| 53 |
+
{
|
| 54 |
+
typedef thrust::tuple<> type;
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
template<unsigned int i>
|
| 59 |
+
class argument
|
| 60 |
+
{
|
| 61 |
+
public:
|
| 62 |
+
template<typename Env>
|
| 63 |
+
struct result
|
| 64 |
+
: argument_helper<i,Env>
|
| 65 |
+
{
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
__host__ __device__
|
| 69 |
+
constexpr argument(){}
|
| 70 |
+
|
| 71 |
+
template<typename Env>
|
| 72 |
+
__host__ __device__
|
| 73 |
+
typename result<Env>::type eval(const Env &e) const
|
| 74 |
+
{
|
| 75 |
+
return thrust::get<i>(e);
|
| 76 |
+
} // end eval()
|
| 77 |
+
}; // end argument
|
| 78 |
+
|
| 79 |
+
} // end functional
|
| 80 |
+
} // end detail
|
| 81 |
+
THRUST_NAMESPACE_END
|
| 82 |
+
|
miniCUDA124/include/thrust/detail/functional/composite.h
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Portions of this code are derived from
|
| 18 |
+
//
|
| 19 |
+
// Manjunath Kudlur's Carbon library
|
| 20 |
+
//
|
| 21 |
+
// and
|
| 22 |
+
//
|
| 23 |
+
// Based on Boost.Phoenix v1.2
|
| 24 |
+
// Copyright (c) 2001-2002 Joel de Guzman
|
| 25 |
+
|
| 26 |
+
#pragma once
|
| 27 |
+
|
| 28 |
+
#include <thrust/detail/config.h>
|
| 29 |
+
|
| 30 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 31 |
+
# pragma GCC system_header
|
| 32 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 33 |
+
# pragma clang system_header
|
| 34 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 35 |
+
# pragma system_header
|
| 36 |
+
#endif // no system header
|
| 37 |
+
|
| 38 |
+
#include <thrust/detail/functional/actor.h>
|
| 39 |
+
#include <thrust/tuple.h>
|
| 40 |
+
|
| 41 |
+
THRUST_NAMESPACE_BEGIN
|
| 42 |
+
namespace detail
|
| 43 |
+
{
|
| 44 |
+
namespace functional
|
| 45 |
+
{
|
| 46 |
+
|
| 47 |
+
template <typename... Eval>
|
| 48 |
+
class composite;
|
| 49 |
+
|
| 50 |
+
template<typename Eval0, typename Eval1>
|
| 51 |
+
class composite<Eval0, Eval1>
|
| 52 |
+
{
|
| 53 |
+
public:
|
| 54 |
+
template<typename Env>
|
| 55 |
+
struct result
|
| 56 |
+
{
|
| 57 |
+
typedef typename Eval0::template result<
|
| 58 |
+
thrust::tuple<
|
| 59 |
+
typename Eval1::template result<Env>::type
|
| 60 |
+
>
|
| 61 |
+
>::type type;
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
__host__ __device__
|
| 65 |
+
composite(const Eval0 &e0, const Eval1 &e1)
|
| 66 |
+
: m_eval0(e0),
|
| 67 |
+
m_eval1(e1)
|
| 68 |
+
{}
|
| 69 |
+
|
| 70 |
+
template<typename Env>
|
| 71 |
+
__host__ __device__
|
| 72 |
+
typename result<Env>::type
|
| 73 |
+
eval(const Env &x) const
|
| 74 |
+
{
|
| 75 |
+
typename Eval1::template result<Env>::type result1 = m_eval1.eval(x);
|
| 76 |
+
return m_eval0.eval(thrust::tie(result1));
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
private:
|
| 80 |
+
Eval0 m_eval0;
|
| 81 |
+
Eval1 m_eval1;
|
| 82 |
+
}; // end composite<Eval0,Eval1>
|
| 83 |
+
|
| 84 |
+
template<typename Eval0, typename Eval1, typename Eval2>
|
| 85 |
+
class composite<Eval0, Eval1, Eval2>
|
| 86 |
+
{
|
| 87 |
+
public:
|
| 88 |
+
template<typename Env>
|
| 89 |
+
struct result
|
| 90 |
+
{
|
| 91 |
+
typedef typename Eval0::template result<
|
| 92 |
+
thrust::tuple<
|
| 93 |
+
typename Eval1::template result<Env>::type,
|
| 94 |
+
typename Eval2::template result<Env>::type
|
| 95 |
+
>
|
| 96 |
+
>::type type;
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
__host__ __device__
|
| 100 |
+
composite(const Eval0 &e0, const Eval1 &e1, const Eval2 &e2)
|
| 101 |
+
: m_eval0(e0),
|
| 102 |
+
m_eval1(e1),
|
| 103 |
+
m_eval2(e2)
|
| 104 |
+
{}
|
| 105 |
+
|
| 106 |
+
template<typename Env>
|
| 107 |
+
__host__ __device__
|
| 108 |
+
typename result<Env>::type
|
| 109 |
+
eval(const Env &x) const
|
| 110 |
+
{
|
| 111 |
+
typename Eval1::template result<Env>::type result1 = m_eval1.eval(x);
|
| 112 |
+
typename Eval2::template result<Env>::type result2 = m_eval2.eval(x);
|
| 113 |
+
return m_eval0.eval(thrust::tie(result1,result2));
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
private:
|
| 117 |
+
Eval0 m_eval0;
|
| 118 |
+
Eval1 m_eval1;
|
| 119 |
+
Eval2 m_eval2;
|
| 120 |
+
}; // end composite<Eval0,Eval1,Eval2>
|
| 121 |
+
|
| 122 |
+
template<typename Eval0, typename Eval1>
|
| 123 |
+
__host__ __device__
|
| 124 |
+
actor<composite<Eval0,Eval1> > compose(const Eval0 &e0, const Eval1 &e1)
|
| 125 |
+
{
|
| 126 |
+
return actor<composite<Eval0,Eval1> >(composite<Eval0,Eval1>(e0,e1));
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
template<typename Eval0, typename Eval1, typename Eval2>
|
| 130 |
+
__host__ __device__
|
| 131 |
+
actor<composite<Eval0,Eval1,Eval2> > compose(const Eval0 &e0, const Eval1 &e1, const Eval2 &e2)
|
| 132 |
+
{
|
| 133 |
+
return actor<composite<Eval0,Eval1,Eval2> >(composite<Eval0,Eval1,Eval2>(e0,e1,e2));
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
} // end functional
|
| 137 |
+
} // end detail
|
| 138 |
+
THRUST_NAMESPACE_END
|
| 139 |
+
|
miniCUDA124/include/thrust/detail/functional/operators.h
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/functional/operators/arithmetic_operators.h>
|
| 29 |
+
#include <thrust/detail/functional/operators/relational_operators.h>
|
| 30 |
+
#include <thrust/detail/functional/operators/logical_operators.h>
|
| 31 |
+
#include <thrust/detail/functional/operators/bitwise_operators.h>
|
| 32 |
+
#include <thrust/detail/functional/operators/compound_assignment_operators.h>
|
| 33 |
+
|
miniCUDA124/include/thrust/detail/functional/operators/arithmetic_operators.h
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/functional/actor.h>
|
| 29 |
+
#include <thrust/detail/functional/composite.h>
|
| 30 |
+
#include <thrust/detail/functional/operators/operator_adaptors.h>
|
| 31 |
+
#include <thrust/functional.h>
|
| 32 |
+
|
| 33 |
+
THRUST_NAMESPACE_BEGIN
|
| 34 |
+
namespace detail
|
| 35 |
+
{
|
| 36 |
+
namespace functional
|
| 37 |
+
{
|
| 38 |
+
|
| 39 |
+
template<typename Eval>
|
| 40 |
+
__host__ __device__
|
| 41 |
+
actor<
|
| 42 |
+
composite<
|
| 43 |
+
transparent_unary_operator<thrust::negate<>>,
|
| 44 |
+
actor<Eval>
|
| 45 |
+
>
|
| 46 |
+
>
|
| 47 |
+
__host__ __device__
|
| 48 |
+
operator-(const actor<Eval> &_1)
|
| 49 |
+
{
|
| 50 |
+
return compose(transparent_unary_operator<thrust::negate<>>(), _1);
|
| 51 |
+
} // end operator-()
|
| 52 |
+
|
| 53 |
+
// there's no standard unary_plus functional, so roll an ad hoc one here
|
| 54 |
+
struct unary_plus
|
| 55 |
+
{
|
| 56 |
+
using is_transparent = void;
|
| 57 |
+
|
| 58 |
+
__thrust_exec_check_disable__
|
| 59 |
+
template <typename T1>
|
| 60 |
+
__host__ __device__
|
| 61 |
+
constexpr auto operator()(T1&& t1) const
|
| 62 |
+
noexcept(noexcept(+THRUST_FWD(t1)))
|
| 63 |
+
THRUST_TRAILING_RETURN(decltype(+THRUST_FWD(t1)))
|
| 64 |
+
{
|
| 65 |
+
return +THRUST_FWD(t1);
|
| 66 |
+
}
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
template<typename Eval>
|
| 70 |
+
__host__ __device__
|
| 71 |
+
actor<
|
| 72 |
+
composite<
|
| 73 |
+
transparent_unary_operator<unary_plus>,
|
| 74 |
+
actor<Eval>
|
| 75 |
+
>
|
| 76 |
+
>
|
| 77 |
+
operator+(const actor<Eval> &_1)
|
| 78 |
+
{
|
| 79 |
+
return compose(transparent_unary_operator<unary_plus>(), _1);
|
| 80 |
+
} // end operator+()
|
| 81 |
+
|
| 82 |
+
template<typename T1, typename T2>
|
| 83 |
+
__host__ __device__
|
| 84 |
+
actor<
|
| 85 |
+
composite<
|
| 86 |
+
transparent_binary_operator<thrust::plus<>>,
|
| 87 |
+
actor<T1>,
|
| 88 |
+
typename as_actor<T2>::type
|
| 89 |
+
>
|
| 90 |
+
>
|
| 91 |
+
operator+(const actor<T1> &_1, const T2 &_2)
|
| 92 |
+
{
|
| 93 |
+
return compose(transparent_binary_operator<thrust::plus<>>(),
|
| 94 |
+
make_actor(_1),
|
| 95 |
+
make_actor(_2));
|
| 96 |
+
} // end operator+()
|
| 97 |
+
|
| 98 |
+
template<typename T1, typename T2>
|
| 99 |
+
__host__ __device__
|
| 100 |
+
actor<
|
| 101 |
+
composite<
|
| 102 |
+
transparent_binary_operator<thrust::plus<>>,
|
| 103 |
+
typename as_actor<T1>::type,
|
| 104 |
+
actor<T2>
|
| 105 |
+
>
|
| 106 |
+
>
|
| 107 |
+
operator+(const T1 &_1, const actor<T2> &_2)
|
| 108 |
+
{
|
| 109 |
+
return compose(transparent_binary_operator<thrust::plus<>>(),
|
| 110 |
+
make_actor(_1),
|
| 111 |
+
make_actor(_2));
|
| 112 |
+
} // end operator+()
|
| 113 |
+
|
| 114 |
+
template<typename T1, typename T2>
|
| 115 |
+
__host__ __device__
|
| 116 |
+
actor<
|
| 117 |
+
composite<
|
| 118 |
+
transparent_binary_operator<thrust::plus<>>,
|
| 119 |
+
actor<T1>,
|
| 120 |
+
actor<T2>
|
| 121 |
+
>
|
| 122 |
+
>
|
| 123 |
+
operator+(const actor<T1> &_1, const actor<T2> &_2)
|
| 124 |
+
{
|
| 125 |
+
return compose(transparent_binary_operator<thrust::plus<>>(),
|
| 126 |
+
make_actor(_1),
|
| 127 |
+
make_actor(_2));
|
| 128 |
+
} // end operator+()
|
| 129 |
+
|
| 130 |
+
template<typename T1, typename T2>
|
| 131 |
+
__host__ __device__
|
| 132 |
+
actor<
|
| 133 |
+
composite<
|
| 134 |
+
transparent_binary_operator<thrust::minus<>>,
|
| 135 |
+
typename as_actor<T1>::type,
|
| 136 |
+
actor<T2>
|
| 137 |
+
>
|
| 138 |
+
>
|
| 139 |
+
operator-(const T1 &_1, const actor<T2> &_2)
|
| 140 |
+
{
|
| 141 |
+
return compose(transparent_binary_operator<thrust::minus<>>(),
|
| 142 |
+
make_actor(_1),
|
| 143 |
+
make_actor(_2));
|
| 144 |
+
} // end operator-()
|
| 145 |
+
|
| 146 |
+
template<typename T1, typename T2>
|
| 147 |
+
__host__ __device__
|
| 148 |
+
actor<
|
| 149 |
+
composite<
|
| 150 |
+
transparent_binary_operator<thrust::minus<>>,
|
| 151 |
+
actor<T1>,
|
| 152 |
+
typename as_actor<T2>::type
|
| 153 |
+
>
|
| 154 |
+
>
|
| 155 |
+
operator-(const actor<T1> &_1, const T2 &_2)
|
| 156 |
+
{
|
| 157 |
+
return compose(transparent_binary_operator<thrust::minus<>>(),
|
| 158 |
+
make_actor(_1),
|
| 159 |
+
make_actor(_2));
|
| 160 |
+
} // end operator-()
|
| 161 |
+
|
| 162 |
+
template<typename T1, typename T2>
|
| 163 |
+
__host__ __device__
|
| 164 |
+
actor<
|
| 165 |
+
composite<
|
| 166 |
+
transparent_binary_operator<thrust::minus<>>,
|
| 167 |
+
actor<T1>,
|
| 168 |
+
actor<T2>
|
| 169 |
+
>
|
| 170 |
+
>
|
| 171 |
+
operator-(const actor<T1> &_1, const actor<T2> &_2)
|
| 172 |
+
{
|
| 173 |
+
return compose(transparent_binary_operator<thrust::minus<>>(),
|
| 174 |
+
make_actor(_1),
|
| 175 |
+
make_actor(_2));
|
| 176 |
+
} // end operator-()
|
| 177 |
+
|
| 178 |
+
template<typename T1, typename T2>
|
| 179 |
+
__host__ __device__
|
| 180 |
+
actor<
|
| 181 |
+
composite<
|
| 182 |
+
transparent_binary_operator<thrust::multiplies<>>,
|
| 183 |
+
typename as_actor<T1>::type,
|
| 184 |
+
actor<T2>
|
| 185 |
+
>
|
| 186 |
+
>
|
| 187 |
+
operator*(const T1 &_1, const actor<T2> &_2)
|
| 188 |
+
{
|
| 189 |
+
return compose(transparent_binary_operator<thrust::multiplies<>>(),
|
| 190 |
+
make_actor(_1),
|
| 191 |
+
make_actor(_2));
|
| 192 |
+
} // end operator*()
|
| 193 |
+
|
| 194 |
+
template<typename T1, typename T2>
|
| 195 |
+
__host__ __device__
|
| 196 |
+
actor<
|
| 197 |
+
composite<
|
| 198 |
+
transparent_binary_operator<thrust::multiplies<>>,
|
| 199 |
+
actor<T1>,
|
| 200 |
+
typename as_actor<T2>::type
|
| 201 |
+
>
|
| 202 |
+
>
|
| 203 |
+
operator*(const actor<T1> &_1, const T2 &_2)
|
| 204 |
+
{
|
| 205 |
+
return compose(transparent_binary_operator<thrust::multiplies<>>(),
|
| 206 |
+
make_actor(_1),
|
| 207 |
+
make_actor(_2));
|
| 208 |
+
} // end operator*()
|
| 209 |
+
|
| 210 |
+
template<typename T1, typename T2>
|
| 211 |
+
__host__ __device__
|
| 212 |
+
actor<
|
| 213 |
+
composite<
|
| 214 |
+
transparent_binary_operator<thrust::multiplies<>>,
|
| 215 |
+
actor<T1>,
|
| 216 |
+
actor<T2>
|
| 217 |
+
>
|
| 218 |
+
>
|
| 219 |
+
operator*(const actor<T1> &_1, const actor<T2> &_2)
|
| 220 |
+
{
|
| 221 |
+
return compose(transparent_binary_operator<thrust::multiplies<>>(),
|
| 222 |
+
make_actor(_1),
|
| 223 |
+
make_actor(_2));
|
| 224 |
+
} // end operator*()
|
| 225 |
+
|
| 226 |
+
template<typename T1, typename T2>
|
| 227 |
+
__host__ __device__
|
| 228 |
+
actor<
|
| 229 |
+
composite<
|
| 230 |
+
transparent_binary_operator<thrust::divides<>>,
|
| 231 |
+
actor<T1>,
|
| 232 |
+
typename as_actor<T2>::type
|
| 233 |
+
>
|
| 234 |
+
>
|
| 235 |
+
operator/(const actor<T1> &_1, const T2 &_2)
|
| 236 |
+
{
|
| 237 |
+
return compose(transparent_binary_operator<thrust::divides<>>(),
|
| 238 |
+
make_actor(_1),
|
| 239 |
+
make_actor(_2));
|
| 240 |
+
} // end operator/()
|
| 241 |
+
|
| 242 |
+
template<typename T1, typename T2>
|
| 243 |
+
__host__ __device__
|
| 244 |
+
actor<
|
| 245 |
+
composite<
|
| 246 |
+
transparent_binary_operator<thrust::divides<>>,
|
| 247 |
+
typename as_actor<T1>::type,
|
| 248 |
+
actor<T2>
|
| 249 |
+
>
|
| 250 |
+
>
|
| 251 |
+
operator/(const T1 &_1, const actor<T2> &_2)
|
| 252 |
+
{
|
| 253 |
+
return compose(transparent_binary_operator<thrust::divides<>>(),
|
| 254 |
+
make_actor(_1),
|
| 255 |
+
make_actor(_2));
|
| 256 |
+
} // end operator/()
|
| 257 |
+
|
| 258 |
+
template<typename T1, typename T2>
|
| 259 |
+
__host__ __device__
|
| 260 |
+
actor<
|
| 261 |
+
composite<
|
| 262 |
+
transparent_binary_operator<thrust::divides<>>,
|
| 263 |
+
actor<T1>,
|
| 264 |
+
actor<T2>
|
| 265 |
+
>
|
| 266 |
+
>
|
| 267 |
+
operator/(const actor<T1> &_1, const actor<T2> &_2)
|
| 268 |
+
{
|
| 269 |
+
return compose(transparent_binary_operator<thrust::divides<>>(),
|
| 270 |
+
make_actor(_1),
|
| 271 |
+
make_actor(_2));
|
| 272 |
+
} // end operator/()
|
| 273 |
+
|
| 274 |
+
template<typename T1, typename T2>
|
| 275 |
+
__host__ __device__
|
| 276 |
+
actor<
|
| 277 |
+
composite<
|
| 278 |
+
transparent_binary_operator<thrust::modulus<>>,
|
| 279 |
+
actor<T1>,
|
| 280 |
+
typename as_actor<T2>::type
|
| 281 |
+
>
|
| 282 |
+
>
|
| 283 |
+
operator%(const actor<T1> &_1, const T2 &_2)
|
| 284 |
+
{
|
| 285 |
+
return compose(transparent_binary_operator<thrust::modulus<>>(),
|
| 286 |
+
make_actor(_1),
|
| 287 |
+
make_actor(_2));
|
| 288 |
+
} // end operator%()
|
| 289 |
+
|
| 290 |
+
template<typename T1, typename T2>
|
| 291 |
+
__host__ __device__
|
| 292 |
+
actor<
|
| 293 |
+
composite<
|
| 294 |
+
transparent_binary_operator<thrust::modulus<>>,
|
| 295 |
+
typename as_actor<T1>::type,
|
| 296 |
+
actor<T2>
|
| 297 |
+
>
|
| 298 |
+
>
|
| 299 |
+
operator%(const T1 &_1, const actor<T2> &_2)
|
| 300 |
+
{
|
| 301 |
+
return compose(transparent_binary_operator<thrust::modulus<void>>(),
|
| 302 |
+
make_actor(_1),
|
| 303 |
+
make_actor(_2));
|
| 304 |
+
} // end operator%()
|
| 305 |
+
|
| 306 |
+
template<typename T1, typename T2>
|
| 307 |
+
__host__ __device__
|
| 308 |
+
actor<
|
| 309 |
+
composite<
|
| 310 |
+
transparent_binary_operator<thrust::modulus<>>,
|
| 311 |
+
actor<T1>,
|
| 312 |
+
actor<T2>
|
| 313 |
+
>
|
| 314 |
+
>
|
| 315 |
+
operator%(const actor<T1> &_1, const actor<T2> &_2)
|
| 316 |
+
{
|
| 317 |
+
return compose(transparent_binary_operator<thrust::modulus<>>(),
|
| 318 |
+
make_actor(_1),
|
| 319 |
+
make_actor(_2));
|
| 320 |
+
} // end operator%()
|
| 321 |
+
|
| 322 |
+
// there's no standard prefix_increment functional, so roll an ad hoc one here
|
| 323 |
+
struct prefix_increment
|
| 324 |
+
{
|
| 325 |
+
using is_transparent = void;
|
| 326 |
+
|
| 327 |
+
__thrust_exec_check_disable__
|
| 328 |
+
template <typename T1>
|
| 329 |
+
__host__ __device__
|
| 330 |
+
constexpr auto operator()(T1&& t1) const
|
| 331 |
+
noexcept(noexcept(++THRUST_FWD(t1)))
|
| 332 |
+
THRUST_TRAILING_RETURN(decltype(++THRUST_FWD(t1)))
|
| 333 |
+
{
|
| 334 |
+
return ++THRUST_FWD(t1);
|
| 335 |
+
}
|
| 336 |
+
}; // end prefix_increment
|
| 337 |
+
|
| 338 |
+
template<typename Eval>
|
| 339 |
+
__host__ __device__
|
| 340 |
+
actor<
|
| 341 |
+
composite<
|
| 342 |
+
transparent_unary_operator<prefix_increment>,
|
| 343 |
+
actor<Eval>
|
| 344 |
+
>
|
| 345 |
+
>
|
| 346 |
+
operator++(const actor<Eval> &_1)
|
| 347 |
+
{
|
| 348 |
+
return compose(transparent_unary_operator<prefix_increment>(), _1);
|
| 349 |
+
} // end operator++()
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
// there's no standard postfix_increment functional, so roll an ad hoc one here
|
| 353 |
+
struct postfix_increment
|
| 354 |
+
{
|
| 355 |
+
using is_transparent = void;
|
| 356 |
+
|
| 357 |
+
__thrust_exec_check_disable__
|
| 358 |
+
template <typename T1>
|
| 359 |
+
__host__ __device__
|
| 360 |
+
constexpr auto operator()(T1&& t1) const
|
| 361 |
+
noexcept(noexcept(THRUST_FWD(t1)++))
|
| 362 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1)++))
|
| 363 |
+
{
|
| 364 |
+
return THRUST_FWD(t1)++;
|
| 365 |
+
}
|
| 366 |
+
}; // end postfix_increment
|
| 367 |
+
|
| 368 |
+
template<typename Eval>
|
| 369 |
+
__host__ __device__
|
| 370 |
+
actor<
|
| 371 |
+
composite<
|
| 372 |
+
transparent_unary_operator<postfix_increment>,
|
| 373 |
+
actor<Eval>
|
| 374 |
+
>
|
| 375 |
+
>
|
| 376 |
+
operator++(const actor<Eval> &_1, int)
|
| 377 |
+
{
|
| 378 |
+
return compose(transparent_unary_operator<postfix_increment>(), _1);
|
| 379 |
+
} // end operator++()
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
// there's no standard prefix_decrement functional, so roll an ad hoc one here
|
| 383 |
+
struct prefix_decrement
|
| 384 |
+
{
|
| 385 |
+
using is_transparent = void;
|
| 386 |
+
|
| 387 |
+
__thrust_exec_check_disable__
|
| 388 |
+
template <typename T1>
|
| 389 |
+
__host__ __device__
|
| 390 |
+
constexpr auto operator()(T1&& t1) const
|
| 391 |
+
noexcept(noexcept(--THRUST_FWD(t1)))
|
| 392 |
+
THRUST_TRAILING_RETURN(decltype(--THRUST_FWD(t1)))
|
| 393 |
+
{
|
| 394 |
+
return --THRUST_FWD(t1);
|
| 395 |
+
}
|
| 396 |
+
}; // end prefix_decrement
|
| 397 |
+
|
| 398 |
+
template<typename Eval>
|
| 399 |
+
__host__ __device__
|
| 400 |
+
actor<
|
| 401 |
+
composite<
|
| 402 |
+
transparent_unary_operator<prefix_decrement>,
|
| 403 |
+
actor<Eval>
|
| 404 |
+
>
|
| 405 |
+
>
|
| 406 |
+
operator--(const actor<Eval> &_1)
|
| 407 |
+
{
|
| 408 |
+
return compose(transparent_unary_operator<prefix_decrement>(), _1);
|
| 409 |
+
} // end operator--()
|
| 410 |
+
|
| 411 |
+
|
| 412 |
+
// there's no standard postfix_decrement functional, so roll an ad hoc one here
|
| 413 |
+
struct postfix_decrement
|
| 414 |
+
{
|
| 415 |
+
using is_transparent = void;
|
| 416 |
+
|
| 417 |
+
__thrust_exec_check_disable__
|
| 418 |
+
template <typename T1>
|
| 419 |
+
__host__ __device__
|
| 420 |
+
constexpr auto operator()(T1&& t1) const
|
| 421 |
+
noexcept(noexcept(THRUST_FWD(t1)--))
|
| 422 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1)--))
|
| 423 |
+
{
|
| 424 |
+
return THRUST_FWD(t1)--;
|
| 425 |
+
}
|
| 426 |
+
}; // end prefix_increment
|
| 427 |
+
|
| 428 |
+
template<typename Eval>
|
| 429 |
+
__host__ __device__
|
| 430 |
+
actor<
|
| 431 |
+
composite<
|
| 432 |
+
transparent_unary_operator<postfix_decrement>,
|
| 433 |
+
actor<Eval>
|
| 434 |
+
>
|
| 435 |
+
>
|
| 436 |
+
operator--(const actor<Eval> &_1, int)
|
| 437 |
+
{
|
| 438 |
+
return compose(transparent_unary_operator<postfix_decrement>(), _1);
|
| 439 |
+
} // end operator--()
|
| 440 |
+
|
| 441 |
+
} // end functional
|
| 442 |
+
} // end detail
|
| 443 |
+
THRUST_NAMESPACE_END
|
| 444 |
+
|
miniCUDA124/include/thrust/detail/functional/operators/assignment_operator.h
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/functional/actor.h>
|
| 29 |
+
#include <thrust/detail/functional/composite.h>
|
| 30 |
+
#include <thrust/detail/functional/operators/operator_adaptors.h>
|
| 31 |
+
#include <thrust/functional.h>
|
| 32 |
+
|
| 33 |
+
THRUST_NAMESPACE_BEGIN
|
| 34 |
+
|
| 35 |
+
// XXX WAR circular inclusion with this forward declaration
|
| 36 |
+
template<typename,typename,typename> struct binary_function;
|
| 37 |
+
|
| 38 |
+
namespace detail
|
| 39 |
+
{
|
| 40 |
+
namespace functional
|
| 41 |
+
{
|
| 42 |
+
|
| 43 |
+
// XXX WAR circular inclusion with this forward declaration
|
| 44 |
+
template<typename> struct as_actor;
|
| 45 |
+
|
| 46 |
+
// there's no standard assign functional, so roll an ad hoc one here
|
| 47 |
+
struct assign
|
| 48 |
+
{
|
| 49 |
+
using is_transparent = void;
|
| 50 |
+
|
| 51 |
+
__thrust_exec_check_disable__
|
| 52 |
+
template <typename T1, typename T2>
|
| 53 |
+
__host__ __device__
|
| 54 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 55 |
+
noexcept(noexcept(THRUST_FWD(t1) = THRUST_FWD(t2)))
|
| 56 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) = THRUST_FWD(t2)))
|
| 57 |
+
{
|
| 58 |
+
return THRUST_FWD(t1) = THRUST_FWD(t2);
|
| 59 |
+
}
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
template<typename Eval, typename T>
|
| 63 |
+
struct assign_result
|
| 64 |
+
{
|
| 65 |
+
typedef actor<
|
| 66 |
+
composite<
|
| 67 |
+
transparent_binary_operator<assign>,
|
| 68 |
+
actor<Eval>,
|
| 69 |
+
typename as_actor<T>::type
|
| 70 |
+
>
|
| 71 |
+
> type;
|
| 72 |
+
}; // end assign_result
|
| 73 |
+
|
| 74 |
+
template<typename Eval, typename T>
|
| 75 |
+
__host__ __device__
|
| 76 |
+
typename assign_result<Eval,T>::type
|
| 77 |
+
do_assign(const actor<Eval> &_1, const T &_2)
|
| 78 |
+
{
|
| 79 |
+
return compose(transparent_binary_operator<assign>(),
|
| 80 |
+
_1,
|
| 81 |
+
as_actor<T>::convert(_2));
|
| 82 |
+
} // end do_assign()
|
| 83 |
+
|
| 84 |
+
} // end functional
|
| 85 |
+
} // end detail
|
| 86 |
+
THRUST_NAMESPACE_END
|
| 87 |
+
|
miniCUDA124/include/thrust/detail/functional/operators/bitwise_operators.h
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/functional/actor.h>
|
| 29 |
+
#include <thrust/detail/functional/composite.h>
|
| 30 |
+
#include <thrust/detail/functional/operators/operator_adaptors.h>
|
| 31 |
+
#include <thrust/functional.h>
|
| 32 |
+
|
| 33 |
+
THRUST_NAMESPACE_BEGIN
|
| 34 |
+
namespace detail
|
| 35 |
+
{
|
| 36 |
+
namespace functional
|
| 37 |
+
{
|
| 38 |
+
|
| 39 |
+
template<typename T1, typename T2>
|
| 40 |
+
__host__ __device__
|
| 41 |
+
actor<
|
| 42 |
+
composite<
|
| 43 |
+
transparent_binary_operator<bit_and<>>,
|
| 44 |
+
actor<T1>,
|
| 45 |
+
typename as_actor<T2>::type
|
| 46 |
+
>
|
| 47 |
+
>
|
| 48 |
+
operator&(const actor<T1> &_1, const T2 &_2)
|
| 49 |
+
{
|
| 50 |
+
return compose(transparent_binary_operator<bit_and<>>(),
|
| 51 |
+
make_actor(_1),
|
| 52 |
+
make_actor(_2));
|
| 53 |
+
} // end operator&()
|
| 54 |
+
|
| 55 |
+
template<typename T1, typename T2>
|
| 56 |
+
__host__ __device__
|
| 57 |
+
actor<
|
| 58 |
+
composite<
|
| 59 |
+
transparent_binary_operator<bit_and<>>,
|
| 60 |
+
typename as_actor<T1>::type,
|
| 61 |
+
actor<T2>
|
| 62 |
+
>
|
| 63 |
+
>
|
| 64 |
+
operator&(const T1 &_1, const actor<T2> &_2)
|
| 65 |
+
{
|
| 66 |
+
return compose(transparent_binary_operator<bit_and<>>(),
|
| 67 |
+
make_actor(_1),
|
| 68 |
+
make_actor(_2));
|
| 69 |
+
} // end operator&()
|
| 70 |
+
|
| 71 |
+
template<typename T1, typename T2>
|
| 72 |
+
__host__ __device__
|
| 73 |
+
actor<
|
| 74 |
+
composite<
|
| 75 |
+
transparent_binary_operator<bit_and<>>,
|
| 76 |
+
actor<T1>,
|
| 77 |
+
actor<T2>
|
| 78 |
+
>
|
| 79 |
+
>
|
| 80 |
+
operator&(const actor<T1> &_1, const actor<T2> &_2)
|
| 81 |
+
{
|
| 82 |
+
return compose(transparent_binary_operator<bit_and<>>(),
|
| 83 |
+
make_actor(_1),
|
| 84 |
+
make_actor(_2));
|
| 85 |
+
} // end operator&()
|
| 86 |
+
|
| 87 |
+
template<typename T1, typename T2>
|
| 88 |
+
__host__ __device__
|
| 89 |
+
actor<
|
| 90 |
+
composite<
|
| 91 |
+
transparent_binary_operator<bit_or<>>,
|
| 92 |
+
actor<T1>,
|
| 93 |
+
typename as_actor<T2>::type
|
| 94 |
+
>
|
| 95 |
+
>
|
| 96 |
+
operator|(const actor<T1> &_1, const T2 &_2)
|
| 97 |
+
{
|
| 98 |
+
return compose(transparent_binary_operator<bit_or<>>(),
|
| 99 |
+
make_actor(_1),
|
| 100 |
+
make_actor(_2));
|
| 101 |
+
} // end operator|()
|
| 102 |
+
|
| 103 |
+
template<typename T1, typename T2>
|
| 104 |
+
__host__ __device__
|
| 105 |
+
actor<
|
| 106 |
+
composite<
|
| 107 |
+
transparent_binary_operator<bit_or<>>,
|
| 108 |
+
typename as_actor<T1>::type,
|
| 109 |
+
actor<T2>
|
| 110 |
+
>
|
| 111 |
+
>
|
| 112 |
+
operator|(const T1 &_1, const actor<T2> &_2)
|
| 113 |
+
{
|
| 114 |
+
return compose(transparent_binary_operator<bit_or<>>(),
|
| 115 |
+
make_actor(_1),
|
| 116 |
+
make_actor(_2));
|
| 117 |
+
} // end operator|()
|
| 118 |
+
|
| 119 |
+
template<typename T1, typename T2>
|
| 120 |
+
__host__ __device__
|
| 121 |
+
actor<
|
| 122 |
+
composite<
|
| 123 |
+
transparent_binary_operator<bit_or<>>,
|
| 124 |
+
actor<T1>,
|
| 125 |
+
actor<T2>
|
| 126 |
+
>
|
| 127 |
+
>
|
| 128 |
+
operator|(const actor<T1> &_1, const actor<T2> &_2)
|
| 129 |
+
{
|
| 130 |
+
return compose(transparent_binary_operator<bit_or<>>(),
|
| 131 |
+
make_actor(_1),
|
| 132 |
+
make_actor(_2));
|
| 133 |
+
} // end operator|()
|
| 134 |
+
|
| 135 |
+
template<typename T1, typename T2>
|
| 136 |
+
__host__ __device__
|
| 137 |
+
actor<
|
| 138 |
+
composite<
|
| 139 |
+
transparent_binary_operator<bit_xor<>>,
|
| 140 |
+
actor<T1>,
|
| 141 |
+
typename as_actor<T2>::type
|
| 142 |
+
>
|
| 143 |
+
>
|
| 144 |
+
operator^(const actor<T1> &_1, const T2 &_2)
|
| 145 |
+
{
|
| 146 |
+
return compose(transparent_binary_operator<bit_xor<>>(),
|
| 147 |
+
make_actor(_1),
|
| 148 |
+
make_actor(_2));
|
| 149 |
+
} // end operator^()
|
| 150 |
+
|
| 151 |
+
template<typename T1, typename T2>
|
| 152 |
+
__host__ __device__
|
| 153 |
+
actor<
|
| 154 |
+
composite<
|
| 155 |
+
transparent_binary_operator<bit_xor<>>,
|
| 156 |
+
typename as_actor<T1>::type,
|
| 157 |
+
actor<T2>
|
| 158 |
+
>
|
| 159 |
+
>
|
| 160 |
+
operator^(const T1 &_1, const actor<T2> &_2)
|
| 161 |
+
{
|
| 162 |
+
return compose(transparent_binary_operator<bit_xor<>>(),
|
| 163 |
+
make_actor(_1),
|
| 164 |
+
make_actor(_2));
|
| 165 |
+
} // end operator^()
|
| 166 |
+
|
| 167 |
+
template<typename T1, typename T2>
|
| 168 |
+
__host__ __device__
|
| 169 |
+
actor<
|
| 170 |
+
composite<
|
| 171 |
+
transparent_binary_operator<bit_xor<>>,
|
| 172 |
+
actor<T1>,
|
| 173 |
+
actor<T2>
|
| 174 |
+
>
|
| 175 |
+
>
|
| 176 |
+
operator^(const actor<T1> &_1, const actor<T2> &_2)
|
| 177 |
+
{
|
| 178 |
+
return compose(transparent_binary_operator<bit_xor<>>(),
|
| 179 |
+
make_actor(_1),
|
| 180 |
+
make_actor(_2));
|
| 181 |
+
} // end operator^()
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
// there's no standard bit_not functional, so roll an ad hoc one here
|
| 185 |
+
struct bit_not
|
| 186 |
+
{
|
| 187 |
+
using is_transparent = void;
|
| 188 |
+
|
| 189 |
+
__thrust_exec_check_disable__
|
| 190 |
+
template <typename T1>
|
| 191 |
+
__host__ __device__
|
| 192 |
+
constexpr auto operator()(T1&& t1) const
|
| 193 |
+
noexcept(noexcept(~THRUST_FWD(t1)))
|
| 194 |
+
THRUST_TRAILING_RETURN(decltype(~THRUST_FWD(t1)))
|
| 195 |
+
{
|
| 196 |
+
return ~THRUST_FWD(t1);
|
| 197 |
+
}
|
| 198 |
+
}; // end prefix_increment
|
| 199 |
+
|
| 200 |
+
template<typename Eval>
|
| 201 |
+
__host__ __device__
|
| 202 |
+
actor<
|
| 203 |
+
composite<
|
| 204 |
+
transparent_unary_operator<bit_not>,
|
| 205 |
+
actor<Eval>
|
| 206 |
+
>
|
| 207 |
+
>
|
| 208 |
+
__host__ __device__
|
| 209 |
+
operator~(const actor<Eval> &_1)
|
| 210 |
+
{
|
| 211 |
+
return compose(transparent_unary_operator<bit_not>(), _1);
|
| 212 |
+
} // end operator~()
|
| 213 |
+
|
| 214 |
+
// there's no standard bit_lshift functional, so roll an ad hoc one here
|
| 215 |
+
struct bit_lshift
|
| 216 |
+
{
|
| 217 |
+
using is_transparent = void;
|
| 218 |
+
|
| 219 |
+
__thrust_exec_check_disable__
|
| 220 |
+
template <typename T1, typename T2>
|
| 221 |
+
__host__ __device__
|
| 222 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 223 |
+
noexcept(noexcept(THRUST_FWD(t1) << THRUST_FWD(t2)))
|
| 224 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) << THRUST_FWD(t2)))
|
| 225 |
+
{
|
| 226 |
+
return THRUST_FWD(t1) << THRUST_FWD(t2);
|
| 227 |
+
}
|
| 228 |
+
};
|
| 229 |
+
|
| 230 |
+
template<typename T1, typename T2>
|
| 231 |
+
__host__ __device__
|
| 232 |
+
actor<
|
| 233 |
+
composite<
|
| 234 |
+
transparent_binary_operator<bit_lshift>,
|
| 235 |
+
actor<T1>,
|
| 236 |
+
typename as_actor<T2>::type
|
| 237 |
+
>
|
| 238 |
+
>
|
| 239 |
+
operator<<(const actor<T1> &_1, const T2 &_2)
|
| 240 |
+
{
|
| 241 |
+
return compose(transparent_binary_operator<bit_lshift>(),
|
| 242 |
+
make_actor(_1),
|
| 243 |
+
make_actor(_2));
|
| 244 |
+
} // end operator<<()
|
| 245 |
+
|
| 246 |
+
template<typename T1, typename T2>
|
| 247 |
+
__host__ __device__
|
| 248 |
+
actor<
|
| 249 |
+
composite<
|
| 250 |
+
transparent_binary_operator<bit_lshift>,
|
| 251 |
+
typename as_actor<T1>::type,
|
| 252 |
+
actor<T2>
|
| 253 |
+
>
|
| 254 |
+
>
|
| 255 |
+
operator<<(const T1 &_1, const actor<T2> &_2)
|
| 256 |
+
{
|
| 257 |
+
return compose(transparent_binary_operator<bit_lshift>(),
|
| 258 |
+
make_actor(_1),
|
| 259 |
+
make_actor(_2));
|
| 260 |
+
} // end operator<<()
|
| 261 |
+
|
| 262 |
+
template<typename T1, typename T2>
|
| 263 |
+
__host__ __device__
|
| 264 |
+
actor<
|
| 265 |
+
composite<
|
| 266 |
+
transparent_binary_operator<bit_lshift>,
|
| 267 |
+
actor<T1>,
|
| 268 |
+
actor<T2>
|
| 269 |
+
>
|
| 270 |
+
>
|
| 271 |
+
operator<<(const actor<T1> &_1, const actor<T2> &_2)
|
| 272 |
+
{
|
| 273 |
+
return compose(transparent_binary_operator<bit_lshift>(),
|
| 274 |
+
make_actor(_1),
|
| 275 |
+
make_actor(_2));
|
| 276 |
+
} // end operator<<()
|
| 277 |
+
|
| 278 |
+
// there's no standard bit_rshift functional, so roll an ad hoc one here
|
| 279 |
+
struct bit_rshift
|
| 280 |
+
{
|
| 281 |
+
using is_transparent = void;
|
| 282 |
+
|
| 283 |
+
__thrust_exec_check_disable__
|
| 284 |
+
template <typename T1, typename T2>
|
| 285 |
+
__host__ __device__
|
| 286 |
+
constexpr auto operator()(T1& t1, T2&& t2) const
|
| 287 |
+
noexcept(noexcept(THRUST_FWD(t1) >> THRUST_FWD(t2)))
|
| 288 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) >> THRUST_FWD(t2)))
|
| 289 |
+
{
|
| 290 |
+
return THRUST_FWD(t1) >> THRUST_FWD(t2);
|
| 291 |
+
}
|
| 292 |
+
};
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
template<typename T1, typename T2>
|
| 296 |
+
__host__ __device__
|
| 297 |
+
actor<
|
| 298 |
+
composite<
|
| 299 |
+
transparent_binary_operator<bit_rshift>,
|
| 300 |
+
actor<T1>,
|
| 301 |
+
typename as_actor<T2>::type
|
| 302 |
+
>
|
| 303 |
+
>
|
| 304 |
+
operator>>(const actor<T1> &_1, const T2 &_2)
|
| 305 |
+
{
|
| 306 |
+
return compose(transparent_binary_operator<bit_rshift>(),
|
| 307 |
+
make_actor(_1),
|
| 308 |
+
make_actor(_2));
|
| 309 |
+
} // end operator>>()
|
| 310 |
+
|
| 311 |
+
template<typename T1, typename T2>
|
| 312 |
+
__host__ __device__
|
| 313 |
+
actor<
|
| 314 |
+
composite<
|
| 315 |
+
transparent_binary_operator<bit_rshift>,
|
| 316 |
+
typename as_actor<T1>::type,
|
| 317 |
+
actor<T2>
|
| 318 |
+
>
|
| 319 |
+
>
|
| 320 |
+
operator>>(const T1 &_1, const actor<T2> &_2)
|
| 321 |
+
{
|
| 322 |
+
return compose(transparent_binary_operator<bit_rshift>(),
|
| 323 |
+
make_actor(_1),
|
| 324 |
+
make_actor(_2));
|
| 325 |
+
} // end operator>>()
|
| 326 |
+
|
| 327 |
+
template<typename T1, typename T2>
|
| 328 |
+
__host__ __device__
|
| 329 |
+
actor<
|
| 330 |
+
composite<
|
| 331 |
+
transparent_binary_operator<bit_rshift>,
|
| 332 |
+
actor<T1>,
|
| 333 |
+
actor<T2>
|
| 334 |
+
>
|
| 335 |
+
>
|
| 336 |
+
operator>>(const actor<T1> &_1, const actor<T2> &_2)
|
| 337 |
+
{
|
| 338 |
+
return compose(transparent_binary_operator<bit_rshift>(),
|
| 339 |
+
make_actor(_1),
|
| 340 |
+
make_actor(_2));
|
| 341 |
+
} // end operator>>()
|
| 342 |
+
|
| 343 |
+
} // end functional
|
| 344 |
+
} // end detail
|
| 345 |
+
THRUST_NAMESPACE_END
|
| 346 |
+
|
miniCUDA124/include/thrust/detail/functional/operators/compound_assignment_operators.h
ADDED
|
@@ -0,0 +1,520 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/functional/actor.h>
|
| 29 |
+
#include <thrust/detail/functional/composite.h>
|
| 30 |
+
#include <thrust/detail/functional/operators/operator_adaptors.h>
|
| 31 |
+
|
| 32 |
+
THRUST_NAMESPACE_BEGIN
|
| 33 |
+
namespace detail
|
| 34 |
+
{
|
| 35 |
+
namespace functional
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
// there's no standard plus_equal functional, so roll an ad hoc one here
|
| 39 |
+
struct plus_equal
|
| 40 |
+
{
|
| 41 |
+
using is_transparent = void;
|
| 42 |
+
|
| 43 |
+
__thrust_exec_check_disable__
|
| 44 |
+
template <typename T1, typename T2>
|
| 45 |
+
__host__ __device__
|
| 46 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 47 |
+
noexcept(noexcept(THRUST_FWD(t1) += THRUST_FWD(t2)))
|
| 48 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) += THRUST_FWD(t2)))
|
| 49 |
+
{
|
| 50 |
+
return THRUST_FWD(t1) += THRUST_FWD(t2);
|
| 51 |
+
}
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
template<typename T1, typename T2>
|
| 55 |
+
__host__ __device__
|
| 56 |
+
actor<
|
| 57 |
+
composite<
|
| 58 |
+
transparent_binary_operator<plus_equal>,
|
| 59 |
+
actor<T1>,
|
| 60 |
+
typename as_actor<T2>::type
|
| 61 |
+
>
|
| 62 |
+
>
|
| 63 |
+
operator+=(const actor<T1> &_1, const T2 &_2)
|
| 64 |
+
{
|
| 65 |
+
return compose(transparent_binary_operator<plus_equal>(),
|
| 66 |
+
make_actor(_1),
|
| 67 |
+
make_actor(_2));
|
| 68 |
+
} // end operator+=()
|
| 69 |
+
|
| 70 |
+
template<typename T1, typename T2>
|
| 71 |
+
__host__ __device__
|
| 72 |
+
actor<
|
| 73 |
+
composite<
|
| 74 |
+
transparent_binary_operator<plus_equal>,
|
| 75 |
+
actor<T1>,
|
| 76 |
+
actor<T2>
|
| 77 |
+
>
|
| 78 |
+
>
|
| 79 |
+
operator+=(const actor<T1> &_1, const actor<T2> &_2)
|
| 80 |
+
{
|
| 81 |
+
return compose(transparent_binary_operator<plus_equal>(),
|
| 82 |
+
make_actor(_1),
|
| 83 |
+
make_actor(_2));
|
| 84 |
+
} // end operator+=()
|
| 85 |
+
|
| 86 |
+
// there's no standard minus_equal functional, so roll an ad hoc one here
|
| 87 |
+
struct minus_equal
|
| 88 |
+
{
|
| 89 |
+
using is_transparent = void;
|
| 90 |
+
|
| 91 |
+
__thrust_exec_check_disable__
|
| 92 |
+
template <typename T1, typename T2>
|
| 93 |
+
__host__ __device__
|
| 94 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 95 |
+
noexcept(noexcept(THRUST_FWD(t1) -= THRUST_FWD(t2)))
|
| 96 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) -= THRUST_FWD(t2)))
|
| 97 |
+
{
|
| 98 |
+
return THRUST_FWD(t1) -= THRUST_FWD(t2);
|
| 99 |
+
}
|
| 100 |
+
};
|
| 101 |
+
|
| 102 |
+
template<typename T1, typename T2>
|
| 103 |
+
__host__ __device__
|
| 104 |
+
actor<
|
| 105 |
+
composite<
|
| 106 |
+
transparent_binary_operator<minus_equal>,
|
| 107 |
+
actor<T1>,
|
| 108 |
+
typename as_actor<T2>::type
|
| 109 |
+
>
|
| 110 |
+
>
|
| 111 |
+
operator-=(const actor<T1> &_1, const T2 &_2)
|
| 112 |
+
{
|
| 113 |
+
return compose(transparent_binary_operator<minus_equal>(),
|
| 114 |
+
make_actor(_1),
|
| 115 |
+
make_actor(_2));
|
| 116 |
+
} // end operator-=()
|
| 117 |
+
|
| 118 |
+
template<typename T1, typename T2>
|
| 119 |
+
__host__ __device__
|
| 120 |
+
actor<
|
| 121 |
+
composite<
|
| 122 |
+
transparent_binary_operator<minus_equal>,
|
| 123 |
+
actor<T1>,
|
| 124 |
+
actor<T2>
|
| 125 |
+
>
|
| 126 |
+
>
|
| 127 |
+
operator-=(const actor<T1> &_1, const actor<T2> &_2)
|
| 128 |
+
{
|
| 129 |
+
return compose(transparent_binary_operator<minus_equal>(),
|
| 130 |
+
make_actor(_1),
|
| 131 |
+
make_actor(_2));
|
| 132 |
+
} // end operator-=()
|
| 133 |
+
|
| 134 |
+
// there's no standard multiplies_equal functional, so roll an ad hoc one here
|
| 135 |
+
struct multiplies_equal
|
| 136 |
+
{
|
| 137 |
+
using is_transparent = void;
|
| 138 |
+
|
| 139 |
+
__thrust_exec_check_disable__
|
| 140 |
+
template <typename T1, typename T2>
|
| 141 |
+
__host__ __device__
|
| 142 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 143 |
+
noexcept(noexcept(THRUST_FWD(t1) *= THRUST_FWD(t2)))
|
| 144 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) *= THRUST_FWD(t2)))
|
| 145 |
+
{
|
| 146 |
+
return THRUST_FWD(t1) *= THRUST_FWD(t2);
|
| 147 |
+
}
|
| 148 |
+
};
|
| 149 |
+
|
| 150 |
+
template<typename T1, typename T2>
|
| 151 |
+
__host__ __device__
|
| 152 |
+
actor<
|
| 153 |
+
composite<
|
| 154 |
+
transparent_binary_operator<multiplies_equal>,
|
| 155 |
+
actor<T1>,
|
| 156 |
+
typename as_actor<T2>::type
|
| 157 |
+
>
|
| 158 |
+
>
|
| 159 |
+
operator*=(const actor<T1> &_1, const T2 &_2)
|
| 160 |
+
{
|
| 161 |
+
return compose(transparent_binary_operator<multiplies_equal>(),
|
| 162 |
+
make_actor(_1),
|
| 163 |
+
make_actor(_2));
|
| 164 |
+
} // end operator*=()
|
| 165 |
+
|
| 166 |
+
template<typename T1, typename T2>
|
| 167 |
+
__host__ __device__
|
| 168 |
+
actor<
|
| 169 |
+
composite<
|
| 170 |
+
transparent_binary_operator<multiplies_equal>,
|
| 171 |
+
actor<T1>,
|
| 172 |
+
actor<T2>
|
| 173 |
+
>
|
| 174 |
+
>
|
| 175 |
+
operator*=(const actor<T1> &_1, const actor<T2> &_2)
|
| 176 |
+
{
|
| 177 |
+
return compose(transparent_binary_operator<multiplies_equal>(),
|
| 178 |
+
make_actor(_1),
|
| 179 |
+
make_actor(_2));
|
| 180 |
+
} // end operator*=()
|
| 181 |
+
|
| 182 |
+
// there's no standard divides_equal functional, so roll an ad hoc one here
|
| 183 |
+
struct divides_equal
|
| 184 |
+
{
|
| 185 |
+
using is_transparent = void;
|
| 186 |
+
|
| 187 |
+
__thrust_exec_check_disable__
|
| 188 |
+
template <typename T1, typename T2>
|
| 189 |
+
__host__ __device__
|
| 190 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 191 |
+
noexcept(noexcept(THRUST_FWD(t1) /= THRUST_FWD(t2)))
|
| 192 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) /= THRUST_FWD(t2)))
|
| 193 |
+
{
|
| 194 |
+
return THRUST_FWD(t1) /= THRUST_FWD(t2);
|
| 195 |
+
}
|
| 196 |
+
};
|
| 197 |
+
|
| 198 |
+
template<typename T1, typename T2>
|
| 199 |
+
__host__ __device__
|
| 200 |
+
actor<
|
| 201 |
+
composite<
|
| 202 |
+
transparent_binary_operator<divides_equal>,
|
| 203 |
+
actor<T1>,
|
| 204 |
+
typename as_actor<T2>::type
|
| 205 |
+
>
|
| 206 |
+
>
|
| 207 |
+
operator/=(const actor<T1> &_1, const T2 &_2)
|
| 208 |
+
{
|
| 209 |
+
return compose(transparent_binary_operator<divides_equal>(),
|
| 210 |
+
make_actor(_1),
|
| 211 |
+
make_actor(_2));
|
| 212 |
+
} // end operator/=()
|
| 213 |
+
|
| 214 |
+
template<typename T1, typename T2>
|
| 215 |
+
__host__ __device__
|
| 216 |
+
actor<
|
| 217 |
+
composite<
|
| 218 |
+
transparent_binary_operator<divides_equal>,
|
| 219 |
+
actor<T1>,
|
| 220 |
+
actor<T2>
|
| 221 |
+
>
|
| 222 |
+
>
|
| 223 |
+
operator/=(const actor<T1> &_1, const actor<T2> &_2)
|
| 224 |
+
{
|
| 225 |
+
return compose(transparent_binary_operator<divides_equal>(),
|
| 226 |
+
make_actor(_1),
|
| 227 |
+
make_actor(_2));
|
| 228 |
+
} // end operator/=()
|
| 229 |
+
|
| 230 |
+
// there's no standard modulus_equal functional, so roll an ad hoc one here
|
| 231 |
+
struct modulus_equal
|
| 232 |
+
{
|
| 233 |
+
using is_transparent = void;
|
| 234 |
+
|
| 235 |
+
__thrust_exec_check_disable__
|
| 236 |
+
template <typename T1, typename T2>
|
| 237 |
+
__host__ __device__
|
| 238 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 239 |
+
noexcept(noexcept(THRUST_FWD(t1) %= THRUST_FWD(t2)))
|
| 240 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) %= THRUST_FWD(t2)))
|
| 241 |
+
{
|
| 242 |
+
return THRUST_FWD(t1) %= THRUST_FWD(t2);
|
| 243 |
+
}
|
| 244 |
+
};
|
| 245 |
+
|
| 246 |
+
template<typename T1, typename T2>
|
| 247 |
+
__host__ __device__
|
| 248 |
+
actor<
|
| 249 |
+
composite<
|
| 250 |
+
transparent_binary_operator<modulus_equal>,
|
| 251 |
+
actor<T1>,
|
| 252 |
+
typename as_actor<T2>::type
|
| 253 |
+
>
|
| 254 |
+
>
|
| 255 |
+
operator%=(const actor<T1> &_1, const T2 &_2)
|
| 256 |
+
{
|
| 257 |
+
return compose(transparent_binary_operator<modulus_equal>(),
|
| 258 |
+
make_actor(_1),
|
| 259 |
+
make_actor(_2));
|
| 260 |
+
} // end operator%=()
|
| 261 |
+
|
| 262 |
+
template<typename T1, typename T2>
|
| 263 |
+
__host__ __device__
|
| 264 |
+
actor<
|
| 265 |
+
composite<
|
| 266 |
+
transparent_binary_operator<modulus_equal>,
|
| 267 |
+
actor<T1>,
|
| 268 |
+
actor<T2>
|
| 269 |
+
>
|
| 270 |
+
>
|
| 271 |
+
operator%=(const actor<T1> &_1, const actor<T2> &_2)
|
| 272 |
+
{
|
| 273 |
+
return compose(transparent_binary_operator<modulus_equal>(),
|
| 274 |
+
make_actor(_1),
|
| 275 |
+
make_actor(_2));
|
| 276 |
+
} // end operator%=()
|
| 277 |
+
|
| 278 |
+
// there's no standard bit_and_equal functional, so roll an ad hoc one here
|
| 279 |
+
struct bit_and_equal
|
| 280 |
+
{
|
| 281 |
+
using is_transparent = void;
|
| 282 |
+
|
| 283 |
+
__thrust_exec_check_disable__
|
| 284 |
+
template <typename T1, typename T2>
|
| 285 |
+
__host__ __device__
|
| 286 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 287 |
+
noexcept(noexcept(THRUST_FWD(t1) &= THRUST_FWD(t2)))
|
| 288 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) &= THRUST_FWD(t2)))
|
| 289 |
+
{
|
| 290 |
+
return THRUST_FWD(t1) &= THRUST_FWD(t2);
|
| 291 |
+
}
|
| 292 |
+
};
|
| 293 |
+
|
| 294 |
+
template<typename T1, typename T2>
|
| 295 |
+
__host__ __device__
|
| 296 |
+
actor<
|
| 297 |
+
composite<
|
| 298 |
+
transparent_binary_operator<bit_and_equal>,
|
| 299 |
+
actor<T1>,
|
| 300 |
+
typename as_actor<T2>::type
|
| 301 |
+
>
|
| 302 |
+
>
|
| 303 |
+
operator&=(const actor<T1> &_1, const T2 &_2)
|
| 304 |
+
{
|
| 305 |
+
return compose(transparent_binary_operator<bit_and_equal>(),
|
| 306 |
+
make_actor(_1),
|
| 307 |
+
make_actor(_2));
|
| 308 |
+
} // end operator&=()
|
| 309 |
+
|
| 310 |
+
template<typename T1, typename T2>
|
| 311 |
+
__host__ __device__
|
| 312 |
+
actor<
|
| 313 |
+
composite<
|
| 314 |
+
transparent_binary_operator<bit_and_equal>,
|
| 315 |
+
actor<T1>,
|
| 316 |
+
actor<T2>
|
| 317 |
+
>
|
| 318 |
+
>
|
| 319 |
+
operator&=(const actor<T1> &_1, const actor<T2> &_2)
|
| 320 |
+
{
|
| 321 |
+
return compose(transparent_binary_operator<bit_and_equal>(),
|
| 322 |
+
make_actor(_1),
|
| 323 |
+
make_actor(_2));
|
| 324 |
+
} // end operator&=()
|
| 325 |
+
|
| 326 |
+
// there's no standard bit_or_equal functional, so roll an ad hoc one here
|
| 327 |
+
struct bit_or_equal
|
| 328 |
+
{
|
| 329 |
+
using is_transparent = void;
|
| 330 |
+
|
| 331 |
+
__thrust_exec_check_disable__
|
| 332 |
+
template <typename T1, typename T2>
|
| 333 |
+
__host__ __device__
|
| 334 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 335 |
+
noexcept(noexcept(THRUST_FWD(t1) |= THRUST_FWD(t2)))
|
| 336 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) |= THRUST_FWD(t2)))
|
| 337 |
+
{
|
| 338 |
+
return THRUST_FWD(t1) |= THRUST_FWD(t2);
|
| 339 |
+
}
|
| 340 |
+
};
|
| 341 |
+
|
| 342 |
+
template<typename T1, typename T2>
|
| 343 |
+
__host__ __device__
|
| 344 |
+
actor<
|
| 345 |
+
composite<
|
| 346 |
+
transparent_binary_operator<bit_or_equal>,
|
| 347 |
+
actor<T1>,
|
| 348 |
+
typename as_actor<T2>::type
|
| 349 |
+
>
|
| 350 |
+
>
|
| 351 |
+
operator|=(const actor<T1> &_1, const T2 &_2)
|
| 352 |
+
{
|
| 353 |
+
return compose(transparent_binary_operator<bit_or_equal>(),
|
| 354 |
+
make_actor(_1),
|
| 355 |
+
make_actor(_2));
|
| 356 |
+
} // end operator|=()
|
| 357 |
+
|
| 358 |
+
template<typename T1, typename T2>
|
| 359 |
+
__host__ __device__
|
| 360 |
+
actor<
|
| 361 |
+
composite<
|
| 362 |
+
transparent_binary_operator<bit_or_equal>,
|
| 363 |
+
actor<T1>,
|
| 364 |
+
actor<T2>
|
| 365 |
+
>
|
| 366 |
+
>
|
| 367 |
+
operator|=(const actor<T1> &_1, const actor<T2> &_2)
|
| 368 |
+
{
|
| 369 |
+
return compose(transparent_binary_operator<bit_or_equal>(),
|
| 370 |
+
make_actor(_1),
|
| 371 |
+
make_actor(_2));
|
| 372 |
+
} // end operator|=()
|
| 373 |
+
|
| 374 |
+
// there's no standard bit_xor_equal functional, so roll an ad hoc one here
|
| 375 |
+
struct bit_xor_equal
|
| 376 |
+
{
|
| 377 |
+
using is_transparent = void;
|
| 378 |
+
|
| 379 |
+
__thrust_exec_check_disable__
|
| 380 |
+
template <typename T1, typename T2>
|
| 381 |
+
__host__ __device__
|
| 382 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 383 |
+
noexcept(noexcept(THRUST_FWD(t1) ^= THRUST_FWD(t2)))
|
| 384 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) ^= THRUST_FWD(t2)))
|
| 385 |
+
{
|
| 386 |
+
return THRUST_FWD(t1) ^= THRUST_FWD(t2);
|
| 387 |
+
}
|
| 388 |
+
};
|
| 389 |
+
|
| 390 |
+
template<typename T1, typename T2>
|
| 391 |
+
__host__ __device__
|
| 392 |
+
actor<
|
| 393 |
+
composite<
|
| 394 |
+
transparent_binary_operator<bit_xor_equal>,
|
| 395 |
+
actor<T1>,
|
| 396 |
+
typename as_actor<T2>::type
|
| 397 |
+
>
|
| 398 |
+
>
|
| 399 |
+
operator^=(const actor<T1> &_1, const T2 &_2)
|
| 400 |
+
{
|
| 401 |
+
return compose(transparent_binary_operator<bit_xor_equal>(),
|
| 402 |
+
make_actor(_1),
|
| 403 |
+
make_actor(_2));
|
| 404 |
+
} // end operator|=()
|
| 405 |
+
|
| 406 |
+
template<typename T1, typename T2>
|
| 407 |
+
__host__ __device__
|
| 408 |
+
actor<
|
| 409 |
+
composite<
|
| 410 |
+
transparent_binary_operator<bit_xor_equal>,
|
| 411 |
+
actor<T1>,
|
| 412 |
+
actor<T2>
|
| 413 |
+
>
|
| 414 |
+
>
|
| 415 |
+
operator^=(const actor<T1> &_1, const actor<T2> &_2)
|
| 416 |
+
{
|
| 417 |
+
return compose(transparent_binary_operator<bit_xor_equal>(),
|
| 418 |
+
make_actor(_1),
|
| 419 |
+
make_actor(_2));
|
| 420 |
+
} // end operator|=()
|
| 421 |
+
|
| 422 |
+
// there's no standard bit_lshift_equal functional, so roll an ad hoc one here
|
| 423 |
+
struct bit_lshift_equal
|
| 424 |
+
{
|
| 425 |
+
using is_transparent = void;
|
| 426 |
+
|
| 427 |
+
__thrust_exec_check_disable__
|
| 428 |
+
template <typename T1, typename T2>
|
| 429 |
+
__host__ __device__
|
| 430 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 431 |
+
noexcept(noexcept(THRUST_FWD(t1) <<= THRUST_FWD(t2)))
|
| 432 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) <<= THRUST_FWD(t2)))
|
| 433 |
+
{
|
| 434 |
+
return THRUST_FWD(t1) <<= THRUST_FWD(t2);
|
| 435 |
+
}
|
| 436 |
+
};
|
| 437 |
+
template<typename T1, typename T2>
|
| 438 |
+
__host__ __device__
|
| 439 |
+
actor<
|
| 440 |
+
composite<
|
| 441 |
+
transparent_binary_operator<bit_lshift_equal>,
|
| 442 |
+
actor<T1>,
|
| 443 |
+
typename as_actor<T2>::type
|
| 444 |
+
>
|
| 445 |
+
>
|
| 446 |
+
operator<<=(const actor<T1> &_1, const T2 &_2)
|
| 447 |
+
{
|
| 448 |
+
return compose(transparent_binary_operator<bit_lshift_equal>(),
|
| 449 |
+
make_actor(_1),
|
| 450 |
+
make_actor(_2));
|
| 451 |
+
} // end operator<<=()
|
| 452 |
+
|
| 453 |
+
template<typename T1, typename T2>
|
| 454 |
+
__host__ __device__
|
| 455 |
+
actor<
|
| 456 |
+
composite<
|
| 457 |
+
transparent_binary_operator<bit_lshift_equal>,
|
| 458 |
+
actor<T1>,
|
| 459 |
+
actor<T2>
|
| 460 |
+
>
|
| 461 |
+
>
|
| 462 |
+
operator<<=(const actor<T1> &_1, const actor<T2> &_2)
|
| 463 |
+
{
|
| 464 |
+
return compose(transparent_binary_operator<bit_lshift_equal>(),
|
| 465 |
+
make_actor(_1),
|
| 466 |
+
make_actor(_2));
|
| 467 |
+
} // end operator<<=()
|
| 468 |
+
|
| 469 |
+
// there's no standard bit_rshift_equal functional, so roll an ad hoc one here
|
| 470 |
+
struct bit_rshift_equal
|
| 471 |
+
{
|
| 472 |
+
using is_transparent = void;
|
| 473 |
+
|
| 474 |
+
__thrust_exec_check_disable__
|
| 475 |
+
template <typename T1, typename T2>
|
| 476 |
+
__host__ __device__
|
| 477 |
+
constexpr auto operator()(T1&& t1, T2&& t2) const
|
| 478 |
+
noexcept(noexcept(THRUST_FWD(t1) >>= THRUST_FWD(t2)))
|
| 479 |
+
THRUST_TRAILING_RETURN(decltype(THRUST_FWD(t1) >>= THRUST_FWD(t2)))
|
| 480 |
+
{
|
| 481 |
+
return THRUST_FWD(t1) >>= THRUST_FWD(t2);
|
| 482 |
+
}
|
| 483 |
+
};
|
| 484 |
+
|
| 485 |
+
template<typename T1, typename T2>
|
| 486 |
+
__host__ __device__
|
| 487 |
+
actor<
|
| 488 |
+
composite<
|
| 489 |
+
transparent_binary_operator<bit_rshift_equal>,
|
| 490 |
+
actor<T1>,
|
| 491 |
+
typename as_actor<T2>::type
|
| 492 |
+
>
|
| 493 |
+
>
|
| 494 |
+
operator>>=(const actor<T1> &_1, const T2 &_2)
|
| 495 |
+
{
|
| 496 |
+
return compose(transparent_binary_operator<bit_rshift_equal>(),
|
| 497 |
+
make_actor(_1),
|
| 498 |
+
make_actor(_2));
|
| 499 |
+
} // end operator>>=()
|
| 500 |
+
|
| 501 |
+
template<typename T1, typename T2>
|
| 502 |
+
__host__ __device__
|
| 503 |
+
actor<
|
| 504 |
+
composite<
|
| 505 |
+
transparent_binary_operator<bit_rshift_equal>,
|
| 506 |
+
actor<T1>,
|
| 507 |
+
actor<T2>
|
| 508 |
+
>
|
| 509 |
+
>
|
| 510 |
+
operator>>=(const actor<T1> &_1, const actor<T2> &_2)
|
| 511 |
+
{
|
| 512 |
+
return compose(transparent_binary_operator<bit_rshift_equal>(),
|
| 513 |
+
make_actor(_1),
|
| 514 |
+
make_actor(_2));
|
| 515 |
+
} // end operator>>=()
|
| 516 |
+
|
| 517 |
+
} // end functional
|
| 518 |
+
} // end detail
|
| 519 |
+
THRUST_NAMESPACE_END
|
| 520 |
+
|
miniCUDA124/include/thrust/detail/functional/operators/logical_operators.h
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/functional/actor.h>
|
| 29 |
+
#include <thrust/detail/functional/composite.h>
|
| 30 |
+
#include <thrust/detail/functional/operators/operator_adaptors.h>
|
| 31 |
+
#include <thrust/functional.h>
|
| 32 |
+
|
| 33 |
+
THRUST_NAMESPACE_BEGIN
|
| 34 |
+
namespace detail
|
| 35 |
+
{
|
| 36 |
+
namespace functional
|
| 37 |
+
{
|
| 38 |
+
|
| 39 |
+
template<typename T1, typename T2>
|
| 40 |
+
__host__ __device__
|
| 41 |
+
actor<
|
| 42 |
+
composite<
|
| 43 |
+
transparent_binary_operator<thrust::logical_and<>>,
|
| 44 |
+
actor<T1>,
|
| 45 |
+
typename as_actor<T2>::type
|
| 46 |
+
>
|
| 47 |
+
>
|
| 48 |
+
operator&&(const actor<T1> &_1, const T2 &_2)
|
| 49 |
+
{
|
| 50 |
+
return compose(transparent_binary_operator<thrust::logical_and<>>(),
|
| 51 |
+
make_actor(_1),
|
| 52 |
+
make_actor(_2));
|
| 53 |
+
} // end operator&&()
|
| 54 |
+
|
| 55 |
+
template<typename T1, typename T2>
|
| 56 |
+
__host__ __device__
|
| 57 |
+
actor<
|
| 58 |
+
composite<
|
| 59 |
+
transparent_binary_operator<thrust::logical_and<>>,
|
| 60 |
+
typename as_actor<T1>::type,
|
| 61 |
+
actor<T2>
|
| 62 |
+
>
|
| 63 |
+
>
|
| 64 |
+
operator&&(const T1 &_1, const actor<T2> &_2)
|
| 65 |
+
{
|
| 66 |
+
return compose(transparent_binary_operator<thrust::logical_and<>>(),
|
| 67 |
+
make_actor(_1),
|
| 68 |
+
make_actor(_2));
|
| 69 |
+
} // end operator&&()
|
| 70 |
+
|
| 71 |
+
template<typename T1, typename T2>
|
| 72 |
+
__host__ __device__
|
| 73 |
+
actor<
|
| 74 |
+
composite<
|
| 75 |
+
transparent_binary_operator<thrust::logical_and<>>,
|
| 76 |
+
actor<T1>,
|
| 77 |
+
actor<T2>
|
| 78 |
+
>
|
| 79 |
+
>
|
| 80 |
+
operator&&(const actor<T1> &_1, const actor<T2> &_2)
|
| 81 |
+
{
|
| 82 |
+
return compose(transparent_binary_operator<thrust::logical_and<>>(),
|
| 83 |
+
make_actor(_1),
|
| 84 |
+
make_actor(_2));
|
| 85 |
+
} // end operator&&()
|
| 86 |
+
|
| 87 |
+
template<typename T1, typename T2>
|
| 88 |
+
__host__ __device__
|
| 89 |
+
actor<
|
| 90 |
+
composite<
|
| 91 |
+
transparent_binary_operator<thrust::logical_or<>>,
|
| 92 |
+
actor<T1>,
|
| 93 |
+
typename as_actor<T2>::type
|
| 94 |
+
>
|
| 95 |
+
>
|
| 96 |
+
operator||(const actor<T1> &_1, const T2 &_2)
|
| 97 |
+
{
|
| 98 |
+
return compose(transparent_binary_operator<thrust::logical_or<>>(),
|
| 99 |
+
make_actor(_1),
|
| 100 |
+
make_actor(_2));
|
| 101 |
+
} // end operator&&()
|
| 102 |
+
|
| 103 |
+
template<typename T1, typename T2>
|
| 104 |
+
__host__ __device__
|
| 105 |
+
actor<
|
| 106 |
+
composite<
|
| 107 |
+
transparent_binary_operator<thrust::logical_or<>>,
|
| 108 |
+
typename as_actor<T1>::type,
|
| 109 |
+
actor<T2>
|
| 110 |
+
>
|
| 111 |
+
>
|
| 112 |
+
operator||(const T1 &_1, const actor<T2> &_2)
|
| 113 |
+
{
|
| 114 |
+
return compose(transparent_binary_operator<thrust::logical_or<>>(),
|
| 115 |
+
make_actor(_1),
|
| 116 |
+
make_actor(_2));
|
| 117 |
+
} // end operator&&()
|
| 118 |
+
|
| 119 |
+
template<typename T1, typename T2>
|
| 120 |
+
__host__ __device__
|
| 121 |
+
actor<
|
| 122 |
+
composite<
|
| 123 |
+
transparent_binary_operator<thrust::logical_or<>>,
|
| 124 |
+
actor<T1>,
|
| 125 |
+
actor<T2>
|
| 126 |
+
>
|
| 127 |
+
>
|
| 128 |
+
operator||(const actor<T1> &_1, const actor<T2> &_2)
|
| 129 |
+
{
|
| 130 |
+
return compose(transparent_binary_operator<thrust::logical_or<>>(),
|
| 131 |
+
make_actor(_1),
|
| 132 |
+
make_actor(_2));
|
| 133 |
+
} // end operator&&()
|
| 134 |
+
|
| 135 |
+
template<typename Eval>
|
| 136 |
+
__host__ __device__
|
| 137 |
+
actor<
|
| 138 |
+
composite<
|
| 139 |
+
transparent_unary_operator<thrust::logical_not<>>,
|
| 140 |
+
actor<Eval>
|
| 141 |
+
>
|
| 142 |
+
>
|
| 143 |
+
operator!(const actor<Eval> &_1)
|
| 144 |
+
{
|
| 145 |
+
return compose(transparent_unary_operator<thrust::logical_not<>>(), _1);
|
| 146 |
+
} // end operator!()
|
| 147 |
+
|
| 148 |
+
} // end functional
|
| 149 |
+
} // end detail
|
| 150 |
+
THRUST_NAMESPACE_END
|
| 151 |
+
|
miniCUDA124/include/thrust/detail/functional/operators/operator_adaptors.h
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/functional/argument.h>
|
| 29 |
+
#include <thrust/detail/type_deduction.h>
|
| 30 |
+
#include <thrust/tuple.h>
|
| 31 |
+
#include <thrust/detail/type_traits.h>
|
| 32 |
+
#include <thrust/type_traits/void_t.h>
|
| 33 |
+
|
| 34 |
+
#include <type_traits>
|
| 35 |
+
|
| 36 |
+
THRUST_NAMESPACE_BEGIN
|
| 37 |
+
namespace detail
|
| 38 |
+
{
|
| 39 |
+
namespace functional
|
| 40 |
+
{
|
| 41 |
+
|
| 42 |
+
// Adapts a transparent unary functor from functional.h (e.g. thrust::negate<>)
|
| 43 |
+
// into the Eval interface.
|
| 44 |
+
template <typename UnaryFunctor>
|
| 45 |
+
struct transparent_unary_operator
|
| 46 |
+
{
|
| 47 |
+
template <typename>
|
| 48 |
+
using operator_type = UnaryFunctor;
|
| 49 |
+
|
| 50 |
+
template <typename Env>
|
| 51 |
+
using argument =
|
| 52 |
+
typename thrust::detail::eval_if<
|
| 53 |
+
thrust::tuple_size<Env>::value != 1,
|
| 54 |
+
thrust::detail::identity_<thrust::tuple<>>,
|
| 55 |
+
thrust::detail::functional::argument_helper<0, Env>
|
| 56 |
+
>::type;
|
| 57 |
+
|
| 58 |
+
template <typename Env>
|
| 59 |
+
struct result_type_impl
|
| 60 |
+
{
|
| 61 |
+
using type = decltype(
|
| 62 |
+
std::declval<UnaryFunctor>()(std::declval<argument<Env>>()));
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
template <typename Env>
|
| 66 |
+
using result_type =
|
| 67 |
+
typename thrust::detail::eval_if<
|
| 68 |
+
std::is_same<thrust::tuple<>, argument<Env>>::value,
|
| 69 |
+
thrust::detail::identity_<thrust::tuple<>>,
|
| 70 |
+
result_type_impl<Env>
|
| 71 |
+
>::type;
|
| 72 |
+
|
| 73 |
+
template <typename Env>
|
| 74 |
+
struct result
|
| 75 |
+
{
|
| 76 |
+
using op_type = UnaryFunctor;
|
| 77 |
+
using type = result_type<Env>;
|
| 78 |
+
};
|
| 79 |
+
|
| 80 |
+
template <typename Env>
|
| 81 |
+
__host__ __device__
|
| 82 |
+
result_type<Env> eval(Env&& e) const
|
| 83 |
+
THRUST_RETURNS(UnaryFunctor{}(thrust::get<0>(THRUST_FWD(e))))
|
| 84 |
+
};
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
// Adapts a transparent binary functor from functional.h (e.g. thrust::less<>)
|
| 88 |
+
// into the Eval interface.
|
| 89 |
+
template <typename BinaryFunctor>
|
| 90 |
+
struct transparent_binary_operator
|
| 91 |
+
{
|
| 92 |
+
template <typename>
|
| 93 |
+
using operator_type = BinaryFunctor;
|
| 94 |
+
|
| 95 |
+
template <typename Env>
|
| 96 |
+
using first_argument =
|
| 97 |
+
typename thrust::detail::eval_if<
|
| 98 |
+
thrust::tuple_size<Env>::value != 2,
|
| 99 |
+
thrust::detail::identity_<thrust::tuple<>>,
|
| 100 |
+
thrust::detail::functional::argument_helper<0, Env>
|
| 101 |
+
>::type;
|
| 102 |
+
|
| 103 |
+
template <typename Env>
|
| 104 |
+
using second_argument =
|
| 105 |
+
typename thrust::detail::eval_if<
|
| 106 |
+
thrust::tuple_size<Env>::value != 2,
|
| 107 |
+
thrust::detail::identity_<thrust::tuple<>>,
|
| 108 |
+
thrust::detail::functional::argument_helper<1, Env>
|
| 109 |
+
>::type;
|
| 110 |
+
|
| 111 |
+
template <typename Env>
|
| 112 |
+
struct result_type_impl
|
| 113 |
+
{
|
| 114 |
+
using type = decltype(
|
| 115 |
+
std::declval<BinaryFunctor>()(std::declval<first_argument<Env>>(),
|
| 116 |
+
std::declval<second_argument<Env>>()));
|
| 117 |
+
};
|
| 118 |
+
|
| 119 |
+
template <typename Env>
|
| 120 |
+
using result_type =
|
| 121 |
+
typename thrust::detail::eval_if<
|
| 122 |
+
(std::is_same<thrust::tuple<>, first_argument<Env>>::value ||
|
| 123 |
+
std::is_same<thrust::tuple<>, second_argument<Env>>::value),
|
| 124 |
+
thrust::detail::identity_<thrust::tuple<>>,
|
| 125 |
+
result_type_impl<Env>
|
| 126 |
+
>::type;
|
| 127 |
+
|
| 128 |
+
template <typename Env>
|
| 129 |
+
struct result
|
| 130 |
+
{
|
| 131 |
+
using op_type = BinaryFunctor;
|
| 132 |
+
using type = result_type<Env>;
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
template <typename Env>
|
| 136 |
+
__host__ __device__
|
| 137 |
+
result_type<Env> eval(Env&& e) const
|
| 138 |
+
THRUST_RETURNS(BinaryFunctor{}(thrust::get<0>(e), thrust::get<1>(e)))
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
} // end functional
|
| 142 |
+
} // end detail
|
| 143 |
+
THRUST_NAMESPACE_END
|
| 144 |
+
|
miniCUDA124/include/thrust/detail/functional/operators/relational_operators.h
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/functional/actor.h>
|
| 29 |
+
#include <thrust/detail/functional/composite.h>
|
| 30 |
+
#include <thrust/detail/functional/operators/operator_adaptors.h>
|
| 31 |
+
#include <thrust/functional.h>
|
| 32 |
+
|
| 33 |
+
THRUST_NAMESPACE_BEGIN
|
| 34 |
+
namespace detail
|
| 35 |
+
{
|
| 36 |
+
namespace functional
|
| 37 |
+
{
|
| 38 |
+
|
| 39 |
+
template<typename T1, typename T2>
|
| 40 |
+
__host__ __device__
|
| 41 |
+
actor<
|
| 42 |
+
composite<
|
| 43 |
+
transparent_binary_operator<thrust::equal_to<>>,
|
| 44 |
+
actor<T1>,
|
| 45 |
+
typename as_actor<T2>::type
|
| 46 |
+
>
|
| 47 |
+
>
|
| 48 |
+
operator==(const actor<T1> &_1, const T2 &_2)
|
| 49 |
+
{
|
| 50 |
+
return compose(transparent_binary_operator<thrust::equal_to<>>(),
|
| 51 |
+
make_actor(_1),
|
| 52 |
+
make_actor(_2));
|
| 53 |
+
} // end operator==()
|
| 54 |
+
|
| 55 |
+
template<typename T1, typename T2>
|
| 56 |
+
__host__ __device__
|
| 57 |
+
actor<
|
| 58 |
+
composite<
|
| 59 |
+
transparent_binary_operator<thrust::equal_to<>>,
|
| 60 |
+
typename as_actor<T1>::type,
|
| 61 |
+
actor<T2>
|
| 62 |
+
>
|
| 63 |
+
>
|
| 64 |
+
operator==(const T1 &_1, const actor<T2> &_2)
|
| 65 |
+
{
|
| 66 |
+
return compose(transparent_binary_operator<thrust::equal_to<>>(),
|
| 67 |
+
make_actor(_1),
|
| 68 |
+
make_actor(_2));
|
| 69 |
+
} // end operator==()
|
| 70 |
+
|
| 71 |
+
template<typename T1, typename T2>
|
| 72 |
+
__host__ __device__
|
| 73 |
+
actor<
|
| 74 |
+
composite<
|
| 75 |
+
transparent_binary_operator<thrust::equal_to<>>,
|
| 76 |
+
actor<T1>,
|
| 77 |
+
actor<T2>
|
| 78 |
+
>
|
| 79 |
+
>
|
| 80 |
+
operator==(const actor<T1> &_1, const actor<T2> &_2)
|
| 81 |
+
{
|
| 82 |
+
return compose(transparent_binary_operator<thrust::equal_to<>>(),
|
| 83 |
+
make_actor(_1),
|
| 84 |
+
make_actor(_2));
|
| 85 |
+
} // end operator==()
|
| 86 |
+
|
| 87 |
+
template<typename T1, typename T2>
|
| 88 |
+
__host__ __device__
|
| 89 |
+
actor<
|
| 90 |
+
composite<
|
| 91 |
+
transparent_binary_operator<thrust::not_equal_to<>>,
|
| 92 |
+
actor<T1>,
|
| 93 |
+
typename as_actor<T2>::type
|
| 94 |
+
>
|
| 95 |
+
>
|
| 96 |
+
operator!=(const actor<T1> &_1, const T2 &_2)
|
| 97 |
+
{
|
| 98 |
+
return compose(transparent_binary_operator<thrust::not_equal_to<>>(),
|
| 99 |
+
make_actor(_1),
|
| 100 |
+
make_actor(_2));
|
| 101 |
+
} // end operator!=()
|
| 102 |
+
|
| 103 |
+
template<typename T1, typename T2>
|
| 104 |
+
__host__ __device__
|
| 105 |
+
actor<
|
| 106 |
+
composite<
|
| 107 |
+
transparent_binary_operator<thrust::not_equal_to<>>,
|
| 108 |
+
typename as_actor<T1>::type,
|
| 109 |
+
actor<T2>
|
| 110 |
+
>
|
| 111 |
+
>
|
| 112 |
+
operator!=(const T1 &_1, const actor<T2> &_2)
|
| 113 |
+
{
|
| 114 |
+
return compose(transparent_binary_operator<thrust::not_equal_to<>>(),
|
| 115 |
+
make_actor(_1),
|
| 116 |
+
make_actor(_2));
|
| 117 |
+
} // end operator!=()
|
| 118 |
+
|
| 119 |
+
template<typename T1, typename T2>
|
| 120 |
+
__host__ __device__
|
| 121 |
+
actor<
|
| 122 |
+
composite<
|
| 123 |
+
transparent_binary_operator<thrust::not_equal_to<>>,
|
| 124 |
+
actor<T1>,
|
| 125 |
+
actor<T2>
|
| 126 |
+
>
|
| 127 |
+
>
|
| 128 |
+
operator!=(const actor<T1> &_1, const actor<T2> &_2)
|
| 129 |
+
{
|
| 130 |
+
return compose(transparent_binary_operator<thrust::not_equal_to<>>(),
|
| 131 |
+
make_actor(_1),
|
| 132 |
+
make_actor(_2));
|
| 133 |
+
} // end operator!=()
|
| 134 |
+
|
| 135 |
+
template<typename T1, typename T2>
|
| 136 |
+
__host__ __device__
|
| 137 |
+
actor<
|
| 138 |
+
composite<
|
| 139 |
+
transparent_binary_operator<thrust::greater<>>,
|
| 140 |
+
actor<T1>,
|
| 141 |
+
typename as_actor<T2>::type
|
| 142 |
+
>
|
| 143 |
+
>
|
| 144 |
+
operator>(const actor<T1> &_1, const T2 &_2)
|
| 145 |
+
{
|
| 146 |
+
return compose(transparent_binary_operator<thrust::greater<>>(),
|
| 147 |
+
make_actor(_1),
|
| 148 |
+
make_actor(_2));
|
| 149 |
+
} // end operator>()
|
| 150 |
+
|
| 151 |
+
template<typename T1, typename T2>
|
| 152 |
+
__host__ __device__
|
| 153 |
+
actor<
|
| 154 |
+
composite<
|
| 155 |
+
transparent_binary_operator<thrust::greater<>>,
|
| 156 |
+
typename as_actor<T1>::type,
|
| 157 |
+
actor<T2>
|
| 158 |
+
>
|
| 159 |
+
>
|
| 160 |
+
operator>(const T1 &_1, const actor<T2> &_2)
|
| 161 |
+
{
|
| 162 |
+
return compose(transparent_binary_operator<thrust::greater<>>(),
|
| 163 |
+
make_actor(_1),
|
| 164 |
+
make_actor(_2));
|
| 165 |
+
} // end operator>()
|
| 166 |
+
|
| 167 |
+
template<typename T1, typename T2>
|
| 168 |
+
__host__ __device__
|
| 169 |
+
actor<
|
| 170 |
+
composite<
|
| 171 |
+
transparent_binary_operator<thrust::greater<>>,
|
| 172 |
+
actor<T1>,
|
| 173 |
+
actor<T2>
|
| 174 |
+
>
|
| 175 |
+
>
|
| 176 |
+
operator>(const actor<T1> &_1, const actor<T2> &_2)
|
| 177 |
+
{
|
| 178 |
+
return compose(transparent_binary_operator<thrust::greater<>>(),
|
| 179 |
+
make_actor(_1),
|
| 180 |
+
make_actor(_2));
|
| 181 |
+
} // end operator>()
|
| 182 |
+
|
| 183 |
+
template<typename T1, typename T2>
|
| 184 |
+
__host__ __device__
|
| 185 |
+
actor<
|
| 186 |
+
composite<
|
| 187 |
+
transparent_binary_operator<thrust::less<>>,
|
| 188 |
+
actor<T1>,
|
| 189 |
+
typename as_actor<T2>::type
|
| 190 |
+
>
|
| 191 |
+
>
|
| 192 |
+
operator<(const actor<T1> &_1, const T2 &_2)
|
| 193 |
+
{
|
| 194 |
+
return compose(transparent_binary_operator<thrust::less<>>(),
|
| 195 |
+
make_actor(_1),
|
| 196 |
+
make_actor(_2));
|
| 197 |
+
} // end operator<()
|
| 198 |
+
|
| 199 |
+
template<typename T1, typename T2>
|
| 200 |
+
__host__ __device__
|
| 201 |
+
actor<
|
| 202 |
+
composite<
|
| 203 |
+
transparent_binary_operator<thrust::less<>>,
|
| 204 |
+
typename as_actor<T1>::type,
|
| 205 |
+
actor<T2>
|
| 206 |
+
>
|
| 207 |
+
>
|
| 208 |
+
operator<(const T1 &_1, const actor<T2> &_2)
|
| 209 |
+
{
|
| 210 |
+
return compose(transparent_binary_operator<thrust::less<>>(),
|
| 211 |
+
make_actor(_1),
|
| 212 |
+
make_actor(_2));
|
| 213 |
+
} // end operator<()
|
| 214 |
+
|
| 215 |
+
template<typename T1, typename T2>
|
| 216 |
+
__host__ __device__
|
| 217 |
+
actor<
|
| 218 |
+
composite<
|
| 219 |
+
transparent_binary_operator<thrust::less<>>,
|
| 220 |
+
actor<T1>,
|
| 221 |
+
actor<T2>
|
| 222 |
+
>
|
| 223 |
+
>
|
| 224 |
+
operator<(const actor<T1> &_1, const actor<T2> &_2)
|
| 225 |
+
{
|
| 226 |
+
return compose(transparent_binary_operator<thrust::less<>>(),
|
| 227 |
+
make_actor(_1),
|
| 228 |
+
make_actor(_2));
|
| 229 |
+
} // end operator<()
|
| 230 |
+
|
| 231 |
+
template<typename T1, typename T2>
|
| 232 |
+
__host__ __device__
|
| 233 |
+
actor<
|
| 234 |
+
composite<
|
| 235 |
+
transparent_binary_operator<thrust::greater_equal<>>,
|
| 236 |
+
actor<T1>,
|
| 237 |
+
typename as_actor<T2>::type
|
| 238 |
+
>
|
| 239 |
+
>
|
| 240 |
+
operator>=(const actor<T1> &_1, const T2 &_2)
|
| 241 |
+
{
|
| 242 |
+
return compose(transparent_binary_operator<thrust::greater_equal<>>(),
|
| 243 |
+
make_actor(_1),
|
| 244 |
+
make_actor(_2));
|
| 245 |
+
} // end operator>=()
|
| 246 |
+
|
| 247 |
+
template<typename T1, typename T2>
|
| 248 |
+
__host__ __device__
|
| 249 |
+
actor<
|
| 250 |
+
composite<
|
| 251 |
+
transparent_binary_operator<thrust::greater_equal<>>,
|
| 252 |
+
typename as_actor<T1>::type,
|
| 253 |
+
actor<T2>
|
| 254 |
+
>
|
| 255 |
+
>
|
| 256 |
+
operator>=(const T1 &_1, const actor<T2> &_2)
|
| 257 |
+
{
|
| 258 |
+
return compose(transparent_binary_operator<thrust::greater_equal<>>(),
|
| 259 |
+
make_actor(_1),
|
| 260 |
+
make_actor(_2));
|
| 261 |
+
} // end operator>=()
|
| 262 |
+
|
| 263 |
+
template<typename T1, typename T2>
|
| 264 |
+
__host__ __device__
|
| 265 |
+
actor<
|
| 266 |
+
composite<
|
| 267 |
+
transparent_binary_operator<thrust::greater_equal<>>,
|
| 268 |
+
actor<T1>,
|
| 269 |
+
actor<T2>
|
| 270 |
+
>
|
| 271 |
+
>
|
| 272 |
+
operator>=(const actor<T1> &_1, const actor<T2> &_2)
|
| 273 |
+
{
|
| 274 |
+
return compose(transparent_binary_operator<thrust::greater_equal<>>(),
|
| 275 |
+
make_actor(_1),
|
| 276 |
+
make_actor(_2));
|
| 277 |
+
} // end operator>=()
|
| 278 |
+
|
| 279 |
+
template<typename T1, typename T2>
|
| 280 |
+
__host__ __device__
|
| 281 |
+
actor<
|
| 282 |
+
composite<
|
| 283 |
+
transparent_binary_operator<thrust::less_equal<>>,
|
| 284 |
+
actor<T1>,
|
| 285 |
+
typename as_actor<T2>::type
|
| 286 |
+
>
|
| 287 |
+
>
|
| 288 |
+
operator<=(const actor<T1> &_1, const T2 &_2)
|
| 289 |
+
{
|
| 290 |
+
return compose(transparent_binary_operator<thrust::less_equal<>>(),
|
| 291 |
+
make_actor(_1),
|
| 292 |
+
make_actor(_2));
|
| 293 |
+
} // end operator<=()
|
| 294 |
+
|
| 295 |
+
template<typename T1, typename T2>
|
| 296 |
+
__host__ __device__
|
| 297 |
+
actor<
|
| 298 |
+
composite<
|
| 299 |
+
transparent_binary_operator<thrust::less_equal<>>,
|
| 300 |
+
typename as_actor<T1>::type,
|
| 301 |
+
actor<T2>
|
| 302 |
+
>
|
| 303 |
+
>
|
| 304 |
+
operator<=(const T1 &_1, const actor<T2> &_2)
|
| 305 |
+
{
|
| 306 |
+
return compose(transparent_binary_operator<thrust::less_equal<>>(),
|
| 307 |
+
make_actor(_1),
|
| 308 |
+
make_actor(_2));
|
| 309 |
+
} // end operator<=()
|
| 310 |
+
|
| 311 |
+
template<typename T1, typename T2>
|
| 312 |
+
__host__ __device__
|
| 313 |
+
actor<
|
| 314 |
+
composite<
|
| 315 |
+
transparent_binary_operator<thrust::less_equal<>>,
|
| 316 |
+
actor<T1>,
|
| 317 |
+
actor<T2>
|
| 318 |
+
>
|
| 319 |
+
>
|
| 320 |
+
operator<=(const actor<T1> &_1, const actor<T2> &_2)
|
| 321 |
+
{
|
| 322 |
+
return compose(transparent_binary_operator<thrust::less_equal<>>(),
|
| 323 |
+
make_actor(_1),
|
| 324 |
+
make_actor(_2));
|
| 325 |
+
} // end operator<=()
|
| 326 |
+
|
| 327 |
+
} // end functional
|
| 328 |
+
} // end detail
|
| 329 |
+
THRUST_NAMESPACE_END
|
| 330 |
+
|