paredeyes commited on
Commit
a1b80c9
·
verified ·
1 Parent(s): 230dad3

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. ComfyUI-YoloWorld-EfficientSAM/efficient_sam_s_cpu.jit +3 -0
  3. ffmpeg/bin/avfilter-10.dll +3 -0
  4. miniCUDA124/include/thrust/system/tbb/detail/count.h +31 -0
  5. miniCUDA124/include/thrust/system/tbb/detail/equal.h +31 -0
  6. miniCUDA124/include/thrust/system/tbb/detail/execution_policy.h +90 -0
  7. miniCUDA124/include/thrust/system/tbb/detail/extrema.h +74 -0
  8. miniCUDA124/include/thrust/system/tbb/detail/fill.h +31 -0
  9. miniCUDA124/include/thrust/system/tbb/detail/find.h +53 -0
  10. miniCUDA124/include/thrust/system/tbb/detail/for_each.h +61 -0
  11. miniCUDA124/include/thrust/system/tbb/detail/for_each.inl +110 -0
  12. miniCUDA124/include/thrust/system/tbb/detail/gather.h +31 -0
  13. miniCUDA124/include/thrust/system/tbb/detail/generate.h +31 -0
  14. miniCUDA124/include/thrust/system/tbb/detail/get_value.h +31 -0
  15. miniCUDA124/include/thrust/system/tbb/detail/inner_product.h +31 -0
  16. miniCUDA124/include/thrust/system/tbb/detail/iter_swap.h +31 -0
  17. miniCUDA124/include/thrust/system/tbb/detail/logical.h +31 -0
  18. miniCUDA124/include/thrust/system/tbb/detail/malloc_and_free.h +31 -0
  19. miniCUDA124/include/thrust/system/tbb/detail/memory.inl +95 -0
  20. miniCUDA124/include/thrust/system/tbb/detail/merge.h +77 -0
  21. miniCUDA124/include/thrust/system/tbb/detail/merge.inl +297 -0
  22. miniCUDA124/include/thrust/system/tbb/detail/mismatch.h +31 -0
  23. miniCUDA124/include/thrust/system/tbb/detail/par.h +69 -0
  24. miniCUDA124/include/thrust/system/tbb/detail/partition.h +94 -0
  25. miniCUDA124/include/thrust/system/tbb/detail/partition.inl +109 -0
  26. miniCUDA124/include/thrust/system/tbb/detail/per_device_resource.h +30 -0
  27. miniCUDA124/include/thrust/system/tbb/detail/reduce.h +61 -0
  28. miniCUDA124/include/thrust/system/tbb/detail/reduce.inl +138 -0
  29. miniCUDA124/include/thrust/system/tbb/detail/reduce_by_key.h +64 -0
  30. miniCUDA124/include/thrust/system/tbb/detail/reduce_by_key.inl +349 -0
  31. miniCUDA124/include/thrust/system/tbb/detail/reduce_intervals.h +132 -0
  32. miniCUDA124/include/thrust/system/tbb/detail/remove.h +88 -0
  33. miniCUDA124/include/thrust/system/tbb/detail/remove.inl +101 -0
  34. miniCUDA124/include/thrust/system/tbb/detail/replace.h +31 -0
  35. miniCUDA124/include/thrust/system/tbb/detail/reverse.h +31 -0
  36. miniCUDA124/include/thrust/system/tbb/detail/scan.h +71 -0
  37. miniCUDA124/include/thrust/system/tbb/detail/scan.inl +266 -0
  38. miniCUDA124/include/thrust/system/tbb/detail/scan_by_key.h +31 -0
  39. miniCUDA124/include/thrust/system/tbb/detail/scatter.h +31 -0
  40. miniCUDA124/include/thrust/system/tbb/detail/sequence.h +31 -0
  41. miniCUDA124/include/thrust/system/tbb/detail/set_operations.h +31 -0
  42. miniCUDA124/include/thrust/system/tbb/detail/sort.h +62 -0
  43. miniCUDA124/include/thrust/system/tbb/detail/sort.inl +274 -0
  44. miniCUDA124/include/thrust/system/tbb/detail/swap_ranges.h +31 -0
  45. miniCUDA124/include/thrust/system/tbb/detail/tabulate.h +31 -0
  46. miniCUDA124/include/thrust/system/tbb/detail/temporary_buffer.h +30 -0
  47. miniCUDA124/include/thrust/system/tbb/detail/transform.h +31 -0
  48. miniCUDA124/include/thrust/system/tbb/detail/transform_reduce.h +31 -0
  49. miniCUDA124/include/thrust/system/tbb/detail/transform_scan.h +31 -0
  50. miniCUDA124/include/thrust/system/tbb/detail/uninitialized_copy.h +31 -0
.gitattributes CHANGED
@@ -96,3 +96,5 @@ 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
98
  miniCUDA124/bin/nvjpeg64_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
98
  miniCUDA124/bin/nvjpeg64_12.dll filter=lfs diff=lfs merge=lfs -text
99
+ ffmpeg/bin/avfilter-10.dll filter=lfs diff=lfs merge=lfs -text
100
+ ComfyUI-YoloWorld-EfficientSAM/efficient_sam_s_cpu.jit filter=lfs diff=lfs merge=lfs -text
ComfyUI-YoloWorld-EfficientSAM/efficient_sam_s_cpu.jit ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b63ab268e9020b0fb7fc9f46e742644d4c9ea6e5d9caf56045f0afb6475db09
3
+ size 106006979
ffmpeg/bin/avfilter-10.dll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c31032592fd453217bea06e99449d4febc084e96725f8e0761892c4c421352b
3
+ size 28882432
miniCUDA124/include/thrust/system/tbb/detail/count.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 count
30
+ #include <thrust/system/cpp/detail/count.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/equal.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 equal
30
+ #include <thrust/system/cpp/detail/equal.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/execution_policy.h ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/cpp/detail/execution_policy.h>
29
+ #include <thrust/iterator/detail/any_system_tag.h>
30
+ #include <thrust/detail/type_traits.h>
31
+
32
+ THRUST_NAMESPACE_BEGIN
33
+ namespace system
34
+ {
35
+ // put the canonical tag in the same ns as the backend's entry points
36
+ namespace tbb
37
+ {
38
+ namespace detail
39
+ {
40
+
41
+ // this awkward sequence of definitions arise
42
+ // from the desire both for tag to derive
43
+ // from execution_policy and for execution_policy
44
+ // to convert to tag (when execution_policy is not
45
+ // an ancestor of tag)
46
+
47
+ // forward declaration of tag
48
+ struct tag;
49
+
50
+ // forward declaration of execution_policy
51
+ template<typename> struct execution_policy;
52
+
53
+ // specialize execution_policy for tag
54
+ template<>
55
+ struct execution_policy<tag>
56
+ : thrust::system::cpp::detail::execution_policy<tag>
57
+ {};
58
+
59
+ // tag's definition comes before the
60
+ // generic definition of execution_policy
61
+ struct tag : execution_policy<tag> {};
62
+
63
+ // allow conversion to tag when it is not a successor
64
+ template<typename Derived>
65
+ struct execution_policy
66
+ : thrust::system::cpp::detail::execution_policy<Derived>
67
+ {
68
+ typedef tag tag_type;
69
+ operator tag() const { return tag(); }
70
+ };
71
+
72
+ } // end detail
73
+
74
+ // alias execution_policy and tag here
75
+ using thrust::system::tbb::detail::execution_policy;
76
+ using thrust::system::tbb::detail::tag;
77
+
78
+ } // end tbb
79
+ } // end system
80
+
81
+ // alias items at top-level
82
+ namespace tbb
83
+ {
84
+
85
+ using thrust::system::tbb::execution_policy;
86
+ using thrust::system::tbb::tag;
87
+
88
+ } // end tbb
89
+ THRUST_NAMESPACE_END
90
+
miniCUDA124/include/thrust/system/tbb/detail/extrema.h ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/tbb/detail/execution_policy.h>
29
+ #include <thrust/system/detail/generic/extrema.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+ namespace system
33
+ {
34
+ namespace tbb
35
+ {
36
+ namespace detail
37
+ {
38
+
39
+ template <typename DerivedPolicy, typename ForwardIterator, typename BinaryPredicate>
40
+ ForwardIterator max_element(execution_policy<DerivedPolicy> &exec,
41
+ ForwardIterator first,
42
+ ForwardIterator last,
43
+ BinaryPredicate comp)
44
+ {
45
+ // tbb prefers generic::max_element to cpp::max_element
46
+ return thrust::system::detail::generic::max_element(exec, first, last, comp);
47
+ } // end max_element()
48
+
49
+ template <typename DerivedPolicy, typename ForwardIterator, typename BinaryPredicate>
50
+ ForwardIterator min_element(execution_policy<DerivedPolicy> &exec,
51
+ ForwardIterator first,
52
+ ForwardIterator last,
53
+ BinaryPredicate comp)
54
+ {
55
+ // tbb prefers generic::min_element to cpp::min_element
56
+ return thrust::system::detail::generic::min_element(exec, first, last, comp);
57
+ } // end min_element()
58
+
59
+ template <typename DerivedPolicy, typename ForwardIterator, typename BinaryPredicate>
60
+ thrust::pair<ForwardIterator,ForwardIterator> minmax_element(execution_policy<DerivedPolicy> &exec,
61
+ ForwardIterator first,
62
+ ForwardIterator last,
63
+ BinaryPredicate comp)
64
+ {
65
+ // tbb prefers generic::minmax_element to cpp::minmax_element
66
+ return thrust::system::detail::generic::minmax_element(exec, first, last, comp);
67
+ } // end minmax_element()
68
+
69
+ } // end detail
70
+ } // end tbb
71
+ } // end system
72
+ THRUST_NAMESPACE_END
73
+
74
+
miniCUDA124/include/thrust/system/tbb/detail/fill.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 fill
30
+ #include <thrust/system/cpp/detail/fill.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/find.h ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+ #include <thrust/system/detail/generic/find.h>
29
+ #include <thrust/system/tbb/detail/execution_policy.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+ namespace system
33
+ {
34
+ namespace tbb
35
+ {
36
+ namespace detail
37
+ {
38
+
39
+ template <typename DerivedPolicy, typename InputIterator, typename Predicate>
40
+ InputIterator find_if(execution_policy<DerivedPolicy> &exec,
41
+ InputIterator first,
42
+ InputIterator last,
43
+ Predicate pred)
44
+ {
45
+ // tbb prefers generic::find_if to cpp::find_if
46
+ return thrust::system::detail::generic::find_if(exec, first, last, pred);
47
+ }
48
+
49
+ } // end namespace detail
50
+ } // end namespace tbb
51
+ } // end namespace system
52
+ THRUST_NAMESPACE_END
53
+
miniCUDA124/include/thrust/system/tbb/detail/for_each.h ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/tbb/detail/execution_policy.h>
29
+
30
+ THRUST_NAMESPACE_BEGIN
31
+ namespace system
32
+ {
33
+ namespace tbb
34
+ {
35
+ namespace detail
36
+ {
37
+
38
+ template<typename DerivedPolicy,
39
+ typename RandomAccessIterator,
40
+ typename UnaryFunction>
41
+ RandomAccessIterator for_each(execution_policy<DerivedPolicy> &exec,
42
+ RandomAccessIterator first,
43
+ RandomAccessIterator last,
44
+ UnaryFunction f);
45
+
46
+ template<typename DerivedPolicy,
47
+ typename RandomAccessIterator,
48
+ typename Size,
49
+ typename UnaryFunction>
50
+ RandomAccessIterator for_each_n(execution_policy<DerivedPolicy> &exec,
51
+ RandomAccessIterator first,
52
+ Size n,
53
+ UnaryFunction f);
54
+
55
+ } // end namespace detail
56
+ } // end namespace tbb
57
+ } // end namespace system
58
+ THRUST_NAMESPACE_END
59
+
60
+ #include <thrust/system/tbb/detail/for_each.inl>
61
+
miniCUDA124/include/thrust/system/tbb/detail/for_each.inl ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #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/static_assert.h>
29
+ #include <thrust/distance.h>
30
+ #include <thrust/iterator/iterator_traits.h>
31
+ #include <thrust/distance.h>
32
+ #include <thrust/system/detail/sequential/execution_policy.h>
33
+
34
+ #include <tbb/blocked_range.h>
35
+ #include <tbb/parallel_for.h>
36
+
37
+ THRUST_NAMESPACE_BEGIN
38
+ namespace system
39
+ {
40
+ namespace tbb
41
+ {
42
+ namespace detail
43
+ {
44
+ namespace for_each_detail
45
+ {
46
+
47
+ template<typename RandomAccessIterator,
48
+ typename Size,
49
+ typename UnaryFunction>
50
+ struct body
51
+ {
52
+ RandomAccessIterator m_first;
53
+ UnaryFunction m_f;
54
+
55
+ body(RandomAccessIterator first, UnaryFunction f)
56
+ : m_first(first), m_f(f)
57
+ {}
58
+
59
+ void operator()(const ::tbb::blocked_range<Size> &r) const
60
+ {
61
+ // we assume that blocked_range specifies a contiguous range of integers
62
+ thrust::for_each_n(thrust::system::detail::sequential::seq, m_first + r.begin(), r.size(), m_f);
63
+ } // end operator()()
64
+ }; // end body
65
+
66
+
67
+ template<typename Size, typename RandomAccessIterator, typename UnaryFunction>
68
+ body<RandomAccessIterator,Size,UnaryFunction>
69
+ make_body(RandomAccessIterator first, UnaryFunction f)
70
+ {
71
+ return body<RandomAccessIterator,Size,UnaryFunction>(first, f);
72
+ } // end make_body()
73
+
74
+
75
+ } // end for_each_detail
76
+
77
+
78
+ template<typename DerivedPolicy,
79
+ typename RandomAccessIterator,
80
+ typename Size,
81
+ typename UnaryFunction>
82
+ RandomAccessIterator for_each_n(execution_policy<DerivedPolicy> &,
83
+ RandomAccessIterator first,
84
+ Size n,
85
+ UnaryFunction f)
86
+ {
87
+ ::tbb::parallel_for(::tbb::blocked_range<Size>(0,n), for_each_detail::make_body<Size>(first,f));
88
+
89
+ // return the end of the range
90
+ return first + n;
91
+ } // end for_each_n
92
+
93
+
94
+ template<typename DerivedPolicy,
95
+ typename RandomAccessIterator,
96
+ typename UnaryFunction>
97
+ RandomAccessIterator for_each(execution_policy<DerivedPolicy> &s,
98
+ RandomAccessIterator first,
99
+ RandomAccessIterator last,
100
+ UnaryFunction f)
101
+ {
102
+ return tbb::detail::for_each_n(s, first, thrust::distance(first,last), f);
103
+ } // end for_each()
104
+
105
+
106
+ } // end namespace detail
107
+ } // end namespace tbb
108
+ } // end namespace system
109
+ THRUST_NAMESPACE_END
110
+
miniCUDA124/include/thrust/system/tbb/detail/gather.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 gather
30
+ #include <thrust/system/cpp/detail/gather.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/generate.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 generate
30
+ #include <thrust/system/cpp/detail/generate.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/get_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 get_value
30
+ #include <thrust/system/cpp/detail/get_value.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/inner_product.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 inner_product
30
+ #include <thrust/system/cpp/detail/inner_product.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/iter_swap.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 iter_swap
30
+ #include <thrust/system/cpp/detail/iter_swap.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/logical.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 logical
30
+ #include <thrust/system/cpp/detail/logical.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/malloc_and_free.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 malloc and free
30
+ #include <thrust/system/cpp/detail/malloc_and_free.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/memory.inl ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2018 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+ #include <thrust/system/cpp/detail/execution_policy.h>
29
+ #include <thrust/system/tbb/memory.h>
30
+ #include <thrust/system/cpp/memory.h>
31
+ #include <limits>
32
+
33
+ THRUST_NAMESPACE_BEGIN
34
+ namespace system
35
+ {
36
+ namespace tbb
37
+ {
38
+
39
+
40
+ namespace detail
41
+ {
42
+
43
+ // XXX circular #inclusion problems cause the compiler to believe that cpp::malloc
44
+ // is not defined
45
+ // WAR the problem by using adl to call cpp::malloc, which requires it to depend
46
+ // on a template parameter
47
+ template<typename Tag>
48
+ pointer<void> malloc_workaround(Tag t, std::size_t n)
49
+ {
50
+ return pointer<void>(malloc(t, n));
51
+ } // end malloc_workaround()
52
+
53
+ // XXX circular #inclusion problems cause the compiler to believe that cpp::free
54
+ // is not defined
55
+ // WAR the problem by using adl to call cpp::free, which requires it to depend
56
+ // on a template parameter
57
+ template<typename Tag>
58
+ void free_workaround(Tag t, pointer<void> ptr)
59
+ {
60
+ free(t, ptr.get());
61
+ } // end free_workaround()
62
+
63
+ } // end detail
64
+
65
+ inline pointer<void> malloc(std::size_t n)
66
+ {
67
+ // XXX this is how we'd like to implement this function,
68
+ // if not for circular #inclusion problems:
69
+ //
70
+ // return pointer<void>(thrust::system::cpp::malloc(n))
71
+ //
72
+ return detail::malloc_workaround(cpp::tag(), n);
73
+ } // end malloc()
74
+
75
+ template<typename T>
76
+ pointer<T> malloc(std::size_t n)
77
+ {
78
+ pointer<void> raw_ptr = thrust::system::tbb::malloc(sizeof(T) * n);
79
+ return pointer<T>(reinterpret_cast<T*>(raw_ptr.get()));
80
+ } // end malloc()
81
+
82
+ inline void free(pointer<void> ptr)
83
+ {
84
+ // XXX this is how we'd like to implement this function,
85
+ // if not for circular #inclusion problems:
86
+ //
87
+ // thrust::system::cpp::free(ptr)
88
+ //
89
+ detail::free_workaround(cpp::tag(), ptr);
90
+ } // end free()
91
+
92
+ } // end tbb
93
+ } // end system
94
+ THRUST_NAMESPACE_END
95
+
miniCUDA124/include/thrust/system/tbb/detail/merge.h ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/tbb/detail/execution_policy.h>
29
+
30
+ THRUST_NAMESPACE_BEGIN
31
+ namespace system
32
+ {
33
+ namespace tbb
34
+ {
35
+ namespace detail
36
+ {
37
+
38
+ template<typename ExecutionPolicy,
39
+ typename InputIterator1,
40
+ typename InputIterator2,
41
+ typename OutputIterator,
42
+ typename StrictWeakOrdering>
43
+ OutputIterator merge(execution_policy<ExecutionPolicy> &exec,
44
+ InputIterator1 first1,
45
+ InputIterator1 last1,
46
+ InputIterator2 first2,
47
+ InputIterator2 last2,
48
+ OutputIterator result,
49
+ StrictWeakOrdering comp);
50
+
51
+ template <typename ExecutionPolicy,
52
+ typename InputIterator1,
53
+ typename InputIterator2,
54
+ typename InputIterator3,
55
+ typename InputIterator4,
56
+ typename OutputIterator1,
57
+ typename OutputIterator2,
58
+ typename StrictWeakOrdering>
59
+ thrust::pair<OutputIterator1,OutputIterator2>
60
+ merge_by_key(execution_policy<ExecutionPolicy> &exec,
61
+ InputIterator1 keys_first1,
62
+ InputIterator1 keys_last1,
63
+ InputIterator2 keys_first2,
64
+ InputIterator2 keys_last2,
65
+ InputIterator3 values_first3,
66
+ InputIterator4 values_first4,
67
+ OutputIterator1 keys_result,
68
+ OutputIterator2 values_result,
69
+ StrictWeakOrdering comp);
70
+
71
+ } // end detail
72
+ } // end tbb
73
+ } // end system
74
+ THRUST_NAMESPACE_END
75
+
76
+ #include <thrust/system/tbb/detail/merge.inl>
77
+
miniCUDA124/include/thrust/system/tbb/detail/merge.inl ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/iterator_traits.h>
30
+ #include <thrust/detail/temporary_array.h>
31
+ #include <thrust/system/tbb/detail/execution_policy.h>
32
+ #include <thrust/merge.h>
33
+ #include <thrust/binary_search.h>
34
+ #include <thrust/detail/seq.h>
35
+ #include <tbb/parallel_for.h>
36
+
37
+ THRUST_NAMESPACE_BEGIN
38
+ namespace system
39
+ {
40
+ namespace tbb
41
+ {
42
+ namespace detail
43
+ {
44
+ namespace merge_detail
45
+ {
46
+
47
+ template<typename InputIterator1,
48
+ typename InputIterator2,
49
+ typename OutputIterator,
50
+ typename StrictWeakOrdering>
51
+ struct range
52
+ {
53
+ InputIterator1 first1, last1;
54
+ InputIterator2 first2, last2;
55
+ OutputIterator result;
56
+ StrictWeakOrdering comp;
57
+ size_t grain_size;
58
+
59
+ range(InputIterator1 first1, InputIterator1 last1,
60
+ InputIterator2 first2, InputIterator2 last2,
61
+ OutputIterator result,
62
+ StrictWeakOrdering comp,
63
+ size_t grain_size = 1024)
64
+ : first1(first1), last1(last1),
65
+ first2(first2), last2(last2),
66
+ result(result), comp(comp), grain_size(grain_size)
67
+ {}
68
+
69
+ range(range& r, ::tbb::split)
70
+ : first1(r.first1), last1(r.last1),
71
+ first2(r.first2), last2(r.last2),
72
+ result(r.result), comp(r.comp), grain_size(r.grain_size)
73
+ {
74
+ // we can assume n1 and n2 are not both 0
75
+ size_t n1 = thrust::distance(first1, last1);
76
+ size_t n2 = thrust::distance(first2, last2);
77
+
78
+ InputIterator1 mid1 = first1;
79
+ InputIterator2 mid2 = first2;
80
+
81
+ if (n1 > n2)
82
+ {
83
+ mid1 += n1 / 2;
84
+ mid2 = thrust::lower_bound(thrust::seq, first2, last2, raw_reference_cast(*mid1), comp);
85
+ }
86
+ else
87
+ {
88
+ mid2 += n2 / 2;
89
+ mid1 = thrust::upper_bound(thrust::seq, first1, last1, raw_reference_cast(*mid2), comp);
90
+ }
91
+
92
+ // set first range to [first1, mid1), [first2, mid2), result
93
+ r.last1 = mid1;
94
+ r.last2 = mid2;
95
+
96
+ // set second range to [mid1, last1), [mid2, last2), result + (mid1 - first1) + (mid2 - first2)
97
+ first1 = mid1;
98
+ first2 = mid2;
99
+ result += thrust::distance(r.first1, mid1) + thrust::distance(r.first2, mid2);
100
+ }
101
+
102
+ bool empty(void) const
103
+ {
104
+ return (first1 == last1) && (first2 == last2);
105
+ }
106
+
107
+ bool is_divisible(void) const
108
+ {
109
+ return static_cast<size_t>(thrust::distance(first1, last1) + thrust::distance(first2, last2)) > grain_size;
110
+ }
111
+ };
112
+
113
+ struct body
114
+ {
115
+ template <typename Range>
116
+ void operator()(Range& r) const
117
+ {
118
+ thrust::merge(thrust::seq,
119
+ r.first1, r.last1,
120
+ r.first2, r.last2,
121
+ r.result,
122
+ r.comp);
123
+ }
124
+ };
125
+
126
+ } // end namespace merge_detail
127
+
128
+ namespace merge_by_key_detail
129
+ {
130
+
131
+ template<typename InputIterator1,
132
+ typename InputIterator2,
133
+ typename InputIterator3,
134
+ typename InputIterator4,
135
+ typename OutputIterator1,
136
+ typename OutputIterator2,
137
+ typename StrictWeakOrdering>
138
+ struct range
139
+ {
140
+ InputIterator1 keys_first1, keys_last1;
141
+ InputIterator2 keys_first2, keys_last2;
142
+ InputIterator3 values_first1;
143
+ InputIterator4 values_first2;
144
+ OutputIterator1 keys_result;
145
+ OutputIterator2 values_result;
146
+ StrictWeakOrdering comp;
147
+ size_t grain_size;
148
+
149
+ range(InputIterator1 keys_first1, InputIterator1 keys_last1,
150
+ InputIterator2 keys_first2, InputIterator2 keys_last2,
151
+ InputIterator3 values_first1,
152
+ InputIterator4 values_first2,
153
+ OutputIterator1 keys_result,
154
+ OutputIterator2 values_result,
155
+ StrictWeakOrdering comp,
156
+ size_t grain_size = 1024)
157
+ : keys_first1(keys_first1), keys_last1(keys_last1),
158
+ keys_first2(keys_first2), keys_last2(keys_last2),
159
+ values_first1(values_first1),
160
+ values_first2(values_first2),
161
+ keys_result(keys_result), values_result(values_result),
162
+ comp(comp), grain_size(grain_size)
163
+ {}
164
+
165
+ range(range& r, ::tbb::split)
166
+ : keys_first1(r.keys_first1), keys_last1(r.keys_last1),
167
+ keys_first2(r.keys_first2), keys_last2(r.keys_last2),
168
+ values_first1(r.values_first1),
169
+ values_first2(r.values_first2),
170
+ keys_result(r.keys_result), values_result(r.values_result),
171
+ comp(r.comp), grain_size(r.grain_size)
172
+ {
173
+ // we can assume n1 and n2 are not both 0
174
+ size_t n1 = thrust::distance(keys_first1, keys_last1);
175
+ size_t n2 = thrust::distance(keys_first2, keys_last2);
176
+
177
+ InputIterator1 mid1 = keys_first1;
178
+ InputIterator2 mid2 = keys_first2;
179
+
180
+ if (n1 > n2)
181
+ {
182
+ mid1 += n1 / 2;
183
+ mid2 = thrust::lower_bound(thrust::seq, keys_first2, keys_last2, raw_reference_cast(*mid1), comp);
184
+ }
185
+ else
186
+ {
187
+ mid2 += n2 / 2;
188
+ mid1 = thrust::upper_bound(thrust::seq, keys_first1, keys_last1, raw_reference_cast(*mid2), comp);
189
+ }
190
+
191
+ // set first range to [keys_first1, mid1), [keys_first2, mid2), keys_result, values_result
192
+ r.keys_last1 = mid1;
193
+ r.keys_last2 = mid2;
194
+
195
+ // set second range to [mid1, keys_last1), [mid2, keys_last2), keys_result + (mid1 - keys_first1) + (mid2 - keys_first2), values_result + (mid1 - keys_first1) + (mid2 - keys_first2)
196
+ keys_first1 = mid1;
197
+ keys_first2 = mid2;
198
+ values_first1 += thrust::distance(r.keys_first1, mid1);
199
+ values_first2 += thrust::distance(r.keys_first2, mid2);
200
+ keys_result += thrust::distance(r.keys_first1, mid1) + thrust::distance(r.keys_first2, mid2);
201
+ values_result += thrust::distance(r.keys_first1, mid1) + thrust::distance(r.keys_first2, mid2);
202
+ }
203
+
204
+ bool empty(void) const
205
+ {
206
+ return (keys_first1 == keys_last1) && (keys_first2 == keys_last2);
207
+ }
208
+
209
+ bool is_divisible(void) const
210
+ {
211
+ return static_cast<size_t>(thrust::distance(keys_first1, keys_last1) + thrust::distance(keys_first2, keys_last2)) > grain_size;
212
+ }
213
+ };
214
+
215
+ struct body
216
+ {
217
+ template <typename Range>
218
+ void operator()(Range& r) const
219
+ {
220
+ thrust::merge_by_key(thrust::seq,
221
+ r.keys_first1, r.keys_last1,
222
+ r.keys_first2, r.keys_last2,
223
+ r.values_first1,
224
+ r.values_first2,
225
+ r.keys_result,
226
+ r.values_result,
227
+ r.comp);
228
+ }
229
+ };
230
+
231
+ } // end namespace merge_by_key_detail
232
+
233
+
234
+ template<typename DerivedPolicy,
235
+ typename InputIterator1,
236
+ typename InputIterator2,
237
+ typename OutputIterator,
238
+ typename StrictWeakOrdering>
239
+ OutputIterator merge(execution_policy<DerivedPolicy> &,
240
+ InputIterator1 first1,
241
+ InputIterator1 last1,
242
+ InputIterator2 first2,
243
+ InputIterator2 last2,
244
+ OutputIterator result,
245
+ StrictWeakOrdering comp)
246
+ {
247
+ typedef typename merge_detail::range<InputIterator1,InputIterator2,OutputIterator,StrictWeakOrdering> Range;
248
+ typedef merge_detail::body Body;
249
+ Range range(first1, last1, first2, last2, result, comp);
250
+ Body body;
251
+
252
+ ::tbb::parallel_for(range, body);
253
+
254
+ thrust::advance(result, thrust::distance(first1, last1) + thrust::distance(first2, last2));
255
+
256
+ return result;
257
+ } // end merge()
258
+
259
+ template <typename DerivedPolicy,
260
+ typename InputIterator1,
261
+ typename InputIterator2,
262
+ typename InputIterator3,
263
+ typename InputIterator4,
264
+ typename OutputIterator1,
265
+ typename OutputIterator2,
266
+ typename StrictWeakOrdering>
267
+ thrust::pair<OutputIterator1,OutputIterator2>
268
+ merge_by_key(execution_policy<DerivedPolicy> &,
269
+ InputIterator1 keys_first1,
270
+ InputIterator1 keys_last1,
271
+ InputIterator2 keys_first2,
272
+ InputIterator2 keys_last2,
273
+ InputIterator3 values_first3,
274
+ InputIterator4 values_first4,
275
+ OutputIterator1 keys_result,
276
+ OutputIterator2 values_result,
277
+ StrictWeakOrdering comp)
278
+ {
279
+ typedef typename merge_by_key_detail::range<InputIterator1,InputIterator2,InputIterator3,InputIterator4,OutputIterator1,OutputIterator2,StrictWeakOrdering> Range;
280
+ typedef merge_by_key_detail::body Body;
281
+
282
+ Range range(keys_first1, keys_last1, keys_first2, keys_last2, values_first3, values_first4, keys_result, values_result, comp);
283
+ Body body;
284
+
285
+ ::tbb::parallel_for(range, body);
286
+
287
+ thrust::advance(keys_result, thrust::distance(keys_first1, keys_last1) + thrust::distance(keys_first2, keys_last2));
288
+ thrust::advance(values_result, thrust::distance(keys_first1, keys_last1) + thrust::distance(keys_first2, keys_last2));
289
+
290
+ return thrust::make_pair(keys_result,values_result);
291
+ }
292
+
293
+ } // end namespace detail
294
+ } // end namespace tbb
295
+ } // end namespace system
296
+ THRUST_NAMESPACE_END
297
+
miniCUDA124/include/thrust/system/tbb/detail/mismatch.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 mismatch
30
+ #include <thrust/system/cpp/detail/mismatch.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/par.h ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2018 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+ #include <thrust/detail/allocator_aware_execution_policy.h>
29
+ #include <thrust/system/tbb/detail/execution_policy.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+ namespace system
33
+ {
34
+ namespace tbb
35
+ {
36
+ namespace detail
37
+ {
38
+
39
+
40
+ struct par_t : thrust::system::tbb::detail::execution_policy<par_t>,
41
+ thrust::detail::allocator_aware_execution_policy<
42
+ thrust::system::tbb::detail::execution_policy>
43
+ {
44
+ __host__ __device__
45
+ constexpr par_t() : thrust::system::tbb::detail::execution_policy<par_t>() {}
46
+ };
47
+
48
+
49
+ } // end detail
50
+
51
+
52
+ static const detail::par_t par;
53
+
54
+
55
+ } // end tbb
56
+ } // end system
57
+
58
+
59
+ // alias par here
60
+ namespace tbb
61
+ {
62
+
63
+
64
+ using thrust::system::tbb::par;
65
+
66
+
67
+ } // end tbb
68
+ THRUST_NAMESPACE_END
69
+
miniCUDA124/include/thrust/system/tbb/detail/partition.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/system/tbb/detail/execution_policy.h>
29
+ #include <thrust/pair.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+ namespace system
33
+ {
34
+ namespace tbb
35
+ {
36
+ namespace detail
37
+ {
38
+
39
+
40
+ template<typename DerivedPolicy,
41
+ typename ForwardIterator,
42
+ typename Predicate>
43
+ ForwardIterator stable_partition(execution_policy<DerivedPolicy> &exec,
44
+ ForwardIterator first,
45
+ ForwardIterator last,
46
+ Predicate pred);
47
+
48
+ template<typename DerivedPolicy,
49
+ typename ForwardIterator,
50
+ typename InputIterator,
51
+ typename Predicate>
52
+ ForwardIterator stable_partition(execution_policy<DerivedPolicy> &exec,
53
+ ForwardIterator first,
54
+ ForwardIterator last,
55
+ InputIterator stencil,
56
+ Predicate pred);
57
+
58
+ template<typename DerivedPolicy,
59
+ typename InputIterator,
60
+ typename OutputIterator1,
61
+ typename OutputIterator2,
62
+ typename Predicate>
63
+ thrust::pair<OutputIterator1,OutputIterator2>
64
+ stable_partition_copy(execution_policy<DerivedPolicy> &exec,
65
+ InputIterator first,
66
+ InputIterator last,
67
+ OutputIterator1 out_true,
68
+ OutputIterator2 out_false,
69
+ Predicate pred);
70
+
71
+
72
+ template<typename DerivedPolicy,
73
+ typename InputIterator1,
74
+ typename InputIterator2,
75
+ typename OutputIterator1,
76
+ typename OutputIterator2,
77
+ typename Predicate>
78
+ thrust::pair<OutputIterator1,OutputIterator2>
79
+ stable_partition_copy(execution_policy<DerivedPolicy> &exec,
80
+ InputIterator1 first,
81
+ InputIterator1 last,
82
+ InputIterator2 stencil,
83
+ OutputIterator1 out_true,
84
+ OutputIterator2 out_false,
85
+ Predicate pred);
86
+
87
+
88
+ } // end namespace detail
89
+ } // end namespace tbb
90
+ } // end namespace system
91
+ THRUST_NAMESPACE_END
92
+
93
+ #include <thrust/system/tbb/detail/partition.inl>
94
+
miniCUDA124/include/thrust/system/tbb/detail/partition.inl ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/tbb/detail/partition.h>
29
+ #include <thrust/system/detail/generic/partition.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+ namespace system
33
+ {
34
+ namespace tbb
35
+ {
36
+ namespace detail
37
+ {
38
+
39
+
40
+ template<typename DerivedPolicy,
41
+ typename ForwardIterator,
42
+ typename Predicate>
43
+ ForwardIterator stable_partition(execution_policy<DerivedPolicy> &exec,
44
+ ForwardIterator first,
45
+ ForwardIterator last,
46
+ Predicate pred)
47
+ {
48
+ // tbb prefers generic::stable_partition to cpp::stable_partition
49
+ return thrust::system::detail::generic::stable_partition(exec, first, last, pred);
50
+ } // end stable_partition()
51
+
52
+
53
+ template<typename DerivedPolicy,
54
+ typename ForwardIterator,
55
+ typename InputIterator,
56
+ typename Predicate>
57
+ ForwardIterator stable_partition(execution_policy<DerivedPolicy> &exec,
58
+ ForwardIterator first,
59
+ ForwardIterator last,
60
+ InputIterator stencil,
61
+ Predicate pred)
62
+ {
63
+ // tbb prefers generic::stable_partition to cpp::stable_partition
64
+ return thrust::system::detail::generic::stable_partition(exec, first, last, stencil, pred);
65
+ } // end stable_partition()
66
+
67
+ template<typename DerivedPolicy,
68
+ typename InputIterator,
69
+ typename OutputIterator1,
70
+ typename OutputIterator2,
71
+ typename Predicate>
72
+ thrust::pair<OutputIterator1,OutputIterator2>
73
+ stable_partition_copy(execution_policy<DerivedPolicy> &exec,
74
+ InputIterator first,
75
+ InputIterator last,
76
+ OutputIterator1 out_true,
77
+ OutputIterator2 out_false,
78
+ Predicate pred)
79
+ {
80
+ // tbb prefers generic::stable_partition_copy to cpp::stable_partition_copy
81
+ return thrust::system::detail::generic::stable_partition_copy(exec, first, last, out_true, out_false, pred);
82
+ } // end stable_partition_copy()
83
+
84
+
85
+ template<typename DerivedPolicy,
86
+ typename InputIterator1,
87
+ typename InputIterator2,
88
+ typename OutputIterator1,
89
+ typename OutputIterator2,
90
+ typename Predicate>
91
+ thrust::pair<OutputIterator1,OutputIterator2>
92
+ stable_partition_copy(execution_policy<DerivedPolicy> &exec,
93
+ InputIterator1 first,
94
+ InputIterator1 last,
95
+ InputIterator2 stencil,
96
+ OutputIterator1 out_true,
97
+ OutputIterator2 out_false,
98
+ Predicate pred)
99
+ {
100
+ // tbb prefers generic::stable_partition_copy to cpp::stable_partition_copy
101
+ return thrust::system::detail::generic::stable_partition_copy(exec, first, last, stencil, out_true, out_false, pred);
102
+ } // end stable_partition_copy()
103
+
104
+
105
+ } // end namespace detail
106
+ } // end namespace tbb
107
+ } // end namespace system
108
+ THRUST_NAMESPACE_END
109
+
miniCUDA124/include/thrust/system/tbb/detail/per_device_resource.h ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2018 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ // this system has no special per device resource functions
30
+
miniCUDA124/include/thrust/system/tbb/detail/reduce.h ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 reduce.h
19
+ * \brief TBB implementation of reduce.
20
+ */
21
+
22
+ #pragma once
23
+
24
+ #include <thrust/detail/config.h>
25
+
26
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
27
+ # pragma GCC system_header
28
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
29
+ # pragma clang system_header
30
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
31
+ # pragma system_header
32
+ #endif // no system header
33
+ #include <thrust/system/tbb/detail/execution_policy.h>
34
+
35
+ THRUST_NAMESPACE_BEGIN
36
+ namespace system
37
+ {
38
+ namespace tbb
39
+ {
40
+ namespace detail
41
+ {
42
+
43
+
44
+ template<typename DerivedPolicy,
45
+ typename InputIterator,
46
+ typename OutputType,
47
+ typename BinaryFunction>
48
+ OutputType reduce(execution_policy<DerivedPolicy> &exec,
49
+ InputIterator begin,
50
+ InputIterator end,
51
+ OutputType init,
52
+ BinaryFunction binary_op);
53
+
54
+
55
+ } // end namespace detail
56
+ } // end namespace tbb
57
+ } // end namespace system
58
+ THRUST_NAMESPACE_END
59
+
60
+ #include <thrust/system/tbb/detail/reduce.inl>
61
+
miniCUDA124/include/thrust/system/tbb/detail/reduce.inl 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
+
18
+ #pragma once
19
+
20
+ #include <thrust/detail/config.h>
21
+
22
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
23
+ # pragma GCC system_header
24
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
25
+ # pragma clang system_header
26
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
27
+ # pragma system_header
28
+ #endif // no system header
29
+ #include <thrust/detail/function.h>
30
+ #include <thrust/detail/static_assert.h>
31
+ #include <thrust/iterator/iterator_traits.h>
32
+ #include <thrust/distance.h>
33
+ #include <thrust/reduce.h>
34
+ #include <tbb/blocked_range.h>
35
+ #include <tbb/parallel_reduce.h>
36
+
37
+ THRUST_NAMESPACE_BEGIN
38
+ namespace system
39
+ {
40
+ namespace tbb
41
+ {
42
+ namespace detail
43
+ {
44
+ namespace reduce_detail
45
+ {
46
+
47
+ template<typename RandomAccessIterator,
48
+ typename OutputType,
49
+ typename BinaryFunction>
50
+ struct body
51
+ {
52
+ RandomAccessIterator first;
53
+ OutputType sum;
54
+ bool first_call; // TBB can invoke operator() multiple times on the same body
55
+ thrust::detail::wrapped_function<BinaryFunction,OutputType> binary_op;
56
+
57
+ // note: we only initalize sum with init to avoid calling OutputType's default constructor
58
+ body(RandomAccessIterator first, OutputType init, BinaryFunction binary_op)
59
+ : first(first), sum(init), first_call(true), binary_op(binary_op)
60
+ {}
61
+
62
+ // note: we only initalize sum with b.sum to avoid calling OutputType's default constructor
63
+ body(body& b, ::tbb::split)
64
+ : first(b.first), sum(b.sum), first_call(true), binary_op(b.binary_op)
65
+ {}
66
+
67
+ template <typename Size>
68
+ void operator()(const ::tbb::blocked_range<Size> &r)
69
+ {
70
+ // we assume that blocked_range specifies a contiguous range of integers
71
+
72
+ if (r.empty()) return; // nothing to do
73
+
74
+ RandomAccessIterator iter = first + r.begin();
75
+
76
+ OutputType temp = thrust::raw_reference_cast(*iter);
77
+
78
+ ++iter;
79
+
80
+ for (Size i = r.begin() + 1; i != r.end(); ++i, ++iter)
81
+ temp = binary_op(temp, *iter);
82
+
83
+
84
+ if (first_call)
85
+ {
86
+ // first time body has been invoked
87
+ first_call = false;
88
+ sum = temp;
89
+ }
90
+ else
91
+ {
92
+ // body has been previously invoked, accumulate temp into sum
93
+ sum = binary_op(sum, temp);
94
+ }
95
+ } // end operator()()
96
+
97
+ void join(body& b)
98
+ {
99
+ sum = binary_op(sum, b.sum);
100
+ }
101
+ }; // end body
102
+
103
+ } // end reduce_detail
104
+
105
+
106
+ template<typename DerivedPolicy,
107
+ typename InputIterator,
108
+ typename OutputType,
109
+ typename BinaryFunction>
110
+ OutputType reduce(execution_policy<DerivedPolicy> &,
111
+ InputIterator begin,
112
+ InputIterator end,
113
+ OutputType init,
114
+ BinaryFunction binary_op)
115
+ {
116
+ typedef typename thrust::iterator_difference<InputIterator>::type Size;
117
+
118
+ Size n = thrust::distance(begin, end);
119
+
120
+ if (n == 0)
121
+ {
122
+ return init;
123
+ }
124
+ else
125
+ {
126
+ typedef typename reduce_detail::body<InputIterator,OutputType,BinaryFunction> Body;
127
+ Body reduce_body(begin, init, binary_op);
128
+ ::tbb::parallel_reduce(::tbb::blocked_range<Size>(0,n), reduce_body);
129
+ return binary_op(init, reduce_body.sum);
130
+ }
131
+ }
132
+
133
+
134
+ } // end namespace detail
135
+ } // end namespace tbb
136
+ } // end namespace system
137
+ THRUST_NAMESPACE_END
138
+
miniCUDA124/include/thrust/system/tbb/detail/reduce_by_key.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
+ #include <thrust/system/tbb/detail/execution_policy.h>
29
+ #include <thrust/pair.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+ namespace system
33
+ {
34
+ namespace tbb
35
+ {
36
+ namespace detail
37
+ {
38
+
39
+
40
+ template<typename DerivedPolicy,
41
+ typename InputIterator1,
42
+ typename InputIterator2,
43
+ typename OutputIterator1,
44
+ typename OutputIterator2,
45
+ typename BinaryPredicate,
46
+ typename BinaryFunction>
47
+ thrust::pair<OutputIterator1,OutputIterator2>
48
+ reduce_by_key(execution_policy<DerivedPolicy> &exec,
49
+ InputIterator1 keys_first,
50
+ InputIterator1 keys_last,
51
+ InputIterator2 values_first,
52
+ OutputIterator1 keys_output,
53
+ OutputIterator2 values_output,
54
+ BinaryPredicate binary_pred,
55
+ BinaryFunction binary_op);
56
+
57
+
58
+ } // end namespace detail
59
+ } // end namespace tbb
60
+ } // end namespace system
61
+ THRUST_NAMESPACE_END
62
+
63
+ #include <thrust/system/tbb/detail/reduce_by_key.inl>
64
+
miniCUDA124/include/thrust/system/tbb/detail/reduce_by_key.inl ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/tbb/detail/reduce_by_key.h>
29
+ #include <thrust/iterator/reverse_iterator.h>
30
+ #include <thrust/detail/seq.h>
31
+ #include <thrust/system/tbb/detail/execution_policy.h>
32
+ #include <thrust/system/tbb/detail/reduce_intervals.h>
33
+ #include <thrust/detail/minmax.h>
34
+ #include <thrust/detail/temporary_array.h>
35
+ #include <thrust/detail/range/tail_flags.h>
36
+ #include <tbb/blocked_range.h>
37
+ #include <tbb/parallel_for.h>
38
+
39
+ #include <cassert>
40
+ #include <thread>
41
+
42
+
43
+ THRUST_NAMESPACE_BEGIN
44
+ namespace system
45
+ {
46
+ namespace tbb
47
+ {
48
+ namespace detail
49
+ {
50
+ namespace reduce_by_key_detail
51
+ {
52
+
53
+
54
+ template<typename L, typename R>
55
+ inline L divide_ri(const L x, const R y)
56
+ {
57
+ return (x + (y - 1)) / y;
58
+ }
59
+
60
+
61
+ template<typename InputIterator, typename BinaryFunction, typename OutputIterator = void>
62
+ struct partial_sum_type
63
+ : thrust::detail::eval_if<
64
+ thrust::detail::has_result_type<BinaryFunction>::value,
65
+ thrust::detail::result_type<BinaryFunction>,
66
+ thrust::detail::eval_if<
67
+ thrust::detail::is_output_iterator<OutputIterator>::value,
68
+ thrust::iterator_value<InputIterator>,
69
+ thrust::iterator_value<OutputIterator>
70
+ >
71
+ >
72
+ {};
73
+
74
+
75
+ template<typename InputIterator, typename BinaryFunction>
76
+ struct partial_sum_type<InputIterator,BinaryFunction,void>
77
+ : thrust::detail::eval_if<
78
+ thrust::detail::has_result_type<BinaryFunction>::value,
79
+ thrust::detail::result_type<BinaryFunction>,
80
+ thrust::iterator_value<InputIterator>
81
+ >
82
+ {};
83
+
84
+
85
+ template<typename InputIterator1,
86
+ typename InputIterator2,
87
+ typename BinaryPredicate,
88
+ typename BinaryFunction>
89
+ thrust::pair<
90
+ InputIterator1,
91
+ thrust::pair<
92
+ typename thrust::iterator_value<InputIterator1>::type,
93
+ typename partial_sum_type<InputIterator2,BinaryFunction>::type
94
+ >
95
+ >
96
+ reduce_last_segment_backward(InputIterator1 keys_first,
97
+ InputIterator1 keys_last,
98
+ InputIterator2 values_first,
99
+ BinaryPredicate binary_pred,
100
+ BinaryFunction binary_op)
101
+ {
102
+ typename thrust::iterator_difference<InputIterator1>::type n = keys_last - keys_first;
103
+
104
+ // reverse the ranges and consume from the end
105
+ thrust::reverse_iterator<InputIterator1> keys_first_r(keys_last);
106
+ thrust::reverse_iterator<InputIterator1> keys_last_r(keys_first);
107
+ thrust::reverse_iterator<InputIterator2> values_first_r(values_first + n);
108
+
109
+ typename thrust::iterator_value<InputIterator1>::type result_key = *keys_first_r;
110
+ typename partial_sum_type<InputIterator2,BinaryFunction>::type result_value = *values_first_r;
111
+
112
+ // consume the entirety of the first key's sequence
113
+ for(++keys_first_r, ++values_first_r;
114
+ (keys_first_r != keys_last_r) && binary_pred(*keys_first_r, result_key);
115
+ ++keys_first_r, ++values_first_r)
116
+ {
117
+ result_value = binary_op(result_value, *values_first_r);
118
+ }
119
+
120
+ return thrust::make_pair(keys_first_r.base(), thrust::make_pair(result_key, result_value));
121
+ }
122
+
123
+
124
+ template<typename InputIterator1,
125
+ typename InputIterator2,
126
+ typename OutputIterator1,
127
+ typename OutputIterator2,
128
+ typename BinaryPredicate,
129
+ typename BinaryFunction>
130
+ thrust::tuple<
131
+ OutputIterator1,
132
+ OutputIterator2,
133
+ typename thrust::iterator_value<InputIterator1>::type,
134
+ typename partial_sum_type<InputIterator2,BinaryFunction>::type
135
+ >
136
+ reduce_by_key_with_carry(InputIterator1 keys_first,
137
+ InputIterator1 keys_last,
138
+ InputIterator2 values_first,
139
+ OutputIterator1 keys_output,
140
+ OutputIterator2 values_output,
141
+ BinaryPredicate binary_pred,
142
+ BinaryFunction binary_op)
143
+ {
144
+ // first, consume the last sequence to produce the carry
145
+ // XXX is there an elegant way to pose this such that we don't need to default construct carry?
146
+ thrust::pair<
147
+ typename thrust::iterator_value<InputIterator1>::type,
148
+ typename partial_sum_type<InputIterator2,BinaryFunction>::type
149
+ > carry;
150
+
151
+ thrust::tie(keys_last, carry) = reduce_last_segment_backward(keys_first, keys_last, values_first, binary_pred, binary_op);
152
+
153
+ // finish with sequential reduce_by_key
154
+ thrust::tie(keys_output, values_output) =
155
+ thrust::reduce_by_key(thrust::seq, keys_first, keys_last, values_first, keys_output, values_output, binary_pred, binary_op);
156
+
157
+ return thrust::make_tuple(keys_output, values_output, carry.first, carry.second);
158
+ }
159
+
160
+
161
+ template<typename Iterator>
162
+ bool interval_has_carry(size_t interval_idx, size_t interval_size, size_t num_intervals, Iterator tail_flags)
163
+ {
164
+ // to discover whether the interval has a carry, look at the tail_flag corresponding to its last element
165
+ // the final interval never has a carry by definition
166
+ return (interval_idx + 1 < num_intervals) ? !tail_flags[(interval_idx + 1) * interval_size - 1] : false;
167
+ }
168
+
169
+
170
+ template<typename Iterator1, typename Iterator2, typename Iterator3, typename Iterator4, typename Iterator5, typename Iterator6, typename BinaryPredicate, typename BinaryFunction>
171
+ struct serial_reduce_by_key_body
172
+ {
173
+ typedef typename thrust::iterator_difference<Iterator1>::type size_type;
174
+
175
+ Iterator1 keys_first;
176
+ Iterator2 values_first;
177
+ Iterator3 result_offset;
178
+ Iterator4 keys_result;
179
+ Iterator5 values_result;
180
+ Iterator6 carry_result;
181
+
182
+ size_type n;
183
+ size_type interval_size;
184
+ size_type num_intervals;
185
+
186
+ BinaryPredicate binary_pred;
187
+ BinaryFunction binary_op;
188
+
189
+ serial_reduce_by_key_body(Iterator1 keys_first, Iterator2 values_first, Iterator3 result_offset, Iterator4 keys_result, Iterator5 values_result, Iterator6 carry_result, size_type n, size_type interval_size, size_type num_intervals, BinaryPredicate binary_pred, BinaryFunction binary_op)
190
+ : keys_first(keys_first), values_first(values_first),
191
+ result_offset(result_offset),
192
+ keys_result(keys_result),
193
+ values_result(values_result),
194
+ carry_result(carry_result),
195
+ n(n),
196
+ interval_size(interval_size),
197
+ num_intervals(num_intervals),
198
+ binary_pred(binary_pred),
199
+ binary_op(binary_op)
200
+ {}
201
+
202
+ void operator()(const ::tbb::blocked_range<size_type> &r) const
203
+ {
204
+ assert(r.size() == 1);
205
+
206
+ const size_type interval_idx = r.begin();
207
+
208
+ const size_type offset_to_first = interval_size * interval_idx;
209
+ const size_type offset_to_last = (thrust::min)(n, offset_to_first + interval_size);
210
+
211
+ Iterator1 my_keys_first = keys_first + offset_to_first;
212
+ Iterator1 my_keys_last = keys_first + offset_to_last;
213
+ Iterator2 my_values_first = values_first + offset_to_first;
214
+ Iterator3 my_result_offset = result_offset + interval_idx;
215
+ Iterator4 my_keys_result = keys_result + *my_result_offset;
216
+ Iterator5 my_values_result = values_result + *my_result_offset;
217
+ Iterator6 my_carry_result = carry_result + interval_idx;
218
+
219
+ // consume the rest of the interval with reduce_by_key
220
+ typedef typename thrust::iterator_value<Iterator1>::type key_type;
221
+ typedef typename partial_sum_type<Iterator2,BinaryFunction>::type value_type;
222
+
223
+ // XXX is there a way to pose this so that we don't require default construction of carry?
224
+ thrust::pair<key_type, value_type> carry;
225
+
226
+ thrust::tie(my_keys_result, my_values_result, carry.first, carry.second) =
227
+ reduce_by_key_with_carry(my_keys_first,
228
+ my_keys_last,
229
+ my_values_first,
230
+ my_keys_result,
231
+ my_values_result,
232
+ binary_pred,
233
+ binary_op);
234
+
235
+ // store to carry only when we actually have a carry
236
+ // store to my_keys_result & my_values_result otherwise
237
+
238
+ // create tail_flags so we can check for a carry
239
+ thrust::detail::tail_flags<Iterator1,BinaryPredicate> flags = thrust::detail::make_tail_flags(keys_first, keys_first + n, binary_pred);
240
+
241
+ if(interval_has_carry(interval_idx, interval_size, num_intervals, flags.begin()))
242
+ {
243
+ // we can ignore the carry's key
244
+ // XXX because the carry result is uninitialized, we should copy construct
245
+ *my_carry_result = carry.second;
246
+ }
247
+ else
248
+ {
249
+ *my_keys_result = carry.first;
250
+ *my_values_result = carry.second;
251
+ }
252
+ }
253
+ };
254
+
255
+
256
+ template<typename Iterator1, typename Iterator2, typename Iterator3, typename Iterator4, typename Iterator5, typename Iterator6, typename BinaryPredicate, typename BinaryFunction>
257
+ serial_reduce_by_key_body<Iterator1,Iterator2,Iterator3,Iterator4,Iterator5,Iterator6,BinaryPredicate,BinaryFunction>
258
+ make_serial_reduce_by_key_body(Iterator1 keys_first, Iterator2 values_first, Iterator3 result_offset, Iterator4 keys_result, Iterator5 values_result, Iterator6 carry_result, typename thrust::iterator_difference<Iterator1>::type n, size_t interval_size, size_t num_intervals, BinaryPredicate binary_pred, BinaryFunction binary_op)
259
+ {
260
+ return serial_reduce_by_key_body<Iterator1,Iterator2,Iterator3,Iterator4,Iterator5,Iterator6,BinaryPredicate,BinaryFunction>(keys_first, values_first, result_offset, keys_result, values_result, carry_result, n, interval_size, num_intervals, binary_pred, binary_op);
261
+ }
262
+
263
+
264
+ } // end reduce_by_key_detail
265
+
266
+
267
+ template<typename DerivedPolicy, typename Iterator1, typename Iterator2, typename Iterator3, typename Iterator4, typename BinaryPredicate, typename BinaryFunction>
268
+ thrust::pair<Iterator3,Iterator4>
269
+ reduce_by_key(thrust::tbb::execution_policy<DerivedPolicy> &exec,
270
+ Iterator1 keys_first, Iterator1 keys_last,
271
+ Iterator2 values_first,
272
+ Iterator3 keys_result,
273
+ Iterator4 values_result,
274
+ BinaryPredicate binary_pred,
275
+ BinaryFunction binary_op)
276
+ {
277
+
278
+ typedef typename thrust::iterator_difference<Iterator1>::type difference_type;
279
+ difference_type n = keys_last - keys_first;
280
+ if(n == 0) return thrust::make_pair(keys_result, values_result);
281
+
282
+ // XXX this value is a tuning opportunity
283
+ const difference_type parallelism_threshold = 10000;
284
+
285
+ if(n < parallelism_threshold)
286
+ {
287
+ // don't bother parallelizing for small n
288
+ return thrust::reduce_by_key(thrust::seq, keys_first, keys_last, values_first, keys_result, values_result, binary_pred, binary_op);
289
+ }
290
+
291
+ // count the number of processors
292
+ const unsigned int p = thrust::max<unsigned int>(1u, std::thread::hardware_concurrency());
293
+
294
+ // generate O(P) intervals of sequential work
295
+ // XXX oversubscribing is a tuning opportunity
296
+ const unsigned int subscription_rate = 1;
297
+ difference_type interval_size = thrust::min<difference_type>(parallelism_threshold, thrust::max<difference_type>(n, n / (subscription_rate * p)));
298
+ difference_type num_intervals = reduce_by_key_detail::divide_ri(n, interval_size);
299
+
300
+ // decompose the input into intervals of size N / num_intervals
301
+ // add one extra element to this vector to store the size of the entire result
302
+ thrust::detail::temporary_array<difference_type, DerivedPolicy> interval_output_offsets(0, exec, num_intervals + 1);
303
+
304
+ // first count the number of tail flags in each interval
305
+ thrust::detail::tail_flags<Iterator1,BinaryPredicate> tail_flags = thrust::detail::make_tail_flags(keys_first, keys_last, binary_pred);
306
+ thrust::system::tbb::detail::reduce_intervals(exec, tail_flags.begin(), tail_flags.end(), interval_size, interval_output_offsets.begin() + 1, thrust::plus<size_t>());
307
+ interval_output_offsets[0] = 0;
308
+
309
+ // scan the counts to get each body's output offset
310
+ thrust::inclusive_scan(thrust::seq,
311
+ interval_output_offsets.begin() + 1, interval_output_offsets.end(),
312
+ interval_output_offsets.begin() + 1);
313
+
314
+ // do a reduce_by_key serially in each thread
315
+ // the final interval never has a carry by definition, so don't reserve space for it
316
+ typedef typename reduce_by_key_detail::partial_sum_type<Iterator2,BinaryFunction>::type carry_type;
317
+ thrust::detail::temporary_array<carry_type, DerivedPolicy> carries(0, exec, num_intervals - 1);
318
+
319
+ // force grainsize == 1 with simple_partioner()
320
+ ::tbb::parallel_for(::tbb::blocked_range<difference_type>(0, num_intervals, 1),
321
+ reduce_by_key_detail::make_serial_reduce_by_key_body(keys_first, values_first, interval_output_offsets.begin(), keys_result, values_result, carries.begin(), n, interval_size, num_intervals, binary_pred, binary_op),
322
+ ::tbb::simple_partitioner());
323
+
324
+ difference_type size_of_result = interval_output_offsets[num_intervals];
325
+
326
+ // sequentially accumulate the carries
327
+ // note that the last interval does not have a carry
328
+ // XXX find a way to express this loop via a sequential algorithm, perhaps reduce_by_key
329
+ for(typename thrust::detail::temporary_array<carry_type,DerivedPolicy>::size_type i = 0; i < carries.size(); ++i)
330
+ {
331
+ // if our interval has a carry, then we need to sum the carry to the next interval's output offset
332
+ // if it does not have a carry, then we need to ignore carry_value[i]
333
+ if(reduce_by_key_detail::interval_has_carry(i, interval_size, num_intervals, tail_flags.begin()))
334
+ {
335
+ difference_type output_idx = interval_output_offsets[i+1];
336
+
337
+ values_result[output_idx] = binary_op(values_result[output_idx], carries[i]);
338
+ }
339
+ }
340
+
341
+ return thrust::make_pair(keys_result + size_of_result, values_result + size_of_result);
342
+ }
343
+
344
+
345
+ } // end detail
346
+ } // end tbb
347
+ } // end system
348
+ THRUST_NAMESPACE_END
349
+
miniCUDA124/include/thrust/system/tbb/detail/reduce_intervals.h ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/tbb/detail/execution_policy.h>
29
+ #include <thrust/detail/seq.h>
30
+
31
+ #include <tbb/parallel_for.h>
32
+ #include <thrust/iterator/iterator_traits.h>
33
+ #include <thrust/detail/minmax.h>
34
+ #include <thrust/system/cpp/memory.h>
35
+ #include <thrust/reduce.h>
36
+ #include <cassert>
37
+
38
+ THRUST_NAMESPACE_BEGIN
39
+ namespace system
40
+ {
41
+ namespace tbb
42
+ {
43
+ namespace detail
44
+ {
45
+ namespace reduce_intervals_detail
46
+ {
47
+
48
+
49
+ template<typename L, typename R>
50
+ inline L divide_ri(const L x, const R y)
51
+ {
52
+ return (x + (y - 1)) / y;
53
+ }
54
+
55
+
56
+ template<typename RandomAccessIterator1, typename RandomAccessIterator2, typename Size, typename BinaryFunction>
57
+ struct body
58
+ {
59
+ RandomAccessIterator1 first;
60
+ RandomAccessIterator2 result;
61
+ Size n, interval_size;
62
+ BinaryFunction binary_op;
63
+
64
+ body(RandomAccessIterator1 first, RandomAccessIterator2 result, Size n, Size interval_size, BinaryFunction binary_op)
65
+ : first(first), result(result), n(n), interval_size(interval_size), binary_op(binary_op)
66
+ {}
67
+
68
+ void operator()(const ::tbb::blocked_range<Size> &r) const
69
+ {
70
+ assert(r.size() == 1);
71
+
72
+ Size interval_idx = r.begin();
73
+
74
+ Size offset_to_first = interval_size * interval_idx;
75
+ Size offset_to_last = (thrust::min)(n, offset_to_first + interval_size);
76
+
77
+ RandomAccessIterator1 my_first = first + offset_to_first;
78
+ RandomAccessIterator1 my_last = first + offset_to_last;
79
+
80
+ // carefully pass the init value for the interval with raw_reference_cast
81
+ typedef typename BinaryFunction::result_type sum_type;
82
+ result[interval_idx] =
83
+ thrust::reduce(thrust::seq, my_first + 1, my_last, sum_type(thrust::raw_reference_cast(*my_first)), binary_op);
84
+ }
85
+ };
86
+
87
+
88
+ template<typename RandomAccessIterator1, typename RandomAccessIterator2, typename Size, typename BinaryFunction>
89
+ body<RandomAccessIterator1,RandomAccessIterator2,Size,BinaryFunction>
90
+ make_body(RandomAccessIterator1 first, RandomAccessIterator2 result, Size n, Size interval_size, BinaryFunction binary_op)
91
+ {
92
+ return body<RandomAccessIterator1,RandomAccessIterator2,Size,BinaryFunction>(first, result, n, interval_size, binary_op);
93
+ }
94
+
95
+
96
+ } // end reduce_intervals_detail
97
+
98
+
99
+ template<typename DerivedPolicy, typename RandomAccessIterator1, typename Size, typename RandomAccessIterator2, typename BinaryFunction>
100
+ void reduce_intervals(thrust::tbb::execution_policy<DerivedPolicy> &,
101
+ RandomAccessIterator1 first,
102
+ RandomAccessIterator1 last,
103
+ Size interval_size,
104
+ RandomAccessIterator2 result,
105
+ BinaryFunction binary_op)
106
+ {
107
+ typename thrust::iterator_difference<RandomAccessIterator1>::type n = last - first;
108
+
109
+ Size num_intervals = reduce_intervals_detail::divide_ri(n, interval_size);
110
+
111
+ ::tbb::parallel_for(::tbb::blocked_range<Size>(0, num_intervals, 1), reduce_intervals_detail::make_body(first, result, Size(n), interval_size, binary_op), ::tbb::simple_partitioner());
112
+ }
113
+
114
+
115
+ template<typename DerivedPolicy, typename RandomAccessIterator1, typename Size, typename RandomAccessIterator2>
116
+ void reduce_intervals(thrust::tbb::execution_policy<DerivedPolicy> &exec,
117
+ RandomAccessIterator1 first,
118
+ RandomAccessIterator1 last,
119
+ Size interval_size,
120
+ RandomAccessIterator2 result)
121
+ {
122
+ typedef typename thrust::iterator_value<RandomAccessIterator1>::type value_type;
123
+
124
+ return thrust::system::tbb::detail::reduce_intervals(exec, first, last, interval_size, result, thrust::plus<value_type>());
125
+ }
126
+
127
+
128
+ } // end detail
129
+ } // end tbb
130
+ } // end system
131
+ THRUST_NAMESPACE_END
132
+
miniCUDA124/include/thrust/system/tbb/detail/remove.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/omp/detail/execution_policy.h>
29
+
30
+ THRUST_NAMESPACE_BEGIN
31
+ namespace system
32
+ {
33
+ namespace omp
34
+ {
35
+ namespace detail
36
+ {
37
+
38
+ template<typename ExecutionPolicy,
39
+ typename ForwardIterator,
40
+ typename Predicate>
41
+ ForwardIterator remove_if(execution_policy<ExecutionPolicy> &exec,
42
+ ForwardIterator first,
43
+ ForwardIterator last,
44
+ Predicate pred);
45
+
46
+
47
+ template<typename ExecutionPolicy,
48
+ typename ForwardIterator,
49
+ typename InputIterator,
50
+ typename Predicate>
51
+ ForwardIterator remove_if(execution_policy<ExecutionPolicy> &exec,
52
+ ForwardIterator first,
53
+ ForwardIterator last,
54
+ InputIterator stencil,
55
+ Predicate pred);
56
+
57
+
58
+ template<typename ExecutionPolicy,
59
+ typename InputIterator,
60
+ typename OutputIterator,
61
+ typename Predicate>
62
+ OutputIterator remove_copy_if(execution_policy<ExecutionPolicy> &exec,
63
+ InputIterator first,
64
+ InputIterator last,
65
+ OutputIterator result,
66
+ Predicate pred);
67
+
68
+
69
+ template<typename ExecutionPolicy,
70
+ typename InputIterator1,
71
+ typename InputIterator2,
72
+ typename OutputIterator,
73
+ typename Predicate>
74
+ OutputIterator remove_copy_if(execution_policy<ExecutionPolicy> &exec,
75
+ InputIterator1 first,
76
+ InputIterator1 last,
77
+ InputIterator2 stencil,
78
+ OutputIterator result,
79
+ Predicate pred);
80
+
81
+
82
+ } // end namespace detail
83
+ } // end namespace omp
84
+ } // end namespace system
85
+ THRUST_NAMESPACE_END
86
+
87
+ #include <thrust/system/tbb/detail/remove.inl>
88
+
miniCUDA124/include/thrust/system/tbb/detail/remove.inl ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/tbb/detail/remove.h>
29
+ #include <thrust/system/detail/generic/remove.h>
30
+
31
+ THRUST_NAMESPACE_BEGIN
32
+ namespace system
33
+ {
34
+ namespace tbb
35
+ {
36
+ namespace detail
37
+ {
38
+
39
+ template<typename DerivedPolicy,
40
+ typename ForwardIterator,
41
+ typename Predicate>
42
+ ForwardIterator remove_if(execution_policy<DerivedPolicy> &exec,
43
+ ForwardIterator first,
44
+ ForwardIterator last,
45
+ Predicate pred)
46
+ {
47
+ // tbb prefers generic::remove_if to cpp::remove_if
48
+ return thrust::system::detail::generic::remove_if(exec, first, last, pred);
49
+ }
50
+
51
+
52
+ template<typename DerivedPolicy,
53
+ typename ForwardIterator,
54
+ typename InputIterator,
55
+ typename Predicate>
56
+ ForwardIterator remove_if(execution_policy<DerivedPolicy> &exec,
57
+ ForwardIterator first,
58
+ ForwardIterator last,
59
+ InputIterator stencil,
60
+ Predicate pred)
61
+ {
62
+ // tbb prefers generic::remove_if to cpp::remove_if
63
+ return thrust::system::detail::generic::remove_if(exec, first, last, stencil, pred);
64
+ }
65
+
66
+
67
+ template<typename DerivedPolicy,
68
+ typename InputIterator,
69
+ typename OutputIterator,
70
+ typename Predicate>
71
+ OutputIterator remove_copy_if(execution_policy<DerivedPolicy> &exec,
72
+ InputIterator first,
73
+ InputIterator last,
74
+ OutputIterator result,
75
+ Predicate pred)
76
+ {
77
+ // tbb prefers generic::remove_copy_if to cpp::remove_copy_if
78
+ return thrust::system::detail::generic::remove_copy_if(exec, first, last, result, pred);
79
+ }
80
+
81
+ template<typename DerivedPolicy,
82
+ typename InputIterator1,
83
+ typename InputIterator2,
84
+ typename OutputIterator,
85
+ typename Predicate>
86
+ OutputIterator remove_copy_if(execution_policy<DerivedPolicy> &exec,
87
+ InputIterator1 first,
88
+ InputIterator1 last,
89
+ InputIterator2 stencil,
90
+ OutputIterator result,
91
+ Predicate pred)
92
+ {
93
+ // tbb prefers generic::remove_copy_if to cpp::remove_copy_if
94
+ return thrust::system::detail::generic::remove_copy_if(exec, first, last, stencil, result, pred);
95
+ }
96
+
97
+ } // end namespace detail
98
+ } // end namespace tbb
99
+ } // end namespace system
100
+ THRUST_NAMESPACE_END
101
+
miniCUDA124/include/thrust/system/tbb/detail/replace.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 this algorithm
30
+ #include <thrust/system/cpp/detail/scatter.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/reverse.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 reverse
30
+ #include <thrust/system/cpp/detail/reverse.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/scan.h ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+
18
+ /*! \file scan.h
19
+ * \brief TBB implementations of scan functions.
20
+ */
21
+
22
+ #pragma once
23
+
24
+ #include <thrust/detail/config.h>
25
+
26
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
27
+ # pragma GCC system_header
28
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
29
+ # pragma clang system_header
30
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
31
+ # pragma system_header
32
+ #endif // no system header
33
+ #include <thrust/system/tbb/detail/execution_policy.h>
34
+
35
+ THRUST_NAMESPACE_BEGIN
36
+ namespace system
37
+ {
38
+ namespace tbb
39
+ {
40
+ namespace detail
41
+ {
42
+
43
+ template<typename InputIterator,
44
+ typename OutputIterator,
45
+ typename BinaryFunction>
46
+ OutputIterator inclusive_scan(tag,
47
+ InputIterator first,
48
+ InputIterator last,
49
+ OutputIterator result,
50
+ BinaryFunction binary_op);
51
+
52
+
53
+ template<typename InputIterator,
54
+ typename OutputIterator,
55
+ typename T,
56
+ typename BinaryFunction>
57
+ OutputIterator exclusive_scan(tag,
58
+ InputIterator first,
59
+ InputIterator last,
60
+ OutputIterator result,
61
+ T init,
62
+ BinaryFunction binary_op);
63
+
64
+
65
+ } // end namespace detail
66
+ } // end namespace tbb
67
+ } // end namespace system
68
+ THRUST_NAMESPACE_END
69
+
70
+ #include <thrust/system/tbb/detail/scan.inl>
71
+
miniCUDA124/include/thrust/system/tbb/detail/scan.inl ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/tbb/detail/scan.h>
29
+ #include <thrust/distance.h>
30
+ #include <thrust/advance.h>
31
+ #include <thrust/iterator/iterator_traits.h>
32
+ #include <thrust/detail/function.h>
33
+ #include <thrust/detail/type_traits.h>
34
+ #include <thrust/detail/type_traits/function_traits.h>
35
+ #include <thrust/detail/type_traits/iterator/is_output_iterator.h>
36
+ #include <tbb/blocked_range.h>
37
+ #include <tbb/parallel_scan.h>
38
+
39
+ THRUST_NAMESPACE_BEGIN
40
+ namespace system
41
+ {
42
+ namespace tbb
43
+ {
44
+ namespace detail
45
+ {
46
+ namespace scan_detail
47
+ {
48
+
49
+ template<typename InputIterator,
50
+ typename OutputIterator,
51
+ typename BinaryFunction,
52
+ typename ValueType>
53
+ struct inclusive_body
54
+ {
55
+ InputIterator input;
56
+ OutputIterator output;
57
+ thrust::detail::wrapped_function<BinaryFunction,ValueType> binary_op;
58
+ ValueType sum;
59
+ bool first_call;
60
+
61
+ inclusive_body(InputIterator input, OutputIterator output, BinaryFunction binary_op, ValueType dummy)
62
+ : input(input), output(output), binary_op(binary_op), sum(dummy), first_call(true)
63
+ {}
64
+
65
+ inclusive_body(inclusive_body& b, ::tbb::split)
66
+ : input(b.input), output(b.output), binary_op(b.binary_op), sum(b.sum), first_call(true)
67
+ {}
68
+
69
+ template<typename Size>
70
+ void operator()(const ::tbb::blocked_range<Size>& r, ::tbb::pre_scan_tag)
71
+ {
72
+ InputIterator iter = input + r.begin();
73
+
74
+ ValueType temp = *iter;
75
+
76
+ ++iter;
77
+
78
+ for (Size i = r.begin() + 1; i != r.end(); ++i, ++iter)
79
+ temp = binary_op(temp, *iter);
80
+
81
+ if (first_call)
82
+ sum = temp;
83
+ else
84
+ sum = binary_op(sum, temp);
85
+
86
+ first_call = false;
87
+ }
88
+
89
+ template<typename Size>
90
+ void operator()(const ::tbb::blocked_range<Size>& r, ::tbb::final_scan_tag)
91
+ {
92
+ InputIterator iter1 = input + r.begin();
93
+ OutputIterator iter2 = output + r.begin();
94
+
95
+ if (first_call)
96
+ {
97
+ *iter2 = sum = *iter1;
98
+ ++iter1;
99
+ ++iter2;
100
+ for (Size i = r.begin() + 1; i != r.end(); ++i, ++iter1, ++iter2)
101
+ *iter2 = sum = binary_op(sum, *iter1);
102
+ }
103
+ else
104
+ {
105
+ for (Size i = r.begin(); i != r.end(); ++i, ++iter1, ++iter2)
106
+ *iter2 = sum = binary_op(sum, *iter1);
107
+ }
108
+
109
+ first_call = false;
110
+ }
111
+
112
+ void reverse_join(inclusive_body& b)
113
+ {
114
+ // Only accumulate this functor's partial sum if this functor has been
115
+ // called at least once -- otherwise we'll over-count the initial value.
116
+ if (!first_call)
117
+ {
118
+ sum = binary_op(b.sum, sum);
119
+ }
120
+ }
121
+
122
+ void assign(inclusive_body& b)
123
+ {
124
+ sum = b.sum;
125
+ }
126
+ };
127
+
128
+
129
+ template<typename InputIterator,
130
+ typename OutputIterator,
131
+ typename BinaryFunction,
132
+ typename ValueType>
133
+ struct exclusive_body
134
+ {
135
+ InputIterator input;
136
+ OutputIterator output;
137
+ thrust::detail::wrapped_function<BinaryFunction,ValueType> binary_op;
138
+ ValueType sum;
139
+ bool first_call;
140
+
141
+ exclusive_body(InputIterator input, OutputIterator output, BinaryFunction binary_op, ValueType init)
142
+ : input(input), output(output), binary_op(binary_op), sum(init), first_call(true)
143
+ {}
144
+
145
+ exclusive_body(exclusive_body& b, ::tbb::split)
146
+ : input(b.input), output(b.output), binary_op(b.binary_op), sum(b.sum), first_call(true)
147
+ {}
148
+
149
+ template<typename Size>
150
+ void operator()(const ::tbb::blocked_range<Size>& r, ::tbb::pre_scan_tag)
151
+ {
152
+ InputIterator iter = input + r.begin();
153
+
154
+ ValueType temp = *iter;
155
+
156
+ ++iter;
157
+
158
+ for (Size i = r.begin() + 1; i != r.end(); ++i, ++iter)
159
+ temp = binary_op(temp, *iter);
160
+
161
+ if (first_call && r.begin() > 0)
162
+ sum = temp;
163
+ else
164
+ sum = binary_op(sum, temp);
165
+
166
+ first_call = false;
167
+ }
168
+
169
+ template<typename Size>
170
+ void operator()(const ::tbb::blocked_range<Size>& r, ::tbb::final_scan_tag)
171
+ {
172
+ InputIterator iter1 = input + r.begin();
173
+ OutputIterator iter2 = output + r.begin();
174
+
175
+ for (Size i = r.begin(); i != r.end(); ++i, ++iter1, ++iter2)
176
+ {
177
+ ValueType temp = binary_op(sum, *iter1);
178
+ *iter2 = sum;
179
+ sum = temp;
180
+ }
181
+
182
+ first_call = false;
183
+ }
184
+
185
+ void reverse_join(exclusive_body& b)
186
+ {
187
+ // Only accumulate this functor's partial sum if this functor has been
188
+ // called at least once -- otherwise we'll over-count the initial value.
189
+ if (!first_call)
190
+ {
191
+ sum = binary_op(b.sum, sum);
192
+ }
193
+ }
194
+
195
+ void assign(exclusive_body& b)
196
+ {
197
+ sum = b.sum;
198
+ }
199
+ };
200
+
201
+ } // end scan_detail
202
+
203
+ template<typename InputIterator,
204
+ typename OutputIterator,
205
+ typename BinaryFunction>
206
+ OutputIterator inclusive_scan(tag,
207
+ InputIterator first,
208
+ InputIterator last,
209
+ OutputIterator result,
210
+ BinaryFunction binary_op)
211
+ {
212
+ using namespace thrust::detail;
213
+
214
+ // Use the input iterator's value type per https://wg21.link/P0571
215
+ using ValueType = typename thrust::iterator_value<InputIterator>::type;
216
+
217
+ using Size = typename thrust::iterator_difference<InputIterator>::type;
218
+ Size n = thrust::distance(first, last);
219
+
220
+ if (n != 0)
221
+ {
222
+ typedef typename scan_detail::inclusive_body<InputIterator,OutputIterator,BinaryFunction,ValueType> Body;
223
+ Body scan_body(first, result, binary_op, *first);
224
+ ::tbb::parallel_scan(::tbb::blocked_range<Size>(0,n), scan_body);
225
+ }
226
+
227
+ thrust::advance(result, n);
228
+
229
+ return result;
230
+ }
231
+
232
+ template<typename InputIterator,
233
+ typename OutputIterator,
234
+ typename InitialValueType,
235
+ typename BinaryFunction>
236
+ OutputIterator exclusive_scan(tag,
237
+ InputIterator first,
238
+ InputIterator last,
239
+ OutputIterator result,
240
+ InitialValueType init,
241
+ BinaryFunction binary_op)
242
+ {
243
+ using namespace thrust::detail;
244
+
245
+ // Use the initial value type per https://wg21.link/P0571
246
+ using ValueType = InitialValueType;
247
+
248
+ using Size = typename thrust::iterator_difference<InputIterator>::type;
249
+ Size n = thrust::distance(first, last);
250
+
251
+ if (n != 0)
252
+ {
253
+ typedef typename scan_detail::exclusive_body<InputIterator,OutputIterator,BinaryFunction,ValueType> Body;
254
+ Body scan_body(first, result, binary_op, init);
255
+ ::tbb::parallel_scan(::tbb::blocked_range<Size>(0,n), scan_body);
256
+ }
257
+
258
+ thrust::advance(result, n);
259
+
260
+ return result;
261
+ }
262
+
263
+ } // end namespace detail
264
+ } // end namespace tbb
265
+ } // end namespace system
266
+ THRUST_NAMESPACE_END
miniCUDA124/include/thrust/system/tbb/detail/scan_by_key.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 scan_by_key
30
+ #include <thrust/system/cpp/detail/scan_by_key.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/scatter.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 this algorithm
30
+ #include <thrust/system/cpp/detail/scatter.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/sequence.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 sequence
30
+ #include <thrust/system/cpp/detail/sequence.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/set_operations.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 set_operations
30
+ #include <thrust/system/cpp/detail/set_operations.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/sort.h ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+ #include <thrust/system/tbb/detail/execution_policy.h>
29
+
30
+ THRUST_NAMESPACE_BEGIN
31
+ namespace system
32
+ {
33
+ namespace tbb
34
+ {
35
+ namespace detail
36
+ {
37
+
38
+ template<typename DerivedPolicy,
39
+ typename RandomAccessIterator,
40
+ typename StrictWeakOrdering>
41
+ void stable_sort(execution_policy<DerivedPolicy> &exec,
42
+ RandomAccessIterator first,
43
+ RandomAccessIterator last,
44
+ StrictWeakOrdering comp);
45
+
46
+ template<typename DerivedPolicy,
47
+ typename RandomAccessIterator1,
48
+ typename RandomAccessIterator2,
49
+ typename StrictWeakOrdering>
50
+ void stable_sort_by_key(execution_policy<DerivedPolicy> &exec,
51
+ RandomAccessIterator1 keys_first,
52
+ RandomAccessIterator1 keys_last,
53
+ RandomAccessIterator2 values_first,
54
+ StrictWeakOrdering comp);
55
+
56
+ } // end namespace detail
57
+ } // end namespace tbb
58
+ } // end namespace system
59
+ THRUST_NAMESPACE_END
60
+
61
+ #include <thrust/system/tbb/detail/sort.inl>
62
+
miniCUDA124/include/thrust/system/tbb/detail/sort.inl ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/temporary_array.h>
29
+ #include <thrust/detail/copy.h>
30
+ #include <thrust/iterator/iterator_traits.h>
31
+ #include <thrust/distance.h>
32
+ #include <thrust/merge.h>
33
+ #include <thrust/sort.h>
34
+ #include <thrust/detail/seq.h>
35
+ #include <tbb/parallel_invoke.h>
36
+
37
+ THRUST_NAMESPACE_BEGIN
38
+ namespace system
39
+ {
40
+ namespace tbb
41
+ {
42
+ namespace detail
43
+ {
44
+ namespace sort_detail
45
+ {
46
+
47
+
48
+ // TODO tune this based on data type and comp
49
+ const static int threshold = 128 * 1024;
50
+
51
+
52
+ template<typename DerivedPolicy, typename Iterator1, typename Iterator2, typename StrictWeakOrdering>
53
+ void merge_sort(execution_policy<DerivedPolicy> &exec, Iterator1 first1, Iterator1 last1, Iterator2 first2, StrictWeakOrdering comp, bool inplace);
54
+
55
+
56
+ template<typename DerivedPolicy, typename Iterator1, typename Iterator2, typename StrictWeakOrdering>
57
+ struct merge_sort_closure
58
+ {
59
+ execution_policy<DerivedPolicy> &exec;
60
+ Iterator1 first1, last1;
61
+ Iterator2 first2;
62
+ StrictWeakOrdering comp;
63
+ bool inplace;
64
+
65
+ merge_sort_closure(execution_policy<DerivedPolicy> &exec, Iterator1 first1, Iterator1 last1, Iterator2 first2, StrictWeakOrdering comp, bool inplace)
66
+ : exec(exec), first1(first1), last1(last1), first2(first2), comp(comp), inplace(inplace)
67
+ {}
68
+
69
+ void operator()(void) const
70
+ {
71
+ merge_sort(exec, first1, last1, first2, comp, inplace);
72
+ }
73
+ };
74
+
75
+
76
+ template<typename DerivedPolicy, typename Iterator1, typename Iterator2, typename StrictWeakOrdering>
77
+ void merge_sort(execution_policy<DerivedPolicy> &exec, Iterator1 first1, Iterator1 last1, Iterator2 first2, StrictWeakOrdering comp, bool inplace)
78
+ {
79
+ typedef typename thrust::iterator_difference<Iterator1>::type difference_type;
80
+
81
+ difference_type n = thrust::distance(first1, last1);
82
+
83
+ if (n < threshold)
84
+ {
85
+ thrust::stable_sort(thrust::seq, first1, last1, comp);
86
+
87
+ if(!inplace)
88
+ {
89
+ thrust::copy(thrust::seq, first1, last1, first2);
90
+ }
91
+
92
+ return;
93
+ }
94
+
95
+ Iterator1 mid1 = first1 + (n / 2);
96
+ Iterator2 mid2 = first2 + (n / 2);
97
+ Iterator2 last2 = first2 + n;
98
+
99
+ typedef merge_sort_closure<DerivedPolicy,Iterator1,Iterator2,StrictWeakOrdering> Closure;
100
+
101
+ Closure left (exec, first1, mid1, first2, comp, !inplace);
102
+ Closure right(exec, mid1, last1, mid2, comp, !inplace);
103
+
104
+ ::tbb::parallel_invoke(left, right);
105
+
106
+ if(inplace) thrust::merge(exec, first2, mid2, mid2, last2, first1, comp);
107
+ else thrust::merge(exec, first1, mid1, mid1, last1, first2, comp);
108
+ }
109
+
110
+
111
+ } // end namespace sort_detail
112
+
113
+
114
+ namespace sort_by_key_detail
115
+ {
116
+
117
+
118
+ // TODO tune this based on data type and comp
119
+ const static int threshold = 128 * 1024;
120
+
121
+
122
+ template<typename DerivedPolicy,
123
+ typename Iterator1,
124
+ typename Iterator2,
125
+ typename Iterator3,
126
+ typename Iterator4,
127
+ typename StrictWeakOrdering>
128
+ void merge_sort_by_key(execution_policy<DerivedPolicy> &exec,
129
+ Iterator1 first1,
130
+ Iterator1 last1,
131
+ Iterator2 first2,
132
+ Iterator3 first3,
133
+ Iterator4 first4,
134
+ StrictWeakOrdering comp,
135
+ bool inplace);
136
+
137
+
138
+ template<typename DerivedPolicy,
139
+ typename Iterator1,
140
+ typename Iterator2,
141
+ typename Iterator3,
142
+ typename Iterator4,
143
+ typename StrictWeakOrdering>
144
+ struct merge_sort_by_key_closure
145
+ {
146
+ execution_policy<DerivedPolicy> &exec;
147
+ Iterator1 first1, last1;
148
+ Iterator2 first2;
149
+ Iterator3 first3;
150
+ Iterator4 first4;
151
+ StrictWeakOrdering comp;
152
+ bool inplace;
153
+
154
+ merge_sort_by_key_closure(execution_policy<DerivedPolicy> &exec,
155
+ Iterator1 first1,
156
+ Iterator1 last1,
157
+ Iterator2 first2,
158
+ Iterator3 first3,
159
+ Iterator4 first4,
160
+ StrictWeakOrdering comp,
161
+ bool inplace)
162
+ : exec(exec), first1(first1), last1(last1), first2(first2), first3(first3), first4(first4), comp(comp), inplace(inplace)
163
+ {}
164
+
165
+ void operator()(void) const
166
+ {
167
+ merge_sort_by_key(exec, first1, last1, first2, first3, first4, comp, inplace);
168
+ }
169
+ };
170
+
171
+
172
+ template<typename DerivedPolicy,
173
+ typename Iterator1,
174
+ typename Iterator2,
175
+ typename Iterator3,
176
+ typename Iterator4,
177
+ typename StrictWeakOrdering>
178
+ void merge_sort_by_key(execution_policy<DerivedPolicy> &exec,
179
+ Iterator1 first1,
180
+ Iterator1 last1,
181
+ Iterator2 first2,
182
+ Iterator3 first3,
183
+ Iterator4 first4,
184
+ StrictWeakOrdering comp,
185
+ bool inplace)
186
+ {
187
+ typedef typename thrust::iterator_difference<Iterator1>::type difference_type;
188
+
189
+ difference_type n = thrust::distance(first1, last1);
190
+
191
+ Iterator1 mid1 = first1 + (n / 2);
192
+ Iterator2 mid2 = first2 + (n / 2);
193
+ Iterator3 mid3 = first3 + (n / 2);
194
+ Iterator4 mid4 = first4 + (n / 2);
195
+ Iterator2 last2 = first2 + n;
196
+ Iterator3 last3 = first3 + n;
197
+
198
+ if (n < threshold)
199
+ {
200
+ thrust::stable_sort_by_key(thrust::seq, first1, last1, first2, comp);
201
+
202
+ if(!inplace)
203
+ {
204
+ thrust::copy(thrust::seq, first1, last1, first3);
205
+ thrust::copy(thrust::seq, first2, last2, first4);
206
+ }
207
+
208
+ return;
209
+ }
210
+
211
+ typedef merge_sort_by_key_closure<DerivedPolicy,Iterator1,Iterator2,Iterator3,Iterator4,StrictWeakOrdering> Closure;
212
+
213
+ Closure left (exec, first1, mid1, first2, first3, first4, comp, !inplace);
214
+ Closure right(exec, mid1, last1, mid2, mid3, mid4, comp, !inplace);
215
+
216
+ ::tbb::parallel_invoke(left, right);
217
+
218
+ if(inplace)
219
+ {
220
+ thrust::merge_by_key(exec, first3, mid3, mid3, last3, first4, mid4, first1, first2, comp);
221
+ }
222
+ else
223
+ {
224
+ thrust::merge_by_key(exec, first1, mid1, mid1, last1, first2, mid2, first3, first4, comp);
225
+ }
226
+ }
227
+
228
+
229
+ } // end namespace sort_detail
230
+
231
+
232
+ template<typename DerivedPolicy,
233
+ typename RandomAccessIterator,
234
+ typename StrictWeakOrdering>
235
+ void stable_sort(execution_policy<DerivedPolicy> &exec,
236
+ RandomAccessIterator first,
237
+ RandomAccessIterator last,
238
+ StrictWeakOrdering comp)
239
+ {
240
+ typedef typename thrust::iterator_value<RandomAccessIterator>::type key_type;
241
+
242
+ thrust::detail::temporary_array<key_type, DerivedPolicy> temp(exec, first, last);
243
+
244
+ sort_detail::merge_sort(exec, first, last, temp.begin(), comp, true);
245
+ }
246
+
247
+
248
+ template<typename DerivedPolicy,
249
+ typename RandomAccessIterator1,
250
+ typename RandomAccessIterator2,
251
+ typename StrictWeakOrdering>
252
+ void stable_sort_by_key(execution_policy<DerivedPolicy> &exec,
253
+ RandomAccessIterator1 first1,
254
+ RandomAccessIterator1 last1,
255
+ RandomAccessIterator2 first2,
256
+ StrictWeakOrdering comp)
257
+ {
258
+ typedef typename thrust::iterator_value<RandomAccessIterator1>::type key_type;
259
+ typedef typename thrust::iterator_value<RandomAccessIterator2>::type val_type;
260
+
261
+ RandomAccessIterator2 last2 = first2 + thrust::distance(first1, last1);
262
+
263
+ thrust::detail::temporary_array<key_type, DerivedPolicy> temp1(exec, first1, last1);
264
+ thrust::detail::temporary_array<val_type, DerivedPolicy> temp2(exec, first2, last2);
265
+
266
+ sort_by_key_detail::merge_sort_by_key(exec, first1, last1, first2, temp1.begin(), temp2.begin(), comp, true);
267
+ }
268
+
269
+
270
+ } // end namespace detail
271
+ } // end namespace tbb
272
+ } // end namespace system
273
+ THRUST_NAMESPACE_END
274
+
miniCUDA124/include/thrust/system/tbb/detail/swap_ranges.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
+ // tbb inherits swap_ranges
30
+ #include <thrust/system/cpp/detail/swap_ranges.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/tabulate.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 tabulate
30
+ #include <thrust/system/cpp/detail/tabulate.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/temporary_buffer.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 temporary buffer functions
30
+
miniCUDA124/include/thrust/system/tbb/detail/transform.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
+ // omp inherits transform
30
+ #include <thrust/system/cpp/detail/transform.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/transform_reduce.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 transform_reduce
30
+ #include <thrust/system/cpp/detail/transform_reduce.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/transform_scan.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 transform_scan
30
+ #include <thrust/system/cpp/detail/transform_scan.h>
31
+
miniCUDA124/include/thrust/system/tbb/detail/uninitialized_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 uninitialized_copy
30
+ #include <thrust/system/cpp/detail/uninitialized_copy.h>
31
+