ZTWHHH commited on
Commit
626e106
·
verified ·
1 Parent(s): 1aec91e

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. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Almaty +0 -0
  2. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Anadyr +0 -0
  3. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Brunei +0 -0
  4. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Chita +0 -0
  5. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Dili +0 -0
  6. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Karachi +0 -0
  7. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Omsk +0 -0
  8. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Taipei +0 -0
  9. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Tel_Aviv +0 -0
  10. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Thimbu +0 -0
  11. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Ust-Nera +0 -0
  12. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Yakutsk +0 -0
  13. parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Yerevan +0 -0
  14. videollama2/lib/python3.10/site-packages/pip/_internal/__pycache__/cache.cpython-310.pyc +0 -0
  15. videollama2/lib/python3.10/site-packages/pip/_internal/__pycache__/configuration.cpython-310.pyc +0 -0
  16. videollama2/lib/python3.10/site-packages/pip/_internal/__pycache__/pyproject.cpython-310.pyc +0 -0
  17. videollama2/lib/python3.10/site-packages/pip/_internal/__pycache__/self_outdated_check.cpython-310.pyc +0 -0
  18. videollama2/lib/python3.10/site-packages/pip/_internal/__pycache__/wheel_builder.cpython-310.pyc +0 -0
  19. videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/_jaraco_text.cpython-310.pyc +0 -0
  20. videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/datetime.cpython-310.pyc +0 -0
  21. videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/deprecation.cpython-310.pyc +0 -0
  22. videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/misc.cpython-310.pyc +0 -0
  23. videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/retry.cpython-310.pyc +0 -0
  24. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/copy_if.h +30 -0
  25. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/count.h +29 -0
  26. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/generate.h +29 -0
  27. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/merge.h +30 -0
  28. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/per_device_resource.h +29 -0
  29. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/sequence.h +29 -0
  30. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/swap_ranges.h +29 -0
  31. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/tabulate.h +29 -0
  32. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/unique_by_key.h +30 -0
  33. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/vector.inl +130 -0
  34. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/adjacent_difference.h +224 -0
  35. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/assign_value.h +97 -0
  36. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/binary_search.h +29 -0
  37. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/cdp_dispatch.h +97 -0
  38. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/copy.h +129 -0
  39. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/copy_if.h +280 -0
  40. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/count.h +71 -0
  41. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/fill.h +91 -0
  42. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/find.h +175 -0
  43. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/for_each.h +83 -0
  44. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/future.inl +1235 -0
  45. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/gather.h +91 -0
  46. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/generate.h +87 -0
  47. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/get_value.h +89 -0
  48. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/iter_swap.h +69 -0
  49. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/logical.h +29 -0
  50. vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/make_unsigned_special.h +61 -0
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Almaty ADDED
Binary file (983 Bytes). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Anadyr ADDED
Binary file (1.17 kB). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Brunei ADDED
Binary file (469 Bytes). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Chita ADDED
Binary file (1.21 kB). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Dili ADDED
Binary file (257 Bytes). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Karachi ADDED
Binary file (379 Bytes). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Omsk ADDED
Binary file (1.19 kB). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Taipei ADDED
Binary file (761 Bytes). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Tel_Aviv ADDED
Binary file (2.39 kB). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Thimbu ADDED
Binary file (189 Bytes). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Ust-Nera ADDED
Binary file (1.24 kB). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Yakutsk ADDED
Binary file (1.19 kB). View file
 
parrot/lib/python3.10/site-packages/pytz/zoneinfo/Asia/Yerevan ADDED
Binary file (1.14 kB). View file
 
videollama2/lib/python3.10/site-packages/pip/_internal/__pycache__/cache.cpython-310.pyc ADDED
Binary file (9.03 kB). View file
 
videollama2/lib/python3.10/site-packages/pip/_internal/__pycache__/configuration.cpython-310.pyc ADDED
Binary file (11.6 kB). View file
 
videollama2/lib/python3.10/site-packages/pip/_internal/__pycache__/pyproject.cpython-310.pyc ADDED
Binary file (3.75 kB). View file
 
videollama2/lib/python3.10/site-packages/pip/_internal/__pycache__/self_outdated_check.cpython-310.pyc ADDED
Binary file (6.85 kB). View file
 
videollama2/lib/python3.10/site-packages/pip/_internal/__pycache__/wheel_builder.cpython-310.pyc ADDED
Binary file (8.63 kB). View file
 
videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/_jaraco_text.cpython-310.pyc ADDED
Binary file (3.83 kB). View file
 
videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/datetime.cpython-310.pyc ADDED
Binary file (499 Bytes). View file
 
videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/deprecation.cpython-310.pyc ADDED
Binary file (3.3 kB). View file
 
videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/misc.cpython-310.pyc ADDED
Binary file (22.9 kB). View file
 
videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/retry.cpython-310.pyc ADDED
Binary file (1.6 kB). View file
 
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/copy_if.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 inherits copy_if
30
+ #include <thrust/system/detail/sequential/copy_if.h>
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/count.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ // this system has no special version of this algorithm
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/generate.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ // this system has no special version of this algorithm
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/merge.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 inherits merge
30
+ #include <thrust/system/detail/sequential/merge.h>
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/per_device_resource.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/sequence.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ // this system has no special version of this algorithm
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/swap_ranges.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ // cpp has no special swap_ranges
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/tabulate.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ // this system has no special version of this algorithm
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/unique_by_key.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 inherits unique_by_key
30
+ #include <thrust/system/detail/sequential/unique_by_key.h>
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cpp/detail/vector.inl ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/vector.h>
29
+
30
+ #include <utility>
31
+
32
+ THRUST_NAMESPACE_BEGIN
33
+ namespace system
34
+ {
35
+ namespace cpp
36
+ {
37
+
38
+ template <typename T, typename Allocator>
39
+ vector<T, Allocator>::vector()
40
+ : super_t()
41
+ {}
42
+
43
+ template <typename T, typename Allocator>
44
+ vector<T, Allocator>::vector(size_type n)
45
+ : super_t(n)
46
+ {}
47
+
48
+ template <typename T, typename Allocator>
49
+ vector<T, Allocator>::vector(size_type n, const value_type& value)
50
+ : super_t(n, value)
51
+ {}
52
+
53
+ template <typename T, typename Allocator>
54
+ vector<T, Allocator>::vector(const vector& x)
55
+ : super_t(x)
56
+ {}
57
+
58
+ template <typename T, typename Allocator>
59
+ vector<T, Allocator>::vector(vector&& x)
60
+ : super_t(std::move(x))
61
+ {}
62
+
63
+ template <typename T, typename Allocator>
64
+ template <typename OtherT, typename OtherAllocator>
65
+ vector<T, Allocator>::vector(const thrust::detail::vector_base<OtherT, OtherAllocator>& x)
66
+ : super_t(x)
67
+ {}
68
+
69
+ template <typename T, typename Allocator>
70
+ template <typename OtherT, typename OtherAllocator>
71
+ vector<T, Allocator>::vector(const std::vector<OtherT, OtherAllocator>& x)
72
+ : super_t(x)
73
+ {}
74
+
75
+ template <typename T, typename Allocator>
76
+ template <typename InputIterator>
77
+ vector<T, Allocator>::vector(InputIterator first, InputIterator last)
78
+ : super_t(first, last)
79
+ {}
80
+
81
+ template <typename T, typename Allocator>
82
+ vector<T, Allocator>& vector<T, Allocator>::operator=(const vector& x)
83
+ {
84
+ super_t::operator=(x);
85
+ return *this;
86
+ }
87
+
88
+ template <typename T, typename Allocator>
89
+ vector<T, Allocator>& vector<T, Allocator>::operator=(vector&& x)
90
+ {
91
+ super_t::operator=(std::move(x));
92
+ return *this;
93
+ }
94
+
95
+ template <typename T, typename Allocator>
96
+ vector<T, Allocator>::vector(std::initializer_list<T> il)
97
+ : super_t(il)
98
+ {}
99
+
100
+ template <typename T, typename Allocator>
101
+ vector<T, Allocator>::vector(std::initializer_list<T> il, const Allocator& alloc)
102
+ : super_t(il, alloc)
103
+ {}
104
+
105
+ template <typename T, typename Allocator>
106
+ vector<T, Allocator>& vector<T, Allocator>::operator=(std::initializer_list<T> il)
107
+ {
108
+ super_t::operator=(il);
109
+ return *this;
110
+ }
111
+
112
+ template <typename T, typename Allocator>
113
+ template <typename OtherT, typename OtherAllocator>
114
+ vector<T, Allocator>& vector<T, Allocator>::operator=(const std::vector<OtherT, OtherAllocator>& x)
115
+ {
116
+ super_t::operator=(x);
117
+ return *this;
118
+ }
119
+
120
+ template <typename T, typename Allocator>
121
+ template <typename OtherT, typename OtherAllocator>
122
+ vector<T, Allocator>& vector<T, Allocator>::operator=(const thrust::detail::vector_base<OtherT, OtherAllocator>& x)
123
+ {
124
+ super_t::operator=(x);
125
+ return *this;
126
+ }
127
+
128
+ } // namespace cpp
129
+ } // namespace system
130
+ THRUST_NAMESPACE_END
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/adjacent_difference.h ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******************************************************************************
2
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ * * Redistributions of source code must retain the above copyright
7
+ * notice, this list of conditions and the following disclaimer.
8
+ * * Redistributions in binary form must reproduce the above copyright
9
+ * notice, this list of conditions and the following disclaimer in the
10
+ * documentation and/or other materials provided with the distribution.
11
+ * * Neither the name of the NVIDIA CORPORATION nor the
12
+ * names of its contributors may be used to endorse or promote products
13
+ * derived from this software without specific prior written permission.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
19
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ *
26
+ ******************************************************************************/
27
+ #pragma once
28
+
29
+ #include <thrust/detail/config.h>
30
+
31
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
32
+ # pragma GCC system_header
33
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
34
+ # pragma clang system_header
35
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
36
+ # pragma system_header
37
+ #endif // no system header
38
+
39
+ #if _CCCL_HAS_CUDA_COMPILER
40
+
41
+ # include <thrust/system/cuda/config.h>
42
+
43
+ # include <cub/device/device_adjacent_difference.cuh>
44
+ # include <cub/util_math.cuh>
45
+
46
+ # include <thrust/detail/minmax.h>
47
+ # include <thrust/detail/temporary_array.h>
48
+ # include <thrust/detail/type_traits.h>
49
+ # include <thrust/functional.h>
50
+ # include <thrust/system/cuda/detail/cdp_dispatch.h>
51
+ # include <thrust/system/cuda/detail/dispatch.h>
52
+ # include <thrust/system/cuda/detail/par_to_seq.h>
53
+ # include <thrust/system/cuda/detail/util.h>
54
+ # include <thrust/type_traits/is_contiguous_iterator.h>
55
+
56
+ # include <cuda/std/type_traits>
57
+
58
+ # include <cstdint>
59
+
60
+ THRUST_NAMESPACE_BEGIN
61
+
62
+ template <typename DerivedPolicy, typename InputIterator, typename OutputIterator, typename BinaryFunction>
63
+ _CCCL_HOST_DEVICE OutputIterator adjacent_difference(
64
+ const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
65
+ InputIterator first,
66
+ InputIterator last,
67
+ OutputIterator result,
68
+ BinaryFunction binary_op);
69
+
70
+ namespace cuda_cub
71
+ {
72
+
73
+ namespace __adjacent_difference
74
+ {
75
+
76
+ template <bool MayAlias, class InputIt, class OutputIt, class BinaryOp>
77
+ cudaError_t THRUST_RUNTIME_FUNCTION doit_step(
78
+ void* d_temp_storage,
79
+ size_t& temp_storage_bytes,
80
+ InputIt first,
81
+ OutputIt result,
82
+ BinaryOp binary_op,
83
+ std::size_t num_items,
84
+ cudaStream_t stream)
85
+ {
86
+ if (num_items == 0)
87
+ {
88
+ return cudaSuccess;
89
+ }
90
+
91
+ constexpr bool may_alias = MayAlias;
92
+ constexpr bool read_left = true;
93
+
94
+ using Dispatch32 = cub::DispatchAdjacentDifference<InputIt, OutputIt, BinaryOp, std::int32_t, may_alias, read_left>;
95
+ using Dispatch64 = cub::DispatchAdjacentDifference<InputIt, OutputIt, BinaryOp, std::int64_t, may_alias, read_left>;
96
+
97
+ cudaError_t status;
98
+ THRUST_INDEX_TYPE_DISPATCH2(
99
+ status,
100
+ Dispatch32::Dispatch,
101
+ Dispatch64::Dispatch,
102
+ num_items,
103
+ (d_temp_storage, temp_storage_bytes, first, result, num_items_fixed, binary_op, stream));
104
+ return status;
105
+ }
106
+
107
+ template <class InputIt, class OutputIt, class BinaryOp>
108
+ cudaError_t THRUST_RUNTIME_FUNCTION doit_step(
109
+ void* d_temp_storage,
110
+ size_t& temp_storage_bytes,
111
+ InputIt first,
112
+ OutputIt result,
113
+ BinaryOp binary_op,
114
+ std::size_t num_items,
115
+ cudaStream_t stream,
116
+ thrust::detail::integral_constant<bool, false> /* comparable */)
117
+ {
118
+ constexpr bool may_alias = true;
119
+ return doit_step<may_alias>(d_temp_storage, temp_storage_bytes, first, result, binary_op, num_items, stream);
120
+ }
121
+
122
+ template <class InputIt, class OutputIt, class BinaryOp>
123
+ cudaError_t THRUST_RUNTIME_FUNCTION doit_step(
124
+ void* d_temp_storage,
125
+ size_t& temp_storage_bytes,
126
+ InputIt first,
127
+ OutputIt result,
128
+ BinaryOp binary_op,
129
+ std::size_t num_items,
130
+ cudaStream_t stream,
131
+ thrust::detail::integral_constant<bool, true> /* comparable */)
132
+ {
133
+ // The documentation states that pointers might be equal but can't alias in
134
+ // any other way. That is, the distance should be equal to zero or exceed
135
+ // `num_items`. In the latter case, we use an optimized version.
136
+ if (first != result)
137
+ {
138
+ constexpr bool may_alias = false;
139
+ return doit_step<may_alias>(d_temp_storage, temp_storage_bytes, first, result, binary_op, num_items, stream);
140
+ }
141
+
142
+ constexpr bool may_alias = true;
143
+ return doit_step<may_alias>(d_temp_storage, temp_storage_bytes, first, result, binary_op, num_items, stream);
144
+ }
145
+
146
+ template <typename Derived, typename InputIt, typename OutputIt, typename BinaryOp>
147
+ OutputIt THRUST_RUNTIME_FUNCTION
148
+ adjacent_difference(execution_policy<Derived>& policy, InputIt first, InputIt last, OutputIt result, BinaryOp binary_op)
149
+ {
150
+ const auto num_items = static_cast<std::size_t>(thrust::distance(first, last));
151
+ std::size_t storage_size = 0;
152
+ cudaStream_t stream = cuda_cub::stream(policy);
153
+
154
+ using UnwrapInputIt = thrust::try_unwrap_contiguous_iterator_t<InputIt>;
155
+ using UnwrapOutputIt = thrust::try_unwrap_contiguous_iterator_t<OutputIt>;
156
+
157
+ using InputValueT = thrust::iterator_value_t<UnwrapInputIt>;
158
+ using OutputValueT = thrust::iterator_value_t<UnwrapOutputIt>;
159
+
160
+ constexpr bool can_compare_iterators =
161
+ ::cuda::std::is_pointer<UnwrapInputIt>::value && ::cuda::std::is_pointer<UnwrapOutputIt>::value
162
+ && std::is_same<InputValueT, OutputValueT>::value;
163
+
164
+ auto first_unwrap = thrust::try_unwrap_contiguous_iterator(first);
165
+ auto result_unwrap = thrust::try_unwrap_contiguous_iterator(result);
166
+
167
+ thrust::detail::integral_constant<bool, can_compare_iterators> comparable;
168
+
169
+ cudaError_t status =
170
+ doit_step(nullptr, storage_size, first_unwrap, result_unwrap, binary_op, num_items, stream, comparable);
171
+ cuda_cub::throw_on_error(status, "adjacent_difference failed on 1st step");
172
+
173
+ // Allocate temporary storage.
174
+ thrust::detail::temporary_array<std::uint8_t, Derived> tmp(policy, storage_size);
175
+
176
+ status = doit_step(
177
+ static_cast<void*>(tmp.data().get()),
178
+ storage_size,
179
+ first_unwrap,
180
+ result_unwrap,
181
+ binary_op,
182
+ num_items,
183
+ stream,
184
+ comparable);
185
+ cuda_cub::throw_on_error(status, "adjacent_difference failed on 2nd step");
186
+
187
+ status = cuda_cub::synchronize_optional(policy);
188
+ cuda_cub::throw_on_error(status, "adjacent_difference failed to synchronize");
189
+
190
+ return result + num_items;
191
+ }
192
+
193
+ } // namespace __adjacent_difference
194
+
195
+ //-------------------------
196
+ // Thrust API entry points
197
+ //-------------------------
198
+
199
+ _CCCL_EXEC_CHECK_DISABLE
200
+ template <class Derived, class InputIt, class OutputIt, class BinaryOp>
201
+ OutputIt _CCCL_HOST_DEVICE
202
+ adjacent_difference(execution_policy<Derived>& policy, InputIt first, InputIt last, OutputIt result, BinaryOp binary_op)
203
+ {
204
+ THRUST_CDP_DISPATCH(
205
+ (result = __adjacent_difference::adjacent_difference(policy, first, last, result, binary_op);),
206
+ (result = thrust::adjacent_difference(cvt_to_seq(derived_cast(policy)), first, last, result, binary_op);));
207
+ return result;
208
+ }
209
+
210
+ template <class Derived, class InputIt, class OutputIt>
211
+ OutputIt _CCCL_HOST_DEVICE
212
+ adjacent_difference(execution_policy<Derived>& policy, InputIt first, InputIt last, OutputIt result)
213
+ {
214
+ using input_type = typename iterator_traits<InputIt>::value_type;
215
+ return cuda_cub::adjacent_difference(policy, first, last, result, minus<input_type>());
216
+ }
217
+
218
+ } // namespace cuda_cub
219
+ THRUST_NAMESPACE_END
220
+
221
+ //
222
+ # include <thrust/adjacent_difference.h>
223
+ # include <thrust/memory.h>
224
+ #endif
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/assign_value.h ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #if _CCCL_HAS_CUDA_COMPILER
30
+ # include <thrust/system/cuda/config.h>
31
+
32
+ # include <thrust/detail/raw_pointer_cast.h>
33
+ # include <thrust/system/cuda/detail/copy.h>
34
+ # include <thrust/system/cuda/detail/execution_policy.h>
35
+
36
+ # include <nv/target>
37
+
38
+ THRUST_NAMESPACE_BEGIN
39
+ namespace cuda_cub
40
+ {
41
+
42
+ template <typename DerivedPolicy, typename Pointer1, typename Pointer2>
43
+ inline _CCCL_HOST_DEVICE void
44
+ assign_value(thrust::cuda::execution_policy<DerivedPolicy>& exec, Pointer1 dst, Pointer2 src)
45
+ {
46
+ // XXX war nvbugs/881631
47
+ struct war_nvbugs_881631
48
+ {
49
+ _CCCL_HOST inline static void
50
+ host_path(thrust::cuda::execution_policy<DerivedPolicy>& exec, Pointer1 dst, Pointer2 src)
51
+ {
52
+ cuda_cub::copy(exec, src, src + 1, dst);
53
+ }
54
+
55
+ _CCCL_DEVICE inline static void
56
+ device_path(thrust::cuda::execution_policy<DerivedPolicy>&, Pointer1 dst, Pointer2 src)
57
+ {
58
+ *thrust::raw_pointer_cast(dst) = *thrust::raw_pointer_cast(src);
59
+ }
60
+ };
61
+
62
+ NV_IF_TARGET(
63
+ NV_IS_HOST, (war_nvbugs_881631::host_path(exec, dst, src);), (war_nvbugs_881631::device_path(exec, dst, src);));
64
+
65
+ } // end assign_value()
66
+
67
+ template <typename System1, typename System2, typename Pointer1, typename Pointer2>
68
+ inline _CCCL_HOST_DEVICE void assign_value(cross_system<System1, System2>& systems, Pointer1 dst, Pointer2 src)
69
+ {
70
+ // XXX war nvbugs/881631
71
+ struct war_nvbugs_881631
72
+ {
73
+ _CCCL_HOST inline static void host_path(cross_system<System1, System2>& systems, Pointer1 dst, Pointer2 src)
74
+ {
75
+ // rotate the systems so that they are ordered the same as (src, dst)
76
+ // for the call to thrust::copy
77
+ cross_system<System2, System1> rotated_systems = systems.rotate();
78
+ cuda_cub::copy(rotated_systems, src, src + 1, dst);
79
+ }
80
+
81
+ _CCCL_DEVICE inline static void device_path(cross_system<System1, System2>&, Pointer1 dst, Pointer2 src)
82
+ {
83
+ // XXX forward the true cuda::execution_policy inside systems here
84
+ // instead of materializing a tag
85
+ thrust::cuda::tag cuda_tag;
86
+ thrust::cuda_cub::assign_value(cuda_tag, dst, src);
87
+ }
88
+ };
89
+
90
+ NV_IF_TARGET(NV_IS_HOST,
91
+ (war_nvbugs_881631::host_path(systems, dst, src);),
92
+ (war_nvbugs_881631::device_path(systems, dst, src);));
93
+ } // end assign_value()
94
+
95
+ } // namespace cuda_cub
96
+ THRUST_NAMESPACE_END
97
+ #endif
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/binary_search.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2021 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ // this system has no special version of this algorithm
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/cdp_dispatch.h ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2021-2022 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
19
+ * Utilities for CUDA dynamic parallelism.
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
+
34
+ #include <cub/config.cuh>
35
+
36
+ #include <cub/detail/detect_cuda_runtime.cuh>
37
+
38
+ #include <nv/target>
39
+
40
+ /**
41
+ * \def THRUST_CDP_DISPATCH
42
+ *
43
+ * If CUDA Dynamic Parallelism / CUDA Nested Parallelism is available, always
44
+ * run the parallel implementation. Otherwise, run the parallel implementation
45
+ * when called from the host, and fallback to the sequential implementation on
46
+ * the device.
47
+ *
48
+ * `par_impl` and `seq_impl` are blocks of C++ statements enclosed in
49
+ * parentheses, similar to NV_IF_TARGET blocks:
50
+ *
51
+ * \code
52
+ * THRUST_CDP_DISPATCH((launch_parallel_kernel();), (run_serial_impl();));
53
+ * \endcode
54
+ */
55
+
56
+ #if defined(CUB_DETAIL_CDPv1)
57
+
58
+ // Special case for NVCC -- need to inform the device path about the kernels
59
+ // that are launched from the host path.
60
+ # if defined(__CUDACC__) && defined(__CUDA_ARCH__)
61
+
62
+ // seq_impl only used on platforms that do not support device synchronization.
63
+ # define THRUST_CDP_DISPATCH(par_impl, seq_impl) \
64
+ if (false) \
65
+ { /* Without this, the device pass won't compile any kernels. */ \
66
+ NV_IF_TARGET(NV_ANY_TARGET, par_impl); \
67
+ } \
68
+ NV_IF_TARGET(NV_PROVIDES_SM_90, seq_impl, par_impl)
69
+
70
+ # else // NVCC device pass
71
+
72
+ // seq_impl only used on platforms that do not support device synchronization.
73
+ # define THRUST_CDP_DISPATCH(par_impl, seq_impl) NV_IF_TARGET(NV_PROVIDES_SM_90, seq_impl, par_impl)
74
+
75
+ # endif // NVCC device pass
76
+
77
+ #else // CDPv1 unavailable. Always fallback to serial on device:
78
+
79
+ // Special case for NVCC -- need to inform the device path about the kernels
80
+ // that are launched from the host path.
81
+ # if defined(__CUDACC__) && defined(__CUDA_ARCH__)
82
+
83
+ // Device-side launch not supported, fallback to sequential in device code.
84
+ # define THRUST_CDP_DISPATCH(par_impl, seq_impl) \
85
+ if (false) \
86
+ { /* Without this, the device pass won't compile any kernels. */ \
87
+ NV_IF_TARGET(NV_ANY_TARGET, par_impl); \
88
+ } \
89
+ NV_IF_TARGET(NV_IS_HOST, par_impl, seq_impl)
90
+
91
+ # else // !(NVCC device pass):
92
+
93
+ # define THRUST_CDP_DISPATCH(par_impl, seq_impl) NV_IF_TARGET(NV_IS_HOST, par_impl, seq_impl)
94
+
95
+ # endif // NVCC device pass
96
+
97
+ #endif // CDP version
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/copy.h ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******************************************************************************
2
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ * * Redistributions of source code must retain the above copyright
7
+ * notice, this list of conditions and the following disclaimer.
8
+ * * Redistributions in binary form must reproduce the above copyright
9
+ * notice, this list of conditions and the following disclaimer in the
10
+ * documentation and/or other materials provided with the distribution.
11
+ * * Neither the name of the NVIDIA CORPORATION nor the
12
+ * names of its contributors may be used to endorse or promote products
13
+ * derived from this software without specific prior written permission.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
19
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ *
26
+ ******************************************************************************/
27
+ #pragma once
28
+
29
+ #include <thrust/detail/config.h>
30
+
31
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
32
+ # pragma GCC system_header
33
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
34
+ # pragma clang system_header
35
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
36
+ # pragma system_header
37
+ #endif // no system header
38
+
39
+ #include <thrust/system/cuda/config.h>
40
+
41
+ #include <thrust/advance.h>
42
+ #include <thrust/system/cuda/detail/cdp_dispatch.h>
43
+ #include <thrust/system/cuda/detail/cross_system.h>
44
+ #include <thrust/system/cuda/detail/execution_policy.h>
45
+
46
+ THRUST_NAMESPACE_BEGIN
47
+
48
+ template <typename DerivedPolicy, typename InputIt, typename OutputIt>
49
+ _CCCL_HOST_DEVICE OutputIt
50
+ copy(const thrust::detail::execution_policy_base<DerivedPolicy>& exec, InputIt first, InputIt last, OutputIt result);
51
+
52
+ template <class DerivedPolicy, class InputIt, class Size, class OutputIt>
53
+ _CCCL_HOST_DEVICE OutputIt
54
+ copy_n(const thrust::detail::execution_policy_base<DerivedPolicy>& exec, InputIt first, Size n, OutputIt result);
55
+
56
+ namespace cuda_cub
57
+ {
58
+
59
+ // D->D copy requires NVCC compiler
60
+ template <class System, class InputIterator, class OutputIterator>
61
+ OutputIterator _CCCL_HOST_DEVICE
62
+ copy(execution_policy<System>& system, InputIterator first, InputIterator last, OutputIterator result);
63
+
64
+ template <class System1, class System2, class InputIterator, class OutputIterator>
65
+ OutputIterator _CCCL_HOST
66
+ copy(cross_system<System1, System2> systems, InputIterator first, InputIterator last, OutputIterator result);
67
+
68
+ template <class System, class InputIterator, class Size, class OutputIterator>
69
+ OutputIterator _CCCL_HOST_DEVICE
70
+ copy_n(execution_policy<System>& system, InputIterator first, Size n, OutputIterator result);
71
+
72
+ template <class System1, class System2, class InputIterator, class Size, class OutputIterator>
73
+ OutputIterator _CCCL_HOST
74
+ copy_n(cross_system<System1, System2> systems, InputIterator first, Size n, OutputIterator result);
75
+
76
+ } // namespace cuda_cub
77
+ THRUST_NAMESPACE_END
78
+
79
+ #include <thrust/system/cuda/detail/internal/copy_cross_system.h>
80
+ #include <thrust/system/cuda/detail/internal/copy_device_to_device.h>
81
+ #include <thrust/system/cuda/detail/par_to_seq.h>
82
+
83
+ THRUST_NAMESPACE_BEGIN
84
+ namespace cuda_cub
85
+ {
86
+
87
+ #if _CCCL_HAS_CUDA_COMPILER
88
+ // D->D copy requires NVCC compiler
89
+
90
+ _CCCL_EXEC_CHECK_DISABLE
91
+ template <class System, class InputIterator, class OutputIterator>
92
+ OutputIterator _CCCL_HOST_DEVICE
93
+ copy(execution_policy<System>& system, InputIterator first, InputIterator last, OutputIterator result)
94
+ {
95
+ THRUST_CDP_DISPATCH((result = __copy::device_to_device(system, first, last, result);),
96
+ (result = thrust::copy(cvt_to_seq(derived_cast(system)), first, last, result);));
97
+ return result;
98
+ } // end copy()
99
+
100
+ _CCCL_EXEC_CHECK_DISABLE
101
+ template <class System, class InputIterator, class Size, class OutputIterator>
102
+ OutputIterator _CCCL_HOST_DEVICE
103
+ copy_n(execution_policy<System>& system, InputIterator first, Size n, OutputIterator result)
104
+ {
105
+ THRUST_CDP_DISPATCH((result = __copy::device_to_device(system, first, thrust::next(first, n), result);),
106
+ (result = thrust::copy_n(cvt_to_seq(derived_cast(system)), first, n, result);));
107
+ return result;
108
+ } // end copy_n()
109
+ #endif
110
+
111
+ template <class System1, class System2, class InputIterator, class OutputIterator>
112
+ OutputIterator _CCCL_HOST
113
+ copy(cross_system<System1, System2> systems, InputIterator first, InputIterator last, OutputIterator result)
114
+ {
115
+ return __copy::cross_system_copy(systems, first, last, result);
116
+ } // end copy()
117
+
118
+ template <class System1, class System2, class InputIterator, class Size, class OutputIterator>
119
+ OutputIterator _CCCL_HOST
120
+ copy_n(cross_system<System1, System2> systems, InputIterator first, Size n, OutputIterator result)
121
+ {
122
+ return __copy::cross_system_copy_n(systems, first, n, result);
123
+ } // end copy_n()
124
+
125
+ } // namespace cuda_cub
126
+ THRUST_NAMESPACE_END
127
+
128
+ #include <thrust/detail/temporary_array.h>
129
+ #include <thrust/memory.h>
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/copy_if.h ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******************************************************************************
2
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ * * Redistributions of source code must retain the above copyright
7
+ * notice, this list of conditions and the following disclaimer.
8
+ * * Redistributions in binary form must reproduce the above copyright
9
+ * notice, this list of conditions and the following disclaimer in the
10
+ * documentation and/or other materials provided with the distribution.
11
+ * * Neither the name of the NVIDIA CORPORATION nor the
12
+ * names of its contributors may be used to endorse or promote products
13
+ * derived from this software without specific prior written permission.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
19
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ *
26
+ ******************************************************************************/
27
+ #pragma once
28
+
29
+ #include <thrust/detail/config.h>
30
+
31
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
32
+ # pragma GCC system_header
33
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
34
+ # pragma clang system_header
35
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
36
+ # pragma system_header
37
+ #endif // no system header
38
+ #if _CCCL_HAS_CUDA_COMPILER
39
+
40
+ # include <thrust/system/cuda/config.h>
41
+
42
+ # include <cub/device/device_select.cuh>
43
+ # include <cub/util_math.cuh>
44
+ # include <cub/util_temporary_storage.cuh>
45
+ # include <cub/util_type.cuh>
46
+
47
+ # include <thrust/advance.h>
48
+ # include <thrust/detail/alignment.h>
49
+ # include <thrust/detail/function.h>
50
+ # include <thrust/detail/temporary_array.h>
51
+ # include <thrust/distance.h>
52
+ # include <thrust/system/cuda/detail/cdp_dispatch.h>
53
+ # include <thrust/system/cuda/detail/core/util.h>
54
+ # include <thrust/system/cuda/detail/dispatch.h>
55
+ # include <thrust/system/cuda/detail/par_to_seq.h>
56
+ # include <thrust/system/cuda/detail/util.h>
57
+
58
+ # include <cstdint>
59
+
60
+ THRUST_NAMESPACE_BEGIN
61
+ // XXX declare generic copy_if interface
62
+ // to avoid circulular dependency from thrust/copy.h
63
+ template <typename DerivedPolicy, typename InputIterator, typename OutputIterator, typename Predicate>
64
+ _CCCL_HOST_DEVICE OutputIterator copy_if(
65
+ const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
66
+ InputIterator first,
67
+ InputIterator last,
68
+ OutputIterator result,
69
+ Predicate pred);
70
+
71
+ template <typename DerivedPolicy,
72
+ typename InputIterator1,
73
+ typename InputIterator2,
74
+ typename OutputIterator,
75
+ typename Predicate>
76
+ _CCCL_HOST_DEVICE OutputIterator copy_if(
77
+ const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
78
+ InputIterator1 first,
79
+ InputIterator1 last,
80
+ InputIterator2 stencil,
81
+ OutputIterator result,
82
+ Predicate pred);
83
+
84
+ namespace cuda_cub
85
+ {
86
+
87
+ namespace detail
88
+ {
89
+
90
+ /**
91
+ * Enum class to indicate whether the memory of input and output iterators potentially alias one another.
92
+ */
93
+ enum class InputMayAliasOutput
94
+ {
95
+ no,
96
+ yes
97
+ };
98
+
99
+ template <InputMayAliasOutput MayAlias,
100
+ typename Derived,
101
+ typename InputIt,
102
+ typename StencilIt,
103
+ typename OutputIt,
104
+ typename Predicate,
105
+ typename OffsetT>
106
+ struct DispatchCopyIf
107
+ {
108
+ static cudaError_t THRUST_RUNTIME_FUNCTION dispatch(
109
+ execution_policy<Derived>& policy,
110
+ void* d_temp_storage,
111
+ size_t& temp_storage_bytes,
112
+ InputIt first,
113
+ StencilIt stencil,
114
+ OutputIt& output,
115
+ Predicate predicate,
116
+ OffsetT num_items)
117
+ {
118
+ using num_selected_out_it_t = OffsetT*;
119
+ using equality_op_t = cub::NullType;
120
+
121
+ cudaError_t status = cudaSuccess;
122
+ cudaStream_t stream = cuda_cub::stream(policy);
123
+
124
+ std::size_t allocation_sizes[2] = {0, sizeof(OffsetT)};
125
+ void* allocations[2] = {nullptr, nullptr};
126
+
127
+ // drop rejected items (i.e., this is not a partition, but a selection)
128
+ constexpr bool keep_rejects = false;
129
+ constexpr bool may_alias = (MayAlias == InputMayAliasOutput::yes);
130
+
131
+ // Query algorithm memory requirements
132
+ status = cub::DispatchSelectIf<
133
+ InputIt,
134
+ StencilIt,
135
+ OutputIt,
136
+ num_selected_out_it_t,
137
+ Predicate,
138
+ equality_op_t,
139
+ OffsetT,
140
+ keep_rejects,
141
+ may_alias>::Dispatch(nullptr,
142
+ allocation_sizes[0],
143
+ first,
144
+ stencil,
145
+ output,
146
+ static_cast<num_selected_out_it_t>(nullptr),
147
+ predicate,
148
+ equality_op_t{},
149
+ num_items,
150
+ stream);
151
+ CUDA_CUB_RET_IF_FAIL(status);
152
+
153
+ status = cub::AliasTemporaries(d_temp_storage, temp_storage_bytes, allocations, allocation_sizes);
154
+ CUDA_CUB_RET_IF_FAIL(status);
155
+
156
+ // Return if we're only querying temporary storage requirements
157
+ if (d_temp_storage == nullptr)
158
+ {
159
+ return status;
160
+ }
161
+
162
+ // Return for empty problems
163
+ if (num_items == 0)
164
+ {
165
+ return status;
166
+ }
167
+
168
+ // Memory allocation for the number of selected output items
169
+ OffsetT* d_num_selected_out = thrust::detail::aligned_reinterpret_cast<OffsetT*>(allocations[1]);
170
+
171
+ // Run algorithm
172
+ status = cub::DispatchSelectIf<
173
+ InputIt,
174
+ StencilIt,
175
+ OutputIt,
176
+ num_selected_out_it_t,
177
+ Predicate,
178
+ equality_op_t,
179
+ OffsetT,
180
+ keep_rejects,
181
+ may_alias>::Dispatch(allocations[0],
182
+ allocation_sizes[0],
183
+ first,
184
+ stencil,
185
+ output,
186
+ d_num_selected_out,
187
+ predicate,
188
+ equality_op_t{},
189
+ num_items,
190
+ stream);
191
+ CUDA_CUB_RET_IF_FAIL(status);
192
+
193
+ // Get number of selected items
194
+ status = cuda_cub::synchronize(policy);
195
+ CUDA_CUB_RET_IF_FAIL(status);
196
+ OffsetT num_selected = get_value(policy, d_num_selected_out);
197
+ thrust::advance(output, num_selected);
198
+ return status;
199
+ }
200
+ };
201
+
202
+ template <InputMayAliasOutput MayAlias,
203
+ typename Derived,
204
+ typename InputIt,
205
+ typename StencilIt,
206
+ typename OutputIt,
207
+ typename Predicate>
208
+ THRUST_RUNTIME_FUNCTION OutputIt copy_if(
209
+ execution_policy<Derived>& policy,
210
+ InputIt first,
211
+ InputIt last,
212
+ StencilIt stencil,
213
+ OutputIt output,
214
+ Predicate predicate)
215
+ {
216
+ using size_type = typename iterator_traits<InputIt>::difference_type;
217
+
218
+ size_type num_items = static_cast<size_type>(thrust::distance(first, last));
219
+ cudaError_t status = cudaSuccess;
220
+ size_t temp_storage_bytes = 0;
221
+
222
+ // 64-bit offset-type dispatch
223
+ // Since https://github.com/NVIDIA/cccl/pull/2400, cub::DeviceSelect is using a streaming approach that splits up
224
+ // inputs larger than INT_MAX into partitions of up to `INT_MAX` items each, repeatedly invoking the respective
225
+ // algorithm. With that approach, we can always use i64 offset types for DispatchSelectIf, because there's only very
226
+ // limited performance upside for using i32 offset types. This avoids potentially duplicate kernel compilation.
227
+ using dispatch64_t = DispatchCopyIf<MayAlias, Derived, InputIt, StencilIt, OutputIt, Predicate, std::int64_t>;
228
+
229
+ // Query temporary storage requirements
230
+ status = dispatch64_t::dispatch(
231
+ policy, nullptr, temp_storage_bytes, first, stencil, output, predicate, static_cast<std::int64_t>(num_items));
232
+ cuda_cub::throw_on_error(status, "copy_if failed on 1st step");
233
+
234
+ // Allocate temporary storage.
235
+ thrust::detail::temporary_array<std::uint8_t, Derived> tmp(policy, temp_storage_bytes);
236
+ void* temp_storage = static_cast<void*>(tmp.data().get());
237
+
238
+ // Run algorithm
239
+ status = dispatch64_t::dispatch(
240
+ policy, temp_storage, temp_storage_bytes, first, stencil, output, predicate, static_cast<std::int64_t>(num_items));
241
+ cuda_cub::throw_on_error(status, "copy_if failed on 2nd step");
242
+
243
+ return output;
244
+ }
245
+
246
+ } // namespace detail
247
+
248
+ //-------------------------
249
+ // Thrust API entry points
250
+ //-------------------------
251
+ _CCCL_EXEC_CHECK_DISABLE
252
+ template <class Derived, class InputIterator, class OutputIterator, class Predicate>
253
+ OutputIterator _CCCL_HOST_DEVICE copy_if(
254
+ execution_policy<Derived>& policy, InputIterator first, InputIterator last, OutputIterator result, Predicate pred)
255
+ {
256
+ THRUST_CDP_DISPATCH((return detail::copy_if<detail::InputMayAliasOutput::no>(
257
+ policy, first, last, static_cast<cub::NullType*>(nullptr), result, pred);),
258
+ (return thrust::copy_if(cvt_to_seq(derived_cast(policy)), first, last, result, pred);));
259
+ }
260
+
261
+ _CCCL_EXEC_CHECK_DISABLE
262
+ template <class Derived, class InputIterator, class StencilIterator, class OutputIterator, class Predicate>
263
+ OutputIterator _CCCL_HOST_DEVICE copy_if(
264
+ execution_policy<Derived>& policy,
265
+ InputIterator first,
266
+ InputIterator last,
267
+ StencilIterator stencil,
268
+ OutputIterator result,
269
+ Predicate pred)
270
+ {
271
+ THRUST_CDP_DISPATCH(
272
+ (return detail::copy_if<detail::InputMayAliasOutput::no>(policy, first, last, stencil, result, pred);),
273
+ (return thrust::copy_if(cvt_to_seq(derived_cast(policy)), first, last, stencil, result, pred);));
274
+ }
275
+
276
+ } // namespace cuda_cub
277
+ THRUST_NAMESPACE_END
278
+
279
+ # include <thrust/copy.h>
280
+ #endif
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/count.h ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******************************************************************************
2
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ * * Redistributions of source code must retain the above copyright
7
+ * notice, this list of conditions and the following disclaimer.
8
+ * * Redistributions in binary form must reproduce the above copyright
9
+ * notice, this list of conditions and the following disclaimer in the
10
+ * documentation and/or other materials provided with the distribution.
11
+ * * Neither the name of the NVIDIA CORPORATION nor the
12
+ * names of its contributors may be used to endorse or promote products
13
+ * derived from this software without specific prior written permission.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
19
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ *
26
+ ******************************************************************************/
27
+ #pragma once
28
+
29
+ #include <thrust/detail/config.h>
30
+
31
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
32
+ # pragma GCC system_header
33
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
34
+ # pragma clang system_header
35
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
36
+ # pragma system_header
37
+ #endif // no system header
38
+
39
+ #if _CCCL_HAS_CUDA_COMPILER
40
+ # include <thrust/system/cuda/config.h>
41
+
42
+ # include <thrust/distance.h>
43
+ # include <thrust/iterator/transform_iterator.h>
44
+ # include <thrust/system/cuda/detail/reduce.h>
45
+ # include <thrust/system/cuda/detail/util.h>
46
+
47
+ THRUST_NAMESPACE_BEGIN
48
+ namespace cuda_cub
49
+ {
50
+
51
+ template <class Derived, class InputIt, class UnaryPred>
52
+ typename iterator_traits<InputIt>::difference_type _CCCL_HOST_DEVICE
53
+ count_if(execution_policy<Derived>& policy, InputIt first, InputIt last, UnaryPred unary_pred)
54
+ {
55
+ using size_type = typename iterator_traits<InputIt>::difference_type;
56
+ using flag_iterator_t = transform_iterator<UnaryPred, InputIt, size_type, size_type>;
57
+
58
+ return cuda_cub::reduce_n(
59
+ policy, flag_iterator_t(first, unary_pred), thrust::distance(first, last), size_type(0), plus<size_type>());
60
+ }
61
+
62
+ template <class Derived, class InputIt, class Value>
63
+ typename iterator_traits<InputIt>::difference_type _CCCL_HOST_DEVICE
64
+ count(execution_policy<Derived>& policy, InputIt first, InputIt last, Value const& value)
65
+ {
66
+ return cuda_cub::count_if(policy, first, last, thrust::detail::equal_to_value<Value>(value));
67
+ }
68
+
69
+ } // namespace cuda_cub
70
+ THRUST_NAMESPACE_END
71
+ #endif
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/fill.h ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******************************************************************************
2
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ * * Redistributions of source code must retain the above copyright
7
+ * notice, this list of conditions and the following disclaimer.
8
+ * * Redistributions in binary form must reproduce the above copyright
9
+ * notice, this list of conditions and the following disclaimer in the
10
+ * documentation and/or other materials provided with the distribution.
11
+ * * Neither the name of the NVIDIA CORPORATION nor the
12
+ * names of its contributors may be used to endorse or promote products
13
+ * derived from this software without specific prior written permission.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
19
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ *
26
+ ******************************************************************************/
27
+ #pragma once
28
+
29
+ #include <thrust/detail/config.h>
30
+
31
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
32
+ # pragma GCC system_header
33
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
34
+ # pragma clang system_header
35
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
36
+ # pragma system_header
37
+ #endif // no system header
38
+
39
+ #if _CCCL_HAS_CUDA_COMPILER
40
+ # include <thrust/distance.h>
41
+ # include <thrust/system/cuda/detail/parallel_for.h>
42
+ # include <thrust/system/cuda/detail/util.h>
43
+
44
+ THRUST_NAMESPACE_BEGIN
45
+ namespace cuda_cub
46
+ {
47
+
48
+ namespace __fill
49
+ {
50
+
51
+ // fill functor
52
+ template <class Iterator, class T>
53
+ struct functor
54
+ {
55
+ Iterator it;
56
+ T value;
57
+
58
+ THRUST_FUNCTION
59
+ functor(Iterator it, T value)
60
+ : it(it)
61
+ , value(value)
62
+ {}
63
+
64
+ template <class Size>
65
+ THRUST_DEVICE_FUNCTION void operator()(Size idx)
66
+ {
67
+ it[idx] = value;
68
+ }
69
+ }; // struct functor
70
+
71
+ } // namespace __fill
72
+
73
+ template <class Derived, class OutputIterator, class Size, class T>
74
+ OutputIterator _CCCL_HOST_DEVICE
75
+ fill_n(execution_policy<Derived>& policy, OutputIterator first, Size count, const T& value)
76
+ {
77
+ cuda_cub::parallel_for(policy, __fill::functor<OutputIterator, T>(first, value), count);
78
+
79
+ return first + count;
80
+ } // func fill_n
81
+
82
+ template <class Derived, class ForwardIterator, class T>
83
+ void _CCCL_HOST_DEVICE
84
+ fill(execution_policy<Derived>& policy, ForwardIterator first, ForwardIterator last, const T& value)
85
+ {
86
+ cuda_cub::fill_n(policy, first, thrust::distance(first, last), value);
87
+ } // func fill
88
+
89
+ } // namespace cuda_cub
90
+ THRUST_NAMESPACE_END
91
+ #endif
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/find.h ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******************************************************************************
2
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ * * Redistributions of source code must retain the above copyright
7
+ * notice, this list of conditions and the following disclaimer.
8
+ * * Redistributions in binary form must reproduce the above copyright
9
+ * notice, this list of conditions and the following disclaimer in the
10
+ * documentation and/or other materials provided with the distribution.
11
+ * * Neither the name of the NVIDIA CORPORATION nor the
12
+ * names of its contributors may be used to endorse or promote products
13
+ * derived from this software without specific prior written permission.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
19
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ *
26
+ ******************************************************************************/
27
+ #pragma once
28
+
29
+ #include <thrust/detail/config.h>
30
+
31
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
32
+ # pragma GCC system_header
33
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
34
+ # pragma clang system_header
35
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
36
+ # pragma system_header
37
+ #endif // no system header
38
+
39
+ #if _CCCL_HAS_CUDA_COMPILER
40
+ # include <thrust/system/cuda/config.h>
41
+
42
+ # include <thrust/detail/minmax.h>
43
+ # include <thrust/distance.h>
44
+ # include <thrust/iterator/counting_iterator.h>
45
+ # include <thrust/iterator/transform_iterator.h>
46
+ # include <thrust/system/cuda/detail/execution_policy.h>
47
+
48
+ THRUST_NAMESPACE_BEGIN
49
+ namespace cuda_cub
50
+ {
51
+
52
+ // XXX forward declare to circumvent circular dependency
53
+ template <class Derived, class InputIt, class Predicate>
54
+ InputIt _CCCL_HOST_DEVICE find_if(execution_policy<Derived>& policy, InputIt first, InputIt last, Predicate predicate);
55
+
56
+ template <class Derived, class InputIt, class Predicate>
57
+ InputIt _CCCL_HOST_DEVICE
58
+ find_if_not(execution_policy<Derived>& policy, InputIt first, InputIt last, Predicate predicate);
59
+
60
+ template <class Derived, class InputIt, class T>
61
+ InputIt _CCCL_HOST_DEVICE find(execution_policy<Derived>& policy, InputIt first, InputIt last, T const& value);
62
+
63
+ }; // namespace cuda_cub
64
+ THRUST_NAMESPACE_END
65
+
66
+ # include <thrust/iterator/zip_iterator.h>
67
+ # include <thrust/system/cuda/detail/reduce.h>
68
+
69
+ THRUST_NAMESPACE_BEGIN
70
+ namespace cuda_cub
71
+ {
72
+
73
+ namespace __find_if
74
+ {
75
+
76
+ template <typename TupleType>
77
+ struct functor
78
+ {
79
+ THRUST_DEVICE_FUNCTION TupleType operator()(const TupleType& lhs, const TupleType& rhs) const
80
+ {
81
+ // select the smallest index among true results
82
+ if (thrust::get<0>(lhs) && thrust::get<0>(rhs))
83
+ {
84
+ return TupleType(true, (thrust::min)(thrust::get<1>(lhs), thrust::get<1>(rhs)));
85
+ }
86
+ else if (thrust::get<0>(lhs))
87
+ {
88
+ return lhs;
89
+ }
90
+ else
91
+ {
92
+ return rhs;
93
+ }
94
+ }
95
+ };
96
+ } // namespace __find_if
97
+
98
+ template <class Derived, class InputIt, class Size, class Predicate>
99
+ InputIt _CCCL_HOST_DEVICE
100
+ find_if_n(execution_policy<Derived>& policy, InputIt first, Size num_items, Predicate predicate)
101
+ {
102
+ using result_type = typename thrust::tuple<bool, Size>;
103
+
104
+ // empty sequence
105
+ if (num_items == 0)
106
+ {
107
+ return first;
108
+ }
109
+
110
+ // this implementation breaks up the sequence into separate intervals
111
+ // in an attempt to early-out as soon as a value is found
112
+ //
113
+ // XXX compose find_if from a look-back prefix scan algorithm
114
+ // and abort kernel when the first element is found
115
+
116
+ // TODO incorporate sizeof(InputType) into interval_threshold and round to multiple of 32
117
+ const Size interval_threshold = 1 << 20;
118
+ const Size interval_size = (thrust::min)(interval_threshold, num_items);
119
+
120
+ // force transform_iterator output to bool
121
+ using XfrmIterator = transform_iterator<Predicate, InputIt, bool, bool>;
122
+ using IteratorTuple = thrust::tuple<XfrmIterator, counting_iterator<Size>>;
123
+ using ZipIterator = thrust::zip_iterator<IteratorTuple>;
124
+
125
+ IteratorTuple iter_tuple = thrust::make_tuple(XfrmIterator(first, predicate), counting_iterator<Size>(0));
126
+
127
+ ZipIterator begin = thrust::make_zip_iterator(iter_tuple);
128
+ ZipIterator end = begin + num_items;
129
+
130
+ for (ZipIterator interval_begin = begin; interval_begin < end; interval_begin += interval_size)
131
+ {
132
+ ZipIterator interval_end = interval_begin + interval_size;
133
+ if (end < interval_end)
134
+ {
135
+ interval_end = end;
136
+ } // end if
137
+
138
+ result_type result = reduce(
139
+ policy, interval_begin, interval_end, result_type(false, interval_end - begin), __find_if::functor<result_type>());
140
+
141
+ // see if we found something
142
+ if (thrust::get<0>(result))
143
+ {
144
+ return first + thrust::get<1>(result);
145
+ }
146
+ }
147
+
148
+ // nothing was found if we reach here...
149
+ return first + num_items;
150
+ }
151
+
152
+ template <class Derived, class InputIt, class Predicate>
153
+ InputIt _CCCL_HOST_DEVICE find_if(execution_policy<Derived>& policy, InputIt first, InputIt last, Predicate predicate)
154
+ {
155
+ return cuda_cub::find_if_n(policy, first, thrust::distance(first, last), predicate);
156
+ }
157
+
158
+ template <class Derived, class InputIt, class Predicate>
159
+ InputIt _CCCL_HOST_DEVICE
160
+ find_if_not(execution_policy<Derived>& policy, InputIt first, InputIt last, Predicate predicate)
161
+ {
162
+ return cuda_cub::find_if(policy, first, last, thrust::not_fn(predicate));
163
+ }
164
+
165
+ template <class Derived, class InputIt, class T>
166
+ InputIt _CCCL_HOST_DEVICE find(execution_policy<Derived>& policy, InputIt first, InputIt last, T const& value)
167
+ {
168
+ using thrust::placeholders::_1;
169
+
170
+ return cuda_cub::find_if(policy, first, last, _1 == value);
171
+ }
172
+
173
+ } // namespace cuda_cub
174
+ THRUST_NAMESPACE_END
175
+ #endif
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/for_each.h ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******************************************************************************
2
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ * * Redistributions of source code must retain the above copyright
7
+ * notice, this list of conditions and the following disclaimer.
8
+ * * Redistributions in binary form must reproduce the above copyright
9
+ * notice, this list of conditions and the following disclaimer in the
10
+ * documentation and/or other materials provided with the distribution.
11
+ * * Neither the name of the NVIDIA CORPORATION nor the
12
+ * names of its contributors may be used to endorse or promote products
13
+ * derived from this software without specific prior written permission.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
19
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ *
26
+ ******************************************************************************/
27
+ #pragma once
28
+
29
+ #include <thrust/detail/config.h>
30
+
31
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
32
+ # pragma GCC system_header
33
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
34
+ # pragma clang system_header
35
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
36
+ # pragma system_header
37
+ #endif // no system header
38
+
39
+ #if _CCCL_HAS_CUDA_COMPILER
40
+ # include <thrust/system/cuda/config.h>
41
+
42
+ # include <cub/device/device_for.cuh>
43
+
44
+ # include <thrust/detail/function.h>
45
+ # include <thrust/distance.h>
46
+ # include <thrust/system/cuda/detail/cdp_dispatch.h>
47
+ # include <thrust/system/cuda/detail/parallel_for.h>
48
+ # include <thrust/system/cuda/detail/util.h>
49
+
50
+ THRUST_NAMESPACE_BEGIN
51
+
52
+ namespace cuda_cub
53
+ {
54
+
55
+ // for_each_n
56
+ _CCCL_EXEC_CHECK_DISABLE
57
+ template <class Derived, class Input, class Size, class UnaryOp>
58
+ Input THRUST_FUNCTION for_each_n(execution_policy<Derived>& policy, Input first, Size count, UnaryOp op)
59
+ {
60
+ THRUST_CDP_DISPATCH(
61
+ (cudaStream_t stream = cuda_cub::stream(policy);
62
+ cudaError_t status = cub::DeviceFor::ForEachN(first, count, op, stream);
63
+ cuda_cub::throw_on_error(status, "parallel_for failed");
64
+ status = cuda_cub::synchronize_optional(policy);
65
+ cuda_cub::throw_on_error(status, "parallel_for: failed to synchronize");),
66
+ (for (Size idx = 0; idx != count; ++idx) { op(raw_reference_cast(*(first + idx))); }));
67
+
68
+ return first + count;
69
+ }
70
+
71
+ // for_each
72
+ template <class Derived, class Input, class UnaryOp>
73
+ Input THRUST_FUNCTION for_each(execution_policy<Derived>& policy, Input first, Input last, UnaryOp op)
74
+ {
75
+ using size_type = typename iterator_traits<Input>::difference_type;
76
+ size_type count = static_cast<size_type>(thrust::distance(first, last));
77
+
78
+ return THRUST_NS_QUALIFIER::cuda_cub::for_each_n(policy, first, count, op);
79
+ }
80
+ } // namespace cuda_cub
81
+
82
+ THRUST_NAMESPACE_END
83
+ #endif
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/future.inl ADDED
@@ -0,0 +1,1235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright (c) 2018 NVIDIA Corporation
2
+ // Author: Bryce Adelstein Lelbach <brycelelbach@gmail.com>
3
+ //
4
+ // Distributed under the Boost Software License v1.0 (boost.org/LICENSE_1_0.txt)
5
+
6
+ // TODO: Split into more granular headers (move unique_stream/unique_marker to
7
+ // another header, etc).
8
+
9
+ #pragma once
10
+
11
+ #include <thrust/detail/config.h>
12
+
13
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
14
+ # pragma GCC system_header
15
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
16
+ # pragma clang system_header
17
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
18
+ # pragma system_header
19
+ #endif // no system header
20
+ #include <thrust/detail/cpp14_required.h>
21
+
22
+ #if _CCCL_STD_VER >= 2014
23
+
24
+ # include <thrust/allocate_unique.h>
25
+ # include <thrust/detail/event_error.h>
26
+ # include <thrust/detail/execute_with_dependencies.h>
27
+ # include <thrust/detail/memory_wrapper.h>
28
+ # include <thrust/detail/static_assert.h>
29
+ # include <thrust/detail/tuple_algorithms.h>
30
+ # include <thrust/detail/type_deduction.h>
31
+ # include <thrust/detail/type_traits/pointer_traits.h>
32
+ # include <thrust/optional.h>
33
+ # include <thrust/system/cuda/detail/get_value.h>
34
+ # include <thrust/system/cuda/detail/util.h>
35
+ # include <thrust/system/cuda/future.h>
36
+ # include <thrust/system/cuda/memory.h>
37
+ # include <thrust/type_traits/integer_sequence.h>
38
+
39
+ # include <cuda/std/__memory/unique_ptr.h>
40
+ # include <cuda/std/type_traits>
41
+
42
+ # include <type_traits>
43
+
44
+ _CCCL_SUPPRESS_DEPRECATED_PUSH
45
+ THRUST_NAMESPACE_BEGIN
46
+
47
+ // Forward declaration.
48
+ struct CCCL_DEPRECATED new_stream_t;
49
+
50
+ namespace system
51
+ {
52
+ namespace cuda
53
+ {
54
+ namespace detail
55
+ {
56
+
57
+ ///////////////////////////////////////////////////////////////////////////////
58
+
59
+ struct nonowning_t final
60
+ {};
61
+
62
+ _CCCL_GLOBAL_CONSTANT nonowning_t nonowning{};
63
+
64
+ ///////////////////////////////////////////////////////////////////////////////
65
+
66
+ struct marker_deleter final
67
+ {
68
+ _CCCL_HOST void operator()(CUevent_st* e) const
69
+ {
70
+ if (nullptr != e)
71
+ {
72
+ thrust::cuda_cub::throw_on_error(cudaEventDestroy(e));
73
+ }
74
+ }
75
+ };
76
+
77
+ ///////////////////////////////////////////////////////////////////////////////
78
+
79
+ struct unique_marker final
80
+ {
81
+ using native_handle_type = CUevent_st*;
82
+
83
+ private:
84
+ std::unique_ptr<CUevent_st, marker_deleter> handle_;
85
+
86
+ public:
87
+ /// \brief Create a new stream and construct a handle to it. When the handle
88
+ /// is destroyed, the stream is destroyed.
89
+ _CCCL_HOST unique_marker()
90
+ : handle_(nullptr, marker_deleter())
91
+ {
92
+ native_handle_type e;
93
+ thrust::cuda_cub::throw_on_error(cudaEventCreateWithFlags(&e, cudaEventDisableTiming));
94
+ handle_.reset(e);
95
+ }
96
+
97
+ _CCCL_EXEC_CHECK_DISABLE
98
+ unique_marker(unique_marker const&) = delete;
99
+ _CCCL_EXEC_CHECK_DISABLE
100
+ unique_marker(unique_marker&&) = default;
101
+ _CCCL_EXEC_CHECK_DISABLE
102
+ unique_marker& operator=(unique_marker const&) = delete;
103
+ _CCCL_EXEC_CHECK_DISABLE
104
+ unique_marker& operator=(unique_marker&&) = default;
105
+
106
+ _CCCL_EXEC_CHECK_DISABLE
107
+ ~unique_marker() = default;
108
+
109
+ _CCCL_HOST auto get() const THRUST_DECLTYPE_RETURNS(native_handle_type(handle_.get()));
110
+ _CCCL_HOST auto native_handle() const THRUST_DECLTYPE_RETURNS(native_handle_type(handle_.get()));
111
+
112
+ _CCCL_HOST bool valid() const noexcept
113
+ {
114
+ return bool(handle_);
115
+ }
116
+
117
+ _CCCL_HOST bool ready() const
118
+ {
119
+ cudaError_t const err = cudaEventQuery(handle_.get());
120
+
121
+ if (cudaErrorNotReady == err)
122
+ {
123
+ return false;
124
+ }
125
+
126
+ // Throw on any other error.
127
+ thrust::cuda_cub::throw_on_error(err);
128
+
129
+ return true;
130
+ }
131
+
132
+ _CCCL_HOST void wait() const
133
+ {
134
+ thrust::cuda_cub::throw_on_error(cudaEventSynchronize(handle_.get()));
135
+ }
136
+
137
+ _CCCL_HOST bool operator==(unique_marker const& other) const
138
+ {
139
+ return other.handle_ == handle_;
140
+ }
141
+
142
+ _CCCL_HOST bool operator!=(unique_marker const& other) const
143
+ {
144
+ return !(other == *this);
145
+ }
146
+ };
147
+
148
+ ///////////////////////////////////////////////////////////////////////////////
149
+
150
+ struct stream_deleter final
151
+ {
152
+ _CCCL_HOST void operator()(CUstream_st* s) const
153
+ {
154
+ if (nullptr != s)
155
+ {
156
+ thrust::cuda_cub::throw_on_error(cudaStreamDestroy(s));
157
+ }
158
+ }
159
+ };
160
+
161
+ struct stream_conditional_deleter final
162
+ {
163
+ private:
164
+ bool cond_;
165
+
166
+ public:
167
+ _CCCL_HOST constexpr stream_conditional_deleter() noexcept
168
+ : cond_(true)
169
+ {}
170
+
171
+ _CCCL_HOST explicit constexpr stream_conditional_deleter(nonowning_t) noexcept
172
+ : cond_(false)
173
+ {}
174
+
175
+ _CCCL_HOST void operator()(CUstream_st* s) const
176
+ {
177
+ if (cond_ && nullptr != s)
178
+ {
179
+ thrust::cuda_cub::throw_on_error(cudaStreamDestroy(s));
180
+ }
181
+ }
182
+ };
183
+
184
+ ///////////////////////////////////////////////////////////////////////////////
185
+
186
+ struct unique_stream final
187
+ {
188
+ using native_handle_type = CUstream_st*;
189
+
190
+ private:
191
+ std::unique_ptr<CUstream_st, stream_conditional_deleter> handle_;
192
+
193
+ public:
194
+ /// \brief Create a new stream and construct a handle to it. When the handle
195
+ /// is destroyed, the stream is destroyed.
196
+ _CCCL_HOST unique_stream()
197
+ : handle_(nullptr, stream_conditional_deleter())
198
+ {
199
+ native_handle_type s;
200
+ thrust::cuda_cub::throw_on_error(cudaStreamCreateWithFlags(&s, cudaStreamNonBlocking));
201
+ handle_.reset(s);
202
+ }
203
+
204
+ /// \brief Construct a non-owning handle to an existing stream. When the
205
+ /// handle is destroyed, the stream is not destroyed.
206
+ _CCCL_HOST explicit unique_stream(nonowning_t, native_handle_type handle)
207
+ : handle_(handle, stream_conditional_deleter(nonowning))
208
+ {}
209
+
210
+ _CCCL_EXEC_CHECK_DISABLE
211
+ unique_stream(unique_stream const&) = delete;
212
+
213
+ // GCC 10 complains if this is defaulted. See NVIDIA/thrust#1269.
214
+ _CCCL_EXEC_CHECK_DISABLE
215
+ _CCCL_HOST unique_stream(unique_stream&& o) noexcept
216
+ : handle_(std::move(o.handle_))
217
+ {}
218
+
219
+ _CCCL_EXEC_CHECK_DISABLE
220
+ unique_stream& operator=(unique_stream const&) = delete;
221
+ _CCCL_EXEC_CHECK_DISABLE
222
+ unique_stream& operator=(unique_stream&&) = default;
223
+
224
+ _CCCL_EXEC_CHECK_DISABLE
225
+ ~unique_stream() = default;
226
+
227
+ _CCCL_HOST auto get() const THRUST_DECLTYPE_RETURNS(native_handle_type(handle_.get()));
228
+ _CCCL_HOST auto native_handle() const THRUST_DECLTYPE_RETURNS(native_handle_type(handle_.get()));
229
+
230
+ _CCCL_HOST bool valid() const noexcept
231
+ {
232
+ return bool(handle_);
233
+ }
234
+
235
+ _CCCL_HOST bool ready() const
236
+ {
237
+ cudaError_t const err = cudaStreamQuery(handle_.get());
238
+
239
+ if (cudaErrorNotReady == err)
240
+ {
241
+ return false;
242
+ }
243
+
244
+ // Throw on any other error.
245
+ thrust::cuda_cub::throw_on_error(err);
246
+
247
+ return true;
248
+ }
249
+
250
+ _CCCL_HOST void wait() const
251
+ {
252
+ thrust::cuda_cub::throw_on_error(cudaStreamSynchronize(handle_.get()));
253
+ }
254
+
255
+ _CCCL_HOST void depend_on(unique_marker& e)
256
+ {
257
+ thrust::cuda_cub::throw_on_error(cudaStreamWaitEvent(handle_.get(), e.get(), 0));
258
+ }
259
+
260
+ _CCCL_HOST void depend_on(unique_stream& s)
261
+ {
262
+ if (s != *this)
263
+ {
264
+ unique_marker e;
265
+ s.record(e);
266
+ depend_on(e);
267
+ }
268
+ }
269
+
270
+ _CCCL_HOST void record(unique_marker& e)
271
+ {
272
+ thrust::cuda_cub::throw_on_error(cudaEventRecord(e.get(), handle_.get()));
273
+ }
274
+
275
+ _CCCL_HOST bool operator==(unique_stream const& other) const
276
+ {
277
+ return other.handle_ == handle_;
278
+ }
279
+
280
+ _CCCL_HOST bool operator!=(unique_stream const& other) const
281
+ {
282
+ return !(other == *this);
283
+ }
284
+ };
285
+
286
+ ///////////////////////////////////////////////////////////////////////////////
287
+
288
+ // Inheritance hierarchy of future/event shared state types.
289
+
290
+ struct async_signal;
291
+
292
+ template <typename KeepAlives>
293
+ struct async_keep_alives /* : virtual async_signal */;
294
+
295
+ template <typename T>
296
+ struct async_value /* : virtual async_signal */;
297
+
298
+ template <typename T, typename Pointer, typename KeepAlives>
299
+ struct async_addressable_value_with_keep_alives
300
+ /* : async_value<T>, async_keep_alives<KeepAlives> */;
301
+
302
+ ///////////////////////////////////////////////////////////////////////////////
303
+
304
+ template <typename T, typename Pointer>
305
+ struct weak_promise;
306
+
307
+ template <typename X, typename XPointer = pointer<X>>
308
+ struct unique_eager_future_promise_pair final
309
+ {
310
+ unique_eager_future<X> future;
311
+ weak_promise<X, XPointer> promise;
312
+ };
313
+
314
+ _CCCL_SUPPRESS_DEPRECATED_PUSH // for thrust::optional
315
+
316
+ struct acquired_stream final
317
+ {
318
+ unique_stream stream;
319
+ optional<std::size_t> const acquired_from;
320
+ // `acquired_from` contains the index in the tuple of dependencies from which
321
+ // the stream was acquired. If `acquired_from` is empty, no stream could be
322
+ // acquired from a dependency, and then the stream was newly created.
323
+ };
324
+
325
+ // Precondition: `device` is the current CUDA device.
326
+ template <typename X, typename Y, typename Deleter>
327
+ _CCCL_HOST optional<unique_stream> try_acquire_stream(int device, std::unique_ptr<Y, Deleter>&) noexcept;
328
+
329
+ // Precondition: `device` is the current CUDA device.
330
+ _CCCL_HOST inline optional<unique_stream> try_acquire_stream(int, unique_stream& stream) noexcept;
331
+
332
+ // Precondition: `device` is the current CUDA device.
333
+ _CCCL_HOST inline optional<unique_stream> try_acquire_stream(int device, ready_event&) noexcept;
334
+
335
+ // Precondition: `device` is the current CUDA device.
336
+ template <typename X>
337
+ _CCCL_HOST inline optional<unique_stream> try_acquire_stream(int device, ready_future<X>&) noexcept;
338
+
339
+ // Precondition: `device` is the current CUDA device.
340
+ _CCCL_HOST inline optional<unique_stream> try_acquire_stream(int device, unique_eager_event& parent) noexcept;
341
+
342
+ // Precondition: `device` is the current CUDA device.
343
+ template <typename X>
344
+ _CCCL_HOST optional<unique_stream> try_acquire_stream(int device, unique_eager_future<X>& parent) noexcept;
345
+
346
+ _CCCL_SUPPRESS_DEPRECATED_POP
347
+
348
+ template <typename... Dependencies>
349
+ _CCCL_HOST acquired_stream acquire_stream(int device, Dependencies&... deps) noexcept;
350
+
351
+ template <typename... Dependencies>
352
+ _CCCL_HOST unique_eager_event make_dependent_event(std::tuple<Dependencies...>&& deps);
353
+
354
+ template <typename X, typename XPointer, typename ComputeContent, typename... Dependencies>
355
+ _CCCL_HOST unique_eager_future_promise_pair<X, XPointer>
356
+ make_dependent_future(ComputeContent&& cc, std::tuple<Dependencies...>&& deps);
357
+
358
+ ///////////////////////////////////////////////////////////////////////////////
359
+
360
+ struct async_signal
361
+ {
362
+ protected:
363
+ unique_stream stream_;
364
+
365
+ public:
366
+ // Constructs an `async_signal` which uses `stream`.
367
+ _CCCL_HOST explicit async_signal(unique_stream&& stream)
368
+ : stream_(std::move(stream))
369
+ {}
370
+
371
+ _CCCL_HOST virtual ~async_signal() {}
372
+
373
+ unique_stream& stream() noexcept
374
+ {
375
+ return stream_;
376
+ }
377
+ unique_stream const& stream() const noexcept
378
+ {
379
+ return stream_;
380
+ }
381
+ };
382
+
383
+ template <typename... KeepAlives>
384
+ struct async_keep_alives<std::tuple<KeepAlives...>> : virtual async_signal
385
+ {
386
+ using keep_alives_type = std::tuple<KeepAlives...>;
387
+
388
+ protected:
389
+ keep_alives_type keep_alives_;
390
+
391
+ public:
392
+ // Constructs an `async_keep_alives` which uses `stream`, and keeps the
393
+ // objects in the tuple `keep_alives` alive until the asynchronous signal is
394
+ // destroyed.
395
+ _CCCL_HOST explicit async_keep_alives(unique_stream&& stream, keep_alives_type&& keep_alives)
396
+ : async_signal(std::move(stream))
397
+ , keep_alives_(std::move(keep_alives))
398
+ {}
399
+
400
+ _CCCL_HOST virtual ~async_keep_alives() {}
401
+ };
402
+
403
+ template <typename T>
404
+ struct async_value : virtual async_signal
405
+ {
406
+ using value_type = T;
407
+ using raw_const_pointer = value_type const*;
408
+
409
+ // Constructs an `async_value` which uses `stream` and has no content.
410
+ _CCCL_HOST explicit async_value(unique_stream stream)
411
+ : async_signal(std::move(stream))
412
+ {}
413
+
414
+ _CCCL_HOST virtual ~async_value() {}
415
+
416
+ _CCCL_HOST virtual bool valid_content() const noexcept
417
+ {
418
+ return false;
419
+ }
420
+
421
+ _CCCL_HOST virtual value_type get()
422
+ {
423
+ throw thrust::event_error(event_errc::no_state);
424
+ }
425
+
426
+ _CCCL_HOST virtual value_type extract()
427
+ {
428
+ throw thrust::event_error(event_errc::no_state);
429
+ }
430
+
431
+ // For testing only.
432
+ # if defined(THRUST_ENABLE_FUTURE_RAW_DATA_MEMBER)
433
+ _CCCL_HOST virtual raw_const_pointer raw_data() const
434
+ {
435
+ return nullptr;
436
+ }
437
+ # endif
438
+ };
439
+
440
+ template <typename T, typename Pointer, typename... KeepAlives>
441
+ struct async_addressable_value_with_keep_alives<T, Pointer, std::tuple<KeepAlives...>> final
442
+ : async_value<T>
443
+ , async_keep_alives<std::tuple<KeepAlives...>>
444
+ {
445
+ using value_type = typename async_value<T>::value_type;
446
+ using raw_const_pointer = typename async_value<T>::raw_const_pointer;
447
+
448
+ using keep_alives_type = typename async_keep_alives<std::tuple<KeepAlives...>>::keep_alives_type;
449
+
450
+ using pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<value_type>::other;
451
+ using const_pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<value_type const>::other;
452
+
453
+ private:
454
+ pointer content_;
455
+
456
+ public:
457
+ // Constructs an `async_addressable_value_with_keep_alives` which uses
458
+ // `stream`, keeps the objects in the tuple `keep_alives` alive until the
459
+ // asynchronous value is destroyed, and determines the location of its
460
+ // content by evaluating `compute_content(content_keep_alive)`.
461
+ // NOTE: The use of a callback idiom is necessary if the content is stored in
462
+ // place in the content keep alive object, in which case we need to get its
463
+ // address after its been moved into the new signal we're constructing.
464
+ // NOTE: NVCC has a bug that causes it to reorder our base class initializers
465
+ // in generated host code, which leads to -Wreorder warnings.
466
+ _CCCL_DIAG_PUSH
467
+ _CCCL_DIAG_SUPPRESS_CLANG("-Wreorder")
468
+ _CCCL_DIAG_SUPPRESS_GCC("-Wreorder")
469
+ _CCCL_DIAG_SUPPRESS_ICC(2407)
470
+ template <typename ComputeContent>
471
+ _CCCL_HOST explicit async_addressable_value_with_keep_alives(
472
+ unique_stream&& stream, keep_alives_type&& keep_alives, ComputeContent&& compute_content)
473
+ : async_signal(std::move(stream))
474
+ , async_value<T>(std::move(stream))
475
+ , async_keep_alives<keep_alives_type>(std::move(stream), std::move(keep_alives))
476
+ {
477
+ content_ = THRUST_FWD(compute_content)(std::get<0>(this->keep_alives_));
478
+ }
479
+ _CCCL_DIAG_POP
480
+
481
+ _CCCL_HOST bool valid_content() const noexcept final override
482
+ {
483
+ return nullptr != content_;
484
+ }
485
+
486
+ // Precondition: `true == valid_content()`.
487
+ _CCCL_HOST pointer data()
488
+ {
489
+ if (!valid_content())
490
+ {
491
+ throw thrust::event_error(event_errc::no_content);
492
+ }
493
+
494
+ return content_;
495
+ }
496
+
497
+ // Precondition: `true == valid_content()`.
498
+ _CCCL_HOST const_pointer data() const
499
+ {
500
+ if (!valid_content())
501
+ {
502
+ throw thrust::event_error(event_errc::no_content);
503
+ }
504
+
505
+ return content_;
506
+ }
507
+
508
+ // Blocks.
509
+ // Precondition: `true == valid_content()`.
510
+ _CCCL_HOST value_type get() final override
511
+ {
512
+ this->stream().wait();
513
+ return *data();
514
+ }
515
+
516
+ // Blocks.
517
+ // Precondition: `true == valid_content()`.
518
+ _CCCL_HOST value_type extract() final override
519
+ {
520
+ this->stream().wait();
521
+ return std::move(*data());
522
+ }
523
+
524
+ // For testing only.
525
+ # if defined(THRUST_ENABLE_FUTURE_RAW_DATA_MEMBER)
526
+ _CCCL_HOST raw_const_pointer raw_data() const final override
527
+ {
528
+ return raw_pointer_cast(content_);
529
+ }
530
+ # endif
531
+ };
532
+
533
+ ///////////////////////////////////////////////////////////////////////////////
534
+
535
+ template <typename T, typename Pointer>
536
+ struct weak_promise final
537
+ {
538
+ using value_type = typename async_value<T>::value_type;
539
+
540
+ using pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<T>::other;
541
+ using const_pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<T const>::other;
542
+
543
+ private:
544
+ int device_ = 0;
545
+ pointer content_;
546
+
547
+ explicit weak_promise(int device_id, pointer content)
548
+ : device_(device_id)
549
+ , content_(std::move(content))
550
+ {}
551
+
552
+ public:
553
+ _CCCL_HOST_DEVICE weak_promise()
554
+ : device_(0)
555
+ , content_{}
556
+ {}
557
+
558
+ _CCCL_EXEC_CHECK_DISABLE
559
+ weak_promise(weak_promise const&) = default;
560
+ _CCCL_EXEC_CHECK_DISABLE
561
+ weak_promise(weak_promise&&) = default;
562
+ _CCCL_EXEC_CHECK_DISABLE
563
+ weak_promise& operator=(weak_promise const&) = default;
564
+ _CCCL_EXEC_CHECK_DISABLE
565
+ weak_promise& operator=(weak_promise&&) = default;
566
+
567
+ template <typename U>
568
+ _CCCL_HOST_DEVICE void set_value(U&& value) &&
569
+ {
570
+ *content_ = THRUST_FWD(value);
571
+ }
572
+
573
+ template <typename X, typename XPointer, typename ComputeContent, typename... Dependencies>
574
+ friend _CCCL_HOST unique_eager_future_promise_pair<X, XPointer>
575
+ thrust::system::cuda::detail::make_dependent_future(ComputeContent&& cc, std::tuple<Dependencies...>&& deps);
576
+ };
577
+
578
+ ///////////////////////////////////////////////////////////////////////////////
579
+
580
+ } // namespace detail
581
+
582
+ struct CCCL_DEPRECATED ready_event final
583
+ {
584
+ ready_event() = default;
585
+
586
+ template <typename U>
587
+ _CCCL_HOST_DEVICE explicit ready_event(ready_future<U>)
588
+ {}
589
+
590
+ _CCCL_HOST_DEVICE static constexpr bool valid_content() noexcept
591
+ {
592
+ return true;
593
+ }
594
+
595
+ _CCCL_HOST_DEVICE static constexpr bool ready() noexcept
596
+ {
597
+ return true;
598
+ }
599
+ };
600
+
601
+ template <typename T>
602
+ struct CCCL_DEPRECATED ready_future final
603
+ {
604
+ using value_type = T;
605
+ using raw_const_pointer = T const*;
606
+
607
+ private:
608
+ value_type value_;
609
+
610
+ public:
611
+ _CCCL_HOST_DEVICE ready_future()
612
+ : value_{}
613
+ {}
614
+
615
+ ready_future(ready_future&&) = default;
616
+ ready_future(ready_future const&) = default;
617
+ ready_future& operator=(ready_future&&) = default;
618
+ ready_future& operator=(ready_future const&) = default;
619
+
620
+ template <typename U>
621
+ _CCCL_HOST_DEVICE explicit ready_future(U&& u)
622
+ : value_(THRUST_FWD(u))
623
+ {}
624
+
625
+ _CCCL_HOST_DEVICE static constexpr bool valid_content() noexcept
626
+ {
627
+ return true;
628
+ }
629
+
630
+ _CCCL_HOST_DEVICE static constexpr bool ready() noexcept
631
+ {
632
+ return true;
633
+ }
634
+
635
+ _CCCL_HOST_DEVICE value_type get() const
636
+ {
637
+ return value_;
638
+ }
639
+
640
+ _CCCL_NODISCARD _CCCL_HOST_DEVICE value_type extract()
641
+ {
642
+ return std::move(value_);
643
+ }
644
+
645
+ # if defined(THRUST_ENABLE_FUTURE_RAW_DATA_MEMBER)
646
+ // For testing only.
647
+ _CCCL_HOST_DEVICE raw_const_pointer data() const
648
+ {
649
+ return addressof(value_);
650
+ }
651
+ # endif
652
+ };
653
+
654
+ struct CCCL_DEPRECATED unique_eager_event final
655
+ {
656
+ protected:
657
+ int device_ = 0;
658
+ std::unique_ptr<detail::async_signal> async_signal_;
659
+
660
+ _CCCL_HOST explicit unique_eager_event(int device_id, std::unique_ptr<detail::async_signal> async_signal)
661
+ : device_(device_id)
662
+ , async_signal_(std::move(async_signal))
663
+ {}
664
+
665
+ public:
666
+ _CCCL_HOST unique_eager_event()
667
+ : device_(0)
668
+ , async_signal_()
669
+ {}
670
+
671
+ unique_eager_event(unique_eager_event&&) = default;
672
+ unique_eager_event(unique_eager_event const&) = delete;
673
+ unique_eager_event& operator=(unique_eager_event&&) = default;
674
+ unique_eager_event& operator=(unique_eager_event const&) = delete;
675
+
676
+ // Any `unique_eager_future<T>` can be explicitly converted to a
677
+ // `unique_eager_event<void>`.
678
+ template <typename U>
679
+ _CCCL_HOST explicit unique_eager_event(unique_eager_future<U>&& other)
680
+ // NOTE: We upcast to `unique_ptr<async_signal>` here.
681
+ : device_(other.where())
682
+ , async_signal_(other.async_signal_.release())
683
+ {}
684
+
685
+ _CCCL_HOST
686
+ // NOTE: We take `new_stream_t` by `const&` because it is incomplete here.
687
+ explicit unique_eager_event(new_stream_t const&)
688
+ : device_(0)
689
+ , async_signal_(new detail::async_signal(detail::unique_stream{}))
690
+ {
691
+ thrust::cuda_cub::throw_on_error(cudaGetDevice(&device_));
692
+ }
693
+
694
+ _CCCL_HOST virtual ~unique_eager_event()
695
+ {
696
+ // FIXME: If we could asynchronously handle destruction of keep alives, we
697
+ // could avoid doing this.
698
+ if (valid_stream())
699
+ {
700
+ wait();
701
+ }
702
+ }
703
+
704
+ _CCCL_HOST bool valid_stream() const noexcept
705
+ {
706
+ return bool(async_signal_);
707
+ }
708
+
709
+ _CCCL_HOST bool ready() const noexcept
710
+ {
711
+ if (valid_stream())
712
+ {
713
+ return stream().ready();
714
+ }
715
+ else
716
+ {
717
+ return false;
718
+ }
719
+ }
720
+
721
+ // Precondition: `true == valid_stream()`.
722
+ _CCCL_HOST detail::unique_stream& stream()
723
+ {
724
+ if (!valid_stream())
725
+ {
726
+ throw thrust::event_error(event_errc::no_state);
727
+ }
728
+
729
+ return async_signal_->stream();
730
+ }
731
+ detail::unique_stream const& stream() const
732
+ {
733
+ if (!valid_stream())
734
+ {
735
+ throw thrust::event_error(event_errc::no_state);
736
+ }
737
+
738
+ return async_signal_->stream();
739
+ }
740
+
741
+ _CCCL_HOST int where() const noexcept
742
+ {
743
+ return device_;
744
+ }
745
+
746
+ // Precondition: `true == valid_stream()`.
747
+ _CCCL_HOST void wait()
748
+ {
749
+ stream().wait();
750
+ }
751
+
752
+ _CCCL_SUPPRESS_DEPRECATED_PUSH // for thrust::optional
753
+ friend _CCCL_HOST optional<detail::unique_stream>
754
+ thrust::system::cuda::detail::try_acquire_stream(int device_id, unique_eager_event& parent) noexcept;
755
+ _CCCL_SUPPRESS_DEPRECATED_POP
756
+
757
+ template <typename... Dependencies>
758
+ friend _CCCL_HOST unique_eager_event
759
+ thrust::system::cuda::detail::make_dependent_event(std::tuple<Dependencies...>&& deps);
760
+ };
761
+
762
+ template <typename T>
763
+ struct CCCL_DEPRECATED unique_eager_future final
764
+ {
765
+ THRUST_STATIC_ASSERT_MSG((!std::is_same<T, ::cuda::std::remove_cvref_t<void>>::value),
766
+ "`thrust::event` should be used to express valueless futures");
767
+
768
+ using value_type = typename detail::async_value<T>::value_type;
769
+ using raw_const_pointer = typename detail::async_value<T>::raw_const_pointer;
770
+
771
+ private:
772
+ int device_ = 0;
773
+ ::cuda::std::unique_ptr<detail::async_value<value_type>> async_signal_;
774
+
775
+ _CCCL_HOST explicit unique_eager_future(int device_id, std::unique_ptr<detail::async_value<value_type>> async_signal)
776
+ : device_(device_id)
777
+ , async_signal_(async_signal.release())
778
+ {}
779
+
780
+ public:
781
+ _CCCL_HOST unique_eager_future()
782
+ : device_(0)
783
+ , async_signal_()
784
+ {}
785
+
786
+ unique_eager_future(unique_eager_future&&) = default;
787
+ unique_eager_future(unique_eager_future const&) = delete;
788
+ unique_eager_future& operator=(unique_eager_future&&) = default;
789
+ unique_eager_future& operator=(unique_eager_future const&) = delete;
790
+
791
+ _CCCL_HOST
792
+ // NOTE: We take `new_stream_t` by `const&` because it is incomplete here.
793
+ explicit unique_eager_future(new_stream_t const&)
794
+ : device_(0)
795
+ , async_signal_(new detail::async_value<value_type>(detail::unique_stream{}))
796
+ {
797
+ thrust::cuda_cub::throw_on_error(cudaGetDevice(&device_));
798
+ }
799
+
800
+ _CCCL_HOST ~unique_eager_future()
801
+ {
802
+ // FIXME: If we could asynchronously handle destruction of keep alives, we
803
+ // could avoid doing this.
804
+ if (valid_stream())
805
+ {
806
+ wait();
807
+ }
808
+ }
809
+
810
+ _CCCL_HOST bool valid_stream() const noexcept
811
+ {
812
+ return bool(async_signal_);
813
+ }
814
+
815
+ _CCCL_HOST bool valid_content() const noexcept
816
+ {
817
+ if (!valid_stream())
818
+ {
819
+ return false;
820
+ }
821
+
822
+ // We might have been constructed with `new_stream_t`, in which case we'd
823
+ // have an async_value, but it doesn't have content.
824
+ return async_signal_->valid_content();
825
+ }
826
+
827
+ // Precondition: `true == valid_stream()`.
828
+ _CCCL_HOST bool ready() const noexcept
829
+ {
830
+ if (valid_stream())
831
+ {
832
+ return stream().ready();
833
+ }
834
+ else
835
+ {
836
+ return false;
837
+ }
838
+ }
839
+
840
+ // Precondition: `true == valid_stream()`.
841
+ _CCCL_HOST detail::unique_stream& stream()
842
+ {
843
+ if (!valid_stream())
844
+ {
845
+ throw thrust::event_error(event_errc::no_state);
846
+ }
847
+
848
+ return async_signal_->stream();
849
+ }
850
+ _CCCL_HOST detail::unique_stream const& stream() const
851
+ {
852
+ if (!valid_stream())
853
+ {
854
+ throw thrust::event_error(event_errc::no_state);
855
+ }
856
+
857
+ return async_signal_->stream();
858
+ }
859
+
860
+ _CCCL_HOST int where() const noexcept
861
+ {
862
+ return device_;
863
+ }
864
+
865
+ // Blocks.
866
+ // Precondition: `true == valid_stream()`.
867
+ _CCCL_HOST void wait()
868
+ {
869
+ stream().wait();
870
+ }
871
+
872
+ // Blocks.
873
+ // Precondition: `true == valid_content()`.
874
+ _CCCL_HOST value_type get()
875
+ {
876
+ if (!valid_content())
877
+ {
878
+ throw thrust::event_error(event_errc::no_content);
879
+ }
880
+
881
+ return async_signal_->get();
882
+ }
883
+
884
+ // Blocks.
885
+ // Precondition: `true == valid_content()`.
886
+ _CCCL_NODISCARD _CCCL_HOST value_type extract()
887
+ {
888
+ if (!valid_content())
889
+ {
890
+ throw thrust::event_error(event_errc::no_content);
891
+ }
892
+
893
+ value_type tmp(async_signal_->extract());
894
+ async_signal_.reset();
895
+ return tmp;
896
+ }
897
+
898
+ // For testing only.
899
+ # if defined(THRUST_ENABLE_FUTURE_RAW_DATA_MEMBER)
900
+ // Precondition: `true == valid_stream()`.
901
+ _CCCL_HOST raw_const_pointer raw_data() const
902
+ {
903
+ if (!valid_stream())
904
+ {
905
+ throw thrust::event_error(event_errc::no_state);
906
+ }
907
+
908
+ return async_signal_->raw_data();
909
+ }
910
+ # endif
911
+
912
+ _CCCL_SUPPRESS_DEPRECATED_PUSH // for thrust::optional
913
+ template <typename X>
914
+ friend _CCCL_HOST optional<detail::unique_stream>
915
+ thrust::system::cuda::detail::try_acquire_stream(int device_id, unique_eager_future<X>& parent) noexcept;
916
+ _CCCL_SUPPRESS_DEPRECATED_POP
917
+
918
+ template <typename X, typename XPointer, typename ComputeContent, typename... Dependencies>
919
+ friend _CCCL_HOST detail::unique_eager_future_promise_pair<X, XPointer>
920
+ thrust::system::cuda::detail::make_dependent_future(ComputeContent&& cc, std::tuple<Dependencies...>&& deps);
921
+
922
+ friend struct unique_eager_event;
923
+ };
924
+
925
+ ///////////////////////////////////////////////////////////////////////////////
926
+
927
+ namespace detail
928
+ {
929
+ _CCCL_SUPPRESS_DEPRECATED_PUSH // for thrust::optional
930
+
931
+ template <typename X, typename Deleter>
932
+ _CCCL_HOST optional<unique_stream> try_acquire_stream(int, std::unique_ptr<X, Deleter>&) noexcept
933
+ {
934
+ // There's no stream to acquire!
935
+ return {};
936
+ }
937
+
938
+ _CCCL_HOST inline optional<unique_stream> try_acquire_stream(int, unique_stream& stream) noexcept
939
+ {
940
+ return {std::move(stream)};
941
+ }
942
+
943
+ _CCCL_HOST inline optional<unique_stream> try_acquire_stream(int, ready_event&) noexcept
944
+ {
945
+ // There's no stream to acquire!
946
+ return {};
947
+ }
948
+
949
+ template <typename X>
950
+ _CCCL_HOST optional<unique_stream> try_acquire_stream(int, ready_future<X>&) noexcept
951
+ {
952
+ // There's no stream to acquire!
953
+ return {};
954
+ }
955
+
956
+ _CCCL_HOST optional<unique_stream> try_acquire_stream(int device_id, unique_eager_event& parent) noexcept
957
+ {
958
+ // We have unique ownership, so we can always steal the stream if the future
959
+ // has one as long as they are on the same device as us.
960
+ if (parent.valid_stream())
961
+ {
962
+ if (device_id == parent.device_)
963
+ {
964
+ return std::move(parent.async_signal_->stream());
965
+ }
966
+ }
967
+
968
+ return {};
969
+ }
970
+
971
+ template <typename X>
972
+ _CCCL_HOST optional<unique_stream> try_acquire_stream(int device_id, unique_eager_future<X>& parent) noexcept
973
+ {
974
+ // We have unique ownership, so we can always steal the stream if the future
975
+ // has one as long as they are on the same device as us.
976
+ if (parent.valid_stream())
977
+ {
978
+ if (device_id == parent.device_)
979
+ {
980
+ return std::move(parent.async_signal_->stream());
981
+ }
982
+ }
983
+
984
+ return {};
985
+ }
986
+
987
+ _CCCL_SUPPRESS_DEPRECATED_POP
988
+
989
+ ///////////////////////////////////////////////////////////////////////////////
990
+
991
+ template <typename... Dependencies>
992
+ _CCCL_HOST acquired_stream acquire_stream_impl(int, std::tuple<Dependencies...>&, index_sequence<>) noexcept
993
+ {
994
+ // We tried to take a stream from all of our dependencies and failed every
995
+ // time, so we need to make a new stream.
996
+ return {unique_stream{}, {}};
997
+ }
998
+
999
+ template <typename... Dependencies, std::size_t I0, std::size_t... Is>
1000
+ _CCCL_HOST acquired_stream
1001
+ acquire_stream_impl(int device_id, std::tuple<Dependencies...>& deps, index_sequence<I0, Is...>) noexcept
1002
+ {
1003
+ _CCCL_SUPPRESS_DEPRECATED_PUSH // for thrust::optional (MSVC warnings here)
1004
+ auto tr = try_acquire_stream(device_id, std::get<I0>(deps));
1005
+
1006
+ if (tr)
1007
+ {
1008
+ return {std::move(*tr), {I0}};
1009
+ }
1010
+ else
1011
+ {
1012
+ return acquire_stream_impl(device_id, deps, index_sequence<Is...>{});
1013
+ }
1014
+ _CCCL_SUPPRESS_DEPRECATED_POP
1015
+ }
1016
+
1017
+ template <typename... Dependencies>
1018
+ _CCCL_HOST acquired_stream acquire_stream(int device_id, std::tuple<Dependencies...>& deps) noexcept
1019
+ {
1020
+ return acquire_stream_impl(device_id, deps, make_index_sequence<sizeof...(Dependencies)>{});
1021
+ }
1022
+
1023
+ ///////////////////////////////////////////////////////////////////////////////
1024
+
1025
+ template <typename X, typename Deleter>
1026
+ _CCCL_HOST void create_dependency(unique_stream&, std::unique_ptr<X, Deleter>&) noexcept
1027
+ {}
1028
+
1029
+ _CCCL_HOST inline void create_dependency(unique_stream&, ready_event&) noexcept {}
1030
+
1031
+ template <typename T>
1032
+ _CCCL_HOST void create_dependency(unique_stream&, ready_future<T>&) noexcept
1033
+ {}
1034
+
1035
+ _CCCL_HOST inline void create_dependency(unique_stream& child, unique_stream& parent)
1036
+ {
1037
+ child.depend_on(parent);
1038
+ }
1039
+
1040
+ _CCCL_HOST inline void create_dependency(unique_stream& child, unique_eager_event& parent)
1041
+ {
1042
+ child.depend_on(parent.stream());
1043
+ }
1044
+
1045
+ template <typename X>
1046
+ _CCCL_HOST void create_dependency(unique_stream& child, unique_eager_future<X>& parent)
1047
+ {
1048
+ child.depend_on(parent.stream());
1049
+ }
1050
+
1051
+ template <typename... Dependencies>
1052
+ _CCCL_HOST void create_dependencies_impl(acquired_stream&, std::tuple<Dependencies...>&, index_sequence<>)
1053
+ {}
1054
+
1055
+ template <typename... Dependencies, std::size_t I0, std::size_t... Is>
1056
+ _CCCL_HOST void
1057
+ create_dependencies_impl(acquired_stream& as, std::tuple<Dependencies...>& deps, index_sequence<I0, Is...>)
1058
+ {
1059
+ // We only need to wait on the current dependency if we didn't steal our
1060
+ // stream from it.
1061
+ _CCCL_SUPPRESS_DEPRECATED_PUSH
1062
+ if (!as.acquired_from || *as.acquired_from != I0)
1063
+ {
1064
+ create_dependency(as.stream, std::get<I0>(deps));
1065
+ }
1066
+ _CCCL_SUPPRESS_DEPRECATED_POP
1067
+
1068
+ create_dependencies_impl(as, deps, index_sequence<Is...>{});
1069
+ }
1070
+
1071
+ template <typename... Dependencies>
1072
+ _CCCL_HOST void create_dependencies(acquired_stream& as, std::tuple<Dependencies...>& deps)
1073
+ {
1074
+ create_dependencies_impl(as, deps, make_index_sequence<sizeof...(Dependencies)>{});
1075
+ }
1076
+
1077
+ ///////////////////////////////////////////////////////////////////////////////
1078
+
1079
+ // Metafunction that determine which `Dependencies` need to be kept alive.
1080
+ // Returns the result as an `index_sequence` of indices into the parameter
1081
+ // pack.
1082
+ template <typename Tuple, typename Indices>
1083
+ struct find_keep_alives_impl;
1084
+ template <typename Tuple>
1085
+ using find_keep_alives =
1086
+ typename find_keep_alives_impl<Tuple, make_index_sequence<std::tuple_size<Tuple>::value>>::type;
1087
+
1088
+ template <>
1089
+ struct find_keep_alives_impl<std::tuple<>, index_sequence<>>
1090
+ {
1091
+ using type = index_sequence<>;
1092
+ };
1093
+
1094
+ // User-provided stream.
1095
+ template <typename... Dependencies, std::size_t I0, std::size_t... Is>
1096
+ struct find_keep_alives_impl<std::tuple<unique_stream, Dependencies...>, index_sequence<I0, Is...>>
1097
+ {
1098
+ // Nothing to keep alive, skip this index.
1099
+ using type = typename find_keep_alives_impl<std::tuple<Dependencies...>, index_sequence<Is...>>::type;
1100
+ };
1101
+
1102
+ template <typename... Dependencies, std::size_t I0, std::size_t... Is>
1103
+ struct find_keep_alives_impl<std::tuple<ready_event, Dependencies...>, index_sequence<I0, Is...>>
1104
+ {
1105
+ // Nothing to keep alive, skip this index.
1106
+ using type = typename find_keep_alives_impl<std::tuple<Dependencies...>, index_sequence<Is...>>::type;
1107
+ };
1108
+
1109
+ template <typename T, typename... Dependencies, std::size_t I0, std::size_t... Is>
1110
+ struct find_keep_alives_impl<std::tuple<ready_future<T>, Dependencies...>, index_sequence<I0, Is...>>
1111
+ {
1112
+ // Add this index to the list.
1113
+ using type = integer_sequence_push_front<
1114
+ std::size_t,
1115
+ I0,
1116
+ typename find_keep_alives_impl<std::tuple<Dependencies...>, index_sequence<Is...>>::type>;
1117
+ };
1118
+
1119
+ template <typename... Dependencies, std::size_t I0, std::size_t... Is>
1120
+ struct find_keep_alives_impl<std::tuple<unique_eager_event, Dependencies...>, index_sequence<I0, Is...>>
1121
+ {
1122
+ // Add this index to the list.
1123
+ using type = integer_sequence_push_front<
1124
+ std::size_t,
1125
+ I0,
1126
+ typename find_keep_alives_impl<std::tuple<Dependencies...>, index_sequence<Is...>>::type>;
1127
+ };
1128
+
1129
+ template <typename X, typename... Dependencies, std::size_t I0, std::size_t... Is>
1130
+ struct find_keep_alives_impl<std::tuple<unique_eager_future<X>, Dependencies...>, index_sequence<I0, Is...>>
1131
+ {
1132
+ // Add this index to the list.
1133
+ using type = integer_sequence_push_front<
1134
+ std::size_t,
1135
+ I0,
1136
+ typename find_keep_alives_impl<std::tuple<Dependencies...>, index_sequence<Is...>>::type>;
1137
+ };
1138
+
1139
+ // Content storage.
1140
+ template <typename T, typename Deleter, typename... Dependencies, std::size_t I0, std::size_t... Is>
1141
+ struct find_keep_alives_impl<std::tuple<std::unique_ptr<T, Deleter>, Dependencies...>, index_sequence<I0, Is...>>
1142
+ {
1143
+ // Add this index to the list.
1144
+ using type = integer_sequence_push_front<
1145
+ std::size_t,
1146
+ I0,
1147
+ typename find_keep_alives_impl<std::tuple<Dependencies...>, index_sequence<Is...>>::type>;
1148
+ };
1149
+
1150
+ ///////////////////////////////////////////////////////////////////////////////
1151
+
1152
+ template <typename... Dependencies>
1153
+ _CCCL_HOST unique_eager_event make_dependent_event(std::tuple<Dependencies...>&& deps)
1154
+ {
1155
+ int device_id = 0;
1156
+ thrust::cuda_cub::throw_on_error(cudaGetDevice(&device_id));
1157
+
1158
+ // First, either steal a stream from one of our children or make a new one.
1159
+ auto as = acquire_stream(device_id, deps);
1160
+
1161
+ // Then, make the stream we've acquired asynchronously wait on all of our
1162
+ // dependencies, except the one we stole the stream from.
1163
+ create_dependencies(as, deps);
1164
+
1165
+ // Then, we determine which subset of dependencies need to be kept alive.
1166
+ auto ka = tuple_subset(std::move(deps), find_keep_alives<std::tuple<Dependencies...>>{});
1167
+
1168
+ // Next, we create the asynchronous signal.
1169
+ using async_signal_type = async_keep_alives<decltype(ka)>;
1170
+
1171
+ std::unique_ptr<async_signal_type> sig(new async_signal_type(std::move(as.stream), std::move(ka)));
1172
+
1173
+ // Finally, we create the event object.
1174
+ return unique_eager_event(device_id, std::move(sig));
1175
+ }
1176
+
1177
+ ///////////////////////////////////////////////////////////////////////////////
1178
+
1179
+ template <typename X, typename XPointer, typename ComputeContent, typename... Dependencies>
1180
+ _CCCL_HOST unique_eager_future_promise_pair<X, XPointer>
1181
+ make_dependent_future(ComputeContent&& cc, std::tuple<Dependencies...>&& deps)
1182
+ {
1183
+ int device_id = 0;
1184
+ thrust::cuda_cub::throw_on_error(cudaGetDevice(&device_id));
1185
+
1186
+ // First, either steal a stream from one of our children or make a new one.
1187
+ auto as = acquire_stream(device_id, deps);
1188
+
1189
+ // Then, make the stream we've acquired asynchronously wait on all of our
1190
+ // dependencies, except the one we stole the stream from.
1191
+ create_dependencies(as, deps);
1192
+
1193
+ // Then, we determine which subset of dependencies need to be kept alive.
1194
+ auto ka = tuple_subset(std::move(deps), find_keep_alives<std::tuple<Dependencies...>>{});
1195
+
1196
+ // Next, we create the asynchronous value.
1197
+ using async_signal_type = async_addressable_value_with_keep_alives<X, XPointer, decltype(ka)>;
1198
+
1199
+ std::unique_ptr<async_signal_type> sig(new async_signal_type(std::move(as.stream), std::move(ka), std::move(cc)));
1200
+
1201
+ // Finally, we create the promise and future objects.
1202
+ weak_promise<X, XPointer> child_prom(device_id, sig->data());
1203
+ unique_eager_future<X> child_fut(device_id, std::move(sig));
1204
+
1205
+ return unique_eager_future_promise_pair<X, XPointer>{std::move(child_fut), std::move(child_prom)};
1206
+ }
1207
+
1208
+ } // namespace detail
1209
+
1210
+ ///////////////////////////////////////////////////////////////////////////////
1211
+
1212
+ template <typename... Events>
1213
+ CCCL_DEPRECATED _CCCL_HOST unique_eager_event when_all(Events&&... evs)
1214
+ // TODO: Constrain to events, futures, and maybe streams (currently allows keep
1215
+ // alives).
1216
+ {
1217
+ return detail::make_dependent_event(std::make_tuple(std::move(evs)...));
1218
+ }
1219
+
1220
+ // ADL hook for transparent `.after` move support.
1221
+ CCCL_DEPRECATED _CCCL_HOST inline auto capture_as_dependency(unique_eager_event& dependency)
1222
+ THRUST_DECLTYPE_RETURNS(std::move(dependency))
1223
+
1224
+ // ADL hook for transparent `.after` move support.
1225
+ template <typename X>
1226
+ CCCL_DEPRECATED _CCCL_HOST auto capture_as_dependency(unique_eager_future<X>& dependency)
1227
+ THRUST_DECLTYPE_RETURNS(std::move(dependency))
1228
+
1229
+ } // namespace cuda
1230
+ } // namespace system
1231
+
1232
+ _CCCL_SUPPRESS_DEPRECATED_POP
1233
+ THRUST_NAMESPACE_END
1234
+
1235
+ #endif // C++14
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/gather.h ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******************************************************************************
2
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ * * Redistributions of source code must retain the above copyright
7
+ * notice, this list of conditions and the following disclaimer.
8
+ * * Redistributions in binary form must reproduce the above copyright
9
+ * notice, this list of conditions and the following disclaimer in the
10
+ * documentation and/or other materials provided with the distribution.
11
+ * * Neither the name of the NVIDIA CORPORATION nor the
12
+ * names of its contributors may be used to endorse or promote products
13
+ * derived from this software without specific prior written permission.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
19
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ *
26
+ ******************************************************************************/
27
+ #pragma once
28
+
29
+ #include <thrust/detail/config.h>
30
+
31
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
32
+ # pragma GCC system_header
33
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
34
+ # pragma clang system_header
35
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
36
+ # pragma system_header
37
+ #endif // no system header
38
+
39
+ #if _CCCL_HAS_CUDA_COMPILER
40
+ # include <thrust/iterator/permutation_iterator.h>
41
+ # include <thrust/system/cuda/detail/transform.h>
42
+
43
+ # include <cuda/std/__functional/identity.h>
44
+
45
+ THRUST_NAMESPACE_BEGIN
46
+ namespace cuda_cub
47
+ {
48
+
49
+ template <class Derived, class MapIt, class ItemsIt, class ResultIt>
50
+ ResultIt _CCCL_HOST_DEVICE
51
+ gather(execution_policy<Derived>& policy, MapIt map_first, MapIt map_last, ItemsIt items, ResultIt result)
52
+ {
53
+ return cuda_cub::transform(
54
+ policy,
55
+ thrust::make_permutation_iterator(items, map_first),
56
+ thrust::make_permutation_iterator(items, map_last),
57
+ result,
58
+ ::cuda::std::__identity{});
59
+ }
60
+
61
+ template <class Derived, class MapIt, class StencilIt, class ItemsIt, class ResultIt, class Predicate>
62
+ ResultIt _CCCL_HOST_DEVICE gather_if(
63
+ execution_policy<Derived>& policy,
64
+ MapIt map_first,
65
+ MapIt map_last,
66
+ StencilIt stencil,
67
+ ItemsIt items,
68
+ ResultIt result,
69
+ Predicate predicate)
70
+ {
71
+ return cuda_cub::transform_if(
72
+ policy,
73
+ thrust::make_permutation_iterator(items, map_first),
74
+ thrust::make_permutation_iterator(items, map_last),
75
+ stencil,
76
+ result,
77
+ ::cuda::std::__identity{},
78
+ predicate);
79
+ }
80
+
81
+ template <class Derived, class MapIt, class StencilIt, class ItemsIt, class ResultIt>
82
+ ResultIt _CCCL_HOST_DEVICE gather_if(
83
+ execution_policy<Derived>& policy, MapIt map_first, MapIt map_last, StencilIt stencil, ItemsIt items, ResultIt result)
84
+ {
85
+ return cuda_cub::gather_if(policy, map_first, map_last, stencil, items, result, ::cuda::std::__identity{});
86
+ }
87
+
88
+ } // namespace cuda_cub
89
+ THRUST_NAMESPACE_END
90
+
91
+ #endif
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/generate.h ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******************************************************************************
2
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ * * Redistributions of source code must retain the above copyright
7
+ * notice, this list of conditions and the following disclaimer.
8
+ * * Redistributions in binary form must reproduce the above copyright
9
+ * notice, this list of conditions and the following disclaimer in the
10
+ * documentation and/or other materials provided with the distribution.
11
+ * * Neither the name of the NVIDIA CORPORATION nor the
12
+ * names of its contributors may be used to endorse or promote products
13
+ * derived from this software without specific prior written permission.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
19
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ *
26
+ ******************************************************************************/
27
+ #pragma once
28
+
29
+ #include <thrust/detail/config.h>
30
+
31
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
32
+ # pragma GCC system_header
33
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
34
+ # pragma clang system_header
35
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
36
+ # pragma system_header
37
+ #endif // no system header
38
+
39
+ #if _CCCL_HAS_CUDA_COMPILER
40
+ # include <thrust/system/cuda/config.h>
41
+
42
+ # include <thrust/distance.h>
43
+ # include <thrust/system/cuda/detail/for_each.h>
44
+
45
+ # include <iterator>
46
+
47
+ THRUST_NAMESPACE_BEGIN
48
+ namespace cuda_cub
49
+ {
50
+
51
+ // for_each functor
52
+ template <class Generator>
53
+ struct generate_f
54
+ {
55
+ Generator generator;
56
+
57
+ THRUST_FUNCTION
58
+ generate_f(Generator generator_)
59
+ : generator(generator_)
60
+ {}
61
+
62
+ template <class T>
63
+ THRUST_DEVICE_FUNCTION void operator()(T const& value)
64
+ {
65
+ T& lvalue = const_cast<T&>(value);
66
+ lvalue = generator();
67
+ }
68
+ };
69
+
70
+ // for_each_n
71
+ template <class Derived, class OutputIt, class Size, class Generator>
72
+ OutputIt _CCCL_HOST_DEVICE
73
+ generate_n(execution_policy<Derived>& policy, OutputIt result, Size count, Generator generator)
74
+ {
75
+ return cuda_cub::for_each_n(policy, result, count, generate_f<Generator>(generator));
76
+ }
77
+
78
+ // for_each
79
+ template <class Derived, class OutputIt, class Generator>
80
+ void _CCCL_HOST_DEVICE generate(execution_policy<Derived>& policy, OutputIt first, OutputIt last, Generator generator)
81
+ {
82
+ cuda_cub::generate_n(policy, first, thrust::distance(first, last), generator);
83
+ }
84
+
85
+ } // namespace cuda_cub
86
+ THRUST_NAMESPACE_END
87
+ #endif
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/get_value.h ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ #if _CCCL_HAS_CUDA_COMPILER
30
+ # include <thrust/system/cuda/config.h>
31
+
32
+ # include <thrust/detail/raw_pointer_cast.h>
33
+ # include <thrust/iterator/iterator_traits.h>
34
+ # include <thrust/system/cuda/detail/cross_system.h>
35
+
36
+ # include <nv/target>
37
+
38
+ THRUST_NAMESPACE_BEGIN
39
+ namespace cuda_cub
40
+ {
41
+
42
+ namespace
43
+ {
44
+
45
+ template <typename DerivedPolicy, typename Pointer>
46
+ inline _CCCL_HOST_DEVICE typename thrust::iterator_value<Pointer>::type
47
+ get_value_msvc2005_war(execution_policy<DerivedPolicy>& exec, Pointer ptr)
48
+ {
49
+ using result_type = typename thrust::iterator_value<Pointer>::type;
50
+
51
+ // XXX war nvbugs/881631
52
+ struct war_nvbugs_881631
53
+ {
54
+ _CCCL_HOST inline static result_type host_path(execution_policy<DerivedPolicy>& exec, Pointer ptr)
55
+ {
56
+ // when called from host code, implement with assign_value
57
+ // note that this requires a type with default constructor
58
+ result_type result;
59
+
60
+ thrust::host_system_tag host_tag;
61
+ cross_system<thrust::host_system_tag, DerivedPolicy> systems(host_tag, exec);
62
+ assign_value(systems, &result, ptr);
63
+
64
+ return result;
65
+ }
66
+
67
+ _CCCL_DEVICE inline static result_type device_path(execution_policy<DerivedPolicy>&, Pointer ptr)
68
+ {
69
+ // when called from device code, just do simple deref
70
+ return *thrust::raw_pointer_cast(ptr);
71
+ }
72
+ };
73
+
74
+ NV_IF_TARGET(
75
+ NV_IS_HOST, (return war_nvbugs_881631::host_path(exec, ptr);), (return war_nvbugs_881631::device_path(exec, ptr);))
76
+ } // end get_value_msvc2005_war()
77
+ } // namespace
78
+
79
+ template <typename DerivedPolicy, typename Pointer>
80
+ inline _CCCL_HOST_DEVICE typename thrust::iterator_value<Pointer>::type
81
+ get_value(execution_policy<DerivedPolicy>& exec, Pointer ptr)
82
+ {
83
+ return get_value_msvc2005_war(exec, ptr);
84
+ } // end get_value()
85
+
86
+ } // namespace cuda_cub
87
+ THRUST_NAMESPACE_END
88
+
89
+ #endif
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/iter_swap.h ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #if _CCCL_HAS_CUDA_COMPILER
30
+
31
+ # include <thrust/system/cuda/config.h>
32
+
33
+ # include <thrust/detail/raw_pointer_cast.h>
34
+ # include <thrust/swap.h>
35
+ # include <thrust/system/cuda/detail/execution_policy.h>
36
+
37
+ # include <cuda/std/utility>
38
+
39
+ # include <nv/target>
40
+
41
+ THRUST_NAMESPACE_BEGIN
42
+ namespace cuda_cub
43
+ {
44
+
45
+ template <typename DerivedPolicy, typename Pointer1, typename Pointer2>
46
+ inline _CCCL_HOST_DEVICE void iter_swap(thrust::cuda::execution_policy<DerivedPolicy>&, Pointer1 a, Pointer2 b)
47
+ {
48
+ // XXX war nvbugs/881631
49
+ struct war_nvbugs_881631
50
+ {
51
+ _CCCL_HOST inline static void host_path(Pointer1 a, Pointer2 b)
52
+ {
53
+ thrust::swap_ranges(a, a + 1, b);
54
+ }
55
+
56
+ _CCCL_DEVICE inline static void device_path(Pointer1 a, Pointer2 b)
57
+ {
58
+ using ::cuda::std::swap;
59
+ swap(*thrust::raw_pointer_cast(a), *thrust::raw_pointer_cast(b));
60
+ }
61
+ };
62
+
63
+ NV_IF_TARGET(NV_IS_HOST, (war_nvbugs_881631::host_path(a, b);), (war_nvbugs_881631::device_path(a, b);));
64
+
65
+ } // end iter_swap()
66
+
67
+ } // namespace cuda_cub
68
+ THRUST_NAMESPACE_END
69
+ #endif
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/logical.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2008-2013 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ // this system has no special version of this algorithm
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/cuda/detail/make_unsigned_special.h ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2019 NVIDIA Corporation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <thrust/detail/config.h>
20
+
21
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
22
+ # pragma GCC system_header
23
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
24
+ # pragma clang system_header
25
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
26
+ # pragma system_header
27
+ #endif // no system header
28
+
29
+ THRUST_NAMESPACE_BEGIN
30
+ namespace cuda_cub
31
+ {
32
+
33
+ namespace detail
34
+ {
35
+
36
+ template <typename Size>
37
+ struct make_unsigned_special;
38
+
39
+ template <>
40
+ struct make_unsigned_special<int>
41
+ {
42
+ using type = unsigned int;
43
+ };
44
+
45
+ // this is special, because CUDA's atomicAdd doesn't have an overload
46
+ // for unsigned long, for some godforsaken reason
47
+ template <>
48
+ struct make_unsigned_special<long>
49
+ {
50
+ using type = unsigned long long;
51
+ };
52
+
53
+ template <>
54
+ struct make_unsigned_special<long long>
55
+ {
56
+ using type = unsigned long long;
57
+ };
58
+
59
+ } // namespace detail
60
+ } // namespace cuda_cub
61
+ THRUST_NAMESPACE_END