paredeyes commited on
Commit
82fcb5f
·
verified ·
1 Parent(s): 2386e30

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. miniCUDA124/bin/nvrtc-builtins64_124.dll +3 -0
  3. miniCUDA124/bin/nvrtc64_120_0.dll +3 -0
  4. miniCUDA124/include/thrust/iterator/detail/discard_iterator_base.h +72 -0
  5. miniCUDA124/include/thrust/iterator/detail/distance_from_result.h +49 -0
  6. miniCUDA124/include/thrust/iterator/detail/host_system_tag.h +38 -0
  7. miniCUDA124/include/thrust/iterator/detail/is_iterator_category.h +67 -0
  8. miniCUDA124/include/thrust/iterator/detail/iterator_adaptor_base.h +120 -0
  9. miniCUDA124/include/thrust/iterator/detail/iterator_category_to_system.h +87 -0
  10. miniCUDA124/include/thrust/iterator/detail/iterator_category_to_traversal.h +138 -0
  11. miniCUDA124/include/thrust/iterator/detail/iterator_category_with_system_and_traversal.h +64 -0
  12. miniCUDA124/include/thrust/iterator/detail/iterator_facade_category.h +260 -0
  13. miniCUDA124/include/thrust/iterator/detail/iterator_traits.inl +144 -0
  14. miniCUDA124/include/thrust/iterator/detail/minimum_system.h +89 -0
  15. miniCUDA124/include/thrust/iterator/detail/normal_iterator.h +87 -0
  16. miniCUDA124/include/thrust/iterator/detail/permutation_iterator_base.h +62 -0
  17. miniCUDA124/include/thrust/iterator/detail/retag.h +155 -0
  18. miniCUDA124/include/thrust/iterator/detail/reverse_iterator.inl +126 -0
  19. miniCUDA124/include/thrust/iterator/detail/reverse_iterator_base.h +51 -0
  20. miniCUDA124/include/thrust/iterator/detail/tagged_iterator.h +93 -0
  21. miniCUDA124/include/thrust/iterator/detail/transform_input_output_iterator.inl +115 -0
  22. miniCUDA124/include/thrust/iterator/detail/transform_iterator.inl +77 -0
  23. miniCUDA124/include/thrust/iterator/detail/transform_output_iterator.inl +89 -0
  24. miniCUDA124/include/thrust/iterator/detail/tuple_of_iterator_references.h +160 -0
  25. miniCUDA124/include/thrust/iterator/detail/universal_categories.h +94 -0
  26. miniCUDA124/include/thrust/iterator/detail/zip_iterator.inl +160 -0
  27. miniCUDA124/include/thrust/iterator/detail/zip_iterator_base.h +361 -0
  28. miniCUDA124/include/thrust/random/detail/discard_block_engine.inl +223 -0
  29. miniCUDA124/include/thrust/random/detail/linear_congruential_engine.inl +180 -0
  30. miniCUDA124/include/thrust/random/detail/linear_congruential_engine_discard.h +116 -0
  31. miniCUDA124/include/thrust/random/detail/linear_feedback_shift_engine.inl +176 -0
  32. miniCUDA124/include/thrust/random/detail/linear_feedback_shift_engine_wordmask.h +56 -0
  33. miniCUDA124/include/thrust/random/detail/mod.h +106 -0
  34. miniCUDA124/include/thrust/random/detail/normal_distribution.inl +265 -0
  35. miniCUDA124/include/thrust/random/detail/normal_distribution_base.h +156 -0
  36. miniCUDA124/include/thrust/random/detail/random_core_access.h +66 -0
  37. miniCUDA124/include/thrust/random/detail/subtract_with_carry_engine.inl +221 -0
  38. miniCUDA124/include/thrust/random/detail/uniform_int_distribution.inl +257 -0
  39. miniCUDA124/include/thrust/random/detail/uniform_real_distribution.inl +242 -0
  40. miniCUDA124/include/thrust/random/detail/xor_combine_engine.inl +226 -0
  41. miniCUDA124/include/thrust/random/detail/xor_combine_engine_max.h +333 -0
  42. miniCUDA124/include/thrust/system/cpp/detail/adjacent_difference.h +31 -0
  43. miniCUDA124/include/thrust/system/cpp/detail/assign_value.h +31 -0
  44. miniCUDA124/include/thrust/system/cpp/detail/binary_search.h +33 -0
  45. miniCUDA124/include/thrust/system/cpp/detail/copy.h +31 -0
  46. miniCUDA124/include/thrust/system/cpp/detail/copy_if.h +31 -0
  47. miniCUDA124/include/thrust/system/cpp/detail/count.h +30 -0
  48. miniCUDA124/include/thrust/system/cpp/detail/equal.h +30 -0
  49. miniCUDA124/include/thrust/system/cpp/detail/execution_policy.h +88 -0
  50. miniCUDA124/include/thrust/system/cpp/execution_policy.h +164 -0
.gitattributes CHANGED
@@ -93,3 +93,5 @@ miniCUDA124/bin/nppig64_12.dll filter=lfs diff=lfs merge=lfs -text
93
  miniCUDA124/bin/ptxas.exe filter=lfs diff=lfs merge=lfs -text
94
  miniCUDA124/bin/nvprof.exe filter=lfs diff=lfs merge=lfs -text
95
  miniCUDA124/bin/npps64_12.dll filter=lfs diff=lfs merge=lfs -text
 
 
 
93
  miniCUDA124/bin/ptxas.exe filter=lfs diff=lfs merge=lfs -text
94
  miniCUDA124/bin/nvprof.exe filter=lfs diff=lfs merge=lfs -text
95
  miniCUDA124/bin/npps64_12.dll filter=lfs diff=lfs merge=lfs -text
96
+ miniCUDA124/bin/nvrtc64_120_0.dll filter=lfs diff=lfs merge=lfs -text
97
+ miniCUDA124/bin/nvrtc-builtins64_124.dll filter=lfs diff=lfs merge=lfs -text
miniCUDA124/bin/nvrtc-builtins64_124.dll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:79888dba26c51475ea21fc7b47d2b9dd5b1ffaecc8e5ea22a49fa5f5a722eb43
3
+ size 5367808
miniCUDA124/bin/nvrtc64_120_0.dll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3aa3cd8aa10437e212760c0e1ed730807811ec3bc330216dbfde4b26211d2243
3
+ size 44738048
miniCUDA124/include/thrust/iterator/detail/discard_iterator_base.h ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+ #include <thrust/iterator/counting_iterator.h>
29
+ #include <thrust/iterator/iterator_adaptor.h>
30
+ #include <thrust/iterator/detail/any_assign.h>
31
+ #include <cstddef> // for std::ptrdiff_t
32
+
33
+ THRUST_NAMESPACE_BEGIN
34
+
35
+ // forward declaration of discard_iterator
36
+ template<typename> class discard_iterator;
37
+
38
+ namespace detail
39
+ {
40
+
41
+
42
+ template<typename System>
43
+ struct discard_iterator_base
44
+ {
45
+ // XXX value_type should actually be void
46
+ // but this interferes with zip_iterator<discard_iterator>
47
+ typedef any_assign value_type;
48
+ typedef any_assign& reference;
49
+ typedef std::ptrdiff_t incrementable;
50
+
51
+ typedef typename thrust::counting_iterator<
52
+ incrementable,
53
+ System,
54
+ thrust::random_access_traversal_tag
55
+ > base_iterator;
56
+
57
+ typedef typename thrust::iterator_adaptor<
58
+ discard_iterator<System>,
59
+ base_iterator,
60
+ value_type,
61
+ typename thrust::iterator_system<base_iterator>::type,
62
+ typename thrust::iterator_traversal<base_iterator>::type,
63
+ reference
64
+ > type;
65
+ }; // end discard_iterator_base
66
+
67
+
68
+ } // end detail
69
+
70
+ THRUST_NAMESPACE_END
71
+
72
+
miniCUDA124/include/thrust/iterator/detail/distance_from_result.h ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
30
+ THRUST_NAMESPACE_BEGIN
31
+
32
+ namespace detail
33
+ {
34
+
35
+ // since both arguments are known to be specializations of iterator_facade,
36
+ // it's legal to access IteratorFacade2::difference_type
37
+ template<typename IteratorFacade1, typename IteratorFacade2>
38
+ struct distance_from_result
39
+ : eval_if<
40
+ is_convertible<IteratorFacade2,IteratorFacade1>::value,
41
+ identity_<typename IteratorFacade1::difference_type>,
42
+ identity_<typename IteratorFacade2::difference_type>
43
+ >
44
+ {};
45
+
46
+ } // end detail
47
+
48
+ THRUST_NAMESPACE_END
49
+
miniCUDA124/include/thrust/iterator/detail/host_system_tag.h ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 the host system's execution_policy header
30
+ #define __THRUST_HOST_SYSTEM_TAG_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/execution_policy.h>
31
+ #include __THRUST_HOST_SYSTEM_TAG_HEADER
32
+ #undef __THRUST_HOST_SYSTEM_TAG_HEADER
33
+
34
+ THRUST_NAMESPACE_BEGIN
35
+
36
+ typedef thrust::system::__THRUST_HOST_SYSTEM_NAMESPACE::tag host_system_tag;
37
+
38
+ THRUST_NAMESPACE_END
miniCUDA124/include/thrust/iterator/detail/is_iterator_category.h ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/iterator/iterator_categories.h>
29
+ #include <thrust/detail/type_traits.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+
33
+ namespace detail
34
+ {
35
+
36
+ template <typename T>
37
+ struct is_host_iterator_category
38
+ : thrust::detail::or_<
39
+ thrust::detail::is_convertible<T, thrust::input_host_iterator_tag>,
40
+ thrust::detail::is_convertible<T, thrust::output_host_iterator_tag>
41
+ >
42
+ {
43
+ }; // end is_host_iterator_category
44
+
45
+ template <typename T>
46
+ struct is_device_iterator_category
47
+ : thrust::detail::or_<
48
+ thrust::detail::is_convertible<T, thrust::input_device_iterator_tag>,
49
+ thrust::detail::is_convertible<T, thrust::output_device_iterator_tag>
50
+ >
51
+ {
52
+ }; // end is_device_iterator_category
53
+
54
+
55
+ template <typename T>
56
+ struct is_iterator_category
57
+ : thrust::detail::or_<
58
+ is_host_iterator_category<T>,
59
+ is_device_iterator_category<T>
60
+ >
61
+ {
62
+ }; // end is_iterator_category
63
+
64
+ } // end detail
65
+
66
+ THRUST_NAMESPACE_END
67
+
miniCUDA124/include/thrust/iterator/detail/iterator_adaptor_base.h ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/type_traits.h>
30
+ #include <thrust/iterator/iterator_traits.h>
31
+ #include <thrust/detail/use_default.h>
32
+ #include <thrust/iterator/iterator_facade.h>
33
+
34
+ THRUST_NAMESPACE_BEGIN
35
+
36
+
37
+ // forward declaration of iterator_adaptor for iterator_adaptor_base below
38
+ template<typename Derived,
39
+ typename Base,
40
+ typename Value,
41
+ typename System,
42
+ typename Traversal,
43
+ typename Reference,
44
+ typename Difference
45
+ >
46
+ class iterator_adaptor;
47
+
48
+
49
+ namespace detail
50
+ {
51
+
52
+ // If T is use_default, return the result of invoking
53
+ // DefaultNullaryFn, otherwise return T.
54
+ // XXX rename to dflt_help
55
+ template <class T, class DefaultNullaryFn>
56
+ struct ia_dflt_help
57
+ : thrust::detail::eval_if<
58
+ thrust::detail::is_same<T, thrust::use_default>::value
59
+ , DefaultNullaryFn
60
+ , thrust::detail::identity_<T>
61
+ >
62
+ {
63
+ }; // end ia_dflt_help
64
+
65
+
66
+ // A metafunction which computes an iterator_adaptor's base class,
67
+ // a specialization of iterator_facade.
68
+ template<typename Derived,
69
+ typename Base,
70
+ typename Value,
71
+ typename System,
72
+ typename Traversal,
73
+ typename Reference,
74
+ typename Difference
75
+ >
76
+ struct iterator_adaptor_base
77
+ {
78
+ typedef typename ia_dflt_help<
79
+ Value,
80
+ iterator_value<Base>
81
+ >::type value;
82
+
83
+ typedef typename ia_dflt_help<
84
+ System,
85
+ thrust::iterator_system<Base>
86
+ >::type system;
87
+
88
+ typedef typename ia_dflt_help<
89
+ Traversal,
90
+ thrust::iterator_traversal<Base>
91
+ >::type traversal;
92
+
93
+ typedef typename ia_dflt_help<
94
+ Reference,
95
+ thrust::detail::eval_if<
96
+ thrust::detail::is_same<Value,use_default>::value,
97
+ thrust::iterator_reference<Base>,
98
+ thrust::detail::add_reference<Value>
99
+ >
100
+ >::type reference;
101
+
102
+ typedef typename ia_dflt_help<
103
+ Difference,
104
+ iterator_difference<Base>
105
+ >::type difference;
106
+
107
+ typedef thrust::iterator_facade<
108
+ Derived,
109
+ value,
110
+ system,
111
+ traversal,
112
+ reference,
113
+ difference
114
+ > type;
115
+ }; // end iterator_adaptor_base
116
+
117
+
118
+ } // end detail
119
+ THRUST_NAMESPACE_END
120
+
miniCUDA124/include/thrust/iterator/detail/iterator_category_to_system.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/iterator/iterator_categories.h>
29
+ #include <thrust/iterator/detail/iterator_traversal_tags.h>
30
+ #include <thrust/iterator/detail/host_system_tag.h>
31
+ #include <thrust/iterator/detail/device_system_tag.h>
32
+ #include <thrust/iterator/detail/any_system_tag.h>
33
+ #include <thrust/detail/type_traits.h>
34
+
35
+ THRUST_NAMESPACE_BEGIN
36
+
37
+ namespace detail
38
+ {
39
+
40
+ // forward declaration
41
+ template <typename> struct is_iterator_system;
42
+
43
+ template <typename> struct device_iterator_category_to_backend_system;
44
+
45
+ // XXX this should work entirely differently
46
+ // we should just specialize this metafunction for iterator_category_with_system_and_traversal
47
+ template<typename Category>
48
+ struct iterator_category_to_system
49
+ // convertible to host iterator?
50
+ : eval_if<
51
+ or_<
52
+ is_convertible<Category, thrust::input_host_iterator_tag>,
53
+ is_convertible<Category, thrust::output_host_iterator_tag>
54
+ >::value,
55
+
56
+ detail::identity_<thrust::host_system_tag>,
57
+
58
+ // convertible to device iterator?
59
+ eval_if<
60
+ or_<
61
+ is_convertible<Category, thrust::input_device_iterator_tag>,
62
+ is_convertible<Category, thrust::output_device_iterator_tag>
63
+ >::value,
64
+
65
+ detail::identity_<thrust::device_system_tag>,
66
+
67
+ // unknown system
68
+ detail::identity_<void>
69
+ > // if device
70
+ > // if host
71
+ {
72
+ }; // end iterator_category_to_system
73
+
74
+
75
+ template<typename CategoryOrTraversal>
76
+ struct iterator_category_or_traversal_to_system
77
+ : eval_if<
78
+ is_iterator_system<CategoryOrTraversal>::value,
79
+ detail::identity_<CategoryOrTraversal>,
80
+ iterator_category_to_system<CategoryOrTraversal>
81
+ >
82
+ {
83
+ }; // end iterator_category_or_traversal_to_system
84
+
85
+ } // end detail
86
+ THRUST_NAMESPACE_END
87
+
miniCUDA124/include/thrust/iterator/detail/iterator_category_to_traversal.h ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/iterator/iterator_categories.h>
29
+ #include <thrust/iterator/detail/iterator_traversal_tags.h>
30
+ #include <thrust/iterator/detail/iterator_category_to_system.h>
31
+ #include <thrust/detail/type_traits.h>
32
+
33
+ THRUST_NAMESPACE_BEGIN
34
+
35
+ namespace detail
36
+ {
37
+
38
+ // forward declarations
39
+ template <typename> struct is_iterator_system;
40
+ template <typename> struct is_iterator_traversal;
41
+
42
+ template <typename Category>
43
+ struct host_system_category_to_traversal
44
+ : eval_if<
45
+ is_convertible<Category, random_access_host_iterator_tag>::value,
46
+ detail::identity_<random_access_traversal_tag>,
47
+ eval_if<
48
+ is_convertible<Category, bidirectional_host_iterator_tag>::value,
49
+ detail::identity_<bidirectional_traversal_tag>,
50
+ eval_if<
51
+ is_convertible<Category, forward_host_iterator_tag>::value,
52
+ detail::identity_<forward_traversal_tag>,
53
+ eval_if<
54
+ is_convertible<Category, input_host_iterator_tag>::value,
55
+ detail::identity_<single_pass_traversal_tag>,
56
+ eval_if<
57
+ is_convertible<Category, output_host_iterator_tag>::value,
58
+ detail::identity_<incrementable_traversal_tag>,
59
+ detail::identity_<void>
60
+ >
61
+ >
62
+ >
63
+ >
64
+ >
65
+ {
66
+ }; // end host_system_category_to_traversal
67
+
68
+
69
+
70
+ template <typename Category>
71
+ struct device_system_category_to_traversal
72
+ : eval_if<
73
+ is_convertible<Category, random_access_device_iterator_tag>::value,
74
+ detail::identity_<random_access_traversal_tag>,
75
+ eval_if<
76
+ is_convertible<Category, bidirectional_device_iterator_tag>::value,
77
+ detail::identity_<bidirectional_traversal_tag>,
78
+ eval_if<
79
+ is_convertible<Category, forward_device_iterator_tag>::value,
80
+ detail::identity_<forward_traversal_tag>,
81
+ eval_if<
82
+ is_convertible<Category, input_device_iterator_tag>::value,
83
+ detail::identity_<single_pass_traversal_tag>,
84
+ eval_if<
85
+ is_convertible<Category, output_device_iterator_tag>::value,
86
+ detail::identity_<incrementable_traversal_tag>,
87
+ detail::identity_<void>
88
+ >
89
+ >
90
+ >
91
+ >
92
+ >
93
+ {
94
+ }; // end device_system_category_to_traversal
95
+
96
+
97
+ template<typename Category>
98
+ struct category_to_traversal
99
+ // check for host system
100
+ : eval_if<
101
+ or_<
102
+ is_convertible<Category, thrust::input_host_iterator_tag>,
103
+ is_convertible<Category, thrust::output_host_iterator_tag>
104
+ >::value,
105
+
106
+ host_system_category_to_traversal<Category>,
107
+
108
+ // check for device system
109
+ eval_if<
110
+ or_<
111
+ is_convertible<Category, thrust::input_device_iterator_tag>,
112
+ is_convertible<Category, thrust::output_device_iterator_tag>
113
+ >::value,
114
+
115
+ device_system_category_to_traversal<Category>,
116
+
117
+ // unknown category
118
+ detail::identity_<void>
119
+ >
120
+ >
121
+ {};
122
+
123
+
124
+ template <typename CategoryOrTraversal>
125
+ struct iterator_category_to_traversal
126
+ : eval_if<
127
+ is_iterator_traversal<CategoryOrTraversal>::value,
128
+ detail::identity_<CategoryOrTraversal>,
129
+ category_to_traversal<CategoryOrTraversal>
130
+ >
131
+ {
132
+ }; // end iterator_category_to_traversal
133
+
134
+
135
+ } // end detail
136
+
137
+ THRUST_NAMESPACE_END
138
+
miniCUDA124/include/thrust/iterator/detail/iterator_category_with_system_and_traversal.h ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Category, typename System, typename Traversal>
35
+ struct iterator_category_with_system_and_traversal
36
+ : Category
37
+ {
38
+ }; // end iterator_category_with_system_and_traversal
39
+
40
+
41
+ // specialize iterator_category_to_system for iterator_category_with_system_and_traversal
42
+ template<typename Category> struct iterator_category_to_system;
43
+
44
+ template<typename Category, typename System, typename Traversal>
45
+ struct iterator_category_to_system<iterator_category_with_system_and_traversal<Category,System,Traversal> >
46
+ {
47
+ typedef System type;
48
+ }; // end iterator_category_to_system
49
+
50
+
51
+ // specialize iterator_category_to_traversal for iterator_category_with_system_and_traversal
52
+ template<typename Category> struct iterator_category_to_traversal;
53
+
54
+ template<typename Category, typename System, typename Traversal>
55
+ struct iterator_category_to_traversal<iterator_category_with_system_and_traversal<Category,System,Traversal> >
56
+ {
57
+ typedef Traversal type;
58
+ }; // end iterator_category_to_traversal
59
+
60
+
61
+
62
+ } // end detail
63
+ THRUST_NAMESPACE_END
64
+
miniCUDA124/include/thrust/iterator/detail/iterator_facade_category.h ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/iterator/detail/host_system_tag.h>
30
+ #include <thrust/iterator/detail/device_system_tag.h>
31
+ #include <thrust/iterator/detail/any_system_tag.h>
32
+ #include <thrust/iterator/iterator_categories.h>
33
+ #include <thrust/iterator/detail/iterator_traversal_tags.h>
34
+ #include <thrust/iterator/detail/is_iterator_category.h>
35
+ #include <thrust/iterator/detail/iterator_category_with_system_and_traversal.h>
36
+ #include <thrust/iterator/detail/iterator_category_to_traversal.h>
37
+
38
+ THRUST_NAMESPACE_BEGIN
39
+
40
+ namespace detail
41
+ {
42
+
43
+
44
+ // adapted from http://www.boost.org/doc/libs/1_37_0/libs/iterator/doc/iterator_facade.html#iterator-category
45
+ //
46
+ // in our implementation, R need not be a reference type to result in a category
47
+ // derived from forward_XXX_iterator_tag
48
+ //
49
+ // iterator-category(T,V,R) :=
50
+ // if(T is convertible to input_host_iterator_tag
51
+ // || T is convertible to output_host_iterator_tag
52
+ // || T is convertible to input_device_iterator_tag
53
+ // || T is convertible to output_device_iterator_tag
54
+ // )
55
+ // return T
56
+ //
57
+ // else if (T is not convertible to incrementable_traversal_tag)
58
+ // the program is ill-formed
59
+ //
60
+ // else return a type X satisfying the following two constraints:
61
+ //
62
+ // 1. X is convertible to X1, and not to any more-derived
63
+ // type, where X1 is defined by:
64
+ //
65
+ // if (T is convertible to forward_traversal_tag)
66
+ // {
67
+ // if (T is convertible to random_access_traversal_tag)
68
+ // X1 = random_access_host_iterator_tag
69
+ // else if (T is convertible to bidirectional_traversal_tag)
70
+ // X1 = bidirectional_host_iterator_tag
71
+ // else
72
+ // X1 = forward_host_iterator_tag
73
+ // }
74
+ // else
75
+ // {
76
+ // if (T is convertible to single_pass_traversal_tag
77
+ // && R is convertible to V)
78
+ // X1 = input_host_iterator_tag
79
+ // else
80
+ // X1 = T
81
+ // }
82
+ //
83
+ // 2. category-to-traversal(X) is convertible to the most
84
+ // derived traversal tag type to which X is also convertible,
85
+ // and not to any more-derived traversal tag type.
86
+
87
+
88
+ template<typename System, typename Traversal, typename ValueParam, typename Reference>
89
+ struct iterator_facade_default_category;
90
+
91
+
92
+ // Thrust's implementation of iterator_facade_default_category is slightly
93
+ // different from Boost's equivalent.
94
+ // Thrust does not check is_convertible<Reference, ValueParam> because Reference
95
+ // may not be a complete type at this point, and implementations of is_convertible
96
+ // typically require that both types be complete.
97
+ // Instead, it simply assumes that if is_convertible<Traversal, single_pass_traversal_tag>,
98
+ // then the category is input_iterator_tag
99
+
100
+
101
+ // this is the function for standard system iterators
102
+ template<typename Traversal, typename ValueParam, typename Reference>
103
+ struct iterator_facade_default_category_std :
104
+ thrust::detail::eval_if<
105
+ thrust::detail::is_convertible<Traversal, thrust::forward_traversal_tag>::value,
106
+ thrust::detail::eval_if<
107
+ thrust::detail::is_convertible<Traversal, thrust::random_access_traversal_tag>::value,
108
+ thrust::detail::identity_<std::random_access_iterator_tag>,
109
+ thrust::detail::eval_if<
110
+ thrust::detail::is_convertible<Traversal, thrust::bidirectional_traversal_tag>::value,
111
+ thrust::detail::identity_<std::bidirectional_iterator_tag>,
112
+ thrust::detail::identity_<std::forward_iterator_tag>
113
+ >
114
+ >,
115
+ thrust::detail::eval_if< // XXX note we differ from Boost here
116
+ thrust::detail::is_convertible<Traversal, thrust::single_pass_traversal_tag>::value,
117
+ thrust::detail::identity_<std::input_iterator_tag>,
118
+ thrust::detail::identity_<Traversal>
119
+ >
120
+ >
121
+ {
122
+ }; // end iterator_facade_default_category_std
123
+
124
+
125
+ // this is the function for host system iterators
126
+ template<typename Traversal, typename ValueParam, typename Reference>
127
+ struct iterator_facade_default_category_host :
128
+ thrust::detail::eval_if<
129
+ thrust::detail::is_convertible<Traversal, thrust::forward_traversal_tag>::value,
130
+ thrust::detail::eval_if<
131
+ thrust::detail::is_convertible<Traversal, thrust::random_access_traversal_tag>::value,
132
+ thrust::detail::identity_<thrust::random_access_host_iterator_tag>,
133
+ thrust::detail::eval_if<
134
+ thrust::detail::is_convertible<Traversal, thrust::bidirectional_traversal_tag>::value,
135
+ thrust::detail::identity_<thrust::bidirectional_host_iterator_tag>,
136
+ thrust::detail::identity_<thrust::forward_host_iterator_tag>
137
+ >
138
+ >,
139
+ thrust::detail::eval_if< // XXX note we differ from Boost here
140
+ thrust::detail::is_convertible<Traversal, thrust::single_pass_traversal_tag>::value,
141
+ thrust::detail::identity_<thrust::input_host_iterator_tag>,
142
+ thrust::detail::identity_<Traversal>
143
+ >
144
+ >
145
+ {
146
+ }; // end iterator_facade_default_category_host
147
+
148
+
149
+ // this is the function for device system iterators
150
+ template<typename Traversal, typename ValueParam, typename Reference>
151
+ struct iterator_facade_default_category_device :
152
+ thrust::detail::eval_if<
153
+ thrust::detail::is_convertible<Traversal, thrust::forward_traversal_tag>::value,
154
+ thrust::detail::eval_if<
155
+ thrust::detail::is_convertible<Traversal, thrust::random_access_traversal_tag>::value,
156
+ thrust::detail::identity_<thrust::random_access_device_iterator_tag>,
157
+ thrust::detail::eval_if<
158
+ thrust::detail::is_convertible<Traversal, thrust::bidirectional_traversal_tag>::value,
159
+ thrust::detail::identity_<thrust::bidirectional_device_iterator_tag>,
160
+ thrust::detail::identity_<thrust::forward_device_iterator_tag>
161
+ >
162
+ >,
163
+ thrust::detail::eval_if<
164
+ thrust::detail::is_convertible<Traversal, thrust::single_pass_traversal_tag>::value, // XXX note we differ from Boost here
165
+ thrust::detail::identity_<thrust::input_device_iterator_tag>,
166
+ thrust::detail::identity_<Traversal>
167
+ >
168
+ >
169
+ {
170
+ }; // end iterator_facade_default_category_device
171
+
172
+
173
+ // this is the function for any system iterators
174
+ template<typename Traversal, typename ValueParam, typename Reference>
175
+ struct iterator_facade_default_category_any
176
+ {
177
+ typedef thrust::detail::iterator_category_with_system_and_traversal<
178
+ typename iterator_facade_default_category_std<Traversal, ValueParam, Reference>::type,
179
+ thrust::any_system_tag,
180
+ Traversal
181
+ > type;
182
+ }; // end iterator_facade_default_category_any
183
+
184
+
185
+ template<typename System, typename Traversal, typename ValueParam, typename Reference>
186
+ struct iterator_facade_default_category
187
+ // check for any system
188
+ : thrust::detail::eval_if<
189
+ thrust::detail::is_convertible<System, thrust::any_system_tag>::value,
190
+ iterator_facade_default_category_any<Traversal, ValueParam, Reference>,
191
+
192
+ // check for host system
193
+ thrust::detail::eval_if<
194
+ thrust::detail::is_convertible<System, thrust::host_system_tag>::value,
195
+ iterator_facade_default_category_host<Traversal, ValueParam, Reference>,
196
+
197
+ // check for device system
198
+ thrust::detail::eval_if<
199
+ thrust::detail::is_convertible<System, thrust::device_system_tag>::value,
200
+ iterator_facade_default_category_device<Traversal, ValueParam, Reference>,
201
+
202
+ // if we don't recognize the system, get a standard iterator category
203
+ // and combine it with System & Traversal
204
+ thrust::detail::identity_<
205
+ thrust::detail::iterator_category_with_system_and_traversal<
206
+ typename iterator_facade_default_category_std<Traversal, ValueParam, Reference>::type,
207
+ System,
208
+ Traversal
209
+ >
210
+ >
211
+ >
212
+ >
213
+ >
214
+ {};
215
+
216
+
217
+ template<typename System, typename Traversal, typename ValueParam, typename Reference>
218
+ struct iterator_facade_category_impl
219
+ {
220
+ typedef typename iterator_facade_default_category<
221
+ System,Traversal,ValueParam,Reference
222
+ >::type category;
223
+
224
+ // we must be able to deduce both Traversal & System from category
225
+ // otherwise, munge them all together
226
+ typedef typename thrust::detail::eval_if<
227
+ thrust::detail::and_<
228
+ thrust::detail::is_same<
229
+ Traversal,
230
+ typename thrust::detail::iterator_category_to_traversal<category>::type
231
+ >,
232
+ thrust::detail::is_same<
233
+ System,
234
+ typename thrust::detail::iterator_category_to_system<category>::type
235
+ >
236
+ >::value,
237
+ thrust::detail::identity_<category>,
238
+ thrust::detail::identity_<thrust::detail::iterator_category_with_system_and_traversal<category,System,Traversal> >
239
+ >::type type;
240
+ }; // end iterator_facade_category_impl
241
+
242
+
243
+ template<typename CategoryOrSystem,
244
+ typename CategoryOrTraversal,
245
+ typename ValueParam,
246
+ typename Reference>
247
+ struct iterator_facade_category
248
+ {
249
+ typedef typename
250
+ thrust::detail::eval_if<
251
+ thrust::detail::is_iterator_category<CategoryOrTraversal>::value,
252
+ thrust::detail::identity_<CategoryOrTraversal>, // categories are fine as-is
253
+ iterator_facade_category_impl<CategoryOrSystem, CategoryOrTraversal, ValueParam, Reference>
254
+ >::type type;
255
+ }; // end iterator_facade_category
256
+
257
+
258
+ } // end detail
259
+ THRUST_NAMESPACE_END
260
+
miniCUDA124/include/thrust/iterator/detail/iterator_traits.inl 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
+
29
+ #include <thrust/iterator/iterator_categories.h>
30
+ #include <thrust/iterator/detail/iterator_category_to_traversal.h>
31
+ #include <thrust/detail/type_traits.h>
32
+ #include <thrust/type_traits/void_t.h>
33
+
34
+ THRUST_NAMESPACE_BEGIN
35
+
36
+ template<typename Iterator>
37
+ struct iterator_value
38
+ {
39
+ typedef typename thrust::iterator_traits<Iterator>::value_type type;
40
+ }; // end iterator_value
41
+
42
+ template <typename Iterator>
43
+ using iterator_value_t = typename iterator_value<Iterator>::type;
44
+
45
+ template<typename Iterator>
46
+ struct iterator_pointer
47
+ {
48
+ typedef typename thrust::iterator_traits<Iterator>::pointer type;
49
+ }; // end iterator_pointer
50
+
51
+ template <typename Iterator>
52
+ using iterator_pointer_t = typename iterator_pointer<Iterator>::type;
53
+
54
+ template<typename Iterator>
55
+ struct iterator_reference
56
+ {
57
+ typedef typename iterator_traits<Iterator>::reference type;
58
+ }; // end iterator_reference
59
+
60
+ template <typename Iterator>
61
+ using iterator_reference_t = typename iterator_reference<Iterator>::type;
62
+
63
+ template<typename Iterator>
64
+ struct iterator_difference
65
+ {
66
+ typedef typename thrust::iterator_traits<Iterator>::difference_type type;
67
+ }; // end iterator_difference
68
+
69
+ template <typename Iterator>
70
+ using iterator_difference_t = typename iterator_difference<Iterator>::type;
71
+
72
+ namespace detail
73
+ {
74
+
75
+ template <typename Iterator, typename = void>
76
+ struct iterator_system_impl {};
77
+
78
+ template <typename Iterator>
79
+ struct iterator_system_impl<
80
+ Iterator
81
+ , typename voider<
82
+ typename iterator_traits<Iterator>::iterator_category
83
+ >::type
84
+ >
85
+ : detail::iterator_category_to_system<
86
+ typename iterator_traits<Iterator>::iterator_category
87
+ >
88
+ {};
89
+
90
+ } // namespace detail
91
+
92
+ template <typename Iterator>
93
+ struct iterator_system : detail::iterator_system_impl<Iterator> {};
94
+
95
+ // specialize iterator_system for void *, which has no category
96
+ template<>
97
+ struct iterator_system<void *>
98
+ {
99
+ typedef thrust::iterator_system<int*>::type type;
100
+ }; // end iterator_system<void*>
101
+
102
+ template<>
103
+ struct iterator_system<const void *>
104
+ {
105
+ typedef thrust::iterator_system<const int*>::type type;
106
+ }; // end iterator_system<void*>
107
+
108
+ template <typename Iterator>
109
+ using iterator_system_t = typename iterator_system<Iterator>::type;
110
+
111
+ template <typename Iterator>
112
+ struct iterator_traversal
113
+ : detail::iterator_category_to_traversal<
114
+ typename thrust::iterator_traits<Iterator>::iterator_category
115
+ >
116
+ {
117
+ }; // end iterator_traversal
118
+
119
+ namespace detail
120
+ {
121
+
122
+ template <typename T>
123
+ struct is_iterator_traversal
124
+ : thrust::detail::is_convertible<T, incrementable_traversal_tag>
125
+ {
126
+ }; // end is_iterator_traversal
127
+
128
+
129
+ template<typename T>
130
+ struct is_iterator_system
131
+ : detail::or_<
132
+ detail::is_convertible<T, any_system_tag>,
133
+ detail::or_<
134
+ detail::is_convertible<T, host_system_tag>,
135
+ detail::is_convertible<T, device_system_tag>
136
+ >
137
+ >
138
+ {
139
+ }; // end is_iterator_system
140
+
141
+
142
+ } // end namespace detail
143
+ THRUST_NAMESPACE_END
144
+
miniCUDA124/include/thrust/iterator/detail/minimum_system.h ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/type_traits/is_metafunction_defined.h>
30
+ #include <thrust/detail/type_traits/minimum_type.h>
31
+
32
+ THRUST_NAMESPACE_BEGIN
33
+ namespace detail
34
+ {
35
+
36
+
37
+ template<typename T1,
38
+ typename T2 = void,
39
+ typename T3 = void,
40
+ typename T4 = void,
41
+ typename T5 = void,
42
+ typename T6 = void,
43
+ typename T7 = void,
44
+ typename T8 = void,
45
+ typename T9 = void,
46
+ typename T10 = void,
47
+ typename T11 = void,
48
+ typename T12 = void,
49
+ typename T13 = void,
50
+ typename T14 = void,
51
+ typename T15 = void,
52
+ typename T16 = void>
53
+ struct unrelated_systems {};
54
+
55
+
56
+ // if a minimum system exists for these arguments, return it
57
+ // otherwise, collect the arguments and report them as unrelated
58
+ template<typename T1,
59
+ typename T2 = minimum_type_detail::any_conversion,
60
+ typename T3 = minimum_type_detail::any_conversion,
61
+ typename T4 = minimum_type_detail::any_conversion,
62
+ typename T5 = minimum_type_detail::any_conversion,
63
+ typename T6 = minimum_type_detail::any_conversion,
64
+ typename T7 = minimum_type_detail::any_conversion,
65
+ typename T8 = minimum_type_detail::any_conversion,
66
+ typename T9 = minimum_type_detail::any_conversion,
67
+ typename T10 = minimum_type_detail::any_conversion,
68
+ typename T11 = minimum_type_detail::any_conversion,
69
+ typename T12 = minimum_type_detail::any_conversion,
70
+ typename T13 = minimum_type_detail::any_conversion,
71
+ typename T14 = minimum_type_detail::any_conversion,
72
+ typename T15 = minimum_type_detail::any_conversion,
73
+ typename T16 = minimum_type_detail::any_conversion>
74
+ struct minimum_system
75
+ : thrust::detail::eval_if<
76
+ is_metafunction_defined<
77
+ minimum_type<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>
78
+ >::value,
79
+ minimum_type<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>,
80
+ thrust::detail::identity_<
81
+ unrelated_systems<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>
82
+ >
83
+ >
84
+ {}; // end minimum_system
85
+
86
+
87
+ } // end detail
88
+ THRUST_NAMESPACE_END
89
+
miniCUDA124/include/thrust/iterator/detail/normal_iterator.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
+
18
+ /*! \file normal_iterator.h
19
+ * \brief Defines the interface to an iterator class
20
+ * which adapts a pointer type.
21
+ */
22
+
23
+ #pragma once
24
+
25
+ #include <thrust/detail/config.h>
26
+
27
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
28
+ # pragma GCC system_header
29
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
30
+ # pragma clang system_header
31
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
32
+ # pragma system_header
33
+ #endif // no system header
34
+
35
+ #include <thrust/iterator/iterator_adaptor.h>
36
+ #include <thrust/detail/type_traits.h>
37
+ #include <thrust/type_traits/is_contiguous_iterator.h>
38
+
39
+ THRUST_NAMESPACE_BEGIN
40
+ namespace detail
41
+ {
42
+
43
+
44
+ template<typename Pointer>
45
+ class normal_iterator
46
+ : public iterator_adaptor<
47
+ normal_iterator<Pointer>,
48
+ Pointer
49
+ >
50
+ {
51
+ typedef iterator_adaptor<normal_iterator<Pointer>, Pointer> super_t;
52
+
53
+ public:
54
+ __host__ __device__
55
+ normal_iterator() {}
56
+
57
+ __host__ __device__
58
+ normal_iterator(Pointer p)
59
+ : super_t(p) {}
60
+
61
+ template<typename OtherPointer>
62
+ __host__ __device__
63
+ normal_iterator(const normal_iterator<OtherPointer> &other,
64
+ typename thrust::detail::enable_if_convertible<
65
+ OtherPointer,
66
+ Pointer
67
+ >::type * = 0)
68
+ : super_t(other.base()) {}
69
+
70
+ }; // end normal_iterator
71
+
72
+
73
+ template<typename Pointer>
74
+ inline __host__ __device__ normal_iterator<Pointer> make_normal_iterator(Pointer ptr)
75
+ {
76
+ return normal_iterator<Pointer>(ptr);
77
+ }
78
+
79
+ } // end detail
80
+
81
+ template <typename T>
82
+ struct proclaim_contiguous_iterator<
83
+ thrust::detail::normal_iterator<T>
84
+ > : true_type {};
85
+
86
+ THRUST_NAMESPACE_END
87
+
miniCUDA124/include/thrust/iterator/detail/permutation_iterator_base.h ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/iterator/iterator_adaptor.h>
30
+ #include <thrust/iterator/iterator_traits.h>
31
+ #include <thrust/detail/type_traits.h>
32
+ #include <thrust/iterator/detail/minimum_system.h>
33
+
34
+ THRUST_NAMESPACE_BEGIN
35
+
36
+ template<typename,typename> class permutation_iterator;
37
+
38
+
39
+ namespace detail
40
+ {
41
+
42
+ template<typename ElementIterator,
43
+ typename IndexIterator>
44
+ struct permutation_iterator_base
45
+ {
46
+ typedef typename thrust::iterator_system<ElementIterator>::type System1;
47
+ typedef typename thrust::iterator_system<IndexIterator>::type System2;
48
+
49
+ typedef thrust::iterator_adaptor<
50
+ permutation_iterator<ElementIterator,IndexIterator>,
51
+ IndexIterator,
52
+ typename thrust::iterator_value<ElementIterator>::type,
53
+ typename detail::minimum_system<System1,System2>::type,
54
+ thrust::use_default,
55
+ typename thrust::iterator_reference<ElementIterator>::type
56
+ > type;
57
+ }; // end permutation_iterator_base
58
+
59
+ } // end detail
60
+
61
+ THRUST_NAMESPACE_END
62
+
miniCUDA124/include/thrust/iterator/detail/retag.h ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/iterator/detail/tagged_iterator.h>
30
+ #include <thrust/detail/pointer.h>
31
+
32
+ THRUST_NAMESPACE_BEGIN
33
+ namespace detail
34
+ {
35
+
36
+
37
+ // we can retag an iterator if FromTag converts to ToTag
38
+ // or vice versa
39
+ template<typename FromTag, typename ToTag>
40
+ struct is_retaggable
41
+ : integral_constant<
42
+ bool,
43
+ (is_convertible<FromTag,ToTag>::value || is_convertible<ToTag,FromTag>::value)
44
+ >
45
+ {};
46
+
47
+
48
+ template<typename FromTag, typename ToTag, typename Result>
49
+ struct enable_if_retaggable
50
+ : enable_if<
51
+ is_retaggable<FromTag,ToTag>::value,
52
+ Result
53
+ >
54
+ {}; // end enable_if_retaggable
55
+
56
+
57
+ } // end detail
58
+
59
+
60
+ template<typename Tag, typename Iterator>
61
+ __host__ __device__
62
+ thrust::detail::tagged_iterator<Iterator,Tag>
63
+ reinterpret_tag(Iterator iter)
64
+ {
65
+ return thrust::detail::tagged_iterator<Iterator,Tag>(iter);
66
+ } // end reinterpret_tag()
67
+
68
+
69
+ // specialization for raw pointer
70
+ template<typename Tag, typename T>
71
+ __host__ __device__
72
+ thrust::pointer<T,Tag>
73
+ reinterpret_tag(T *ptr)
74
+ {
75
+ return thrust::pointer<T,Tag>(ptr);
76
+ } // end reinterpret_tag()
77
+
78
+
79
+ // specialization for thrust::pointer
80
+ template<typename Tag, typename T, typename OtherTag, typename Reference, typename Derived>
81
+ __host__ __device__
82
+ thrust::pointer<T,Tag>
83
+ reinterpret_tag(thrust::pointer<T,OtherTag,Reference,Derived> ptr)
84
+ {
85
+ return reinterpret_tag<Tag>(ptr.get());
86
+ } // end reinterpret_tag()
87
+
88
+
89
+ // avoid deeply-nested tagged_iterator
90
+ template<typename Tag, typename BaseIterator, typename OtherTag>
91
+ __host__ __device__
92
+ thrust::detail::tagged_iterator<BaseIterator,Tag>
93
+ reinterpret_tag(thrust::detail::tagged_iterator<BaseIterator,OtherTag> iter)
94
+ {
95
+ return reinterpret_tag<Tag>(iter.base());
96
+ } // end reinterpret_tag()
97
+
98
+
99
+ template<typename Tag, typename Iterator>
100
+ __host__ __device__
101
+ typename thrust::detail::enable_if_retaggable<
102
+ typename thrust::iterator_system<Iterator>::type,
103
+ Tag,
104
+ thrust::detail::tagged_iterator<Iterator,Tag>
105
+ >::type
106
+ retag(Iterator iter)
107
+ {
108
+ return reinterpret_tag<Tag>(iter);
109
+ } // end retag()
110
+
111
+
112
+ // specialization for raw pointer
113
+ template<typename Tag, typename T>
114
+ __host__ __device__
115
+ typename thrust::detail::enable_if_retaggable<
116
+ typename thrust::iterator_system<T*>::type,
117
+ Tag,
118
+ thrust::pointer<T,Tag>
119
+ >::type
120
+ retag(T *ptr)
121
+ {
122
+ return reinterpret_tag<Tag>(ptr);
123
+ } // end retag()
124
+
125
+
126
+ // specialization for thrust::pointer
127
+ template<typename Tag, typename T, typename OtherTag>
128
+ __host__ __device__
129
+ typename thrust::detail::enable_if_retaggable<
130
+ OtherTag,
131
+ Tag,
132
+ thrust::pointer<T,Tag>
133
+ >::type
134
+ retag(thrust::pointer<T,OtherTag> ptr)
135
+ {
136
+ return reinterpret_tag<Tag>(ptr);
137
+ } // end retag()
138
+
139
+
140
+ // avoid deeply-nested tagged_iterator
141
+ template<typename Tag, typename BaseIterator, typename OtherTag>
142
+ __host__ __device__
143
+ typename thrust::detail::enable_if_retaggable<
144
+ OtherTag,
145
+ Tag,
146
+ thrust::detail::tagged_iterator<BaseIterator,Tag>
147
+ >::type
148
+ retag(thrust::detail::tagged_iterator<BaseIterator,OtherTag> iter)
149
+ {
150
+ return reinterpret_tag<Tag>(iter);
151
+ } // end retag()
152
+
153
+
154
+ THRUST_NAMESPACE_END
155
+
miniCUDA124/include/thrust/iterator/detail/reverse_iterator.inl ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/iterator/reverse_iterator.h>
30
+ #include <thrust/iterator/iterator_traits.h>
31
+
32
+ THRUST_NAMESPACE_BEGIN
33
+
34
+ namespace detail
35
+ {
36
+
37
+ __thrust_exec_check_disable__
38
+ template<typename Iterator>
39
+ __host__ __device__
40
+ Iterator prior(Iterator x)
41
+ {
42
+ return --x;
43
+ } // end prior()
44
+
45
+ } // end detail
46
+
47
+ template<typename BidirectionalIterator>
48
+ __host__ __device__
49
+ reverse_iterator<BidirectionalIterator>
50
+ ::reverse_iterator(BidirectionalIterator x)
51
+ :super_t(x)
52
+ {
53
+ } // end reverse_iterator::reverse_iterator()
54
+
55
+ template<typename BidirectionalIterator>
56
+ template<typename OtherBidirectionalIterator>
57
+ __host__ __device__
58
+ reverse_iterator<BidirectionalIterator>
59
+ ::reverse_iterator(reverse_iterator<OtherBidirectionalIterator> const &r
60
+ // XXX msvc screws this up
61
+ #if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC
62
+ , typename thrust::detail::enable_if<
63
+ thrust::detail::is_convertible<
64
+ OtherBidirectionalIterator,
65
+ BidirectionalIterator
66
+ >::value
67
+ >::type *
68
+ #endif // MSVC
69
+ )
70
+ :super_t(r.base())
71
+ {
72
+ } // end reverse_iterator::reverse_iterator()
73
+
74
+ template<typename BidirectionalIterator>
75
+ __host__ __device__
76
+ typename reverse_iterator<BidirectionalIterator>::super_t::reference
77
+ reverse_iterator<BidirectionalIterator>
78
+ ::dereference() const
79
+ {
80
+ return *thrust::detail::prior(this->base());
81
+ } // end reverse_iterator::increment()
82
+
83
+ template<typename BidirectionalIterator>
84
+ __host__ __device__
85
+ void reverse_iterator<BidirectionalIterator>
86
+ ::increment()
87
+ {
88
+ --this->base_reference();
89
+ } // end reverse_iterator::increment()
90
+
91
+ template<typename BidirectionalIterator>
92
+ __host__ __device__
93
+ void reverse_iterator<BidirectionalIterator>
94
+ ::decrement()
95
+ {
96
+ ++this->base_reference();
97
+ } // end reverse_iterator::decrement()
98
+
99
+ template<typename BidirectionalIterator>
100
+ __host__ __device__
101
+ void reverse_iterator<BidirectionalIterator>
102
+ ::advance(typename super_t::difference_type n)
103
+ {
104
+ this->base_reference() += -n;
105
+ } // end reverse_iterator::advance()
106
+
107
+ template<typename BidirectionalIterator>
108
+ template<typename OtherBidirectionalIterator>
109
+ __host__ __device__
110
+ typename reverse_iterator<BidirectionalIterator>::super_t::difference_type
111
+ reverse_iterator<BidirectionalIterator>
112
+ ::distance_to(reverse_iterator<OtherBidirectionalIterator> const &y) const
113
+ {
114
+ return this->base_reference() - y.base();
115
+ } // end reverse_iterator::distance_to()
116
+
117
+ template<typename BidirectionalIterator>
118
+ __host__ __device__
119
+ reverse_iterator<BidirectionalIterator> make_reverse_iterator(BidirectionalIterator x)
120
+ {
121
+ return reverse_iterator<BidirectionalIterator>(x);
122
+ } // end make_reverse_iterator()
123
+
124
+
125
+ THRUST_NAMESPACE_END
126
+
miniCUDA124/include/thrust/iterator/detail/reverse_iterator_base.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
+ #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/iterator/iterator_adaptor.h>
30
+ #include <thrust/iterator/iterator_traits.h>
31
+
32
+ THRUST_NAMESPACE_BEGIN
33
+
34
+ template <typename> class reverse_iterator;
35
+
36
+ namespace detail
37
+ {
38
+
39
+ template<typename BidirectionalIterator>
40
+ struct reverse_iterator_base
41
+ {
42
+ typedef thrust::iterator_adaptor<
43
+ thrust::reverse_iterator<BidirectionalIterator>,
44
+ BidirectionalIterator
45
+ > type;
46
+ }; // end reverse_iterator_base
47
+
48
+ } // end detail
49
+
50
+ THRUST_NAMESPACE_END
51
+
miniCUDA124/include/thrust/iterator/detail/tagged_iterator.h ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/iterator/iterator_adaptor.h>
29
+ #include <thrust/iterator/iterator_traits.h>
30
+ #include <thrust/detail/use_default.h>
31
+ #include <thrust/type_traits/is_contiguous_iterator.h>
32
+
33
+ THRUST_NAMESPACE_BEGIN
34
+ namespace detail
35
+ {
36
+
37
+ template <typename,typename> class tagged_iterator;
38
+
39
+ template<typename Iterator, typename Tag>
40
+ struct tagged_iterator_base
41
+ {
42
+ typedef thrust::iterator_adaptor<
43
+ tagged_iterator<Iterator,Tag>,
44
+ Iterator,
45
+ typename thrust::iterator_value<Iterator>::type,
46
+ Tag,
47
+ typename thrust::iterator_traversal<Iterator>::type,
48
+ typename thrust::iterator_reference<Iterator>::type,
49
+ typename thrust::iterator_difference<Iterator>::type
50
+ > type;
51
+ }; // end tagged_iterator_base
52
+
53
+ template<typename Iterator, typename Tag>
54
+ class tagged_iterator
55
+ : public tagged_iterator_base<Iterator,Tag>::type
56
+ {
57
+ private:
58
+ typedef typename tagged_iterator_base<Iterator,Tag>::type super_t;
59
+
60
+ public:
61
+ __host__ __device__
62
+ tagged_iterator() {}
63
+
64
+ __host__ __device__
65
+ explicit tagged_iterator(Iterator x)
66
+ : super_t(x) {}
67
+ }; // end tagged_iterator
68
+
69
+ /*! \p make_tagged_iterator creates a \p tagged_iterator
70
+ * from a \c Iterator with system tag \c Tag.
71
+ *
72
+ * \tparam Tag Any system tag.
73
+ * \tparam Iterator Any iterator type.
74
+ * \param iter The iterator of interest.
75
+ * \return An iterator whose system tag is \p Tag and whose behavior is otherwise
76
+ * equivalent to \p iter.
77
+ */
78
+ template <typename Tag, typename Iterator>
79
+ inline auto make_tagged_iterator(Iterator iter) -> tagged_iterator<Iterator, Tag>
80
+ {
81
+ return tagged_iterator<Iterator, Tag>(iter);
82
+ }
83
+
84
+ } // end detail
85
+
86
+ // tagged_iterator is trivial if its base iterator is.
87
+ template <typename BaseIterator, typename Tag>
88
+ struct proclaim_contiguous_iterator<
89
+ detail::tagged_iterator<BaseIterator, Tag>
90
+ > : is_contiguous_iterator<BaseIterator> {};
91
+
92
+ THRUST_NAMESPACE_END
93
+
miniCUDA124/include/thrust/iterator/detail/transform_input_output_iterator.inl ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2020-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+ #include <thrust/iterator/iterator_adaptor.h>
29
+ #include <thrust/detail/type_traits.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+
33
+ template <typename InputFunction, typename OutputFunction, typename Iterator>
34
+ class transform_input_output_iterator;
35
+
36
+ namespace detail
37
+ {
38
+
39
+ // Proxy reference that invokes InputFunction when reading from and
40
+ // OutputFunction when writing to the dereferenced iterator
41
+ template <typename InputFunction, typename OutputFunction, typename Iterator>
42
+ class transform_input_output_iterator_proxy
43
+ {
44
+ using iterator_value_type = typename thrust::iterator_value<Iterator>::type;
45
+
46
+ using Value = invoke_result_t<InputFunction, iterator_value_type>;
47
+
48
+ public:
49
+ __host__ __device__
50
+ transform_input_output_iterator_proxy(const Iterator& io, InputFunction input_function, OutputFunction output_function)
51
+ : io(io), input_function(input_function), output_function(output_function)
52
+ {
53
+ }
54
+
55
+ transform_input_output_iterator_proxy(const transform_input_output_iterator_proxy&) = default;
56
+
57
+ __thrust_exec_check_disable__
58
+ __host__ __device__
59
+ operator Value const() const
60
+ {
61
+ return input_function(*io);
62
+ }
63
+
64
+ __thrust_exec_check_disable__
65
+ template <typename T>
66
+ __host__ __device__
67
+ transform_input_output_iterator_proxy operator=(const T& x)
68
+ {
69
+ *io = output_function(x);
70
+ return *this;
71
+ }
72
+
73
+ __thrust_exec_check_disable__
74
+ __host__ __device__
75
+ transform_input_output_iterator_proxy operator=(const transform_input_output_iterator_proxy& x)
76
+ {
77
+ *io = output_function(x);
78
+ return *this;
79
+ }
80
+
81
+ private:
82
+ Iterator io;
83
+ InputFunction input_function;
84
+ OutputFunction output_function;
85
+ };
86
+
87
+ // Compute the iterator_adaptor instantiation to be used for transform_input_output_iterator
88
+ template <typename InputFunction, typename OutputFunction, typename Iterator>
89
+ struct transform_input_output_iterator_base
90
+ {
91
+ private:
92
+ using iterator_value_type = typename thrust::iterator_value<Iterator>::type;
93
+
94
+ public:
95
+ typedef thrust::iterator_adaptor
96
+ <
97
+ transform_input_output_iterator<InputFunction, OutputFunction, Iterator>
98
+ , Iterator
99
+ , detail::invoke_result_t<InputFunction, iterator_value_type>
100
+ , thrust::use_default
101
+ , thrust::use_default
102
+ , transform_input_output_iterator_proxy<InputFunction, OutputFunction, Iterator>
103
+ > type;
104
+ };
105
+
106
+ // Register transform_input_output_iterator_proxy with 'is_proxy_reference' from
107
+ // type_traits to enable its use with algorithms.
108
+ template <typename InputFunction, typename OutputFunction, typename Iterator>
109
+ struct is_proxy_reference<
110
+ transform_input_output_iterator_proxy<InputFunction, OutputFunction, Iterator> >
111
+ : public thrust::detail::true_type {};
112
+
113
+ } // end detail
114
+ THRUST_NAMESPACE_END
115
+
miniCUDA124/include/thrust/iterator/detail/transform_iterator.inl ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+ #include <thrust/detail/type_traits.h>
29
+ #include <thrust/detail/type_traits/result_of_adaptable_function.h>
30
+ #include <thrust/iterator/iterator_adaptor.h>
31
+ #include <thrust/iterator/iterator_traits.h>
32
+ #include <thrust/iterator/transform_iterator.h>
33
+ #include <thrust/type_traits/remove_cvref.h>
34
+
35
+ THRUST_NAMESPACE_BEGIN
36
+
37
+ template <class UnaryFunction, class Iterator, class Reference, class Value>
38
+ class transform_iterator;
39
+
40
+ namespace detail
41
+ {
42
+
43
+ // Compute the iterator_adaptor instantiation to be used for transform_iterator
44
+ template <class UnaryFunc, class Iterator, class Reference, class Value>
45
+ struct transform_iterator_base
46
+ {
47
+ private:
48
+ // By default, dereferencing the iterator yields the same as the function.
49
+ typedef typename thrust::detail::ia_dflt_help<
50
+ Reference,
51
+ thrust::detail::result_of_adaptable_function<UnaryFunc(typename thrust::iterator_value<Iterator>::type)>
52
+ >::type reference;
53
+
54
+ // To get the default for Value: remove cvref on the result type.
55
+ using value_type =
56
+ typename thrust::detail::ia_dflt_help<Value, thrust::remove_cvref<reference>>::type;
57
+
58
+ public:
59
+ typedef thrust::iterator_adaptor
60
+ <
61
+ transform_iterator<UnaryFunc, Iterator, Reference, Value>
62
+ , Iterator
63
+ , value_type
64
+ , thrust::use_default // Leave the system alone
65
+ //, thrust::use_default // Leave the traversal alone
66
+ // use the Iterator's category to let any system iterators remain random access even though
67
+ // transform_iterator's reference type may not be a reference
68
+ // XXX figure out why only iterators whose reference types are true references are random access
69
+ , typename thrust::iterator_traits<Iterator>::iterator_category
70
+ , reference
71
+ > type;
72
+ };
73
+
74
+
75
+ } // end detail
76
+ THRUST_NAMESPACE_END
77
+
miniCUDA124/include/thrust/iterator/detail/transform_output_iterator.inl ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/iterator/transform_output_iterator.h>
30
+ #include <thrust/iterator/iterator_adaptor.h>
31
+
32
+ THRUST_NAMESPACE_BEGIN
33
+
34
+ template <typename UnaryFunction, typename OutputIterator>
35
+ class transform_output_iterator;
36
+
37
+ namespace detail
38
+ {
39
+
40
+ // Proxy reference that uses Unary Function to transform the rhs of assigment
41
+ // operator before writing the result to OutputIterator
42
+ template <typename UnaryFunction, typename OutputIterator>
43
+ class transform_output_iterator_proxy
44
+ {
45
+ public:
46
+ __host__ __device__
47
+ transform_output_iterator_proxy(const OutputIterator& out, UnaryFunction fun) : out(out), fun(fun)
48
+ {
49
+ }
50
+
51
+ __thrust_exec_check_disable__
52
+ template <typename T>
53
+ __host__ __device__
54
+ transform_output_iterator_proxy operator=(const T& x)
55
+ {
56
+ *out = fun(x);
57
+ return *this;
58
+ }
59
+
60
+ private:
61
+ OutputIterator out;
62
+ UnaryFunction fun;
63
+ };
64
+
65
+ // Compute the iterator_adaptor instantiation to be used for transform_output_iterator
66
+ template <typename UnaryFunction, typename OutputIterator>
67
+ struct transform_output_iterator_base
68
+ {
69
+ typedef thrust::iterator_adaptor
70
+ <
71
+ transform_output_iterator<UnaryFunction, OutputIterator>
72
+ , OutputIterator
73
+ , thrust::use_default
74
+ , thrust::use_default
75
+ , thrust::use_default
76
+ , transform_output_iterator_proxy<UnaryFunction, OutputIterator>
77
+ > type;
78
+ };
79
+
80
+ // Register transform_output_iterator_proxy with 'is_proxy_reference' from
81
+ // type_traits to enable its use with algorithms.
82
+ template <class UnaryFunction, class OutputIterator>
83
+ struct is_proxy_reference<
84
+ transform_output_iterator_proxy<UnaryFunction, OutputIterator> >
85
+ : public thrust::detail::true_type {};
86
+
87
+ } // end detail
88
+ THRUST_NAMESPACE_END
89
+
miniCUDA124/include/thrust/iterator/detail/tuple_of_iterator_references.h ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2018 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <cuda/std/type_traits>
30
+ #include <cuda/std/tuple>
31
+
32
+ #include <thrust/tuple.h>
33
+ #include <thrust/pair.h>
34
+ #include <thrust/detail/reference_forward_declaration.h>
35
+ #include <thrust/detail/raw_reference_cast.h>
36
+
37
+ THRUST_NAMESPACE_BEGIN
38
+
39
+ namespace detail
40
+ {
41
+
42
+ template<
43
+ typename... Ts
44
+ >
45
+ class tuple_of_iterator_references : public thrust::tuple<Ts...>
46
+ {
47
+ public:
48
+ using super_t = thrust::tuple<Ts...>;
49
+ using super_t::super_t;
50
+
51
+ inline __host__ __device__
52
+ tuple_of_iterator_references()
53
+ : super_t()
54
+ {}
55
+
56
+ // allow implicit construction from tuple<refs>
57
+ inline __host__ __device__
58
+ tuple_of_iterator_references(const super_t& other)
59
+ : super_t(other)
60
+ {}
61
+
62
+ inline __host__ __device__
63
+ tuple_of_iterator_references(super_t&& other)
64
+ : super_t(::cuda::std::move(other))
65
+ {}
66
+
67
+ // allow assignment from tuples
68
+ // XXX might be worthwhile to guard this with an enable_if is_assignable
69
+ __thrust_exec_check_disable__
70
+ template<typename... Us>
71
+ inline __host__ __device__
72
+ tuple_of_iterator_references &operator=(const thrust::tuple<Us...> &other)
73
+ {
74
+ super_t::operator=(other);
75
+ return *this;
76
+ }
77
+
78
+ // allow assignment from pairs
79
+ // XXX might be worthwhile to guard this with an enable_if is_assignable
80
+ __thrust_exec_check_disable__
81
+ template<typename U1, typename U2>
82
+ inline __host__ __device__
83
+ tuple_of_iterator_references &operator=(const thrust::pair<U1,U2> &other)
84
+ {
85
+ super_t::operator=(other);
86
+ return *this;
87
+ }
88
+
89
+ // allow assignment from reference<tuple>
90
+ // XXX perhaps we should generalize to reference<T>
91
+ // we could captures reference<pair> this way
92
+ __thrust_exec_check_disable__
93
+ template<typename Pointer, typename Derived, typename... Us>
94
+ inline __host__ __device__
95
+ tuple_of_iterator_references&
96
+ operator=(const thrust::reference<thrust::tuple<Us...>, Pointer, Derived> &other)
97
+ {
98
+ typedef thrust::tuple<Us...> tuple_type;
99
+
100
+ // XXX perhaps this could be accelerated
101
+ super_t::operator=(tuple_type{other});
102
+ return *this;
103
+ }
104
+
105
+ template<class... Us, ::cuda::std::__enable_if_t<sizeof...(Us) == sizeof...(Ts), int> = 0>
106
+ inline __host__ __device__
107
+ constexpr operator thrust::tuple<Us...>() const {
108
+ return to_tuple<Us...>(typename ::cuda::std::__make_tuple_indices<sizeof...(Ts)>::type{});
109
+ }
110
+
111
+ // this overload of swap() permits swapping tuple_of_iterator_references returned as temporaries from
112
+ // iterator dereferences
113
+ template<class... Us>
114
+ inline __host__ __device__
115
+ friend void swap(tuple_of_iterator_references&& x, tuple_of_iterator_references<Us...>&& y)
116
+ {
117
+ x.swap(y);
118
+ }
119
+
120
+ private:
121
+ template<class... Us, size_t... Id>
122
+ inline __host__ __device__
123
+ constexpr thrust::tuple<Us...> to_tuple(::cuda::std::__tuple_indices<Id...>) const {
124
+ return {get<Id>(*this)...};
125
+ }
126
+ };
127
+
128
+ } // end detail
129
+
130
+ THRUST_NAMESPACE_END
131
+
132
+ _LIBCUDACXX_BEGIN_NAMESPACE_STD
133
+
134
+ // define tuple_size, tuple_element, etc.
135
+ template <class... Ts>
136
+ struct tuple_size<THRUST_NS_QUALIFIER::detail::tuple_of_iterator_references<Ts...>>
137
+ : integral_constant<size_t, sizeof...(Ts)>
138
+ {};
139
+
140
+ template <size_t Id, class... Ts>
141
+ struct tuple_element<Id, THRUST_NS_QUALIFIER::detail::tuple_of_iterator_references<Ts...>>
142
+ : _CUDA_VSTD::tuple_element<Id, _CUDA_VSTD::tuple<Ts...>>
143
+ {};
144
+
145
+ _LIBCUDACXX_END_NAMESPACE_STD
146
+
147
+ // structured bindings suppport
148
+ namespace std {
149
+
150
+ template <class... Ts>
151
+ struct tuple_size<THRUST_NS_QUALIFIER::detail::tuple_of_iterator_references<Ts...>>
152
+ : integral_constant<size_t, sizeof...(Ts)>
153
+ {};
154
+
155
+ template <size_t Id, class... Ts>
156
+ struct tuple_element<Id, THRUST_NS_QUALIFIER::detail::tuple_of_iterator_references<Ts...>>
157
+ : _CUDA_VSTD::tuple_element<Id, _CUDA_VSTD::tuple<Ts...>>
158
+ {};
159
+
160
+ } // namespace std
miniCUDA124/include/thrust/iterator/detail/universal_categories.h ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/iterator/iterator_categories.h>
29
+
30
+ // XXX eliminate this file
31
+
32
+ THRUST_NAMESPACE_BEGIN
33
+
34
+ // define these types without inheritance to avoid ambiguous conversion to base classes
35
+
36
+ struct input_universal_iterator_tag
37
+ {
38
+ operator input_host_iterator_tag () {return input_host_iterator_tag();}
39
+
40
+ operator input_device_iterator_tag () {return input_device_iterator_tag();}
41
+ };
42
+
43
+ struct output_universal_iterator_tag
44
+ {
45
+ operator output_host_iterator_tag () {return output_host_iterator_tag();}
46
+
47
+ operator output_device_iterator_tag () {return output_device_iterator_tag();}
48
+ };
49
+
50
+ struct forward_universal_iterator_tag
51
+ : input_universal_iterator_tag
52
+ {
53
+ operator forward_host_iterator_tag () {return forward_host_iterator_tag();};
54
+
55
+ operator forward_device_iterator_tag () {return forward_device_iterator_tag();};
56
+ };
57
+
58
+ struct bidirectional_universal_iterator_tag
59
+ : forward_universal_iterator_tag
60
+ {
61
+ operator bidirectional_host_iterator_tag () {return bidirectional_host_iterator_tag();};
62
+
63
+ operator bidirectional_device_iterator_tag () {return bidirectional_device_iterator_tag();};
64
+ };
65
+
66
+
67
+ namespace detail
68
+ {
69
+
70
+ // create this struct to control conversion precedence in random_access_universal_iterator_tag
71
+ template<typename T>
72
+ struct one_degree_of_separation
73
+ : T
74
+ {
75
+ };
76
+
77
+ } // end detail
78
+
79
+
80
+ struct random_access_universal_iterator_tag
81
+ {
82
+ // these conversions are all P0
83
+ operator random_access_host_iterator_tag () {return random_access_host_iterator_tag();};
84
+
85
+ operator random_access_device_iterator_tag () {return random_access_device_iterator_tag();};
86
+
87
+ // bidirectional_universal_iterator_tag is P1
88
+ operator detail::one_degree_of_separation<bidirectional_universal_iterator_tag> () {return detail::one_degree_of_separation<bidirectional_universal_iterator_tag>();}
89
+
90
+ };
91
+
92
+
93
+ THRUST_NAMESPACE_END
94
+
miniCUDA124/include/thrust/iterator/detail/zip_iterator.inl ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/iterator/zip_iterator.h>
30
+ #include <thrust/detail/tuple_transform.h>
31
+
32
+ THRUST_NAMESPACE_BEGIN
33
+
34
+
35
+ template<typename IteratorTuple>
36
+ __host__ __device__
37
+ zip_iterator<IteratorTuple>
38
+ ::zip_iterator()
39
+ {
40
+ } // end zip_iterator::zip_iterator()
41
+
42
+
43
+ template<typename IteratorTuple>
44
+ __host__ __device__
45
+ zip_iterator<IteratorTuple>
46
+ ::zip_iterator(IteratorTuple iterator_tuple)
47
+ :m_iterator_tuple(iterator_tuple)
48
+ {
49
+ } // end zip_iterator::zip_iterator()
50
+
51
+
52
+ template<typename IteratorTuple>
53
+ template<typename OtherIteratorTuple>
54
+ __host__ __device__
55
+ zip_iterator<IteratorTuple>
56
+ ::zip_iterator(const zip_iterator<OtherIteratorTuple> &other,
57
+ typename thrust::detail::enable_if_convertible<
58
+ OtherIteratorTuple,
59
+ IteratorTuple
60
+ >::type *)
61
+ :m_iterator_tuple(other.get_iterator_tuple())
62
+ {
63
+ } // end zip_iterator::zip_iterator()
64
+
65
+
66
+ template<typename IteratorTuple>
67
+ __host__ __device__
68
+ const IteratorTuple &zip_iterator<IteratorTuple>
69
+ ::get_iterator_tuple() const
70
+ {
71
+ return m_iterator_tuple;
72
+ } // end zip_iterator::get_iterator_tuple()
73
+
74
+
75
+ template<typename IteratorTuple>
76
+ typename zip_iterator<IteratorTuple>::super_t::reference
77
+ __host__ __device__
78
+ zip_iterator<IteratorTuple>
79
+ ::dereference() const
80
+ {
81
+ using namespace detail::tuple_impl_specific;
82
+
83
+ return thrust::detail::tuple_host_device_transform<
84
+ detail::dereference_iterator::template apply
85
+ >(get_iterator_tuple(), detail::dereference_iterator());
86
+ } // end zip_iterator::dereference()
87
+
88
+
89
+ __thrust_exec_check_disable__
90
+ template<typename IteratorTuple>
91
+ template<typename OtherIteratorTuple>
92
+ __host__ __device__
93
+ bool zip_iterator<IteratorTuple>
94
+ ::equal(const zip_iterator<OtherIteratorTuple> &other) const
95
+ {
96
+ return get<0>(get_iterator_tuple()) == get<0>(other.get_iterator_tuple());
97
+ } // end zip_iterator::equal()
98
+
99
+
100
+ template<typename IteratorTuple>
101
+ __host__ __device__
102
+ void zip_iterator<IteratorTuple>
103
+ ::advance(typename super_t::difference_type n)
104
+ {
105
+ using namespace detail::tuple_impl_specific;
106
+ tuple_for_each(m_iterator_tuple,
107
+ detail::advance_iterator<typename super_t::difference_type>(n));
108
+ } // end zip_iterator::advance()
109
+
110
+
111
+ template<typename IteratorTuple>
112
+ __host__ __device__
113
+ void zip_iterator<IteratorTuple>
114
+ ::increment()
115
+ {
116
+ using namespace detail::tuple_impl_specific;
117
+ tuple_for_each(m_iterator_tuple, detail::increment_iterator());
118
+ } // end zip_iterator::increment()
119
+
120
+
121
+ template<typename IteratorTuple>
122
+ __host__ __device__
123
+ void zip_iterator<IteratorTuple>
124
+ ::decrement()
125
+ {
126
+ using namespace detail::tuple_impl_specific;
127
+ tuple_for_each(m_iterator_tuple, detail::decrement_iterator());
128
+ } // end zip_iterator::decrement()
129
+
130
+
131
+ __thrust_exec_check_disable__
132
+ template<typename IteratorTuple>
133
+ template <typename OtherIteratorTuple>
134
+ __host__ __device__
135
+ typename zip_iterator<IteratorTuple>::super_t::difference_type
136
+ zip_iterator<IteratorTuple>
137
+ ::distance_to(const zip_iterator<OtherIteratorTuple> &other) const
138
+ {
139
+ return get<0>(other.get_iterator_tuple()) - get<0>(get_iterator_tuple());
140
+ } // end zip_iterator::distance_to()
141
+
142
+
143
+ template<typename... Iterators>
144
+ __host__ __device__
145
+ zip_iterator<thrust::tuple<Iterators...>> make_zip_iterator(thrust::tuple<Iterators...> t)
146
+ {
147
+ return zip_iterator<thrust::tuple<Iterators...>>(t);
148
+ } // end make_zip_iterator()
149
+
150
+
151
+ template<typename... Iterators>
152
+ __host__ __device__
153
+ zip_iterator<thrust::tuple<Iterators...>> make_zip_iterator(Iterators... its)
154
+ {
155
+ return make_zip_iterator(thrust::make_tuple(its...));
156
+ } // end make_zip_iterator()
157
+
158
+
159
+ THRUST_NAMESPACE_END
160
+
miniCUDA124/include/thrust/iterator/detail/zip_iterator_base.h ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/advance.h>
30
+ #include <thrust/iterator/iterator_traits.h>
31
+ #include <thrust/iterator/iterator_facade.h>
32
+ #include <thrust/iterator/iterator_categories.h>
33
+ #include <thrust/iterator/detail/minimum_category.h>
34
+ #include <thrust/iterator/detail/minimum_system.h>
35
+ #include <thrust/type_traits/integer_sequence.h>
36
+ #include <thrust/tuple.h>
37
+ #include <thrust/detail/tuple_meta_transform.h>
38
+ #include <thrust/detail/tuple_transform.h>
39
+ #include <thrust/detail/type_traits.h>
40
+ #include <thrust/iterator/detail/tuple_of_iterator_references.h>
41
+
42
+ THRUST_NAMESPACE_BEGIN
43
+
44
+ // forward declare zip_iterator for zip_iterator_base
45
+ template<typename IteratorTuple> class zip_iterator;
46
+
47
+ namespace detail
48
+ {
49
+
50
+
51
+ // Functors to be used with tuple algorithms
52
+ //
53
+ template<typename DiffType>
54
+ class advance_iterator
55
+ {
56
+ public:
57
+ inline __host__ __device__
58
+ advance_iterator(DiffType step) : m_step(step) {}
59
+
60
+ __thrust_exec_check_disable__
61
+ template<typename Iterator>
62
+ inline __host__ __device__
63
+ void operator()(Iterator& it) const
64
+ { thrust::advance(it, m_step); }
65
+
66
+ private:
67
+ DiffType m_step;
68
+ }; // end advance_iterator
69
+
70
+
71
+ struct increment_iterator
72
+ {
73
+ __thrust_exec_check_disable__
74
+ template<typename Iterator>
75
+ inline __host__ __device__
76
+ void operator()(Iterator& it)
77
+ { ++it; }
78
+ }; // end increment_iterator
79
+
80
+
81
+ struct decrement_iterator
82
+ {
83
+ __thrust_exec_check_disable__
84
+ template<typename Iterator>
85
+ inline __host__ __device__
86
+ void operator()(Iterator& it)
87
+ { --it; }
88
+ }; // end decrement_iterator
89
+
90
+
91
+ struct dereference_iterator
92
+ {
93
+ template<typename Iterator>
94
+ struct apply
95
+ {
96
+ typedef typename
97
+ iterator_traits<Iterator>::reference
98
+ type;
99
+ }; // end apply
100
+
101
+ // XXX silence warnings of the form "calling a __host__ function from a __host__ __device__ function is not allowed
102
+ __thrust_exec_check_disable__
103
+ template<typename Iterator>
104
+ __host__ __device__
105
+ typename apply<Iterator>::type operator()(Iterator const& it)
106
+ {
107
+ return *it;
108
+ }
109
+ }; // end dereference_iterator
110
+
111
+
112
+ // The namespace tuple_impl_specific provides two meta-
113
+ // algorithms and two algorithms for tuples.
114
+ namespace tuple_impl_specific
115
+ {
116
+
117
+ // define apply1 for tuple_meta_transform_impl
118
+ template<typename UnaryMetaFunctionClass, class Arg>
119
+ struct apply1
120
+ : UnaryMetaFunctionClass::template apply<Arg>
121
+ {
122
+ }; // end apply1
123
+
124
+
125
+ // define apply2 for tuple_meta_accumulate_impl
126
+ template<typename UnaryMetaFunctionClass, class Arg1, class Arg2>
127
+ struct apply2
128
+ : UnaryMetaFunctionClass::template apply<Arg1,Arg2>
129
+ {
130
+ }; // end apply2
131
+
132
+
133
+ // Meta-accumulate algorithm for tuples. Note: The template
134
+ // parameter StartType corresponds to the initial value in
135
+ // ordinary accumulation.
136
+ //
137
+ template<class Tuple, class BinaryMetaFun, class StartType>
138
+ struct tuple_meta_accumulate;
139
+
140
+ template<
141
+ class BinaryMetaFun
142
+ , typename StartType
143
+ >
144
+ struct tuple_meta_accumulate<thrust::tuple<>,BinaryMetaFun,StartType>
145
+ {
146
+ typedef typename thrust::detail::identity_<StartType>::type type;
147
+ };
148
+
149
+
150
+ template<
151
+ class BinaryMetaFun
152
+ , typename StartType
153
+ , typename T
154
+ , typename... Ts
155
+ >
156
+ struct tuple_meta_accumulate<thrust::tuple<T,Ts...>,BinaryMetaFun,StartType>
157
+ {
158
+ typedef typename apply2<
159
+ BinaryMetaFun
160
+ , T
161
+ , typename tuple_meta_accumulate<
162
+ thrust::tuple<Ts...>
163
+ , BinaryMetaFun
164
+ , StartType
165
+ >::type
166
+ >::type type;
167
+ };
168
+
169
+
170
+ template<typename Fun>
171
+ inline __host__ __device__
172
+ Fun tuple_for_each_helper(Fun f)
173
+ {
174
+ return f;
175
+ }
176
+
177
+ template<typename Fun, typename T, typename... Ts>
178
+ inline __host__ __device__
179
+ Fun tuple_for_each_helper(Fun f, T& t, Ts&... ts)
180
+ {
181
+ f(t);
182
+ return tuple_for_each_helper(f, ts...);
183
+ }
184
+
185
+ // for_each algorithm for tuples.
186
+
187
+ template<typename Fun, typename... Ts, size_t... Is>
188
+ inline __host__ __device__
189
+ Fun tuple_for_each(thrust::tuple<Ts...>& t, Fun f, thrust::index_sequence<Is...>)
190
+ {
191
+ return tuple_for_each_helper(f, thrust::get<Is>(t)...);
192
+ } // end tuple_for_each()
193
+
194
+ // for_each algorithm for tuples.
195
+ template<typename Fun, typename... Ts>
196
+ inline __host__ __device__
197
+ Fun tuple_for_each(thrust::tuple<Ts...>& t, Fun f)
198
+ {
199
+ return tuple_for_each(t, f, thrust::make_index_sequence<thrust::tuple_size<thrust::tuple<Ts...>>::value>{});
200
+ }
201
+
202
+
203
+ } // end tuple_impl_specific
204
+
205
+
206
+ // Metafunction to obtain the type of the tuple whose element types
207
+ // are the value_types of an iterator tupel.
208
+ //
209
+ template<typename IteratorTuple>
210
+ struct tuple_of_value_types
211
+ : tuple_meta_transform<
212
+ IteratorTuple,
213
+ iterator_value
214
+ >
215
+ {
216
+ }; // end tuple_of_value_types
217
+
218
+
219
+ struct minimum_category_lambda
220
+ {
221
+ template<typename T1, typename T2>
222
+ struct apply : minimum_category<T1,T2>
223
+ {};
224
+ };
225
+
226
+
227
+
228
+ // Metafunction to obtain the minimal traversal tag in a tuple
229
+ // of iterators.
230
+ //
231
+ template<typename IteratorTuple>
232
+ struct minimum_traversal_category_in_iterator_tuple
233
+ {
234
+ typedef typename tuple_meta_transform<
235
+ IteratorTuple
236
+ , thrust::iterator_traversal
237
+ >::type tuple_of_traversal_tags;
238
+
239
+ typedef typename tuple_impl_specific::tuple_meta_accumulate<
240
+ tuple_of_traversal_tags
241
+ , minimum_category_lambda
242
+ , thrust::random_access_traversal_tag
243
+ >::type type;
244
+ };
245
+
246
+
247
+ struct minimum_system_lambda
248
+ {
249
+ template<typename T1, typename T2>
250
+ struct apply : minimum_system<T1,T2>
251
+ {};
252
+ };
253
+
254
+
255
+
256
+ // Metafunction to obtain the minimal system tag in a tuple
257
+ // of iterators.
258
+ template<typename IteratorTuple>
259
+ struct minimum_system_in_iterator_tuple
260
+ {
261
+ typedef typename thrust::detail::tuple_meta_transform<
262
+ IteratorTuple,
263
+ thrust::iterator_system
264
+ >::type tuple_of_system_tags;
265
+
266
+ typedef typename tuple_impl_specific::tuple_meta_accumulate<
267
+ tuple_of_system_tags,
268
+ minimum_system_lambda,
269
+ thrust::any_system_tag
270
+ >::type type;
271
+ };
272
+
273
+ namespace zip_iterator_base_ns
274
+ {
275
+
276
+
277
+ template<typename Tuple, typename IndexSequence>
278
+ struct tuple_of_iterator_references_helper;
279
+
280
+
281
+ template<typename Tuple, size_t... Is>
282
+ struct tuple_of_iterator_references_helper<Tuple, thrust::index_sequence<Is...>>
283
+ {
284
+ typedef thrust::detail::tuple_of_iterator_references<
285
+ typename thrust::tuple_element<Is,Tuple>::type...
286
+ > type;
287
+ };
288
+
289
+
290
+ template<typename IteratorTuple>
291
+ struct tuple_of_iterator_references
292
+ {
293
+ // get a thrust::tuple of the iterators' references
294
+ typedef typename tuple_meta_transform<
295
+ IteratorTuple,
296
+ iterator_reference
297
+ >::type tuple_of_references;
298
+
299
+ // map thrust::tuple<T...> to tuple_of_iterator_references<T...>
300
+ typedef typename tuple_of_iterator_references_helper<
301
+ tuple_of_references,
302
+ thrust::make_index_sequence<thrust::tuple_size<tuple_of_references>::value>
303
+ >::type type;
304
+ };
305
+
306
+
307
+ } // end zip_iterator_base_ns
308
+
309
+ ///////////////////////////////////////////////////////////////////
310
+ //
311
+ // Class zip_iterator_base
312
+ //
313
+ // Builds and exposes the iterator facade type from which the zip
314
+ // iterator will be derived.
315
+ //
316
+ template<typename IteratorTuple>
317
+ struct zip_iterator_base
318
+ {
319
+ //private:
320
+ // reference type is the type of the tuple obtained from the
321
+ // iterators' reference types.
322
+ typedef typename zip_iterator_base_ns::tuple_of_iterator_references<IteratorTuple>::type reference;
323
+
324
+ // Boost's Value type is the same as reference type.
325
+ //typedef reference value_type;
326
+ typedef typename tuple_of_value_types<IteratorTuple>::type value_type;
327
+
328
+ // Difference type is the first iterator's difference type
329
+ typedef typename thrust::iterator_traits<
330
+ typename thrust::tuple_element<0, IteratorTuple>::type
331
+ >::difference_type difference_type;
332
+
333
+ // Iterator system is the minimum system tag in the
334
+ // iterator tuple
335
+ typedef typename
336
+ minimum_system_in_iterator_tuple<IteratorTuple>::type system;
337
+
338
+ // Traversal category is the minimum traversal category in the
339
+ // iterator tuple
340
+ typedef typename
341
+ minimum_traversal_category_in_iterator_tuple<IteratorTuple>::type traversal_category;
342
+
343
+ public:
344
+
345
+ // The iterator facade type from which the zip iterator will
346
+ // be derived.
347
+ typedef thrust::iterator_facade<
348
+ zip_iterator<IteratorTuple>,
349
+ value_type,
350
+ system,
351
+ traversal_category,
352
+ reference,
353
+ difference_type
354
+ > type;
355
+ }; // end zip_iterator_base
356
+
357
+ } // end detail
358
+
359
+ THRUST_NAMESPACE_END
360
+
361
+
miniCUDA124/include/thrust/random/detail/discard_block_engine.inl ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/random/discard_block_engine.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+
33
+ namespace random
34
+ {
35
+
36
+
37
+ template<typename Engine, size_t p, size_t r>
38
+ __host__ __device__
39
+ discard_block_engine<Engine,p,r>
40
+ ::discard_block_engine()
41
+ : m_e(), m_n(0)
42
+ {}
43
+
44
+
45
+ template<typename Engine, size_t p, size_t r>
46
+ __host__ __device__
47
+ discard_block_engine<Engine,p,r>
48
+ ::discard_block_engine(result_type s)
49
+ : m_e(s), m_n(0)
50
+ {}
51
+
52
+
53
+ template<typename Engine, size_t p, size_t r>
54
+ __host__ __device__
55
+ discard_block_engine<Engine,p,r>
56
+ ::discard_block_engine(const base_type &urng)
57
+ : m_e(urng), m_n(0)
58
+ {}
59
+
60
+
61
+ template<typename Engine, size_t p, size_t r>
62
+ __host__ __device__
63
+ void discard_block_engine<Engine,p,r>
64
+ ::seed(void)
65
+ {
66
+ m_e.seed();
67
+ m_n = 0;
68
+ }
69
+
70
+
71
+ template<typename Engine, size_t p, size_t r>
72
+ __host__ __device__
73
+ void discard_block_engine<Engine,p,r>
74
+ ::seed(result_type s)
75
+ {
76
+ m_e.seed(s);
77
+ m_n = 0;
78
+ }
79
+
80
+
81
+ template<typename Engine, size_t p, size_t r>
82
+ __host__ __device__
83
+ typename discard_block_engine<Engine,p,r>::result_type
84
+ discard_block_engine<Engine,p,r>
85
+ ::operator()(void)
86
+ {
87
+ if(m_n >= used_block)
88
+ {
89
+ m_e.discard(block_size - m_n);
90
+ // for(; m_n < block_size; ++m_n)
91
+ // m_e();
92
+ m_n = 0;
93
+ }
94
+
95
+ ++m_n;
96
+
97
+ return m_e();
98
+ }
99
+
100
+
101
+ template<typename Engine, size_t p, size_t r>
102
+ __host__ __device__
103
+ void discard_block_engine<Engine,p,r>
104
+ ::discard(unsigned long long z)
105
+ {
106
+ // XXX this should be accelerated
107
+ for(; z > 0; --z)
108
+ {
109
+ this->operator()();
110
+ } // end for
111
+ }
112
+
113
+
114
+ template<typename Engine, size_t p, size_t r>
115
+ __host__ __device__
116
+ const typename discard_block_engine<Engine,p,r>::base_type &
117
+ discard_block_engine<Engine,p,r>
118
+ ::base(void) const
119
+ {
120
+ return m_e;
121
+ }
122
+
123
+
124
+ template<typename Engine, size_t p, size_t r>
125
+ template<typename CharT, typename Traits>
126
+ std::basic_ostream<CharT,Traits>& discard_block_engine<Engine,p,r>
127
+ ::stream_out(std::basic_ostream<CharT,Traits> &os) const
128
+ {
129
+ typedef std::basic_ostream<CharT,Traits> ostream_type;
130
+ typedef typename ostream_type::ios_base ios_base;
131
+
132
+ // save old flags & fill character
133
+ const typename ios_base::fmtflags flags = os.flags();
134
+ const CharT fill = os.fill();
135
+
136
+ const CharT space = os.widen(' ');
137
+ os.flags(ios_base::dec | ios_base::fixed | ios_base::left);
138
+ os.fill(space);
139
+
140
+ // output the base engine followed by n
141
+ os << m_e << space << m_n;
142
+
143
+ // restore flags & fill character
144
+ os.flags(flags);
145
+ os.fill(fill);
146
+
147
+ return os;
148
+ }
149
+
150
+
151
+ template<typename Engine, size_t p, size_t r>
152
+ template<typename CharT, typename Traits>
153
+ std::basic_istream<CharT,Traits>& discard_block_engine<Engine,p,r>
154
+ ::stream_in(std::basic_istream<CharT,Traits> &is)
155
+ {
156
+ typedef std::basic_istream<CharT,Traits> istream_type;
157
+ typedef typename istream_type::ios_base ios_base;
158
+
159
+ // save old flags
160
+ const typename ios_base::fmtflags flags = is.flags();
161
+
162
+ is.flags(ios_base::skipws);
163
+
164
+ // input the base engine and then n
165
+ is >> m_e >> m_n;
166
+
167
+ // restore old flags
168
+ is.flags(flags);
169
+ return is;
170
+ }
171
+
172
+
173
+ template<typename Engine, size_t p, size_t r>
174
+ __host__ __device__
175
+ bool discard_block_engine<Engine,p,r>
176
+ ::equal(const discard_block_engine<Engine,p,r> &rhs) const
177
+ {
178
+ return (m_e == rhs.m_e) && (m_n == rhs.m_n);
179
+ }
180
+
181
+
182
+ template<typename Engine, size_t p, size_t r,
183
+ typename CharT, typename Traits>
184
+ std::basic_ostream<CharT,Traits>&
185
+ operator<<(std::basic_ostream<CharT,Traits> &os,
186
+ const discard_block_engine<Engine,p,r> &e)
187
+ {
188
+ return thrust::random::detail::random_core_access::stream_out(os,e);
189
+ }
190
+
191
+
192
+ template<typename Engine, size_t p, size_t r,
193
+ typename CharT, typename Traits>
194
+ std::basic_istream<CharT,Traits>&
195
+ operator>>(std::basic_istream<CharT,Traits> &is,
196
+ discard_block_engine<Engine,p,r> &e)
197
+ {
198
+ return thrust::random::detail::random_core_access::stream_in(is,e);
199
+ }
200
+
201
+
202
+ template<typename Engine, size_t p, size_t r>
203
+ __host__ __device__
204
+ bool operator==(const discard_block_engine<Engine,p,r> &lhs,
205
+ const discard_block_engine<Engine,p,r> &rhs)
206
+ {
207
+ return thrust::random::detail::random_core_access::equal(lhs,rhs);
208
+ }
209
+
210
+
211
+ template<typename Engine, size_t p, size_t r>
212
+ __host__ __device__
213
+ bool operator!=(const discard_block_engine<Engine,p,r> &lhs,
214
+ const discard_block_engine<Engine,p,r> &rhs)
215
+ {
216
+ return !(lhs == rhs);
217
+ }
218
+
219
+
220
+ } // end random
221
+
222
+ THRUST_NAMESPACE_END
223
+
miniCUDA124/include/thrust/random/detail/linear_congruential_engine.inl ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/random/linear_congruential_engine.h>
30
+ #include <thrust/random/detail/mod.h>
31
+ #include <thrust/random/detail/random_core_access.h>
32
+
33
+ THRUST_NAMESPACE_BEGIN
34
+
35
+ namespace random
36
+ {
37
+
38
+
39
+ template<typename UIntType, UIntType a, UIntType c, UIntType m>
40
+ __host__ __device__
41
+ linear_congruential_engine<UIntType,a,c,m>
42
+ ::linear_congruential_engine(result_type s)
43
+ {
44
+ seed(s);
45
+ } // end linear_congruential_engine::linear_congruential_engine()
46
+
47
+
48
+ template<typename UIntType, UIntType a, UIntType c, UIntType m>
49
+ __host__ __device__
50
+ void linear_congruential_engine<UIntType,a,c,m>
51
+ ::seed(result_type s)
52
+ {
53
+ if((detail::mod<UIntType, 1, 0, m>(c) == 0) &&
54
+ (detail::mod<UIntType, 1, 0, m>(s) == 0))
55
+ m_x = detail::mod<UIntType, 1, 0, m>(1);
56
+ else
57
+ m_x = detail::mod<UIntType, 1, 0, m>(s);
58
+ } // end linear_congruential_engine::seed()
59
+
60
+
61
+ template<typename UIntType, UIntType a, UIntType c, UIntType m>
62
+ __host__ __device__
63
+ typename linear_congruential_engine<UIntType,a,c,m>::result_type
64
+ linear_congruential_engine<UIntType,a,c,m>
65
+ ::operator()(void)
66
+ {
67
+ m_x = detail::mod<UIntType,a,c,m>(m_x);
68
+ return m_x;
69
+ } // end linear_congruential_engine::operator()()
70
+
71
+
72
+ template<typename UIntType, UIntType a, UIntType c, UIntType m>
73
+ __host__ __device__
74
+ void linear_congruential_engine<UIntType,a,c,m>
75
+ ::discard(unsigned long long z)
76
+ {
77
+ thrust::random::detail::linear_congruential_engine_discard::discard(*this,z);
78
+ } // end linear_congruential_engine::discard()
79
+
80
+
81
+ template<typename UIntType, UIntType a, UIntType c, UIntType m>
82
+ template<typename CharT, typename Traits>
83
+ std::basic_ostream<CharT,Traits>& linear_congruential_engine<UIntType,a,c,m>
84
+ ::stream_out(std::basic_ostream<CharT,Traits> &os) const
85
+ {
86
+ typedef std::basic_ostream<CharT,Traits> ostream_type;
87
+ typedef typename ostream_type::ios_base ios_base;
88
+
89
+ // save old flags & fill character
90
+ const typename ios_base::fmtflags flags = os.flags();
91
+ const CharT fill = os.fill();
92
+
93
+ os.flags(ios_base::dec | ios_base::fixed | ios_base::left);
94
+ os.fill(os.widen(' '));
95
+
96
+ // output one word of state
97
+ os << m_x;
98
+
99
+ // restore flags & fill character
100
+ os.flags(flags);
101
+ os.fill(fill);
102
+
103
+ return os;
104
+ }
105
+
106
+
107
+ template<typename UIntType, UIntType a, UIntType c, UIntType m>
108
+ template<typename CharT, typename Traits>
109
+ std::basic_istream<CharT,Traits>& linear_congruential_engine<UIntType,a,c,m>
110
+ ::stream_in(std::basic_istream<CharT,Traits> &is)
111
+ {
112
+ typedef std::basic_istream<CharT,Traits> istream_type;
113
+ typedef typename istream_type::ios_base ios_base;
114
+
115
+ // save old flags
116
+ const typename ios_base::fmtflags flags = is.flags();
117
+
118
+ is.flags(ios_base::dec);
119
+
120
+ // input one word of state
121
+ is >> m_x;
122
+
123
+ // restore flags
124
+ is.flags(flags);
125
+
126
+ return is;
127
+ }
128
+
129
+
130
+ template<typename UIntType, UIntType a, UIntType c, UIntType m>
131
+ __host__ __device__
132
+ bool linear_congruential_engine<UIntType,a,c,m>
133
+ ::equal(const linear_congruential_engine<UIntType,a,c,m> &rhs) const
134
+ {
135
+ return m_x == rhs.m_x;
136
+ }
137
+
138
+
139
+ template<typename UIntType_, UIntType_ a_, UIntType_ c_, UIntType_ m_>
140
+ __host__ __device__
141
+ bool operator==(const linear_congruential_engine<UIntType_,a_,c_,m_> &lhs,
142
+ const linear_congruential_engine<UIntType_,a_,c_,m_> &rhs)
143
+ {
144
+ return detail::random_core_access::equal(lhs,rhs);
145
+ }
146
+
147
+
148
+ template<typename UIntType, UIntType a, UIntType c, UIntType m>
149
+ __host__ __device__
150
+ bool operator!=(const linear_congruential_engine<UIntType,a,c,m> &lhs,
151
+ const linear_congruential_engine<UIntType,a,c,m> &rhs)
152
+ {
153
+ return !(lhs == rhs);
154
+ }
155
+
156
+
157
+ template<typename UIntType_, UIntType_ a_, UIntType_ c_, UIntType_ m_,
158
+ typename CharT, typename Traits>
159
+ std::basic_ostream<CharT,Traits>&
160
+ operator<<(std::basic_ostream<CharT,Traits> &os,
161
+ const linear_congruential_engine<UIntType_,a_,c_,m_> &e)
162
+ {
163
+ return detail::random_core_access::stream_out(os,e);
164
+ }
165
+
166
+
167
+ template<typename UIntType_, UIntType_ a_, UIntType_ c_, UIntType_ m_,
168
+ typename CharT, typename Traits>
169
+ std::basic_istream<CharT,Traits>&
170
+ operator>>(std::basic_istream<CharT,Traits> &is,
171
+ linear_congruential_engine<UIntType_,a_,c_,m_> &e)
172
+ {
173
+ return detail::random_core_access::stream_in(is,e);
174
+ }
175
+
176
+
177
+ } // end random
178
+
179
+ THRUST_NAMESPACE_END
180
+
miniCUDA124/include/thrust/random/detail/linear_congruential_engine_discard.h ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/cstdint.h>
30
+ #include <thrust/random/detail/mod.h>
31
+
32
+ THRUST_NAMESPACE_BEGIN
33
+
34
+ namespace random
35
+ {
36
+
37
+ namespace detail
38
+ {
39
+
40
+
41
+ template<typename UIntType, UIntType a, unsigned long long c, UIntType m>
42
+ struct linear_congruential_engine_discard_implementation
43
+ {
44
+ __host__ __device__
45
+ static void discard(UIntType &state, unsigned long long z)
46
+ {
47
+ for(; z > 0; --z)
48
+ {
49
+ state = detail::mod<UIntType,a,c,m>(state);
50
+ }
51
+ }
52
+ }; // end linear_congruential_engine_discard
53
+
54
+
55
+ // specialize for small integers and c == 0
56
+ // XXX figure out a robust implemenation of this for any unsigned integer type later
57
+ template<thrust::detail::uint32_t a, thrust::detail::uint32_t m>
58
+ struct linear_congruential_engine_discard_implementation<thrust::detail::uint32_t,a,0,m>
59
+ {
60
+ __host__ __device__
61
+ static void discard(thrust::detail::uint32_t &state, unsigned long long z)
62
+ {
63
+ const thrust::detail::uint32_t modulus = m;
64
+
65
+ // XXX we need to use unsigned long long here or we will encounter overflow in the
66
+ // multiplies below
67
+ // figure out a robust implementation of this later
68
+ unsigned long long multiplier = a;
69
+ unsigned long long multiplier_to_z = 1;
70
+
71
+ // see http://en.wikipedia.org/wiki/Modular_exponentiation
72
+ while(z > 0)
73
+ {
74
+ if(z & 1)
75
+ {
76
+ // multiply in this bit's contribution while using modulus to keep result small
77
+ multiplier_to_z = (multiplier_to_z * multiplier) % modulus;
78
+ }
79
+
80
+ // move to the next bit of the exponent, square (and mod) the base accordingly
81
+ z >>= 1;
82
+ multiplier = (multiplier * multiplier) % modulus;
83
+ }
84
+
85
+ state = static_cast<thrust::detail::uint32_t>((multiplier_to_z * state) % modulus);
86
+ }
87
+ }; // end linear_congruential_engine_discard
88
+
89
+
90
+ struct linear_congruential_engine_discard
91
+ {
92
+ template<typename LinearCongruentialEngine>
93
+ __host__ __device__
94
+ static void discard(LinearCongruentialEngine &lcg, unsigned long long z)
95
+ {
96
+ typedef typename LinearCongruentialEngine::result_type result_type;
97
+ const result_type c = LinearCongruentialEngine::increment;
98
+ const result_type a = LinearCongruentialEngine::multiplier;
99
+ const result_type m = LinearCongruentialEngine::modulus;
100
+
101
+ // XXX WAR unused variable warnings
102
+ (void) c;
103
+ (void) a;
104
+ (void) m;
105
+
106
+ linear_congruential_engine_discard_implementation<result_type,a,c,m>::discard(lcg.m_x, z);
107
+ }
108
+ }; // end linear_congruential_engine_discard
109
+
110
+
111
+ } // end detail
112
+
113
+ } // end random
114
+
115
+ THRUST_NAMESPACE_END
116
+
miniCUDA124/include/thrust/random/detail/linear_feedback_shift_engine.inl ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/random/linear_feedback_shift_engine.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+
33
+ namespace random
34
+ {
35
+
36
+ template<typename UIntType, size_t w, size_t k, size_t q, size_t s>
37
+ __host__ __device__
38
+ linear_feedback_shift_engine<UIntType,w,k,q,s>
39
+ ::linear_feedback_shift_engine(result_type value)
40
+ {
41
+ seed(value);
42
+ } // end linear_feedback_shift_engine::linear_feedback_shift_engine()
43
+
44
+ template<typename UIntType, size_t w, size_t k, size_t q, size_t s>
45
+ __host__ __device__
46
+ void linear_feedback_shift_engine<UIntType,w,k,q,s>
47
+ ::seed(result_type value)
48
+ {
49
+ m_value = value;
50
+ } // end linear_feedback_shift_engine::seed()
51
+
52
+ template<typename UIntType, size_t w, size_t k, size_t q, size_t s>
53
+ __host__ __device__
54
+ typename linear_feedback_shift_engine<UIntType,w,k,q,s>::result_type
55
+ linear_feedback_shift_engine<UIntType,w,k,q,s>
56
+ ::operator()(void)
57
+ {
58
+ const UIntType b = (((m_value << q) ^ m_value) & wordmask) >> (k-s);
59
+ const UIntType mask = ( (~static_cast<UIntType>(0)) << (w-k) ) & wordmask;
60
+ m_value = ((m_value & mask) << s) ^ b;
61
+ return m_value;
62
+ } // end linear_feedback_shift_engine::operator()()
63
+
64
+
65
+ template<typename UIntType, size_t w, size_t k, size_t q, size_t s>
66
+ __host__ __device__
67
+ void linear_feedback_shift_engine<UIntType,w,k,q,s>
68
+ ::discard(unsigned long long z)
69
+ {
70
+ for(; z > 0; --z)
71
+ {
72
+ this->operator()();
73
+ } // end for
74
+ } // end linear_feedback_shift_engine::discard()
75
+
76
+
77
+ template<typename UIntType, size_t w, size_t k, size_t q, size_t s>
78
+ template<typename CharT, typename Traits>
79
+ std::basic_ostream<CharT,Traits>& linear_feedback_shift_engine<UIntType,w,k,q,s>
80
+ ::stream_out(std::basic_ostream<CharT,Traits> &os) const
81
+ {
82
+ typedef std::basic_ostream<CharT,Traits> ostream_type;
83
+ typedef typename ostream_type::ios_base ios_base;
84
+
85
+ // save old flags & fill character
86
+ const typename ios_base::fmtflags flags = os.flags();
87
+ const CharT fill = os.fill();
88
+
89
+ os.flags(ios_base::dec | ios_base::fixed | ios_base::left);
90
+ os.fill(os.widen(' '));
91
+
92
+ // output one word of state
93
+ os << m_value;
94
+
95
+ // restore flags & fill character
96
+ os.flags(flags);
97
+ os.fill(fill);
98
+
99
+ return os;
100
+ }
101
+
102
+
103
+ template<typename UIntType, size_t w, size_t k, size_t q, size_t s>
104
+ template<typename CharT, typename Traits>
105
+ std::basic_istream<CharT,Traits>& linear_feedback_shift_engine<UIntType,w,k,q,s>
106
+ ::stream_in(std::basic_istream<CharT,Traits> &is)
107
+ {
108
+ typedef std::basic_istream<CharT,Traits> istream_type;
109
+ typedef typename istream_type::ios_base ios_base;
110
+
111
+ // save old flags
112
+ const typename ios_base::fmtflags flags = is.flags();
113
+
114
+ is.flags(ios_base::skipws);
115
+
116
+ // input one word of state
117
+ is >> m_value;
118
+
119
+ // restore flags
120
+ is.flags(flags);
121
+
122
+ return is;
123
+ }
124
+
125
+
126
+ template<typename UIntType, size_t w, size_t k, size_t q, size_t s>
127
+ __host__ __device__
128
+ bool linear_feedback_shift_engine<UIntType,w,k,q,s>
129
+ ::equal(const linear_feedback_shift_engine<UIntType,w,k,q,s> &rhs) const
130
+ {
131
+ return m_value == rhs.m_value;
132
+ }
133
+
134
+
135
+ template<typename UIntType, size_t w, size_t k, size_t q, size_t s>
136
+ __host__ __device__
137
+ bool operator==(const linear_feedback_shift_engine<UIntType,w,k,q,s> &lhs,
138
+ const linear_feedback_shift_engine<UIntType,w,k,q,s> &rhs)
139
+ {
140
+ return thrust::random::detail::random_core_access::equal(lhs,rhs);
141
+ }
142
+
143
+
144
+ template<typename UIntType, size_t w, size_t k, size_t q, size_t s>
145
+ __host__ __device__
146
+ bool operator!=(const linear_feedback_shift_engine<UIntType,w,k,q,s> &lhs,
147
+ const linear_feedback_shift_engine<UIntType,w,k,q,s> &rhs)
148
+ {
149
+ return !(lhs == rhs);
150
+ }
151
+
152
+
153
+ template<typename UIntType_, size_t w_, size_t k_, size_t q_, size_t s_,
154
+ typename CharT, typename Traits>
155
+ std::basic_ostream<CharT,Traits>&
156
+ operator<<(std::basic_ostream<CharT,Traits> &os,
157
+ const linear_feedback_shift_engine<UIntType_,w_,k_,q_,s_> &e)
158
+ {
159
+ return thrust::random::detail::random_core_access::stream_out(os,e);
160
+ }
161
+
162
+
163
+ template<typename UIntType_, size_t w_, size_t k_, size_t q_, size_t s_,
164
+ typename CharT, typename Traits>
165
+ std::basic_istream<CharT,Traits>&
166
+ operator>>(std::basic_istream<CharT,Traits> &is,
167
+ linear_feedback_shift_engine<UIntType_,w_,k_,q_,s_> &e)
168
+ {
169
+ return thrust::random::detail::random_core_access::stream_in(is,e);
170
+ }
171
+
172
+
173
+ } // end random
174
+
175
+ THRUST_NAMESPACE_END
176
+
miniCUDA124/include/thrust/random/detail/linear_feedback_shift_engine_wordmask.h ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ THRUST_NAMESPACE_BEGIN
30
+
31
+ namespace random
32
+ {
33
+
34
+ namespace detail
35
+ {
36
+
37
+ template<typename T, int w, int i = w-1>
38
+ struct linear_feedback_shift_engine_wordmask
39
+ {
40
+ static const T value =
41
+ (T(1u) << i) |
42
+ linear_feedback_shift_engine_wordmask<T, w, i-1>::value;
43
+ }; // end linear_feedback_shift_engine_wordmask
44
+
45
+ template<typename T, int w>
46
+ struct linear_feedback_shift_engine_wordmask<T, w, 0>
47
+ {
48
+ static const T value = 0;
49
+ }; // end linear_feedback_shift_engine_wordmask
50
+
51
+ } // end detail
52
+
53
+ } // end random
54
+
55
+ THRUST_NAMESPACE_END
56
+
miniCUDA124/include/thrust/random/detail/mod.h ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
31
+ namespace random
32
+ {
33
+
34
+ namespace detail
35
+ {
36
+
37
+ template<typename T, T a, T c, T m, bool = (m == 0)>
38
+ struct static_mod
39
+ {
40
+ static const T q = m / a;
41
+ static const T r = m % a;
42
+
43
+ __host__ __device__
44
+ T operator()(T x) const
45
+ {
46
+ THRUST_IF_CONSTEXPR(a == 1)
47
+ {
48
+ x %= m;
49
+ }
50
+ else
51
+ {
52
+ T t1 = a * (x % q);
53
+ T t2 = r * (x / q);
54
+ if(t1 >= t2)
55
+ {
56
+ x = t1 - t2;
57
+ }
58
+ else
59
+ {
60
+ x = m - t2 + t1;
61
+ }
62
+ }
63
+
64
+ THRUST_IF_CONSTEXPR(c != 0)
65
+ {
66
+ const T d = m - x;
67
+ if(d > c)
68
+ {
69
+ x += c;
70
+ }
71
+ else
72
+ {
73
+ x = c - d;
74
+ }
75
+ }
76
+
77
+ return x;
78
+ }
79
+ }; // end static_mod
80
+
81
+
82
+ // Rely on machine overflow handling
83
+ template<typename T, T a, T c, T m>
84
+ struct static_mod<T,a,c,m,true>
85
+ {
86
+ __host__ __device__
87
+ T operator()(T x) const
88
+ {
89
+ return a * x + c;
90
+ }
91
+ }; // end static_mod
92
+
93
+ template<typename T, T a, T c, T m>
94
+ __host__ __device__
95
+ T mod(T x)
96
+ {
97
+ static_mod<T,a,c,m> f;
98
+ return f(x);
99
+ } // end static_mod
100
+
101
+ } // end detail
102
+
103
+ } // end random
104
+
105
+ THRUST_NAMESPACE_END
106
+
miniCUDA124/include/thrust/random/detail/normal_distribution.inl ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/random/normal_distribution.h>
30
+ #include <thrust/random/uniform_real_distribution.h>
31
+ #include <thrust/detail/cstdint.h>
32
+ #include <thrust/detail/integer_traits.h>
33
+
34
+ // for floating point infinity
35
+ #if THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_NVCC
36
+ #include <math_constants.h>
37
+ #else
38
+ #include <limits>
39
+ #endif
40
+
41
+ THRUST_NAMESPACE_BEGIN
42
+
43
+ namespace random
44
+ {
45
+
46
+
47
+ template<typename RealType>
48
+ __host__ __device__
49
+ normal_distribution<RealType>
50
+ ::normal_distribution(RealType a, RealType b)
51
+ :super_t(),m_param(a,b)
52
+ {
53
+ } // end normal_distribution::normal_distribution()
54
+
55
+
56
+ template<typename RealType>
57
+ __host__ __device__
58
+ normal_distribution<RealType>
59
+ ::normal_distribution(const param_type &parm)
60
+ :super_t(),m_param(parm)
61
+ {
62
+ } // end normal_distribution::normal_distribution()
63
+
64
+
65
+ template<typename RealType>
66
+ __host__ __device__
67
+ void normal_distribution<RealType>
68
+ ::reset(void)
69
+ {
70
+ super_t::reset();
71
+ } // end normal_distribution::reset()
72
+
73
+
74
+ template<typename RealType>
75
+ template<typename UniformRandomNumberGenerator>
76
+ __host__ __device__
77
+ typename normal_distribution<RealType>::result_type
78
+ normal_distribution<RealType>
79
+ ::operator()(UniformRandomNumberGenerator &urng)
80
+ {
81
+ return operator()(urng, m_param);
82
+ } // end normal_distribution::operator()()
83
+
84
+
85
+ template<typename RealType>
86
+ template<typename UniformRandomNumberGenerator>
87
+ __host__ __device__
88
+ typename normal_distribution<RealType>::result_type
89
+ normal_distribution<RealType>
90
+ ::operator()(UniformRandomNumberGenerator &urng,
91
+ const param_type &parm)
92
+ {
93
+ return super_t::sample(urng, parm.first, parm.second);
94
+ } // end normal_distribution::operator()()
95
+
96
+
97
+ template<typename RealType>
98
+ __host__ __device__
99
+ typename normal_distribution<RealType>::param_type
100
+ normal_distribution<RealType>
101
+ ::param(void) const
102
+ {
103
+ return m_param;
104
+ } // end normal_distribution::param()
105
+
106
+
107
+ template<typename RealType>
108
+ __host__ __device__
109
+ void normal_distribution<RealType>
110
+ ::param(const param_type &parm)
111
+ {
112
+ m_param = parm;
113
+ } // end normal_distribution::param()
114
+
115
+
116
+ template<typename RealType>
117
+ __host__ __device__
118
+ typename normal_distribution<RealType>::result_type
119
+ normal_distribution<RealType>
120
+ ::min THRUST_PREVENT_MACRO_SUBSTITUTION (void) const
121
+ {
122
+ return -this->max THRUST_PREVENT_MACRO_SUBSTITUTION ();
123
+ } // end normal_distribution::min()
124
+
125
+
126
+ template<typename RealType>
127
+ __host__ __device__
128
+ typename normal_distribution<RealType>::result_type
129
+ normal_distribution<RealType>
130
+ ::max THRUST_PREVENT_MACRO_SUBSTITUTION (void) const
131
+ {
132
+ // XXX this solution is pretty terrible
133
+ // we can't use numeric_traits<RealType>::max because nvcc will
134
+ // complain that it is a __host__ function
135
+ union
136
+ {
137
+ thrust::detail::uint32_t inf_as_int;
138
+ float result;
139
+ } hack;
140
+
141
+ hack.inf_as_int = 0x7f800000u;
142
+
143
+ return hack.result;
144
+ } // end normal_distribution::max()
145
+
146
+
147
+ template<typename RealType>
148
+ __host__ __device__
149
+ typename normal_distribution<RealType>::result_type
150
+ normal_distribution<RealType>
151
+ ::mean(void) const
152
+ {
153
+ return m_param.first;
154
+ } // end normal_distribution::mean()
155
+
156
+
157
+ template<typename RealType>
158
+ __host__ __device__
159
+ typename normal_distribution<RealType>::result_type
160
+ normal_distribution<RealType>
161
+ ::stddev(void) const
162
+ {
163
+ return m_param.second;
164
+ } // end normal_distribution::stddev()
165
+
166
+
167
+ template<typename RealType>
168
+ __host__ __device__
169
+ bool normal_distribution<RealType>
170
+ ::equal(const normal_distribution &rhs) const
171
+ {
172
+ return m_param == rhs.param();
173
+ }
174
+
175
+
176
+ template<typename RealType>
177
+ template<typename CharT, typename Traits>
178
+ std::basic_ostream<CharT,Traits>&
179
+ normal_distribution<RealType>
180
+ ::stream_out(std::basic_ostream<CharT,Traits> &os) const
181
+ {
182
+ typedef std::basic_ostream<CharT,Traits> ostream_type;
183
+ typedef typename ostream_type::ios_base ios_base;
184
+
185
+ // save old flags and fill character
186
+ const typename ios_base::fmtflags flags = os.flags();
187
+ const CharT fill = os.fill();
188
+
189
+ const CharT space = os.widen(' ');
190
+ os.flags(ios_base::dec | ios_base::fixed | ios_base::left);
191
+ os.fill(space);
192
+
193
+ os << mean() << space << stddev();
194
+
195
+ // restore old flags and fill character
196
+ os.flags(flags);
197
+ os.fill(fill);
198
+ return os;
199
+ }
200
+
201
+
202
+ template<typename RealType>
203
+ template<typename CharT, typename Traits>
204
+ std::basic_istream<CharT,Traits>&
205
+ normal_distribution<RealType>
206
+ ::stream_in(std::basic_istream<CharT,Traits> &is)
207
+ {
208
+ typedef std::basic_istream<CharT,Traits> istream_type;
209
+ typedef typename istream_type::ios_base ios_base;
210
+
211
+ // save old flags
212
+ const typename ios_base::fmtflags flags = is.flags();
213
+
214
+ is.flags(ios_base::skipws);
215
+
216
+ is >> m_param.first >> m_param.second;
217
+
218
+ // restore old flags
219
+ is.flags(flags);
220
+ return is;
221
+ }
222
+
223
+
224
+ template<typename RealType>
225
+ __host__ __device__
226
+ bool operator==(const normal_distribution<RealType> &lhs,
227
+ const normal_distribution<RealType> &rhs)
228
+ {
229
+ return thrust::random::detail::random_core_access::equal(lhs,rhs);
230
+ }
231
+
232
+
233
+ template<typename RealType>
234
+ __host__ __device__
235
+ bool operator!=(const normal_distribution<RealType> &lhs,
236
+ const normal_distribution<RealType> &rhs)
237
+ {
238
+ return !(lhs == rhs);
239
+ }
240
+
241
+
242
+ template<typename RealType,
243
+ typename CharT, typename Traits>
244
+ std::basic_ostream<CharT,Traits>&
245
+ operator<<(std::basic_ostream<CharT,Traits> &os,
246
+ const normal_distribution<RealType> &d)
247
+ {
248
+ return thrust::random::detail::random_core_access::stream_out(os,d);
249
+ }
250
+
251
+
252
+ template<typename RealType,
253
+ typename CharT, typename Traits>
254
+ std::basic_istream<CharT,Traits>&
255
+ operator>>(std::basic_istream<CharT,Traits> &is,
256
+ normal_distribution<RealType> &d)
257
+ {
258
+ return thrust::random::detail::random_core_access::stream_in(is,d);
259
+ }
260
+
261
+
262
+ } // end random
263
+
264
+ THRUST_NAMESPACE_END
265
+
miniCUDA124/include/thrust/random/detail/normal_distribution_base.h ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /*
18
+ * Copyright Jens Maurer 2000-2001
19
+ * Distributed under the Boost Software License, Version 1.0. (See
20
+ * accompanying file LICENSE_1_0.txt or copy at
21
+ * http://www.boost.org/LICENSE_1_0.txt)
22
+ */
23
+
24
+ #pragma once
25
+
26
+ #include <thrust/detail/config.h>
27
+
28
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
29
+ # pragma GCC system_header
30
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
31
+ # pragma clang system_header
32
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
33
+ # pragma system_header
34
+ #endif // no system header
35
+ #include <thrust/pair.h>
36
+ #include <thrust/random/uniform_real_distribution.h>
37
+ #include <limits>
38
+ #include <cmath>
39
+
40
+ THRUST_NAMESPACE_BEGIN
41
+ namespace random
42
+ {
43
+ namespace detail
44
+ {
45
+
46
+ // this version samples the normal distribution directly
47
+ // and uses the non-standard math function erfcinv
48
+ template<typename RealType>
49
+ class normal_distribution_nvcc
50
+ {
51
+ protected:
52
+ template<typename UniformRandomNumberGenerator>
53
+ __host__ __device__
54
+ RealType sample(UniformRandomNumberGenerator &urng, const RealType mean, const RealType stddev)
55
+ {
56
+ using uint_type = typename UniformRandomNumberGenerator::result_type;
57
+ constexpr uint_type urng_range = UniformRandomNumberGenerator::max - UniformRandomNumberGenerator::min;
58
+
59
+ // Constants for conversion
60
+ constexpr RealType S1 = static_cast<RealType>(1. / static_cast<double>(urng_range));
61
+ constexpr RealType S2 = S1 / 2;
62
+
63
+ RealType S3 = static_cast<RealType>(-1.4142135623730950488016887242097); // -sqrt(2)
64
+
65
+ // Get the integer value
66
+ uint_type u = urng() - UniformRandomNumberGenerator::min;
67
+
68
+ // Ensure the conversion to float will give a value in the range [0,0.5)
69
+ if(u > (urng_range / 2))
70
+ {
71
+ u = urng_range - u;
72
+ S3 = -S3;
73
+ }
74
+
75
+ // Convert to floating point in [0,0.5)
76
+ RealType p = u*S1 + S2;
77
+
78
+ // Apply inverse error function
79
+ return mean + stddev * S3 * erfcinv(2 * p);
80
+ }
81
+
82
+ // no-op
83
+ __host__ __device__
84
+ void reset() {}
85
+ };
86
+
87
+ // this version samples the normal distribution using
88
+ // Marsaglia's "polar method"
89
+ template<typename RealType>
90
+ class normal_distribution_portable
91
+ {
92
+ protected:
93
+ normal_distribution_portable()
94
+ : m_r1(), m_r2(), m_cached_rho(), m_valid(false)
95
+ {}
96
+
97
+ normal_distribution_portable(const normal_distribution_portable &other)
98
+ : m_r1(other.m_r1), m_r2(other.m_r2), m_cached_rho(other.m_cached_rho), m_valid(other.m_valid)
99
+ {}
100
+
101
+ void reset()
102
+ {
103
+ m_valid = false;
104
+ }
105
+
106
+ // note that we promise to call this member function with the same mean and stddev
107
+ template<typename UniformRandomNumberGenerator>
108
+ __host__ __device__
109
+ RealType sample(UniformRandomNumberGenerator &urng, const RealType mean, const RealType stddev)
110
+ {
111
+ // implementation from Boost
112
+ // allow for Koenig lookup
113
+ using std::sqrt; using std::log; using std::sin; using std::cos;
114
+
115
+ if(!m_valid)
116
+ {
117
+ uniform_real_distribution<RealType> u01;
118
+ m_r1 = u01(urng);
119
+ m_r2 = u01(urng);
120
+ m_cached_rho = sqrt(-RealType(2) * log(RealType(1)-m_r2));
121
+
122
+ m_valid = true;
123
+ }
124
+ else
125
+ {
126
+ m_valid = false;
127
+ }
128
+
129
+ const RealType pi = RealType(3.14159265358979323846);
130
+
131
+ RealType result = m_cached_rho * (m_valid ?
132
+ cos(RealType(2)*pi*m_r1) :
133
+ sin(RealType(2)*pi*m_r1));
134
+
135
+ return mean + stddev * result;
136
+ }
137
+
138
+ private:
139
+ RealType m_r1, m_r2, m_cached_rho;
140
+ bool m_valid;
141
+ };
142
+
143
+ template<typename RealType>
144
+ struct normal_distribution_base
145
+ {
146
+ #if THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_NVCC && !defined(_NVHPC_CUDA)
147
+ typedef normal_distribution_nvcc<RealType> type;
148
+ #else
149
+ typedef normal_distribution_portable<RealType> type;
150
+ #endif
151
+ };
152
+
153
+ } // end detail
154
+ } // end random
155
+ THRUST_NAMESPACE_END
156
+
miniCUDA124/include/thrust/random/detail/random_core_access.h ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
31
+ namespace random
32
+ {
33
+
34
+ namespace detail
35
+ {
36
+
37
+ struct random_core_access
38
+ {
39
+
40
+ template<typename OStream, typename EngineOrDistribution>
41
+ static OStream &stream_out(OStream &os, const EngineOrDistribution &x)
42
+ {
43
+ return x.stream_out(os);
44
+ }
45
+
46
+ template<typename IStream, typename EngineOrDistribution>
47
+ static IStream &stream_in(IStream &is, EngineOrDistribution &x)
48
+ {
49
+ return x.stream_in(is);
50
+ }
51
+
52
+ template<typename EngineOrDistribution>
53
+ __host__ __device__
54
+ static bool equal(const EngineOrDistribution &lhs, const EngineOrDistribution &rhs)
55
+ {
56
+ return lhs.equal(rhs);
57
+ }
58
+
59
+ }; // end random_core_access
60
+
61
+ } // end detail
62
+
63
+ } // end random
64
+
65
+ THRUST_NAMESPACE_END
66
+
miniCUDA124/include/thrust/random/detail/subtract_with_carry_engine.inl ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/random/linear_congruential_engine.h>
30
+ #include <thrust/random/subtract_with_carry_engine.h>
31
+ #include <thrust/random/detail/mod.h>
32
+ #include <thrust/random/detail/random_core_access.h>
33
+
34
+ THRUST_NAMESPACE_BEGIN
35
+
36
+ namespace random
37
+ {
38
+
39
+
40
+ template<typename UIntType, size_t w, size_t s, size_t r>
41
+ __host__ __device__
42
+ subtract_with_carry_engine<UIntType,w,s,r>
43
+ ::subtract_with_carry_engine(result_type value)
44
+ {
45
+ seed(value);
46
+ } // end subtract_with_carry_engine::subtract_with_carry_engine()
47
+
48
+
49
+ template<typename UIntType, size_t w, size_t s, size_t r>
50
+ __host__ __device__
51
+ void subtract_with_carry_engine<UIntType,w,s,r>
52
+ ::seed(result_type value)
53
+ {
54
+ thrust::random::linear_congruential_engine<result_type,
55
+ 40014u, 0u, 2147483563u> e(value == 0u ? default_seed : value);
56
+
57
+ // initialize state
58
+ for(size_t i = 0; i < long_lag; ++i)
59
+ {
60
+ m_x[i] = detail::mod<UIntType, 1, 0, modulus>(e());
61
+ } // end for i
62
+
63
+ m_carry = (m_x[long_lag-1] == 0);
64
+ m_k = 0;
65
+ } // end subtract_with_carry_engine::seed()
66
+
67
+
68
+ template<typename UIntType, size_t w, size_t s, size_t r>
69
+ __host__ __device__
70
+ typename subtract_with_carry_engine<UIntType,w,s,r>::result_type
71
+ subtract_with_carry_engine<UIntType,w,s,r>
72
+ ::operator()(void)
73
+ {
74
+ // XXX we probably need to cache these m_x[m_k] in a register
75
+ // maybe we need to cache the use of all member variables
76
+ int short_index = m_k - short_lag;
77
+ if(short_index < 0)
78
+ short_index += long_lag;
79
+ result_type xi;
80
+ if (m_x[short_index] >= m_x[m_k] + m_carry)
81
+ {
82
+ // x(n) >= 0
83
+ xi = m_x[short_index] - m_x[m_k] - m_carry;
84
+ m_carry = 0;
85
+ }
86
+ else
87
+ {
88
+ // x(n) < 0
89
+ xi = modulus - m_x[m_k] - m_carry + m_x[short_index];
90
+ m_carry = 1;
91
+ }
92
+ m_x[m_k] = xi;
93
+ ++m_k;
94
+ if(m_k >= long_lag)
95
+ m_k = 0;
96
+ return xi;
97
+ } // end subtract_with_carry_engine::operator()()
98
+
99
+
100
+ template<typename UIntType, size_t w, size_t s, size_t r>
101
+ __host__ __device__
102
+ void subtract_with_carry_engine<UIntType,w,s,r>
103
+ ::discard(unsigned long long z)
104
+ {
105
+ for(; z > 0; --z)
106
+ {
107
+ this->operator()();
108
+ } // end for
109
+ } // end subtract_with_carry_engine::discard()
110
+
111
+
112
+ template<typename UIntType, size_t w, size_t s, size_t r>
113
+ template<typename CharT, typename Traits>
114
+ std::basic_ostream<CharT,Traits>& subtract_with_carry_engine<UIntType,w,s,r>
115
+ ::stream_out(std::basic_ostream<CharT,Traits> &os) const
116
+ {
117
+ typedef std::basic_ostream<CharT,Traits> ostream_type;
118
+ typedef typename ostream_type::ios_base ios_base;
119
+
120
+ const typename ios_base::fmtflags flags = os.flags();
121
+ const CharT fill = os.fill();
122
+ const CharT space = os.widen(' ');
123
+ os.flags(ios_base::dec | ios_base::fixed | ios_base::left);
124
+ os.fill(space);
125
+
126
+ const UIntType long_lag_ = r;
127
+
128
+ for(size_t i = 0; i < r; ++i)
129
+ os << m_x[(i + m_k) % long_lag_] << space;
130
+ os << m_carry;
131
+
132
+ os.flags(flags);
133
+ os.fill(fill);
134
+ return os;
135
+ }
136
+
137
+
138
+ template<typename UIntType, size_t w, size_t s, size_t r>
139
+ template<typename CharType, typename Traits>
140
+ std::basic_istream<CharType,Traits>& subtract_with_carry_engine<UIntType,w,s,r>
141
+ ::stream_in(std::basic_istream<CharType,Traits> &is)
142
+ {
143
+ typedef std::basic_istream<CharType,Traits> istream_type;
144
+ typedef typename istream_type::ios_base ios_base;
145
+
146
+ const typename ios_base::fmtflags flags = is.flags();
147
+ is.flags(ios_base::dec | ios_base::skipws);
148
+
149
+ for(size_t i = 0; i < r; ++i)
150
+ is >> m_x[i];
151
+ is >> m_carry;
152
+
153
+ m_k = 0;
154
+
155
+ is.flags(flags);
156
+ return is;
157
+ }
158
+
159
+
160
+ template<typename UIntType, size_t w, size_t s, size_t r>
161
+ __host__ __device__
162
+ bool subtract_with_carry_engine<UIntType,w,s,r>
163
+ ::equal(const subtract_with_carry_engine<UIntType,w,s,r> &rhs) const
164
+ {
165
+ const UIntType long_lag_ = r;
166
+
167
+ bool result = true;
168
+ for(size_t i = 0; i < r; ++i)
169
+ {
170
+ result &= (m_x[(i + m_k) % long_lag_] == rhs.m_x[(i + rhs.m_k) % long_lag_]);
171
+ }
172
+
173
+ // XXX not sure if this last check is necessary
174
+ result &= (m_carry == rhs.m_carry);
175
+
176
+ return result;
177
+ }
178
+
179
+
180
+ template<typename UIntType, size_t w, size_t s, size_t r,
181
+ typename CharT, typename Traits>
182
+ std::basic_ostream<CharT,Traits>&
183
+ operator<<(std::basic_ostream<CharT,Traits> &os,
184
+ const subtract_with_carry_engine<UIntType,w,s,r> &e)
185
+ {
186
+ return thrust::random::detail::random_core_access::stream_out(os,e);
187
+ }
188
+
189
+
190
+ template<typename UIntType, size_t w, size_t s, size_t r,
191
+ typename CharType, typename Traits>
192
+ std::basic_istream<CharType,Traits>&
193
+ operator>>(std::basic_istream<CharType,Traits> &is,
194
+ subtract_with_carry_engine<UIntType,w,s,r> &e)
195
+ {
196
+ return thrust::random::detail::random_core_access::stream_in(is,e);
197
+ }
198
+
199
+
200
+ template<typename UIntType, size_t w, size_t s, size_t r>
201
+ __host__ __device__
202
+ bool operator==(const subtract_with_carry_engine<UIntType,w,s,r> &lhs,
203
+ const subtract_with_carry_engine<UIntType,w,s,r> &rhs)
204
+ {
205
+ return thrust::random::detail::random_core_access::equal(lhs,rhs);
206
+ }
207
+
208
+
209
+ template<typename UIntType, size_t w, size_t s, size_t r>
210
+ __host__ __device__
211
+ bool operator!=(const subtract_with_carry_engine<UIntType,w,s,r> &lhs,
212
+ const subtract_with_carry_engine<UIntType,w,s,r> &rhs)
213
+ {
214
+ return !(lhs == rhs);
215
+ }
216
+
217
+
218
+ } // end random
219
+
220
+ THRUST_NAMESPACE_END
221
+
miniCUDA124/include/thrust/random/detail/uniform_int_distribution.inl ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/random/uniform_int_distribution.h>
30
+ #include <thrust/random/uniform_real_distribution.h>
31
+ #include <thrust/detail/type_traits.h>
32
+
33
+ THRUST_NAMESPACE_BEGIN
34
+
35
+ namespace random
36
+ {
37
+
38
+
39
+ template<typename IntType>
40
+ __host__ __device__
41
+ uniform_int_distribution<IntType>
42
+ ::uniform_int_distribution(IntType a, IntType b)
43
+ :m_param(a,b)
44
+ {
45
+ } // end uniform_int_distribution::uniform_int_distribution()
46
+
47
+
48
+ template<typename IntType>
49
+ __host__ __device__
50
+ uniform_int_distribution<IntType>
51
+ ::uniform_int_distribution(const param_type &parm)
52
+ :m_param(parm)
53
+ {
54
+ } // end uniform_int_distribution::uniform_int_distribution()
55
+
56
+
57
+ template<typename IntType>
58
+ __host__ __device__
59
+ void uniform_int_distribution<IntType>
60
+ ::reset(void)
61
+ {
62
+ } // end uniform_int_distribution::reset()
63
+
64
+
65
+ template<typename IntType>
66
+ template<typename UniformRandomNumberGenerator>
67
+ __host__ __device__
68
+ typename uniform_int_distribution<IntType>::result_type
69
+ uniform_int_distribution<IntType>
70
+ ::operator()(UniformRandomNumberGenerator &urng)
71
+ {
72
+ return operator()(urng, m_param);
73
+ } // end uniform_int_distribution::operator()()
74
+
75
+
76
+ template<typename IntType>
77
+ template<typename UniformRandomNumberGenerator>
78
+ __host__ __device__
79
+ typename uniform_int_distribution<IntType>::result_type
80
+ uniform_int_distribution<IntType>
81
+ ::operator()(UniformRandomNumberGenerator &urng, const param_type &parm)
82
+ {
83
+ // XXX this implementation is somewhat hacky and will skip
84
+ // values if the range of the RNG is smaller than the range of the distribution
85
+ // we should improve this implementation in a later version
86
+
87
+ typedef typename thrust::detail::largest_available_float::type float_type;
88
+
89
+ const float_type real_min(static_cast<float_type>(parm.first));
90
+ const float_type real_max(static_cast<float_type>(parm.second));
91
+
92
+ // add one to the right end of the interval because it is half-open
93
+ // XXX adding 1.0 to a potentially large floating point number seems like a bad idea
94
+ uniform_real_distribution<float_type> real_dist(real_min, real_max + float_type(1));
95
+
96
+ return static_cast<result_type>(real_dist(urng));
97
+ } // end uniform_int_distribution::operator()()
98
+
99
+
100
+ template<typename IntType>
101
+ __host__ __device__
102
+ typename uniform_int_distribution<IntType>::result_type
103
+ uniform_int_distribution<IntType>
104
+ ::a(void) const
105
+ {
106
+ return m_param.first;
107
+ } // end uniform_int_distribution<IntType>::a()
108
+
109
+
110
+ template<typename IntType>
111
+ __host__ __device__
112
+ typename uniform_int_distribution<IntType>::result_type
113
+ uniform_int_distribution<IntType>
114
+ ::b(void) const
115
+ {
116
+ return m_param.second;
117
+ } // end uniform_int_distribution::b()
118
+
119
+
120
+ template<typename IntType>
121
+ __host__ __device__
122
+ typename uniform_int_distribution<IntType>::param_type
123
+ uniform_int_distribution<IntType>
124
+ ::param(void) const
125
+ {
126
+ return m_param;
127
+ } // end uniform_int_distribution::param()
128
+
129
+
130
+ template<typename IntType>
131
+ __host__ __device__
132
+ void uniform_int_distribution<IntType>
133
+ ::param(const param_type &parm)
134
+ {
135
+ m_param = parm;
136
+ } // end uniform_int_distribution::param()
137
+
138
+
139
+ template<typename IntType>
140
+ __host__ __device__
141
+ typename uniform_int_distribution<IntType>::result_type
142
+ uniform_int_distribution<IntType>
143
+ ::min THRUST_PREVENT_MACRO_SUBSTITUTION (void) const
144
+ {
145
+ return a();
146
+ } // end uniform_int_distribution::min()
147
+
148
+
149
+ template<typename IntType>
150
+ __host__ __device__
151
+ typename uniform_int_distribution<IntType>::result_type
152
+ uniform_int_distribution<IntType>
153
+ ::max THRUST_PREVENT_MACRO_SUBSTITUTION (void) const
154
+ {
155
+ return b();
156
+ } // end uniform_int_distribution::max()
157
+
158
+
159
+ template<typename IntType>
160
+ __host__ __device__
161
+ bool uniform_int_distribution<IntType>
162
+ ::equal(const uniform_int_distribution &rhs) const
163
+ {
164
+ return param() == rhs.param();
165
+ }
166
+
167
+
168
+ template<typename IntType>
169
+ template<typename CharT, typename Traits>
170
+ std::basic_ostream<CharT,Traits>&
171
+ uniform_int_distribution<IntType>
172
+ ::stream_out(std::basic_ostream<CharT,Traits> &os) const
173
+ {
174
+ typedef std::basic_ostream<CharT,Traits> ostream_type;
175
+ typedef typename ostream_type::ios_base ios_base;
176
+
177
+ // save old flags and fill character
178
+ const typename ios_base::fmtflags flags = os.flags();
179
+ const CharT fill = os.fill();
180
+
181
+ const CharT space = os.widen(' ');
182
+ os.flags(ios_base::dec | ios_base::fixed | ios_base::left);
183
+ os.fill(space);
184
+
185
+ os << a() << space << b();
186
+
187
+ // restore old flags and fill character
188
+ os.flags(flags);
189
+ os.fill(fill);
190
+ return os;
191
+ }
192
+
193
+
194
+ template<typename IntType>
195
+ template<typename CharT, typename Traits>
196
+ std::basic_istream<CharT,Traits>&
197
+ uniform_int_distribution<IntType>
198
+ ::stream_in(std::basic_istream<CharT,Traits> &is)
199
+ {
200
+ typedef std::basic_istream<CharT,Traits> istream_type;
201
+ typedef typename istream_type::ios_base ios_base;
202
+
203
+ // save old flags
204
+ const typename ios_base::fmtflags flags = is.flags();
205
+
206
+ is.flags(ios_base::skipws);
207
+
208
+ is >> m_param.first >> m_param.second;
209
+
210
+ // restore old flags
211
+ is.flags(flags);
212
+ return is;
213
+ }
214
+
215
+
216
+ template<typename IntType>
217
+ __host__ __device__
218
+ bool operator==(const uniform_int_distribution<IntType> &lhs,
219
+ const uniform_int_distribution<IntType> &rhs)
220
+ {
221
+ return thrust::random::detail::random_core_access::equal(lhs,rhs);
222
+ }
223
+
224
+
225
+ template<typename IntType>
226
+ __host__ __device__
227
+ bool operator!=(const uniform_int_distribution<IntType> &lhs,
228
+ const uniform_int_distribution<IntType> &rhs)
229
+ {
230
+ return !(lhs == rhs);
231
+ }
232
+
233
+
234
+ template<typename IntType,
235
+ typename CharT, typename Traits>
236
+ std::basic_ostream<CharT,Traits>&
237
+ operator<<(std::basic_ostream<CharT,Traits> &os,
238
+ const uniform_int_distribution<IntType> &d)
239
+ {
240
+ return thrust::random::detail::random_core_access::stream_out(os,d);
241
+ }
242
+
243
+
244
+ template<typename IntType,
245
+ typename CharT, typename Traits>
246
+ std::basic_istream<CharT,Traits>&
247
+ operator>>(std::basic_istream<CharT,Traits> &is,
248
+ uniform_int_distribution<IntType> &d)
249
+ {
250
+ return thrust::random::detail::random_core_access::stream_in(is,d);
251
+ }
252
+
253
+
254
+ } // end random
255
+
256
+ THRUST_NAMESPACE_END
257
+
miniCUDA124/include/thrust/random/detail/uniform_real_distribution.inl ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/random/uniform_real_distribution.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+
33
+ namespace random
34
+ {
35
+
36
+
37
+ template<typename RealType>
38
+ __host__ __device__
39
+ uniform_real_distribution<RealType>
40
+ ::uniform_real_distribution(RealType a, RealType b)
41
+ :m_param(a,b)
42
+ {
43
+ } // end uniform_real_distribution::uniform_real_distribution()
44
+
45
+ template<typename RealType>
46
+ __host__ __device__
47
+ uniform_real_distribution<RealType>
48
+ ::uniform_real_distribution(const param_type &parm)
49
+ :m_param(parm)
50
+ {
51
+ } // end uniform_real_distribution::uniform_real_distribution()
52
+
53
+ template<typename RealType>
54
+ __host__ __device__
55
+ void uniform_real_distribution<RealType>
56
+ ::reset(void)
57
+ {
58
+ } // end uniform_real_distribution::reset()
59
+
60
+ template<typename RealType>
61
+ template<typename UniformRandomNumberGenerator>
62
+ __host__ __device__
63
+ typename uniform_real_distribution<RealType>::result_type
64
+ uniform_real_distribution<RealType>
65
+ ::operator()(UniformRandomNumberGenerator &urng)
66
+ {
67
+ return operator()(urng, m_param);
68
+ } // end uniform_real::operator()()
69
+
70
+ template<typename RealType>
71
+ template<typename UniformRandomNumberGenerator>
72
+ __host__ __device__
73
+ typename uniform_real_distribution<RealType>::result_type
74
+ uniform_real_distribution<RealType>
75
+ ::operator()(UniformRandomNumberGenerator &urng,
76
+ const param_type &parm)
77
+ {
78
+ // call the urng & map its result to [0,1)
79
+ result_type result = static_cast<result_type>(urng() - UniformRandomNumberGenerator::min);
80
+
81
+ // adding one to the denominator ensures that the interval is half-open at 1.0
82
+ // XXX adding 1.0 to a potentially large floating point number seems like a bad idea
83
+ // XXX OTOH adding 1 to what is potentially UINT_MAX also seems like a bad idea
84
+ // XXX we could statically check if 1u + (max - min) is representable and do that, otherwise use the current implementation
85
+ result /= (result_type(1) + static_cast<result_type>(UniformRandomNumberGenerator::max - UniformRandomNumberGenerator::min));
86
+
87
+ return (result * (parm.second - parm.first)) + parm.first;
88
+ } // end uniform_real::operator()()
89
+
90
+ template<typename RealType>
91
+ __host__ __device__
92
+ typename uniform_real_distribution<RealType>::result_type
93
+ uniform_real_distribution<RealType>
94
+ ::a(void) const
95
+ {
96
+ return m_param.first;
97
+ } // end uniform_real::a()
98
+
99
+ template<typename RealType>
100
+ __host__ __device__
101
+ typename uniform_real_distribution<RealType>::result_type
102
+ uniform_real_distribution<RealType>
103
+ ::b(void) const
104
+ {
105
+ return m_param.second;
106
+ } // end uniform_real_distribution::b()
107
+
108
+ template<typename RealType>
109
+ __host__ __device__
110
+ typename uniform_real_distribution<RealType>::param_type
111
+ uniform_real_distribution<RealType>
112
+ ::param(void) const
113
+ {
114
+ return m_param;;
115
+ } // end uniform_real_distribution::param()
116
+
117
+ template<typename RealType>
118
+ __host__ __device__
119
+ void uniform_real_distribution<RealType>
120
+ ::param(const param_type &parm)
121
+ {
122
+ m_param = parm;
123
+ } // end uniform_real_distribution::param()
124
+
125
+ template<typename RealType>
126
+ __host__ __device__
127
+ typename uniform_real_distribution<RealType>::result_type
128
+ uniform_real_distribution<RealType>
129
+ ::min THRUST_PREVENT_MACRO_SUBSTITUTION (void) const
130
+ {
131
+ return a();
132
+ } // end uniform_real_distribution::min()
133
+
134
+ template<typename RealType>
135
+ __host__ __device__
136
+ typename uniform_real_distribution<RealType>::result_type
137
+ uniform_real_distribution<RealType>
138
+ ::max THRUST_PREVENT_MACRO_SUBSTITUTION (void) const
139
+ {
140
+ return b();
141
+ } // end uniform_real_distribution::max()
142
+
143
+
144
+ template<typename RealType>
145
+ __host__ __device__
146
+ bool uniform_real_distribution<RealType>
147
+ ::equal(const uniform_real_distribution &rhs) const
148
+ {
149
+ return m_param == rhs.param();
150
+ }
151
+
152
+
153
+ template<typename RealType>
154
+ template<typename CharT, typename Traits>
155
+ std::basic_ostream<CharT,Traits>&
156
+ uniform_real_distribution<RealType>
157
+ ::stream_out(std::basic_ostream<CharT,Traits> &os) const
158
+ {
159
+ typedef std::basic_ostream<CharT,Traits> ostream_type;
160
+ typedef typename ostream_type::ios_base ios_base;
161
+
162
+ // save old flags and fill character
163
+ const typename ios_base::fmtflags flags = os.flags();
164
+ const CharT fill = os.fill();
165
+
166
+ const CharT space = os.widen(' ');
167
+ os.flags(ios_base::dec | ios_base::fixed | ios_base::left);
168
+ os.fill(space);
169
+
170
+ os << a() << space << b();
171
+
172
+ // restore old flags and fill character
173
+ os.flags(flags);
174
+ os.fill(fill);
175
+ return os;
176
+ }
177
+
178
+
179
+ template<typename RealType>
180
+ template<typename CharT, typename Traits>
181
+ std::basic_istream<CharT,Traits>&
182
+ uniform_real_distribution<RealType>
183
+ ::stream_in(std::basic_istream<CharT,Traits> &is)
184
+ {
185
+ typedef std::basic_istream<CharT,Traits> istream_type;
186
+ typedef typename istream_type::ios_base ios_base;
187
+
188
+ // save old flags
189
+ const typename ios_base::fmtflags flags = is.flags();
190
+
191
+ is.flags(ios_base::skipws);
192
+
193
+ is >> m_param.first >> m_param.second;
194
+
195
+ // restore old flags
196
+ is.flags(flags);
197
+ return is;
198
+ }
199
+
200
+
201
+ template<typename RealType>
202
+ __host__ __device__
203
+ bool operator==(const uniform_real_distribution<RealType> &lhs,
204
+ const uniform_real_distribution<RealType> &rhs)
205
+ {
206
+ return thrust::random::detail::random_core_access::equal(lhs,rhs);
207
+ }
208
+
209
+
210
+ template<typename RealType>
211
+ __host__ __device__
212
+ bool operator!=(const uniform_real_distribution<RealType> &lhs,
213
+ const uniform_real_distribution<RealType> &rhs)
214
+ {
215
+ return !(lhs == rhs);
216
+ }
217
+
218
+
219
+ template<typename RealType,
220
+ typename CharT, typename Traits>
221
+ std::basic_ostream<CharT,Traits>&
222
+ operator<<(std::basic_ostream<CharT,Traits> &os,
223
+ const uniform_real_distribution<RealType> &d)
224
+ {
225
+ return thrust::random::detail::random_core_access::stream_out(os,d);
226
+ }
227
+
228
+
229
+ template<typename RealType,
230
+ typename CharT, typename Traits>
231
+ std::basic_istream<CharT,Traits>&
232
+ operator>>(std::basic_istream<CharT,Traits> &is,
233
+ uniform_real_distribution<RealType> &d)
234
+ {
235
+ return thrust::random::detail::random_core_access::stream_in(is,d);
236
+ }
237
+
238
+
239
+ } // end random
240
+
241
+ THRUST_NAMESPACE_END
242
+
miniCUDA124/include/thrust/random/detail/xor_combine_engine.inl ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #include <thrust/random/xor_combine_engine.h>
30
+ #include <thrust/random/detail/random_core_access.h>
31
+
32
+ THRUST_NAMESPACE_BEGIN
33
+
34
+ namespace random
35
+ {
36
+
37
+ template<typename Engine1, size_t s1,
38
+ typename Engine2, size_t s2>
39
+ __host__ __device__
40
+ xor_combine_engine<Engine1,s1,Engine2,s2>
41
+ ::xor_combine_engine(void)
42
+ :m_b1(),m_b2()
43
+ {
44
+ } // end xor_combine_engine::xor_combine_engine()
45
+
46
+ template<typename Engine1, size_t s1,
47
+ typename Engine2, size_t s2>
48
+ __host__ __device__
49
+ xor_combine_engine<Engine1,s1,Engine2,s2>
50
+ ::xor_combine_engine(const base1_type &urng1, const base2_type &urng2)
51
+ :m_b1(urng1),m_b2(urng2)
52
+ {
53
+ } // end xor_combine_engine::xor_combine_engine()
54
+
55
+ template<typename Engine1, size_t s1,
56
+ typename Engine2, size_t s2>
57
+ __host__ __device__
58
+ xor_combine_engine<Engine1,s1,Engine2,s2>
59
+ ::xor_combine_engine(result_type s)
60
+ :m_b1(s),m_b2(s)
61
+ {
62
+ } // end xor_combine_engine::xor_combine_engine()
63
+
64
+ template<typename Engine1, size_t s1,
65
+ typename Engine2, size_t s2>
66
+ __host__ __device__
67
+ void xor_combine_engine<Engine1,s1,Engine2,s2>
68
+ ::seed(void)
69
+ {
70
+ m_b1.seed();
71
+ m_b2.seed();
72
+ } // end xor_combine_engine::seed()
73
+
74
+ template<typename Engine1, size_t s1,
75
+ typename Engine2, size_t s2>
76
+ __host__ __device__
77
+ void xor_combine_engine<Engine1,s1,Engine2,s2>
78
+ ::seed(result_type s)
79
+ {
80
+ m_b1.seed(s);
81
+ m_b2.seed(s);
82
+ } // end xor_combine_engine::seed()
83
+
84
+ template<typename Engine1, size_t s1,
85
+ typename Engine2, size_t s2>
86
+ __host__ __device__
87
+ const typename xor_combine_engine<Engine1,s1,Engine2,s2>::base1_type &
88
+ xor_combine_engine<Engine1,s1,Engine2,s2>
89
+ ::base1(void) const
90
+ {
91
+ return m_b1;
92
+ } // end xor_combine_engine::base1()
93
+
94
+ template<typename Engine1, size_t s1,
95
+ typename Engine2, size_t s2>
96
+ __host__ __device__
97
+ const typename xor_combine_engine<Engine1,s1,Engine2,s2>::base2_type &
98
+ xor_combine_engine<Engine1,s1,Engine2,s2>
99
+ ::base2(void) const
100
+ {
101
+ return m_b2;
102
+ } // end xor_combine_engine::base2()
103
+
104
+ template<typename Engine1, size_t s1,
105
+ typename Engine2, size_t s2>
106
+ __host__ __device__
107
+ typename xor_combine_engine<Engine1,s1,Engine2,s2>::result_type
108
+ xor_combine_engine<Engine1,s1,Engine2,s2>
109
+ ::operator()(void)
110
+ {
111
+ return (result_type(m_b1() - base1_type::min) << shift1) ^
112
+ (result_type(m_b2() - base2_type::min) << shift2);
113
+ } // end xor_combine_engine::operator()()
114
+
115
+ template<typename Engine1, size_t s1,
116
+ typename Engine2, size_t s2>
117
+ __host__ __device__
118
+ void xor_combine_engine<Engine1, s1, Engine2, s2>
119
+ ::discard(unsigned long long z)
120
+ {
121
+ for(; z > 0; --z)
122
+ {
123
+ this->operator()();
124
+ } // end for
125
+ } // end xor_combine_engine::discard()
126
+
127
+
128
+ template<typename Engine1, size_t s1, typename Engine2, size_t s2>
129
+ template<typename CharT, typename Traits>
130
+ std::basic_ostream<CharT,Traits>& xor_combine_engine<Engine1,s1,Engine2,s2>
131
+ ::stream_out(std::basic_ostream<CharT,Traits> &os) const
132
+ {
133
+ typedef std::basic_ostream<CharT,Traits> ostream_type;
134
+ typedef typename ostream_type::ios_base ios_base;
135
+
136
+ // save old flags and fill character
137
+ const typename ios_base::fmtflags flags = os.flags();
138
+ const CharT fill = os.fill();
139
+
140
+ const CharT space = os.widen(' ');
141
+ os.flags(ios_base::dec | ios_base::fixed | ios_base::left);
142
+ os.fill(space);
143
+
144
+ // output each base engine in turn
145
+ os << base1() << space << base2();
146
+
147
+ // restore old flags and fill character
148
+ os.flags(flags);
149
+ os.fill(fill);
150
+ return os;
151
+ }
152
+
153
+
154
+ template<typename Engine1, size_t s1, typename Engine2, size_t s2>
155
+ template<typename CharT, typename Traits>
156
+ std::basic_istream<CharT,Traits>& xor_combine_engine<Engine1,s1,Engine2,s2>
157
+ ::stream_in(std::basic_istream<CharT,Traits> &is)
158
+ {
159
+ typedef std::basic_istream<CharT,Traits> istream_type;
160
+ typedef typename istream_type::ios_base ios_base;
161
+
162
+ // save old flags
163
+ const typename ios_base::fmtflags flags = is.flags();
164
+
165
+ is.flags(ios_base::skipws);
166
+
167
+ // input each base engine in turn
168
+ is >> m_b1 >> m_b2;
169
+
170
+ // restore old flags
171
+ is.flags(flags);
172
+ return is;
173
+ }
174
+
175
+
176
+ template<typename Engine1, size_t s1, typename Engine2, size_t s2>
177
+ __host__ __device__
178
+ bool xor_combine_engine<Engine1,s1,Engine2,s2>
179
+ ::equal(const xor_combine_engine<Engine1,s1,Engine2,s2> &rhs) const
180
+ {
181
+ return (m_b1 == rhs.m_b1) && (m_b2 == rhs.m_b2);
182
+ }
183
+
184
+
185
+ template<typename Engine1, size_t s1, typename Engine2, size_t s2,
186
+ typename CharT, typename Traits>
187
+ std::basic_ostream<CharT,Traits>&
188
+ operator<<(std::basic_ostream<CharT,Traits> &os,
189
+ const xor_combine_engine<Engine1,s1,Engine2,s2> &e)
190
+ {
191
+ return thrust::random::detail::random_core_access::stream_out(os,e);
192
+ }
193
+
194
+
195
+ template<typename Engine1, size_t s1, typename Engine2, size_t s2,
196
+ typename CharT, typename Traits>
197
+ std::basic_istream<CharT,Traits>&
198
+ operator>>(std::basic_istream<CharT,Traits> &is,
199
+ xor_combine_engine<Engine1,s1,Engine2,s2> &e)
200
+ {
201
+ return thrust::random::detail::random_core_access::stream_in(is,e);
202
+ }
203
+
204
+
205
+ template<typename Engine1, size_t s1, typename Engine2, size_t s2>
206
+ __host__ __device__
207
+ bool operator==(const xor_combine_engine<Engine1,s1,Engine2,s2> &lhs,
208
+ const xor_combine_engine<Engine1,s1,Engine2,s2> &rhs)
209
+ {
210
+ return thrust::random::detail::random_core_access::equal(lhs,rhs);
211
+ }
212
+
213
+
214
+ template<typename Engine1, size_t s1, typename Engine2, size_t s2>
215
+ __host__ __device__
216
+ bool operator!=(const xor_combine_engine<Engine1,s1,Engine2,s2> &lhs,
217
+ const xor_combine_engine<Engine1,s1,Engine2,s2> &rhs)
218
+ {
219
+ return !(lhs == rhs);
220
+ }
221
+
222
+
223
+ } // end random
224
+
225
+ THRUST_NAMESPACE_END
226
+
miniCUDA124/include/thrust/random/detail/xor_combine_engine_max.h ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/type_traits.h>
30
+ #include <thrust/detail/mpl/math.h>
31
+ #include <limits>
32
+ #include <cstddef>
33
+
34
+ THRUST_NAMESPACE_BEGIN
35
+
36
+ namespace random
37
+ {
38
+
39
+ namespace detail
40
+ {
41
+
42
+
43
+ namespace math = thrust::detail::mpl::math;
44
+
45
+
46
+ namespace detail
47
+ {
48
+
49
+ // two cases for this function avoids compile-time warnings of overflow
50
+ template<typename UIntType, UIntType w,
51
+ UIntType lhs, UIntType rhs,
52
+ bool shift_will_overflow>
53
+ struct lshift_w
54
+ {
55
+ static const UIntType value = 0;
56
+ };
57
+
58
+
59
+ template<typename UIntType, UIntType w,
60
+ UIntType lhs, UIntType rhs>
61
+ struct lshift_w<UIntType,w,lhs,rhs,false>
62
+ {
63
+ static const UIntType value = lhs << rhs;
64
+ };
65
+
66
+ } // end detail
67
+
68
+
69
+ template<typename UIntType, UIntType w,
70
+ UIntType lhs, UIntType rhs>
71
+ struct lshift_w
72
+ {
73
+ static const bool shift_will_overflow = rhs >= w;
74
+
75
+ static const UIntType value = detail::lshift_w<UIntType, w, lhs, rhs, shift_will_overflow>::value;
76
+ };
77
+
78
+
79
+ template<typename UIntType, UIntType lhs, UIntType rhs>
80
+ struct lshift
81
+ : lshift_w<UIntType, std::numeric_limits<UIntType>::digits, lhs, rhs>
82
+ {};
83
+
84
+
85
+ template<typename UIntType, int p>
86
+ struct two_to_the_power
87
+ : lshift<UIntType, 1, p>
88
+ {};
89
+
90
+
91
+ template<typename result_type, result_type a, result_type b, int d>
92
+ class xor_combine_engine_max_aux_constants
93
+ {
94
+ public:
95
+ static const result_type two_to_the_d = two_to_the_power<result_type, d>::value;
96
+ static const result_type c = lshift<result_type, a, d>::value;
97
+
98
+ static const result_type t =
99
+ math::max<
100
+ result_type,
101
+ c,
102
+ b
103
+ >::value;
104
+
105
+ static const result_type u =
106
+ math::min<
107
+ result_type,
108
+ c,
109
+ b
110
+ >::value;
111
+
112
+ static const result_type p = math::log2<u>::value;
113
+ static const result_type two_to_the_p = two_to_the_power<result_type, p>::value;
114
+
115
+ static const result_type k = math::div<result_type, t, two_to_the_p>::value;
116
+ };
117
+
118
+
119
+ template<typename result_type, result_type, result_type, int> struct xor_combine_engine_max_aux;
120
+
121
+
122
+ template<typename result_type, result_type a, result_type b, int d>
123
+ struct xor_combine_engine_max_aux_case4
124
+ {
125
+ typedef xor_combine_engine_max_aux_constants<result_type,a,b,d> constants;
126
+
127
+ static const result_type k_plus_1_times_two_to_the_p =
128
+ lshift<
129
+ result_type,
130
+ math::plus<result_type,constants::k,1>::value,
131
+ constants::p
132
+ >::value;
133
+
134
+ static const result_type M =
135
+ xor_combine_engine_max_aux<
136
+ result_type,
137
+ math::div<
138
+ result_type,
139
+ math::mod<
140
+ result_type,
141
+ constants::u,
142
+ constants::two_to_the_p
143
+ >::value,
144
+ constants::two_to_the_p
145
+ >::value,
146
+ math::mod<
147
+ result_type,
148
+ constants::t,
149
+ constants::two_to_the_p
150
+ >::value,
151
+ d
152
+ >::value;
153
+
154
+ static const result_type value = math::plus<result_type, k_plus_1_times_two_to_the_p, M>::value;
155
+ };
156
+
157
+
158
+ template<typename result_type, result_type a, result_type b, int d>
159
+ struct xor_combine_engine_max_aux_case3
160
+ {
161
+ typedef xor_combine_engine_max_aux_constants<result_type,a,b,d> constants;
162
+
163
+ static const result_type k_plus_1_times_two_to_the_p =
164
+ lshift<
165
+ result_type,
166
+ math::plus<result_type,constants::k,1>::value,
167
+ constants::p
168
+ >::value;
169
+
170
+ static const result_type M =
171
+ xor_combine_engine_max_aux<
172
+ result_type,
173
+ math::div<
174
+ result_type,
175
+ math::mod<
176
+ result_type,
177
+ constants::t,
178
+ constants::two_to_the_p
179
+ >::value,
180
+ constants::two_to_the_p
181
+ >::value,
182
+ math::mod<
183
+ result_type,
184
+ constants::u,
185
+ constants::two_to_the_p
186
+ >::value,
187
+ d
188
+ >::value;
189
+
190
+ static const result_type value = math::plus<result_type, k_plus_1_times_two_to_the_p, M>::value;
191
+ };
192
+
193
+
194
+
195
+ template<typename result_type, result_type a, result_type b, int d>
196
+ struct xor_combine_engine_max_aux_case2
197
+ {
198
+ typedef xor_combine_engine_max_aux_constants<result_type,a,b,d> constants;
199
+
200
+ static const result_type k_plus_1_times_two_to_the_p =
201
+ lshift<
202
+ result_type,
203
+ math::plus<result_type,constants::k,1>::value,
204
+ constants::p
205
+ >::value;
206
+
207
+ static const result_type value =
208
+ math::minus<
209
+ result_type,
210
+ k_plus_1_times_two_to_the_p,
211
+ 1
212
+ >::value;
213
+ };
214
+
215
+
216
+ template<typename result_type, result_type a, result_type b, int d>
217
+ struct xor_combine_engine_max_aux_case1
218
+ {
219
+ static const result_type c = lshift<result_type, a, d>::value;
220
+
221
+ static const result_type value = math::plus<result_type,c,b>::value;
222
+ };
223
+
224
+
225
+ template<typename result_type, result_type a, result_type b, int d>
226
+ struct xor_combine_engine_max_aux_2
227
+ {
228
+ typedef xor_combine_engine_max_aux_constants<result_type,a,b,d> constants;
229
+
230
+ static const result_type value =
231
+ thrust::detail::eval_if<
232
+ // if k is odd...
233
+ math::is_odd<result_type, constants::k>::value,
234
+ thrust::detail::identity_<
235
+ thrust::detail::integral_constant<
236
+ result_type,
237
+ xor_combine_engine_max_aux_case2<result_type,a,b,d>::value
238
+ >
239
+ >,
240
+ thrust::detail::eval_if<
241
+ // otherwise if a * 2^3 >= b, then case 3
242
+ a * constants::two_to_the_d >= b,
243
+ thrust::detail::identity_<
244
+ thrust::detail::integral_constant<
245
+ result_type,
246
+ xor_combine_engine_max_aux_case3<result_type,a,b,d>::value
247
+ >
248
+ >,
249
+ // otherwise, case 4
250
+ thrust::detail::identity_<
251
+ thrust::detail::integral_constant<
252
+ result_type,
253
+ xor_combine_engine_max_aux_case4<result_type,a,b,d>::value
254
+ >
255
+ >
256
+ >
257
+ >::type::value;
258
+ };
259
+
260
+
261
+ template<typename result_type,
262
+ result_type a,
263
+ result_type b,
264
+ int d,
265
+ bool use_case1 = (a == 0) || (b < two_to_the_power<result_type,d>::value)>
266
+ struct xor_combine_engine_max_aux_1
267
+ : xor_combine_engine_max_aux_case1<result_type,a,b,d>
268
+ {};
269
+
270
+
271
+ template<typename result_type,
272
+ result_type a,
273
+ result_type b,
274
+ int d>
275
+ struct xor_combine_engine_max_aux_1<result_type,a,b,d,false>
276
+ : xor_combine_engine_max_aux_2<result_type,a,b,d>
277
+ {};
278
+
279
+
280
+ template<typename result_type,
281
+ result_type a,
282
+ result_type b,
283
+ int d>
284
+ struct xor_combine_engine_max_aux
285
+ : xor_combine_engine_max_aux_1<result_type,a,b,d>
286
+ {};
287
+
288
+
289
+ template<typename Engine1, size_t s1, typename Engine2, size_t s2, typename result_type>
290
+ struct xor_combine_engine_max
291
+ {
292
+ static const size_t w = std::numeric_limits<result_type>::digits;
293
+
294
+ static const result_type m1 =
295
+ math::min<
296
+ result_type,
297
+ result_type(Engine1::max - Engine1::min),
298
+ two_to_the_power<result_type, w-s1>::value - 1
299
+ >::value;
300
+
301
+ static const result_type m2 =
302
+ math::min<
303
+ result_type,
304
+ result_type(Engine2::max - Engine2::min),
305
+ two_to_the_power<result_type, w-s2>::value - 1
306
+ >::value;
307
+
308
+ static const result_type s = s1 - s2;
309
+
310
+ static const result_type M =
311
+ xor_combine_engine_max_aux<
312
+ result_type,
313
+ m1,
314
+ m2,
315
+ s
316
+ >::value;
317
+
318
+ // the value is M(m1,m2,s) lshift_w s2
319
+ static const result_type value =
320
+ lshift_w<
321
+ result_type,
322
+ w,
323
+ M,
324
+ s2
325
+ >::value;
326
+ }; // end xor_combine_engine_max
327
+
328
+ } // end detail
329
+
330
+ } // end random
331
+
332
+ THRUST_NAMESPACE_END
333
+
miniCUDA124/include/thrust/system/cpp/detail/adjacent_difference.h ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
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
+ // this system inherits adjacent_difference
30
+ #include <thrust/system/detail/sequential/adjacent_difference.h>
31
+
miniCUDA124/include/thrust/system/cpp/detail/assign_value.h ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
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
+ // this system inherits assign_value
30
+ #include <thrust/system/detail/sequential/assign_value.h>
31
+
miniCUDA124/include/thrust/system/cpp/detail/binary_search.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
+
29
+ #include <thrust/system/cpp/detail/execution_policy.h>
30
+
31
+ // this system inherits the binary search algorithms
32
+ #include <thrust/system/detail/sequential/binary_search.h>
33
+
miniCUDA124/include/thrust/system/cpp/detail/copy.h ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
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
+ // this system inherits copy
30
+ #include <thrust/system/detail/sequential/copy.h>
31
+
miniCUDA124/include/thrust/system/cpp/detail/copy_if.h ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
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
+ // this system inherits copy_if
30
+ #include <thrust/system/detail/sequential/copy_if.h>
31
+
miniCUDA124/include/thrust/system/cpp/detail/count.h ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ // this system has no special version of this algorithm
30
+
miniCUDA124/include/thrust/system/cpp/detail/equal.h ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ // this system has no special version of this algorithm
30
+
miniCUDA124/include/thrust/system/cpp/detail/execution_policy.h ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/system/detail/sequential/execution_policy.h>
29
+
30
+ THRUST_NAMESPACE_BEGIN
31
+ namespace system
32
+ {
33
+ // put the canonical tag in the same ns as the backend's entry points
34
+ namespace cpp
35
+ {
36
+ namespace detail
37
+ {
38
+
39
+ // this awkward sequence of definitions arise
40
+ // from the desire both for tag to derive
41
+ // from execution_policy and for execution_policy
42
+ // to convert to tag (when execution_policy is not
43
+ // an ancestor of tag)
44
+
45
+ // forward declaration of tag
46
+ struct tag;
47
+
48
+ // forward declaration of execution_policy
49
+ template<typename> struct execution_policy;
50
+
51
+ // specialize execution_policy for tag
52
+ template<>
53
+ struct execution_policy<tag>
54
+ : thrust::system::detail::sequential::execution_policy<tag>
55
+ {};
56
+
57
+ // tag's definition comes before the
58
+ // generic definition of execution_policy
59
+ struct tag : execution_policy<tag> {};
60
+
61
+ // allow conversion to tag when it is not a successor
62
+ template<typename Derived>
63
+ struct execution_policy
64
+ : thrust::system::detail::sequential::execution_policy<Derived>
65
+ {
66
+ typedef tag tag_type;
67
+ operator tag() const { return tag(); }
68
+ };
69
+
70
+ } // end detail
71
+
72
+ // alias execution_policy and tag here
73
+ using thrust::system::cpp::detail::execution_policy;
74
+ using thrust::system::cpp::detail::tag;
75
+
76
+ } // end cpp
77
+ } // end system
78
+
79
+ // alias items at top-level
80
+ namespace cpp
81
+ {
82
+
83
+ using thrust::system::cpp::execution_policy;
84
+ using thrust::system::cpp::tag;
85
+
86
+ } // end cpp
87
+ THRUST_NAMESPACE_END
88
+
miniCUDA124/include/thrust/system/cpp/execution_policy.h ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 thrust/system/cpp/execution_policy.h
18
+ * \brief Execution policies for Thrust's Standard C++ system.
19
+ */
20
+
21
+ #pragma once
22
+
23
+ #include <thrust/detail/config.h>
24
+
25
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
26
+ # pragma GCC system_header
27
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
28
+ # pragma clang system_header
29
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
30
+ # pragma system_header
31
+ #endif // no system header
32
+
33
+ // get the execution policies definitions first
34
+ #include <thrust/system/cpp/detail/execution_policy.h>
35
+
36
+ // get the definition of par
37
+ #include <thrust/system/cpp/detail/par.h>
38
+
39
+ // now get all the algorithm definitions
40
+
41
+ #include <thrust/system/cpp/detail/adjacent_difference.h>
42
+ #include <thrust/system/cpp/detail/assign_value.h>
43
+ #include <thrust/system/cpp/detail/binary_search.h>
44
+ #include <thrust/system/cpp/detail/copy.h>
45
+ #include <thrust/system/cpp/detail/copy_if.h>
46
+ #include <thrust/system/cpp/detail/count.h>
47
+ #include <thrust/system/cpp/detail/equal.h>
48
+ #include <thrust/system/cpp/detail/extrema.h>
49
+ #include <thrust/system/cpp/detail/fill.h>
50
+ #include <thrust/system/cpp/detail/find.h>
51
+ #include <thrust/system/cpp/detail/for_each.h>
52
+ #include <thrust/system/cpp/detail/gather.h>
53
+ #include <thrust/system/cpp/detail/generate.h>
54
+ #include <thrust/system/cpp/detail/get_value.h>
55
+ #include <thrust/system/cpp/detail/inner_product.h>
56
+ #include <thrust/system/cpp/detail/iter_swap.h>
57
+ #include <thrust/system/cpp/detail/logical.h>
58
+ #include <thrust/system/cpp/detail/malloc_and_free.h>
59
+ #include <thrust/system/cpp/detail/merge.h>
60
+ #include <thrust/system/cpp/detail/mismatch.h>
61
+ #include <thrust/system/cpp/detail/partition.h>
62
+ #include <thrust/system/cpp/detail/reduce.h>
63
+ #include <thrust/system/cpp/detail/reduce_by_key.h>
64
+ #include <thrust/system/cpp/detail/remove.h>
65
+ #include <thrust/system/cpp/detail/replace.h>
66
+ #include <thrust/system/cpp/detail/reverse.h>
67
+ #include <thrust/system/cpp/detail/scan.h>
68
+ #include <thrust/system/cpp/detail/scan_by_key.h>
69
+ #include <thrust/system/cpp/detail/scatter.h>
70
+ #include <thrust/system/cpp/detail/sequence.h>
71
+ #include <thrust/system/cpp/detail/set_operations.h>
72
+ #include <thrust/system/cpp/detail/sort.h>
73
+ #include <thrust/system/cpp/detail/swap_ranges.h>
74
+ #include <thrust/system/cpp/detail/tabulate.h>
75
+ #include <thrust/system/cpp/detail/transform.h>
76
+ #include <thrust/system/cpp/detail/transform_reduce.h>
77
+ #include <thrust/system/cpp/detail/transform_scan.h>
78
+ #include <thrust/system/cpp/detail/uninitialized_copy.h>
79
+ #include <thrust/system/cpp/detail/uninitialized_fill.h>
80
+ #include <thrust/system/cpp/detail/unique.h>
81
+ #include <thrust/system/cpp/detail/unique_by_key.h>
82
+
83
+
84
+ // define these entities here for the purpose of Doxygenating them
85
+ // they are actually defined elsewhere
86
+ #if 0
87
+ THRUST_NAMESPACE_BEGIN
88
+ namespace system
89
+ {
90
+ namespace cpp
91
+ {
92
+
93
+
94
+ /*! \addtogroup execution_policies
95
+ * \{
96
+ */
97
+
98
+
99
+ /*! \p thrust::system::cpp::execution_policy is the base class for all Thrust parallel execution
100
+ * policies which are derived from Thrust's standard C++ backend system.
101
+ */
102
+ template<typename DerivedPolicy>
103
+ struct execution_policy : thrust::execution_policy<DerivedPolicy>
104
+ {};
105
+
106
+
107
+ /*! \p thrust::system::cpp::tag is a type representing Thrust's standard C++ backend system in C++'s type system.
108
+ * Iterators "tagged" with a type which is convertible to \p cpp::tag assert that they may be
109
+ * "dispatched" to algorithm implementations in the \p cpp system.
110
+ */
111
+ struct tag : thrust::system::cpp::execution_policy<tag> { unspecified };
112
+
113
+
114
+ /*!
115
+ * \p thrust::system::cpp::par is the parallel execution policy associated with Thrust's standard
116
+ * C++ backend system.
117
+ *
118
+ * Instead of relying on implicit algorithm dispatch through iterator system tags, users may
119
+ * directly target Thrust's C++ backend system by providing \p thrust::cpp::par as an algorithm
120
+ * parameter.
121
+ *
122
+ * Explicit dispatch can be useful in avoiding the introduction of data copies into containers such
123
+ * as \p thrust::cpp::vector.
124
+ *
125
+ * The type of \p thrust::cpp::par is implementation-defined.
126
+ *
127
+ * The following code snippet demonstrates how to use \p thrust::cpp::par to explicitly dispatch an
128
+ * invocation of \p thrust::for_each to the standard C++ backend system:
129
+ *
130
+ * \code
131
+ * #include <thrust/for_each.h>
132
+ * #include <thrust/system/cpp/execution_policy.h>
133
+ * #include <cstdio>
134
+ *
135
+ * struct printf_functor
136
+ * {
137
+ * __host__ __device__
138
+ * void operator()(int x)
139
+ * {
140
+ * printf("%d\n", x);
141
+ * }
142
+ * };
143
+ * ...
144
+ * int vec[3];
145
+ * vec[0] = 0; vec[1] = 1; vec[2] = 2;
146
+ *
147
+ * thrust::for_each(thrust::cpp::par, vec.begin(), vec.end(), printf_functor());
148
+ *
149
+ * // 0 1 2 is printed to standard output in some unspecified order
150
+ * \endcode
151
+ */
152
+ static const unspecified par;
153
+
154
+
155
+ /*! \}
156
+ */
157
+
158
+
159
+ } // end cpp
160
+ } // end system
161
+ THRUST_NAMESPACE_END
162
+ #endif
163
+
164
+