koichi12 commited on
Commit
71147a9
·
verified ·
1 Parent(s): 2abe095

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. .venv/lib/python3.11/site-packages/numpy.libs/libgfortran-040039e1.so.5.0.0 +3 -0
  3. .venv/lib/python3.11/site-packages/numpy.libs/libquadmath-96973f99.so.0.0.0 +3 -0
  4. .venv/lib/python3.11/site-packages/triton/backends/amd/include/hip/amd_detail/amd_hip_fp16.h +1809 -0
  5. .venv/lib/python3.11/site-packages/triton/backends/amd/include/hip/amd_detail/concepts.hpp +30 -0
  6. .venv/lib/python3.11/site-packages/triton/backends/amd/include/hip/amd_detail/macro_based_grid_launch.hpp +798 -0
  7. .venv/lib/python3.11/site-packages/triton/backends/amd/include/hip/amd_detail/ockl_image.h +177 -0
  8. .venv/lib/python3.11/site-packages/triton/backends/compiler.py +76 -0
  9. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/builtin_types.h +64 -0
  10. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/common_functions.h +65 -0
  11. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/coalesced_scan.h +174 -0
  12. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/driver_abi.h +99 -0
  13. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/info.h +344 -0
  14. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/invoke.h +189 -0
  15. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/partitioning.h +159 -0
  16. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/sync.h +282 -0
  17. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuComplex.h +348 -0
  18. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda.h +0 -0
  19. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cudaEGLTypedefs.h +96 -0
  20. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cudaVDPAUTypedefs.h +90 -0
  21. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_awbarrier.h +280 -0
  22. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_awbarrier_helpers.h +365 -0
  23. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_awbarrier_primitives.h +109 -0
  24. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_bf16.h +0 -0
  25. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_bf16.hpp +0 -0
  26. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_device_runtime_api.h +889 -0
  27. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_egl_interop.h +642 -0
  28. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_fp16.h +0 -0
  29. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_fp16.hpp +0 -0
  30. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_fp8.h +367 -0
  31. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_fp8.hpp +1750 -0
  32. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_occupancy.h +1958 -0
  33. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_pipeline.h +224 -0
  34. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_pipeline_helpers.h +373 -0
  35. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_pipeline_primitives.h +148 -0
  36. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_runtime.h +2374 -0
  37. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_texture_types.h +76 -0
  38. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cupti_checkpoint.h +127 -0
  39. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cupti_nvtx_cbid.h +111 -0
  40. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cupti_pcsampling.h +936 -0
  41. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cupti_result.h +346 -0
  42. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cupti_target.h +43 -0
  43. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/device_double_functions.h +65 -0
  44. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/device_launch_parameters.h +118 -0
  45. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/device_types.h +81 -0
  46. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/driver_functions.h +145 -0
  47. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/driver_types.h +0 -0
  48. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/generated_cudaVDPAU_meta.h +46 -0
  49. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/generated_cuda_gl_interop_meta.h +71 -0
  50. .venv/lib/python3.11/site-packages/triton/backends/nvidia/include/generated_cuda_meta.h +3563 -0
.gitattributes CHANGED
@@ -261,3 +261,5 @@ tuning-competition-baseline/.venv/lib/python3.11/site-packages/torch/_inductor/_
261
  .venv/lib/python3.11/site-packages/propcache/_helpers_c.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
262
  .venv/lib/python3.11/site-packages/setuptools/cli-arm64.exe filter=lfs diff=lfs merge=lfs -text
263
  .venv/lib/python3.11/site-packages/setuptools/gui-arm64.exe filter=lfs diff=lfs merge=lfs -text
 
 
 
261
  .venv/lib/python3.11/site-packages/propcache/_helpers_c.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
262
  .venv/lib/python3.11/site-packages/setuptools/cli-arm64.exe filter=lfs diff=lfs merge=lfs -text
263
  .venv/lib/python3.11/site-packages/setuptools/gui-arm64.exe filter=lfs diff=lfs merge=lfs -text
264
+ .venv/lib/python3.11/site-packages/numpy.libs/libquadmath-96973f99.so.0.0.0 filter=lfs diff=lfs merge=lfs -text
265
+ .venv/lib/python3.11/site-packages/numpy.libs/libgfortran-040039e1.so.5.0.0 filter=lfs diff=lfs merge=lfs -text
.venv/lib/python3.11/site-packages/numpy.libs/libgfortran-040039e1.so.5.0.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:14afb3129b1a8b50bc40a3b0820c7f1152ea9bc10121aab152943f7057472886
3
+ size 2686065
.venv/lib/python3.11/site-packages/numpy.libs/libquadmath-96973f99.so.0.0.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:934c22ded0e7d169c4d4678876c96051adf3d94545da962f60b41659b075da3b
3
+ size 247609
.venv/lib/python3.11/site-packages/triton/backends/amd/include/hip/amd_detail/amd_hip_fp16.h ADDED
@@ -0,0 +1,1809 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (c) 2015 - 2023 Advanced Micro Devices, Inc. All rights reserved.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+ */
22
+
23
+ #pragma once
24
+ #ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_FP16_H
25
+ #define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_FP16_H
26
+
27
+ #if defined(__HIPCC_RTC__)
28
+ #define __HOST_DEVICE__ __device__
29
+ #else
30
+ #define __HOST_DEVICE__ __host__ __device__
31
+ #include <hip/amd_detail/amd_hip_common.h>
32
+ #include "hip/amd_detail/host_defines.h"
33
+ #include <assert.h>
34
+ #if defined(__cplusplus)
35
+ #include <algorithm>
36
+ #include <type_traits>
37
+ #include <utility>
38
+ #endif
39
+ #endif // !defined(__HIPCC_RTC__)
40
+
41
+ #if defined(__clang__) && defined(__HIP__)
42
+ typedef _Float16 _Float16_2 __attribute__((ext_vector_type(2)));
43
+
44
+ struct __half_raw {
45
+ union {
46
+ static_assert(sizeof(_Float16) == sizeof(unsigned short), "");
47
+
48
+ _Float16 data;
49
+ unsigned short x;
50
+ };
51
+ };
52
+
53
+ struct __half2_raw {
54
+ union {
55
+ static_assert(sizeof(_Float16_2) == sizeof(unsigned short[2]), "");
56
+
57
+ struct {
58
+ __half_raw x;
59
+ __half_raw y;
60
+ };
61
+ _Float16_2 data;
62
+ };
63
+ };
64
+
65
+ #if defined(__cplusplus)
66
+ #if !defined(__HIPCC_RTC__)
67
+ #include "hip_fp16_math_fwd.h"
68
+ #include "amd_hip_vector_types.h"
69
+ #include "host_defines.h"
70
+ #include "amd_device_functions.h"
71
+ #include "amd_warp_functions.h"
72
+ #endif
73
+ namespace std
74
+ {
75
+ template<> struct is_floating_point<_Float16> : std::true_type {};
76
+ }
77
+
78
+ template<bool cond, typename T = void>
79
+ using Enable_if_t = typename std::enable_if<cond, T>::type;
80
+
81
+ // BEGIN STRUCT __HALF
82
+ struct __half {
83
+ protected:
84
+ union {
85
+ static_assert(sizeof(_Float16) == sizeof(unsigned short), "");
86
+
87
+ _Float16 data;
88
+ unsigned short __x;
89
+ };
90
+ public:
91
+ // CREATORS
92
+ __HOST_DEVICE__
93
+ __half() = default;
94
+ __HOST_DEVICE__
95
+ __half(const __half_raw& x) : data{x.data} {}
96
+ #if !defined(__HIP_NO_HALF_CONVERSIONS__)
97
+ __HOST_DEVICE__
98
+ __half(decltype(data) x) : data{x} {}
99
+ template<
100
+ typename T,
101
+ Enable_if_t<std::is_floating_point<T>{}>* = nullptr>
102
+ __HOST_DEVICE__
103
+ __half(T x) : data{static_cast<_Float16>(x)} {}
104
+ #endif
105
+ __HOST_DEVICE__
106
+ __half(const __half&) = default;
107
+ __HOST_DEVICE__
108
+ __half(__half&&) = default;
109
+ __HOST_DEVICE__
110
+ ~__half() = default;
111
+
112
+ // CREATORS - DEVICE ONLY
113
+ #if !defined(__HIP_NO_HALF_CONVERSIONS__)
114
+ template<
115
+ typename T, Enable_if_t<std::is_integral<T>{}>* = nullptr>
116
+ __HOST_DEVICE__
117
+ __half(T x) : data{static_cast<_Float16>(x)} {}
118
+ #endif
119
+
120
+ // MANIPULATORS
121
+ __HOST_DEVICE__
122
+ __half& operator=(const __half&) = default;
123
+ __HOST_DEVICE__
124
+ __half& operator=(__half&&) = default;
125
+ __HOST_DEVICE__
126
+ __half& operator=(const __half_raw& x)
127
+ {
128
+ data = x.data;
129
+ return *this;
130
+ }
131
+ __HOST_DEVICE__
132
+ volatile __half& operator=(const __half_raw& x) volatile
133
+ {
134
+ data = x.data;
135
+ return *this;
136
+ }
137
+ volatile __half& operator=(const volatile __half_raw& x) volatile
138
+ {
139
+ data = x.data;
140
+ return *this;
141
+ }
142
+ __half& operator=(__half_raw&& x)
143
+ {
144
+ data = x.data;
145
+ return *this;
146
+ }
147
+ volatile __half& operator=(__half_raw&& x) volatile
148
+ {
149
+ data = x.data;
150
+ return *this;
151
+ }
152
+ volatile __half& operator=(volatile __half_raw&& x) volatile
153
+ {
154
+ data = x.data;
155
+ return *this;
156
+ }
157
+ #if !defined(__HIP_NO_HALF_CONVERSIONS__)
158
+ template<
159
+ typename T,
160
+ Enable_if_t<std::is_floating_point<T>{}>* = nullptr>
161
+ __HOST_DEVICE__
162
+ __half& operator=(T x)
163
+ {
164
+ data = static_cast<_Float16>(x);
165
+ return *this;
166
+ }
167
+ #endif
168
+
169
+ // MANIPULATORS - DEVICE ONLY
170
+ #if !defined(__HIP_NO_HALF_CONVERSIONS__)
171
+ template<
172
+ typename T, Enable_if_t<std::is_integral<T>{}>* = nullptr>
173
+ __device__
174
+ __half& operator=(T x)
175
+ {
176
+ data = static_cast<_Float16>(x);
177
+ return *this;
178
+ }
179
+ #endif
180
+
181
+ #if !defined(__HIP_NO_HALF_OPERATORS__)
182
+ __device__
183
+ __half& operator+=(const __half& x)
184
+ {
185
+ data += x.data;
186
+ return *this;
187
+ }
188
+ __device__
189
+ __half& operator-=(const __half& x)
190
+ {
191
+ data -= x.data;
192
+ return *this;
193
+ }
194
+ __device__
195
+ __half& operator*=(const __half& x)
196
+ {
197
+ data *= x.data;
198
+ return *this;
199
+ }
200
+ __device__
201
+ __half& operator/=(const __half& x)
202
+ {
203
+ data /= x.data;
204
+ return *this;
205
+ }
206
+ __device__
207
+ __half& operator++() { ++data; return *this; }
208
+ __device__
209
+ __half operator++(int)
210
+ {
211
+ __half tmp{*this};
212
+ ++*this;
213
+ return tmp;
214
+ }
215
+ __device__
216
+ __half& operator--() { --data; return *this; }
217
+ __device__
218
+ __half operator--(int)
219
+ {
220
+ __half tmp{*this};
221
+ --*this;
222
+ return tmp;
223
+ }
224
+ #endif
225
+
226
+ // ACCESSORS
227
+ #if !defined(__HIP_NO_HALF_CONVERSIONS__)
228
+ template<
229
+ typename T,
230
+ Enable_if_t<std::is_floating_point<T>{}>* = nullptr>
231
+ __HOST_DEVICE__
232
+ operator T() const { return data; }
233
+ #endif
234
+ __HOST_DEVICE__
235
+ operator __half_raw() const { return __half_raw{data}; }
236
+ __HOST_DEVICE__
237
+ operator __half_raw() const volatile
238
+ {
239
+ return __half_raw{data};
240
+ }
241
+
242
+ #if !defined(__HIP_NO_HALF_CONVERSIONS__)
243
+ template<
244
+ typename T, Enable_if_t<std::is_integral<T>{}>* = nullptr>
245
+ __HOST_DEVICE__
246
+ operator T() const { return data; }
247
+ #endif
248
+
249
+ #if !defined(__HIP_NO_HALF_OPERATORS__)
250
+ __device__
251
+ __half operator+() const { return *this; }
252
+ __device__
253
+ __half operator-() const
254
+ {
255
+ __half tmp{*this};
256
+ tmp.data = -tmp.data;
257
+ return tmp;
258
+ }
259
+ #endif
260
+
261
+ // FRIENDS
262
+ #if !defined(__HIP_NO_HALF_OPERATORS__)
263
+ friend
264
+ inline
265
+ __device__
266
+ __half operator+(const __half& x, const __half& y)
267
+ {
268
+ return __half{x} += y;
269
+ }
270
+ friend
271
+ inline
272
+ __device__
273
+ __half operator-(const __half& x, const __half& y)
274
+ {
275
+ return __half{x} -= y;
276
+ }
277
+ friend
278
+ inline
279
+ __device__
280
+ __half operator*(const __half& x, const __half& y)
281
+ {
282
+ return __half{x} *= y;
283
+ }
284
+ friend
285
+ inline
286
+ __device__
287
+ __half operator/(const __half& x, const __half& y)
288
+ {
289
+ return __half{x} /= y;
290
+ }
291
+ friend
292
+ inline
293
+ __device__
294
+ bool operator==(const __half& x, const __half& y)
295
+ {
296
+ return x.data == y.data;
297
+ }
298
+ friend
299
+ inline
300
+ __device__
301
+ bool operator!=(const __half& x, const __half& y)
302
+ {
303
+ return !(x == y);
304
+ }
305
+ friend
306
+ inline
307
+ __device__
308
+ bool operator<(const __half& x, const __half& y)
309
+ {
310
+ return x.data < y.data;
311
+ }
312
+ friend
313
+ inline
314
+ __device__
315
+ bool operator>(const __half& x, const __half& y)
316
+ {
317
+ return y.data < x.data;
318
+ }
319
+ friend
320
+ inline
321
+ __device__
322
+ bool operator<=(const __half& x, const __half& y)
323
+ {
324
+ return !(y < x);
325
+ }
326
+ friend
327
+ inline
328
+ __device__
329
+ bool operator>=(const __half& x, const __half& y)
330
+ {
331
+ return !(x < y);
332
+ }
333
+ #endif // !defined(__HIP_NO_HALF_OPERATORS__)
334
+ };
335
+ // END STRUCT __HALF
336
+
337
+ // BEGIN STRUCT __HALF2
338
+ struct __half2 {
339
+ public:
340
+ union {
341
+ static_assert(
342
+ sizeof(_Float16_2) == sizeof(unsigned short[2]), "");
343
+
344
+ struct {
345
+ __half x;
346
+ __half y;
347
+ };
348
+ _Float16_2 data;
349
+ };
350
+
351
+ // CREATORS
352
+ __HOST_DEVICE__
353
+ __half2() = default;
354
+ __HOST_DEVICE__
355
+ __half2(const __half2_raw& xx) : data{xx.data} {}
356
+ __HOST_DEVICE__
357
+ __half2(decltype(data) xx) : data{xx} {}
358
+ __HOST_DEVICE__
359
+ __half2(const __half& xx, const __half& yy)
360
+ :
361
+ data{static_cast<__half_raw>(xx).data,
362
+ static_cast<__half_raw>(yy).data}
363
+ {}
364
+ __HOST_DEVICE__
365
+ __half2(const __half2&) = default;
366
+ __HOST_DEVICE__
367
+ __half2(__half2&&) = default;
368
+ __HOST_DEVICE__
369
+ ~__half2() = default;
370
+
371
+ // MANIPULATORS
372
+ __HOST_DEVICE__
373
+ __half2& operator=(const __half2&) = default;
374
+ __HOST_DEVICE__
375
+ __half2& operator=(__half2&&) = default;
376
+ __HOST_DEVICE__
377
+ __half2& operator=(const __half2_raw& xx)
378
+ {
379
+ data = xx.data;
380
+ return *this;
381
+ }
382
+
383
+ // MANIPULATORS - DEVICE ONLY
384
+ #if !defined(__HIP_NO_HALF_OPERATORS__)
385
+ __device__
386
+ __half2& operator+=(const __half2& xx)
387
+ {
388
+ data += xx.data;
389
+ return *this;
390
+ }
391
+ __device__
392
+ __half2& operator-=(const __half2& xx)
393
+ {
394
+ data -= xx.data;
395
+ return *this;
396
+ }
397
+ __device__
398
+ __half2& operator*=(const __half2& xx)
399
+ {
400
+ data *= xx.data;
401
+ return *this;
402
+ }
403
+ __device__
404
+ __half2& operator/=(const __half2& xx)
405
+ {
406
+ data /= xx.data;
407
+ return *this;
408
+ }
409
+ __device__
410
+ __half2& operator++() { return *this += _Float16_2{1, 1}; }
411
+ __device__
412
+ __half2 operator++(int)
413
+ {
414
+ __half2 tmp{*this};
415
+ ++*this;
416
+ return tmp;
417
+ }
418
+ __device__
419
+ __half2& operator--() { return *this -= _Float16_2{1, 1}; }
420
+ __device__
421
+ __half2 operator--(int)
422
+ {
423
+ __half2 tmp{*this};
424
+ --*this;
425
+ return tmp;
426
+ }
427
+ #endif
428
+
429
+ // ACCESSORS
430
+ __HOST_DEVICE__
431
+ operator decltype(data)() const { return data; }
432
+ __HOST_DEVICE__
433
+ operator __half2_raw() const {
434
+ __half2_raw r;
435
+ r.data = data;
436
+ return r;
437
+ }
438
+
439
+ // ACCESSORS - DEVICE ONLY
440
+ #if !defined(__HIP_NO_HALF_OPERATORS__)
441
+ __device__
442
+ __half2 operator+() const { return *this; }
443
+ __device__
444
+ __half2 operator-() const
445
+ {
446
+ __half2 tmp{*this};
447
+ tmp.data = -tmp.data;
448
+ return tmp;
449
+ }
450
+ #endif
451
+
452
+ // FRIENDS
453
+ #if !defined(__HIP_NO_HALF_OPERATORS__)
454
+ friend
455
+ inline
456
+ __device__
457
+ __half2 operator+(const __half2& xx, const __half2& yy)
458
+ {
459
+ return __half2{xx} += yy;
460
+ }
461
+ friend
462
+ inline
463
+ __device__
464
+ __half2 operator-(const __half2& xx, const __half2& yy)
465
+ {
466
+ return __half2{xx} -= yy;
467
+ }
468
+ friend
469
+ inline
470
+ __device__
471
+ __half2 operator*(const __half2& xx, const __half2& yy)
472
+ {
473
+ return __half2{xx} *= yy;
474
+ }
475
+ friend
476
+ inline
477
+ __device__
478
+ __half2 operator/(const __half2& xx, const __half2& yy)
479
+ {
480
+ return __half2{xx} /= yy;
481
+ }
482
+ friend
483
+ inline
484
+ __device__
485
+ bool operator==(const __half2& xx, const __half2& yy)
486
+ {
487
+ auto r = xx.data == yy.data;
488
+ return r.x != 0 && r.y != 0;
489
+ }
490
+ friend
491
+ inline
492
+ __device__
493
+ bool operator!=(const __half2& xx, const __half2& yy)
494
+ {
495
+ return !(xx == yy);
496
+ }
497
+ friend
498
+ inline
499
+ __device__
500
+ bool operator<(const __half2& xx, const __half2& yy)
501
+ {
502
+ auto r = xx.data < yy.data;
503
+ return r.x != 0 && r.y != 0;
504
+ }
505
+ friend
506
+ inline
507
+ __device__
508
+ bool operator>(const __half2& xx, const __half2& yy)
509
+ {
510
+ return yy < xx;
511
+ }
512
+ friend
513
+ inline
514
+ __device__
515
+ bool operator<=(const __half2& xx, const __half2& yy)
516
+ {
517
+ return !(yy < xx);
518
+ }
519
+ friend
520
+ inline
521
+ __device__
522
+ bool operator>=(const __half2& xx, const __half2& yy)
523
+ {
524
+ return !(xx < yy);
525
+ }
526
+ #endif // !defined(__HIP_NO_HALF_OPERATORS__)
527
+ };
528
+ // END STRUCT __HALF2
529
+
530
+ namespace
531
+ {
532
+ inline
533
+ __HOST_DEVICE__
534
+ __half2 make_half2(__half x, __half y)
535
+ {
536
+ return __half2{x, y};
537
+ }
538
+
539
+ inline
540
+ __HOST_DEVICE__
541
+ __half __low2half(__half2 x)
542
+ {
543
+ return __half{__half_raw{static_cast<__half2_raw>(x).data.x}};
544
+ }
545
+
546
+ inline
547
+ __HOST_DEVICE__
548
+ __half __high2half(__half2 x)
549
+ {
550
+ return __half{__half_raw{static_cast<__half2_raw>(x).data.y}};
551
+ }
552
+
553
+ inline
554
+ __HOST_DEVICE__
555
+ __half2 __half2half2(__half x)
556
+ {
557
+ return __half2{x, x};
558
+ }
559
+
560
+ inline
561
+ __HOST_DEVICE__
562
+ __half2 __halves2half2(__half x, __half y)
563
+ {
564
+ return __half2{x, y};
565
+ }
566
+
567
+ inline
568
+ __HOST_DEVICE__
569
+ __half2 __low2half2(__half2 x)
570
+ {
571
+ return __half2{
572
+ _Float16_2{
573
+ static_cast<__half2_raw>(x).data.x,
574
+ static_cast<__half2_raw>(x).data.x}};
575
+ }
576
+
577
+ inline
578
+ __HOST_DEVICE__
579
+ __half2 __high2half2(__half2 x)
580
+ {
581
+ return __half2{
582
+ _Float16_2{
583
+ static_cast<__half2_raw>(x).data.y,
584
+ static_cast<__half2_raw>(x).data.y}};
585
+ }
586
+
587
+ inline
588
+ __HOST_DEVICE__
589
+ __half2 __lows2half2(__half2 x, __half2 y)
590
+ {
591
+ return __half2{
592
+ _Float16_2{
593
+ static_cast<__half2_raw>(x).data.x,
594
+ static_cast<__half2_raw>(y).data.x}};
595
+ }
596
+
597
+ inline
598
+ __HOST_DEVICE__
599
+ __half2 __highs2half2(__half2 x, __half2 y)
600
+ {
601
+ return __half2{
602
+ _Float16_2{
603
+ static_cast<__half2_raw>(x).data.y,
604
+ static_cast<__half2_raw>(y).data.y}};
605
+ }
606
+
607
+ inline
608
+ __HOST_DEVICE__
609
+ __half2 __lowhigh2highlow(__half2 x)
610
+ {
611
+ return __half2{
612
+ _Float16_2{
613
+ static_cast<__half2_raw>(x).data.y,
614
+ static_cast<__half2_raw>(x).data.x}};
615
+ }
616
+
617
+ // Bitcasts
618
+ inline
619
+ __device__
620
+ short __half_as_short(__half x)
621
+ {
622
+ return static_cast<__half_raw>(x).x;
623
+ }
624
+
625
+ inline
626
+ __device__
627
+ unsigned short __half_as_ushort(__half x)
628
+ {
629
+ return static_cast<__half_raw>(x).x;
630
+ }
631
+
632
+ inline
633
+ __device__
634
+ __half __short_as_half(short x)
635
+ {
636
+ __half_raw r; r.x = x;
637
+ return r;
638
+ }
639
+
640
+ inline
641
+ __device__
642
+ __half __ushort_as_half(unsigned short x)
643
+ {
644
+ __half_raw r; r.x = x;
645
+ return r;
646
+ }
647
+
648
+ // float -> half | half2
649
+ inline
650
+ __HOST_DEVICE__
651
+ __half __float2half(float x)
652
+ {
653
+ return __half_raw{static_cast<_Float16>(x)};
654
+ }
655
+ inline
656
+ __HOST_DEVICE__
657
+ __half __float2half_rn(float x)
658
+ {
659
+ return __half_raw{static_cast<_Float16>(x)};
660
+ }
661
+ #if !defined(__HIPCC_RTC__)
662
+ // TODO: rounding behaviour is not correct for host functions.
663
+ inline
664
+ __host__
665
+ __half __float2half_rz(float x)
666
+ {
667
+ return __half_raw{static_cast<_Float16>(x)};
668
+ }
669
+ inline
670
+ __host__
671
+ __half __float2half_rd(float x)
672
+ {
673
+ return __half_raw{static_cast<_Float16>(x)};
674
+ }
675
+ inline
676
+ __host__
677
+ __half __float2half_ru(float x)
678
+ {
679
+ return __half_raw{static_cast<_Float16>(x)};
680
+ }
681
+ #endif
682
+ inline
683
+ __device__
684
+ __half __float2half_rz(float x)
685
+ {
686
+ return __half_raw{__ocml_cvtrtz_f16_f32(x)};
687
+ }
688
+ inline
689
+ __device__
690
+ __half __float2half_rd(float x)
691
+ {
692
+ return __half_raw{__ocml_cvtrtn_f16_f32(x)};
693
+ }
694
+ inline
695
+ __device__
696
+ __half __float2half_ru(float x)
697
+ {
698
+ return __half_raw{__ocml_cvtrtp_f16_f32(x)};
699
+ }
700
+ inline
701
+ __HOST_DEVICE__
702
+ __half2 __float2half2_rn(float x)
703
+ {
704
+ return __half2{
705
+ _Float16_2{
706
+ static_cast<_Float16>(x), static_cast<_Float16>(x)}};
707
+ }
708
+ inline
709
+ __HOST_DEVICE__
710
+ __half2 __floats2half2_rn(float x, float y)
711
+ {
712
+ return __half2{_Float16_2{
713
+ static_cast<_Float16>(x), static_cast<_Float16>(y)}};
714
+ }
715
+ inline
716
+ __HOST_DEVICE__
717
+ __half2 __float22half2_rn(float2 x)
718
+ {
719
+ return __floats2half2_rn(x.x, x.y);
720
+ }
721
+
722
+ // half | half2 -> float
723
+ inline
724
+ __HOST_DEVICE__
725
+ float __half2float(__half x)
726
+ {
727
+ return static_cast<__half_raw>(x).data;
728
+ }
729
+ inline
730
+ __HOST_DEVICE__
731
+ float __low2float(__half2 x)
732
+ {
733
+ return static_cast<__half2_raw>(x).data.x;
734
+ }
735
+ inline
736
+ __HOST_DEVICE__
737
+ float __high2float(__half2 x)
738
+ {
739
+ return static_cast<__half2_raw>(x).data.y;
740
+ }
741
+ inline
742
+ __HOST_DEVICE__
743
+ float2 __half22float2(__half2 x)
744
+ {
745
+ return make_float2(
746
+ static_cast<__half2_raw>(x).data.x,
747
+ static_cast<__half2_raw>(x).data.y);
748
+ }
749
+
750
+ // half -> int
751
+ inline
752
+ __device__
753
+ int __half2int_rn(__half x)
754
+ {
755
+ return static_cast<__half_raw>(x).data;
756
+ }
757
+ inline
758
+ __device__
759
+ int __half2int_rz(__half x)
760
+ {
761
+ return static_cast<__half_raw>(x).data;
762
+ }
763
+ inline
764
+ __device__
765
+ int __half2int_rd(__half x)
766
+ {
767
+ return static_cast<__half_raw>(x).data;
768
+ }
769
+ inline
770
+ __device__
771
+ int __half2int_ru(__half x)
772
+ {
773
+ return static_cast<__half_raw>(x).data;
774
+ }
775
+
776
+ // int -> half
777
+ inline
778
+ __device__
779
+ __half __int2half_rn(int x)
780
+ {
781
+ return __half_raw{static_cast<_Float16>(x)};
782
+ }
783
+ inline
784
+ __device__
785
+ __half __int2half_rz(int x)
786
+ {
787
+ return __half_raw{static_cast<_Float16>(x)};
788
+ }
789
+ inline
790
+ __device__
791
+ __half __int2half_rd(int x)
792
+ {
793
+ return __half_raw{static_cast<_Float16>(x)};
794
+ }
795
+ inline
796
+ __device__
797
+ __half __int2half_ru(int x)
798
+ {
799
+ return __half_raw{static_cast<_Float16>(x)};
800
+ }
801
+
802
+ // half -> short
803
+ inline
804
+ __device__
805
+ short __half2short_rn(__half x)
806
+ {
807
+ return static_cast<__half_raw>(x).data;
808
+ }
809
+ inline
810
+ __device__
811
+ short __half2short_rz(__half x)
812
+ {
813
+ return static_cast<__half_raw>(x).data;
814
+ }
815
+ inline
816
+ __device__
817
+ short __half2short_rd(__half x)
818
+ {
819
+ return static_cast<__half_raw>(x).data;
820
+ }
821
+ inline
822
+ __device__
823
+ short __half2short_ru(__half x)
824
+ {
825
+ return static_cast<__half_raw>(x).data;
826
+ }
827
+
828
+ // short -> half
829
+ inline
830
+ __device__
831
+ __half __short2half_rn(short x)
832
+ {
833
+ return __half_raw{static_cast<_Float16>(x)};
834
+ }
835
+ inline
836
+ __device__
837
+ __half __short2half_rz(short x)
838
+ {
839
+ return __half_raw{static_cast<_Float16>(x)};
840
+ }
841
+ inline
842
+ __device__
843
+ __half __short2half_rd(short x)
844
+ {
845
+ return __half_raw{static_cast<_Float16>(x)};
846
+ }
847
+ inline
848
+ __device__
849
+ __half __short2half_ru(short x)
850
+ {
851
+ return __half_raw{static_cast<_Float16>(x)};
852
+ }
853
+
854
+ // half -> long long
855
+ inline
856
+ __device__
857
+ long long __half2ll_rn(__half x)
858
+ {
859
+ return static_cast<__half_raw>(x).data;
860
+ }
861
+ inline
862
+ __device__
863
+ long long __half2ll_rz(__half x)
864
+ {
865
+ return static_cast<__half_raw>(x).data;
866
+ }
867
+ inline
868
+ __device__
869
+ long long __half2ll_rd(__half x)
870
+ {
871
+ return static_cast<__half_raw>(x).data;
872
+ }
873
+ inline
874
+ __device__
875
+ long long __half2ll_ru(__half x)
876
+ {
877
+ return static_cast<__half_raw>(x).data;
878
+ }
879
+
880
+ // long long -> half
881
+ inline
882
+ __device__
883
+ __half __ll2half_rn(long long x)
884
+ {
885
+ return __half_raw{static_cast<_Float16>(x)};
886
+ }
887
+ inline
888
+ __device__
889
+ __half __ll2half_rz(long long x)
890
+ {
891
+ return __half_raw{static_cast<_Float16>(x)};
892
+ }
893
+ inline
894
+ __device__
895
+ __half __ll2half_rd(long long x)
896
+ {
897
+ return __half_raw{static_cast<_Float16>(x)};
898
+ }
899
+ inline
900
+ __device__
901
+ __half __ll2half_ru(long long x)
902
+ {
903
+ return __half_raw{static_cast<_Float16>(x)};
904
+ }
905
+
906
+ // half -> unsigned int
907
+ inline
908
+ __device__
909
+ unsigned int __half2uint_rn(__half x)
910
+ {
911
+ return static_cast<__half_raw>(x).data;
912
+ }
913
+ inline
914
+ __device__
915
+ unsigned int __half2uint_rz(__half x)
916
+ {
917
+ return static_cast<__half_raw>(x).data;
918
+ }
919
+ inline
920
+ __device__
921
+ unsigned int __half2uint_rd(__half x)
922
+ {
923
+ return static_cast<__half_raw>(x).data;
924
+ }
925
+ inline
926
+ __device__
927
+ unsigned int __half2uint_ru(__half x)
928
+ {
929
+ return static_cast<__half_raw>(x).data;
930
+ }
931
+
932
+ // unsigned int -> half
933
+ inline
934
+ __device__
935
+ __half __uint2half_rn(unsigned int x)
936
+ {
937
+ return __half_raw{static_cast<_Float16>(x)};
938
+ }
939
+ inline
940
+ __device__
941
+ __half __uint2half_rz(unsigned int x)
942
+ {
943
+ return __half_raw{static_cast<_Float16>(x)};
944
+ }
945
+ inline
946
+ __device__
947
+ __half __uint2half_rd(unsigned int x)
948
+ {
949
+ return __half_raw{static_cast<_Float16>(x)};
950
+ }
951
+ inline
952
+ __device__
953
+ __half __uint2half_ru(unsigned int x)
954
+ {
955
+ return __half_raw{static_cast<_Float16>(x)};
956
+ }
957
+
958
+ // half -> unsigned short
959
+ inline
960
+ __device__
961
+ unsigned short __half2ushort_rn(__half x)
962
+ {
963
+ return static_cast<__half_raw>(x).data;
964
+ }
965
+ inline
966
+ __device__
967
+ unsigned short __half2ushort_rz(__half x)
968
+ {
969
+ return static_cast<__half_raw>(x).data;
970
+ }
971
+ inline
972
+ __device__
973
+ unsigned short __half2ushort_rd(__half x)
974
+ {
975
+ return static_cast<__half_raw>(x).data;
976
+ }
977
+ inline
978
+ __device__
979
+ unsigned short __half2ushort_ru(__half x)
980
+ {
981
+ return static_cast<__half_raw>(x).data;
982
+ }
983
+
984
+ // unsigned short -> half
985
+ inline
986
+ __device__
987
+ __half __ushort2half_rn(unsigned short x)
988
+ {
989
+ return __half_raw{static_cast<_Float16>(x)};
990
+ }
991
+ inline
992
+ __device__
993
+ __half __ushort2half_rz(unsigned short x)
994
+ {
995
+ return __half_raw{static_cast<_Float16>(x)};
996
+ }
997
+ inline
998
+ __device__
999
+ __half __ushort2half_rd(unsigned short x)
1000
+ {
1001
+ return __half_raw{static_cast<_Float16>(x)};
1002
+ }
1003
+ inline
1004
+ __device__
1005
+ __half __ushort2half_ru(unsigned short x)
1006
+ {
1007
+ return __half_raw{static_cast<_Float16>(x)};
1008
+ }
1009
+
1010
+ // half -> unsigned long long
1011
+ inline
1012
+ __device__
1013
+ unsigned long long __half2ull_rn(__half x)
1014
+ {
1015
+ return static_cast<__half_raw>(x).data;
1016
+ }
1017
+ inline
1018
+ __device__
1019
+ unsigned long long __half2ull_rz(__half x)
1020
+ {
1021
+ return static_cast<__half_raw>(x).data;
1022
+ }
1023
+ inline
1024
+ __device__
1025
+ unsigned long long __half2ull_rd(__half x)
1026
+ {
1027
+ return static_cast<__half_raw>(x).data;
1028
+ }
1029
+ inline
1030
+ __device__
1031
+ unsigned long long __half2ull_ru(__half x)
1032
+ {
1033
+ return static_cast<__half_raw>(x).data;
1034
+ }
1035
+
1036
+ // unsigned long long -> half
1037
+ inline
1038
+ __device__
1039
+ __half __ull2half_rn(unsigned long long x)
1040
+ {
1041
+ return __half_raw{static_cast<_Float16>(x)};
1042
+ }
1043
+ inline
1044
+ __device__
1045
+ __half __ull2half_rz(unsigned long long x)
1046
+ {
1047
+ return __half_raw{static_cast<_Float16>(x)};
1048
+ }
1049
+ inline
1050
+ __device__
1051
+ __half __ull2half_rd(unsigned long long x)
1052
+ {
1053
+ return __half_raw{static_cast<_Float16>(x)};
1054
+ }
1055
+ inline
1056
+ __device__
1057
+ __half __ull2half_ru(unsigned long long x)
1058
+ {
1059
+ return __half_raw{static_cast<_Float16>(x)};
1060
+ }
1061
+
1062
+ // Load primitives
1063
+ inline
1064
+ __device__
1065
+ __half __ldg(const __half* ptr) { return *ptr; }
1066
+ inline
1067
+ __device__
1068
+ __half __ldcg(const __half* ptr) { return *ptr; }
1069
+ inline
1070
+ __device__
1071
+ __half __ldca(const __half* ptr) { return *ptr; }
1072
+ inline
1073
+ __device__
1074
+ __half __ldcs(const __half* ptr) { return *ptr; }
1075
+
1076
+ inline
1077
+ __HOST_DEVICE__
1078
+ __half2 __ldg(const __half2* ptr) { return *ptr; }
1079
+ inline
1080
+ __HOST_DEVICE__
1081
+ __half2 __ldcg(const __half2* ptr) { return *ptr; }
1082
+ inline
1083
+ __HOST_DEVICE__
1084
+ __half2 __ldca(const __half2* ptr) { return *ptr; }
1085
+ inline
1086
+ __HOST_DEVICE__
1087
+ __half2 __ldcs(const __half2* ptr) { return *ptr; }
1088
+
1089
+ // Relations
1090
+ inline
1091
+ __device__
1092
+ bool __heq(__half x, __half y)
1093
+ {
1094
+ return static_cast<__half_raw>(x).data ==
1095
+ static_cast<__half_raw>(y).data;
1096
+ }
1097
+ inline
1098
+ __device__
1099
+ bool __hne(__half x, __half y)
1100
+ {
1101
+ return static_cast<__half_raw>(x).data !=
1102
+ static_cast<__half_raw>(y).data;
1103
+ }
1104
+ inline
1105
+ __device__
1106
+ bool __hle(__half x, __half y)
1107
+ {
1108
+ return static_cast<__half_raw>(x).data <=
1109
+ static_cast<__half_raw>(y).data;
1110
+ }
1111
+ inline
1112
+ __device__
1113
+ bool __hge(__half x, __half y)
1114
+ {
1115
+ return static_cast<__half_raw>(x).data >=
1116
+ static_cast<__half_raw>(y).data;
1117
+ }
1118
+ inline
1119
+ __device__
1120
+ bool __hlt(__half x, __half y)
1121
+ {
1122
+ return static_cast<__half_raw>(x).data <
1123
+ static_cast<__half_raw>(y).data;
1124
+ }
1125
+ inline
1126
+ __device__
1127
+ bool __hgt(__half x, __half y)
1128
+ {
1129
+ return static_cast<__half_raw>(x).data >
1130
+ static_cast<__half_raw>(y).data;
1131
+ }
1132
+ inline __device__
1133
+ bool __hequ(__half x, __half y) {
1134
+ return !(static_cast<__half_raw>(x).data < static_cast<__half_raw>(y).data) &&
1135
+ !(static_cast<__half_raw>(x).data > static_cast<__half_raw>(y).data);
1136
+ }
1137
+ inline __device__
1138
+ bool __hneu(__half x, __half y) {
1139
+ return !(static_cast<__half_raw>(x).data == static_cast<__half_raw>(y).data);
1140
+ }
1141
+ inline __device__
1142
+ bool __hleu(__half x, __half y) {
1143
+ return !(static_cast<__half_raw>(x).data > static_cast<__half_raw>(y).data);
1144
+ }
1145
+ inline
1146
+ __device__
1147
+ bool __hgeu(__half x, __half y) {
1148
+ return !(static_cast<__half_raw>(x).data < static_cast<__half_raw>(y).data);
1149
+ }
1150
+ inline
1151
+ __device__
1152
+ bool __hltu(__half x, __half y) {
1153
+ return !(static_cast<__half_raw>(x).data >= static_cast<__half_raw>(y).data);
1154
+ }
1155
+ inline
1156
+ __device__
1157
+ bool __hgtu(__half x, __half y) {
1158
+ return !(static_cast<__half_raw>(x).data <= static_cast<__half_raw>(y).data);
1159
+ }
1160
+
1161
+ inline
1162
+ __HOST_DEVICE__
1163
+ __half2 __heq2(__half2 x, __half2 y)
1164
+ {
1165
+ auto r = static_cast<__half2_raw>(x).data ==
1166
+ static_cast<__half2_raw>(y).data;
1167
+ return __builtin_convertvector(-r, _Float16_2);
1168
+ }
1169
+ inline
1170
+ __HOST_DEVICE__
1171
+ __half2 __hne2(__half2 x, __half2 y)
1172
+ {
1173
+ auto r = static_cast<__half2_raw>(x).data !=
1174
+ static_cast<__half2_raw>(y).data;
1175
+ return __builtin_convertvector(-r, _Float16_2);
1176
+ }
1177
+ inline
1178
+ __HOST_DEVICE__
1179
+ __half2 __hle2(__half2 x, __half2 y)
1180
+ {
1181
+ auto r = static_cast<__half2_raw>(x).data <=
1182
+ static_cast<__half2_raw>(y).data;
1183
+ return __builtin_convertvector(-r, _Float16_2);
1184
+ }
1185
+ inline
1186
+ __HOST_DEVICE__
1187
+ __half2 __hge2(__half2 x, __half2 y)
1188
+ {
1189
+ auto r = static_cast<__half2_raw>(x).data >=
1190
+ static_cast<__half2_raw>(y).data;
1191
+ return __builtin_convertvector(-r, _Float16_2);
1192
+ }
1193
+ inline
1194
+ __HOST_DEVICE__
1195
+ __half2 __hlt2(__half2 x, __half2 y)
1196
+ {
1197
+ auto r = static_cast<__half2_raw>(x).data <
1198
+ static_cast<__half2_raw>(y).data;
1199
+ return __builtin_convertvector(-r, _Float16_2);
1200
+ }
1201
+ inline
1202
+ __HOST_DEVICE__
1203
+ __half2 __hgt2(__half2 x, __half2 y)
1204
+ {
1205
+ auto r = static_cast<__half2_raw>(x).data >
1206
+ static_cast<__half2_raw>(y).data;
1207
+ return __builtin_convertvector(-r, _Float16_2);
1208
+ }
1209
+ inline __HOST_DEVICE__
1210
+ __half2 __hequ2(__half2 x, __half2 y) {
1211
+ auto r = !(static_cast<__half2_raw>(x).data < static_cast<__half2_raw>(y).data) &&
1212
+ !(static_cast<__half2_raw>(x).data > static_cast<__half2_raw>(y).data);
1213
+ return __builtin_convertvector(-r, _Float16_2);
1214
+ }
1215
+ inline
1216
+ __HOST_DEVICE__
1217
+ __half2 __hneu2(__half2 x, __half2 y) {
1218
+ auto r = !(static_cast<__half2_raw>(x).data == static_cast<__half2_raw>(y).data);
1219
+ return __builtin_convertvector(-r, _Float16_2);
1220
+ }
1221
+ inline
1222
+ __HOST_DEVICE__
1223
+ __half2 __hleu2(__half2 x, __half2 y) {
1224
+ auto r = !(static_cast<__half2_raw>(x).data > static_cast<__half2_raw>(y).data);
1225
+ return __builtin_convertvector(-r, _Float16_2);
1226
+ }
1227
+ inline
1228
+ __HOST_DEVICE__
1229
+ __half2 __hgeu2(__half2 x, __half2 y) {
1230
+ auto r = !(static_cast<__half2_raw>(x).data < static_cast<__half2_raw>(y).data);
1231
+ return __builtin_convertvector(-r, _Float16_2);
1232
+ }
1233
+ inline
1234
+ __HOST_DEVICE__
1235
+ __half2 __hltu2(__half2 x, __half2 y) {
1236
+ auto r = !(static_cast<__half2_raw>(x).data >= static_cast<__half2_raw>(y).data);
1237
+ return __builtin_convertvector(-r, _Float16_2);
1238
+ }
1239
+ inline
1240
+ __HOST_DEVICE__
1241
+ __half2 __hgtu2(__half2 x, __half2 y) {
1242
+ auto r = !(static_cast<__half2_raw>(x).data <= static_cast<__half2_raw>(y).data);
1243
+ return __builtin_convertvector(-r, _Float16_2);
1244
+ }
1245
+
1246
+ inline
1247
+ __HOST_DEVICE__
1248
+ bool __hbeq2(__half2 x, __half2 y)
1249
+ {
1250
+ auto r = static_cast<__half2_raw>(__heq2(x, y));
1251
+ return r.data.x != 0 && r.data.y != 0;
1252
+ }
1253
+ inline
1254
+ __HOST_DEVICE__
1255
+ bool __hbne2(__half2 x, __half2 y)
1256
+ {
1257
+ auto r = static_cast<__half2_raw>(__hne2(x, y));
1258
+ return r.data.x != 0 && r.data.y != 0;
1259
+ }
1260
+ inline
1261
+ __HOST_DEVICE__
1262
+ bool __hble2(__half2 x, __half2 y)
1263
+ {
1264
+ auto r = static_cast<__half2_raw>(__hle2(x, y));
1265
+ return r.data.x != 0 && r.data.y != 0;
1266
+ }
1267
+ inline
1268
+ __HOST_DEVICE__
1269
+ bool __hbge2(__half2 x, __half2 y)
1270
+ {
1271
+ auto r = static_cast<__half2_raw>(__hge2(x, y));
1272
+ return r.data.x != 0 && r.data.y != 0;
1273
+ }
1274
+ inline
1275
+ __HOST_DEVICE__
1276
+ bool __hblt2(__half2 x, __half2 y)
1277
+ {
1278
+ auto r = static_cast<__half2_raw>(__hlt2(x, y));
1279
+ return r.data.x != 0 && r.data.y != 0;
1280
+ }
1281
+ inline
1282
+ __HOST_DEVICE__
1283
+ bool __hbgt2(__half2 x, __half2 y)
1284
+ {
1285
+ auto r = static_cast<__half2_raw>(__hgt2(x, y));
1286
+ return r.data.x != 0 && r.data.y != 0;
1287
+ }
1288
+ inline
1289
+ __HOST_DEVICE__
1290
+ bool __hbequ2(__half2 x, __half2 y) { return __hbeq2(x, y); }
1291
+ inline
1292
+ __HOST_DEVICE__
1293
+ bool __hbneu2(__half2 x, __half2 y) { return __hbne2(x, y); }
1294
+ inline
1295
+ __HOST_DEVICE__
1296
+ bool __hbleu2(__half2 x, __half2 y) { return __hble2(x, y); }
1297
+ inline
1298
+ __HOST_DEVICE__
1299
+ bool __hbgeu2(__half2 x, __half2 y) { return __hbge2(x, y); }
1300
+ inline
1301
+ __HOST_DEVICE__
1302
+ bool __hbltu2(__half2 x, __half2 y) { return __hblt2(x, y); }
1303
+ inline
1304
+ __HOST_DEVICE__
1305
+ bool __hbgtu2(__half2 x, __half2 y) { return __hbgt2(x, y); }
1306
+ inline
1307
+ __device__
1308
+ __half __hmax(const __half x, const __half y) {
1309
+ return __half_raw{__ocml_fmax_f16(static_cast<__half_raw>(x).data,
1310
+ static_cast<__half_raw>(y).data)};
1311
+ }
1312
+ inline
1313
+ __device__
1314
+ __half __hmax_nan(const __half x, const __half y) {
1315
+ if(__ocml_isnan_f16(static_cast<__half_raw>(x).data)) {
1316
+ return x;
1317
+ } else if (__ocml_isnan_f16(static_cast<__half_raw>(y).data)) {
1318
+ return y;
1319
+ }
1320
+ return __hmax(x, y);
1321
+ }
1322
+ inline
1323
+ __device__
1324
+ __half __hmin(const __half x, const __half y) {
1325
+ return __half_raw{__ocml_fmin_f16(static_cast<__half_raw>(x).data,
1326
+ static_cast<__half_raw>(y).data)};
1327
+ }
1328
+ inline
1329
+ __device__
1330
+ __half __hmin_nan(const __half x, const __half y) {
1331
+ if(__ocml_isnan_f16(static_cast<__half_raw>(x).data)) {
1332
+ return x;
1333
+ } else if (__ocml_isnan_f16(static_cast<__half_raw>(y).data)) {
1334
+ return y;
1335
+ }
1336
+ return __hmin(x, y);
1337
+ }
1338
+
1339
+ // Arithmetic
1340
+ inline
1341
+ __device__
1342
+ __half __clamp_01(__half x)
1343
+ {
1344
+ auto r = static_cast<__half_raw>(x);
1345
+
1346
+ if (__hlt(x, __half_raw{0})) return __half_raw{0};
1347
+ if (__hlt(__half_raw{1}, x)) return __half_raw{1};
1348
+ return r;
1349
+ }
1350
+
1351
+ inline
1352
+ __device__
1353
+ __half __hadd(__half x, __half y)
1354
+ {
1355
+ return __half_raw{
1356
+ static_cast<__half_raw>(x).data +
1357
+ static_cast<__half_raw>(y).data};
1358
+ }
1359
+ inline
1360
+ __device__
1361
+ __half __habs(__half x)
1362
+ {
1363
+ return __half_raw{
1364
+ __ocml_fabs_f16(static_cast<__half_raw>(x).data)};
1365
+ }
1366
+ inline
1367
+ __device__
1368
+ __half __hsub(__half x, __half y)
1369
+ {
1370
+ return __half_raw{
1371
+ static_cast<__half_raw>(x).data -
1372
+ static_cast<__half_raw>(y).data};
1373
+ }
1374
+ inline
1375
+ __device__
1376
+ __half __hmul(__half x, __half y)
1377
+ {
1378
+ return __half_raw{
1379
+ static_cast<__half_raw>(x).data *
1380
+ static_cast<__half_raw>(y).data};
1381
+ }
1382
+ inline
1383
+ __device__
1384
+ __half __hadd_sat(__half x, __half y)
1385
+ {
1386
+ return __clamp_01(__hadd(x, y));
1387
+ }
1388
+ inline
1389
+ __device__
1390
+ __half __hsub_sat(__half x, __half y)
1391
+ {
1392
+ return __clamp_01(__hsub(x, y));
1393
+ }
1394
+ inline
1395
+ __device__
1396
+ __half __hmul_sat(__half x, __half y)
1397
+ {
1398
+ return __clamp_01(__hmul(x, y));
1399
+ }
1400
+ inline
1401
+ __device__
1402
+ __half __hfma(__half x, __half y, __half z)
1403
+ {
1404
+ return __half_raw{__ocml_fma_f16(
1405
+ static_cast<__half_raw>(x).data,
1406
+ static_cast<__half_raw>(y).data,
1407
+ static_cast<__half_raw>(z).data)};
1408
+ }
1409
+ inline
1410
+ __device__
1411
+ __half __hfma_sat(__half x, __half y, __half z)
1412
+ {
1413
+ return __clamp_01(__hfma(x, y, z));
1414
+ }
1415
+ inline
1416
+ __device__
1417
+ __half __hdiv(__half x, __half y)
1418
+ {
1419
+ return __half_raw{
1420
+ static_cast<__half_raw>(x).data /
1421
+ static_cast<__half_raw>(y).data};
1422
+ }
1423
+
1424
+ inline
1425
+ __HOST_DEVICE__
1426
+ __half2 __hadd2(__half2 x, __half2 y)
1427
+ {
1428
+ return __half2{
1429
+ static_cast<__half2_raw>(x).data +
1430
+ static_cast<__half2_raw>(y).data};
1431
+ }
1432
+ inline
1433
+ __HOST_DEVICE__
1434
+ __half2 __habs2(__half2 x)
1435
+ {
1436
+ return __half2{
1437
+ __ocml_fabs_2f16(static_cast<__half2_raw>(x).data)};
1438
+ }
1439
+ inline
1440
+ __HOST_DEVICE__
1441
+ __half2 __hsub2(__half2 x, __half2 y)
1442
+ {
1443
+ return __half2{
1444
+ static_cast<__half2_raw>(x).data -
1445
+ static_cast<__half2_raw>(y).data};
1446
+ }
1447
+ inline
1448
+ __HOST_DEVICE__
1449
+ __half2 __hmul2(__half2 x, __half2 y)
1450
+ {
1451
+ return __half2{
1452
+ static_cast<__half2_raw>(x).data *
1453
+ static_cast<__half2_raw>(y).data};
1454
+ }
1455
+ inline
1456
+ __HOST_DEVICE__
1457
+ __half2 __hadd2_sat(__half2 x, __half2 y)
1458
+ {
1459
+ auto r = static_cast<__half2_raw>(__hadd2(x, y));
1460
+ return __half2{
1461
+ __clamp_01(__half_raw{r.data.x}),
1462
+ __clamp_01(__half_raw{r.data.y})};
1463
+ }
1464
+ inline
1465
+ __HOST_DEVICE__
1466
+ __half2 __hsub2_sat(__half2 x, __half2 y)
1467
+ {
1468
+ auto r = static_cast<__half2_raw>(__hsub2(x, y));
1469
+ return __half2{
1470
+ __clamp_01(__half_raw{r.data.x}),
1471
+ __clamp_01(__half_raw{r.data.y})};
1472
+ }
1473
+ inline
1474
+ __HOST_DEVICE__
1475
+ __half2 __hmul2_sat(__half2 x, __half2 y)
1476
+ {
1477
+ auto r = static_cast<__half2_raw>(__hmul2(x, y));
1478
+ return __half2{
1479
+ __clamp_01(__half_raw{r.data.x}),
1480
+ __clamp_01(__half_raw{r.data.y})};
1481
+ }
1482
+ inline
1483
+ __HOST_DEVICE__
1484
+ __half2 __hfma2(__half2 x, __half2 y, __half2 z)
1485
+ {
1486
+ return __half2{__ocml_fma_2f16(x, y, z)};
1487
+ }
1488
+ inline
1489
+ __HOST_DEVICE__
1490
+ __half2 __hfma2_sat(__half2 x, __half2 y, __half2 z)
1491
+ {
1492
+ auto r = static_cast<__half2_raw>(__hfma2(x, y, z));
1493
+ return __half2{
1494
+ __clamp_01(__half_raw{r.data.x}),
1495
+ __clamp_01(__half_raw{r.data.y})};
1496
+ }
1497
+ inline
1498
+ __HOST_DEVICE__
1499
+ __half2 __h2div(__half2 x, __half2 y)
1500
+ {
1501
+ return __half2{
1502
+ static_cast<__half2_raw>(x).data /
1503
+ static_cast<__half2_raw>(y).data};
1504
+ }
1505
+
1506
+ // Math functions
1507
+ #if defined(__clang__) && defined(__HIP__)
1508
+ inline
1509
+ __device__
1510
+ float amd_mixed_dot(__half2 a, __half2 b, float c, bool saturate) {
1511
+ return __ockl_fdot2(static_cast<__half2_raw>(a).data,
1512
+ static_cast<__half2_raw>(b).data,
1513
+ c, saturate);
1514
+ }
1515
+ #endif
1516
+ inline
1517
+ __device__
1518
+ __half htrunc(__half x)
1519
+ {
1520
+ return __half_raw{
1521
+ __ocml_trunc_f16(static_cast<__half_raw>(x).data)};
1522
+ }
1523
+ inline
1524
+ __device__
1525
+ __half hceil(__half x)
1526
+ {
1527
+ return __half_raw{
1528
+ __ocml_ceil_f16(static_cast<__half_raw>(x).data)};
1529
+ }
1530
+ inline
1531
+ __device__
1532
+ __half hfloor(__half x)
1533
+ {
1534
+ return __half_raw{
1535
+ __ocml_floor_f16(static_cast<__half_raw>(x).data)};
1536
+ }
1537
+ inline
1538
+ __device__
1539
+ __half hrint(__half x)
1540
+ {
1541
+ return __half_raw{
1542
+ __ocml_rint_f16(static_cast<__half_raw>(x).data)};
1543
+ }
1544
+ inline
1545
+ __device__
1546
+ __half hsin(__half x)
1547
+ {
1548
+ return __half_raw{
1549
+ __ocml_sin_f16(static_cast<__half_raw>(x).data)};
1550
+ }
1551
+ inline
1552
+ __device__
1553
+ __half hcos(__half x)
1554
+ {
1555
+ return __half_raw{
1556
+ __ocml_cos_f16(static_cast<__half_raw>(x).data)};
1557
+ }
1558
+ inline
1559
+ __device__
1560
+ __half hexp(__half x)
1561
+ {
1562
+ return __half_raw{
1563
+ __ocml_exp_f16(static_cast<__half_raw>(x).data)};
1564
+ }
1565
+ inline
1566
+ __device__
1567
+ __half hexp2(__half x)
1568
+ {
1569
+ return __half_raw{
1570
+ __ocml_exp2_f16(static_cast<__half_raw>(x).data)};
1571
+ }
1572
+ inline
1573
+ __device__
1574
+ __half hexp10(__half x)
1575
+ {
1576
+ return __half_raw{
1577
+ __ocml_exp10_f16(static_cast<__half_raw>(x).data)};
1578
+ }
1579
+ inline
1580
+ __device__
1581
+ __half hlog2(__half x)
1582
+ {
1583
+ return __half_raw{
1584
+ __ocml_log2_f16(static_cast<__half_raw>(x).data)};
1585
+ }
1586
+ inline
1587
+ __device__
1588
+ __half hlog(__half x)
1589
+ {
1590
+ return __half_raw{
1591
+ __ocml_log_f16(static_cast<__half_raw>(x).data)};
1592
+ }
1593
+ inline
1594
+ __device__
1595
+ __half hlog10(__half x)
1596
+ {
1597
+ return __half_raw{
1598
+ __ocml_log10_f16(static_cast<__half_raw>(x).data)};
1599
+ }
1600
+ inline
1601
+ __device__
1602
+ __half hrcp(__half x)
1603
+ {
1604
+ return __half_raw{
1605
+ static_cast<_Float16>(1.0f) /static_cast<__half_raw>(x).data};
1606
+ }
1607
+ inline
1608
+ __device__
1609
+ __half hrsqrt(__half x)
1610
+ {
1611
+ return __half_raw{
1612
+ __ocml_rsqrt_f16(static_cast<__half_raw>(x).data)};
1613
+ }
1614
+ inline
1615
+ __device__
1616
+ __half hsqrt(__half x)
1617
+ {
1618
+ return __half_raw{
1619
+ __ocml_sqrt_f16(static_cast<__half_raw>(x).data)};
1620
+ }
1621
+ inline
1622
+ __device__
1623
+ bool __hisinf(__half x)
1624
+ {
1625
+ return __ocml_isinf_f16(static_cast<__half_raw>(x).data);
1626
+ }
1627
+ inline
1628
+ __device__
1629
+ bool __hisnan(__half x)
1630
+ {
1631
+ return __ocml_isnan_f16(static_cast<__half_raw>(x).data);
1632
+ }
1633
+ inline
1634
+ __device__
1635
+ __half __hneg(__half x)
1636
+ {
1637
+ return __half_raw{-static_cast<__half_raw>(x).data};
1638
+ }
1639
+
1640
+ inline
1641
+ __HOST_DEVICE__
1642
+ __half2 h2trunc(__half2 x)
1643
+ {
1644
+ return __half2{__ocml_trunc_2f16(x)};
1645
+ }
1646
+ inline
1647
+ __HOST_DEVICE__
1648
+ __half2 h2ceil(__half2 x)
1649
+ {
1650
+ return __half2{__ocml_ceil_2f16(x)};
1651
+ }
1652
+ inline
1653
+ __HOST_DEVICE__
1654
+ __half2 h2floor(__half2 x)
1655
+ {
1656
+ return __half2{__ocml_floor_2f16(x)};
1657
+ }
1658
+ inline
1659
+ __HOST_DEVICE__
1660
+ __half2 h2rint(__half2 x)
1661
+ {
1662
+ return __half2{__ocml_rint_2f16(x)};
1663
+ }
1664
+ inline
1665
+ __HOST_DEVICE__
1666
+ __half2 h2sin(__half2 x)
1667
+ {
1668
+ return __half2{__ocml_sin_2f16(x)};
1669
+ }
1670
+ inline
1671
+ __HOST_DEVICE__
1672
+ __half2 h2cos(__half2 x)
1673
+ {
1674
+ return __half2{__ocml_cos_2f16(x)};
1675
+ }
1676
+ inline
1677
+ __HOST_DEVICE__
1678
+ __half2 h2exp(__half2 x)
1679
+ {
1680
+ return __half2{__ocml_exp_2f16(x)};
1681
+ }
1682
+ inline
1683
+ __HOST_DEVICE__
1684
+ __half2 h2exp2(__half2 x)
1685
+ {
1686
+ return __half2{__ocml_exp2_2f16(x)};
1687
+ }
1688
+ inline
1689
+ __HOST_DEVICE__
1690
+ __half2 h2exp10(__half2 x)
1691
+ {
1692
+ return __half2{__ocml_exp10_2f16(x)};
1693
+ }
1694
+ inline
1695
+ __HOST_DEVICE__
1696
+ __half2 h2log2(__half2 x)
1697
+ {
1698
+ return __half2{__ocml_log2_2f16(x)};
1699
+ }
1700
+ inline
1701
+ __HOST_DEVICE__
1702
+ __half2 h2log(__half2 x) { return __ocml_log_2f16(x); }
1703
+ inline
1704
+ __HOST_DEVICE__
1705
+ __half2 h2log10(__half2 x) { return __ocml_log10_2f16(x); }
1706
+ inline
1707
+ __HOST_DEVICE__
1708
+ __half2 h2rcp(__half2 x) {
1709
+ return _Float16_2{
1710
+ _Float16_2{static_cast<_Float16>(1.0f), static_cast<_Float16>(1.0f)} / x.data};
1711
+ }
1712
+ inline
1713
+ __HOST_DEVICE__
1714
+ __half2 h2rsqrt(__half2 x) { return __ocml_rsqrt_2f16(x); }
1715
+ inline
1716
+ __HOST_DEVICE__
1717
+ __half2 h2sqrt(__half2 x) { return __ocml_sqrt_2f16(x); }
1718
+ inline
1719
+ __HOST_DEVICE__
1720
+ __half2 __hisinf2(__half2 x)
1721
+ {
1722
+ auto r = __ocml_isinf_2f16(x);
1723
+ return __half2{_Float16_2{
1724
+ static_cast<_Float16>(r.x), static_cast<_Float16>(r.y)}};
1725
+ }
1726
+ inline
1727
+ __HOST_DEVICE__
1728
+ __half2 __hisnan2(__half2 x)
1729
+ {
1730
+ auto r = __ocml_isnan_2f16(x);
1731
+ return __half2{_Float16_2{
1732
+ static_cast<_Float16>(r.x), static_cast<_Float16>(r.y)}};
1733
+ }
1734
+ inline
1735
+ __HOST_DEVICE__
1736
+ __half2 __hneg2(__half2 x)
1737
+ {
1738
+ return __half2{-static_cast<__half2_raw>(x).data};
1739
+ }
1740
+ } // Anonymous namespace.
1741
+
1742
+ #if !defined(HIP_NO_HALF)
1743
+ using half = __half;
1744
+ using half2 = __half2;
1745
+ #endif
1746
+ __device__
1747
+ inline
1748
+ __half __shfl(__half var, int src_lane, int width = warpSize) {
1749
+ union { int i; __half h; } tmp; tmp.h = var;
1750
+ tmp.i = __shfl(tmp.i, src_lane, width);
1751
+ return tmp.h;
1752
+ }
1753
+ __device__
1754
+ inline
1755
+ __half2 __shfl(__half2 var, int src_lane, int width = warpSize) {
1756
+ union { int i; __half2 h; } tmp; tmp.h = var;
1757
+ tmp.i = __shfl(tmp.i, src_lane, width);
1758
+ return tmp.h;
1759
+ }
1760
+ __device__
1761
+ inline
1762
+ __half __shfl_up(__half var, unsigned int lane_delta, int width = warpSize) {
1763
+ union { int i; __half h; } tmp; tmp.h = var;
1764
+ tmp.i = __shfl_up(tmp.i, lane_delta, width);
1765
+ return tmp.h;
1766
+ }
1767
+ __device__
1768
+ inline
1769
+ __half2 __shfl_up(__half2 var, unsigned int lane_delta, int width = warpSize) {
1770
+ union { int i; __half2 h; } tmp; tmp.h = var;
1771
+ tmp.i = __shfl_up(tmp.i, lane_delta, width);
1772
+ return tmp.h;
1773
+ }
1774
+ __device__
1775
+ inline
1776
+ __half __shfl_down(__half var, unsigned int lane_delta, int width = warpSize) {
1777
+ union { int i; __half h; } tmp; tmp.h = var;
1778
+ tmp.i = __shfl_down(tmp.i, lane_delta, width);
1779
+ return tmp.h;
1780
+ }
1781
+ __device__
1782
+ inline
1783
+ __half2 __shfl_down(__half2 var, unsigned int lane_delta, int width = warpSize) {
1784
+ union { int i; __half2 h; } tmp; tmp.h = var;
1785
+ tmp.i = __shfl_down(tmp.i, lane_delta, width);
1786
+ return tmp.h;
1787
+ }
1788
+ __device__
1789
+ inline
1790
+ __half __shfl_xor(__half var, int lane_mask, int width = warpSize) {
1791
+ union { int i; __half h; } tmp; tmp.h = var;
1792
+ tmp.i = __shfl_xor(tmp.i, lane_mask, width);
1793
+ return tmp.h;
1794
+ }
1795
+ __device__
1796
+ inline
1797
+ __half2 __shfl_xor(__half2 var, int lane_mask, int width = warpSize) {
1798
+ union { int i; __half2 h; } tmp; tmp.h = var;
1799
+ tmp.i = __shfl_xor(tmp.i, lane_mask, width);
1800
+ return tmp.h;
1801
+ }
1802
+ #endif // defined(__cplusplus)
1803
+ #elif defined(__GNUC__)
1804
+ #if !defined(__HIPCC_RTC__)
1805
+ #include "hip_fp16_gcc.h"
1806
+ #endif
1807
+ #endif // !defined(__clang__) && defined(__GNUC__)
1808
+
1809
+ #endif // HIP_INCLUDE_HIP_AMD_DETAIL_HIP_FP16_H
.venv/lib/python3.11/site-packages/triton/backends/amd/include/hip/amd_detail/concepts.hpp ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+ */
22
+
23
+ #pragma once
24
+
25
+ namespace hip_impl // Documentation only.
26
+ {
27
+ #define requires(...)
28
+
29
+ #define FunctionalProcedure typename
30
+ } // namespace hip_impl
.venv/lib/python3.11/site-packages/triton/backends/amd/include/hip/amd_detail/macro_based_grid_launch.hpp ADDED
@@ -0,0 +1,798 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+ */
22
+
23
+ #pragma once
24
+
25
+ #include "concepts.hpp"
26
+ #include "helpers.hpp"
27
+
28
+ #include "hc.hpp"
29
+ #include "hip/hip_ext.h"
30
+ #include "hip_runtime.h"
31
+
32
+ #include <functional>
33
+ #include <iostream>
34
+ #include <stdexcept>
35
+ #include <type_traits>
36
+ #include <utility>
37
+
38
+ namespace hip_impl {
39
+ namespace {
40
+ struct New_grid_launch_tag {};
41
+ struct Old_grid_launch_tag {};
42
+
43
+ template <typename C, typename D>
44
+ class RAII_guard {
45
+ D dtor_;
46
+
47
+ public:
48
+ RAII_guard() = default;
49
+
50
+ RAII_guard(const C& ctor, D dtor) : dtor_{std::move(dtor)} { ctor(); }
51
+
52
+ RAII_guard(const RAII_guard&) = default;
53
+ RAII_guard(RAII_guard&&) = default;
54
+
55
+ RAII_guard& operator=(const RAII_guard&) = default;
56
+ RAII_guard& operator=(RAII_guard&&) = default;
57
+
58
+ ~RAII_guard() { dtor_(); }
59
+ };
60
+
61
+ template <typename C, typename D>
62
+ RAII_guard<C, D> make_RAII_guard(const C& ctor, D dtor) {
63
+ return RAII_guard<C, D>{ctor, std::move(dtor)};
64
+ }
65
+
66
+ template <FunctionalProcedure F, typename... Ts>
67
+ using is_new_grid_launch_t = typename std::conditional<is_callable<F(Ts...)>{}, New_grid_launch_tag,
68
+ Old_grid_launch_tag>::type;
69
+ } // namespace
70
+
71
+ // TODO: - dispatch rank should be derived from the domain dimensions passed
72
+ // in, and not always assumed to be 3;
73
+
74
+ template <FunctionalProcedure K, typename... Ts>
75
+ requires(Domain<K> ==
76
+ {Ts...}) inline void grid_launch_hip_impl_(New_grid_launch_tag, dim3 num_blocks,
77
+ dim3 dim_blocks, int group_mem_bytes,
78
+ const hc::accelerator_view& acc_v, K k) {
79
+ const auto d =
80
+ hc::extent<3>{num_blocks.z * dim_blocks.z, num_blocks.y * dim_blocks.y,
81
+ num_blocks.x * dim_blocks.x}
82
+ .tile_with_dynamic(dim_blocks.z, dim_blocks.y, dim_blocks.x, group_mem_bytes);
83
+
84
+ try {
85
+ hc::parallel_for_each(acc_v, d, k);
86
+ } catch (std::exception& ex) {
87
+ std::cerr << "Failed in " << __func__ << ", with exception: " << ex.what() << std::endl;
88
+ hip_throw(ex);
89
+ }
90
+ }
91
+
92
+ // TODO: these are workarounds, they should be removed.
93
+
94
+ hc::accelerator_view lock_stream_hip_(hipStream_t&, void*&);
95
+ void print_prelaunch_trace_(const char*, dim3, dim3, int, hipStream_t);
96
+ void unlock_stream_hip_(hipStream_t, void*, const char*, hc::accelerator_view*);
97
+
98
+ template <FunctionalProcedure K, typename... Ts>
99
+ requires(Domain<K> == {Ts...}) inline void grid_launch_hip_impl_(New_grid_launch_tag,
100
+ dim3 num_blocks, dim3 dim_blocks,
101
+ int group_mem_bytes,
102
+ hipStream_t stream,
103
+ const char* kernel_name, K k) {
104
+ void* lck_stream = nullptr;
105
+ auto acc_v = lock_stream_hip_(stream, lck_stream);
106
+ auto stream_guard =
107
+ make_RAII_guard(std::bind(print_prelaunch_trace_, kernel_name, num_blocks, dim_blocks,
108
+ group_mem_bytes, stream),
109
+ std::bind(unlock_stream_hip_, stream, lck_stream, kernel_name, &acc_v));
110
+
111
+ try {
112
+ grid_launch_hip_impl_(New_grid_launch_tag{}, std::move(num_blocks), std::move(dim_blocks),
113
+ group_mem_bytes, acc_v, std::move(k));
114
+ } catch (std::exception& ex) {
115
+ std::cerr << "Failed in " << __func__ << ", with exception: " << ex.what() << std::endl;
116
+ hip_throw(ex);
117
+ }
118
+ }
119
+
120
+ template <FunctionalProcedure K, typename... Ts>
121
+ requires(Domain<K> ==
122
+ {hipLaunchParm, Ts...}) inline void grid_launch_hip_impl_(Old_grid_launch_tag,
123
+ dim3 num_blocks, dim3 dim_blocks,
124
+ int group_mem_bytes,
125
+ hipStream_t stream, K k) {
126
+ grid_launch_hip_impl_(New_grid_launch_tag{}, std::move(num_blocks), std::move(dim_blocks),
127
+ group_mem_bytes, std::move(stream), std::move(k));
128
+ }
129
+
130
+ template <FunctionalProcedure K, typename... Ts>
131
+ requires(Domain<K> == {hipLaunchParm, Ts...}) inline void grid_launch_hip_impl_(
132
+ Old_grid_launch_tag, dim3 num_blocks, dim3 dim_blocks, int group_mem_bytes, hipStream_t stream,
133
+ const char* kernel_name, K k) {
134
+ grid_launch_hip_impl_(New_grid_launch_tag{}, std::move(num_blocks), std::move(dim_blocks),
135
+ group_mem_bytes, std::move(stream), kernel_name, std::move(k));
136
+ }
137
+
138
+ template <FunctionalProcedure K, typename... Ts>
139
+ requires(Domain<K> == {Ts...}) inline std::enable_if_t<
140
+ !std::is_function<K>::value> grid_launch_hip_(dim3 num_blocks, dim3 dim_blocks,
141
+ int group_mem_bytes, hipStream_t stream,
142
+ const char* kernel_name, K k) {
143
+ grid_launch_hip_impl_(is_new_grid_launch_t<K, Ts...>{}, std::move(num_blocks),
144
+ std::move(dim_blocks), group_mem_bytes, std::move(stream), kernel_name,
145
+ std::move(k));
146
+ }
147
+
148
+ template <FunctionalProcedure K, typename... Ts>
149
+ requires(Domain<K> == {Ts...}) inline std::enable_if_t<
150
+ !std::is_function<K>::value> grid_launch_hip_(dim3 num_blocks, dim3 dim_blocks,
151
+ int group_mem_bytes, hipStream_t stream, K k) {
152
+ grid_launch_hip_impl_(is_new_grid_launch_t<K, Ts...>{}, std::move(num_blocks),
153
+ std::move(dim_blocks), group_mem_bytes, std::move(stream), std::move(k));
154
+ }
155
+
156
+ // TODO: these are temporary and purposefully noisy and disruptive.
157
+ #define make_kernel_name_hip(k, n) \
158
+ HIP_kernel_functor_name_begin##_##k##_##HIP_kernel_functor_name_end##_##n
159
+
160
+ #define make_kernel_functor_hip_30(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
161
+ p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, \
162
+ p22, p23, p24, p25, p26, p27) \
163
+ struct make_kernel_name_hip(function_name, 28) { \
164
+ std::decay_t<decltype(p0)> _p0_; \
165
+ std::decay_t<decltype(p1)> _p1_; \
166
+ std::decay_t<decltype(p2)> _p2_; \
167
+ std::decay_t<decltype(p3)> _p3_; \
168
+ std::decay_t<decltype(p4)> _p4_; \
169
+ std::decay_t<decltype(p5)> _p5_; \
170
+ std::decay_t<decltype(p6)> _p6_; \
171
+ std::decay_t<decltype(p7)> _p7_; \
172
+ std::decay_t<decltype(p8)> _p8_; \
173
+ std::decay_t<decltype(p9)> _p9_; \
174
+ std::decay_t<decltype(p10)> _p10_; \
175
+ std::decay_t<decltype(p11)> _p11_; \
176
+ std::decay_t<decltype(p12)> _p12_; \
177
+ std::decay_t<decltype(p13)> _p13_; \
178
+ std::decay_t<decltype(p14)> _p14_; \
179
+ std::decay_t<decltype(p15)> _p15_; \
180
+ std::decay_t<decltype(p16)> _p16_; \
181
+ std::decay_t<decltype(p17)> _p17_; \
182
+ std::decay_t<decltype(p18)> _p18_; \
183
+ std::decay_t<decltype(p19)> _p19_; \
184
+ std::decay_t<decltype(p20)> _p20_; \
185
+ std::decay_t<decltype(p21)> _p21_; \
186
+ std::decay_t<decltype(p22)> _p22_; \
187
+ std::decay_t<decltype(p23)> _p23_; \
188
+ std::decay_t<decltype(p24)> _p24_; \
189
+ std::decay_t<decltype(p25)> _p25_; \
190
+ std::decay_t<decltype(p26)> _p26_; \
191
+ std::decay_t<decltype(p27)> _p27_; \
192
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
193
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
194
+ _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, _p18_, _p19_, _p20_, _p21_, \
195
+ _p22_, _p23_, _p24_, _p25_, _p26_, _p27_); \
196
+ } \
197
+ }
198
+ #define make_kernel_functor_hip_29(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
199
+ p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, \
200
+ p22, p23, p24, p25, p26) \
201
+ struct make_kernel_name_hip(function_name, 27) { \
202
+ std::decay_t<decltype(p0)> _p0_; \
203
+ std::decay_t<decltype(p1)> _p1_; \
204
+ std::decay_t<decltype(p2)> _p2_; \
205
+ std::decay_t<decltype(p3)> _p3_; \
206
+ std::decay_t<decltype(p4)> _p4_; \
207
+ std::decay_t<decltype(p5)> _p5_; \
208
+ std::decay_t<decltype(p6)> _p6_; \
209
+ std::decay_t<decltype(p7)> _p7_; \
210
+ std::decay_t<decltype(p8)> _p8_; \
211
+ std::decay_t<decltype(p9)> _p9_; \
212
+ std::decay_t<decltype(p10)> _p10_; \
213
+ std::decay_t<decltype(p11)> _p11_; \
214
+ std::decay_t<decltype(p12)> _p12_; \
215
+ std::decay_t<decltype(p13)> _p13_; \
216
+ std::decay_t<decltype(p14)> _p14_; \
217
+ std::decay_t<decltype(p15)> _p15_; \
218
+ std::decay_t<decltype(p16)> _p16_; \
219
+ std::decay_t<decltype(p17)> _p17_; \
220
+ std::decay_t<decltype(p18)> _p18_; \
221
+ std::decay_t<decltype(p19)> _p19_; \
222
+ std::decay_t<decltype(p20)> _p20_; \
223
+ std::decay_t<decltype(p21)> _p21_; \
224
+ std::decay_t<decltype(p22)> _p22_; \
225
+ std::decay_t<decltype(p23)> _p23_; \
226
+ std::decay_t<decltype(p24)> _p24_; \
227
+ std::decay_t<decltype(p25)> _p25_; \
228
+ std::decay_t<decltype(p26)> _p26_; \
229
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
230
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
231
+ _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, _p18_, _p19_, _p20_, _p21_, \
232
+ _p22_, _p23_, _p24_, _p25_, _p26_); \
233
+ } \
234
+ }
235
+ #define make_kernel_functor_hip_28(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
236
+ p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, \
237
+ p22, p23, p24, p25) \
238
+ struct make_kernel_name_hip(function_name, 26) { \
239
+ std::decay_t<decltype(p0)> _p0_; \
240
+ std::decay_t<decltype(p1)> _p1_; \
241
+ std::decay_t<decltype(p2)> _p2_; \
242
+ std::decay_t<decltype(p3)> _p3_; \
243
+ std::decay_t<decltype(p4)> _p4_; \
244
+ std::decay_t<decltype(p5)> _p5_; \
245
+ std::decay_t<decltype(p6)> _p6_; \
246
+ std::decay_t<decltype(p7)> _p7_; \
247
+ std::decay_t<decltype(p8)> _p8_; \
248
+ std::decay_t<decltype(p9)> _p9_; \
249
+ std::decay_t<decltype(p10)> _p10_; \
250
+ std::decay_t<decltype(p11)> _p11_; \
251
+ std::decay_t<decltype(p12)> _p12_; \
252
+ std::decay_t<decltype(p13)> _p13_; \
253
+ std::decay_t<decltype(p14)> _p14_; \
254
+ std::decay_t<decltype(p15)> _p15_; \
255
+ std::decay_t<decltype(p16)> _p16_; \
256
+ std::decay_t<decltype(p17)> _p17_; \
257
+ std::decay_t<decltype(p18)> _p18_; \
258
+ std::decay_t<decltype(p19)> _p19_; \
259
+ std::decay_t<decltype(p20)> _p20_; \
260
+ std::decay_t<decltype(p21)> _p21_; \
261
+ std::decay_t<decltype(p22)> _p22_; \
262
+ std::decay_t<decltype(p23)> _p23_; \
263
+ std::decay_t<decltype(p24)> _p24_; \
264
+ std::decay_t<decltype(p25)> _p25_; \
265
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
266
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
267
+ _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, _p18_, _p19_, _p20_, _p21_, \
268
+ _p22_, _p23_, _p24_, _p25_); \
269
+ } \
270
+ }
271
+ #define make_kernel_functor_hip_27(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
272
+ p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, \
273
+ p22, p23, p24) \
274
+ struct make_kernel_name_hip(function_name, 25) { \
275
+ std::decay_t<decltype(p0)> _p0_; \
276
+ std::decay_t<decltype(p1)> _p1_; \
277
+ std::decay_t<decltype(p2)> _p2_; \
278
+ std::decay_t<decltype(p3)> _p3_; \
279
+ std::decay_t<decltype(p4)> _p4_; \
280
+ std::decay_t<decltype(p5)> _p5_; \
281
+ std::decay_t<decltype(p6)> _p6_; \
282
+ std::decay_t<decltype(p7)> _p7_; \
283
+ std::decay_t<decltype(p8)> _p8_; \
284
+ std::decay_t<decltype(p9)> _p9_; \
285
+ std::decay_t<decltype(p10)> _p10_; \
286
+ std::decay_t<decltype(p11)> _p11_; \
287
+ std::decay_t<decltype(p12)> _p12_; \
288
+ std::decay_t<decltype(p13)> _p13_; \
289
+ std::decay_t<decltype(p14)> _p14_; \
290
+ std::decay_t<decltype(p15)> _p15_; \
291
+ std::decay_t<decltype(p16)> _p16_; \
292
+ std::decay_t<decltype(p17)> _p17_; \
293
+ std::decay_t<decltype(p18)> _p18_; \
294
+ std::decay_t<decltype(p19)> _p19_; \
295
+ std::decay_t<decltype(p20)> _p20_; \
296
+ std::decay_t<decltype(p21)> _p21_; \
297
+ std::decay_t<decltype(p22)> _p22_; \
298
+ std::decay_t<decltype(p23)> _p23_; \
299
+ std::decay_t<decltype(p24)> _p24_; \
300
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
301
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
302
+ _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, _p18_, _p19_, _p20_, _p21_, \
303
+ _p22_, _p23_, _p24_); \
304
+ } \
305
+ }
306
+ #define make_kernel_functor_hip_26(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
307
+ p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, \
308
+ p22, p23) \
309
+ struct make_kernel_name_hip(function_name, 24) { \
310
+ std::decay_t<decltype(p0)> _p0_; \
311
+ std::decay_t<decltype(p1)> _p1_; \
312
+ std::decay_t<decltype(p2)> _p2_; \
313
+ std::decay_t<decltype(p3)> _p3_; \
314
+ std::decay_t<decltype(p4)> _p4_; \
315
+ std::decay_t<decltype(p5)> _p5_; \
316
+ std::decay_t<decltype(p6)> _p6_; \
317
+ std::decay_t<decltype(p7)> _p7_; \
318
+ std::decay_t<decltype(p8)> _p8_; \
319
+ std::decay_t<decltype(p9)> _p9_; \
320
+ std::decay_t<decltype(p10)> _p10_; \
321
+ std::decay_t<decltype(p11)> _p11_; \
322
+ std::decay_t<decltype(p12)> _p12_; \
323
+ std::decay_t<decltype(p13)> _p13_; \
324
+ std::decay_t<decltype(p14)> _p14_; \
325
+ std::decay_t<decltype(p15)> _p15_; \
326
+ std::decay_t<decltype(p16)> _p16_; \
327
+ std::decay_t<decltype(p17)> _p17_; \
328
+ std::decay_t<decltype(p18)> _p18_; \
329
+ std::decay_t<decltype(p19)> _p19_; \
330
+ std::decay_t<decltype(p20)> _p20_; \
331
+ std::decay_t<decltype(p21)> _p21_; \
332
+ std::decay_t<decltype(p22)> _p22_; \
333
+ std::decay_t<decltype(p23)> _p23_; \
334
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
335
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
336
+ _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, _p18_, _p19_, _p20_, _p21_, \
337
+ _p22_, _p23_); \
338
+ } \
339
+ }
340
+ #define make_kernel_functor_hip_25(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
341
+ p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, \
342
+ p22) \
343
+ struct make_kernel_name_hip(function_name, 23) { \
344
+ std::decay_t<decltype(p0)> _p0_; \
345
+ std::decay_t<decltype(p1)> _p1_; \
346
+ std::decay_t<decltype(p2)> _p2_; \
347
+ std::decay_t<decltype(p3)> _p3_; \
348
+ std::decay_t<decltype(p4)> _p4_; \
349
+ std::decay_t<decltype(p5)> _p5_; \
350
+ std::decay_t<decltype(p6)> _p6_; \
351
+ std::decay_t<decltype(p7)> _p7_; \
352
+ std::decay_t<decltype(p8)> _p8_; \
353
+ std::decay_t<decltype(p9)> _p9_; \
354
+ std::decay_t<decltype(p10)> _p10_; \
355
+ std::decay_t<decltype(p11)> _p11_; \
356
+ std::decay_t<decltype(p12)> _p12_; \
357
+ std::decay_t<decltype(p13)> _p13_; \
358
+ std::decay_t<decltype(p14)> _p14_; \
359
+ std::decay_t<decltype(p15)> _p15_; \
360
+ std::decay_t<decltype(p16)> _p16_; \
361
+ std::decay_t<decltype(p17)> _p17_; \
362
+ std::decay_t<decltype(p18)> _p18_; \
363
+ std::decay_t<decltype(p19)> _p19_; \
364
+ std::decay_t<decltype(p20)> _p20_; \
365
+ std::decay_t<decltype(p21)> _p21_; \
366
+ std::decay_t<decltype(p22)> _p22_; \
367
+ __attribute__((used, flatten)) void operator()(const hc::tiled_index<3>&) const [[hc]] { \
368
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
369
+ _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, _p18_, _p19_, _p20_, _p21_, \
370
+ _p22_); \
371
+ } \
372
+ }
373
+ #define make_kernel_functor_hip_24(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
374
+ p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21) \
375
+ struct make_kernel_name_hip(function_name, 22) { \
376
+ std::decay_t<decltype(p0)> _p0_; \
377
+ std::decay_t<decltype(p1)> _p1_; \
378
+ std::decay_t<decltype(p2)> _p2_; \
379
+ std::decay_t<decltype(p3)> _p3_; \
380
+ std::decay_t<decltype(p4)> _p4_; \
381
+ std::decay_t<decltype(p5)> _p5_; \
382
+ std::decay_t<decltype(p6)> _p6_; \
383
+ std::decay_t<decltype(p7)> _p7_; \
384
+ std::decay_t<decltype(p8)> _p8_; \
385
+ std::decay_t<decltype(p9)> _p9_; \
386
+ std::decay_t<decltype(p10)> _p10_; \
387
+ std::decay_t<decltype(p11)> _p11_; \
388
+ std::decay_t<decltype(p12)> _p12_; \
389
+ std::decay_t<decltype(p13)> _p13_; \
390
+ std::decay_t<decltype(p14)> _p14_; \
391
+ std::decay_t<decltype(p15)> _p15_; \
392
+ std::decay_t<decltype(p16)> _p16_; \
393
+ std::decay_t<decltype(p17)> _p17_; \
394
+ std::decay_t<decltype(p18)> _p18_; \
395
+ std::decay_t<decltype(p19)> _p19_; \
396
+ std::decay_t<decltype(p20)> _p20_; \
397
+ std::decay_t<decltype(p21)> _p21_; \
398
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
399
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
400
+ _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, _p18_, _p19_, _p20_, _p21_); \
401
+ } \
402
+ }
403
+ #define make_kernel_functor_hip_23(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
404
+ p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20) \
405
+ struct make_kernel_name_hip(function_name, 21) { \
406
+ std::decay_t<decltype(p0)> _p0_; \
407
+ std::decay_t<decltype(p1)> _p1_; \
408
+ std::decay_t<decltype(p2)> _p2_; \
409
+ std::decay_t<decltype(p3)> _p3_; \
410
+ std::decay_t<decltype(p4)> _p4_; \
411
+ std::decay_t<decltype(p5)> _p5_; \
412
+ std::decay_t<decltype(p6)> _p6_; \
413
+ std::decay_t<decltype(p7)> _p7_; \
414
+ std::decay_t<decltype(p8)> _p8_; \
415
+ std::decay_t<decltype(p9)> _p9_; \
416
+ std::decay_t<decltype(p10)> _p10_; \
417
+ std::decay_t<decltype(p11)> _p11_; \
418
+ std::decay_t<decltype(p12)> _p12_; \
419
+ std::decay_t<decltype(p13)> _p13_; \
420
+ std::decay_t<decltype(p14)> _p14_; \
421
+ std::decay_t<decltype(p15)> _p15_; \
422
+ std::decay_t<decltype(p16)> _p16_; \
423
+ std::decay_t<decltype(p17)> _p17_; \
424
+ std::decay_t<decltype(p18)> _p18_; \
425
+ std::decay_t<decltype(p19)> _p19_; \
426
+ std::decay_t<decltype(p20)> _p20_; \
427
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
428
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
429
+ _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, _p18_, _p19_, _p20_); \
430
+ } \
431
+ }
432
+ #define make_kernel_functor_hip_22(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
433
+ p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19) \
434
+ struct make_kernel_name_hip(function_name, 20) { \
435
+ std::decay_t<decltype(p0)> _p0_; \
436
+ std::decay_t<decltype(p1)> _p1_; \
437
+ std::decay_t<decltype(p2)> _p2_; \
438
+ std::decay_t<decltype(p3)> _p3_; \
439
+ std::decay_t<decltype(p4)> _p4_; \
440
+ std::decay_t<decltype(p5)> _p5_; \
441
+ std::decay_t<decltype(p6)> _p6_; \
442
+ std::decay_t<decltype(p7)> _p7_; \
443
+ std::decay_t<decltype(p8)> _p8_; \
444
+ std::decay_t<decltype(p9)> _p9_; \
445
+ std::decay_t<decltype(p10)> _p10_; \
446
+ std::decay_t<decltype(p11)> _p11_; \
447
+ std::decay_t<decltype(p12)> _p12_; \
448
+ std::decay_t<decltype(p13)> _p13_; \
449
+ std::decay_t<decltype(p14)> _p14_; \
450
+ std::decay_t<decltype(p15)> _p15_; \
451
+ std::decay_t<decltype(p16)> _p16_; \
452
+ std::decay_t<decltype(p17)> _p17_; \
453
+ std::decay_t<decltype(p18)> _p18_; \
454
+ std::decay_t<decltype(p19)> _p19_; \
455
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
456
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
457
+ _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, _p18_, _p19_); \
458
+ } \
459
+ }
460
+ #define make_kernel_functor_hip_21(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
461
+ p9, p10, p11, p12, p13, p14, p15, p16, p17, p18) \
462
+ struct make_kernel_name_hip(function_name, 19) { \
463
+ std::decay_t<decltype(p0)> _p0_; \
464
+ std::decay_t<decltype(p1)> _p1_; \
465
+ std::decay_t<decltype(p2)> _p2_; \
466
+ std::decay_t<decltype(p3)> _p3_; \
467
+ std::decay_t<decltype(p4)> _p4_; \
468
+ std::decay_t<decltype(p5)> _p5_; \
469
+ std::decay_t<decltype(p6)> _p6_; \
470
+ std::decay_t<decltype(p7)> _p7_; \
471
+ std::decay_t<decltype(p8)> _p8_; \
472
+ std::decay_t<decltype(p9)> _p9_; \
473
+ std::decay_t<decltype(p10)> _p10_; \
474
+ std::decay_t<decltype(p11)> _p11_; \
475
+ std::decay_t<decltype(p12)> _p12_; \
476
+ std::decay_t<decltype(p13)> _p13_; \
477
+ std::decay_t<decltype(p14)> _p14_; \
478
+ std::decay_t<decltype(p15)> _p15_; \
479
+ std::decay_t<decltype(p16)> _p16_; \
480
+ std::decay_t<decltype(p17)> _p17_; \
481
+ std::decay_t<decltype(p18)> _p18_; \
482
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
483
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
484
+ _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, _p18_); \
485
+ } \
486
+ }
487
+ #define make_kernel_functor_hip_20(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
488
+ p9, p10, p11, p12, p13, p14, p15, p16, p17) \
489
+ struct make_kernel_name_hip(function_name, 18) { \
490
+ std::decay_t<decltype(p0)> _p0_; \
491
+ std::decay_t<decltype(p1)> _p1_; \
492
+ std::decay_t<decltype(p2)> _p2_; \
493
+ std::decay_t<decltype(p3)> _p3_; \
494
+ std::decay_t<decltype(p4)> _p4_; \
495
+ std::decay_t<decltype(p5)> _p5_; \
496
+ std::decay_t<decltype(p6)> _p6_; \
497
+ std::decay_t<decltype(p7)> _p7_; \
498
+ std::decay_t<decltype(p8)> _p8_; \
499
+ std::decay_t<decltype(p9)> _p9_; \
500
+ std::decay_t<decltype(p10)> _p10_; \
501
+ std::decay_t<decltype(p11)> _p11_; \
502
+ std::decay_t<decltype(p12)> _p12_; \
503
+ std::decay_t<decltype(p13)> _p13_; \
504
+ std::decay_t<decltype(p14)> _p14_; \
505
+ std::decay_t<decltype(p15)> _p15_; \
506
+ std::decay_t<decltype(p16)> _p16_; \
507
+ std::decay_t<decltype(p17)> _p17_; \
508
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
509
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
510
+ _p12_, _p13_, _p14_, _p15_, _p16_, _p17_); \
511
+ } \
512
+ }
513
+ #define make_kernel_functor_hip_19(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
514
+ p9, p10, p11, p12, p13, p14, p15, p16) \
515
+ struct make_kernel_name_hip(function_name, 17) { \
516
+ std::decay_t<decltype(p0)> _p0_; \
517
+ std::decay_t<decltype(p1)> _p1_; \
518
+ std::decay_t<decltype(p2)> _p2_; \
519
+ std::decay_t<decltype(p3)> _p3_; \
520
+ std::decay_t<decltype(p4)> _p4_; \
521
+ std::decay_t<decltype(p5)> _p5_; \
522
+ std::decay_t<decltype(p6)> _p6_; \
523
+ std::decay_t<decltype(p7)> _p7_; \
524
+ std::decay_t<decltype(p8)> _p8_; \
525
+ std::decay_t<decltype(p9)> _p9_; \
526
+ std::decay_t<decltype(p10)> _p10_; \
527
+ std::decay_t<decltype(p11)> _p11_; \
528
+ std::decay_t<decltype(p12)> _p12_; \
529
+ std::decay_t<decltype(p13)> _p13_; \
530
+ std::decay_t<decltype(p14)> _p14_; \
531
+ std::decay_t<decltype(p15)> _p15_; \
532
+ std::decay_t<decltype(p16)> _p16_; \
533
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
534
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
535
+ _p12_, _p13_, _p14_, _p15_, _p16_); \
536
+ } \
537
+ }
538
+ #define make_kernel_functor_hip_18(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
539
+ p9, p10, p11, p12, p13, p14, p15) \
540
+ struct make_kernel_name_hip(function_name, 16) { \
541
+ std::decay_t<decltype(p0)> _p0_; \
542
+ std::decay_t<decltype(p1)> _p1_; \
543
+ std::decay_t<decltype(p2)> _p2_; \
544
+ std::decay_t<decltype(p3)> _p3_; \
545
+ std::decay_t<decltype(p4)> _p4_; \
546
+ std::decay_t<decltype(p5)> _p5_; \
547
+ std::decay_t<decltype(p6)> _p6_; \
548
+ std::decay_t<decltype(p7)> _p7_; \
549
+ std::decay_t<decltype(p8)> _p8_; \
550
+ std::decay_t<decltype(p9)> _p9_; \
551
+ std::decay_t<decltype(p10)> _p10_; \
552
+ std::decay_t<decltype(p11)> _p11_; \
553
+ std::decay_t<decltype(p12)> _p12_; \
554
+ std::decay_t<decltype(p13)> _p13_; \
555
+ std::decay_t<decltype(p14)> _p14_; \
556
+ std::decay_t<decltype(p15)> _p15_; \
557
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
558
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
559
+ _p12_, _p13_, _p14_, _p15_); \
560
+ } \
561
+ }
562
+ #define make_kernel_functor_hip_17(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
563
+ p9, p10, p11, p12, p13, p14) \
564
+ struct make_kernel_name_hip(function_name, 15) { \
565
+ std::decay_t<decltype(p0)> _p0_; \
566
+ std::decay_t<decltype(p1)> _p1_; \
567
+ std::decay_t<decltype(p2)> _p2_; \
568
+ std::decay_t<decltype(p3)> _p3_; \
569
+ std::decay_t<decltype(p4)> _p4_; \
570
+ std::decay_t<decltype(p5)> _p5_; \
571
+ std::decay_t<decltype(p6)> _p6_; \
572
+ std::decay_t<decltype(p7)> _p7_; \
573
+ std::decay_t<decltype(p8)> _p8_; \
574
+ std::decay_t<decltype(p9)> _p9_; \
575
+ std::decay_t<decltype(p10)> _p10_; \
576
+ std::decay_t<decltype(p11)> _p11_; \
577
+ std::decay_t<decltype(p12)> _p12_; \
578
+ std::decay_t<decltype(p13)> _p13_; \
579
+ std::decay_t<decltype(p14)> _p14_; \
580
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
581
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
582
+ _p12_, _p13_, _p14_); \
583
+ } \
584
+ }
585
+ #define make_kernel_functor_hip_16(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
586
+ p9, p10, p11, p12, p13) \
587
+ struct make_kernel_name_hip(function_name, 14) { \
588
+ std::decay_t<decltype(p0)> _p0_; \
589
+ std::decay_t<decltype(p1)> _p1_; \
590
+ std::decay_t<decltype(p2)> _p2_; \
591
+ std::decay_t<decltype(p3)> _p3_; \
592
+ std::decay_t<decltype(p4)> _p4_; \
593
+ std::decay_t<decltype(p5)> _p5_; \
594
+ std::decay_t<decltype(p6)> _p6_; \
595
+ std::decay_t<decltype(p7)> _p7_; \
596
+ std::decay_t<decltype(p8)> _p8_; \
597
+ std::decay_t<decltype(p9)> _p9_; \
598
+ std::decay_t<decltype(p10)> _p10_; \
599
+ std::decay_t<decltype(p11)> _p11_; \
600
+ std::decay_t<decltype(p12)> _p12_; \
601
+ std::decay_t<decltype(p13)> _p13_; \
602
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
603
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
604
+ _p12_, _p13_); \
605
+ } \
606
+ }
607
+ #define make_kernel_functor_hip_15(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
608
+ p9, p10, p11, p12) \
609
+ struct make_kernel_name_hip(function_name, 13) { \
610
+ std::decay_t<decltype(p0)> _p0_; \
611
+ std::decay_t<decltype(p1)> _p1_; \
612
+ std::decay_t<decltype(p2)> _p2_; \
613
+ std::decay_t<decltype(p3)> _p3_; \
614
+ std::decay_t<decltype(p4)> _p4_; \
615
+ std::decay_t<decltype(p5)> _p5_; \
616
+ std::decay_t<decltype(p6)> _p6_; \
617
+ std::decay_t<decltype(p7)> _p7_; \
618
+ std::decay_t<decltype(p8)> _p8_; \
619
+ std::decay_t<decltype(p9)> _p9_; \
620
+ std::decay_t<decltype(p10)> _p10_; \
621
+ std::decay_t<decltype(p11)> _p11_; \
622
+ std::decay_t<decltype(p12)> _p12_; \
623
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
624
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_, \
625
+ _p12_); \
626
+ } \
627
+ }
628
+ #define make_kernel_functor_hip_14(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
629
+ p9, p10, p11) \
630
+ struct make_kernel_name_hip(function_name, 12) { \
631
+ std::decay_t<decltype(p0)> _p0_; \
632
+ std::decay_t<decltype(p1)> _p1_; \
633
+ std::decay_t<decltype(p2)> _p2_; \
634
+ std::decay_t<decltype(p3)> _p3_; \
635
+ std::decay_t<decltype(p4)> _p4_; \
636
+ std::decay_t<decltype(p5)> _p5_; \
637
+ std::decay_t<decltype(p6)> _p6_; \
638
+ std::decay_t<decltype(p7)> _p7_; \
639
+ std::decay_t<decltype(p8)> _p8_; \
640
+ std::decay_t<decltype(p9)> _p9_; \
641
+ std::decay_t<decltype(p10)> _p10_; \
642
+ std::decay_t<decltype(p11)> _p11_; \
643
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
644
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_, _p11_); \
645
+ } \
646
+ }
647
+ #define make_kernel_functor_hip_13(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
648
+ p9, p10) \
649
+ struct make_kernel_name_hip(function_name, 11) { \
650
+ std::decay_t<decltype(p0)> _p0_; \
651
+ std::decay_t<decltype(p1)> _p1_; \
652
+ std::decay_t<decltype(p2)> _p2_; \
653
+ std::decay_t<decltype(p3)> _p3_; \
654
+ std::decay_t<decltype(p4)> _p4_; \
655
+ std::decay_t<decltype(p5)> _p5_; \
656
+ std::decay_t<decltype(p6)> _p6_; \
657
+ std::decay_t<decltype(p7)> _p7_; \
658
+ std::decay_t<decltype(p8)> _p8_; \
659
+ std::decay_t<decltype(p9)> _p9_; \
660
+ std::decay_t<decltype(p10)> _p10_; \
661
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { \
662
+ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, _p10_); \
663
+ } \
664
+ }
665
+ #define make_kernel_functor_hip_12(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, \
666
+ p9) \
667
+ struct make_kernel_name_hip(function_name, 10) { \
668
+ std::decay_t<decltype(p0)> _p0_; \
669
+ std::decay_t<decltype(p1)> _p1_; \
670
+ std::decay_t<decltype(p2)> _p2_; \
671
+ std::decay_t<decltype(p3)> _p3_; \
672
+ std::decay_t<decltype(p4)> _p4_; \
673
+ std::decay_t<decltype(p5)> _p5_; \
674
+ std::decay_t<decltype(p6)> _p6_; \
675
+ std::decay_t<decltype(p7)> _p7_; \
676
+ std::decay_t<decltype(p8)> _p8_; \
677
+ std::decay_t<decltype(p9)> _p9_; \
678
+ void operator()(const hc::tiled_index<3>&) const \
679
+ [[hc]] { kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_); } \
680
+ }
681
+ #define make_kernel_functor_hip_11(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
682
+ struct make_kernel_name_hip(function_name, 9) { \
683
+ std::decay_t<decltype(p0)> _p0_; \
684
+ std::decay_t<decltype(p1)> _p1_; \
685
+ std::decay_t<decltype(p2)> _p2_; \
686
+ std::decay_t<decltype(p3)> _p3_; \
687
+ std::decay_t<decltype(p4)> _p4_; \
688
+ std::decay_t<decltype(p5)> _p5_; \
689
+ std::decay_t<decltype(p6)> _p6_; \
690
+ std::decay_t<decltype(p7)> _p7_; \
691
+ std::decay_t<decltype(p8)> _p8_; \
692
+ void operator()(const hc::tiled_index<3>&) const \
693
+ [[hc]] { kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_); } \
694
+ }
695
+ #define make_kernel_functor_hip_10(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6, p7) \
696
+ struct make_kernel_name_hip(function_name, 8) { \
697
+ std::decay_t<decltype(p0)> _p0_; \
698
+ std::decay_t<decltype(p1)> _p1_; \
699
+ std::decay_t<decltype(p2)> _p2_; \
700
+ std::decay_t<decltype(p3)> _p3_; \
701
+ std::decay_t<decltype(p4)> _p4_; \
702
+ std::decay_t<decltype(p5)> _p5_; \
703
+ std::decay_t<decltype(p6)> _p6_; \
704
+ std::decay_t<decltype(p7)> _p7_; \
705
+ void operator()(const hc::tiled_index<3>&) const \
706
+ [[hc]] { kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_); } \
707
+ }
708
+ #define make_kernel_functor_hip_9(function_name, kernel_name, p0, p1, p2, p3, p4, p5, p6) \
709
+ struct make_kernel_name_hip(function_name, 7) { \
710
+ std::decay_t<decltype(p0)> _p0_; \
711
+ std::decay_t<decltype(p1)> _p1_; \
712
+ std::decay_t<decltype(p2)> _p2_; \
713
+ std::decay_t<decltype(p3)> _p3_; \
714
+ std::decay_t<decltype(p4)> _p4_; \
715
+ std::decay_t<decltype(p5)> _p5_; \
716
+ std::decay_t<decltype(p6)> _p6_; \
717
+ void operator()(const hc::tiled_index<3>&) const \
718
+ [[hc]] { kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_); } \
719
+ }
720
+ #define make_kernel_functor_hip_8(function_name, kernel_name, p0, p1, p2, p3, p4, p5) \
721
+ struct make_kernel_name_hip(function_name, 6) { \
722
+ std::decay_t<decltype(p0)> _p0_; \
723
+ std::decay_t<decltype(p1)> _p1_; \
724
+ std::decay_t<decltype(p2)> _p2_; \
725
+ std::decay_t<decltype(p3)> _p3_; \
726
+ std::decay_t<decltype(p4)> _p4_; \
727
+ std::decay_t<decltype(p5)> _p5_; \
728
+ void operator()(const hc::tiled_index<3>&) const \
729
+ [[hc]] { kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_); } \
730
+ }
731
+ #define make_kernel_functor_hip_7(function_name, kernel_name, p0, p1, p2, p3, p4) \
732
+ struct make_kernel_name_hip(function_name, 5) { \
733
+ std::decay_t<decltype(p0)> _p0_; \
734
+ std::decay_t<decltype(p1)> _p1_; \
735
+ std::decay_t<decltype(p2)> _p2_; \
736
+ std::decay_t<decltype(p3)> _p3_; \
737
+ std::decay_t<decltype(p4)> _p4_; \
738
+ void operator()(const hc::tiled_index<3>&) const \
739
+ [[hc]] { kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_); } \
740
+ }
741
+ #define make_kernel_functor_hip_6(function_name, kernel_name, p0, p1, p2, p3) \
742
+ struct make_kernel_name_hip(function_name, 4) { \
743
+ std::decay_t<decltype(p0)> _p0_; \
744
+ std::decay_t<decltype(p1)> _p1_; \
745
+ std::decay_t<decltype(p2)> _p2_; \
746
+ std::decay_t<decltype(p3)> _p3_; \
747
+ void operator()(const hc::tiled_index<3>&) const \
748
+ [[hc]] { kernel_name(_p0_, _p1_, _p2_, _p3_); } \
749
+ }
750
+ #define make_kernel_functor_hip_5(function_name, kernel_name, p0, p1, p2) \
751
+ struct make_kernel_name_hip(function_name, 3) { \
752
+ std::decay_t<decltype(p0)> _p0_; \
753
+ std::decay_t<decltype(p1)> _p1_; \
754
+ std::decay_t<decltype(p2)> _p2_; \
755
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { kernel_name(_p0_, _p1_, _p2_); } \
756
+ }
757
+ #define make_kernel_functor_hip_4(function_name, kernel_name, p0, p1) \
758
+ struct make_kernel_name_hip(function_name, 2) { \
759
+ std::decay_t<decltype(p0)> _p0_; \
760
+ std::decay_t<decltype(p1)> _p1_; \
761
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { kernel_name(_p0_, _p1_); } \
762
+ }
763
+ #define fofo(f, n) kernel_prefix_hip##f##kernel_suffix_hip##n
764
+ #define make_kernel_functor_hip_3(function_name, kernel_name, p0) \
765
+ struct make_kernel_name_hip(function_name, 1) { \
766
+ std::decay_t<decltype(p0)> _p0_; \
767
+ void operator()(const hc::tiled_index<3>&) const [[hc]] { kernel_name(_p0_); } \
768
+ }
769
+ #define make_kernel_functor_hip_2(function_name, kernel_name) \
770
+ struct make_kernel_name_hip(function_name, 0) { \
771
+ void operator()(const hc::tiled_index<3>&)[[hc]] { return kernel_name(hipLaunchParm{}); } \
772
+ }
773
+ #define make_kernel_functor_hip_1(...)
774
+ #define make_kernel_functor_hip_0(...)
775
+ #define make_kernel_functor_hip_(...) overload_macro_hip_(make_kernel_functor_hip_, __VA_ARGS__)
776
+
777
+
778
+ #define hipLaunchNamedKernelGGL(function_name, kernel_name, num_blocks, dim_blocks, \
779
+ group_mem_bytes, stream, ...) \
780
+ do { \
781
+ make_kernel_functor_hip_(function_name, kernel_name, __VA_ARGS__) \
782
+ hip_kernel_functor_impl_{__VA_ARGS__}; \
783
+ hip_impl::grid_launch_hip_(num_blocks, dim_blocks, group_mem_bytes, stream, #kernel_name, \
784
+ hip_kernel_functor_impl_); \
785
+ } while (0)
786
+
787
+ #define hipLaunchKernelGGL(kernel_name, num_blocks, dim_blocks, group_mem_bytes, stream, ...) \
788
+ do { \
789
+ hipLaunchNamedKernelGGL(unnamed, kernel_name, num_blocks, dim_blocks, group_mem_bytes, \
790
+ stream, ##__VA_ARGS__); \
791
+ } while (0)
792
+
793
+ #define hipLaunchKernel(kernel_name, num_blocks, dim_blocks, group_mem_bytes, stream, ...) \
794
+ do { \
795
+ hipLaunchKernelGGL(kernel_name, num_blocks, dim_blocks, group_mem_bytes, stream, \
796
+ hipLaunchParm{}, ##__VA_ARGS__); \
797
+ } while (0)
798
+ } // namespace hip_impl
.venv/lib/python3.11/site-packages/triton/backends/amd/include/hip/amd_detail/ockl_image.h ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (c) 2015 - 2023 Advanced Micro Devices, Inc. All rights reserved.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+ */
22
+
23
+ #pragma once
24
+
25
+ #if !defined(__HIPCC_RTC__)
26
+ #include <hip/hip_vector_types.h>
27
+ #endif
28
+
29
+ extern "C" {
30
+
31
+ #define ADDRESS_SPACE_CONSTANT __attribute__((address_space(4)))
32
+
33
+ __device__ float4::Native_vec_ __ockl_image_load_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, int c);
34
+
35
+ __device__ float4::Native_vec_ __ockl_image_load_1Db(unsigned int ADDRESS_SPACE_CONSTANT*i, int c);
36
+
37
+ __device__ float4::Native_vec_ __ockl_image_load_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c);
38
+
39
+ __device__ float4::Native_vec_ __ockl_image_load_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c);
40
+
41
+ __device__ float4::Native_vec_ __ockl_image_load_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c);
42
+
43
+ __device__ float4::Native_vec_ __ockl_image_load_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c);
44
+
45
+ __device__ float4::Native_vec_ __ockl_image_load_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int f);
46
+
47
+ __device__ float4::Native_vec_ __ockl_image_load_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int f);
48
+
49
+ __device__ float4::Native_vec_ __ockl_image_load_lod_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, int c, int l);
50
+
51
+ __device__ float4::Native_vec_ __ockl_image_load_lod_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int l);
52
+
53
+ __device__ float4::Native_vec_ __ockl_image_load_lod_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int l);
54
+
55
+ __device__ float4::Native_vec_ __ockl_image_load_lod_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int l);
56
+
57
+ __device__ float4::Native_vec_ __ockl_image_load_lod_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int l);
58
+
59
+ __device__ float4::Native_vec_ __ockl_image_load_lod_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int f, int l);
60
+
61
+ __device__ float4::Native_vec_ __ockl_image_load_lod_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int f, int l);
62
+
63
+ __device__ void __ockl_image_store_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, int c, float4::Native_vec_ p);
64
+
65
+ __device__ void __ockl_image_store_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, float4::Native_vec_ p);
66
+
67
+ __device__ void __ockl_image_store_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, float4::Native_vec_ p);
68
+
69
+ __device__ void __ockl_image_store_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, float4::Native_vec_ p);
70
+
71
+ __device__ void __ockl_image_store_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, float4::Native_vec_ p);
72
+
73
+ __device__ void __ockl_image_store_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int f, float4::Native_vec_ p);
74
+
75
+ __device__ void __ockl_image_store_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int f, float4::Native_vec_ p);
76
+
77
+ __device__ void __ockl_image_store_lod_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, int c, int l, float4::Native_vec_ p);
78
+
79
+ __device__ void __ockl_image_store_lod_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int l, float4::Native_vec_ p);
80
+
81
+ __device__ void __ockl_image_store_lod_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int l, float4::Native_vec_ p);
82
+
83
+ __device__ void __ockl_image_store_lod_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int l, float4::Native_vec_ p);
84
+
85
+ __device__ void __ockl_image_store_lod_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int l, float4::Native_vec_ p);
86
+
87
+ __device__ void __ockl_image_store_lod_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int f, int l, float4::Native_vec_ p);
88
+
89
+ __device__ void __ockl_image_store_lod_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int f, int l, float4::Native_vec_ p);
90
+
91
+ __device__ float4::Native_vec_ __ockl_image_sample_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float c);
92
+
93
+ __device__ float4::Native_vec_ __ockl_image_sample_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
94
+
95
+ __device__ float4::Native_vec_ __ockl_image_sample_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
96
+
97
+ __device__ float4::Native_vec_ __ockl_image_sample_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c);
98
+
99
+ __device__ float4::Native_vec_ __ockl_image_sample_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c);
100
+
101
+ __device__ float4::Native_vec_ __ockl_image_sample_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c);
102
+
103
+ __device__ float4::Native_vec_ __ockl_image_sample_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c);
104
+
105
+ __device__ float4::Native_vec_ __ockl_image_sample_grad_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float c, float dx, float dy);
106
+
107
+ __device__ float4::Native_vec_ __ockl_image_sample_grad_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c, float dx, float dy);
108
+
109
+ __device__ float4::Native_vec_ __ockl_image_sample_grad_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c, float2::Native_vec_ dx, float2::Native_vec_ dy);
110
+
111
+ __device__ float4::Native_vec_ __ockl_image_sample_grad_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float2::Native_vec_ dx, float2::Native_vec_ dy);
112
+
113
+ __device__ float4::Native_vec_ __ockl_image_sample_grad_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float4::Native_vec_ dx, float4::Native_vec_ dy);
114
+
115
+ __device__ float4::Native_vec_ __ockl_image_sample_lod_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float c, float l);
116
+
117
+ __device__ float4::Native_vec_ __ockl_image_sample_lod_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c, float l);
118
+
119
+ __device__ float4::Native_vec_ __ockl_image_sample_lod_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c, float l);
120
+
121
+ __device__ float4::Native_vec_ __ockl_image_sample_lod_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float l);
122
+
123
+ __device__ float4::Native_vec_ __ockl_image_sample_lod_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float l);
124
+
125
+ __device__ float4::Native_vec_ __ockl_image_sample_lod_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float l);
126
+
127
+ __device__ float4::Native_vec_ __ockl_image_sample_lod_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float l);
128
+
129
+ __device__ float4::Native_vec_ __ockl_image_gather4r_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
130
+
131
+ __device__ float4::Native_vec_ __ockl_image_gather4g_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
132
+
133
+ __device__ float4::Native_vec_ __ockl_image_gather4b_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
134
+
135
+ __device__ float4::Native_vec_ __ockl_image_gather4a_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
136
+
137
+ __device__ int __ockl_image_channel_data_type_1D(unsigned int ADDRESS_SPACE_CONSTANT* i);
138
+
139
+ __device__ int __ockl_image_channel_data_type_1Da(unsigned int ADDRESS_SPACE_CONSTANT* i);
140
+
141
+ __device__ int __ockl_image_channel_data_type_1Db(unsigned int ADDRESS_SPACE_CONSTANT* i);
142
+
143
+ __device__ int __ockl_image_channel_data_type_2D(unsigned int ADDRESS_SPACE_CONSTANT* i);
144
+
145
+ __device__ int __ockl_image_channel_data_type_2Da(unsigned int ADDRESS_SPACE_CONSTANT* i);
146
+
147
+ __device__ int __ockl_image_channel_data_type_2Dad(unsigned int ADDRESS_SPACE_CONSTANT* i);
148
+
149
+ __device__ int __ockl_image_channel_data_type_2Dd(unsigned int ADDRESS_SPACE_CONSTANT* i);
150
+
151
+ __device__ int __ockl_image_channel_data_type_3D(unsigned int ADDRESS_SPACE_CONSTANT* i);
152
+
153
+ __device__ int __ockl_image_channel_data_type_CM(unsigned int ADDRESS_SPACE_CONSTANT* i);
154
+
155
+ __device__ int __ockl_image_channel_data_type_CMa(unsigned int ADDRESS_SPACE_CONSTANT* i);
156
+
157
+ __device__ int __ockl_image_channel_order_1D(unsigned int ADDRESS_SPACE_CONSTANT* i);
158
+
159
+ __device__ int __ockl_image_channel_order_1Da(unsigned int ADDRESS_SPACE_CONSTANT* i);
160
+
161
+ __device__ int __ockl_image_channel_order_1Db(unsigned int ADDRESS_SPACE_CONSTANT* i);
162
+
163
+ __device__ int __ockl_image_channel_order_2D(unsigned int ADDRESS_SPACE_CONSTANT* i);
164
+
165
+ __device__ int __ockl_image_channel_order_2Da(unsigned int ADDRESS_SPACE_CONSTANT* i);
166
+
167
+ __device__ int __ockl_image_channel_order_2Dad(unsigned int ADDRESS_SPACE_CONSTANT* i);
168
+
169
+ __device__ int __ockl_image_channel_order_2Dd(unsigned int ADDRESS_SPACE_CONSTANT* i);
170
+
171
+ __device__ int __ockl_image_channel_order_3D(unsigned int ADDRESS_SPACE_CONSTANT* i);
172
+
173
+ __device__ int __ockl_image_channel_order_CM(unsigned int ADDRESS_SPACE_CONSTANT* i);
174
+
175
+ __device__ int __ockl_image_channel_order_CMa(unsigned int ADDRESS_SPACE_CONSTANT* i);
176
+
177
+ }
.venv/lib/python3.11/site-packages/triton/backends/compiler.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+ import subprocess
4
+
5
+ from abc import ABCMeta, abstractmethod, abstractclassmethod
6
+ from dataclasses import dataclass
7
+ from typing import Union
8
+
9
+
10
+ @dataclass(frozen=True)
11
+ class GPUTarget(object):
12
+ # Target backend, e.g., cuda, hip
13
+ backend: str
14
+ # Target architecture, e.g., 90 (for cuda compute capability), gfx940 (for hip)
15
+ arch: Union[int, str]
16
+ warp_size: int
17
+
18
+
19
+ class BaseBackend(metaclass=ABCMeta):
20
+
21
+ def __init__(self, target: GPUTarget) -> None:
22
+ self.target = target
23
+ assert self.supports_target(target)
24
+
25
+ @staticmethod
26
+ def _path_to_binary(binary: str):
27
+ base_dir = os.path.join(os.path.dirname(__file__), os.pardir)
28
+ paths = [
29
+ os.environ.get(f"TRITON_{binary.upper()}_PATH", ""),
30
+ os.path.join(base_dir, "third_party", "cuda", "bin", binary),
31
+ ]
32
+ for p in paths:
33
+ bin = p.split(" ")[0]
34
+ if os.path.exists(bin) and os.path.isfile(bin):
35
+ result = subprocess.check_output([bin, "--version"], stderr=subprocess.STDOUT)
36
+ if result is not None:
37
+ version = re.search(r".*release (\d+\.\d+).*", result.decode("utf-8"), flags=re.MULTILINE)
38
+ if version is not None:
39
+ return p, version.group(1)
40
+ raise RuntimeError(f"Cannot find {binary}")
41
+
42
+ @abstractclassmethod
43
+ def supports_target(target: GPUTarget):
44
+ raise NotImplementedError
45
+
46
+ @abstractmethod
47
+ def hash(self) -> str:
48
+ """Returns a unique identifier for this backend"""
49
+ raise NotImplementedError
50
+
51
+ @abstractmethod
52
+ def parse_options(self, options: dict) -> object:
53
+ """
54
+ Converts an `options` dictionary into an arbitrary object and returns it.
55
+ This function may contain target-specific heuristics and check the legality of the provided options
56
+ """
57
+ raise NotImplementedError
58
+
59
+ @abstractmethod
60
+ def add_stages(self, stages: dict, options: object) -> None:
61
+ """
62
+ Populates `stages` dictionary with entries of the form:
63
+ ir_name [str] => Function[(src: str, metadata: dict) -> str|bytes]
64
+ The value of each entry may populate a `metadata` dictionary.
65
+ Stages will be run sequentially (in inseriton order) and can communicate using `metadata`.
66
+ All stages are expected to return a `str` object, except for the last stage which returns
67
+ a `bytes` object for execution by the launcher.
68
+ """
69
+ raise NotImplementedError
70
+
71
+ @abstractmethod
72
+ def load_dialects(self, context):
73
+ """
74
+ Load additional MLIR dialects into the provided `context`
75
+ """
76
+ raise NotImplementedError
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/builtin_types.h ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ /*******************************************************************************
51
+ * *
52
+ * *
53
+ * *
54
+ *******************************************************************************/
55
+
56
+ #include "device_types.h"
57
+ #if !defined(__CUDACC_RTC__)
58
+ #define EXCLUDE_FROM_RTC
59
+ #include "driver_types.h"
60
+ #undef EXCLUDE_FROM_RTC
61
+ #endif /* !__CUDACC_RTC__ */
62
+ #include "surface_types.h"
63
+ #include "texture_types.h"
64
+ #include "vector_types.h"
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/common_functions.h ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2018 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__)
51
+ #if defined(_MSC_VER)
52
+ #pragma message("common_functions.h is an internal header file and must not be used directly. This file will be removed in a future CUDA release. Please use cuda_runtime_api.h or cuda_runtime.h instead.")
53
+ #else
54
+ #warning "common_functions.h is an internal header file and must not be used directly. This file will be removed in a future CUDA release. Please use cuda_runtime_api.h or cuda_runtime.h instead."
55
+ #endif
56
+ #define __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
57
+ #define __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_COMMON_FUNCTIONS_H_WRAPPER__
58
+ #endif
59
+
60
+ #include "crt/common_functions.h"
61
+
62
+ #if defined(__UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_COMMON_FUNCTIONS_H_WRAPPER__)
63
+ #undef __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
64
+ #undef __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_COMMON_FUNCTIONS_H_WRAPPER__
65
+ #endif
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/coalesced_scan.h ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 1993-2016 NVIDIA Corporation. All rights reserved.
2
+ *
3
+ * NOTICE TO LICENSEE:
4
+ *
5
+ * The source code and/or documentation ("Licensed Deliverables") are
6
+ * subject to NVIDIA intellectual property rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * The Licensed Deliverables contained herein are PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and are being provided under the terms and
11
+ * conditions of a form of NVIDIA software license agreement by and
12
+ * between NVIDIA and Licensee ("License Agreement") or electronically
13
+ * accepted by Licensee. Notwithstanding any terms or conditions to
14
+ * the contrary in the License Agreement, reproduction or disclosure
15
+ * of the Licensed Deliverables to any third party without the express
16
+ * written consent of NVIDIA is prohibited.
17
+ *
18
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
19
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
20
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. THEY ARE
21
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
22
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
23
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
24
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
25
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
26
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
27
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
28
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
29
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
30
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
31
+ * OF THESE LICENSED DELIVERABLES.
32
+ *
33
+ * U.S. Government End Users. These Licensed Deliverables are a
34
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
35
+ * 1995), consisting of "commercial computer software" and "commercial
36
+ * computer software documentation" as such terms are used in 48
37
+ * C.F.R. 12.212 (SEPT 1995) and are provided to the U.S. Government
38
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
39
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
40
+ * U.S. Government End Users acquire the Licensed Deliverables with
41
+ * only those rights set forth herein.
42
+ *
43
+ * Any use of the Licensed Deliverables in individual and commercial
44
+ * software must include, in the user documentation and internal
45
+ * comments to the code, the above Disclaimer and U.S. Government End
46
+ * Users Notice.
47
+ */
48
+
49
+ #ifndef _CG_COALESCED_SCAN_H_
50
+ #define _CG_COALESCED_SCAN_H_
51
+
52
+ #include "info.h"
53
+ #include "helpers.h"
54
+ #include "cooperative_groups.h"
55
+ #include "partitioning.h"
56
+ #include "functional.h"
57
+
58
+ _CG_BEGIN_NAMESPACE
59
+
60
+ namespace details {
61
+
62
+ template <typename TyGroup, typename TyVal, typename TyOp>
63
+ _CG_QUALIFIER auto inclusive_scan_contiguous(const TyGroup& group, TyVal&& val, TyOp&& op) -> decltype(op(val, val)) {
64
+ auto out = val;
65
+ for (int mask = 1; mask < group.size(); mask <<= 1) {
66
+ auto tmp = group.shfl_up(out, mask);
67
+ if (mask <= group.thread_rank()) {
68
+ out = op(out, tmp);
69
+ }
70
+ }
71
+
72
+ return out;
73
+ }
74
+
75
+ template <typename TyGroup, typename TyVal, typename TyOp>
76
+ _CG_QUALIFIER auto inclusive_scan_non_contiguous(const TyGroup& group, TyVal&& val, TyOp&& op) -> decltype(op(val, val)) {
77
+ const unsigned int groupSize = group.size();
78
+ auto out = val;
79
+
80
+ const unsigned int mask = details::_coalesced_group_data_access::get_mask(group);
81
+ unsigned int lanemask = details::lanemask32_lt() & mask;
82
+ unsigned int srcLane = details::laneid();
83
+
84
+ const unsigned int base = __ffs(mask)-1; /* lane with rank == 0 */
85
+ const unsigned int rank = __popc(lanemask);
86
+
87
+ for (unsigned int i = 1, j = 1; i < groupSize; i <<= 1) {
88
+ if (i <= rank) {
89
+ srcLane -= j;
90
+ j = i; /* maximum possible lane */
91
+
92
+ unsigned int begLane = base + rank - i; /* minimum possible lane */
93
+
94
+ /* Next source lane is in the range [ begLane .. srcLane ]
95
+ * If begLane < srcLane then do a binary search.
96
+ */
97
+ while (begLane < srcLane) {
98
+ const unsigned int halfLane = (begLane + srcLane) >> 1;
99
+ const unsigned int halfMask = lanemask >> halfLane;
100
+ const unsigned int d = __popc(halfMask);
101
+ if (d < i) {
102
+ srcLane = halfLane - 1; /* halfLane too large */
103
+ }
104
+ else if ((i < d) || !(halfMask & 0x01)) {
105
+ begLane = halfLane + 1; /* halfLane too small */
106
+ }
107
+ else {
108
+ begLane = srcLane = halfLane; /* happen to hit */
109
+ }
110
+ }
111
+ }
112
+
113
+ auto tmp = details::tile::shuffle_dispatch<TyVal>::shfl(out, mask, srcLane, 32);
114
+ if (i <= rank) {
115
+ out = op(out, tmp);
116
+ }
117
+ }
118
+ return out;
119
+ }
120
+
121
+ template <unsigned int TySize, typename ParentT, typename TyVal, typename TyOp>
122
+ _CG_QUALIFIER auto coalesced_inclusive_scan(const __single_warp_thread_block_tile<TySize, ParentT>& group,
123
+ TyVal&& val,
124
+ TyOp&& op) -> decltype(op(val, val)) {
125
+ return inclusive_scan_contiguous(group, _CG_STL_NAMESPACE::forward<TyVal>(val), _CG_STL_NAMESPACE::forward<TyOp>(op));
126
+ }
127
+
128
+ template <typename TyVal, typename TyOp>
129
+ _CG_QUALIFIER auto coalesced_inclusive_scan(const coalesced_group& group, TyVal&& val, TyOp&& op) -> decltype(op(val, val)) {
130
+ if (group.size() == 32) {
131
+ return inclusive_scan_contiguous(group, _CG_STL_NAMESPACE::forward<TyVal>(val), _CG_STL_NAMESPACE::forward<TyOp>(op));
132
+ }
133
+ else {
134
+ return inclusive_scan_non_contiguous(group, _CG_STL_NAMESPACE::forward<TyVal>(val), _CG_STL_NAMESPACE::forward<TyOp>(op));
135
+ }
136
+ }
137
+
138
+ template <bool IntegralOptimized>
139
+ struct scan_choose_convertion;
140
+
141
+ template<>
142
+ struct scan_choose_convertion<true> {
143
+ template <typename TyGroup, typename TyRes, typename TyVal>
144
+ _CG_STATIC_QUALIFIER details::remove_qual<TyVal> convert_inclusive_to_exclusive(const TyGroup& group, TyRes& result, TyVal&& val) {
145
+ return result - val;
146
+ }
147
+ };
148
+
149
+ template<>
150
+ struct scan_choose_convertion<false> {
151
+ template <typename TyGroup, typename TyRes, typename TyVal>
152
+ _CG_STATIC_QUALIFIER details::remove_qual<TyVal> convert_inclusive_to_exclusive(const TyGroup& group, TyRes& result, TyVal&& val) {
153
+ auto ret = group.shfl_up(result, 1);
154
+ if (group.thread_rank() == 0) {
155
+ return {};
156
+ }
157
+ else {
158
+ return ret;
159
+ }
160
+ }
161
+ };
162
+
163
+ template <typename TyGroup, typename TyRes, typename TyVal, typename TyFn>
164
+ _CG_QUALIFIER auto convert_inclusive_to_exclusive(const TyGroup& group, TyRes& result, TyVal&& val, TyFn&& op) -> decltype(op(val, val)) {
165
+ using conversion = scan_choose_convertion<_CG_STL_NAMESPACE::is_same<remove_qual<TyFn>, cooperative_groups::plus<remove_qual<TyVal>>>::value
166
+ && _CG_STL_NAMESPACE::is_integral<remove_qual<TyVal>>::value>;
167
+ return conversion::convert_inclusive_to_exclusive(group, result, _CG_STL_NAMESPACE::forward<TyVal>(val));
168
+ }
169
+
170
+ } // details
171
+
172
+ _CG_END_NAMESPACE
173
+
174
+ #endif // _CG_COALESCED_SCAN_H_
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/driver_abi.h ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 1993-2016 NVIDIA Corporation. All rights reserved.
2
+ *
3
+ * NOTICE TO LICENSEE:
4
+ *
5
+ * The source code and/or documentation ("Licensed Deliverables") are
6
+ * subject to NVIDIA intellectual property rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * The Licensed Deliverables contained herein are PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and are being provided under the terms and
11
+ * conditions of a form of NVIDIA software license agreement by and
12
+ * between NVIDIA and Licensee ("License Agreement") or electronically
13
+ * accepted by Licensee. Notwithstanding any terms or conditions to
14
+ * the contrary in the License Agreement, reproduction or disclosure
15
+ * of the Licensed Deliverables to any third party without the express
16
+ * written consent of NVIDIA is prohibited.
17
+ *
18
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
19
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
20
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. THEY ARE
21
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
22
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
23
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
24
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
25
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
26
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
27
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
28
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
29
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
30
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
31
+ * OF THESE LICENSED DELIVERABLES.
32
+ *
33
+ * U.S. Government End Users. These Licensed Deliverables are a
34
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
35
+ * 1995), consisting of "commercial computer software" and "commercial
36
+ * computer software documentation" as such terms are used in 48
37
+ * C.F.R. 12.212 (SEPT 1995) and are provided to the U.S. Government
38
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
39
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
40
+ * U.S. Government End Users acquire the Licensed Deliverables with
41
+ * only those rights set forth herein.
42
+ *
43
+ * Any use of the Licensed Deliverables in individual and commercial
44
+ * software must include, in the user documentation and internal
45
+ * comments to the code, the above Disclaimer and U.S. Government End
46
+ * Users Notice.
47
+ */
48
+
49
+ #ifndef _CG_DRIVER_API_H
50
+ #define _CG_DRIVER_API_H
51
+
52
+ #include "info.h"
53
+
54
+ _CG_BEGIN_NAMESPACE
55
+
56
+ namespace details {
57
+ template <unsigned int RegId>
58
+ _CG_QUALIFIER unsigned int load_env_reg() {
59
+ // Abort by default
60
+ _CG_ABORT();
61
+ return 0;
62
+ }
63
+
64
+ template <unsigned int HiReg, unsigned int LoReg>
65
+ _CG_QUALIFIER unsigned long long load_env_reg64() {
66
+ unsigned long long registerLo = load_env_reg<LoReg>();
67
+ unsigned long long registerHi = load_env_reg<HiReg>();
68
+
69
+ return (registerHi << 32) | registerLo;
70
+ }
71
+
72
+ // inline PTX for accessing registers requires an immediate for the special reg
73
+ # define LOAD_ENVREG(NUMBER) \
74
+ template <> _CG_QUALIFIER unsigned int load_env_reg<NUMBER>() { \
75
+ unsigned int r; \
76
+ asm ("mov.u32 %0, %%envreg" #NUMBER ";" : "=r"(r)); \
77
+ return r; \
78
+ }
79
+
80
+ // Instantiate loaders for registers used
81
+ LOAD_ENVREG(0);
82
+ LOAD_ENVREG(1);
83
+ LOAD_ENVREG(2);
84
+ # undef LOAD_ENVREG
85
+
86
+ struct grid_workspace {
87
+ unsigned int wsSize;
88
+ unsigned int barrier;
89
+ };
90
+
91
+ _CG_QUALIFIER grid_workspace* get_grid_workspace() {
92
+ unsigned long long gridWsAbiAddress = load_env_reg64<1, 2>();
93
+ // Interpret the address from envreg 1 and 2 as the driver's grid workspace
94
+ return (reinterpret_cast<grid_workspace*>(gridWsAbiAddress));
95
+ }
96
+ }
97
+ _CG_END_NAMESPACE
98
+
99
+ #endif // _CG_DRIVER_API_H
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/info.h ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 1993-2021 NVIDIA Corporation. All rights reserved.
2
+ *
3
+ * NOTICE TO LICENSEE:
4
+ *
5
+ * The source code and/or documentation ("Licensed Deliverables") are
6
+ * subject to NVIDIA intellectual property rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * The Licensed Deliverables contained herein are PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and are being provided under the terms and
11
+ * conditions of a form of NVIDIA software license agreement by and
12
+ * between NVIDIA and Licensee ("License Agreement") or electronically
13
+ * accepted by Licensee. Notwithstanding any terms or conditions to
14
+ * the contrary in the License Agreement, reproduction or disclosure
15
+ * of the Licensed Deliverables to any third party without the express
16
+ * written consent of NVIDIA is prohibited.
17
+ *
18
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
19
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
20
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. THEY ARE
21
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
22
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
23
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
24
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
25
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
26
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
27
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
28
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
29
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
30
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
31
+ * OF THESE LICENSED DELIVERABLES.
32
+ *
33
+ * U.S. Government End Users. These Licensed Deliverables are a
34
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
35
+ * 1995), consisting of "commercial computer software" and "commercial
36
+ * computer software documentation" as such terms are used in 48
37
+ * C.F.R. 12.212 (SEPT 1995) and are provided to the U.S. Government
38
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
39
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
40
+ * U.S. Government End Users acquire the Licensed Deliverables with
41
+ * only those rights set forth herein.
42
+ *
43
+ * Any use of the Licensed Deliverables in individual and commercial
44
+ * software must include, in the user documentation and internal
45
+ * comments to the code, the above Disclaimer and U.S. Government End
46
+ * Users Notice.
47
+ */
48
+
49
+
50
+
51
+ #ifndef _CG_INFO_H_
52
+ #define _CG_INFO_H_
53
+ /*
54
+ ** Define: _CG_VERSION
55
+ */
56
+ #define _CG_VERSION 1000
57
+
58
+ /*
59
+ ** Define: _CG_ABI_VERSION
60
+ */
61
+ #ifndef _CG_ABI_VERSION
62
+ # define _CG_ABI_VERSION 1
63
+ #endif
64
+
65
+ /*
66
+ ** Define: _CG_ABI_EXPERIMENTAL
67
+ ** Desc: If enabled, sets all features enabled (ABI-breaking or experimental)
68
+ */
69
+ #if defined(_CG_ABI_EXPERIMENTAL)
70
+ #endif
71
+
72
+ #define _CG_CONCAT_INNER(x, y) x ## y
73
+ #define _CG_CONCAT_OUTER(x, y) _CG_CONCAT_INNER(x, y)
74
+ #define _CG_NAMESPACE _CG_CONCAT_OUTER(__v, _CG_ABI_VERSION)
75
+
76
+ #define _CG_BEGIN_NAMESPACE \
77
+ namespace cooperative_groups { namespace _CG_NAMESPACE {
78
+ #define _CG_END_NAMESPACE \
79
+ }; using namespace _CG_NAMESPACE; };
80
+
81
+ #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSC_VER) && (_MSC_VER >= 1900))
82
+ # define _CG_CPP11_FEATURES
83
+ #endif
84
+
85
+ #if !defined(_CG_QUALIFIER)
86
+ # define _CG_QUALIFIER __forceinline__ __device__
87
+ #endif
88
+ #if !defined(_CG_STATIC_QUALIFIER)
89
+ # define _CG_STATIC_QUALIFIER static __forceinline__ __device__
90
+ #endif
91
+ #if !defined(_CG_CONSTEXPR_QUALIFIER)
92
+ # if defined(_CG_CPP11_FEATURES)
93
+ # define _CG_CONSTEXPR_QUALIFIER constexpr __forceinline__ __device__
94
+ # else
95
+ # define _CG_CONSTEXPR_QUALIFIER _CG_QUALIFIER
96
+ # endif
97
+ #endif
98
+ #if !defined(_CG_STATIC_CONSTEXPR_QUALIFIER)
99
+ # if defined(_CG_CPP11_FEATURES)
100
+ # define _CG_STATIC_CONSTEXPR_QUALIFIER static constexpr __forceinline__ __device__
101
+ # else
102
+ # define _CG_STATIC_CONSTEXPR_QUALIFIER _CG_STATIC_QUALIFIER
103
+ # endif
104
+ #endif
105
+
106
+ #if defined(_MSC_VER)
107
+ # define _CG_DEPRECATED __declspec(deprecated)
108
+ #else
109
+ # define _CG_DEPRECATED __attribute__((deprecated))
110
+ #endif
111
+
112
+ #if (__CUDA_ARCH__ >= 600) || !defined(__CUDA_ARCH__)
113
+ # define _CG_HAS_GRID_GROUP
114
+ #endif
115
+ #if (__CUDA_ARCH__ >= 600) || !defined(__CUDA_ARCH__)
116
+ # define _CG_HAS_MULTI_GRID_GROUP
117
+ #endif
118
+ #if (__CUDA_ARCH__ >= 700) || !defined(__CUDA_ARCH__)
119
+ # define _CG_HAS_MATCH_COLLECTIVE
120
+ #endif
121
+
122
+ #if (__CUDA_ARCH__ >= 800) || !defined(__CUDA_ARCH__) && (defined(__NVCC__) || defined(__CUDACC_RTC__))
123
+ # define _CG_HAS_OP_REDUX
124
+ #endif
125
+
126
+ #if ((__CUDA_ARCH__ >= 800) || !defined(__CUDA_ARCH__)) && !defined(_CG_USER_PROVIDED_SHARED_MEMORY)
127
+ # define _CG_HAS_RESERVED_SHARED
128
+ #endif
129
+
130
+ #if ((__CUDA_ARCH__ >= 900) || !defined(__CUDA_ARCH__)) && \
131
+ (defined(__NVCC__) || defined(__CUDACC_RTC__) || defined(_CG_CLUSTER_INTRINSICS_AVAILABLE)) && \
132
+ defined(_CG_CPP11_FEATURES)
133
+ # define _CG_HAS_CLUSTER_GROUP
134
+ #endif
135
+
136
+ #if (__CUDA_ARCH__ >= 900) || !defined(__CUDA_ARCH__)
137
+ # define _CG_HAS_INSTR_ELECT
138
+ #endif
139
+
140
+ // Has __half and __half2
141
+ // Only usable if you include the cuda_fp16.h extension, and
142
+ // _before_ including cooperative_groups.h
143
+ #ifdef __CUDA_FP16_TYPES_EXIST__
144
+ # define _CG_HAS_FP16_COLLECTIVE
145
+ #endif
146
+
147
+ // Include libcu++ where supported.
148
+ #if defined(_CG_CPP11_FEATURES) && !defined(__QNX__) && !defined(__ibmxl__) && \
149
+ (defined(__NVCC__) || defined(__CUDACC_RTC__)) && \
150
+ (defined(__x86_64__) || defined(__aarch64__) || defined(__ppc64__)|| defined(_M_X64) || defined(_M_ARM64)) && \
151
+ (defined(_MSC_VER) || defined(__GNUC__) || defined(__clang__))
152
+ # define _CG_USE_CUDA_STL
153
+ #else
154
+ # define _CG_USE_OWN_TRAITS
155
+ #endif
156
+
157
+ #if defined(_CG_USE_CUDA_STL) && (!defined(__CUDA_ARCH__) || \
158
+ ((!defined(_MSC_VER) && __CUDA_ARCH__ >= 600) || (defined(_MSC_VER) && __CUDA_ARCH__ >= 700)))
159
+ # define _CG_HAS_STL_ATOMICS
160
+ #endif
161
+
162
+ #ifdef _CG_CPP11_FEATURES
163
+ // Use cuda::std:: for type_traits
164
+ # if defined(_CG_USE_CUDA_STL)
165
+ # define _CG_STL_NAMESPACE cuda::std
166
+ # include <cuda/std/type_traits>
167
+ // Use CG's implementation of type traits
168
+ # else
169
+ # define _CG_STL_NAMESPACE cooperative_groups::details::templates
170
+ # endif
171
+ #endif
172
+
173
+ #ifdef _CG_CPP11_FEATURES
174
+ # define _CG_STATIC_CONST_DECL static constexpr
175
+ # define _CG_CONST_DECL constexpr
176
+ #else
177
+ # define _CG_STATIC_CONST_DECL static const
178
+ # define _CG_CONST_DECL const
179
+ #endif
180
+
181
+ #if (defined(_MSC_VER) && !defined(_WIN64)) || defined(__arm__)
182
+ # define _CG_ASM_PTR_CONSTRAINT "r"
183
+ #else
184
+ # define _CG_ASM_PTR_CONSTRAINT "l"
185
+ #endif
186
+
187
+ /*
188
+ ** Define: CG_DEBUG
189
+ ** What: Enables various runtime safety checks
190
+ */
191
+ #if defined(__CUDACC_DEBUG__) && defined(CG_DEBUG) && !defined(NDEBUG)
192
+ # define _CG_DEBUG
193
+ #endif
194
+
195
+ #if defined(_CG_DEBUG)
196
+ # include <assert.h>
197
+ # define _CG_ASSERT(x) assert((x));
198
+ # define _CG_ABORT() assert(0);
199
+ #else
200
+ # define _CG_ASSERT(x)
201
+ # define _CG_ABORT() __trap();
202
+ #endif
203
+
204
+ _CG_BEGIN_NAMESPACE
205
+
206
+ namespace details {
207
+ _CG_STATIC_CONST_DECL unsigned int default_max_block_size = 1024;
208
+
209
+ #if defined(_CG_CPP11_FEATURES) && !defined(_CG_USE_CUDA_STL)
210
+ namespace templates {
211
+
212
+ /**
213
+ * Integral constants
214
+ **/
215
+ template <typename Ty, Ty Val>
216
+ struct integral_constant {
217
+ static constexpr Ty value = Val;
218
+ typedef Ty type;
219
+
220
+ _CG_QUALIFIER constexpr operator type() const noexcept { return value; }
221
+ _CG_QUALIFIER constexpr type operator()() const noexcept { return value; }
222
+ };
223
+
224
+ typedef integral_constant<bool, true> true_type;
225
+ typedef integral_constant<bool, false> false_type;
226
+
227
+ /**
228
+ * CV Qualifiers
229
+ **/
230
+ template <class Ty> struct is_lvalue_reference : public details::templates::false_type {};
231
+ template <class Ty> struct is_lvalue_reference<Ty&> : public details::templates::true_type {};
232
+
233
+ template <class Ty> struct remove_reference {typedef Ty type;};
234
+ template <class Ty> struct remove_reference<Ty&> {typedef Ty type;};
235
+ template <class Ty> struct remove_reference<Ty&&> {typedef Ty type;};
236
+
237
+ template <class Ty>
238
+ using remove_reference_t = typename details::templates::remove_reference<Ty>::type;
239
+
240
+ template <class Ty> struct remove_const {typedef Ty type;};
241
+ template <class Ty> struct remove_const<const Ty> {typedef Ty type;};
242
+
243
+ template <class Ty> struct remove_volatile {typedef Ty type;};
244
+ template <class Ty> struct remove_volatile<volatile Ty> {typedef Ty type;};
245
+
246
+ template <class Ty> struct remove_cv {typedef typename details::templates::remove_volatile<typename details::templates::remove_const<Ty>::type>::type type;};
247
+
248
+ template <class Ty>
249
+ using remove_cv_t = typename details::templates::remove_cv<Ty>::type;
250
+
251
+ template <class Ty>
252
+ _CG_QUALIFIER Ty&& forward(remove_reference_t<Ty> &t) noexcept {
253
+ return static_cast<Ty&&>(t);
254
+ }
255
+
256
+ template <class Ty>
257
+ _CG_QUALIFIER Ty&& forward(remove_reference_t<Ty> &&t) noexcept {
258
+ static_assert(!details::templates::is_lvalue_reference<Ty>::value, "Forwarding an rvalue as an lvalue is not allowed.");
259
+ return static_cast<Ty&&>(t);
260
+ }
261
+
262
+ /**
263
+ * is_integral
264
+ **/
265
+ template <class Ty> struct _is_integral : public details::templates::false_type {};
266
+ template <> struct _is_integral<bool> : public details::templates::true_type {};
267
+ template <> struct _is_integral<char> : public details::templates::true_type {};
268
+ template <> struct _is_integral<unsigned char> : public details::templates::true_type {};
269
+ template <> struct _is_integral<short> : public details::templates::true_type {};
270
+ template <> struct _is_integral<unsigned short> : public details::templates::true_type {};
271
+ template <> struct _is_integral<int> : public details::templates::true_type {};
272
+ template <> struct _is_integral<unsigned int> : public details::templates::true_type {};
273
+ template <> struct _is_integral<long> : public details::templates::true_type {};
274
+ template <> struct _is_integral<long long> : public details::templates::true_type {};
275
+ template <> struct _is_integral<unsigned long> : public details::templates::true_type {};
276
+ template <> struct _is_integral<unsigned long long> : public details::templates::true_type {};
277
+ //Vector type support?
278
+
279
+ template <typename Ty>
280
+ struct is_integral : public details::templates::_is_integral<typename details::templates::remove_cv<Ty>::type> {};
281
+
282
+ /**
283
+ * is_floating_point
284
+ **/
285
+ template <class Ty> struct _is_floating_point : public details::templates::false_type {};
286
+ template <> struct _is_floating_point<float> : public details::templates::true_type {};
287
+ template <> struct _is_floating_point<double> : public details::templates::true_type {};
288
+ template <> struct _is_floating_point<long double> : public details::templates::true_type {};
289
+ # ifdef __CUDA_FP16_TYPES_EXIST__
290
+ template <> struct _is_floating_point<__half> : public details::templates::true_type {};
291
+ template <> struct _is_floating_point<__half2> : public details::templates::true_type {};
292
+ # endif
293
+ //Vector type support?
294
+
295
+ template <typename Ty>
296
+ struct is_floating_point : public details::templates::_is_floating_point<typename details::templates::remove_cv<Ty>::type> {};
297
+
298
+ template <class T>
299
+ struct is_arithmetic : details::templates::integral_constant<
300
+ bool,
301
+ details::templates::is_integral<T>::value ||
302
+ details::templates::is_floating_point<T>::value> {};
303
+
304
+ template <typename Ty, bool = details::templates::is_arithmetic<Ty>::value>
305
+ struct _is_unsigned : details::templates::integral_constant<bool, Ty(0) < Ty(-1)> {};
306
+
307
+ template <typename Ty>
308
+ struct _is_unsigned<Ty,false> : details::templates::false_type {};
309
+
310
+ template <typename Ty>
311
+ struct is_unsigned : _is_unsigned<typename details::templates::remove_cv<Ty>::type> {};
312
+
313
+ template <typename Ty> struct _is_pointer : public details::templates::false_type {};
314
+ template <typename Ty> struct _is_pointer<Ty*> : public details::templates::true_type {};
315
+
316
+ template <typename Ty>
317
+ struct is_pointer : _is_pointer<typename details::templates::remove_cv<Ty>::type> {};
318
+
319
+ /**
320
+ * programmatic type traits
321
+ **/
322
+ template<bool B, class Ty = void>
323
+ struct enable_if {};
324
+
325
+ template<class Ty>
326
+ struct enable_if<true, Ty> { typedef Ty type; };
327
+
328
+ template<bool Cond, typename Ty = void>
329
+ using enable_if_t = typename details::templates::enable_if<Cond, Ty>::type;
330
+
331
+ template<class Ty1, class Ty2>
332
+ struct is_same : details::templates::false_type {};
333
+
334
+ template<class Ty>
335
+ struct is_same<Ty, Ty> : details::templates::true_type {};
336
+
337
+ } // templates
338
+ #endif // _CG_CPP11_FEATURES
339
+
340
+ } // details
341
+ _CG_END_NAMESPACE
342
+
343
+
344
+ #endif // _CG_INFO_H_
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/invoke.h ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2022 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #ifndef _CG_INVOKE_H
51
+ #define _CG_INVOKE_H
52
+
53
+ #include "info.h"
54
+ #include "helpers.h"
55
+
56
+ #if defined(_CG_CPP11_FEATURES)
57
+
58
+ _CG_BEGIN_NAMESPACE
59
+
60
+ namespace details {
61
+
62
+ template <typename Group>
63
+ struct _elect_group_supported : _CG_STL_NAMESPACE::false_type {};
64
+ #ifdef _CG_HAS_INSTR_ELECT
65
+ template<>
66
+ struct _elect_group_supported<coalesced_group> : _CG_STL_NAMESPACE::true_type {};
67
+ template<unsigned int Size, typename Parent>
68
+ struct _elect_group_supported<thread_block_tile<Size, Parent>> :
69
+ _CG_STL_NAMESPACE::integral_constant<bool, (Size <= 32)> {};
70
+ #endif
71
+
72
+ template <typename Group>
73
+ struct elect_group_supported : public _elect_group_supported<details::remove_qual<Group>> {};
74
+
75
+ template<typename Group>
76
+ _CG_STATIC_QUALIFIER bool elect_one(const Group& group, unsigned int mask, unsigned int& leader_lane) {
77
+ int is_leader = 0;
78
+ #ifdef _CG_HAS_INSTR_ELECT
79
+ asm("{\n\t"
80
+ " .reg .pred p;\n\t"
81
+ " elect.sync %0|p, %2;\n\t"
82
+ " @p mov.s32 %1, 1;\n\t"
83
+ "}"
84
+ : "+r"(leader_lane), "+r"(is_leader) : "r" (mask));
85
+ #endif
86
+ return is_leader;
87
+ }
88
+
89
+ template<bool UseElect>
90
+ struct invoke_one_impl {};
91
+
92
+ template<>
93
+ struct invoke_one_impl<true> {
94
+ template<typename Group, typename Fn, typename... Args>
95
+ _CG_STATIC_QUALIFIER void invoke_one(const Group& group, Fn&& fn, Args&&... args) {
96
+ auto mask = details::_coalesced_group_data_access::get_mask(group);
97
+ unsigned int leader_lane = 0;
98
+
99
+ if (elect_one(group, mask, leader_lane)) {
100
+ _CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...);
101
+ }
102
+ }
103
+
104
+ template<typename Group, typename Fn, typename... Args>
105
+ _CG_STATIC_QUALIFIER auto invoke_one_broadcast(const Group& group, Fn&& fn, Args&&... args)
106
+ -> typename _CG_STL_NAMESPACE::remove_reference<
107
+ decltype(_CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...))>::type {
108
+
109
+ using ResultType = decltype(_CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...));
110
+ details::remove_qual<ResultType> result;
111
+ auto mask = details::_coalesced_group_data_access::get_mask(group);
112
+ unsigned int leader_lane = 0;
113
+
114
+ if (elect_one(group, mask, leader_lane)) {
115
+ result = _CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...);
116
+ }
117
+
118
+ // Need to use low level api instead of group.shfl, because elect_one returns lane id, not group rank.
119
+ return tile::shuffle_dispatch<ResultType>::shfl(result, mask, leader_lane, 32);
120
+ }
121
+ };
122
+
123
+ template<>
124
+ struct invoke_one_impl<false> {
125
+ template<typename Group, typename Fn, typename... Args>
126
+ _CG_STATIC_QUALIFIER void invoke_one(const Group& group, Fn&& fn, Args&&... args) {
127
+ if (group.thread_rank() == 0) {
128
+ _CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...);
129
+ }
130
+ }
131
+
132
+ template<typename Group, typename Fn, typename... Args>
133
+ _CG_STATIC_QUALIFIER auto invoke_one_broadcast(const Group& group, Fn&& fn, Args&&... args)
134
+ -> typename _CG_STL_NAMESPACE::remove_reference<
135
+ decltype(_CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...))>::type {
136
+
137
+ using ResultType = decltype(_CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...));
138
+ details::remove_qual<ResultType> result;
139
+
140
+ if (group.thread_rank() == 0) {
141
+ result = _CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...);
142
+ }
143
+
144
+ return group.shfl(result, 0);
145
+ }
146
+ };
147
+
148
+
149
+ }; // namespace details
150
+
151
+ template<typename Group, typename Fn, typename... Args>
152
+ _CG_QUALIFIER void invoke_one(const Group& group, Fn&& fn, Args&&... args) {
153
+ using impl = details::invoke_one_impl<details::elect_group_supported<Group>::value>;
154
+ impl::invoke_one(group, _CG_STL_NAMESPACE::forward<Fn>(fn), _CG_STL_NAMESPACE::forward<Args>(args)...);
155
+ }
156
+
157
+ template<typename Fn, typename... Args>
158
+ _CG_QUALIFIER auto invoke_one_broadcast(const coalesced_group& group, Fn&& fn, Args&&... args)
159
+ -> typename _CG_STL_NAMESPACE::remove_reference<
160
+ decltype(_CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...))>::type {
161
+
162
+ using ResultType = decltype(_CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...));
163
+ static_assert(!_CG_STL_NAMESPACE::is_same<ResultType, void>::value,
164
+ "For invocables returning void invoke_one should be used instead");
165
+ using impl = details::invoke_one_impl<details::elect_group_supported<coalesced_group>::value>;
166
+ return impl::invoke_one_broadcast(group,
167
+ _CG_STL_NAMESPACE::forward<Fn>(fn),
168
+ _CG_STL_NAMESPACE::forward<Args>(args)...);
169
+ }
170
+
171
+ template<unsigned int Size, typename Parent, typename Fn, typename... Args>
172
+ _CG_QUALIFIER auto invoke_one_broadcast(const thread_block_tile<Size, Parent>& group, Fn&& fn, Args&&... args)
173
+ -> typename _CG_STL_NAMESPACE::remove_reference<
174
+ decltype(_CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...))>::type {
175
+
176
+ using ResultType = decltype(_CG_STL_NAMESPACE::forward<Fn>(fn)(_CG_STL_NAMESPACE::forward<Args>(args)...));
177
+ static_assert(!_CG_STL_NAMESPACE::is_same<ResultType, void>::value,
178
+ "For invocables returning void invoke_one should be used instead");
179
+ using impl = details::invoke_one_impl<details::elect_group_supported<thread_block_tile<Size, Parent>>::value>;
180
+ return impl::invoke_one_broadcast(group,
181
+ _CG_STL_NAMESPACE::forward<Fn>(fn),
182
+ _CG_STL_NAMESPACE::forward<Args>(args)...);
183
+ }
184
+
185
+ _CG_END_NAMESPACE
186
+
187
+ #endif //_CG_CPP11_FEATURES
188
+
189
+ #endif // _CG_INVOKE_H
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/partitioning.h ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2016 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #ifndef _CG_PARTITIONING_H
51
+ #define _CG_PARTITIONING_H
52
+
53
+ #include "info.h"
54
+ #include "helpers.h"
55
+
56
+ _CG_BEGIN_NAMESPACE
57
+
58
+ namespace details {
59
+
60
+ template <typename TyGroup>
61
+ _CG_STATIC_QUALIFIER coalesced_group _binary_partition(const TyGroup &tile, bool pred) {
62
+ const unsigned int fullMask = ~0u;
63
+
64
+ unsigned int thisMask = _coalesced_group_data_access::get_mask(tile);
65
+ unsigned int predMask = pred ? 0 : fullMask;
66
+ unsigned int setMask = __ballot_sync(thisMask, pred);
67
+
68
+ if (setMask == thisMask || setMask == 0) {
69
+ coalesced_group subTile = _coalesced_group_data_access::construct_from_mask<coalesced_group>(thisMask);
70
+ _coalesced_group_data_access::modify_meta_group(subTile, 0, 1);
71
+ return subTile;
72
+ }
73
+ else {
74
+ unsigned int subMask = thisMask & (setMask ^ predMask);
75
+ coalesced_group subTile = _coalesced_group_data_access::construct_from_mask<coalesced_group>(subMask);
76
+ _coalesced_group_data_access::modify_meta_group(subTile, pred, 2);
77
+ return subTile;
78
+ }
79
+ }
80
+
81
+ #if defined(_CG_HAS_MATCH_COLLECTIVE) && defined(_CG_CPP11_FEATURES)
82
+ template <typename TyPredicate>
83
+ struct _labeled_partition_dispatch {
84
+ template <typename TyGroup>
85
+ _CG_QUALIFIER coalesced_group operator()(const TyGroup &tile, TyPredicate pred) {
86
+ unsigned int thisMask = _coalesced_group_data_access::get_mask(tile);
87
+ unsigned int thisBias = __ffs(thisMask) - 1; // Subtract 1 to index properly from [1-32]
88
+ unsigned int subMask = __match_any_sync(thisMask, pred);
89
+
90
+ coalesced_group subTile = _coalesced_group_data_access::construct_from_mask<coalesced_group>(subMask);
91
+
92
+ int leaderLaneId = subTile.shfl(details::laneid(), 0);
93
+
94
+ bool isLeader = !subTile.thread_rank();
95
+ unsigned int leaderMask = __ballot_sync(thisMask, isLeader);
96
+ unsigned int tileRank = __fns(leaderMask, leaderLaneId, 0) - thisBias;
97
+
98
+ _coalesced_group_data_access::modify_meta_group(subTile, tileRank, __popc(leaderMask));
99
+
100
+ return subTile;
101
+ }
102
+ };
103
+
104
+ template <>
105
+ struct _labeled_partition_dispatch<bool> {
106
+ template <typename TyGroup>
107
+ _CG_QUALIFIER coalesced_group operator()(const TyGroup &tile, bool pred) {
108
+ return _binary_partition(tile, pred);
109
+ }
110
+ };
111
+
112
+ template <typename TyPredicate>
113
+ struct _labeled_partition_dispatch<TyPredicate*> {
114
+ template <typename TyGroup>
115
+ _CG_QUALIFIER coalesced_group operator()(const TyGroup &tile, TyPredicate* pred) {
116
+ auto impl = _labeled_partition_dispatch<unsigned long long>();
117
+ return impl(tile, reinterpret_cast<unsigned long long>(pred));
118
+ }
119
+ };
120
+ #endif
121
+ }; // namespace details
122
+
123
+ _CG_STATIC_QUALIFIER coalesced_group binary_partition(const coalesced_group &tile, bool pred) {
124
+ return details::_binary_partition(tile, pred);
125
+ }
126
+
127
+ template <unsigned int Size, typename ParentT>
128
+ _CG_STATIC_QUALIFIER coalesced_group binary_partition(const thread_block_tile<Size, ParentT> &tile, bool pred) {
129
+ #ifdef _CG_CPP11_FEATURES
130
+ static_assert(Size <= 32, "Binary partition is available only for tiles of size smaller or equal to 32");
131
+ #endif
132
+ return details::_binary_partition(tile, pred);
133
+ }
134
+
135
+
136
+ #if defined(_CG_HAS_MATCH_COLLECTIVE) && defined(_CG_CPP11_FEATURES)
137
+ template <typename TyPredicate>
138
+ _CG_STATIC_QUALIFIER coalesced_group labeled_partition(const coalesced_group &tile, TyPredicate pred) {
139
+ static_assert(_CG_STL_NAMESPACE::is_integral<TyPredicate>::value ||
140
+ _CG_STL_NAMESPACE::is_pointer<TyPredicate>::value,
141
+ "labeled_partition predicate must be an integral or pointer type");
142
+ auto dispatch = details::_labeled_partition_dispatch<details::remove_qual<TyPredicate>>();
143
+ return dispatch(tile, pred);
144
+ }
145
+
146
+ template <typename TyPredicate, unsigned int Size, typename ParentT>
147
+ _CG_STATIC_QUALIFIER coalesced_group labeled_partition(const thread_block_tile<Size, ParentT> &tile, TyPredicate pred) {
148
+ static_assert(_CG_STL_NAMESPACE::is_integral<TyPredicate>::value ||
149
+ _CG_STL_NAMESPACE::is_pointer<TyPredicate>::value,
150
+ "labeled_partition predicate must be an integral or pointer type");
151
+ static_assert(Size <= 32, "Labeled partition is available only for tiles of size smaller or equal to 32");
152
+ auto dispatch = details::_labeled_partition_dispatch<details::remove_qual<TyPredicate>>();
153
+ return dispatch(tile, pred);
154
+ }
155
+ #endif
156
+
157
+ _CG_END_NAMESPACE
158
+
159
+ #endif // _CG_PARTITIONING_H
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cooperative_groups/details/sync.h ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 1993-2016 NVIDIA Corporation. All rights reserved.
2
+ *
3
+ * NOTICE TO LICENSEE:
4
+ *
5
+ * The source code and/or documentation ("Licensed Deliverables") are
6
+ * subject to NVIDIA intellectual property rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * The Licensed Deliverables contained herein are PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and are being provided under the terms and
11
+ * conditions of a form of NVIDIA software license agreement by and
12
+ * between NVIDIA and Licensee ("License Agreement") or electronically
13
+ * accepted by Licensee. Notwithstanding any terms or conditions to
14
+ * the contrary in the License Agreement, reproduction or disclosure
15
+ * of the Licensed Deliverables to any third party without the express
16
+ * written consent of NVIDIA is prohibited.
17
+ *
18
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
19
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
20
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. THEY ARE
21
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
22
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
23
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
24
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
25
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
26
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
27
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
28
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
29
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
30
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
31
+ * OF THESE LICENSED DELIVERABLES.
32
+ *
33
+ * U.S. Government End Users. These Licensed Deliverables are a
34
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
35
+ * 1995), consisting of "commercial computer software" and "commercial
36
+ * computer software documentation" as such terms are used in 48
37
+ * C.F.R. 12.212 (SEPT 1995) and are provided to the U.S. Government
38
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
39
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
40
+ * U.S. Government End Users acquire the Licensed Deliverables with
41
+ * only those rights set forth herein.
42
+ *
43
+ * Any use of the Licensed Deliverables in individual and commercial
44
+ * software must include, in the user documentation and internal
45
+ * comments to the code, the above Disclaimer and U.S. Government End
46
+ * Users Notice.
47
+ */
48
+
49
+ #ifndef _CG_GRID_H
50
+ #define _CG_GRID_H
51
+
52
+ #include "info.h"
53
+
54
+ _CG_BEGIN_NAMESPACE
55
+
56
+ namespace details
57
+ {
58
+
59
+ typedef unsigned int barrier_t;
60
+
61
+ _CG_STATIC_QUALIFIER bool bar_has_flipped(unsigned int old_arrive, unsigned int current_arrive) {
62
+ return (((old_arrive ^ current_arrive) & 0x80000000) != 0);
63
+ }
64
+
65
+ _CG_STATIC_QUALIFIER bool is_cta_master() {
66
+ return (threadIdx.x + threadIdx.y + threadIdx.z == 0);
67
+ }
68
+
69
+ _CG_STATIC_QUALIFIER unsigned int sync_grids_arrive(volatile barrier_t *arrived) {
70
+ unsigned int oldArrive = 0;
71
+
72
+ __barrier_sync(0);
73
+
74
+ if (is_cta_master()) {
75
+ unsigned int expected = gridDim.x * gridDim.y * gridDim.z;
76
+ bool gpu_master = (blockIdx.x + blockIdx.y + blockIdx.z == 0);
77
+ unsigned int nb = 1;
78
+
79
+ if (gpu_master) {
80
+ nb = 0x80000000 - (expected - 1);
81
+ }
82
+
83
+ #if __CUDA_ARCH__ < 700
84
+ // Fence; barrier update; volatile polling; fence
85
+ __threadfence();
86
+
87
+ oldArrive = atomicAdd((unsigned int*)arrived, nb);
88
+ #else
89
+ // Barrier update with release; polling with acquire
90
+ asm volatile("atom.add.release.gpu.u32 %0,[%1],%2;" : "=r"(oldArrive) : _CG_ASM_PTR_CONSTRAINT((unsigned int*)arrived), "r"(nb) : "memory");
91
+ #endif
92
+ }
93
+
94
+ return oldArrive;
95
+ }
96
+
97
+
98
+ _CG_STATIC_QUALIFIER void sync_grids_wait(unsigned int oldArrive, volatile barrier_t *arrived) {
99
+ if (is_cta_master()) {
100
+ #if __CUDA_ARCH__ < 700
101
+ while (!bar_has_flipped(oldArrive, *arrived));
102
+
103
+ __threadfence();
104
+
105
+ #else
106
+ unsigned int current_arrive;
107
+ do {
108
+ asm volatile("ld.acquire.gpu.u32 %0,[%1];" : "=r"(current_arrive) : _CG_ASM_PTR_CONSTRAINT((unsigned int *)arrived) : "memory");
109
+ } while (!bar_has_flipped(oldArrive, current_arrive));
110
+ #endif
111
+ }
112
+
113
+ __barrier_sync(0);
114
+ }
115
+
116
+ /* - Multi warp groups synchronization routines - */
117
+
118
+ // Need both acquire and release for the last warp, since it won't be able to acquire with red.and
119
+ _CG_STATIC_QUALIFIER unsigned int atom_or_acq_rel_cta(unsigned int *addr, unsigned int val) {
120
+ unsigned int old;
121
+ #if __CUDA_ARCH__ < 700
122
+ __threadfence_block();
123
+ old = atomicOr(addr, val);
124
+ #else
125
+ asm volatile("atom.or.acq_rel.cta.b32 %0,[%1],%2;" : "=r"(old) : _CG_ASM_PTR_CONSTRAINT(addr), "r"(val) : "memory");
126
+ #endif
127
+ return old;
128
+ }
129
+
130
+ // Special case where barrier is arrived, but not waited on
131
+ _CG_STATIC_QUALIFIER void red_or_release_cta(unsigned int *addr, unsigned int val) {
132
+ #if __CUDA_ARCH__ < 700
133
+ __threadfence_block();
134
+ atomicOr(addr, val);
135
+ #else
136
+ asm volatile("red.or.release.cta.b32 [%0],%1;" :: _CG_ASM_PTR_CONSTRAINT(addr), "r"(val) : "memory");
137
+ #endif
138
+ }
139
+
140
+ // Usually called by last arriving warp to released other warps, can be relaxed, since or was already acq_rel
141
+ _CG_STATIC_QUALIFIER void red_and_relaxed_cta(unsigned int *addr, unsigned int val) {
142
+ #if __CUDA_ARCH__ < 700
143
+ atomicAnd(addr, val);
144
+ #else
145
+ asm volatile("red.and.relaxed.cta.b32 [%0],%1;" :: _CG_ASM_PTR_CONSTRAINT(addr), "r"(val) : "memory");
146
+ #endif
147
+ }
148
+
149
+ // Special case of release, where last warp was doing extra work before releasing others, need to be release
150
+ // to ensure that extra work is visible
151
+ _CG_STATIC_QUALIFIER void red_and_release_cta(unsigned int *addr, unsigned int val) {
152
+ #if __CUDA_ARCH__ < 700
153
+ __threadfence_block();
154
+ atomicAnd(addr, val);
155
+ #else
156
+ asm volatile("red.and.release.cta.b32 [%0],%1;" :: _CG_ASM_PTR_CONSTRAINT(addr), "r"(val) : "memory");
157
+ #endif
158
+ }
159
+
160
+ // Read the barrier, acquire to ensure all memory operations following the sync are correctly performed after it is released
161
+ _CG_STATIC_QUALIFIER unsigned int ld_acquire_cta(unsigned int *addr) {
162
+ unsigned int val;
163
+ #if __CUDA_ARCH__ < 700
164
+ val = *((volatile unsigned int*) addr);
165
+ __threadfence_block();
166
+ #else
167
+ asm volatile("ld.acquire.cta.u32 %0,[%1];" : "=r"(val) : _CG_ASM_PTR_CONSTRAINT(addr) : "memory");
168
+ #endif
169
+ return val;
170
+ }
171
+
172
+ // Get synchronization bit mask of my thread_block_tile of size num_warps. Thread ranks 0..31 have the first bit assigned to them,
173
+ // thread ranks 32..63 second etc
174
+ // Bit masks are unique for each group, groups of the same size will have the same number of bits set, but on different positions
175
+ _CG_STATIC_QUALIFIER unsigned int get_group_mask(unsigned int thread_rank, unsigned int num_warps) {
176
+ return num_warps == 32 ? ~0 : ((1 << num_warps) - 1) << (num_warps * (thread_rank / (num_warps * 32)));
177
+ }
178
+
179
+ _CG_STATIC_QUALIFIER void barrier_wait(barrier_t *arrived, unsigned int warp_bit) {
180
+ while(ld_acquire_cta(arrived) & warp_bit);
181
+ }
182
+
183
+ // Default blocking sync.
184
+ _CG_STATIC_QUALIFIER void sync_warps(barrier_t *arrived, unsigned int thread_rank, unsigned int num_warps) {
185
+ unsigned int warp_id = thread_rank / 32;
186
+ bool warp_master = (thread_rank % 32 == 0);
187
+ unsigned int warp_bit = 1 << warp_id;
188
+ unsigned int group_mask = get_group_mask(thread_rank, num_warps);
189
+
190
+ __syncwarp(0xFFFFFFFF);
191
+
192
+ if (warp_master) {
193
+ unsigned int old = atom_or_acq_rel_cta(arrived, warp_bit);
194
+ if (((old | warp_bit) & group_mask) == group_mask) {
195
+ red_and_relaxed_cta(arrived, ~group_mask);
196
+ }
197
+ else {
198
+ barrier_wait(arrived, warp_bit);
199
+ }
200
+ }
201
+
202
+ __syncwarp(0xFFFFFFFF);
203
+ }
204
+
205
+ // Blocking sync, except the last arriving warp, that releases other warps, returns to do other stuff first.
206
+ // Warp returning true from this function needs to call sync_warps_release.
207
+ _CG_STATIC_QUALIFIER bool sync_warps_last_releases(barrier_t *arrived, unsigned int thread_rank, unsigned int num_warps) {
208
+ unsigned int warp_id = thread_rank / 32;
209
+ bool warp_master = (thread_rank % 32 == 0);
210
+ unsigned int warp_bit = 1 << warp_id;
211
+ unsigned int group_mask = get_group_mask(thread_rank, num_warps);
212
+
213
+ __syncwarp(0xFFFFFFFF);
214
+
215
+ unsigned int old = 0;
216
+ if (warp_master) {
217
+ old = atom_or_acq_rel_cta(arrived, warp_bit);
218
+ }
219
+ old = __shfl_sync(0xFFFFFFFF, old, 0);
220
+ if (((old | warp_bit) & group_mask) == group_mask) {
221
+ return true;
222
+ }
223
+ barrier_wait(arrived, warp_bit);
224
+
225
+ return false;
226
+ }
227
+
228
+ // Release my group from the barrier.
229
+ _CG_STATIC_QUALIFIER void sync_warps_release(barrier_t *arrived, bool is_master, unsigned int thread_rank, unsigned int num_warps) {
230
+ unsigned int group_mask = get_group_mask(thread_rank, num_warps);
231
+ if (is_master) {
232
+ red_and_release_cta(arrived, ~group_mask);
233
+ }
234
+ }
235
+
236
+ // Arrive at my group barrier, but don't block or release the barrier, even if every one arrives.
237
+ // sync_warps_release needs to be called by some warp after this one to reset the barrier.
238
+ _CG_STATIC_QUALIFIER void sync_warps_arrive(barrier_t *arrived, unsigned int thread_rank, unsigned int num_warps) {
239
+ unsigned int warp_id = thread_rank / 32;
240
+ bool warp_master = (thread_rank % 32 == 0);
241
+ unsigned int warp_bit = 1 << warp_id;
242
+ unsigned int group_mask = get_group_mask(thread_rank, num_warps);
243
+
244
+ __syncwarp(0xFFFFFFFF);
245
+
246
+ if (warp_master) {
247
+ red_or_release_cta(arrived, warp_bit);
248
+ }
249
+ }
250
+
251
+ // Wait for my warp to be released from the barrier. Warp must have arrived first.
252
+ _CG_STATIC_QUALIFIER void sync_warps_wait(barrier_t *arrived, unsigned int thread_rank) {
253
+ unsigned int warp_id = thread_rank / 32;
254
+ unsigned int warp_bit = 1 << warp_id;
255
+
256
+ barrier_wait(arrived, warp_bit);
257
+ }
258
+
259
+ // Wait for specific warp to arrive at the barrier
260
+ _CG_QUALIFIER void sync_warps_wait_for_specific_warp(barrier_t *arrived, unsigned int wait_warp_id) {
261
+ unsigned int wait_mask = 1 << wait_warp_id;
262
+ while((ld_acquire_cta(arrived) & wait_mask) != wait_mask);
263
+ }
264
+
265
+ // Initialize the bit corresponding to my warp in the barrier
266
+ _CG_QUALIFIER void sync_warps_reset(barrier_t *arrived, unsigned int thread_rank) {
267
+ unsigned int warp_id = thread_rank / 32;
268
+ unsigned int warp_bit = 1 << warp_id;
269
+
270
+ __syncwarp(0xFFFFFFFF);
271
+
272
+ if (thread_rank % 32 == 0) {
273
+ red_and_release_cta(arrived, ~warp_bit);
274
+ }
275
+ // No need to sync after the atomic, there will be a sync of the group that is being partitioned right after this.
276
+ }
277
+
278
+ } // details
279
+
280
+ _CG_END_NAMESPACE
281
+
282
+ #endif // _CG_GRID_H
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuComplex.h ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2012 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(CU_COMPLEX_H_)
51
+ #define CU_COMPLEX_H_
52
+
53
+ #if !defined(__CUDACC_RTC__)
54
+ #if defined(__GNUC__)
55
+ #if defined(__clang__) || (!defined(__PGIC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)))
56
+ #pragma GCC diagnostic ignored "-Wunused-function"
57
+ #endif
58
+ #endif
59
+ #endif
60
+
61
+ /* When trying to include C header file in C++ Code extern "C" is required
62
+ * But the Standard QNX headers already have ifdef extern in them when compiling C++ Code
63
+ * extern "C" cannot be nested
64
+ * Hence keep the header out of extern "C" block
65
+ */
66
+
67
+ #if !defined(__CUDACC__)
68
+ #include <math.h> /* import fabsf, sqrt */
69
+ #endif /* !defined(__CUDACC__) */
70
+
71
+ #if defined(__cplusplus)
72
+ extern "C" {
73
+ #endif /* __cplusplus */
74
+
75
+ #include "vector_types.h"
76
+
77
+ typedef float2 cuFloatComplex;
78
+
79
+ __host__ __device__ static __inline__ float cuCrealf (cuFloatComplex x)
80
+ {
81
+ return x.x;
82
+ }
83
+
84
+ __host__ __device__ static __inline__ float cuCimagf (cuFloatComplex x)
85
+ {
86
+ return x.y;
87
+ }
88
+
89
+ __host__ __device__ static __inline__ cuFloatComplex make_cuFloatComplex
90
+ (float r, float i)
91
+ {
92
+ cuFloatComplex res;
93
+ res.x = r;
94
+ res.y = i;
95
+ return res;
96
+ }
97
+
98
+ __host__ __device__ static __inline__ cuFloatComplex cuConjf (cuFloatComplex x)
99
+ {
100
+ return make_cuFloatComplex (cuCrealf(x), -cuCimagf(x));
101
+ }
102
+ __host__ __device__ static __inline__ cuFloatComplex cuCaddf (cuFloatComplex x,
103
+ cuFloatComplex y)
104
+ {
105
+ return make_cuFloatComplex (cuCrealf(x) + cuCrealf(y),
106
+ cuCimagf(x) + cuCimagf(y));
107
+ }
108
+
109
+ __host__ __device__ static __inline__ cuFloatComplex cuCsubf (cuFloatComplex x,
110
+ cuFloatComplex y)
111
+ {
112
+ return make_cuFloatComplex (cuCrealf(x) - cuCrealf(y),
113
+ cuCimagf(x) - cuCimagf(y));
114
+ }
115
+
116
+ /* This implementation could suffer from intermediate overflow even though
117
+ * the final result would be in range. However, various implementations do
118
+ * not guard against this (presumably to avoid losing performance), so we
119
+ * don't do it either to stay competitive.
120
+ */
121
+ __host__ __device__ static __inline__ cuFloatComplex cuCmulf (cuFloatComplex x,
122
+ cuFloatComplex y)
123
+ {
124
+ cuFloatComplex prod;
125
+ prod = make_cuFloatComplex ((cuCrealf(x) * cuCrealf(y)) -
126
+ (cuCimagf(x) * cuCimagf(y)),
127
+ (cuCrealf(x) * cuCimagf(y)) +
128
+ (cuCimagf(x) * cuCrealf(y)));
129
+ return prod;
130
+ }
131
+
132
+ /* This implementation guards against intermediate underflow and overflow
133
+ * by scaling. Such guarded implementations are usually the default for
134
+ * complex library implementations, with some also offering an unguarded,
135
+ * faster version.
136
+ */
137
+ __host__ __device__ static __inline__ cuFloatComplex cuCdivf (cuFloatComplex x,
138
+ cuFloatComplex y)
139
+ {
140
+ cuFloatComplex quot;
141
+ float s = fabsf(cuCrealf(y)) + fabsf(cuCimagf(y));
142
+ float oos = 1.0f / s;
143
+ float ars = cuCrealf(x) * oos;
144
+ float ais = cuCimagf(x) * oos;
145
+ float brs = cuCrealf(y) * oos;
146
+ float bis = cuCimagf(y) * oos;
147
+ s = (brs * brs) + (bis * bis);
148
+ oos = 1.0f / s;
149
+ quot = make_cuFloatComplex (((ars * brs) + (ais * bis)) * oos,
150
+ ((ais * brs) - (ars * bis)) * oos);
151
+ return quot;
152
+ }
153
+
154
+ /*
155
+ * We would like to call hypotf(), but it's not available on all platforms.
156
+ * This discrete implementation guards against intermediate underflow and
157
+ * overflow by scaling. Otherwise we would lose half the exponent range.
158
+ * There are various ways of doing guarded computation. For now chose the
159
+ * simplest and fastest solution, however this may suffer from inaccuracies
160
+ * if sqrt and division are not IEEE compliant.
161
+ */
162
+ __host__ __device__ static __inline__ float cuCabsf (cuFloatComplex x)
163
+ {
164
+ float a = cuCrealf(x);
165
+ float b = cuCimagf(x);
166
+ float v, w, t;
167
+ a = fabsf(a);
168
+ b = fabsf(b);
169
+ if (a > b) {
170
+ v = a;
171
+ w = b;
172
+ } else {
173
+ v = b;
174
+ w = a;
175
+ }
176
+ t = w / v;
177
+ t = 1.0f + t * t;
178
+ t = v * sqrtf(t);
179
+ if ((v == 0.0f) || (v > 3.402823466e38f) || (w > 3.402823466e38f)) {
180
+ t = v + w;
181
+ }
182
+ return t;
183
+ }
184
+
185
+ /* Double precision */
186
+ typedef double2 cuDoubleComplex;
187
+
188
+ __host__ __device__ static __inline__ double cuCreal (cuDoubleComplex x)
189
+ {
190
+ return x.x;
191
+ }
192
+
193
+ __host__ __device__ static __inline__ double cuCimag (cuDoubleComplex x)
194
+ {
195
+ return x.y;
196
+ }
197
+
198
+ __host__ __device__ static __inline__ cuDoubleComplex make_cuDoubleComplex
199
+ (double r, double i)
200
+ {
201
+ cuDoubleComplex res;
202
+ res.x = r;
203
+ res.y = i;
204
+ return res;
205
+ }
206
+
207
+ __host__ __device__ static __inline__ cuDoubleComplex cuConj(cuDoubleComplex x)
208
+ {
209
+ return make_cuDoubleComplex (cuCreal(x), -cuCimag(x));
210
+ }
211
+
212
+ __host__ __device__ static __inline__ cuDoubleComplex cuCadd(cuDoubleComplex x,
213
+ cuDoubleComplex y)
214
+ {
215
+ return make_cuDoubleComplex (cuCreal(x) + cuCreal(y),
216
+ cuCimag(x) + cuCimag(y));
217
+ }
218
+
219
+ __host__ __device__ static __inline__ cuDoubleComplex cuCsub(cuDoubleComplex x,
220
+ cuDoubleComplex y)
221
+ {
222
+ return make_cuDoubleComplex (cuCreal(x) - cuCreal(y),
223
+ cuCimag(x) - cuCimag(y));
224
+ }
225
+
226
+ /* This implementation could suffer from intermediate overflow even though
227
+ * the final result would be in range. However, various implementations do
228
+ * not guard against this (presumably to avoid losing performance), so we
229
+ * don't do it either to stay competitive.
230
+ */
231
+ __host__ __device__ static __inline__ cuDoubleComplex cuCmul(cuDoubleComplex x,
232
+ cuDoubleComplex y)
233
+ {
234
+ cuDoubleComplex prod;
235
+ prod = make_cuDoubleComplex ((cuCreal(x) * cuCreal(y)) -
236
+ (cuCimag(x) * cuCimag(y)),
237
+ (cuCreal(x) * cuCimag(y)) +
238
+ (cuCimag(x) * cuCreal(y)));
239
+ return prod;
240
+ }
241
+
242
+ /* This implementation guards against intermediate underflow and overflow
243
+ * by scaling. Such guarded implementations are usually the default for
244
+ * complex library implementations, with some also offering an unguarded,
245
+ * faster version.
246
+ */
247
+ __host__ __device__ static __inline__ cuDoubleComplex cuCdiv(cuDoubleComplex x,
248
+ cuDoubleComplex y)
249
+ {
250
+ cuDoubleComplex quot;
251
+ double s = (fabs(cuCreal(y))) + (fabs(cuCimag(y)));
252
+ double oos = 1.0 / s;
253
+ double ars = cuCreal(x) * oos;
254
+ double ais = cuCimag(x) * oos;
255
+ double brs = cuCreal(y) * oos;
256
+ double bis = cuCimag(y) * oos;
257
+ s = (brs * brs) + (bis * bis);
258
+ oos = 1.0 / s;
259
+ quot = make_cuDoubleComplex (((ars * brs) + (ais * bis)) * oos,
260
+ ((ais * brs) - (ars * bis)) * oos);
261
+ return quot;
262
+ }
263
+
264
+ /* This implementation guards against intermediate underflow and overflow
265
+ * by scaling. Otherwise we would lose half the exponent range. There are
266
+ * various ways of doing guarded computation. For now chose the simplest
267
+ * and fastest solution, however this may suffer from inaccuracies if sqrt
268
+ * and division are not IEEE compliant.
269
+ */
270
+ __host__ __device__ static __inline__ double cuCabs (cuDoubleComplex x)
271
+ {
272
+ double a = cuCreal(x);
273
+ double b = cuCimag(x);
274
+ double v, w, t;
275
+ a = fabs(a);
276
+ b = fabs(b);
277
+ if (a > b) {
278
+ v = a;
279
+ w = b;
280
+ } else {
281
+ v = b;
282
+ w = a;
283
+ }
284
+ t = w / v;
285
+ t = 1.0 + t * t;
286
+ t = v * sqrt(t);
287
+ if ((v == 0.0) ||
288
+ (v > 1.79769313486231570e+308) || (w > 1.79769313486231570e+308)) {
289
+ t = v + w;
290
+ }
291
+ return t;
292
+ }
293
+
294
+ #if defined(__cplusplus)
295
+ }
296
+ #endif /* __cplusplus */
297
+
298
+ /* aliases */
299
+ typedef cuFloatComplex cuComplex;
300
+ __host__ __device__ static __inline__ cuComplex make_cuComplex (float x,
301
+ float y)
302
+ {
303
+ return make_cuFloatComplex (x, y);
304
+ }
305
+
306
+ /* float-to-double promotion */
307
+ __host__ __device__ static __inline__ cuDoubleComplex cuComplexFloatToDouble
308
+ (cuFloatComplex c)
309
+ {
310
+ return make_cuDoubleComplex ((double)cuCrealf(c), (double)cuCimagf(c));
311
+ }
312
+
313
+ __host__ __device__ static __inline__ cuFloatComplex cuComplexDoubleToFloat
314
+ (cuDoubleComplex c)
315
+ {
316
+ return make_cuFloatComplex ((float)cuCreal(c), (float)cuCimag(c));
317
+ }
318
+
319
+
320
+ __host__ __device__ static __inline__ cuComplex cuCfmaf( cuComplex x, cuComplex y, cuComplex d)
321
+ {
322
+ float real_res;
323
+ float imag_res;
324
+
325
+ real_res = (cuCrealf(x) * cuCrealf(y)) + cuCrealf(d);
326
+ imag_res = (cuCrealf(x) * cuCimagf(y)) + cuCimagf(d);
327
+
328
+ real_res = -(cuCimagf(x) * cuCimagf(y)) + real_res;
329
+ imag_res = (cuCimagf(x) * cuCrealf(y)) + imag_res;
330
+
331
+ return make_cuComplex(real_res, imag_res);
332
+ }
333
+
334
+ __host__ __device__ static __inline__ cuDoubleComplex cuCfma( cuDoubleComplex x, cuDoubleComplex y, cuDoubleComplex d)
335
+ {
336
+ double real_res;
337
+ double imag_res;
338
+
339
+ real_res = (cuCreal(x) * cuCreal(y)) + cuCreal(d);
340
+ imag_res = (cuCreal(x) * cuCimag(y)) + cuCimag(d);
341
+
342
+ real_res = -(cuCimag(x) * cuCimag(y)) + real_res;
343
+ imag_res = (cuCimag(x) * cuCreal(y)) + imag_res;
344
+
345
+ return make_cuDoubleComplex(real_res, imag_res);
346
+ }
347
+
348
+ #endif /* !defined(CU_COMPLEX_H_) */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda.h ADDED
The diff for this file is too large to render. See raw diff
 
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cudaEGLTypedefs.h ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2020-2021 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #ifndef CUDAEGLTYPEDEFS_H
51
+ #define CUDAEGLTYPEDEFS_H
52
+
53
+ #include <cudaEGL.h>
54
+
55
+ #ifdef __cplusplus
56
+ extern "C" {
57
+ #endif // __cplusplus
58
+
59
+ /*
60
+ * Macros for the latest version for each driver function in cudaEGL.h
61
+ */
62
+ #define PFN_cuGraphicsEGLRegisterImage PFN_cuGraphicsEGLRegisterImage_v7000
63
+ #define PFN_cuEGLStreamConsumerConnect PFN_cuEGLStreamConsumerConnect_v7000
64
+ #define PFN_cuEGLStreamConsumerConnectWithFlags PFN_cuEGLStreamConsumerConnectWithFlags_v8000
65
+ #define PFN_cuEGLStreamConsumerDisconnect PFN_cuEGLStreamConsumerDisconnect_v7000
66
+ #define PFN_cuEGLStreamConsumerAcquireFrame PFN_cuEGLStreamConsumerAcquireFrame_v7000
67
+ #define PFN_cuEGLStreamConsumerReleaseFrame PFN_cuEGLStreamConsumerReleaseFrame_v7000
68
+ #define PFN_cuEGLStreamProducerConnect PFN_cuEGLStreamProducerConnect_v7000
69
+ #define PFN_cuEGLStreamProducerDisconnect PFN_cuEGLStreamProducerDisconnect_v7000
70
+ #define PFN_cuEGLStreamProducerPresentFrame PFN_cuEGLStreamProducerPresentFrame_v7000
71
+ #define PFN_cuEGLStreamProducerReturnFrame PFN_cuEGLStreamProducerReturnFrame_v7000
72
+ #define PFN_cuGraphicsResourceGetMappedEglFrame PFN_cuGraphicsResourceGetMappedEglFrame_v7000
73
+ #define PFN_cuEventCreateFromEGLSync PFN_cuEventCreateFromEGLSync_v9000
74
+
75
+
76
+ /**
77
+ * Type definitions for functions defined in cudaEGL.h
78
+ */
79
+ typedef CUresult (CUDAAPI *PFN_cuGraphicsEGLRegisterImage_v7000)(CUgraphicsResource CUDAAPI *pCudaResource, EGLImageKHR image, unsigned int flags);
80
+ typedef CUresult (CUDAAPI *PFN_cuEGLStreamConsumerConnect_v7000)(CUeglStreamConnection CUDAAPI *conn, EGLStreamKHR stream);
81
+ typedef CUresult (CUDAAPI *PFN_cuEGLStreamConsumerConnectWithFlags_v8000)(CUeglStreamConnection CUDAAPI *conn, EGLStreamKHR stream, unsigned int flags);
82
+ typedef CUresult (CUDAAPI *PFN_cuEGLStreamConsumerDisconnect_v7000)(CUeglStreamConnection CUDAAPI *conn);
83
+ typedef CUresult (CUDAAPI *PFN_cuEGLStreamConsumerAcquireFrame_v7000)(CUeglStreamConnection CUDAAPI *conn, CUgraphicsResource CUDAAPI *pCudaResource, CUstream CUDAAPI *pStream, unsigned int timeout);
84
+ typedef CUresult (CUDAAPI *PFN_cuEGLStreamConsumerReleaseFrame_v7000)(CUeglStreamConnection CUDAAPI *conn, CUgraphicsResource pCudaResource, CUstream CUDAAPI *pStream);
85
+ typedef CUresult (CUDAAPI *PFN_cuEGLStreamProducerConnect_v7000)(CUeglStreamConnection CUDAAPI *conn, EGLStreamKHR stream, EGLint width, EGLint height);
86
+ typedef CUresult (CUDAAPI *PFN_cuEGLStreamProducerDisconnect_v7000)(CUeglStreamConnection CUDAAPI *conn);
87
+ typedef CUresult (CUDAAPI *PFN_cuEGLStreamProducerPresentFrame_v7000)(CUeglStreamConnection CUDAAPI *conn, CUeglFrame_v1 eglframe, CUstream CUDAAPI *pStream);
88
+ typedef CUresult (CUDAAPI *PFN_cuEGLStreamProducerReturnFrame_v7000)(CUeglStreamConnection CUDAAPI *conn, CUeglFrame_v1 CUDAAPI *eglframe, CUstream CUDAAPI *pStream);
89
+ typedef CUresult (CUDAAPI *PFN_cuGraphicsResourceGetMappedEglFrame_v7000)(CUeglFrame_v1 CUDAAPI *eglFrame, CUgraphicsResource resource, unsigned int index, unsigned int mipLevel);
90
+ typedef CUresult (CUDAAPI *PFN_cuEventCreateFromEGLSync_v9000)(CUevent CUDAAPI *phEvent, EGLSyncKHR eglSync, unsigned int flags);
91
+
92
+ #ifdef __cplusplus
93
+ }
94
+ #endif // __cplusplus
95
+
96
+ #endif // file guard
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cudaVDPAUTypedefs.h ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2020-2021 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #ifndef CUDAVDPAUTYPEDEFS_H
51
+ #define CUDAVDPAUTYPEDEFS_H
52
+
53
+ // Dependent includes for cudavdpau.h
54
+ #include <vdpau/vdpau.h>
55
+
56
+ #include <cudaVDPAU.h>
57
+
58
+ #ifdef __cplusplus
59
+ extern "C" {
60
+ #endif // __cplusplus
61
+
62
+ /*
63
+ * Macros for the latest version for each driver function in cudaVDPAU.h
64
+ */
65
+ #define PFN_cuVDPAUGetDevice PFN_cuVDPAUGetDevice_v3010
66
+ #define PFN_cuVDPAUCtxCreate PFN_cuVDPAUCtxCreate_v3020
67
+ #define PFN_cuGraphicsVDPAURegisterVideoSurface PFN_cuGraphicsVDPAURegisterVideoSurface_v3010
68
+ #define PFN_cuGraphicsVDPAURegisterOutputSurface PFN_cuGraphicsVDPAURegisterOutputSurface_v3010
69
+
70
+
71
+ /**
72
+ * Type definitions for functions defined in cudaVDPAU.h
73
+ */
74
+ typedef CUresult (CUDAAPI *PFN_cuVDPAUGetDevice_v3010)(CUdevice_v1 *pDevice, VdpDevice vdpDevice, VdpGetProcAddress *vdpGetProcAddress);
75
+ typedef CUresult (CUDAAPI *PFN_cuVDPAUCtxCreate_v3020)(CUcontext *pCtx, unsigned int flags, CUdevice_v1 device, VdpDevice vdpDevice, VdpGetProcAddress *vdpGetProcAddress);
76
+ typedef CUresult (CUDAAPI *PFN_cuGraphicsVDPAURegisterVideoSurface_v3010)(CUgraphicsResource *pCudaResource, VdpVideoSurface vdpSurface, unsigned int flags);
77
+ typedef CUresult (CUDAAPI *PFN_cuGraphicsVDPAURegisterOutputSurface_v3010)(CUgraphicsResource *pCudaResource, VdpOutputSurface vdpSurface, unsigned int flags);
78
+
79
+ /*
80
+ * Type definitions for older versioned functions in cudaVDPAU.h
81
+ */
82
+ #if defined(__CUDA_API_VERSION_INTERNAL)
83
+ typedef CUresult (CUDAAPI *PFN_cuVDPAUCtxCreate_v3010)(CUcontext *pCtx, unsigned int flags, CUdevice_v1 device, VdpDevice vdpDevice, VdpGetProcAddress *vdpGetProcAddress);
84
+ #endif
85
+
86
+ #ifdef __cplusplus
87
+ }
88
+ #endif // __cplusplus
89
+
90
+ #endif // file guard
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_awbarrier.h ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #ifndef _CUDA_AWBARRIER_H_
51
+ # define _CUDA_AWBARRIER_H_
52
+
53
+ # include "cuda_awbarrier_primitives.h"
54
+
55
+ # if !defined(_CUDA_AWBARRIER_SM_TARGET)
56
+ # error This file requires compute capability 7.0 or greater.
57
+ # endif
58
+
59
+ # if !defined(_CUDA_AWBARRIER_CPLUSPLUS_11_OR_LATER)
60
+ # error This file requires compiler support for the ISO C++ 2011 standard. This support must be enabled with the \
61
+ -std=c++11 compiler option.
62
+ # endif
63
+
64
+ _CUDA_AWBARRIER_BEGIN_NAMESPACE
65
+
66
+ class awbarrier {
67
+ public:
68
+ class arrival_token {
69
+ public:
70
+ arrival_token() = default;
71
+ ~arrival_token() = default;
72
+ _CUDA_AWBARRIER_QUALIFIER uint32_t pending_count() const;
73
+ private:
74
+ _CUDA_AWBARRIER_QUALIFIER arrival_token(uint64_t token);
75
+ uint64_t token;
76
+ friend awbarrier;
77
+ };
78
+ awbarrier() = default;
79
+ awbarrier(const awbarrier&) = delete;
80
+ awbarrier& operator=(const awbarrier&) = delete;
81
+ ~awbarrier() = default;
82
+
83
+ _CUDA_AWBARRIER_QUALIFIER arrival_token arrive();
84
+ _CUDA_AWBARRIER_QUALIFIER arrival_token arrive_and_drop();
85
+ _CUDA_AWBARRIER_QUALIFIER bool timed_wait(arrival_token token, uint32_t hint_cycles);
86
+ _CUDA_AWBARRIER_QUALIFIER bool timed_wait_parity(bool phase, uint32_t hint_cycles);
87
+ _CUDA_AWBARRIER_QUALIFIER void wait(arrival_token token);
88
+ _CUDA_AWBARRIER_QUALIFIER void arrive_and_wait();
89
+ _CUDA_AWBARRIER_QUALIFIER bool try_wait(arrival_token token, uint32_t maxSleepNanosec);
90
+ _CUDA_AWBARRIER_QUALIFIER bool try_wait_parity(bool phase, uint32_t maxSleepNanosec);
91
+ _CUDA_AWBARRIER_STATIC_QUALIFIER __host__ constexpr uint32_t max();
92
+
93
+ private:
94
+ uint64_t barrier;
95
+ friend _CUDA_AWBARRIER_QUALIFIER void init(awbarrier* barrier, uint32_t expected_count);
96
+ friend _CUDA_AWBARRIER_QUALIFIER void inval(awbarrier* barrier);
97
+ friend class pipeline;
98
+ };
99
+
100
+ _CUDA_AWBARRIER_QUALIFIER
101
+ uint32_t awbarrier::arrival_token::pending_count() const
102
+ {
103
+ const uint32_t pending_count = _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_token_pending_count(this->token);
104
+ #if (__CUDA_ARCH__ >= 900)
105
+ return pending_count;
106
+ #else
107
+ return (pending_count >> 15);
108
+ #endif
109
+ }
110
+
111
+ _CUDA_AWBARRIER_QUALIFIER
112
+ awbarrier::arrival_token::arrival_token(uint64_t token)
113
+ : token(token)
114
+ {
115
+ }
116
+
117
+ _CUDA_AWBARRIER_QUALIFIER
118
+ void init(awbarrier* barrier, uint32_t expected_count)
119
+ {
120
+ _CUDA_AWBARRIER_ASSERT(__isShared(barrier));
121
+ _CUDA_AWBARRIER_ASSERT(expected_count > 0 && expected_count <= _CUDA_AWBARRIER_MAX_COUNT);
122
+
123
+ #if (__CUDA_ARCH__ >= 900)
124
+ const uint32_t init_count = expected_count;
125
+ #else
126
+ const uint32_t init_count = (expected_count << 15) + expected_count;
127
+ #endif
128
+
129
+ _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_init(&barrier->barrier, init_count);
130
+ }
131
+
132
+ _CUDA_AWBARRIER_QUALIFIER
133
+ void inval(awbarrier* barrier)
134
+ {
135
+ _CUDA_AWBARRIER_ASSERT(__isShared(barrier));
136
+
137
+ _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_inval(&barrier->barrier);
138
+ }
139
+
140
+ _CUDA_AWBARRIER_QUALIFIER
141
+ awbarrier::arrival_token awbarrier::arrive()
142
+ {
143
+ _CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
144
+
145
+ #if (__CUDA_ARCH__ < 900)
146
+ const uint32_t arrive_count = 1 << 15;
147
+ const uint64_t token = _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop_no_complete<false>(&this->barrier, arrive_count);
148
+ (void)
149
+ #else
150
+ const uint64_t token =
151
+ #endif
152
+ _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop<false>(&this->barrier);
153
+
154
+ return arrival_token(token);
155
+ }
156
+
157
+ _CUDA_AWBARRIER_QUALIFIER
158
+ awbarrier::arrival_token awbarrier::arrive_and_drop()
159
+ {
160
+ _CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
161
+
162
+ #if (__CUDA_ARCH__ < 900)
163
+ const uint32_t arrive_count = 1 << 15;
164
+ const uint64_t token = _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop_no_complete<true>(&this->barrier, arrive_count);
165
+ (void)
166
+ #else
167
+ const uint64_t token =
168
+ #endif
169
+ _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop<true>(&this->barrier);
170
+
171
+ return arrival_token(token);
172
+ }
173
+
174
+ _CUDA_AWBARRIER_QUALIFIER
175
+ bool awbarrier::timed_wait(arrival_token token, uint32_t hint_cycles)
176
+ {
177
+ constexpr uint64_t max_busy_wait_cycles = 1024;
178
+ constexpr uint32_t max_sleep_ns = 1 << 20;
179
+
180
+ _CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
181
+
182
+ if (_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait(&this->barrier, token.token)) {
183
+ return true;
184
+ }
185
+
186
+ uint64_t start_cycles = clock64();
187
+ uint64_t elapsed_cycles = 0;
188
+ uint32_t sleep_ns = 32;
189
+ while (elapsed_cycles < hint_cycles) {
190
+ if (_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait(&this->barrier, token.token)) {
191
+ return true;
192
+ }
193
+
194
+ if (elapsed_cycles > max_busy_wait_cycles) {
195
+ __nanosleep(sleep_ns);
196
+ if (sleep_ns < max_sleep_ns) {
197
+ sleep_ns *= 2;
198
+ }
199
+ }
200
+
201
+ elapsed_cycles = clock64() - start_cycles;
202
+ }
203
+
204
+ return false;
205
+ }
206
+
207
+ _CUDA_AWBARRIER_QUALIFIER
208
+ bool awbarrier::timed_wait_parity(bool phase, uint32_t hint_cycles)
209
+ {
210
+ constexpr uint64_t max_busy_wait_cycles = 1024;
211
+ constexpr uint32_t max_sleep_ns = 1 << 20;
212
+
213
+ _CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
214
+
215
+ if (_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait_parity(&this->barrier, phase)) {
216
+ return true;
217
+ }
218
+
219
+ uint64_t start_cycles = clock64();
220
+ uint64_t elapsed_cycles = 0;
221
+ uint32_t sleep_ns = 32;
222
+ while (elapsed_cycles < hint_cycles) {
223
+ if (_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait_parity(&this->barrier, phase)) {
224
+ return true;
225
+ }
226
+
227
+ if (elapsed_cycles > max_busy_wait_cycles) {
228
+ __nanosleep(sleep_ns);
229
+ if (sleep_ns < max_sleep_ns) {
230
+ sleep_ns *= 2;
231
+ }
232
+ }
233
+
234
+ elapsed_cycles = clock64() - start_cycles;
235
+ }
236
+
237
+ return false;
238
+ }
239
+
240
+ _CUDA_AWBARRIER_QUALIFIER
241
+ bool awbarrier::try_wait(arrival_token token, uint32_t maxSleepNanosec)
242
+ {
243
+ _CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
244
+
245
+ return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_try_wait(&this->barrier, token.token, maxSleepNanosec);
246
+ }
247
+
248
+ _CUDA_AWBARRIER_QUALIFIER
249
+ bool awbarrier::try_wait_parity(bool phase, uint32_t maxSleepNanosec)
250
+ {
251
+ _CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
252
+
253
+ return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_try_wait_parity(&this->barrier, phase, maxSleepNanosec);
254
+ }
255
+
256
+ _CUDA_AWBARRIER_QUALIFIER
257
+ void awbarrier::wait(arrival_token token)
258
+ {
259
+ _CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
260
+
261
+ while (!timed_wait(token, ~0u));
262
+ }
263
+
264
+ _CUDA_AWBARRIER_QUALIFIER
265
+ void awbarrier::arrive_and_wait()
266
+ {
267
+ _CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
268
+
269
+ this->wait(this->arrive());
270
+ }
271
+
272
+ _CUDA_AWBARRIER_QUALIFIER __host__
273
+ constexpr uint32_t awbarrier::max()
274
+ {
275
+ return _CUDA_AWBARRIER_MAX_COUNT;
276
+ }
277
+
278
+ _CUDA_AWBARRIER_END_NAMESPACE
279
+
280
+ #endif /* !_CUDA_AWBARRIER_H_ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_awbarrier_helpers.h ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #ifndef _CUDA_AWBARRIER_HELPERS_H_
51
+ #define _CUDA_AWBARRIER_HELPERS_H_
52
+
53
+ #define _CUDA_AWBARRIER_NAMESPACE nvcuda::experimental
54
+ #define _CUDA_AWBARRIER_BEGIN_NAMESPACE namespace nvcuda { namespace experimental {
55
+ #define _CUDA_AWBARRIER_END_NAMESPACE } }
56
+
57
+ #define _CUDA_AWBARRIER_INTERNAL_NAMESPACE _CUDA_AWBARRIER_NAMESPACE::__awbarrier_internal
58
+ #define _CUDA_AWBARRIER_BEGIN_INTERNAL_NAMESPACE _CUDA_AWBARRIER_BEGIN_NAMESPACE namespace __awbarrier_internal {
59
+ #define _CUDA_AWBARRIER_END_INTERNAL_NAMESPACE } _CUDA_AWBARRIER_END_NAMESPACE
60
+
61
+ # if !defined(_CUDA_AWBARRIER_QUALIFIER)
62
+ # define _CUDA_AWBARRIER_QUALIFIER inline __device__
63
+ # endif
64
+ # if !defined(_CUDA_AWBARRIER_STATIC_QUALIFIER)
65
+ # define _CUDA_AWBARRIER_STATIC_QUALIFIER static inline __device__
66
+ #endif
67
+
68
+ #if defined(__CUDA_ARCH__)
69
+ #if (__CUDA_ARCH__ >= 900)
70
+ # define _CUDA_AWBARRIER_SM_TARGET _CUDA_AWBARRIER_SM_90
71
+ #elif (__CUDA_ARCH__ >= 800)
72
+ # define _CUDA_AWBARRIER_SM_TARGET _CUDA_AWBARRIER_SM_80
73
+ #elif (__CUDA_ARCH__ >= 700)
74
+ # define _CUDA_AWBARRIER_SM_TARGET _CUDA_AWBARRIER_SM_70
75
+ #endif
76
+ #else
77
+ # define _CUDA_AWBARRIER_SM_TARGET _CUDA_AWBARRIER_SM_70
78
+ #endif
79
+
80
+ #define _CUDA_AWBARRIER_MAX_COUNT ((1 << 14) - 1)
81
+
82
+ #if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1900)))
83
+ # define _CUDA_AWBARRIER_CPLUSPLUS_11_OR_LATER
84
+ #endif
85
+
86
+ #if !defined(_CUDA_AWBARRIER_DEBUG)
87
+ # if defined(__CUDACC_DEBUG__)
88
+ # define _CUDA_AWBARRIER_DEBUG 1
89
+ # else
90
+ # define _CUDA_AWBARRIER_DEBUG 0
91
+ # endif
92
+ #endif
93
+
94
+ #if defined(_CUDA_AWBARRIER_DEBUG) && (_CUDA_AWBARRIER_DEBUG == 1) && !defined(NDEBUG)
95
+ # if !defined(__CUDACC_RTC__)
96
+ # include <cassert>
97
+ # endif
98
+ # define _CUDA_AWBARRIER_ASSERT(x) assert((x));
99
+ # define _CUDA_AWBARRIER_ABORT() assert(0);
100
+ #else
101
+ # define _CUDA_AWBARRIER_ASSERT(x)
102
+ # define _CUDA_AWBARRIER_ABORT() __trap();
103
+ #endif
104
+
105
+ #if defined(__CUDACC_RTC__)
106
+ typedef unsigned short uint16_t;
107
+ typedef unsigned int uint32_t;
108
+ typedef unsigned long long uint64_t;
109
+ typedef uint64_t uintptr_t;
110
+ #else
111
+ # include <stdint.h>
112
+ #endif
113
+
114
+ // implicitly provided by NVRTC
115
+ #ifndef __CUDACC_RTC__
116
+ #include <nv/target>
117
+ #endif /* !defined(__CUDACC_RTC__) */
118
+
119
+ typedef uint64_t __mbarrier_t;
120
+ typedef uint64_t __mbarrier_token_t;
121
+
122
+ _CUDA_AWBARRIER_BEGIN_INTERNAL_NAMESPACE
123
+
124
+ extern "C" __device__ uint32_t __nvvm_get_smem_pointer(void *);
125
+
126
+ union AWBarrier {
127
+ struct {
128
+ uint32_t expected;
129
+ uint32_t pending;
130
+ } split;
131
+ uint64_t raw;
132
+ };
133
+
134
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
135
+ void awbarrier_init(uint64_t* barrier, uint32_t expected_count) {
136
+ _CUDA_AWBARRIER_ASSERT(__isShared(barrier));
137
+ _CUDA_AWBARRIER_ASSERT(expected_count > 0 && expected_count < (1 << 29));
138
+
139
+ NV_IF_TARGET(NV_PROVIDES_SM_80,
140
+ asm volatile ("mbarrier.init.shared.b64 [%0], %1;"
141
+ :
142
+ : "r"(__nvvm_get_smem_pointer(barrier)), "r"(expected_count)
143
+ : "memory");
144
+ return;
145
+ )
146
+ NV_IF_TARGET(NV_PROVIDES_SM_70,
147
+ AWBarrier* awbarrier = reinterpret_cast<AWBarrier*>(barrier);
148
+
149
+ awbarrier->split.expected = 0x40000000 - expected_count;
150
+ awbarrier->split.pending = 0x80000000 - expected_count;
151
+ return;
152
+ )
153
+ }
154
+
155
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
156
+ void awbarrier_inval(uint64_t* barrier) {
157
+ _CUDA_AWBARRIER_ASSERT(__isShared(barrier));
158
+
159
+ NV_IF_TARGET(NV_PROVIDES_SM_80,
160
+ asm volatile ("mbarrier.inval.shared.b64 [%0];"
161
+ :
162
+ : "r"(__nvvm_get_smem_pointer(barrier))
163
+ : "memory");
164
+ return;
165
+ )
166
+ return;
167
+ }
168
+
169
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
170
+ uint32_t awbarrier_token_pending_count(uint64_t token) {
171
+ NV_IF_TARGET(NV_PROVIDES_SM_80,
172
+ uint32_t __pending_count;
173
+
174
+ asm ("mbarrier.pending_count.b64 %0, %1;"
175
+ : "=r"(__pending_count)
176
+ : "l"(token));
177
+ return __pending_count;
178
+ )
179
+ NV_IF_TARGET(NV_PROVIDES_SM_70,
180
+ const uint32_t pending = token >> 32;
181
+ return 0x80000000 - (pending & 0x7fffffff);
182
+ )
183
+ }
184
+
185
+ template<bool _Drop>
186
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
187
+ uint64_t awbarrier_arrive_drop(uint64_t* barrier) {
188
+ _CUDA_AWBARRIER_ASSERT(__isShared(barrier));
189
+
190
+ NV_IF_TARGET(NV_PROVIDES_SM_80,
191
+ uint64_t token;
192
+
193
+ if (_Drop) {
194
+ asm volatile ("mbarrier.arrive_drop.shared.b64 %0, [%1];"
195
+ : "=l"(token)
196
+ : "r"(__nvvm_get_smem_pointer(barrier))
197
+ : "memory");
198
+ } else {
199
+ asm volatile ("mbarrier.arrive.shared.b64 %0, [%1];"
200
+ : "=l"(token)
201
+ : "r"(__nvvm_get_smem_pointer(barrier))
202
+ : "memory");
203
+ }
204
+
205
+ return token;
206
+ )
207
+ NV_IF_TARGET(NV_PROVIDES_SM_70,
208
+ AWBarrier* awbarrier = reinterpret_cast<AWBarrier*>(barrier);
209
+
210
+ while ((*reinterpret_cast<volatile uint32_t*>(&awbarrier->split.pending) & 0x7fffffff) == 0);
211
+
212
+ if (_Drop) {
213
+ (void)atomicAdd_block(&awbarrier->split.expected, 1);
214
+ }
215
+
216
+ __threadfence_block();
217
+
218
+ const uint32_t old_pending = atomicAdd_block(&awbarrier->split.pending, 1);
219
+ const uint32_t new_pending = old_pending + 1;
220
+ const bool reset = (old_pending ^ new_pending) & 0x80000000;
221
+
222
+ if (reset) {
223
+ __threadfence_block();
224
+
225
+ uint32_t new_expected = *reinterpret_cast<volatile uint32_t*>(&awbarrier->split.expected);
226
+ new_expected &= ~0x40000000;
227
+ if (new_expected & 0x20000000) {
228
+ new_expected |= 0x40000000;
229
+ }
230
+ atomicAdd_block(&awbarrier->split.pending, new_expected);
231
+ }
232
+
233
+ return static_cast<uint64_t>(old_pending) << 32;
234
+ )
235
+ }
236
+
237
+ template<bool _Drop>
238
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
239
+ uint64_t awbarrier_arrive_drop_no_complete(uint64_t* barrier, uint32_t count) {
240
+ _CUDA_AWBARRIER_ASSERT(__isShared(barrier));
241
+ _CUDA_AWBARRIER_ASSERT(count > 0 && count < (1 << 29));
242
+
243
+ NV_IF_TARGET(NV_PROVIDES_SM_80,
244
+ uint64_t token;
245
+
246
+ if (_Drop) {
247
+ asm volatile ("mbarrier.arrive_drop.noComplete.shared.b64 %0, [%1], %2;"
248
+ : "=l"(token)
249
+ : "r"(__nvvm_get_smem_pointer(barrier)), "r"(count)
250
+ : "memory");
251
+ } else {
252
+ asm volatile ("mbarrier.arrive.noComplete.shared.b64 %0, [%1], %2;"
253
+ : "=l"(token)
254
+ : "r"(__nvvm_get_smem_pointer(barrier)), "r"(count)
255
+ : "memory");
256
+ }
257
+
258
+ return token;
259
+ )
260
+ NV_IF_TARGET(NV_PROVIDES_SM_70,
261
+ AWBarrier* awbarrier = reinterpret_cast<AWBarrier*>(barrier);
262
+
263
+ while ((*reinterpret_cast<volatile uint32_t*>(&awbarrier->split.pending) & 0x7fffffff) == 0);
264
+
265
+ if (_Drop) {
266
+ (void)atomicAdd_block(&awbarrier->split.expected, count);
267
+ }
268
+
269
+ return static_cast<uint64_t>(atomicAdd_block(&awbarrier->split.pending, count)) << 32;
270
+ )
271
+ }
272
+
273
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
274
+ bool awbarrier_test_wait(uint64_t* barrier, uint64_t token) {
275
+ _CUDA_AWBARRIER_ASSERT(__isShared(barrier));
276
+
277
+ NV_IF_TARGET(NV_PROVIDES_SM_80,
278
+ uint32_t __wait_complete;
279
+
280
+ asm volatile ("{"
281
+ " .reg .pred %%p;"
282
+ " mbarrier.test_wait.shared.b64 %%p, [%1], %2;"
283
+ " selp.b32 %0, 1, 0, %%p;"
284
+ "}"
285
+ : "=r"(__wait_complete)
286
+ : "r"(__nvvm_get_smem_pointer(barrier)), "l"(token)
287
+ : "memory");
288
+ return bool(__wait_complete);
289
+ )
290
+ NV_IF_TARGET(NV_PROVIDES_SM_70,
291
+ volatile AWBarrier* awbarrier = reinterpret_cast<volatile AWBarrier*>(barrier);
292
+
293
+ return ((token >> 32) ^ awbarrier->split.pending) & 0x80000000;
294
+ )
295
+ }
296
+
297
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
298
+ bool awbarrier_test_wait_parity(uint64_t* barrier, bool phase_parity) {
299
+ _CUDA_AWBARRIER_ASSERT(__isShared(barrier));
300
+
301
+ NV_IF_TARGET(NV_PROVIDES_SM_90,
302
+ uint32_t __wait_complete = 0;
303
+
304
+ asm volatile ("{"
305
+ ".reg .pred %%p;"
306
+ "mbarrier.test_wait.parity.shared.b64 %%p, [%1], %2;"
307
+ "selp.b32 %0, 1, 0, %%p;"
308
+ "}"
309
+ : "=r"(__wait_complete)
310
+ : "r"(__nvvm_get_smem_pointer(barrier)), "r"(static_cast<uint32_t>(phase_parity))
311
+ : "memory");
312
+
313
+ return __wait_complete;
314
+ )
315
+ _CUDA_AWBARRIER_ABORT()
316
+ return false;
317
+ }
318
+
319
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
320
+ bool awbarrier_try_wait(uint64_t* barrier, uint64_t token, uint32_t max_sleep_nanosec) {
321
+ _CUDA_AWBARRIER_ASSERT(__isShared(barrier));
322
+
323
+ NV_IF_TARGET(NV_PROVIDES_SM_90,
324
+ uint32_t __wait_complete = 0;
325
+
326
+ asm volatile ("{\n\t"
327
+ ".reg .pred p;\n\t"
328
+ "mbarrier.try_wait.shared.b64 p, [%1], %2, %3;\n\t"
329
+ "selp.b32 %0, 1, 0, p;\n\t"
330
+ "}"
331
+ : "=r"(__wait_complete)
332
+ : "r"(__nvvm_get_smem_pointer(barrier)), "l"(token), "r"(max_sleep_nanosec)
333
+ : "memory");
334
+
335
+ return __wait_complete;
336
+ )
337
+ _CUDA_AWBARRIER_ABORT()
338
+ return false;
339
+ }
340
+
341
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
342
+ bool awbarrier_try_wait_parity(uint64_t* barrier, bool phase_parity, uint32_t max_sleep_nanosec) {
343
+ _CUDA_AWBARRIER_ASSERT(__isShared(barrier));
344
+
345
+ NV_IF_TARGET(NV_PROVIDES_SM_90,
346
+ uint32_t __wait_complete = 0;
347
+
348
+ asm volatile ("{\n\t"
349
+ ".reg .pred p;\n\t"
350
+ "mbarrier.try_wait.parity.shared.b64 p, [%1], %2, %3;\n\t"
351
+ "selp.b32 %0, 1, 0, p;\n\t"
352
+ "}"
353
+ : "=r"(__wait_complete)
354
+ : "r"(__nvvm_get_smem_pointer(barrier)), "r"(static_cast<uint32_t>(phase_parity)), "r"(max_sleep_nanosec)
355
+ : "memory");
356
+
357
+ return __wait_complete;
358
+ )
359
+ _CUDA_AWBARRIER_ABORT()
360
+ return false;
361
+ }
362
+
363
+ _CUDA_AWBARRIER_END_INTERNAL_NAMESPACE
364
+
365
+ #endif /* !_CUDA_AWBARRIER_HELPERS_H_ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_awbarrier_primitives.h ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #ifndef _CUDA_AWBARRIER_PRIMITIVES_H_
51
+ #define _CUDA_AWBARRIER_PRIMITIVES_H_
52
+
53
+ #include "cuda_awbarrier_helpers.h"
54
+
55
+ #if !defined(_CUDA_AWBARRIER_SM_TARGET)
56
+ # error This file requires compute capability 7.0 or greater.
57
+ #endif
58
+
59
+ _CUDA_AWBARRIER_STATIC_QUALIFIER __host__
60
+ uint32_t __mbarrier_maximum_count() {
61
+ return _CUDA_AWBARRIER_MAX_COUNT;
62
+ }
63
+
64
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
65
+ void __mbarrier_init(__mbarrier_t* barrier, uint32_t expected_count) {
66
+ _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_init(barrier, expected_count);
67
+ }
68
+
69
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
70
+ void __mbarrier_inval(__mbarrier_t* barrier) {
71
+ _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_inval(barrier);
72
+ }
73
+
74
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
75
+ __mbarrier_token_t __mbarrier_arrive(__mbarrier_t* barrier) {
76
+ return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop<false>(barrier);
77
+ }
78
+
79
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
80
+ __mbarrier_token_t __mbarrier_arrive_and_drop(__mbarrier_t* barrier) {
81
+ return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop<true>(barrier);
82
+ }
83
+
84
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
85
+ bool __mbarrier_test_wait(__mbarrier_t* barrier, __mbarrier_token_t token) {
86
+ return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait(barrier, token);
87
+ }
88
+
89
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
90
+ uint32_t __mbarrier_token_pending_count(__mbarrier_token_t token) {
91
+ return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_token_pending_count(token);
92
+ }
93
+
94
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
95
+ bool __mbarrier_test_wait_parity(__mbarrier_t* barrier, bool phase_parity) {
96
+ return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait_parity(barrier, phase_parity);
97
+ }
98
+
99
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
100
+ bool __mbarrier_try_wait(__mbarrier_t* barrier, __mbarrier_token_t token, uint32_t max_sleep_nanosec) {
101
+ return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_try_wait(barrier, token, max_sleep_nanosec);
102
+ }
103
+
104
+ _CUDA_AWBARRIER_STATIC_QUALIFIER
105
+ bool __mbarrier_try_wait_parity(__mbarrier_t* barrier, bool phase_parity, uint32_t max_sleep_nanosec) {
106
+ return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_try_wait_parity(barrier, phase_parity, max_sleep_nanosec);
107
+ }
108
+
109
+ #endif /* !_CUDA_AWBARRIER_PRIMITIVES_H_ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_bf16.h ADDED
The diff for this file is too large to render. See raw diff
 
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_bf16.hpp ADDED
The diff for this file is too large to render. See raw diff
 
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_device_runtime_api.h ADDED
@@ -0,0 +1,889 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2021 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(__CUDA_DEVICE_RUNTIME_API_H__)
51
+ #define __CUDA_DEVICE_RUNTIME_API_H__
52
+
53
+ #if defined(__CUDACC__) && !defined(__CUDACC_RTC__)
54
+ #include <stdlib.h>
55
+ #endif
56
+
57
+ /*******************************************************************************
58
+ * *
59
+ * *
60
+ * *
61
+ *******************************************************************************/
62
+
63
+ #if !defined(CUDA_FORCE_CDP1_IF_SUPPORTED) && !defined(__CUDADEVRT_INTERNAL__) && !defined(_NVHPC_CUDA) && !(defined(_WIN32) && !defined(_WIN64))
64
+ #define __CUDA_INTERNAL_USE_CDP2
65
+ #endif
66
+
67
+ #if !defined(__CUDACC_RTC__)
68
+
69
+ #if !defined(__CUDACC_INTERNAL_NO_STUBS__) && !defined(__CUDACC_RDC__) && !defined(__CUDACC_EWP__) && defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 350) && !defined(__CUDADEVRT_INTERNAL__)
70
+
71
+ #if defined(__cplusplus)
72
+ extern "C" {
73
+ #endif
74
+
75
+ struct cudaFuncAttributes;
76
+
77
+
78
+ #ifndef __CUDA_INTERNAL_USE_CDP2
79
+ inline __device__ cudaError_t CUDARTAPI cudaMalloc(void **p, size_t s)
80
+ {
81
+ return cudaErrorUnknown;
82
+ }
83
+
84
+ inline __device__ cudaError_t CUDARTAPI cudaFuncGetAttributes(struct cudaFuncAttributes *p, const void *c)
85
+ {
86
+ return cudaErrorUnknown;
87
+ }
88
+
89
+ inline __device__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device)
90
+ {
91
+ return cudaErrorUnknown;
92
+ }
93
+
94
+ inline __device__ cudaError_t CUDARTAPI cudaGetDevice(int *device)
95
+ {
96
+ return cudaErrorUnknown;
97
+ }
98
+
99
+ inline __device__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize)
100
+ {
101
+ return cudaErrorUnknown;
102
+ }
103
+
104
+ inline __device__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags)
105
+ {
106
+ return cudaErrorUnknown;
107
+ }
108
+ #else // __CUDA_INTERNAL_USE_CDP2
109
+ inline __device__ cudaError_t CUDARTAPI __cudaCDP2Malloc(void **p, size_t s)
110
+ {
111
+ return cudaErrorUnknown;
112
+ }
113
+
114
+ inline __device__ cudaError_t CUDARTAPI __cudaCDP2FuncGetAttributes(struct cudaFuncAttributes *p, const void *c)
115
+ {
116
+ return cudaErrorUnknown;
117
+ }
118
+
119
+ inline __device__ cudaError_t CUDARTAPI __cudaCDP2DeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device)
120
+ {
121
+ return cudaErrorUnknown;
122
+ }
123
+
124
+ inline __device__ cudaError_t CUDARTAPI __cudaCDP2GetDevice(int *device)
125
+ {
126
+ return cudaErrorUnknown;
127
+ }
128
+
129
+ inline __device__ cudaError_t CUDARTAPI __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize)
130
+ {
131
+ return cudaErrorUnknown;
132
+ }
133
+
134
+ inline __device__ cudaError_t CUDARTAPI __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags)
135
+ {
136
+ return cudaErrorUnknown;
137
+ }
138
+ #endif // __CUDA_INTERNAL_USE_CDP2
139
+
140
+
141
+ #if defined(__cplusplus)
142
+ }
143
+ #endif
144
+
145
+ #endif /* !defined(__CUDACC_INTERNAL_NO_STUBS__) && !defined(__CUDACC_RDC__) && !defined(__CUDACC_EWP__) && defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 350) && !defined(__CUDADEVRT_INTERNAL__) */
146
+
147
+ #endif /* !defined(__CUDACC_RTC__) */
148
+
149
+ #if defined(__DOXYGEN_ONLY__) || defined(CUDA_ENABLE_DEPRECATED)
150
+ # define __DEPRECATED__(msg)
151
+ #elif defined(_WIN32)
152
+ # define __DEPRECATED__(msg) __declspec(deprecated(msg))
153
+ #elif (defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5 && !defined(__clang__))))
154
+ # define __DEPRECATED__(msg) __attribute__((deprecated))
155
+ #else
156
+ # define __DEPRECATED__(msg) __attribute__((deprecated(msg)))
157
+ #endif
158
+
159
+ #if defined(__CUDA_ARCH__) && !defined(__CDPRT_SUPPRESS_SYNC_DEPRECATION_WARNING)
160
+ # define __CDPRT_DEPRECATED(func_name) __DEPRECATED__("Use of "#func_name" from device code is deprecated. Moreover, such use will cause this module to fail to load on sm_90+ devices. If calls to "#func_name" from device code cannot be removed for older devices at this time, you may guard them with __CUDA_ARCH__ macros to remove them only for sm_90+ devices, making sure to generate code for compute_90 for the macros to take effect. Note that this mitigation will no longer work when support for "#func_name" from device code is eventually dropped for all devices. Disable this warning with -D__CDPRT_SUPPRESS_SYNC_DEPRECATION_WARNING.")
161
+ #else
162
+ # define __CDPRT_DEPRECATED(func_name)
163
+ #endif
164
+
165
+ #if defined(__cplusplus) && defined(__CUDACC__) /* Visible to nvcc front-end only */
166
+ #if !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 350) // Visible to SM>=3.5 and "__host__ __device__" only
167
+
168
+ #include "driver_types.h"
169
+ #include "crt/host_defines.h"
170
+
171
+ #define cudaStreamGraphTailLaunch (cudaStream_t)0x0100000000000000
172
+ #define cudaStreamGraphFireAndForget (cudaStream_t)0x0200000000000000
173
+ #define cudaStreamGraphFireAndForgetAsSibling (cudaStream_t)0x0300000000000000
174
+
175
+ #ifdef __CUDA_INTERNAL_USE_CDP2
176
+ #define cudaStreamTailLaunch ((cudaStream_t)0x3) /**< Per-grid stream with a tail launch semantics. Only applicable when used with CUDA Dynamic Parallelism. */
177
+ #define cudaStreamFireAndForget ((cudaStream_t)0x4) /**< Per-grid stream with a fire-and-forget synchronization behavior. Only applicable when used with CUDA Dynamic Parallelism. */
178
+ #endif
179
+
180
+ extern "C"
181
+ {
182
+
183
+ // Symbols beginning with __cudaCDP* should not be used outside
184
+ // this header file. Instead, compile with -DCUDA_FORCE_CDP1_IF_SUPPORTED if
185
+ // CDP1 support is required.
186
+
187
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaDeviceSynchronizeDeprecationAvoidance(void);
188
+
189
+ #ifndef __CUDA_INTERNAL_USE_CDP2
190
+ //// CDP1 endpoints
191
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device);
192
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetLimit(size_t *pValue, enum cudaLimit limit);
193
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetCacheConfig(enum cudaFuncCache *pCacheConfig);
194
+ extern __DEPRECATED__("cudaDeviceGetSharedMemConfig deprecated") __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetSharedMemConfig(enum cudaSharedMemConfig *pConfig);
195
+ #if (__CUDA_ARCH__ < 900) && (defined(CUDA_FORCE_CDP1_IF_SUPPORTED) || (defined(_WIN32) && !defined(_WIN64)))
196
+ // cudaDeviceSynchronize is removed on sm_90+
197
+ extern __device__ __cudart_builtin__ __CDPRT_DEPRECATED(cudaDeviceSynchronize) cudaError_t CUDARTAPI cudaDeviceSynchronize(void);
198
+ #endif
199
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetLastError(void);
200
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaPeekAtLastError(void);
201
+ extern __device__ __cudart_builtin__ const char* CUDARTAPI cudaGetErrorString(cudaError_t error);
202
+ extern __device__ __cudart_builtin__ const char* CUDARTAPI cudaGetErrorName(cudaError_t error);
203
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetDeviceCount(int *count);
204
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetDevice(int *device);
205
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamCreateWithFlags(cudaStream_t *pStream, unsigned int flags);
206
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamDestroy(cudaStream_t stream);
207
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamWaitEvent(cudaStream_t stream, cudaEvent_t event, unsigned int flags);
208
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamWaitEvent_ptsz(cudaStream_t stream, cudaEvent_t event, unsigned int flags);
209
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventCreateWithFlags(cudaEvent_t *event, unsigned int flags);
210
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecord(cudaEvent_t event, cudaStream_t stream);
211
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecord_ptsz(cudaEvent_t event, cudaStream_t stream);
212
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecordWithFlags(cudaEvent_t event, cudaStream_t stream, unsigned int flags);
213
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecordWithFlags_ptsz(cudaEvent_t event, cudaStream_t stream, unsigned int flags);
214
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventDestroy(cudaEvent_t event);
215
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaFuncGetAttributes(struct cudaFuncAttributes *attr, const void *func);
216
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaFree(void *devPtr);
217
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMalloc(void **devPtr, size_t size);
218
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpyAsync(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream);
219
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpyAsync_ptsz(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream);
220
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy2DAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream);
221
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy2DAsync_ptsz(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream);
222
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy3DAsync(const struct cudaMemcpy3DParms *p, cudaStream_t stream);
223
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy3DAsync_ptsz(const struct cudaMemcpy3DParms *p, cudaStream_t stream);
224
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemsetAsync(void *devPtr, int value, size_t count, cudaStream_t stream);
225
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemsetAsync_ptsz(void *devPtr, int value, size_t count, cudaStream_t stream);
226
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset2DAsync(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream);
227
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset2DAsync_ptsz(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream);
228
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset3DAsync(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream);
229
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset3DAsync_ptsz(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream);
230
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaRuntimeGetVersion(int *runtimeVersion);
231
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize);
232
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags);
233
+ #endif // __CUDA_INTERNAL_USE_CDP2
234
+
235
+ //// CDP2 endpoints
236
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2DeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device);
237
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2DeviceGetLimit(size_t *pValue, enum cudaLimit limit);
238
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2DeviceGetCacheConfig(enum cudaFuncCache *pCacheConfig);
239
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2DeviceGetSharedMemConfig(enum cudaSharedMemConfig *pConfig);
240
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2GetLastError(void);
241
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2PeekAtLastError(void);
242
+ extern __device__ __cudart_builtin__ const char* CUDARTAPI __cudaCDP2GetErrorString(cudaError_t error);
243
+ extern __device__ __cudart_builtin__ const char* CUDARTAPI __cudaCDP2GetErrorName(cudaError_t error);
244
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2GetDeviceCount(int *count);
245
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2GetDevice(int *device);
246
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2StreamCreateWithFlags(cudaStream_t *pStream, unsigned int flags);
247
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2StreamDestroy(cudaStream_t stream);
248
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2StreamWaitEvent(cudaStream_t stream, cudaEvent_t event, unsigned int flags);
249
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2StreamWaitEvent_ptsz(cudaStream_t stream, cudaEvent_t event, unsigned int flags);
250
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventCreateWithFlags(cudaEvent_t *event, unsigned int flags);
251
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventRecord(cudaEvent_t event, cudaStream_t stream);
252
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventRecord_ptsz(cudaEvent_t event, cudaStream_t stream);
253
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventRecordWithFlags(cudaEvent_t event, cudaStream_t stream, unsigned int flags);
254
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventRecordWithFlags_ptsz(cudaEvent_t event, cudaStream_t stream, unsigned int flags);
255
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventDestroy(cudaEvent_t event);
256
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2FuncGetAttributes(struct cudaFuncAttributes *attr, const void *func);
257
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Free(void *devPtr);
258
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Malloc(void **devPtr, size_t size);
259
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2MemcpyAsync(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream);
260
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2MemcpyAsync_ptsz(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream);
261
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memcpy2DAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream);
262
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memcpy2DAsync_ptsz(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream);
263
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memcpy3DAsync(const struct cudaMemcpy3DParms *p, cudaStream_t stream);
264
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memcpy3DAsync_ptsz(const struct cudaMemcpy3DParms *p, cudaStream_t stream);
265
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2MemsetAsync(void *devPtr, int value, size_t count, cudaStream_t stream);
266
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2MemsetAsync_ptsz(void *devPtr, int value, size_t count, cudaStream_t stream);
267
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memset2DAsync(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream);
268
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memset2DAsync_ptsz(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream);
269
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memset3DAsync(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream);
270
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memset3DAsync_ptsz(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream);
271
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2RuntimeGetVersion(int *runtimeVersion);
272
+ extern __device__ __cudart_builtin__ void * CUDARTAPI __cudaCDP2GetParameterBuffer(size_t alignment, size_t size);
273
+ extern __device__ __cudart_builtin__ void * CUDARTAPI __cudaCDP2GetParameterBufferV2(void *func, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize);
274
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2LaunchDevice_ptsz(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream);
275
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2LaunchDeviceV2_ptsz(void *parameterBuffer, cudaStream_t stream);
276
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2LaunchDevice(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream);
277
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2LaunchDeviceV2(void *parameterBuffer, cudaStream_t stream);
278
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize);
279
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags);
280
+
281
+
282
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphLaunch(cudaGraphExec_t graphExec, cudaStream_t stream);
283
+ #if defined(CUDA_API_PER_THREAD_DEFAULT_STREAM)
284
+ static inline __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphLaunch_ptsz(cudaGraphExec_t graphExec, cudaStream_t stream)
285
+ {
286
+ if (stream == 0) {
287
+ stream = cudaStreamPerThread;
288
+ }
289
+ return cudaGraphLaunch(graphExec, stream);
290
+ }
291
+ #endif
292
+
293
+ /**
294
+ * \ingroup CUDART_GRAPH
295
+ * \brief Get the currently running device graph id.
296
+ *
297
+ * Get the currently running device graph id.
298
+ * \return Returns the current device graph id, 0 if the call is outside of a device graph.
299
+ * \sa cudaGraphLaunch
300
+ */
301
+ static inline __device__ __cudart_builtin__ cudaGraphExec_t CUDARTAPI cudaGetCurrentGraphExec(void)
302
+ {
303
+ unsigned long long current_graph_exec;
304
+ asm ("mov.u64 %0, %%current_graph_exec;" : "=l"(current_graph_exec));
305
+ return (cudaGraphExec_t)current_graph_exec;
306
+ }
307
+
308
+ /**
309
+ * \ingroup CUDART_GRAPH
310
+ * \brief Updates the kernel parameters of the given kernel node
311
+ *
312
+ * Updates \p size bytes in the kernel parameters of \p node at \p offset to
313
+ * the contents of \p value. \p node must be device-updatable, and must reside upon the same
314
+ * device as the calling kernel.
315
+ *
316
+ * If this function is called for the node's immediate dependent and that dependent is configured
317
+ * for programmatic dependent launch, then a memory fence must be invoked via __threadfence() before
318
+ * kickoff of the dependent is triggered via ::cudaTriggerProgrammaticLaunchCompletion() to ensure
319
+ * that the update is visible to that dependent node before it is launched.
320
+ *
321
+ * \param node - The node to update
322
+ * \param offset - The offset into the params at which to make the update
323
+ * \param value - Buffer containing the params to write
324
+ * \param size - Size in bytes to update
325
+ *
326
+ * \return
327
+ * cudaSucces,
328
+ * cudaErrorInvalidValue
329
+ * \notefnerr
330
+ *
331
+ * \sa
332
+ * ::cudaGraphKernelNodeSetEnabled,
333
+ * ::cudaGraphKernelNodeSetGridDim,
334
+ * ::cudaGraphKernelNodeUpdatesApply
335
+ */
336
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphKernelNodeSetParam(cudaGraphDeviceNode_t node, size_t offset, const void *value , size_t size);
337
+
338
+ /**
339
+ * \ingroup CUDART_GRAPH
340
+ * \brief Enables or disables the given kernel node
341
+ *
342
+ * Enables or disables \p node based upon \p enable. If \p enable is true, the node will be enabled;
343
+ * if it is false, the node will be disabled. Disabled nodes will act as a NOP during execution.
344
+ * \p node must be device-updatable, and must reside upon the same device as the calling kernel.
345
+ *
346
+ * If this function is called for the node's immediate dependent and that dependent is configured
347
+ * for programmatic dependent launch, then a memory fence must be invoked via __threadfence() before
348
+ * kickoff of the dependent is triggered via ::cudaTriggerProgrammaticLaunchCompletion() to ensure
349
+ * that the update is visible to that dependent node before it is launched.
350
+ *
351
+ * \param node - The node to update
352
+ * \param enable - Whether to enable or disable the node
353
+ *
354
+ * \return
355
+ * cudaSucces,
356
+ * cudaErrorInvalidValue
357
+ * \notefnerr
358
+ *
359
+ * \sa
360
+ * ::cudaGraphKernelNodeSetParam,
361
+ * ::cudaGraphKernelNodeSetGridDim,
362
+ * ::cudaGraphKernelNodeUpdatesApply
363
+ */
364
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphKernelNodeSetEnabled(cudaGraphDeviceNode_t node, bool enable);
365
+
366
+ /**
367
+ * \ingroup CUDART_GRAPH
368
+ * \brief Updates the grid dimensions of the given kernel node
369
+ *
370
+ * Sets the grid dimensions of \p node to \p gridDim. \p node must be device-updatable,
371
+ * and must reside upon the same device as thecalling kernel.
372
+ *
373
+ * If this function is called for the node's immediate dependent and that dependent is configured
374
+ * for programmatic dependent launch, then a memory fence must be invoked via __threadfence() before
375
+ * kickoff of the dependent is triggered via ::cudaTriggerProgrammaticLaunchCompletion() to ensure
376
+ * that the update is visible to that dependent node before it is launched.
377
+ *
378
+ * \param node - The node to update
379
+ * \param gridDim - The grid dimensions to set
380
+ *
381
+ * \return
382
+ * cudaSucces,
383
+ * cudaErrorInvalidValue
384
+ * \notefnerr
385
+ *
386
+ * \sa
387
+ * ::cudaGraphKernelNodeSetParam,
388
+ * ::cudaGraphKernelNodeSetEnabled,
389
+ * ::cudaGraphKernelNodeUpdatesApply
390
+ */
391
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphKernelNodeSetGridDim(cudaGraphDeviceNode_t node, dim3 gridDim);
392
+
393
+ /**
394
+ * \ingroup CUDART_GRAPH
395
+ * \brief Batch applies multiple kernel node updates
396
+ *
397
+ * Batch applies one or more kernel node updates based on the information provided in \p updates.
398
+ * \p updateCount specifies the number of updates to apply. Each entry in \p updates must specify
399
+ * a node to update, the type of update to apply, and the parameters for that type of update. See
400
+ * the documentation for ::cudaGraphKernelNodeUpdate for more detail.
401
+ *
402
+ * If this function is called for the node's immediate dependent and that dependent is configured
403
+ * for programmatic dependent launch, then a memory fence must be invoked via __threadfence() before
404
+ * kickoff of the dependent is triggered via ::cudaTriggerProgrammaticLaunchCompletion() to ensure
405
+ * that the update is visible to that dependent node before it is launched.
406
+ *
407
+ * \param updates - The updates to apply
408
+ * \param updateCount - The number of updates to apply
409
+ *
410
+ * \return
411
+ * cudaSucces,
412
+ * cudaErrorInvalidValue
413
+ * \notefnerr
414
+ *
415
+ * \sa
416
+ * ::cudaGraphKernelNodeSetParam,
417
+ * ::cudaGraphKernelNodeSetEnabled,
418
+ * ::cudaGraphKernelNodeSetGridDim
419
+ */
420
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphKernelNodeUpdatesApply(const cudaGraphKernelNodeUpdate *updates, size_t updateCount);
421
+
422
+ /**
423
+ * \ingroup CUDART_EXECUTION
424
+ * \brief Programmatic dependency trigger
425
+ *
426
+ * This device function ensures the programmatic launch completion edges /
427
+ * events are fulfilled. See
428
+ * ::cudaLaunchAttributeID::cudaLaunchAttributeProgrammaticStreamSerialization
429
+ * and ::cudaLaunchAttributeID::cudaLaunchAttributeProgrammaticEvent for more
430
+ * information. The event / edge kick off only happens when every CTAs
431
+ * in the grid has either exited or called this function at least once,
432
+ * otherwise the kick off happens automatically after all warps finishes
433
+ * execution but before the grid completes. The kick off only enables
434
+ * scheduling of the secondary kernel. It provides no memory visibility
435
+ * guarantee itself. The user could enforce memory visibility by inserting a
436
+ * memory fence of the correct scope.
437
+ */
438
+ static inline __device__ __cudart_builtin__ void CUDARTAPI cudaTriggerProgrammaticLaunchCompletion(void)
439
+ {
440
+ asm volatile("griddepcontrol.launch_dependents;":::);
441
+ }
442
+
443
+ /**
444
+ * \ingroup CUDART_EXECUTION
445
+ * \brief Programmatic grid dependency synchronization
446
+ *
447
+ * This device function will block the thread until all direct grid
448
+ * dependencies have completed. This API is intended to use in conjuncture with
449
+ * programmatic / launch event / dependency. See
450
+ * ::cudaLaunchAttributeID::cudaLaunchAttributeProgrammaticStreamSerialization
451
+ * and ::cudaLaunchAttributeID::cudaLaunchAttributeProgrammaticEvent for more
452
+ * information.
453
+ */
454
+ static inline __device__ __cudart_builtin__ void CUDARTAPI cudaGridDependencySynchronize(void)
455
+ {
456
+ asm volatile("griddepcontrol.wait;":::"memory");
457
+ }
458
+
459
+ /**
460
+ * \ingroup CUDART_GRAPH
461
+ * \brief Sets the condition value associated with a conditional node.
462
+ *
463
+ * Sets the condition value associated with a conditional node.
464
+ * \sa cudaGraphConditionalHandleCreate
465
+ */
466
+ extern __device__ __cudart_builtin__ void CUDARTAPI cudaGraphSetConditional(cudaGraphConditionalHandle handle, unsigned int value);
467
+
468
+ //// CG API
469
+ extern __device__ __cudart_builtin__ unsigned long long CUDARTAPI cudaCGGetIntrinsicHandle(enum cudaCGScope scope);
470
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGSynchronize(unsigned long long handle, unsigned int flags);
471
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGSynchronizeGrid(unsigned long long handle, unsigned int flags);
472
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGGetSize(unsigned int *numThreads, unsigned int *numGrids, unsigned long long handle);
473
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGGetRank(unsigned int *threadRank, unsigned int *gridRank, unsigned long long handle);
474
+
475
+
476
+ //// CDP API
477
+
478
+ #ifdef __CUDA_ARCH__
479
+
480
+ #ifdef __CUDA_INTERNAL_USE_CDP2
481
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device)
482
+ {
483
+ return __cudaCDP2DeviceGetAttribute(value, attr, device);
484
+ }
485
+
486
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetLimit(size_t *pValue, enum cudaLimit limit)
487
+ {
488
+ return __cudaCDP2DeviceGetLimit(pValue, limit);
489
+ }
490
+
491
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetCacheConfig(enum cudaFuncCache *pCacheConfig)
492
+ {
493
+ return __cudaCDP2DeviceGetCacheConfig(pCacheConfig);
494
+ }
495
+
496
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetSharedMemConfig(enum cudaSharedMemConfig *pConfig)
497
+ {
498
+ return __cudaCDP2DeviceGetSharedMemConfig(pConfig);
499
+ }
500
+
501
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetLastError(void)
502
+ {
503
+ return __cudaCDP2GetLastError();
504
+ }
505
+
506
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaPeekAtLastError(void)
507
+ {
508
+ return __cudaCDP2PeekAtLastError();
509
+ }
510
+
511
+ static __inline__ __device__ __cudart_builtin__ const char* CUDARTAPI cudaGetErrorString(cudaError_t error)
512
+ {
513
+ return __cudaCDP2GetErrorString(error);
514
+ }
515
+
516
+ static __inline__ __device__ __cudart_builtin__ const char* CUDARTAPI cudaGetErrorName(cudaError_t error)
517
+ {
518
+ return __cudaCDP2GetErrorName(error);
519
+ }
520
+
521
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetDeviceCount(int *count)
522
+ {
523
+ return __cudaCDP2GetDeviceCount(count);
524
+ }
525
+
526
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetDevice(int *device)
527
+ {
528
+ return __cudaCDP2GetDevice(device);
529
+ }
530
+
531
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamCreateWithFlags(cudaStream_t *pStream, unsigned int flags)
532
+ {
533
+ return __cudaCDP2StreamCreateWithFlags(pStream, flags);
534
+ }
535
+
536
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamDestroy(cudaStream_t stream)
537
+ {
538
+ return __cudaCDP2StreamDestroy(stream);
539
+ }
540
+
541
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamWaitEvent(cudaStream_t stream, cudaEvent_t event, unsigned int flags)
542
+ {
543
+ return __cudaCDP2StreamWaitEvent(stream, event, flags);
544
+ }
545
+
546
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamWaitEvent_ptsz(cudaStream_t stream, cudaEvent_t event, unsigned int flags)
547
+ {
548
+ return __cudaCDP2StreamWaitEvent_ptsz(stream, event, flags);
549
+ }
550
+
551
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventCreateWithFlags(cudaEvent_t *event, unsigned int flags)
552
+ {
553
+ return __cudaCDP2EventCreateWithFlags(event, flags);
554
+ }
555
+
556
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecord(cudaEvent_t event, cudaStream_t stream)
557
+ {
558
+ return __cudaCDP2EventRecord(event, stream);
559
+ }
560
+
561
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecord_ptsz(cudaEvent_t event, cudaStream_t stream)
562
+ {
563
+ return __cudaCDP2EventRecord_ptsz(event, stream);
564
+ }
565
+
566
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecordWithFlags(cudaEvent_t event, cudaStream_t stream, unsigned int flags)
567
+ {
568
+ return __cudaCDP2EventRecordWithFlags(event, stream, flags);
569
+ }
570
+
571
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecordWithFlags_ptsz(cudaEvent_t event, cudaStream_t stream, unsigned int flags)
572
+ {
573
+ return __cudaCDP2EventRecordWithFlags_ptsz(event, stream, flags);
574
+ }
575
+
576
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventDestroy(cudaEvent_t event)
577
+ {
578
+ return __cudaCDP2EventDestroy(event);
579
+ }
580
+
581
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaFuncGetAttributes(struct cudaFuncAttributes *attr, const void *func)
582
+ {
583
+ return __cudaCDP2FuncGetAttributes(attr, func);
584
+ }
585
+
586
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaFree(void *devPtr)
587
+ {
588
+ return __cudaCDP2Free(devPtr);
589
+ }
590
+
591
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMalloc(void **devPtr, size_t size)
592
+ {
593
+ return __cudaCDP2Malloc(devPtr, size);
594
+ }
595
+
596
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpyAsync(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream)
597
+ {
598
+ return __cudaCDP2MemcpyAsync(dst, src, count, kind, stream);
599
+ }
600
+
601
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpyAsync_ptsz(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream)
602
+ {
603
+ return __cudaCDP2MemcpyAsync_ptsz(dst, src, count, kind, stream);
604
+ }
605
+
606
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy2DAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream)
607
+ {
608
+ return __cudaCDP2Memcpy2DAsync(dst, dpitch, src, spitch, width, height, kind, stream);
609
+ }
610
+
611
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy2DAsync_ptsz(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream)
612
+ {
613
+ return __cudaCDP2Memcpy2DAsync_ptsz(dst, dpitch, src, spitch, width, height, kind, stream);
614
+ }
615
+
616
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy3DAsync(const struct cudaMemcpy3DParms *p, cudaStream_t stream)
617
+ {
618
+ return __cudaCDP2Memcpy3DAsync(p, stream);
619
+ }
620
+
621
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy3DAsync_ptsz(const struct cudaMemcpy3DParms *p, cudaStream_t stream)
622
+ {
623
+ return __cudaCDP2Memcpy3DAsync_ptsz(p, stream);
624
+ }
625
+
626
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemsetAsync(void *devPtr, int value, size_t count, cudaStream_t stream)
627
+ {
628
+ return __cudaCDP2MemsetAsync(devPtr, value, count, stream);
629
+ }
630
+
631
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemsetAsync_ptsz(void *devPtr, int value, size_t count, cudaStream_t stream)
632
+ {
633
+ return __cudaCDP2MemsetAsync_ptsz(devPtr, value, count, stream);
634
+ }
635
+
636
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset2DAsync(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream)
637
+ {
638
+ return __cudaCDP2Memset2DAsync(devPtr, pitch, value, width, height, stream);
639
+ }
640
+
641
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset2DAsync_ptsz(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream)
642
+ {
643
+ return __cudaCDP2Memset2DAsync_ptsz(devPtr, pitch, value, width, height, stream);
644
+ }
645
+
646
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset3DAsync(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream)
647
+ {
648
+ return __cudaCDP2Memset3DAsync(pitchedDevPtr, value, extent, stream);
649
+ }
650
+
651
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset3DAsync_ptsz(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream)
652
+ {
653
+ return __cudaCDP2Memset3DAsync_ptsz(pitchedDevPtr, value, extent, stream);
654
+ }
655
+
656
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaRuntimeGetVersion(int *runtimeVersion)
657
+ {
658
+ return __cudaCDP2RuntimeGetVersion(runtimeVersion);
659
+ }
660
+
661
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize)
662
+ {
663
+ return __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessor(numBlocks, func, blockSize, dynamicSmemSize);
664
+ }
665
+
666
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags)
667
+ {
668
+ return __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessorWithFlags(numBlocks, func, blockSize, dynamicSmemSize, flags);
669
+ }
670
+ #endif // __CUDA_INTERNAL_USE_CDP2
671
+
672
+ #endif // __CUDA_ARCH__
673
+
674
+
675
+ /**
676
+ * \ingroup CUDART_EXECUTION
677
+ * \brief Obtains a parameter buffer
678
+ *
679
+ * Obtains a parameter buffer which can be filled with parameters for a kernel launch.
680
+ * Parameters passed to ::cudaLaunchDevice must be allocated via this function.
681
+ *
682
+ * This is a low level API and can only be accessed from Parallel Thread Execution (PTX).
683
+ * CUDA user code should use <<< >>> to launch kernels.
684
+ *
685
+ * \param alignment - Specifies alignment requirement of the parameter buffer
686
+ * \param size - Specifies size requirement in bytes
687
+ *
688
+ * \return
689
+ * Returns pointer to the allocated parameterBuffer
690
+ * \notefnerr
691
+ *
692
+ * \sa cudaLaunchDevice
693
+ */
694
+ #ifdef __CUDA_INTERNAL_USE_CDP2
695
+ static __inline__ __device__ __cudart_builtin__ void * CUDARTAPI cudaGetParameterBuffer(size_t alignment, size_t size)
696
+ {
697
+ return __cudaCDP2GetParameterBuffer(alignment, size);
698
+ }
699
+ #else
700
+ extern __device__ __cudart_builtin__ void * CUDARTAPI cudaGetParameterBuffer(size_t alignment, size_t size);
701
+ #endif
702
+
703
+
704
+ #ifdef __CUDA_INTERNAL_USE_CDP2
705
+ static __inline__ __device__ __cudart_builtin__ void * CUDARTAPI cudaGetParameterBufferV2(void *func, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize)
706
+ {
707
+ return __cudaCDP2GetParameterBufferV2(func, gridDimension, blockDimension, sharedMemSize);
708
+ }
709
+ #else
710
+ extern __device__ __cudart_builtin__ void * CUDARTAPI cudaGetParameterBufferV2(void *func, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize);
711
+ #endif
712
+
713
+
714
+ #ifdef __CUDA_INTERNAL_USE_CDP2
715
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDevice_ptsz(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream)
716
+ {
717
+ return __cudaCDP2LaunchDevice_ptsz(func, parameterBuffer, gridDimension, blockDimension, sharedMemSize, stream);
718
+ }
719
+
720
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDeviceV2_ptsz(void *parameterBuffer, cudaStream_t stream)
721
+ {
722
+ return __cudaCDP2LaunchDeviceV2_ptsz(parameterBuffer, stream);
723
+ }
724
+ #else
725
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDevice_ptsz(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream);
726
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDeviceV2_ptsz(void *parameterBuffer, cudaStream_t stream);
727
+ #endif
728
+
729
+
730
+ /**
731
+ * \ingroup CUDART_EXECUTION
732
+ * \brief Launches a specified kernel
733
+ *
734
+ * Launches a specified kernel with the specified parameter buffer. A parameter buffer can be obtained
735
+ * by calling ::cudaGetParameterBuffer().
736
+ *
737
+ * This is a low level API and can only be accessed from Parallel Thread Execution (PTX).
738
+ * CUDA user code should use <<< >>> to launch the kernels.
739
+ *
740
+ * \param func - Pointer to the kernel to be launched
741
+ * \param parameterBuffer - Holds the parameters to the launched kernel. parameterBuffer can be NULL. (Optional)
742
+ * \param gridDimension - Specifies grid dimensions
743
+ * \param blockDimension - Specifies block dimensions
744
+ * \param sharedMemSize - Specifies size of shared memory
745
+ * \param stream - Specifies the stream to be used
746
+ *
747
+ * \return
748
+ * ::cudaSuccess, ::cudaErrorInvalidDevice, ::cudaErrorLaunchMaxDepthExceeded, ::cudaErrorInvalidConfiguration,
749
+ * ::cudaErrorStartupFailure, ::cudaErrorLaunchPendingCountExceeded, ::cudaErrorLaunchOutOfResources
750
+ * \notefnerr
751
+ * \n Please refer to Execution Configuration and Parameter Buffer Layout from the CUDA Programming
752
+ * Guide for the detailed descriptions of launch configuration and parameter layout respectively.
753
+ *
754
+ * \sa cudaGetParameterBuffer
755
+ */
756
+ #if defined(CUDA_API_PER_THREAD_DEFAULT_STREAM) && defined(__CUDA_ARCH__)
757
+ // When compiling for the device and per thread default stream is enabled, add
758
+ // a static inline redirect to the per thread stream entry points.
759
+
760
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI
761
+ cudaLaunchDevice(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream)
762
+ {
763
+ #ifdef __CUDA_INTERNAL_USE_CDP2
764
+ return __cudaCDP2LaunchDevice_ptsz(func, parameterBuffer, gridDimension, blockDimension, sharedMemSize, stream);
765
+ #else
766
+ return cudaLaunchDevice_ptsz(func, parameterBuffer, gridDimension, blockDimension, sharedMemSize, stream);
767
+ #endif
768
+ }
769
+
770
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI
771
+ cudaLaunchDeviceV2(void *parameterBuffer, cudaStream_t stream)
772
+ {
773
+ #ifdef __CUDA_INTERNAL_USE_CDP2
774
+ return __cudaCDP2LaunchDeviceV2_ptsz(parameterBuffer, stream);
775
+ #else
776
+ return cudaLaunchDeviceV2_ptsz(parameterBuffer, stream);
777
+ #endif
778
+ }
779
+ #else // defined(CUDA_API_PER_THREAD_DEFAULT_STREAM) && defined(__CUDA_ARCH__)
780
+ #ifdef __CUDA_INTERNAL_USE_CDP2
781
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDevice(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream)
782
+ {
783
+ return __cudaCDP2LaunchDevice(func, parameterBuffer, gridDimension, blockDimension, sharedMemSize, stream);
784
+ }
785
+
786
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDeviceV2(void *parameterBuffer, cudaStream_t stream)
787
+ {
788
+ return __cudaCDP2LaunchDeviceV2(parameterBuffer, stream);
789
+ }
790
+ #else // __CUDA_INTERNAL_USE_CDP2
791
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDevice(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream);
792
+ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDeviceV2(void *parameterBuffer, cudaStream_t stream);
793
+ #endif // __CUDA_INTERNAL_USE_CDP2
794
+ #endif // defined(CUDA_API_PER_THREAD_DEFAULT_STREAM) && defined(__CUDA_ARCH__)
795
+
796
+
797
+ // These symbols should not be used outside of this header file.
798
+ #define __cudaCDP2DeviceGetAttribute
799
+ #define __cudaCDP2DeviceGetLimit
800
+ #define __cudaCDP2DeviceGetCacheConfig
801
+ #define __cudaCDP2DeviceGetSharedMemConfig
802
+ #define __cudaCDP2GetLastError
803
+ #define __cudaCDP2PeekAtLastError
804
+ #define __cudaCDP2GetErrorString
805
+ #define __cudaCDP2GetErrorName
806
+ #define __cudaCDP2GetDeviceCount
807
+ #define __cudaCDP2GetDevice
808
+ #define __cudaCDP2StreamCreateWithFlags
809
+ #define __cudaCDP2StreamDestroy
810
+ #define __cudaCDP2StreamWaitEvent
811
+ #define __cudaCDP2StreamWaitEvent_ptsz
812
+ #define __cudaCDP2EventCreateWithFlags
813
+ #define __cudaCDP2EventRecord
814
+ #define __cudaCDP2EventRecord_ptsz
815
+ #define __cudaCDP2EventRecordWithFlags
816
+ #define __cudaCDP2EventRecordWithFlags_ptsz
817
+ #define __cudaCDP2EventDestroy
818
+ #define __cudaCDP2FuncGetAttributes
819
+ #define __cudaCDP2Free
820
+ #define __cudaCDP2Malloc
821
+ #define __cudaCDP2MemcpyAsync
822
+ #define __cudaCDP2MemcpyAsync_ptsz
823
+ #define __cudaCDP2Memcpy2DAsync
824
+ #define __cudaCDP2Memcpy2DAsync_ptsz
825
+ #define __cudaCDP2Memcpy3DAsync
826
+ #define __cudaCDP2Memcpy3DAsync_ptsz
827
+ #define __cudaCDP2MemsetAsync
828
+ #define __cudaCDP2MemsetAsync_ptsz
829
+ #define __cudaCDP2Memset2DAsync
830
+ #define __cudaCDP2Memset2DAsync_ptsz
831
+ #define __cudaCDP2Memset3DAsync
832
+ #define __cudaCDP2Memset3DAsync_ptsz
833
+ #define __cudaCDP2RuntimeGetVersion
834
+ #define __cudaCDP2GetParameterBuffer
835
+ #define __cudaCDP2GetParameterBufferV2
836
+ #define __cudaCDP2LaunchDevice_ptsz
837
+ #define __cudaCDP2LaunchDeviceV2_ptsz
838
+ #define __cudaCDP2LaunchDevice
839
+ #define __cudaCDP2LaunchDeviceV2
840
+ #define __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessor
841
+ #define __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessorWithFlags
842
+
843
+ }
844
+
845
+ template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaMalloc(T **devPtr, size_t size);
846
+ template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaFuncGetAttributes(struct cudaFuncAttributes *attr, T *entry);
847
+ template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, T func, int blockSize, size_t dynamicSmemSize);
848
+ template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, T func, int blockSize, size_t dynamicSmemSize, unsigned int flags);
849
+
850
+ /**
851
+ * \ingroup CUDART_GRAPH
852
+ * \brief Updates the kernel parameters of the given kernel node
853
+ *
854
+ * Updates the kernel parameters of \p node at \p offset to \p value. \p node must be
855
+ * device-updatable, and must reside upon the same device as the calling kernel.
856
+ *
857
+ * If this function is called for the node's immediate dependent and that dependent is configured
858
+ * for programmatic dependent launch, then a memory fence must be invoked via __threadfence() before
859
+ * kickoff of the dependent is triggered via ::cudaTriggerProgrammaticLaunchCompletion() to ensure
860
+ * that the update is visible to that dependent node before it is launched.
861
+ *
862
+ * \param node - The node to update
863
+ * \param offset - The offset into the params at which to make the update
864
+ * \param value - Parameter value to write
865
+ *
866
+ * \return
867
+ * cudaSucces,
868
+ * cudaErrorInvalidValue
869
+ * \notefnerr
870
+ *
871
+ * \sa
872
+ * ::etblGraphKernelNodeSetEnabled,
873
+ * ::etblGraphKernelNodeSetGridDim,
874
+ * ::etblGraphKernelNodeUpdatesApply
875
+ */
876
+ template <typename T>
877
+ static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphKernelNodeSetParam(cudaGraphDeviceNode_t node, size_t offset, const T &value)
878
+ {
879
+ return cudaGraphKernelNodeSetParam(node, offset, &value, sizeof(T));
880
+ }
881
+
882
+ #endif // !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 350)
883
+ #endif /* defined(__cplusplus) && defined(__CUDACC__) */
884
+
885
+ #undef __DEPRECATED__
886
+ #undef __CDPRT_DEPRECATED
887
+ #undef __CUDA_INTERNAL_USE_CDP2
888
+
889
+ #endif /* !__CUDA_DEVICE_RUNTIME_API_H__ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_egl_interop.h ADDED
@@ -0,0 +1,642 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(__CUDA_EGL_INTEROP_H__)
51
+ #define __CUDA_EGL_INTEROP_H__
52
+
53
+ #include "cuda_runtime_api.h"
54
+ #include "cuda_runtime.h"
55
+ #include "cudart_platform.h"
56
+ #include "EGL/egl.h"
57
+ #include "EGL/eglext.h"
58
+
59
+ #if defined(__cplusplus)
60
+ extern "C" {
61
+ #endif /* __cplusplus */
62
+
63
+ /**
64
+ * \addtogroup CUDART_TYPES
65
+ * @{
66
+ */
67
+
68
+ /**
69
+ * Maximum number of planes per frame
70
+ */
71
+ #define CUDA_EGL_MAX_PLANES 3
72
+
73
+ /**
74
+ * CUDA EglFrame type - array or pointer
75
+ */
76
+ typedef enum cudaEglFrameType_enum
77
+ {
78
+ cudaEglFrameTypeArray = 0, /**< Frame type CUDA array */
79
+ cudaEglFrameTypePitch = 1, /**< Frame type CUDA pointer */
80
+ } cudaEglFrameType;
81
+
82
+ /**
83
+ * Resource location flags- sysmem or vidmem
84
+ *
85
+ * For CUDA context on iGPU, since video and system memory are equivalent -
86
+ * these flags will not have an effect on the execution.
87
+ *
88
+ * For CUDA context on dGPU, applications can use the flag ::cudaEglResourceLocationFlags
89
+ * to give a hint about the desired location.
90
+ *
91
+ * ::cudaEglResourceLocationSysmem - the frame data is made resident on the system memory
92
+ * to be accessed by CUDA.
93
+ *
94
+ * ::cudaEglResourceLocationVidmem - the frame data is made resident on the dedicated
95
+ * video memory to be accessed by CUDA.
96
+ *
97
+ * There may be an additional latency due to new allocation and data migration,
98
+ * if the frame is produced on a different memory.
99
+ */
100
+ typedef enum cudaEglResourceLocationFlags_enum {
101
+ cudaEglResourceLocationSysmem = 0x00, /**< Resource location sysmem */
102
+ cudaEglResourceLocationVidmem = 0x01, /**< Resource location vidmem */
103
+ } cudaEglResourceLocationFlags;
104
+
105
+ /**
106
+ * CUDA EGL Color Format - The different planar and multiplanar formats currently supported for CUDA_EGL interops.
107
+ */
108
+ typedef enum cudaEglColorFormat_enum {
109
+ cudaEglColorFormatYUV420Planar = 0, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
110
+ cudaEglColorFormatYUV420SemiPlanar = 1, /**< Y, UV in two surfaces (UV as one surface) with VU byte ordering, width, height ratio same as YUV420Planar. */
111
+ cudaEglColorFormatYUV422Planar = 2, /**< Y, U, V each in a separate surface, U/V width = 1/2 Y width, U/V height = Y height. */
112
+ cudaEglColorFormatYUV422SemiPlanar = 3, /**< Y, UV in two surfaces with VU byte ordering, width, height ratio same as YUV422Planar. */
113
+ cudaEglColorFormatARGB = 6, /**< R/G/B/A four channels in one surface with BGRA byte ordering. */
114
+ cudaEglColorFormatRGBA = 7, /**< R/G/B/A four channels in one surface with ABGR byte ordering. */
115
+ cudaEglColorFormatL = 8, /**< single luminance channel in one surface. */
116
+ cudaEglColorFormatR = 9, /**< single color channel in one surface. */
117
+ cudaEglColorFormatYUV444Planar = 10, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = Y width, U/V height = Y height. */
118
+ cudaEglColorFormatYUV444SemiPlanar = 11, /**< Y, UV in two surfaces (UV as one surface) with VU byte ordering, width, height ratio same as YUV444Planar. */
119
+ cudaEglColorFormatYUYV422 = 12, /**< Y, U, V in one surface, interleaved as UYVY in one channel. */
120
+ cudaEglColorFormatUYVY422 = 13, /**< Y, U, V in one surface, interleaved as YUYV in one channel. */
121
+ cudaEglColorFormatABGR = 14, /**< R/G/B/A four channels in one surface with RGBA byte ordering. */
122
+ cudaEglColorFormatBGRA = 15, /**< R/G/B/A four channels in one surface with ARGB byte ordering. */
123
+ cudaEglColorFormatA = 16, /**< Alpha color format - one channel in one surface. */
124
+ cudaEglColorFormatRG = 17, /**< R/G color format - two channels in one surface with GR byte ordering */
125
+ cudaEglColorFormatAYUV = 18, /**< Y, U, V, A four channels in one surface, interleaved as VUYA. */
126
+ cudaEglColorFormatYVU444SemiPlanar = 19, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
127
+ cudaEglColorFormatYVU422SemiPlanar = 20, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
128
+ cudaEglColorFormatYVU420SemiPlanar = 21, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
129
+ cudaEglColorFormatY10V10U10_444SemiPlanar = 22, /**< Y10, V10U10 in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
130
+ cudaEglColorFormatY10V10U10_420SemiPlanar = 23, /**< Y10, V10U10 in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
131
+ cudaEglColorFormatY12V12U12_444SemiPlanar = 24, /**< Y12, V12U12 in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
132
+ cudaEglColorFormatY12V12U12_420SemiPlanar = 25, /**< Y12, V12U12 in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
133
+ cudaEglColorFormatVYUY_ER = 26, /**< Extended Range Y, U, V in one surface, interleaved as YVYU in one channel. */
134
+ cudaEglColorFormatUYVY_ER = 27, /**< Extended Range Y, U, V in one surface, interleaved as YUYV in one channel. */
135
+ cudaEglColorFormatYUYV_ER = 28, /**< Extended Range Y, U, V in one surface, interleaved as UYVY in one channel. */
136
+ cudaEglColorFormatYVYU_ER = 29, /**< Extended Range Y, U, V in one surface, interleaved as VYUY in one channel. */
137
+ cudaEglColorFormatYUVA_ER = 31, /**< Extended Range Y, U, V, A four channels in one surface, interleaved as AVUY. */
138
+ cudaEglColorFormatAYUV_ER = 32, /**< Extended Range Y, U, V, A four channels in one surface, interleaved as VUYA. */
139
+ cudaEglColorFormatYUV444Planar_ER = 33, /**< Extended Range Y, U, V in three surfaces, U/V width = Y width, U/V height = Y height. */
140
+ cudaEglColorFormatYUV422Planar_ER = 34, /**< Extended Range Y, U, V in three surfaces, U/V width = 1/2 Y width, U/V height = Y height. */
141
+ cudaEglColorFormatYUV420Planar_ER = 35, /**< Extended Range Y, U, V in three surfaces, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
142
+ cudaEglColorFormatYUV444SemiPlanar_ER = 36, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = Y width, U/V height = Y height. */
143
+ cudaEglColorFormatYUV422SemiPlanar_ER = 37, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
144
+ cudaEglColorFormatYUV420SemiPlanar_ER = 38, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
145
+ cudaEglColorFormatYVU444Planar_ER = 39, /**< Extended Range Y, V, U in three surfaces, U/V width = Y width, U/V height = Y height. */
146
+ cudaEglColorFormatYVU422Planar_ER = 40, /**< Extended Range Y, V, U in three surfaces, U/V width = 1/2 Y width, U/V height = Y height. */
147
+ cudaEglColorFormatYVU420Planar_ER = 41, /**< Extended Range Y, V, U in three surfaces, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
148
+ cudaEglColorFormatYVU444SemiPlanar_ER = 42, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
149
+ cudaEglColorFormatYVU422SemiPlanar_ER = 43, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
150
+ cudaEglColorFormatYVU420SemiPlanar_ER = 44, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
151
+ cudaEglColorFormatBayerRGGB = 45, /**< Bayer format - one channel in one surface with interleaved RGGB ordering. */
152
+ cudaEglColorFormatBayerBGGR = 46, /**< Bayer format - one channel in one surface with interleaved BGGR ordering. */
153
+ cudaEglColorFormatBayerGRBG = 47, /**< Bayer format - one channel in one surface with interleaved GRBG ordering. */
154
+ cudaEglColorFormatBayerGBRG = 48, /**< Bayer format - one channel in one surface with interleaved GBRG ordering. */
155
+ cudaEglColorFormatBayer10RGGB = 49, /**< Bayer10 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
156
+ cudaEglColorFormatBayer10BGGR = 50, /**< Bayer10 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
157
+ cudaEglColorFormatBayer10GRBG = 51, /**< Bayer10 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
158
+ cudaEglColorFormatBayer10GBRG = 52, /**< Bayer10 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
159
+ cudaEglColorFormatBayer12RGGB = 53, /**< Bayer12 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
160
+ cudaEglColorFormatBayer12BGGR = 54, /**< Bayer12 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
161
+ cudaEglColorFormatBayer12GRBG = 55, /**< Bayer12 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
162
+ cudaEglColorFormatBayer12GBRG = 56, /**< Bayer12 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
163
+ cudaEglColorFormatBayer14RGGB = 57, /**< Bayer14 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
164
+ cudaEglColorFormatBayer14BGGR = 58, /**< Bayer14 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
165
+ cudaEglColorFormatBayer14GRBG = 59, /**< Bayer14 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
166
+ cudaEglColorFormatBayer14GBRG = 60, /**< Bayer14 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
167
+ cudaEglColorFormatBayer20RGGB = 61, /**< Bayer20 format - one channel in one surface with interleaved RGGB ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
168
+ cudaEglColorFormatBayer20BGGR = 62, /**< Bayer20 format - one channel in one surface with interleaved BGGR ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
169
+ cudaEglColorFormatBayer20GRBG = 63, /**< Bayer20 format - one channel in one surface with interleaved GRBG ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
170
+ cudaEglColorFormatBayer20GBRG = 64, /**< Bayer20 format - one channel in one surface with interleaved GBRG ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
171
+ cudaEglColorFormatYVU444Planar = 65, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = Y width, U/V height = Y height. */
172
+ cudaEglColorFormatYVU422Planar = 66, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = Y height. */
173
+ cudaEglColorFormatYVU420Planar = 67, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
174
+ cudaEglColorFormatBayerIspRGGB = 68, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved RGGB ordering and mapped to opaque integer datatype. */
175
+ cudaEglColorFormatBayerIspBGGR = 69, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved BGGR ordering and mapped to opaque integer datatype. */
176
+ cudaEglColorFormatBayerIspGRBG = 70, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved GRBG ordering and mapped to opaque integer datatype. */
177
+ cudaEglColorFormatBayerIspGBRG = 71, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved GBRG ordering and mapped to opaque integer datatype. */
178
+ cudaEglColorFormatBayerBCCR = 72, /**< Bayer format - one channel in one surface with interleaved BCCR ordering. */
179
+ cudaEglColorFormatBayerRCCB = 73, /**< Bayer format - one channel in one surface with interleaved RCCB ordering. */
180
+ cudaEglColorFormatBayerCRBC = 74, /**< Bayer format - one channel in one surface with interleaved CRBC ordering. */
181
+ cudaEglColorFormatBayerCBRC = 75, /**< Bayer format - one channel in one surface with interleaved CBRC ordering. */
182
+ cudaEglColorFormatBayer10CCCC = 76, /**< Bayer10 format - one channel in one surface with interleaved CCCC ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
183
+ cudaEglColorFormatBayer12BCCR = 77, /**< Bayer12 format - one channel in one surface with interleaved BCCR ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
184
+ cudaEglColorFormatBayer12RCCB = 78, /**< Bayer12 format - one channel in one surface with interleaved RCCB ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
185
+ cudaEglColorFormatBayer12CRBC = 79, /**< Bayer12 format - one channel in one surface with interleaved CRBC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
186
+ cudaEglColorFormatBayer12CBRC = 80, /**< Bayer12 format - one channel in one surface with interleaved CBRC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
187
+ cudaEglColorFormatBayer12CCCC = 81, /**< Bayer12 format - one channel in one surface with interleaved CCCC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
188
+ cudaEglColorFormatY = 82, /**< Color format for single Y plane. */
189
+ cudaEglColorFormatYUV420SemiPlanar_2020 = 83, /**< Y, UV in two surfaces (UV as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
190
+ cudaEglColorFormatYVU420SemiPlanar_2020 = 84, /**< Y, VU in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
191
+ cudaEglColorFormatYUV420Planar_2020 = 85, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
192
+ cudaEglColorFormatYVU420Planar_2020 = 86, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
193
+ cudaEglColorFormatYUV420SemiPlanar_709 = 87, /**< Y, UV in two surfaces (UV as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
194
+ cudaEglColorFormatYVU420SemiPlanar_709 = 88, /**< Y, VU in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
195
+ cudaEglColorFormatYUV420Planar_709 = 89, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
196
+ cudaEglColorFormatYVU420Planar_709 = 90, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
197
+ cudaEglColorFormatY10V10U10_420SemiPlanar_709 = 91, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
198
+ cudaEglColorFormatY10V10U10_420SemiPlanar_2020 = 92, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
199
+ cudaEglColorFormatY10V10U10_422SemiPlanar_2020 = 93, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
200
+ cudaEglColorFormatY10V10U10_422SemiPlanar = 94, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
201
+ cudaEglColorFormatY10V10U10_422SemiPlanar_709 = 95, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
202
+ cudaEglColorFormatY_ER = 96, /**< Extended Range Color format for single Y plane. */
203
+ cudaEglColorFormatY_709_ER = 97, /**< Extended Range Color format for single Y plane. */
204
+ cudaEglColorFormatY10_ER = 98, /**< Extended Range Color format for single Y10 plane. */
205
+ cudaEglColorFormatY10_709_ER = 99, /**< Extended Range Color format for single Y10 plane. */
206
+ cudaEglColorFormatY12_ER = 100, /**< Extended Range Color format for single Y12 plane. */
207
+ cudaEglColorFormatY12_709_ER = 101, /**< Extended Range Color format for single Y12 plane. */
208
+ cudaEglColorFormatYUVA = 102, /**< Y, U, V, A four channels in one surface, interleaved as AVUY. */
209
+ cudaEglColorFormatYVYU = 104, /**< Y, U, V in one surface, interleaved as YVYU in one channel. */
210
+ cudaEglColorFormatVYUY = 105, /**< Y, U, V in one surface, interleaved as VYUY in one channel. */
211
+ cudaEglColorFormatY10V10U10_420SemiPlanar_ER = 106, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
212
+ cudaEglColorFormatY10V10U10_420SemiPlanar_709_ER = 107, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
213
+ cudaEglColorFormatY10V10U10_444SemiPlanar_ER = 108, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
214
+ cudaEglColorFormatY10V10U10_444SemiPlanar_709_ER = 109, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
215
+ cudaEglColorFormatY12V12U12_420SemiPlanar_ER = 110, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
216
+ cudaEglColorFormatY12V12U12_420SemiPlanar_709_ER = 111, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
217
+ cudaEglColorFormatY12V12U12_444SemiPlanar_ER = 112, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
218
+ cudaEglColorFormatY12V12U12_444SemiPlanar_709_ER = 113, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
219
+ } cudaEglColorFormat;
220
+
221
+ /**
222
+ * CUDA EGL Plane Descriptor - structure defining each plane of a CUDA EGLFrame
223
+ */
224
+ typedef struct cudaEglPlaneDesc_st {
225
+ unsigned int width; /**< Width of plane */
226
+ unsigned int height; /**< Height of plane */
227
+ unsigned int depth; /**< Depth of plane */
228
+ unsigned int pitch; /**< Pitch of plane */
229
+ unsigned int numChannels; /**< Number of channels for the plane */
230
+ struct cudaChannelFormatDesc channelDesc; /**< Channel Format Descriptor */
231
+ unsigned int reserved[4]; /**< Reserved for future use */
232
+ } cudaEglPlaneDesc;
233
+
234
+ /**
235
+ * CUDA EGLFrame Descriptor - structure defining one frame of EGL.
236
+ *
237
+ * Each frame may contain one or more planes depending on whether the surface is Multiplanar or not.
238
+ * Each plane of EGLFrame is represented by ::cudaEglPlaneDesc which is defined as:
239
+ * \code
240
+ * typedef struct cudaEglPlaneDesc_st {
241
+ * unsigned int width;
242
+ * unsigned int height;
243
+ * unsigned int depth;
244
+ * unsigned int pitch;
245
+ * unsigned int numChannels;
246
+ * struct cudaChannelFormatDesc channelDesc;
247
+ * unsigned int reserved[4];
248
+ * } cudaEglPlaneDesc;
249
+ * \endcode
250
+
251
+ */
252
+ typedef struct cudaEglFrame_st {
253
+ union {
254
+ cudaArray_t pArray[CUDA_EGL_MAX_PLANES]; /**< Array of CUDA arrays corresponding to each plane*/
255
+ struct cudaPitchedPtr pPitch[CUDA_EGL_MAX_PLANES]; /**< Array of Pointers corresponding to each plane*/
256
+ } frame;
257
+ cudaEglPlaneDesc planeDesc[CUDA_EGL_MAX_PLANES]; /**< CUDA EGL Plane Descriptor ::cudaEglPlaneDesc*/
258
+ unsigned int planeCount; /**< Number of planes */
259
+ cudaEglFrameType frameType; /**< Array or Pitch */
260
+ cudaEglColorFormat eglColorFormat; /**< CUDA EGL Color Format*/
261
+ } cudaEglFrame;
262
+
263
+ /**
264
+ * CUDA EGLSream Connection
265
+ */
266
+ typedef struct CUeglStreamConnection_st *cudaEglStreamConnection;
267
+
268
+ /** @} */ /* END CUDART_TYPES */
269
+
270
+ /**
271
+ * \addtogroup CUDART_EGL EGL Interoperability
272
+ * This section describes the EGL interoperability functions of the CUDA
273
+ * runtime application programming interface.
274
+ *
275
+ * @{
276
+ */
277
+
278
+ /**
279
+ * \brief Registers an EGL image
280
+ *
281
+ * Registers the EGLImageKHR specified by \p image for access by
282
+ * CUDA. A handle to the registered object is returned as \p pCudaResource.
283
+ * Additional Mapping/Unmapping is not required for the registered resource and
284
+ * ::cudaGraphicsResourceGetMappedEglFrame can be directly called on the \p pCudaResource.
285
+ *
286
+ * The application will be responsible for synchronizing access to shared objects.
287
+ * The application must ensure that any pending operation which access the objects have completed
288
+ * before passing control to CUDA. This may be accomplished by issuing and waiting for
289
+ * glFinish command on all GLcontexts (for OpenGL and likewise for other APIs).
290
+ * The application will be also responsible for ensuring that any pending operation on the
291
+ * registered CUDA resource has completed prior to executing subsequent commands in other APIs
292
+ * accesing the same memory objects.
293
+ * This can be accomplished by calling cuCtxSynchronize or cuEventSynchronize (preferably).
294
+ *
295
+ * The surface's intended usage is specified using \p flags, as follows:
296
+ *
297
+ * - ::cudaGraphicsRegisterFlagsNone: Specifies no hints about how this
298
+ * resource will be used. It is therefore assumed that this resource will be
299
+ * read from and written to by CUDA. This is the default value.
300
+ * - ::cudaGraphicsRegisterFlagsReadOnly: Specifies that CUDA
301
+ * will not write to this resource.
302
+ * - ::cudaGraphicsRegisterFlagsWriteDiscard: Specifies that
303
+ * CUDA will not read from this resource and will write over the
304
+ * entire contents of the resource, so none of the data previously
305
+ * stored in the resource will be preserved.
306
+ *
307
+ * The EGLImageKHR is an object which can be used to create EGLImage target resource. It is defined as a void pointer.
308
+ * typedef void* EGLImageKHR
309
+ *
310
+ * \param pCudaResource - Pointer to the returned object handle
311
+ * \param image - An EGLImageKHR image which can be used to create target resource.
312
+ * \param flags - Map flags
313
+ *
314
+ * \return
315
+ * ::cudaSuccess,
316
+ * ::cudaErrorInvalidResourceHandle,
317
+ * ::cudaErrorInvalidValue,
318
+ * ::cudaErrorUnknown
319
+ *
320
+ * \sa
321
+ * ::cudaGraphicsUnregisterResource,
322
+ * ::cudaGraphicsResourceGetMappedEglFrame,
323
+ * ::cuGraphicsEGLRegisterImage
324
+ */
325
+ extern __host__ cudaError_t CUDARTAPI cudaGraphicsEGLRegisterImage(struct cudaGraphicsResource **pCudaResource, EGLImageKHR image, unsigned int flags);
326
+
327
+ /**
328
+ * \brief Connect CUDA to EGLStream as a consumer.
329
+ *
330
+ * Connect CUDA as a consumer to EGLStreamKHR specified by \p eglStream.
331
+ *
332
+ * The EGLStreamKHR is an EGL object that transfers a sequence of image frames from one
333
+ * API to another.
334
+ *
335
+ * \param conn - Pointer to the returned connection handle
336
+ * \param eglStream - EGLStreamKHR handle
337
+ *
338
+ * \return
339
+ * ::cudaSuccess,
340
+ * ::cudaErrorInvalidValue,
341
+ * ::cudaErrorUnknown
342
+ *
343
+ * \sa
344
+ * ::cudaEGLStreamConsumerDisconnect,
345
+ * ::cudaEGLStreamConsumerAcquireFrame,
346
+ * ::cudaEGLStreamConsumerReleaseFrame,
347
+ * ::cuEGLStreamConsumerConnect
348
+ */
349
+ extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerConnect(cudaEglStreamConnection *conn, EGLStreamKHR eglStream);
350
+
351
+ /**
352
+ * \brief Connect CUDA to EGLStream as a consumer with given flags.
353
+ *
354
+ * Connect CUDA as a consumer to EGLStreamKHR specified by \p stream with specified \p flags defined by
355
+ * ::cudaEglResourceLocationFlags.
356
+ *
357
+ * The flags specify whether the consumer wants to access frames from system memory or video memory.
358
+ * Default is ::cudaEglResourceLocationVidmem.
359
+ *
360
+ * \param conn - Pointer to the returned connection handle
361
+ * \param eglStream - EGLStreamKHR handle
362
+ * \param flags - Flags denote intended location - system or video.
363
+ *
364
+ * \return
365
+ * ::cudaSuccess,
366
+ * ::cudaErrorInvalidValue,
367
+ * ::cudaErrorUnknown
368
+ *
369
+ * \sa
370
+ * ::cudaEGLStreamConsumerDisconnect,
371
+ * ::cudaEGLStreamConsumerAcquireFrame,
372
+ * ::cudaEGLStreamConsumerReleaseFrame,
373
+ * ::cuEGLStreamConsumerConnectWithFlags
374
+ */
375
+ extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerConnectWithFlags(cudaEglStreamConnection *conn, EGLStreamKHR eglStream, unsigned int flags);
376
+
377
+ /**
378
+ * \brief Disconnect CUDA as a consumer to EGLStream .
379
+ *
380
+ * Disconnect CUDA as a consumer to EGLStreamKHR.
381
+ *
382
+ * \param conn - Conection to disconnect.
383
+ *
384
+ * \return
385
+ * ::cudaSuccess,
386
+ * ::cudaErrorInvalidValue,
387
+ * ::cudaErrorUnknown
388
+ *
389
+ * \sa
390
+ * ::cudaEGLStreamConsumerConnect,
391
+ * ::cudaEGLStreamConsumerAcquireFrame,
392
+ * ::cudaEGLStreamConsumerReleaseFrame,
393
+ * ::cuEGLStreamConsumerDisconnect
394
+ */
395
+ extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerDisconnect(cudaEglStreamConnection *conn);
396
+
397
+ /**
398
+ * \brief Acquire an image frame from the EGLStream with CUDA as a consumer.
399
+ *
400
+ * Acquire an image frame from EGLStreamKHR.
401
+ * ::cudaGraphicsResourceGetMappedEglFrame can be called on \p pCudaResource to get
402
+ * ::cudaEglFrame.
403
+ *
404
+ * \param conn - Connection on which to acquire
405
+ * \param pCudaResource - CUDA resource on which the EGLStream frame will be mapped for use.
406
+ * \param pStream - CUDA stream for synchronization and any data migrations
407
+ * implied by ::cudaEglResourceLocationFlags.
408
+ * \param timeout - Desired timeout in usec.
409
+ *
410
+ * \return
411
+ * ::cudaSuccess,
412
+ * ::cudaErrorInvalidValue,
413
+ * ::cudaErrorUnknown,
414
+ * ::cudaErrorLaunchTimeout
415
+ *
416
+ * \sa
417
+ * ::cudaEGLStreamConsumerConnect,
418
+ * ::cudaEGLStreamConsumerDisconnect,
419
+ * ::cudaEGLStreamConsumerReleaseFrame,
420
+ * ::cuEGLStreamConsumerAcquireFrame
421
+ */
422
+
423
+ extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerAcquireFrame(cudaEglStreamConnection *conn,
424
+ cudaGraphicsResource_t *pCudaResource, cudaStream_t *pStream, unsigned int timeout);
425
+ /**
426
+ * \brief Releases the last frame acquired from the EGLStream.
427
+ *
428
+ * Release the acquired image frame specified by \p pCudaResource to EGLStreamKHR.
429
+ *
430
+ * \param conn - Connection on which to release
431
+ * \param pCudaResource - CUDA resource whose corresponding frame is to be released
432
+ * \param pStream - CUDA stream on which release will be done.
433
+ *
434
+ * \return
435
+ * ::cudaSuccess,
436
+ * ::cudaErrorInvalidValue,
437
+ * ::cudaErrorUnknown
438
+ *
439
+ * \sa
440
+ * ::cudaEGLStreamConsumerConnect,
441
+ * ::cudaEGLStreamConsumerDisconnect,
442
+ * ::cudaEGLStreamConsumerAcquireFrame,
443
+ * ::cuEGLStreamConsumerReleaseFrame
444
+ */
445
+ extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerReleaseFrame(cudaEglStreamConnection *conn,
446
+ cudaGraphicsResource_t pCudaResource, cudaStream_t *pStream);
447
+
448
+ /**
449
+ * \brief Connect CUDA to EGLStream as a producer.
450
+ *
451
+ * Connect CUDA as a producer to EGLStreamKHR specified by \p stream.
452
+ *
453
+ * The EGLStreamKHR is an EGL object that transfers a sequence of image frames from one
454
+ * API to another.
455
+ *
456
+ * \param conn - Pointer to the returned connection handle
457
+ * \param eglStream - EGLStreamKHR handle
458
+ * \param width - width of the image to be submitted to the stream
459
+ * \param height - height of the image to be submitted to the stream
460
+ *
461
+ * \return
462
+ * ::cudaSuccess,
463
+ * ::cudaErrorInvalidValue,
464
+ * ::cudaErrorUnknown
465
+ *
466
+ * \sa
467
+ * ::cudaEGLStreamProducerDisconnect,
468
+ * ::cudaEGLStreamProducerPresentFrame,
469
+ * ::cudaEGLStreamProducerReturnFrame,
470
+ * ::cuEGLStreamProducerConnect
471
+ */
472
+ extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerConnect(cudaEglStreamConnection *conn,
473
+ EGLStreamKHR eglStream, EGLint width, EGLint height);
474
+
475
+ /**
476
+ * \brief Disconnect CUDA as a producer to EGLStream .
477
+ *
478
+ * Disconnect CUDA as a producer to EGLStreamKHR.
479
+ *
480
+ * \param conn - Conection to disconnect.
481
+ *
482
+ * \return
483
+ * ::cudaSuccess,
484
+ * ::cudaErrorInvalidValue,
485
+ * ::cudaErrorUnknown
486
+ *
487
+ * \sa
488
+ * ::cudaEGLStreamProducerConnect,
489
+ * ::cudaEGLStreamProducerPresentFrame,
490
+ * ::cudaEGLStreamProducerReturnFrame,
491
+ * ::cuEGLStreamProducerDisconnect
492
+ */
493
+ extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerDisconnect(cudaEglStreamConnection *conn);
494
+
495
+ /**
496
+ * \brief Present a CUDA eglFrame to the EGLStream with CUDA as a producer.
497
+ *
498
+ * The ::cudaEglFrame is defined as:
499
+ * \code
500
+ * typedef struct cudaEglFrame_st {
501
+ * union {
502
+ * cudaArray_t pArray[CUDA_EGL_MAX_PLANES];
503
+ * struct cudaPitchedPtr pPitch[CUDA_EGL_MAX_PLANES];
504
+ * } frame;
505
+ * cudaEglPlaneDesc planeDesc[CUDA_EGL_MAX_PLANES];
506
+ * unsigned int planeCount;
507
+ * cudaEglFrameType frameType;
508
+ * cudaEglColorFormat eglColorFormat;
509
+ * } cudaEglFrame;
510
+ * \endcode
511
+ *
512
+ * For ::cudaEglFrame of type ::cudaEglFrameTypePitch, the application may present sub-region of a memory
513
+ * allocation. In that case, ::cudaPitchedPtr::ptr will specify the start address of the sub-region in
514
+ * the allocation and ::cudaEglPlaneDesc will specify the dimensions of the sub-region.
515
+ *
516
+ * \param conn - Connection on which to present the CUDA array
517
+ * \param eglframe - CUDA Eglstream Proucer Frame handle to be sent to the consumer over EglStream.
518
+ * \param pStream - CUDA stream on which to present the frame.
519
+ *
520
+ * \return
521
+ * ::cudaSuccess,
522
+ * ::cudaErrorInvalidValue,
523
+ * ::cudaErrorUnknown
524
+ *
525
+ * \sa
526
+ * ::cudaEGLStreamProducerConnect,
527
+ * ::cudaEGLStreamProducerDisconnect,
528
+ * ::cudaEGLStreamProducerReturnFrame,
529
+ * ::cuEGLStreamProducerPresentFrame
530
+ */
531
+ extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerPresentFrame(cudaEglStreamConnection *conn,
532
+ cudaEglFrame eglframe, cudaStream_t *pStream);
533
+
534
+ /**
535
+ * \brief Return the CUDA eglFrame to the EGLStream last released by the consumer.
536
+ *
537
+ * This API can potentially return cudaErrorLaunchTimeout if the consumer has not
538
+ * returned a frame to EGL stream. If timeout is returned the application can retry.
539
+ *
540
+ * \param conn - Connection on which to present the CUDA array
541
+ * \param eglframe - CUDA Eglstream Proucer Frame handle returned from the consumer over EglStream.
542
+ * \param pStream - CUDA stream on which to return the frame.
543
+ *
544
+ * \return
545
+ * ::cudaSuccess,
546
+ * ::cudaErrorLaunchTimeout,
547
+ * ::cudaErrorInvalidValue,
548
+ * ::cudaErrorUnknown
549
+ *
550
+ * \sa
551
+ * ::cudaEGLStreamProducerConnect,
552
+ * ::cudaEGLStreamProducerDisconnect,
553
+ * ::cudaEGLStreamProducerPresentFrame,
554
+ * ::cuEGLStreamProducerReturnFrame
555
+ */
556
+ extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerReturnFrame(cudaEglStreamConnection *conn,
557
+ cudaEglFrame *eglframe, cudaStream_t *pStream);
558
+
559
+ /**
560
+ * \brief Get an eglFrame through which to access a registered EGL graphics resource.
561
+ *
562
+ * Returns in \p *eglFrame an eglFrame pointer through which the registered graphics resource
563
+ * \p resource may be accessed.
564
+ * This API can only be called for EGL graphics resources.
565
+ *
566
+ * The ::cudaEglFrame is defined as
567
+ * \code
568
+ * typedef struct cudaEglFrame_st {
569
+ * union {
570
+ * cudaArray_t pArray[CUDA_EGL_MAX_PLANES];
571
+ * struct cudaPitchedPtr pPitch[CUDA_EGL_MAX_PLANES];
572
+ * } frame;
573
+ * cudaEglPlaneDesc planeDesc[CUDA_EGL_MAX_PLANES];
574
+ * unsigned int planeCount;
575
+ * cudaEglFrameType frameType;
576
+ * cudaEglColorFormat eglColorFormat;
577
+ * } cudaEglFrame;
578
+ * \endcode
579
+ *
580
+ *
581
+ * \param eglFrame - Returned eglFrame.
582
+ * \param resource - Registered resource to access.
583
+ * \param index - Index for cubemap surfaces.
584
+ * \param mipLevel - Mipmap level for the subresource to access.
585
+ *
586
+ * \return
587
+ * ::cudaSuccess,
588
+ * ::cudaErrorInvalidValue,
589
+ * ::cudaErrorUnknown
590
+ *
591
+ * \note Note that in case of multiplanar \p *eglFrame, pitch of only first plane (unsigned int cudaEglPlaneDesc::pitch) is to be considered by the application.
592
+ *
593
+ * \sa
594
+ * ::cudaGraphicsSubResourceGetMappedArray,
595
+ * ::cudaGraphicsResourceGetMappedPointer,
596
+ * ::cuGraphicsResourceGetMappedEglFrame
597
+ */
598
+ extern __host__ cudaError_t CUDARTAPI cudaGraphicsResourceGetMappedEglFrame(cudaEglFrame* eglFrame,
599
+ cudaGraphicsResource_t resource, unsigned int index, unsigned int mipLevel);
600
+
601
+ /**
602
+ * \brief Creates an event from EGLSync object
603
+ *
604
+ * Creates an event *phEvent from an EGLSyncKHR eglSync with the flages specified
605
+ * via \p flags. Valid flags include:
606
+ * - ::cudaEventDefault: Default event creation flag.
607
+ * - ::cudaEventBlockingSync: Specifies that the created event should use blocking
608
+ * synchronization. A CPU thread that uses ::cudaEventSynchronize() to wait on
609
+ * an event created with this flag will block until the event has actually
610
+ * been completed.
611
+ *
612
+ * ::cudaEventRecord and TimingData are not supported for events created from EGLSync.
613
+ *
614
+ * The EGLSyncKHR is an opaque handle to an EGL sync object.
615
+ * typedef void* EGLSyncKHR
616
+ *
617
+ * \param phEvent - Returns newly created event
618
+ * \param eglSync - Opaque handle to EGLSync object
619
+ * \param flags - Event creation flags
620
+ *
621
+ * \return
622
+ * ::cudaSuccess,
623
+ * ::cudaErrorInitializationError,
624
+ * ::cudaErrorInvalidValue,
625
+ * ::cudaErrorLaunchFailure,
626
+ * ::cudaErrorMemoryAllocation
627
+ *
628
+ * \sa
629
+ * ::cudaEventQuery,
630
+ * ::cudaEventSynchronize,
631
+ * ::cudaEventDestroy
632
+ */
633
+ extern __host__ cudaError_t CUDARTAPI cudaEventCreateFromEGLSync(cudaEvent_t *phEvent, EGLSyncKHR eglSync, unsigned int flags);
634
+
635
+ /** @} */ /* END CUDART_EGL */
636
+
637
+ #if defined(__cplusplus)
638
+ }
639
+ #endif /* __cplusplus */
640
+
641
+ #endif /* __CUDA_EGL_INTEROP_H__ */
642
+
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_fp16.h ADDED
The diff for this file is too large to render. See raw diff
 
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_fp16.hpp ADDED
The diff for this file is too large to render. See raw diff
 
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_fp8.h ADDED
@@ -0,0 +1,367 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2022 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #ifndef __CUDA_FP8_H__
51
+ #define __CUDA_FP8_H__
52
+
53
+ /* Set up function decorations */
54
+ #if defined(__CUDACC__)
55
+ #define __CUDA_FP8_DECL__ static __device__ __inline__
56
+ #define __CUDA_HOSTDEVICE_FP8__ __host__ __device__
57
+ #define __CUDA_HOSTDEVICE_FP8_DECL__ static __host__ __device__ __inline__
58
+ #else /* !defined(__CUDACC__) */
59
+ #if defined(__GNUC__)
60
+ #define __CUDA_HOSTDEVICE_FP8_DECL__ static __attribute__((unused))
61
+ #else
62
+ #define __CUDA_HOSTDEVICE_FP8_DECL__ static
63
+ #endif /* defined(__GNUC__) */
64
+ #define __CUDA_HOSTDEVICE_FP8__
65
+ #endif /* defined(__CUDACC_) */
66
+
67
+ #if !defined(_MSC_VER) && __cplusplus >= 201103L
68
+ #define __CPP_VERSION_AT_LEAST_11_FP8
69
+ #elif _MSC_FULL_VER >= 190024210 && _MSVC_LANG >= 201103L
70
+ #define __CPP_VERSION_AT_LEAST_11_FP8
71
+ #endif
72
+
73
+ /* bring in __half_raw data type */
74
+ #include "cuda_fp16.h"
75
+ /* bring in __nv_bfloat16_raw data type */
76
+ #include "cuda_bf16.h"
77
+ /* bring in float2, double4, etc vector types */
78
+ #include "vector_types.h"
79
+
80
+ /**
81
+ * \defgroup CUDA_MATH_INTRINSIC_FP8 FP8 Intrinsics
82
+ * This section describes fp8 intrinsic functions.
83
+ * To use these functions, include the header file \p cuda_fp8.h in your
84
+ * program.
85
+ * The following macros are available to help users selectively enable/disable
86
+ * various definitions present in the header file:
87
+ * - \p __CUDA_NO_FP8_CONVERSIONS__ - If defined, this macro will prevent any
88
+ * use of the C++ type conversions (converting constructors and conversion
89
+ * operators) defined in the header.
90
+ * - \p __CUDA_NO_FP8_CONVERSION_OPERATORS__ - If defined, this macro will
91
+ * prevent any use of the C++ conversion operators from \p fp8 to other types.
92
+ */
93
+
94
+ /**
95
+ * \defgroup CUDA_MATH_FP8_MISC FP8 Conversion and Data Movement
96
+ * \ingroup CUDA_MATH_INTRINSIC_FP8
97
+ * To use these functions, include the header file \p cuda_fp8.h in your
98
+ * program.
99
+ */
100
+
101
+ /**
102
+ * \ingroup CUDA_MATH_FP8_MISC
103
+ * \brief 8-bit \p unsigned \p integer
104
+ * type abstraction used to for \p fp8 floating-point
105
+ * numbers storage.
106
+ */
107
+ typedef unsigned char __nv_fp8_storage_t;
108
+
109
+ /**
110
+ * \ingroup CUDA_MATH_FP8_MISC
111
+ * \brief 16-bit \p unsigned \p integer
112
+ * type abstraction used to for storage of pairs of
113
+ * \p fp8 floating-point numbers.
114
+ */
115
+ typedef unsigned short int __nv_fp8x2_storage_t;
116
+
117
+ /**
118
+ * \ingroup CUDA_MATH_FP8_MISC
119
+ * \brief 32-bit \p unsigned \p integer
120
+ * type abstraction used to for storage of tetrads of
121
+ * \p fp8 floating-point numbers.
122
+ */
123
+ typedef unsigned int __nv_fp8x4_storage_t;
124
+
125
+ /**
126
+ * \ingroup CUDA_MATH_FP8_MISC
127
+ * \brief Enumerates the modes applicable when
128
+ * performing a narrowing conversion to \p fp8 destination types.
129
+ */
130
+ typedef enum __nv_saturation_t {
131
+ /**
132
+ * Means no saturation to finite is performed when conversion
133
+ * results in rounding values outside the range of destination
134
+ * type.
135
+ * NOTE: for fp8 type of e4m3 kind, the results that are larger
136
+ * than the maximum representable finite number of the target
137
+ * format become NaN.
138
+ */
139
+ __NV_NOSAT,
140
+ /**
141
+ * Means input larger than the maximum representable
142
+ * finite number MAXNORM of the target format round to the
143
+ * MAXNORM of the same sign as input.
144
+ */
145
+ __NV_SATFINITE,
146
+ } __nv_saturation_t;
147
+
148
+ /**
149
+ * \ingroup CUDA_MATH_FP8_MISC
150
+ * \brief Enumerates the possible
151
+ * interpretations of the 8-bit values when referring to them as
152
+ * \p fp8 types.
153
+ */
154
+ typedef enum __nv_fp8_interpretation_t {
155
+ __NV_E4M3, /**< Stands for \p fp8 numbers of \p e4m3 kind. */
156
+ __NV_E5M2, /**< Stands for \p fp8 numbers of \p e5m2 kind. */
157
+ } __nv_fp8_interpretation_t;
158
+
159
+ /* Forward-declaration of C-style APIs */
160
+
161
+ /**
162
+ * \ingroup CUDA_MATH_FP8_MISC
163
+ * \brief Converts input \p double precision \p x to \p fp8 type of the
164
+ * requested kind using round-to-nearest-even rounding and requested saturation
165
+ * mode.
166
+ *
167
+ * \details Converts input \p x to \p fp8 type of the kind specified by
168
+ * \p fp8_interpretation parameter,
169
+ * using round-to-nearest-even rounding and
170
+ * saturation mode specified by \p saturate parameter.
171
+ *
172
+ * \returns
173
+ * - The \p __nv_fp8_storage_t value holds the result of conversion.
174
+ */
175
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t
176
+ __nv_cvt_double_to_fp8(const double x, const __nv_saturation_t saturate,
177
+ const __nv_fp8_interpretation_t fp8_interpretation);
178
+
179
+ /**
180
+ * \ingroup CUDA_MATH_FP8_MISC
181
+ * \brief Converts input vector of two \p double precision numbers packed
182
+ * in \p double2 \p x into a vector of two values of \p fp8 type of
183
+ * the requested kind using round-to-nearest-even rounding and requested
184
+ * saturation mode.
185
+ *
186
+ * \details Converts input vector \p x to a vector of two \p fp8 values of the
187
+ * kind specified by \p fp8_interpretation parameter, using
188
+ * round-to-nearest-even rounding and saturation mode specified by \p saturate
189
+ * parameter.
190
+ *
191
+ * \returns
192
+ * - The \p __nv_fp8x2_storage_t value holds the result of conversion.
193
+ */
194
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t
195
+ __nv_cvt_double2_to_fp8x2(const double2 x, const __nv_saturation_t saturate,
196
+ const __nv_fp8_interpretation_t fp8_interpretation);
197
+
198
+ /**
199
+ * \ingroup CUDA_MATH_FP8_MISC
200
+ * \brief Converts input \p single precision \p x to \p fp8 type of the
201
+ * requested kind using round-to-nearest-even rounding and requested saturation
202
+ * mode.
203
+ *
204
+ * \details Converts input \p x to \p fp8 type of the kind specified by
205
+ * \p fp8_interpretation parameter,
206
+ * using round-to-nearest-even rounding and
207
+ * saturation mode specified by \p saturate parameter.
208
+ *
209
+ * \returns
210
+ * - The \p __nv_fp8_storage_t value holds the result of conversion.
211
+ */
212
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t
213
+ __nv_cvt_float_to_fp8(const float x, const __nv_saturation_t saturate,
214
+ const __nv_fp8_interpretation_t fp8_interpretation);
215
+
216
+ /**
217
+ * \ingroup CUDA_MATH_FP8_MISC
218
+ * \brief Converts input vector of two \p single precision numbers packed
219
+ * in \p float2 \p x into a vector of two values of \p fp8 type of
220
+ * the requested kind using round-to-nearest-even rounding and requested
221
+ * saturation mode.
222
+ *
223
+ * \details Converts input vector \p x to a vector of two \p fp8 values of the
224
+ * kind specified by \p fp8_interpretation parameter, using
225
+ * round-to-nearest-even rounding and saturation mode specified by \p saturate
226
+ * parameter.
227
+ *
228
+ * \returns
229
+ * - The \p __nv_fp8x2_storage_t value holds the result of conversion.
230
+ */
231
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t
232
+ __nv_cvt_float2_to_fp8x2(const float2 x, const __nv_saturation_t saturate,
233
+ const __nv_fp8_interpretation_t fp8_interpretation);
234
+
235
+ /**
236
+ * \ingroup CUDA_MATH_FP8_MISC
237
+ * \brief Converts input \p half precision \p x to \p fp8 type of the requested
238
+ * kind using round-to-nearest-even rounding and requested saturation mode.
239
+ *
240
+ * \details Converts input \p x to \p fp8 type of the kind specified by
241
+ * \p fp8_interpretation parameter,
242
+ * using round-to-nearest-even rounding and
243
+ * saturation mode specified by \p saturate parameter.
244
+ *
245
+ * \returns
246
+ * - The \p __nv_fp8_storage_t value holds the result of conversion.
247
+ */
248
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t
249
+ __nv_cvt_halfraw_to_fp8(const __half_raw x, const __nv_saturation_t saturate,
250
+ const __nv_fp8_interpretation_t fp8_interpretation);
251
+
252
+ /**
253
+ * \ingroup CUDA_MATH_FP8_MISC
254
+ * \brief Converts input vector of two \p half precision numbers packed
255
+ * in \p __half2_raw \p x into a vector of two values of \p fp8 type of
256
+ * the requested kind using round-to-nearest-even rounding and requested
257
+ * saturation mode.
258
+ *
259
+ * \details Converts input vector \p x to a vector of two \p fp8 values of the
260
+ * kind specified by \p fp8_interpretation parameter, using
261
+ * round-to-nearest-even rounding and saturation mode specified by \p saturate
262
+ * parameter.
263
+ *
264
+ * \returns
265
+ * - The \p __nv_fp8x2_storage_t value holds the result of conversion.
266
+ */
267
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t __nv_cvt_halfraw2_to_fp8x2(
268
+ const __half2_raw x, const __nv_saturation_t saturate,
269
+ const __nv_fp8_interpretation_t fp8_interpretation);
270
+
271
+ /**
272
+ * \ingroup CUDA_MATH_FP8_MISC
273
+ * \brief Converts input \p nv_bfloat16 precision \p x to \p fp8 type of the
274
+ * requested kind using round-to-nearest-even rounding and requested saturation
275
+ * mode.
276
+ *
277
+ * \details Converts input \p x to \p fp8 type of the kind specified by
278
+ * \p fp8_interpretation parameter,
279
+ * using round-to-nearest-even rounding and
280
+ * saturation mode specified by \p saturate parameter.
281
+ *
282
+ * \returns
283
+ * - The \p __nv_fp8_storage_t value holds the result of conversion.
284
+ */
285
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t __nv_cvt_bfloat16raw_to_fp8(
286
+ const __nv_bfloat16_raw x, const __nv_saturation_t saturate,
287
+ const __nv_fp8_interpretation_t fp8_interpretation);
288
+
289
+ /**
290
+ * \ingroup CUDA_MATH_FP8_MISC
291
+ * \brief Converts input vector of two \p nv_bfloat16 precision numbers packed
292
+ * in \p __nv_bfloat162_raw \p x into a vector of two values of \p fp8 type of
293
+ * the requested kind using round-to-nearest-even rounding and requested
294
+ * saturation mode.
295
+ *
296
+ * \details Converts input vector \p x to a vector of two \p fp8 values of the
297
+ * kind specified by \p fp8_interpretation parameter, using
298
+ * round-to-nearest-even rounding and saturation mode specified by \p saturate
299
+ * parameter.
300
+ *
301
+ * \returns
302
+ * - The \p __nv_fp8x2_storage_t value holds the result of conversion.
303
+ */
304
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t
305
+ __nv_cvt_bfloat16raw2_to_fp8x2(
306
+ const __nv_bfloat162_raw x, const __nv_saturation_t saturate,
307
+ const __nv_fp8_interpretation_t fp8_interpretation);
308
+
309
+ /**
310
+ * \ingroup CUDA_MATH_FP8_MISC
311
+ * \brief Converts input \p fp8 \p x of the specified kind
312
+ * to \p half precision.
313
+ *
314
+ * \details Converts input \p x of \p fp8 type of the kind specified by
315
+ * \p fp8_interpretation parameter
316
+ * to \p half precision.
317
+ *
318
+ * \returns
319
+ * - The \p __half_raw value holds the result of conversion.
320
+ */
321
+ __CUDA_HOSTDEVICE_FP8_DECL__ __half_raw
322
+ __nv_cvt_fp8_to_halfraw(const __nv_fp8_storage_t x,
323
+ const __nv_fp8_interpretation_t fp8_interpretation);
324
+ /**
325
+ * \ingroup CUDA_MATH_FP8_MISC
326
+ * \brief Converts input vector of two \p fp8 values of the specified kind
327
+ * to a vector of two \p half precision values packed in \p __half2_raw
328
+ * structure.
329
+ *
330
+ * \details Converts input vector \p x of \p fp8 type of the kind specified by
331
+ * \p fp8_interpretation parameter
332
+ * to a vector of two \p half precision values and returns as \p __half2_raw
333
+ * structure.
334
+ *
335
+ * \returns
336
+ * - The \p __half2_raw value holds the result of conversion.
337
+ */
338
+ __CUDA_HOSTDEVICE_FP8_DECL__ __half2_raw
339
+ __nv_cvt_fp8x2_to_halfraw2(const __nv_fp8x2_storage_t x,
340
+ const __nv_fp8_interpretation_t fp8_interpretation);
341
+
342
+ #if defined(__cplusplus)
343
+
344
+ #define __CUDA_FP8_TYPES_EXIST__
345
+
346
+ /* Forward-declaration of structures defined in "cuda_fp8.hpp" */
347
+ struct __nv_fp8_e5m2;
348
+ struct __nv_fp8x2_e5m2;
349
+ struct __nv_fp8x4_e5m2;
350
+
351
+ struct __nv_fp8_e4m3;
352
+ struct __nv_fp8x2_e4m3;
353
+ struct __nv_fp8x4_e4m3;
354
+
355
+ #endif /* defined(__cplusplus) */
356
+
357
+ #include "cuda_fp8.hpp"
358
+
359
+ #undef __CUDA_FP8_DECL__
360
+ #undef __CUDA_HOSTDEVICE_FP8__
361
+ #undef __CUDA_HOSTDEVICE_FP8_DECL__
362
+
363
+ #if defined(__CPP_VERSION_AT_LEAST_11_FP8)
364
+ #undef __CPP_VERSION_AT_LEAST_11_FP8
365
+ #endif /* defined(__CPP_VERSION_AT_LEAST_11_FP8) */
366
+
367
+ #endif /* end of include guard: __CUDA_FP8_H__ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_fp8.hpp ADDED
@@ -0,0 +1,1750 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2022-2023 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(__CUDA_FP8_HPP__)
51
+ #define __CUDA_FP8_HPP__
52
+
53
+ #if !defined(__CUDA_FP8_H__)
54
+ #error "Do not include this file directly. Instead, include cuda_fp8.h."
55
+ #endif
56
+
57
+ /* C++ header for std::memcpy (used for type punning in host-side
58
+ * implementations). When compiling as a CUDA source file memcpy is provided
59
+ * implicitly. !defined(__CUDACC__) implies !defined(__CUDACC_RTC__).
60
+ */
61
+ #if defined(__cplusplus) && !defined(__CUDACC__)
62
+ #include <cstring>
63
+ #elif !defined(__cplusplus) && !defined(__CUDACC__)
64
+ #include <string.h>
65
+ #endif /* defined(__cplusplus) && !defined(__CUDACC__) */
66
+
67
+ /* Set up structure-alignment attribute */
68
+ #if !(defined __CUDA_ALIGN__)
69
+ #if defined(__CUDACC__)
70
+ #define __CUDA_ALIGN__(align) __align__(align)
71
+ #else
72
+ /* Define alignment macro based on compiler type (cannot assume C11 "_Alignas"
73
+ * is available) */
74
+ #if __cplusplus >= 201103L
75
+ #define __CUDA_ALIGN__(n) \
76
+ alignas(n) /* C++11 kindly gives us a keyword for this */
77
+ #else /* !defined(__CPP_VERSION_AT_LEAST_11_FP8)*/
78
+ #if defined(__GNUC__)
79
+ #define __CUDA_ALIGN__(n) __attribute__((aligned(n)))
80
+ #elif defined(_MSC_VER)
81
+ #define __CUDA_ALIGN__(n) __declspec(align(n))
82
+ #else
83
+ #define __CUDA_ALIGN__(n)
84
+ #endif /* defined(__GNUC__) */
85
+ #endif /* defined(__CPP_VERSION_AT_LEAST_11_FP8) */
86
+ #endif /* defined(__CUDACC__) */
87
+ #endif /* !(defined __CUDA_ALIGN__) */
88
+
89
+ #if !(defined __CPP_VERSION_AT_LEAST_11_FP8)
90
+ /* need c++11 for explicit operators */
91
+ #define __CUDA_NO_FP8_CONVERSION_OPERATORS__
92
+ #endif
93
+
94
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t
95
+ __nv_cvt_double_to_fp8(const double x, const __nv_saturation_t saturate,
96
+ const __nv_fp8_interpretation_t fp8_interpretation) {
97
+ unsigned char res;
98
+ unsigned long long int xbits;
99
+
100
+ #if defined(__CUDACC__) || (!defined __cplusplus)
101
+ (void)memcpy(&xbits, &x, sizeof(x));
102
+ #else
103
+ (void)std::memcpy(&xbits, &x, sizeof(x));
104
+ #endif
105
+ unsigned char FP8_MAXNORM;
106
+ unsigned char FP8_MANTISSA_MASK;
107
+ unsigned short int FP8_EXP_BIAS;
108
+ unsigned long long int FP8_SIGNIFICAND_BITS;
109
+ const unsigned long long int DP_INF_BITS = 0x7FF0000000000000ULL;
110
+ unsigned long long int FP8_MINDENORM_O2;
111
+ unsigned long long int FP8_OVERFLOW_THRESHOLD;
112
+ unsigned long long int FP8_MINNORM;
113
+
114
+ if (fp8_interpretation == __NV_E4M3) {
115
+ FP8_EXP_BIAS = 7U;
116
+ FP8_SIGNIFICAND_BITS = 4ULL;
117
+ FP8_MANTISSA_MASK = 0x7U;
118
+ FP8_MINDENORM_O2 = 0x3F50000000000000ULL; // mindenorm/2 = 2^-10
119
+ FP8_OVERFLOW_THRESHOLD =
120
+ 0x407D000000000000ULL; // maxnorm + 1/2ulp = 0x1.Cp+8 + 0x1p+4
121
+ FP8_MAXNORM = 0x7EU;
122
+ FP8_MINNORM = 0x3F90000000000000ULL; // minnorm = 2^-6
123
+ } else { //__NV_E5M2
124
+ FP8_EXP_BIAS = 15U;
125
+ FP8_SIGNIFICAND_BITS = 3ULL;
126
+ FP8_MANTISSA_MASK = 0x3U;
127
+ FP8_MINDENORM_O2 = 0x3EE0000000000000ULL; // mindenorm/2 = 2^-17
128
+ FP8_OVERFLOW_THRESHOLD =
129
+ 0x40EE000000000000ULL -
130
+ 1ULL; // maxnorm + 1/2ulp = 0x1.Ep+15, and -1 to have common code
131
+ FP8_MAXNORM = 0x7BU;
132
+ FP8_MINNORM = 0x3F10000000000000ULL; // minnorm = 2^-14
133
+ }
134
+
135
+ // 1/2 LSB of the target format, positioned in double precision mantissa
136
+ // helpful in midpoints detection during round-to-nearest-even step
137
+ const unsigned long long int FP8_DP_HALF_ULP =
138
+ (unsigned long long int)1ULL << (53ULL - FP8_SIGNIFICAND_BITS - 1ULL);
139
+ // prepare sign bit in target format
140
+ unsigned char sign = (unsigned char)((xbits >> 63ULL) << 7U);
141
+ // prepare exponent field in target format
142
+ unsigned char exp =
143
+ (unsigned char)((((unsigned short int)(xbits >> 52ULL)) & 0x7FFU) -
144
+ 1023U + FP8_EXP_BIAS);
145
+ // round mantissa to target format width, rounding towards zero
146
+ unsigned char mantissa =
147
+ (unsigned char)(xbits >> (53ULL - FP8_SIGNIFICAND_BITS)) &
148
+ FP8_MANTISSA_MASK;
149
+ unsigned long long int absx = xbits & 0x7FFFFFFFFFFFFFFFULL;
150
+
151
+ if (absx <= FP8_MINDENORM_O2) {
152
+ // zero or underflow
153
+ res = 0U;
154
+ } else if (absx > DP_INF_BITS) {
155
+ // NaN
156
+ if (fp8_interpretation == __NV_E4M3) {
157
+ res = 0x7FU;
158
+ } else {
159
+ // NaN --> QNaN
160
+ res = 0x7EU | mantissa;
161
+ }
162
+ } else if (absx > FP8_OVERFLOW_THRESHOLD) {
163
+ if (saturate == __NV_SATFINITE) {
164
+ res = FP8_MAXNORM;
165
+ } else {
166
+ // __NV_NOSAT
167
+ if (fp8_interpretation == __NV_E4M3) {
168
+ // no Inf in E4M3
169
+ res = 0x7FU; // NaN
170
+ } else {
171
+ res = 0x7CU; // Inf in E5M2
172
+ }
173
+ }
174
+ } else if (absx >= FP8_MINNORM) {
175
+ res = (unsigned char)((exp << (FP8_SIGNIFICAND_BITS - 1U)) | mantissa);
176
+ // rounded-off bits
177
+ unsigned long long int round =
178
+ xbits & ((FP8_DP_HALF_ULP << 1ULL) - 1ULL);
179
+ // round-to-nearest-even adjustment
180
+ if ((round > FP8_DP_HALF_ULP) ||
181
+ ((round == FP8_DP_HALF_ULP) && (mantissa & 1U))) {
182
+ res = (unsigned char)(res + 1U);
183
+ }
184
+ } else // Denormal range
185
+ {
186
+ unsigned char shift = (unsigned char)(1U - exp);
187
+ // add implicit leading bit
188
+ mantissa |= (unsigned char)(1U << (FP8_SIGNIFICAND_BITS - 1U));
189
+ // additional round-off due to denormalization
190
+ res = (unsigned char)(mantissa >> shift);
191
+
192
+ // rounded-off bits, including implicit leading bit
193
+ unsigned long long int round =
194
+ (xbits | ((unsigned long long int)1ULL << (53ULL - 1ULL))) &
195
+ ((FP8_DP_HALF_ULP << (shift + 1ULL)) - 1ULL);
196
+ // round-to-nearest-even adjustment
197
+ if ((round > (FP8_DP_HALF_ULP << shift)) ||
198
+ ((round == (FP8_DP_HALF_ULP << shift)) && (res & 1U))) {
199
+ res = (unsigned char)(res + 1U);
200
+ }
201
+ }
202
+
203
+ res |= sign;
204
+
205
+ return (__nv_fp8_storage_t)res;
206
+ }
207
+
208
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t
209
+ __nv_cvt_double2_to_fp8x2(const double2 x, const __nv_saturation_t saturate,
210
+ const __nv_fp8_interpretation_t fp8_interpretation) {
211
+ __nv_fp8x2_storage_t storage = (__nv_fp8x2_storage_t)__nv_cvt_double_to_fp8(
212
+ x.y, saturate, fp8_interpretation);
213
+ storage = (__nv_fp8x2_storage_t)(storage << 8U);
214
+ storage = (__nv_fp8x2_storage_t)(storage |
215
+ __nv_cvt_double_to_fp8(
216
+ x.x, saturate, fp8_interpretation));
217
+ return storage;
218
+ }
219
+
220
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t
221
+ __nv_cvt_float_to_fp8(const float x, const __nv_saturation_t saturate,
222
+ const __nv_fp8_interpretation_t fp8_interpretation) {
223
+ __nv_fp8_storage_t res = 0U;
224
+ #if (defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 890)
225
+ if (saturate == __NV_SATFINITE) {
226
+ __nv_fp8x2_storage_t storage;
227
+ if (fp8_interpretation == __NV_E5M2) {
228
+ asm("{cvt.rn.satfinite.e5m2x2.f32 %0, %2, %1;}\n"
229
+ : "=h"(storage)
230
+ : "f"(x), "f"(0.0f));
231
+ } else {
232
+ asm("{cvt.rn.satfinite.e4m3x2.f32 %0, %2, %1;}\n"
233
+ : "=h"(storage)
234
+ : "f"(x), "f"(0.0f));
235
+ }
236
+ res = (__nv_fp8_storage_t)storage;
237
+ } else
238
+ #endif
239
+ {
240
+ unsigned int xbits;
241
+ #if defined(__CUDACC__) || (!defined __cplusplus)
242
+ (void)memcpy(&xbits, &x, sizeof(x));
243
+ #else
244
+ (void)std::memcpy(&xbits, &x, sizeof(x));
245
+ #endif
246
+
247
+ // isnan
248
+ if ((xbits & 0x7FFFFFFFU) > 0x7F800000U) {
249
+ // Canonical NaN
250
+ xbits = 0x7FFFFFFFU;
251
+ }
252
+
253
+ float fx;
254
+ #if defined(__CUDACC__) || (!defined __cplusplus)
255
+ (void)memcpy(&fx, &xbits, sizeof(xbits));
256
+ #else
257
+ (void)std::memcpy(&fx, &xbits, sizeof(xbits));
258
+ #endif
259
+
260
+ const double dx = (double)fx;
261
+ res = __nv_cvt_double_to_fp8(dx, saturate, fp8_interpretation);
262
+ }
263
+ return res;
264
+ }
265
+
266
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t
267
+ __nv_cvt_float2_to_fp8x2(const float2 x, const __nv_saturation_t saturate,
268
+ const __nv_fp8_interpretation_t fp8_interpretation) {
269
+ __nv_fp8x2_storage_t storage;
270
+ #if (defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 890)
271
+ if (saturate == __NV_SATFINITE) {
272
+ if (fp8_interpretation == __NV_E5M2) {
273
+ asm("{cvt.rn.satfinite.e5m2x2.f32 %0, %2, %1;}\n"
274
+ : "=h"(storage)
275
+ : "f"(x.x), "f"(x.y));
276
+ } else {
277
+ asm("{cvt.rn.satfinite.e4m3x2.f32 %0, %2, %1;}\n"
278
+ : "=h"(storage)
279
+ : "f"(x.x), "f"(x.y));
280
+ }
281
+ } else
282
+ #endif
283
+ {
284
+ storage = (__nv_fp8x2_storage_t)__nv_cvt_float_to_fp8(
285
+ x.y, saturate, fp8_interpretation);
286
+ storage = (__nv_fp8x2_storage_t)(storage << 8U);
287
+ storage = (__nv_fp8x2_storage_t)(storage | __nv_cvt_float_to_fp8(
288
+ x.x, saturate,
289
+ fp8_interpretation));
290
+ }
291
+ return storage;
292
+ }
293
+
294
+ __CUDA_HOSTDEVICE_FP8_DECL__ float
295
+ __internal_halfraw_to_float(const __half_raw x) {
296
+ float f;
297
+ #if (defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 530)
298
+ asm("{cvt.f32.f16 %0, %1;}\n" : "=f"(f) : "h"(x.x));
299
+ #else
300
+ const unsigned int ux = (unsigned int)x.x;
301
+ unsigned int sign = (ux >> 15U) & 1U;
302
+ unsigned int exponent = (ux >> 10U) & 0x1fU;
303
+ unsigned int mantissa = (ux & 0x3ffU) << 13U;
304
+ if (exponent == 0x1fU) { /* NaN or Inf */
305
+ /* discard sign of a NaN */
306
+ sign = ((mantissa != 0U) ? (sign >> 1U) : sign);
307
+ mantissa = ((mantissa != 0U) ? 0x7fffffU : 0U);
308
+ exponent = 0xffU;
309
+ } else if (exponent == 0U) { /* Denorm or Zero */
310
+ if (mantissa != 0U) {
311
+ unsigned int msb;
312
+ exponent = 0x71U;
313
+ do {
314
+ msb = (mantissa & 0x400000U);
315
+ mantissa <<= 1U; /* normalize */
316
+ --exponent;
317
+ } while (msb == 0U);
318
+ mantissa &= 0x7fffffU; /* 1.mantissa is implicit */
319
+ }
320
+ } else {
321
+ exponent += 0x70U;
322
+ }
323
+ const unsigned int u = ((sign << 31U) | (exponent << 23U) | mantissa);
324
+ #if defined(__CUDACC__) || (!defined __cplusplus)
325
+ (void)memcpy(&f, &u, sizeof(u));
326
+ #else
327
+ (void)std::memcpy(&f, &u, sizeof(u));
328
+ #endif
329
+ #endif /* (defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 530) */
330
+ return f;
331
+ }
332
+
333
+ __CUDA_HOSTDEVICE_FP8_DECL__ float2
334
+ __internal_halfraw2_to_float2(const __half2_raw x) {
335
+ __half_raw raw;
336
+ float2 res;
337
+ raw.x = x.x;
338
+ res.x = __internal_halfraw_to_float(raw);
339
+ raw.x = x.y;
340
+ res.y = __internal_halfraw_to_float(raw);
341
+ return res;
342
+ }
343
+
344
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t
345
+ __nv_cvt_halfraw_to_fp8(const __half_raw x, const __nv_saturation_t saturate,
346
+ const __nv_fp8_interpretation_t fp8_interpretation) {
347
+ __nv_fp8_storage_t res = 0U;
348
+ #if (defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 890)
349
+ if (saturate == __NV_SATFINITE) {
350
+ unsigned int half2_storage = (unsigned int)(x.x);
351
+ __nv_fp8x2_storage_t tmp;
352
+ if (fp8_interpretation == __NV_E5M2) {
353
+ asm("{cvt.rn.satfinite.e5m2x2.f16x2 %0, %1;}\n"
354
+ : "=h"(tmp)
355
+ : "r"(half2_storage));
356
+ } else {
357
+ asm("{cvt.rn.satfinite.e4m3x2.f16x2 %0, %1;}\n"
358
+ : "=h"(tmp)
359
+ : "r"(half2_storage));
360
+ }
361
+ res = (__nv_fp8_storage_t)tmp;
362
+ } else
363
+ #endif
364
+ {
365
+ float fx = __internal_halfraw_to_float(x);
366
+ res = __nv_cvt_float_to_fp8(fx, saturate, fp8_interpretation);
367
+ }
368
+ return res;
369
+ }
370
+
371
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t __nv_cvt_halfraw2_to_fp8x2(
372
+ const __half2_raw x, const __nv_saturation_t saturate,
373
+ const __nv_fp8_interpretation_t fp8_interpretation) {
374
+ __nv_fp8x2_storage_t tmp;
375
+ #if (defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 890)
376
+ if (saturate == __NV_SATFINITE) {
377
+ unsigned int half2_storage;
378
+ (void)memcpy(&half2_storage, &x, sizeof(x));
379
+
380
+ if (fp8_interpretation == __NV_E5M2) {
381
+ asm("{cvt.rn.satfinite.e5m2x2.f16x2 %0, %1;}\n"
382
+ : "=h"(tmp)
383
+ : "r"(half2_storage));
384
+ } else {
385
+ asm("{cvt.rn.satfinite.e4m3x2.f16x2 %0, %1;}\n"
386
+ : "=h"(tmp)
387
+ : "r"(half2_storage));
388
+ }
389
+ } else
390
+ #endif
391
+ {
392
+ __half_raw raw;
393
+ raw.x = x.x;
394
+ __nv_fp8_storage_t lo =
395
+ __nv_cvt_halfraw_to_fp8(raw, saturate, fp8_interpretation);
396
+ raw.x = x.y;
397
+ __nv_fp8_storage_t hi =
398
+ __nv_cvt_halfraw_to_fp8(raw, saturate, fp8_interpretation);
399
+ tmp = hi;
400
+ tmp = (__nv_fp8x2_storage_t)(tmp << 8U);
401
+ tmp = (__nv_fp8x2_storage_t)(tmp | lo);
402
+ }
403
+ return tmp;
404
+ }
405
+
406
+ __CUDA_HOSTDEVICE_FP8_DECL__ float
407
+ __internal_bf16raw_to_float(const __nv_bfloat16_raw x) {
408
+ const unsigned int ux = ((unsigned int)x.x) << 16U;
409
+ float fx;
410
+ #if defined(__CUDACC__) || (!defined __cplusplus)
411
+ (void)memcpy(&fx, &ux, sizeof(ux));
412
+ #else
413
+ (void)std::memcpy(&fx, &ux, sizeof(ux));
414
+ #endif
415
+ return fx;
416
+ }
417
+
418
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_bfloat16_raw
419
+ __internal_float_to_bf16raw_rz(const float x) {
420
+ unsigned int ux;
421
+ __nv_bfloat16_raw r;
422
+ #if defined(__CUDACC__) || (!defined __cplusplus)
423
+ (void)memcpy(&ux, &x, sizeof(x));
424
+ #else
425
+ (void)std::memcpy(&ux, &x, sizeof(x));
426
+ #endif
427
+ r.x = (unsigned short int)(ux >> 16U);
428
+ return r;
429
+ }
430
+
431
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t __nv_cvt_bfloat16raw_to_fp8(
432
+ const __nv_bfloat16_raw x, const __nv_saturation_t saturate,
433
+ const __nv_fp8_interpretation_t fp8_interpretation) {
434
+ const float fx = __internal_bf16raw_to_float(x);
435
+ const __nv_fp8_storage_t res =
436
+ __nv_cvt_float_to_fp8(fx, saturate, fp8_interpretation);
437
+ return res;
438
+ }
439
+
440
+ __CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t
441
+ __nv_cvt_bfloat16raw2_to_fp8x2(
442
+ const __nv_bfloat162_raw x, const __nv_saturation_t saturate,
443
+ const __nv_fp8_interpretation_t fp8_interpretation) {
444
+ __nv_bfloat16_raw raw;
445
+ raw.x = x.y;
446
+ __nv_fp8x2_storage_t storage =
447
+ (__nv_fp8x2_storage_t)__nv_cvt_bfloat16raw_to_fp8(raw, saturate,
448
+ fp8_interpretation);
449
+ storage = (__nv_fp8x2_storage_t)(storage << 8U);
450
+ raw.x = x.x;
451
+ storage = (__nv_fp8x2_storage_t)(storage |
452
+ __nv_cvt_bfloat16raw_to_fp8(
453
+ raw, saturate, fp8_interpretation));
454
+ return storage;
455
+ }
456
+
457
+ __CUDA_HOSTDEVICE_FP8_DECL__ __half2_raw
458
+ __nv_cvt_fp8x2_to_halfraw2(const __nv_fp8x2_storage_t x,
459
+ const __nv_fp8_interpretation_t fp8_interpretation);
460
+ __CUDA_HOSTDEVICE_FP8_DECL__ __half_raw
461
+ __nv_cvt_fp8_to_halfraw(const __nv_fp8_storage_t x,
462
+ const __nv_fp8_interpretation_t fp8_interpretation) {
463
+ __half_raw res;
464
+ res.x = 0U;
465
+ #if (defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 890)
466
+ res.x =
467
+ __nv_cvt_fp8x2_to_halfraw2((__nv_fp8x2_storage_t)x, fp8_interpretation)
468
+ .x;
469
+ #else
470
+ unsigned short int ur = (unsigned short int)x;
471
+ ur = (unsigned short int)(ur << 8U);
472
+
473
+ if (fp8_interpretation == __NV_E5M2) {
474
+ if ((ur & 0x7FFFU) > 0x7C00U) {
475
+ /* If NaN, return canonical NaN */
476
+ ur = 0x7FFFU;
477
+ }
478
+ } else { // __NV_E4M3
479
+ unsigned short int sign = ur & 0x8000U;
480
+ unsigned short int exponent =
481
+ (unsigned short int)(((ur & 0x7800U) >> 1U) + 0x2000U);
482
+ unsigned short int mantissa = (ur & 0x0700U) >> 1U;
483
+ unsigned char absx = 0x7FU & (unsigned char)x;
484
+
485
+ if (absx == 0x7FU) // NaN
486
+ {
487
+ ur = 0x7FFFU; // fp16 canonical NaN, discard sign
488
+ } else if (exponent == 0x2000U) {
489
+ // zero or denormal
490
+ if (mantissa != 0U) {
491
+ // normalize
492
+ mantissa = (unsigned short int)(mantissa << 1U);
493
+ while ((mantissa & 0x0400U) == 0U) {
494
+ mantissa = (unsigned short int)(mantissa << 1U);
495
+ exponent = (unsigned short int)(exponent - 0x0400U);
496
+ }
497
+ // discard implicit leading bit
498
+ mantissa &= 0x03FFU;
499
+ } else { // Zero
500
+ exponent = 0U;
501
+ }
502
+
503
+ ur = (sign | exponent) | mantissa;
504
+ } else {
505
+ ur = (sign | exponent) | mantissa;
506
+ }
507
+ }
508
+ res.x = ur;
509
+ #endif
510
+ return res;
511
+ }
512
+
513
+ __CUDA_HOSTDEVICE_FP8_DECL__ __half2_raw
514
+ __nv_cvt_fp8x2_to_halfraw2(const __nv_fp8x2_storage_t x,
515
+ const __nv_fp8_interpretation_t fp8_interpretation) {
516
+ __half2_raw res;
517
+ #if (defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 890)
518
+ unsigned int half2_storage;
519
+ if (fp8_interpretation == __NV_E5M2) {
520
+ asm("{cvt.rn.f16x2.e5m2x2 %0, %1;}\n" : "=r"(half2_storage) : "h"(x));
521
+ } else {
522
+ asm("{cvt.rn.f16x2.e4m3x2 %0, %1;}\n" : "=r"(half2_storage) : "h"(x));
523
+ }
524
+ (void)memcpy(&res, &half2_storage, sizeof(half2_storage));
525
+ #else
526
+ res.x =
527
+ __nv_cvt_fp8_to_halfraw((__nv_fp8_storage_t)x, fp8_interpretation).x;
528
+ res.y = __nv_cvt_fp8_to_halfraw((__nv_fp8_storage_t)(x >> 8U),
529
+ fp8_interpretation)
530
+ .x;
531
+ #endif
532
+ return res;
533
+ }
534
+
535
+ /* All other definitions in this file are only visible to C++ compilers */
536
+ #if defined(__cplusplus)
537
+
538
+ /**
539
+ * \defgroup CUDA_MATH_FP8_E5M2_STRUCT C++ struct for handling fp8 data type of e5m2 kind.
540
+ * \ingroup CUDA_MATH_INTRINSIC_FP8
541
+ */
542
+
543
+ /**
544
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
545
+ * \brief __nv_fp8_e5m2 datatype
546
+ *
547
+ * \details This structure implements the datatype for handling
548
+ * \p fp8 floating-point numbers of \p e5m2 kind:
549
+ * with 1 sign, 5 exponent, 1 implicit and 2 explicit mantissa bits.
550
+ *
551
+ * The structure implements converting constructors and operators.
552
+ */
553
+ struct __CUDA_ALIGN__(1) __nv_fp8_e5m2 {
554
+ public:
555
+ /**
556
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
557
+ * Storage variable contains the \p fp8 floating-point data.
558
+ */
559
+ __nv_fp8_storage_t __x;
560
+
561
+ /**
562
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
563
+ * Constructor by default.
564
+ */
565
+ #if defined(__CPP_VERSION_AT_LEAST_11_FP8)
566
+ __nv_fp8_e5m2() = default;
567
+ #else
568
+ __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e5m2() {}
569
+ #endif /* defined(__CPP_VERSION_AT_LEAST_11_FP8) */
570
+
571
+ #if !defined(__CUDA_NO_FP8_CONVERSIONS__)
572
+
573
+ /* Construct from wider FP types */
574
+ /* Note we do avoid constructor init-list because of special host/device
575
+ * compilation rules */
576
+
577
+ /**
578
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
579
+ * Constructor from \p __half data type, relies on \p __NV_SATFINITE
580
+ * behavior for out-of-range values.
581
+ */
582
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e5m2(const __half f) {
583
+ __x = __nv_cvt_halfraw_to_fp8(static_cast<__half_raw>(f),
584
+ __NV_SATFINITE, __NV_E5M2);
585
+ }
586
+ /**
587
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
588
+ * Constructor from \p __nv_bfloat16 data type, relies on \p __NV_SATFINITE
589
+ * behavior for out-of-range values.
590
+ */
591
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e5m2(const __nv_bfloat16 f) {
592
+ __x = __nv_cvt_bfloat16raw_to_fp8(static_cast<__nv_bfloat16_raw>(f),
593
+ __NV_SATFINITE, __NV_E5M2);
594
+ }
595
+ /**
596
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
597
+ * Constructor from \p float data type, relies on \p __NV_SATFINITE behavior
598
+ * for out-of-range values.
599
+ */
600
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e5m2(const float f) {
601
+ __x = __nv_cvt_float_to_fp8(f, __NV_SATFINITE, __NV_E5M2);
602
+ }
603
+ /**
604
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
605
+ * Constructor from \p double data type, relies on \p __NV_SATFINITE
606
+ * behavior for out-of-range values.
607
+ */
608
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e5m2(const double f) {
609
+ __x = __nv_cvt_double_to_fp8(f, __NV_SATFINITE, __NV_E5M2);
610
+ }
611
+
612
+ /* Converts from integral */
613
+
614
+ /**
615
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
616
+ * Constructor from \p unsigned \p short \p int data type, relies on \p
617
+ * __NV_SATFINITE behavior for out-of-range values.
618
+ */
619
+ explicit __CUDA_HOSTDEVICE_FP8__
620
+ __nv_fp8_e5m2(const unsigned short int val) {
621
+ __x = static_cast<__nv_fp8_e5m2>(static_cast<float>(val)).__x;
622
+ }
623
+ /**
624
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
625
+ * Constructor from \p unsigned \p int data type, relies on \p
626
+ * __NV_SATFINITE behavior for out-of-range values.
627
+ */
628
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e5m2(const unsigned int val) {
629
+ __x = static_cast<__nv_fp8_e5m2>(static_cast<float>(val)).__x;
630
+ }
631
+ /**
632
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
633
+ * Constructor from \p unsigned \p long \p int data type, relies on \p
634
+ * __NV_SATFINITE behavior for out-of-range values.
635
+ */
636
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e5m2(const unsigned long int val) {
637
+ __x = static_cast<__nv_fp8_e5m2>(static_cast<float>(val)).__x;
638
+ }
639
+ /**
640
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
641
+ * Constructor from \p unsigned \p long \p long \p int data type, relies on
642
+ * \p __NV_SATFINITE behavior for out-of-range values.
643
+ */
644
+ explicit __CUDA_HOSTDEVICE_FP8__
645
+ __nv_fp8_e5m2(const unsigned long long int val) {
646
+ __x = static_cast<__nv_fp8_e5m2>(static_cast<float>(val)).__x;
647
+ }
648
+
649
+ /**
650
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
651
+ * Constructor from \p short \p int data type.
652
+ */
653
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e5m2(const short int val) {
654
+ __x = static_cast<__nv_fp8_e5m2>(static_cast<float>(val)).__x;
655
+ }
656
+ /**
657
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
658
+ * Constructor from \p int data type, relies on \p __NV_SATFINITE behavior
659
+ * for out-of-range values.
660
+ */
661
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e5m2(const int val) {
662
+ __x = static_cast<__nv_fp8_e5m2>(static_cast<float>(val)).__x;
663
+ }
664
+ /**
665
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
666
+ * Constructor from \p long \p int data type, relies on \p __NV_SATFINITE behavior
667
+ * for out-of-range values.
668
+ */
669
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e5m2(const long int val) {
670
+ __x = static_cast<__nv_fp8_e5m2>(static_cast<float>(val)).__x;
671
+ }
672
+ /**
673
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
674
+ * Constructor from \p long \p long \p int data type, relies on \p
675
+ * __NV_SATFINITE behavior for out-of-range values.
676
+ */
677
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e5m2(const long long int val) {
678
+ __x = static_cast<__nv_fp8_e5m2>(static_cast<float>(val)).__x;
679
+ }
680
+
681
+ #if !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__)
682
+ /* Widening FP converts */
683
+ /**
684
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
685
+ * Conversion operator to \p __half data type.
686
+ */
687
+ explicit __CUDA_HOSTDEVICE_FP8__ operator __half() const {
688
+ return static_cast<__half>(__nv_cvt_fp8_to_halfraw(__x, __NV_E5M2));
689
+ }
690
+ /**
691
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
692
+ * Conversion operator to \p float data type.
693
+ */
694
+ explicit __CUDA_HOSTDEVICE_FP8__ operator float() const {
695
+ return __internal_halfraw_to_float(
696
+ __nv_cvt_fp8_to_halfraw(__x, __NV_E5M2));
697
+ }
698
+ /**
699
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
700
+ * Conversion operator to \p __nv_bfloat16 data type.
701
+ */
702
+ explicit __CUDA_HOSTDEVICE_FP8__ operator __nv_bfloat16() const {
703
+ return static_cast<__nv_bfloat16>(
704
+ __internal_float_to_bf16raw_rz(float(*this)));
705
+ }
706
+ /**
707
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
708
+ * Conversion operator to \p double data type.
709
+ */
710
+ explicit __CUDA_HOSTDEVICE_FP8__ operator double() const {
711
+ return static_cast<double>(float(*this));
712
+ }
713
+
714
+ /* Convert to integral */
715
+
716
+ /**
717
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
718
+ * Conversion operator to \p unsigned \p char data type.
719
+ * Clamps negative and too large inputs to the output range.
720
+ * \p NaN inputs convert to \p zero.
721
+ */
722
+ explicit __CUDA_HOSTDEVICE_FP8__ operator unsigned char() const {
723
+ unsigned char i;
724
+ const float f = float(*this);
725
+ const unsigned char max_val = 0xFFU;
726
+ const unsigned char min_val = 0U;
727
+ const unsigned char bits = (*this).__x;
728
+ // saturation fixup
729
+ if ((bits & 0x7FU) > 0x7CU) {
730
+ // NaN
731
+ i = 0;
732
+ } else if (f > static_cast<float>(max_val)) {
733
+ // saturate maximum
734
+ i = max_val;
735
+ } else if (f < static_cast<float>(min_val)) {
736
+ // saturate minimum
737
+ i = min_val;
738
+ } else {
739
+ // normal value
740
+ i = static_cast<unsigned char>(f);
741
+ }
742
+ return i;
743
+ }
744
+ /**
745
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
746
+ * Conversion operator to \p unsigned \p short \p int data type.
747
+ * Clamps negative and too large inputs to the output range.
748
+ * \p NaN inputs convert to \p zero.
749
+ */
750
+ explicit __CUDA_HOSTDEVICE_FP8__ operator unsigned short int() const {
751
+ return __half2ushort_rz(__half(*this));
752
+ }
753
+ /**
754
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
755
+ * Conversion operator to \p unsigned \p int data type.
756
+ * Clamps negative and too large inputs to the output range.
757
+ * \p NaN inputs convert to \p zero.
758
+ */
759
+ explicit __CUDA_HOSTDEVICE_FP8__ operator unsigned int() const {
760
+ return __half2uint_rz(__half(*this));
761
+ }
762
+ /**
763
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
764
+ * Conversion operator to \p unsigned \p long \p int data type.
765
+ * Clamps negative and too large inputs to the output range.
766
+ * \p NaN inputs convert to \p zero if output type is 32-bit.
767
+ * \p NaN inputs convert to \p 0x8000000000000000ULL if output type is 64-bit.
768
+ */
769
+ explicit __CUDA_HOSTDEVICE_FP8__ operator unsigned long int() const {
770
+ unsigned long retval;
771
+ /* Suppress VS warning: warning C4127: conditional expression is constant */
772
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
773
+ #pragma warning (push)
774
+ #pragma warning (disable: 4127)
775
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
776
+ if (sizeof(unsigned long) == sizeof(unsigned long long))
777
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
778
+ #pragma warning (pop)
779
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
780
+ {
781
+ retval = static_cast<unsigned long>(__half2ull_rz(__half(*this)));
782
+ }
783
+ else
784
+ {
785
+ retval = static_cast<unsigned long>(__half2uint_rz(__half(*this)));
786
+ }
787
+ return retval;
788
+ }
789
+ /**
790
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
791
+ * Conversion operator to \p unsigned \p long \p long \p int data type.
792
+ * Clamps negative and too large inputs to the output range.
793
+ * \p NaN inputs convert to \p 0x8000000000000000ULL.
794
+ */
795
+ explicit __CUDA_HOSTDEVICE_FP8__ operator unsigned long long int() const {
796
+ return __half2ull_rz(__half(*this));
797
+ }
798
+
799
+ /**
800
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
801
+ * Conversion operator to \p signed \p char data type.
802
+ * Clamps too large inputs to the output range.
803
+ * \p NaN inputs convert to \p zero.
804
+ */
805
+ explicit __CUDA_HOSTDEVICE_FP8__ operator signed char() const {
806
+ signed char i;
807
+ const float f = float(*this);
808
+ const signed char max_val = (signed char)0x7FU;
809
+ const signed char min_val = (signed char)0x80U;
810
+ const unsigned char bits = (*this).__x;
811
+ // saturation fixup
812
+ if ((bits & 0x7FU) > 0x7CU) {
813
+ // NaN
814
+ i = 0;
815
+ } else if (f > static_cast<float>(max_val)) {
816
+ // saturate maximum
817
+ i = max_val;
818
+ } else if (f < static_cast<float>(min_val)) {
819
+ // saturate minimum
820
+ i = min_val;
821
+ } else {
822
+ // normal value
823
+ i = static_cast<signed char>(f);
824
+ }
825
+ return i;
826
+ }
827
+
828
+ /**
829
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
830
+ * Conversion operator to an implementation defined \p char data type.
831
+ *
832
+ * Detects signedness of the \p char type and proceeds accordingly, see
833
+ * further details in signed and unsigned char operators.
834
+
835
+ * Clamps inputs to the output range.
836
+ * \p NaN inputs convert to \p zero.
837
+ */
838
+ explicit __CUDA_HOSTDEVICE_FP8__ operator char() const {
839
+ char value;
840
+ /* Suppress VS warning: warning C4127: conditional expression is constant */
841
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
842
+ #pragma warning (push)
843
+ #pragma warning (disable: 4127)
844
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
845
+ if (((char)-1) < (char)0)
846
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
847
+ #pragma warning (pop)
848
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
849
+ {
850
+ value = static_cast<char>(static_cast<signed char>(*this));
851
+ }
852
+ else
853
+ {
854
+ value = static_cast<char>(static_cast<unsigned char>(*this));
855
+ }
856
+ return value;
857
+ }
858
+
859
+ /**
860
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
861
+ * Conversion operator to \p short \p int data type.
862
+ * Clamps too large inputs to the output range.
863
+ * \p NaN inputs convert to \p zero.
864
+ */
865
+ explicit __CUDA_HOSTDEVICE_FP8__ operator short int() const {
866
+ return __half2short_rz(__half(*this));
867
+ }
868
+ /**
869
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
870
+ * Conversion operator to \p int data type.
871
+ * Clamps too large inputs to the output range.
872
+ * \p NaN inputs convert to \p zero.
873
+ */
874
+ explicit __CUDA_HOSTDEVICE_FP8__ operator int() const {
875
+ return __half2int_rz(__half(*this));
876
+ }
877
+ /**
878
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
879
+ * Conversion operator to \p long \p int data type.
880
+ * Clamps too large inputs to the output range.
881
+ * \p NaN inputs convert to \p zero if output type is 32-bit.
882
+ * \p NaN inputs convert to \p 0x8000000000000000ULL if output type is 64-bit.
883
+ */
884
+ explicit __CUDA_HOSTDEVICE_FP8__ operator long int() const {
885
+ long retval;
886
+ /* Suppress VS warning: warning C4127: conditional expression is constant */
887
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
888
+ #pragma warning (push)
889
+ #pragma warning (disable: 4127)
890
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
891
+ if (sizeof(long) == sizeof(long long))
892
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
893
+ #pragma warning (pop)
894
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
895
+ {
896
+ retval = static_cast<long>(__half2ll_rz(__half(*this)));
897
+ }
898
+ else
899
+ {
900
+ retval = static_cast<long>(__half2int_rz(__half(*this)));
901
+ }
902
+ return retval;
903
+ }
904
+ /**
905
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
906
+ * Conversion operator to \p long \p long \p int data type.
907
+ * Clamps too large inputs to the output range.
908
+ * \p NaN inputs convert to \p 0x8000000000000000LL.
909
+ */
910
+ explicit __CUDA_HOSTDEVICE_FP8__ operator long long int() const {
911
+ return __half2ll_rz(__half(*this));
912
+ }
913
+
914
+ /**
915
+ * \ingroup CUDA_MATH_FP8_E5M2_STRUCT
916
+ * Conversion operator to \p bool data type.
917
+ * +0 and -0 inputs convert to \p false.
918
+ * Non-zero inputs convert to \p true.
919
+ */
920
+ explicit __CUDA_HOSTDEVICE_FP8__ operator bool() const {
921
+ return (__x & 0x7FU) != 0U;
922
+ }
923
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__) */
924
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSIONS__) */
925
+ };
926
+
927
+ /**
928
+ * \defgroup CUDA_MATH_FP8X2_E5M2_STRUCT C++ struct for handling vector type of two fp8 values of e5m2 kind.
929
+ * \ingroup CUDA_MATH_INTRINSIC_FP8
930
+ */
931
+
932
+ /**
933
+ * \ingroup CUDA_MATH_FP8X2_E5M2_STRUCT
934
+ * \brief __nv_fp8x2_e5m2 datatype
935
+ *
936
+ * \details This structure implements the datatype for handling two
937
+ * \p fp8 floating-point numbers of \p e5m2 kind each:
938
+ * with 1 sign, 5 exponent, 1 implicit and 2 explicit mantissa bits.
939
+ *
940
+ * The structure implements converting constructors and operators.
941
+ */
942
+ struct __CUDA_ALIGN__(2) __nv_fp8x2_e5m2 {
943
+ public:
944
+ /**
945
+ * \ingroup CUDA_MATH_FP8X2_E5M2_STRUCT
946
+ * Storage variable contains the vector of two \p fp8 floating-point data
947
+ * values.
948
+ */
949
+ __nv_fp8x2_storage_t __x;
950
+
951
+ /**
952
+ * \ingroup CUDA_MATH_FP8X2_E5M2_STRUCT
953
+ * Constructor by default.
954
+ */
955
+ #if defined(__CPP_VERSION_AT_LEAST_11_FP8)
956
+ __nv_fp8x2_e5m2() = default;
957
+ #else
958
+ __CUDA_HOSTDEVICE_FP8__ __nv_fp8x2_e5m2() {}
959
+ #endif /* defined(__CPP_VERSION_AT_LEAST_11_FP8) */
960
+
961
+ #if !defined(__CUDA_NO_FP8_CONVERSIONS__)
962
+
963
+ /* Construct from wider types */
964
+
965
+ /**
966
+ * \ingroup CUDA_MATH_FP8X2_E5M2_STRUCT
967
+ * Constructor from \p __half2 data type, relies on \p __NV_SATFINITE
968
+ * behavior for out-of-range values.
969
+ */
970
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x2_e5m2(const __half2 f) {
971
+ __x = __nv_cvt_halfraw2_to_fp8x2(static_cast<__half2_raw>(f),
972
+ __NV_SATFINITE, __NV_E5M2);
973
+ }
974
+ /**
975
+ * \ingroup CUDA_MATH_FP8X2_E5M2_STRUCT
976
+ * Constructor from \p __nv_bfloat162 data type, relies on \p __NV_SATFINITE
977
+ * behavior for out-of-range values.
978
+ */
979
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x2_e5m2(const __nv_bfloat162 f) {
980
+ __x = __nv_cvt_bfloat16raw2_to_fp8x2(static_cast<__nv_bfloat162_raw>(f),
981
+ __NV_SATFINITE, __NV_E5M2);
982
+ }
983
+ /**
984
+ * \ingroup CUDA_MATH_FP8X2_E5M2_STRUCT
985
+ * Constructor from \p float2 data type, relies on \p __NV_SATFINITE
986
+ * behavior for out-of-range values.
987
+ */
988
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x2_e5m2(const float2 f) {
989
+ __x = __nv_cvt_float2_to_fp8x2(f, __NV_SATFINITE, __NV_E5M2);
990
+ }
991
+ /**
992
+ * \ingroup CUDA_MATH_FP8X2_E5M2_STRUCT
993
+ * Constructor from \p double2 data type, relies on \p __NV_SATFINITE
994
+ * behavior for out-of-range values.
995
+ */
996
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x2_e5m2(const double2 f) {
997
+ __x = __nv_cvt_double2_to_fp8x2(f, __NV_SATFINITE, __NV_E5M2);
998
+ }
999
+
1000
+ #if !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__)
1001
+ /* Widening converts */
1002
+ /**
1003
+ * \ingroup CUDA_MATH_FP8X2_E5M2_STRUCT
1004
+ * Conversion operator to \p __half2 data type.
1005
+ */
1006
+ explicit __CUDA_HOSTDEVICE_FP8__ operator __half2() const {
1007
+ return static_cast<__half2>(__nv_cvt_fp8x2_to_halfraw2(__x, __NV_E5M2));
1008
+ }
1009
+ /**
1010
+ * \ingroup CUDA_MATH_FP8X2_E5M2_STRUCT
1011
+ * Conversion operator to \p float2 data type.
1012
+ */
1013
+ explicit __CUDA_HOSTDEVICE_FP8__ operator float2() const {
1014
+ return __internal_halfraw2_to_float2(
1015
+ __nv_cvt_fp8x2_to_halfraw2(__x, __NV_E5M2));
1016
+ }
1017
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__) */
1018
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSIONS__) */
1019
+ };
1020
+
1021
+ __CUDA_HOSTDEVICE_FP8_DECL__ unsigned int
1022
+ __internal_pack_u16x2_to_u32(const unsigned short int src_lo,
1023
+ const unsigned short int src_hi) {
1024
+ unsigned int dst;
1025
+ #if (defined __CUDACC__) && (defined __CUDA_ARCH__)
1026
+ asm("{ mov.b32 %0, {%1,%2};}\n" : "=r"(dst) : "h"(src_lo), "h"(src_hi));
1027
+ #else
1028
+ dst = (static_cast<unsigned int>(src_hi) << 16U) |
1029
+ static_cast<unsigned int>(src_lo);
1030
+ #endif
1031
+ return dst;
1032
+ }
1033
+
1034
+ /**
1035
+ * \defgroup CUDA_MATH_FP8X4_E5M2_STRUCT C++ struct for handling vector type of four fp8 values of e5m2 kind.
1036
+ * \ingroup CUDA_MATH_INTRINSIC_FP8
1037
+ */
1038
+
1039
+ /**
1040
+ * \ingroup CUDA_MATH_FP8X4_E5M2_STRUCT
1041
+ * \brief __nv_fp8x4_e5m2 datatype
1042
+ *
1043
+ * \details This structure implements the datatype for handling four
1044
+ * \p fp8 floating-point numbers of \p e5m2 kind each:
1045
+ * with 1 sign, 5 exponent, 1 implicit and 2 explicit mantissa bits.
1046
+ *
1047
+ * The structure implements converting constructors and operators.
1048
+ */
1049
+ struct __CUDA_ALIGN__(4) __nv_fp8x4_e5m2 {
1050
+ public:
1051
+ /**
1052
+ * \ingroup CUDA_MATH_FP8X4_E5M2_STRUCT
1053
+ * Storage variable contains the vector of four \p fp8 floating-point data
1054
+ * values.
1055
+ */
1056
+ __nv_fp8x4_storage_t __x;
1057
+
1058
+ /**
1059
+ * \ingroup CUDA_MATH_FP8X4_E5M2_STRUCT
1060
+ * Constructor by default.
1061
+ */
1062
+ #if defined(__CPP_VERSION_AT_LEAST_11_FP8)
1063
+ __nv_fp8x4_e5m2() = default;
1064
+ #else
1065
+ __CUDA_HOSTDEVICE_FP8__ __nv_fp8x4_e5m2() {}
1066
+ #endif /* defined(__CPP_VERSION_AT_LEAST_11_FP8) */
1067
+
1068
+ #if !defined(__CUDA_NO_FP8_CONVERSIONS__)
1069
+
1070
+ /* Construct from wider types */
1071
+
1072
+ /**
1073
+ * \ingroup CUDA_MATH_FP8X4_E5M2_STRUCT
1074
+ * Constructor from a pair of \p __half2 data type values,
1075
+ * relies on \p __NV_SATFINITE behavior for out-of-range values.
1076
+ */
1077
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x4_e5m2(const __half2 flo,
1078
+ const __half2 fhi) {
1079
+ const __nv_fp8x2_storage_t rlo = __nv_cvt_halfraw2_to_fp8x2(
1080
+ static_cast<__half2_raw>(flo), __NV_SATFINITE, __NV_E5M2);
1081
+ const __nv_fp8x2_storage_t rhi = __nv_cvt_halfraw2_to_fp8x2(
1082
+ static_cast<__half2_raw>(fhi), __NV_SATFINITE, __NV_E5M2);
1083
+ __x = __internal_pack_u16x2_to_u32(rlo, rhi);
1084
+ }
1085
+ /**
1086
+ * \ingroup CUDA_MATH_FP8X4_E5M2_STRUCT
1087
+ * Constructor from a pair of \p __nv_bfloat162 data type values,
1088
+ * relies on \p __NV_SATFINITE behavior for out-of-range values.
1089
+ */
1090
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x4_e5m2(const __nv_bfloat162 flo,
1091
+ const __nv_bfloat162 fhi) {
1092
+ const __nv_fp8x2_storage_t rlo = __nv_cvt_bfloat16raw2_to_fp8x2(
1093
+ static_cast<__nv_bfloat162_raw>(flo), __NV_SATFINITE, __NV_E5M2);
1094
+ const __nv_fp8x2_storage_t rhi = __nv_cvt_bfloat16raw2_to_fp8x2(
1095
+ static_cast<__nv_bfloat162_raw>(fhi), __NV_SATFINITE, __NV_E5M2);
1096
+ __x = __internal_pack_u16x2_to_u32(rlo, rhi);
1097
+ }
1098
+ /**
1099
+ * \ingroup CUDA_MATH_FP8X4_E5M2_STRUCT
1100
+ * Constructor from \p float4 vector data type,
1101
+ * relies on \p __NV_SATFINITE behavior for out-of-range values.
1102
+ */
1103
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x4_e5m2(const float4 f) {
1104
+ const float2 flo = {f.x, f.y};
1105
+ const float2 fhi = {f.z, f.w};
1106
+ const __nv_fp8x2_storage_t rlo =
1107
+ __nv_cvt_float2_to_fp8x2(flo, __NV_SATFINITE, __NV_E5M2);
1108
+ const __nv_fp8x2_storage_t rhi =
1109
+ __nv_cvt_float2_to_fp8x2(fhi, __NV_SATFINITE, __NV_E5M2);
1110
+ __x = __internal_pack_u16x2_to_u32(rlo, rhi);
1111
+ }
1112
+ /**
1113
+ * \ingroup CUDA_MATH_FP8X4_E5M2_STRUCT
1114
+ * Constructor from \p double4 vector data type,
1115
+ * relies on \p __NV_SATFINITE behavior for out-of-range values.
1116
+ */
1117
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x4_e5m2(const double4 f) {
1118
+ const double2 flo = {f.x, f.y};
1119
+ const double2 fhi = {f.z, f.w};
1120
+ const __nv_fp8x2_storage_t rlo =
1121
+ __nv_cvt_double2_to_fp8x2(flo, __NV_SATFINITE, __NV_E5M2);
1122
+ const __nv_fp8x2_storage_t rhi =
1123
+ __nv_cvt_double2_to_fp8x2(fhi, __NV_SATFINITE, __NV_E5M2);
1124
+ __x = __internal_pack_u16x2_to_u32(rlo, rhi);
1125
+ }
1126
+
1127
+ #if !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__)
1128
+ /* Widening converts */
1129
+
1130
+ /**
1131
+ * \ingroup CUDA_MATH_FP8X4_E5M2_STRUCT
1132
+ * Conversion operator to \p float4 vector data type.
1133
+ */
1134
+ explicit __CUDA_HOSTDEVICE_FP8__ operator float4() const {
1135
+ const __nv_fp8x2_storage_t slo = static_cast<__nv_fp8x2_storage_t>(__x);
1136
+ const __nv_fp8x2_storage_t shi =
1137
+ static_cast<__nv_fp8x2_storage_t>(__x >> 16U);
1138
+ float2 rlo = __internal_halfraw2_to_float2(
1139
+ __nv_cvt_fp8x2_to_halfraw2(slo, __NV_E5M2));
1140
+ float2 rhi = __internal_halfraw2_to_float2(
1141
+ __nv_cvt_fp8x2_to_halfraw2(shi, __NV_E5M2));
1142
+ float4 res = {rlo.x, rlo.y, rhi.x, rhi.y};
1143
+ return res;
1144
+ }
1145
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__) */
1146
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSIONS__) */
1147
+ };
1148
+
1149
+ /**
1150
+ * \defgroup CUDA_MATH_FP8_E4M3_STRUCT C++ struct for handling fp8 data type of e4m3 kind.
1151
+ * \ingroup CUDA_MATH_INTRINSIC_FP8
1152
+ */
1153
+
1154
+ /**
1155
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1156
+ * \brief __nv_fp8_e4m3 datatype
1157
+ *
1158
+ * \details This structure implements the datatype for storing
1159
+ * \p fp8 floating-point numbers of \p e4m3 kind:
1160
+ * with 1 sign, 4 exponent, 1 implicit and 3 explicit mantissa bits.
1161
+ * The encoding doesn't support Infinity.
1162
+ * NaNs are limited to 0x7F and 0xFF values.
1163
+ *
1164
+ * The structure implements converting constructors and operators.
1165
+ */
1166
+ struct __CUDA_ALIGN__(1) __nv_fp8_e4m3 {
1167
+ public:
1168
+ /**
1169
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1170
+ * Storage variable contains the \p fp8 floating-point data.
1171
+ */
1172
+ __nv_fp8_storage_t __x;
1173
+
1174
+ /**
1175
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1176
+ * Constructor by default.
1177
+ */
1178
+ #if defined(__CPP_VERSION_AT_LEAST_11_FP8)
1179
+ __nv_fp8_e4m3() = default;
1180
+ #else
1181
+ __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e4m3() {}
1182
+ #endif /* defined(__CPP_VERSION_AT_LEAST_11_FP8) */
1183
+
1184
+ #if !defined(__CUDA_NO_FP8_CONVERSIONS__)
1185
+
1186
+ /* Construct from wider FP types */
1187
+ /* Note we do avoid constructor init-list because of special host/device
1188
+ * compilation rules */
1189
+
1190
+ /**
1191
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1192
+ * Constructor from \p __half data type, relies on \p __NV_SATFINITE
1193
+ * behavior for out-of-range values.
1194
+ */
1195
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e4m3(const __half f) {
1196
+ __x = __nv_cvt_halfraw_to_fp8(static_cast<__half_raw>(f),
1197
+ __NV_SATFINITE, __NV_E4M3);
1198
+ }
1199
+ /**
1200
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1201
+ * Constructor from \p __nv_bfloat16 data type, relies on \p __NV_SATFINITE
1202
+ * behavior for out-of-range values.
1203
+ */
1204
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e4m3(const __nv_bfloat16 f) {
1205
+ __x = __nv_cvt_bfloat16raw_to_fp8(static_cast<__nv_bfloat16_raw>(f),
1206
+ __NV_SATFINITE, __NV_E4M3);
1207
+ }
1208
+ /**
1209
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1210
+ * Constructor from \p float data type, relies on \p __NV_SATFINITE behavior
1211
+ * for out-of-range values.
1212
+ */
1213
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e4m3(const float f) {
1214
+ __x = __nv_cvt_float_to_fp8(f, __NV_SATFINITE, __NV_E4M3);
1215
+ }
1216
+ /**
1217
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1218
+ * Constructor from \p double data type, relies on \p __NV_SATFINITE
1219
+ * behavior for out-of-range values.
1220
+ */
1221
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e4m3(const double f) {
1222
+ __x = __nv_cvt_double_to_fp8(f, __NV_SATFINITE, __NV_E4M3);
1223
+ }
1224
+
1225
+ /* Converts from integral */
1226
+
1227
+ /**
1228
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1229
+ * Constructor from \p unsigned \p short \p int data type, relies on \p
1230
+ * __NV_SATFINITE behavior for out-of-range values.
1231
+ */
1232
+ explicit __CUDA_HOSTDEVICE_FP8__
1233
+ __nv_fp8_e4m3(const unsigned short int val) {
1234
+ __x = static_cast<__nv_fp8_e4m3>(static_cast<float>(val)).__x;
1235
+ }
1236
+ /**
1237
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1238
+ * Constructor from \p unsigned \p int data type, relies on \p
1239
+ * __NV_SATFINITE behavior for out-of-range values.
1240
+ */
1241
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e4m3(const unsigned int val) {
1242
+ __x = static_cast<__nv_fp8_e4m3>(static_cast<float>(val)).__x;
1243
+ }
1244
+ /**
1245
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1246
+ * Constructor from \p unsigned \p long \p int data type, relies on \p
1247
+ * __NV_SATFINITE behavior for out-of-range values.
1248
+ */
1249
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e4m3(const unsigned long int val) {
1250
+ __x = static_cast<__nv_fp8_e4m3>(static_cast<float>(val)).__x;
1251
+ }
1252
+ /**
1253
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1254
+ * Constructor from \p unsigned \p long \p long \p int data type, relies on
1255
+ * \p __NV_SATFINITE behavior for out-of-range values.
1256
+ */
1257
+ explicit __CUDA_HOSTDEVICE_FP8__
1258
+ __nv_fp8_e4m3(const unsigned long long int val) {
1259
+ __x = static_cast<__nv_fp8_e4m3>(static_cast<float>(val)).__x;
1260
+ }
1261
+
1262
+ /**
1263
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1264
+ * Constructor from \p short \p int data type, relies on \p
1265
+ * __NV_SATFINITE behavior for out-of-range values.
1266
+ */
1267
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e4m3(const short int val) {
1268
+ __x = static_cast<__nv_fp8_e4m3>(static_cast<float>(val)).__x;
1269
+ }
1270
+ /**
1271
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1272
+ * Constructor from \p int data type, relies on \p __NV_SATFINITE behavior
1273
+ * for out-of-range values.
1274
+ */
1275
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e4m3(const int val) {
1276
+ __x = static_cast<__nv_fp8_e4m3>(static_cast<float>(val)).__x;
1277
+ }
1278
+ /**
1279
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1280
+ * Constructor from \p long \p int data type, relies on \p
1281
+ * __NV_SATFINITE behavior for out-of-range values.
1282
+ */
1283
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e4m3(const long int val) {
1284
+ __x = static_cast<__nv_fp8_e4m3>(static_cast<float>(val)).__x;
1285
+ }
1286
+ /**
1287
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1288
+ * Constructor from \p long \p long \p int data type, relies on \p
1289
+ * __NV_SATFINITE behavior for out-of-range values.
1290
+ */
1291
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8_e4m3(const long long int val) {
1292
+ __x = static_cast<__nv_fp8_e4m3>(static_cast<float>(val)).__x;
1293
+ }
1294
+
1295
+ #if !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__)
1296
+ /* Widening FP converts */
1297
+ /**
1298
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1299
+ * Conversion operator to \p __half data type.
1300
+ */
1301
+ explicit __CUDA_HOSTDEVICE_FP8__ operator __half() const {
1302
+ return static_cast<__half>(__nv_cvt_fp8_to_halfraw(__x, __NV_E4M3));
1303
+ }
1304
+ /**
1305
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1306
+ * Conversion operator to \p float data type.
1307
+ */
1308
+ explicit __CUDA_HOSTDEVICE_FP8__ operator float() const {
1309
+ return __internal_halfraw_to_float(
1310
+ __nv_cvt_fp8_to_halfraw(__x, __NV_E4M3));
1311
+ }
1312
+ /**
1313
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1314
+ * Conversion operator to \p __nv_bfloat16 data type.
1315
+ */
1316
+ explicit __CUDA_HOSTDEVICE_FP8__ operator __nv_bfloat16() const {
1317
+ return static_cast<__nv_bfloat16>(
1318
+ __internal_float_to_bf16raw_rz(float(*this)));
1319
+ }
1320
+ /**
1321
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1322
+ * Conversion operator to \p double data type.
1323
+ */
1324
+ explicit __CUDA_HOSTDEVICE_FP8__ operator double() const {
1325
+ return static_cast<double>(float(*this));
1326
+ }
1327
+
1328
+ /* Convert to integral */
1329
+
1330
+ /**
1331
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1332
+ * Conversion operator to \p unsigned \p char data type.
1333
+ * Clamps negative and too large inputs to the output range.
1334
+ * \p NaN inputs convert to \p zero.
1335
+ */
1336
+ explicit __CUDA_HOSTDEVICE_FP8__ operator unsigned char() const {
1337
+ unsigned char i;
1338
+ const float f = float(*this);
1339
+ const unsigned char max_val = 0xFFU;
1340
+ const unsigned char min_val = 0U;
1341
+ const unsigned char bits = (*this).__x;
1342
+ // saturation fixup
1343
+ if ((bits & 0x7FU) == 0x7FU) {
1344
+ // NaN
1345
+ i = 0;
1346
+ } else if (f > static_cast<float>(max_val)) {
1347
+ // saturate maximum
1348
+ i = max_val;
1349
+ } else if (f < static_cast<float>(min_val)) {
1350
+ // saturate minimum
1351
+ i = min_val;
1352
+ } else {
1353
+ // normal value
1354
+ i = static_cast<unsigned char>(f);
1355
+ }
1356
+ return i;
1357
+ }
1358
+
1359
+ /**
1360
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1361
+ * Conversion operator to \p unsigned \p short \p int data type.
1362
+ * Clamps negative inputs to zero.
1363
+ * \p NaN inputs convert to \p zero.
1364
+ */
1365
+ explicit __CUDA_HOSTDEVICE_FP8__ operator unsigned short int() const {
1366
+ return __half2ushort_rz(__half(*this));
1367
+ }
1368
+ /**
1369
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1370
+ * Conversion operator to \p unsigned \p int data type.
1371
+ * Clamps negative inputs to zero.
1372
+ * \p NaN inputs convert to \p zero.
1373
+ */
1374
+ explicit __CUDA_HOSTDEVICE_FP8__ operator unsigned int() const {
1375
+ return __half2uint_rz(__half(*this));
1376
+ }
1377
+ /**
1378
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1379
+ * Conversion operator to \p unsigned \p long \p int data type.
1380
+ * Clamps negative and too large inputs to the output range.
1381
+ * \p NaN inputs convert to \p zero if output type is 32-bit.
1382
+ * \p NaN inputs convert to \p 0x8000000000000000ULL if output type is 64-bit.
1383
+ */
1384
+ explicit __CUDA_HOSTDEVICE_FP8__ operator unsigned long int() const {
1385
+ unsigned long retval;
1386
+ /* Suppress VS warning: warning C4127: conditional expression is constant */
1387
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
1388
+ #pragma warning (push)
1389
+ #pragma warning (disable: 4127)
1390
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
1391
+ if (sizeof(unsigned long) == sizeof(unsigned long long))
1392
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
1393
+ #pragma warning (pop)
1394
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
1395
+ {
1396
+ retval = static_cast<unsigned long>(__half2ull_rz(__half(*this)));
1397
+ }
1398
+ else
1399
+ {
1400
+ retval = static_cast<unsigned long>(__half2uint_rz(__half(*this)));
1401
+ }
1402
+ return retval;
1403
+ }
1404
+ /**
1405
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1406
+ * Conversion operator to \p unsigned \p long \p long \p int data type.
1407
+ * Clamps negative inputs to zero.
1408
+ * \p NaN inputs convert to \p 0x8000000000000000ULL.
1409
+ */
1410
+ explicit __CUDA_HOSTDEVICE_FP8__ operator unsigned long long int() const {
1411
+ return __half2ull_rz(__half(*this));
1412
+ }
1413
+
1414
+ /**
1415
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1416
+ * Conversion operator to \p signed \p char data type.
1417
+ * Clamps too large inputs to the output range.
1418
+ * \p NaN inputs convert to \p zero.
1419
+ */
1420
+ explicit __CUDA_HOSTDEVICE_FP8__ operator signed char() const {
1421
+ signed char i;
1422
+ const float f = float(*this);
1423
+ const signed char max_val = (signed char)0x7FU;
1424
+ const signed char min_val = (signed char)0x80U;
1425
+ const unsigned char bits = (*this).__x;
1426
+ // saturation fixup
1427
+ if ((bits & 0x7FU) == 0x7FU) {
1428
+ // NaN
1429
+ i = 0;
1430
+ } else if (f > static_cast<float>(max_val)) {
1431
+ // saturate maximum
1432
+ i = max_val;
1433
+ } else if (f < static_cast<float>(min_val)) {
1434
+ // saturate minimum
1435
+ i = min_val;
1436
+ } else {
1437
+ // normal value
1438
+ i = static_cast<signed char>(f);
1439
+ }
1440
+ return i;
1441
+ }
1442
+
1443
+ /**
1444
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1445
+ * Conversion operator to an implementation defined \p char data type.
1446
+ *
1447
+ * Detects signedness of the \p char type and proceeds accordingly, see
1448
+ * further details in signed and unsigned char operators.
1449
+
1450
+ * Clamps inputs to the output range.
1451
+ * \p NaN inputs convert to \p zero.
1452
+ */
1453
+ explicit __CUDA_HOSTDEVICE_FP8__ operator char() const {
1454
+ char value;
1455
+ /* Suppress VS warning: warning C4127: conditional expression is constant */
1456
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
1457
+ #pragma warning (push)
1458
+ #pragma warning (disable: 4127)
1459
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
1460
+ if (((char)-1) < (char)0)
1461
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
1462
+ #pragma warning (pop)
1463
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
1464
+ {
1465
+ value = static_cast<char>(static_cast<signed char>(*this));
1466
+ }
1467
+ else
1468
+ {
1469
+ value = static_cast<char>(static_cast<unsigned char>(*this));
1470
+ }
1471
+ return value;
1472
+ }
1473
+
1474
+ /**
1475
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1476
+ * Conversion operator to \p short \p int data type.
1477
+ * \p NaN inputs convert to \p zero.
1478
+ */
1479
+ explicit __CUDA_HOSTDEVICE_FP8__ operator short int() const {
1480
+ return __half2short_rz(__half(*this));
1481
+ }
1482
+ /**
1483
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1484
+ * Conversion operator to \p int data type.
1485
+ * \p NaN inputs convert to \p zero.
1486
+ */
1487
+ explicit __CUDA_HOSTDEVICE_FP8__ operator int() const {
1488
+ return __half2int_rz(__half(*this));
1489
+ }
1490
+ /**
1491
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1492
+ * Conversion operator to \p long \p int data type.
1493
+ * Clamps too large inputs to the output range.
1494
+ * \p NaN inputs convert to \p zero if output type is 32-bit.
1495
+ * \p NaN inputs convert to \p 0x8000000000000000ULL if output type is 64-bit.
1496
+ */
1497
+ explicit __CUDA_HOSTDEVICE_FP8__ operator long int() const {
1498
+ long retval;
1499
+ /* Suppress VS warning: warning C4127: conditional expression is constant */
1500
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
1501
+ #pragma warning (push)
1502
+ #pragma warning (disable: 4127)
1503
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
1504
+ if (sizeof(long) == sizeof(long long))
1505
+ #if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
1506
+ #pragma warning (pop)
1507
+ #endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
1508
+ {
1509
+ retval = static_cast<long>(__half2ll_rz(__half(*this)));
1510
+ }
1511
+ else
1512
+ {
1513
+ retval = static_cast<long>(__half2int_rz(__half(*this)));
1514
+ }
1515
+ return retval;
1516
+ }
1517
+ /**
1518
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1519
+ * Conversion operator to \p long \p long \p int data type.
1520
+ * \p NaN inputs convert to \p 0x8000000000000000LL.
1521
+ */
1522
+ explicit __CUDA_HOSTDEVICE_FP8__ operator long long int() const {
1523
+ return __half2ll_rz(__half(*this));
1524
+ }
1525
+
1526
+ /**
1527
+ * \ingroup CUDA_MATH_FP8_E4M3_STRUCT
1528
+ * Conversion operator to \p bool data type.
1529
+ * +0 and -0 inputs convert to \p false.
1530
+ * Non-zero inputs convert to \p true.
1531
+ */
1532
+ explicit __CUDA_HOSTDEVICE_FP8__ operator bool() const {
1533
+ return (__x & 0x7FU) != 0U;
1534
+ }
1535
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__) */
1536
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSIONS__) */
1537
+ };
1538
+
1539
+ /**
1540
+ * \defgroup CUDA_MATH_FP8X2_E4M3_STRUCT C++ struct for handling vector type of two fp8 values of e4m3 kind.
1541
+ * \ingroup CUDA_MATH_INTRINSIC_FP8
1542
+ */
1543
+
1544
+ /**
1545
+ * \ingroup CUDA_MATH_FP8X2_E4M3_STRUCT
1546
+ * \brief __nv_fp8x2_e4m3 datatype
1547
+ *
1548
+ * \details This structure implements the datatype for storage
1549
+ * and operations on the vector of two \p fp8 values of \p e4m3 kind each:
1550
+ * with 1 sign, 4 exponent, 1 implicit and 3 explicit mantissa bits.
1551
+ * The encoding doesn't support Infinity.
1552
+ * NaNs are limited to 0x7F and 0xFF values.
1553
+ */
1554
+ struct __CUDA_ALIGN__(2) __nv_fp8x2_e4m3 {
1555
+ public:
1556
+ /**
1557
+ * \ingroup CUDA_MATH_FP8X2_E4M3_STRUCT
1558
+ * Storage variable contains the vector of two \p fp8 floating-point data
1559
+ * values.
1560
+ */
1561
+ __nv_fp8x2_storage_t __x;
1562
+
1563
+ /**
1564
+ * \ingroup CUDA_MATH_FP8X2_E4M3_STRUCT
1565
+ * Constructor by default.
1566
+ */
1567
+ #if defined(__CPP_VERSION_AT_LEAST_11_FP8)
1568
+ __nv_fp8x2_e4m3() = default;
1569
+ #else
1570
+ __CUDA_HOSTDEVICE_FP8__ __nv_fp8x2_e4m3() {}
1571
+ #endif /* defined(__CPP_VERSION_AT_LEAST_11_FP8) */
1572
+
1573
+ #if !defined(__CUDA_NO_FP8_CONVERSIONS__)
1574
+
1575
+ /* Construct from wider types */
1576
+
1577
+ /**
1578
+ * \ingroup CUDA_MATH_FP8X2_E4M3_STRUCT
1579
+ * Constructor from \p __half2 data type, relies on \p __NV_SATFINITE
1580
+ * behavior for out-of-range values.
1581
+ */
1582
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x2_e4m3(const __half2 f) {
1583
+ __x = __nv_cvt_halfraw2_to_fp8x2(static_cast<__half2_raw>(f),
1584
+ __NV_SATFINITE, __NV_E4M3);
1585
+ }
1586
+ /**
1587
+ * \ingroup CUDA_MATH_FP8X2_E4M3_STRUCT
1588
+ * Constructor from \p __nv_bfloat162 data type, relies on \p __NV_SATFINITE
1589
+ * behavior for out-of-range values.
1590
+ */
1591
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x2_e4m3(const __nv_bfloat162 f) {
1592
+ __x = __nv_cvt_bfloat16raw2_to_fp8x2(static_cast<__nv_bfloat162_raw>(f),
1593
+ __NV_SATFINITE, __NV_E4M3);
1594
+ }
1595
+ /**
1596
+ * \ingroup CUDA_MATH_FP8X2_E4M3_STRUCT
1597
+ * Constructor from \p float2 data type, relies on \p __NV_SATFINITE
1598
+ * behavior for out-of-range values.
1599
+ */
1600
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x2_e4m3(const float2 f) {
1601
+ __x = __nv_cvt_float2_to_fp8x2(f, __NV_SATFINITE, __NV_E4M3);
1602
+ }
1603
+ /**
1604
+ * \ingroup CUDA_MATH_FP8X2_E4M3_STRUCT
1605
+ * Constructor from \p double2 data type, relies on \p __NV_SATFINITE
1606
+ * behavior for out-of-range values.
1607
+ */
1608
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x2_e4m3(const double2 f) {
1609
+ __x = __nv_cvt_double2_to_fp8x2(f, __NV_SATFINITE, __NV_E4M3);
1610
+ }
1611
+
1612
+ #if !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__)
1613
+ /* Widening converts */
1614
+ /**
1615
+ * \ingroup CUDA_MATH_FP8X2_E4M3_STRUCT
1616
+ * Conversion operator to \p __half2 data type.
1617
+ */
1618
+ explicit __CUDA_HOSTDEVICE_FP8__ operator __half2() const {
1619
+ return static_cast<__half2>(__nv_cvt_fp8x2_to_halfraw2(__x, __NV_E4M3));
1620
+ }
1621
+ /**
1622
+ * \ingroup CUDA_MATH_FP8X2_E4M3_STRUCT
1623
+ * Conversion operator to \p float2 data type.
1624
+ */
1625
+ explicit __CUDA_HOSTDEVICE_FP8__ operator float2() const {
1626
+ return __internal_halfraw2_to_float2(
1627
+ __nv_cvt_fp8x2_to_halfraw2(__x, __NV_E4M3));
1628
+ }
1629
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__) */
1630
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSIONS__) */
1631
+ };
1632
+
1633
+ /**
1634
+ * \defgroup CUDA_MATH_FP8X4_E4M3_STRUCT C++ struct for handling vector type of four fp8 values of e4m3 kind.
1635
+ * \ingroup CUDA_MATH_INTRINSIC_FP8
1636
+ */
1637
+
1638
+ /**
1639
+ * \ingroup CUDA_MATH_FP8X4_E4M3_STRUCT
1640
+ * \brief __nv_fp8x4_e4m3 datatype
1641
+ *
1642
+ * \details This structure implements the datatype for storage
1643
+ * and operations on the vector of four \p fp8 values of \p e4m3 kind each:
1644
+ * with 1 sign, 4 exponent, 1 implicit and 3 explicit mantissa bits.
1645
+ * The encoding doesn't support Infinity.
1646
+ * NaNs are limited to 0x7F and 0xFF values.
1647
+ */
1648
+ struct __CUDA_ALIGN__(4) __nv_fp8x4_e4m3 {
1649
+ public:
1650
+ /**
1651
+ * \ingroup CUDA_MATH_FP8X4_E4M3_STRUCT
1652
+ * Storage variable contains the vector of four \p fp8 floating-point data
1653
+ * values.
1654
+ */
1655
+ __nv_fp8x4_storage_t __x;
1656
+
1657
+ /**
1658
+ * \ingroup CUDA_MATH_FP8X4_E4M3_STRUCT
1659
+ * Constructor by default.
1660
+ */
1661
+ #if defined(__CPP_VERSION_AT_LEAST_11_FP8)
1662
+ __nv_fp8x4_e4m3() = default;
1663
+ #else
1664
+ __CUDA_HOSTDEVICE_FP8__ __nv_fp8x4_e4m3() {}
1665
+ #endif /* defined(__CPP_VERSION_AT_LEAST_11_FP8) */
1666
+
1667
+ #if !defined(__CUDA_NO_FP8_CONVERSIONS__)
1668
+
1669
+ /* Construct from wider types */
1670
+
1671
+ /**
1672
+ * \ingroup CUDA_MATH_FP8X4_E4M3_STRUCT
1673
+ * Constructor from a pair of \p __half2 data type values,
1674
+ * relies on \p __NV_SATFINITE behavior for out-of-range values.
1675
+ */
1676
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x4_e4m3(const __half2 flo,
1677
+ const __half2 fhi) {
1678
+ const __nv_fp8x2_storage_t rlo = __nv_cvt_halfraw2_to_fp8x2(
1679
+ static_cast<__half2_raw>(flo), __NV_SATFINITE, __NV_E4M3);
1680
+ const __nv_fp8x2_storage_t rhi = __nv_cvt_halfraw2_to_fp8x2(
1681
+ static_cast<__half2_raw>(fhi), __NV_SATFINITE, __NV_E4M3);
1682
+ __x = __internal_pack_u16x2_to_u32(rlo, rhi);
1683
+ }
1684
+ /**
1685
+ * \ingroup CUDA_MATH_FP8X4_E4M3_STRUCT
1686
+ * Constructor from a pair of \p __nv_bfloat162 data type values,
1687
+ * relies on \p __NV_SATFINITE behavior for out-of-range values.
1688
+ */
1689
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x4_e4m3(const __nv_bfloat162 flo,
1690
+ const __nv_bfloat162 fhi) {
1691
+ const __nv_fp8x2_storage_t rlo = __nv_cvt_bfloat16raw2_to_fp8x2(
1692
+ static_cast<__nv_bfloat162_raw>(flo), __NV_SATFINITE, __NV_E4M3);
1693
+ const __nv_fp8x2_storage_t rhi = __nv_cvt_bfloat16raw2_to_fp8x2(
1694
+ static_cast<__nv_bfloat162_raw>(fhi), __NV_SATFINITE, __NV_E4M3);
1695
+ __x = __internal_pack_u16x2_to_u32(rlo, rhi);
1696
+ }
1697
+ /**
1698
+ * \ingroup CUDA_MATH_FP8X4_E4M3_STRUCT
1699
+ * Constructor from \p float4 vector data type,
1700
+ * relies on \p __NV_SATFINITE behavior for out-of-range values.
1701
+ */
1702
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x4_e4m3(const float4 f) {
1703
+ const float2 flo = {f.x, f.y};
1704
+ const float2 fhi = {f.z, f.w};
1705
+ const __nv_fp8x2_storage_t rlo =
1706
+ __nv_cvt_float2_to_fp8x2(flo, __NV_SATFINITE, __NV_E4M3);
1707
+ const __nv_fp8x2_storage_t rhi =
1708
+ __nv_cvt_float2_to_fp8x2(fhi, __NV_SATFINITE, __NV_E4M3);
1709
+ __x = __internal_pack_u16x2_to_u32(rlo, rhi);
1710
+ }
1711
+ /**
1712
+ * \ingroup CUDA_MATH_FP8X4_E4M3_STRUCT
1713
+ * Constructor from \p double4 vector data type,
1714
+ * relies on \p __NV_SATFINITE behavior for out-of-range values.
1715
+ */
1716
+ explicit __CUDA_HOSTDEVICE_FP8__ __nv_fp8x4_e4m3(const double4 f) {
1717
+ const double2 flo = {f.x, f.y};
1718
+ const double2 fhi = {f.z, f.w};
1719
+ const __nv_fp8x2_storage_t rlo =
1720
+ __nv_cvt_double2_to_fp8x2(flo, __NV_SATFINITE, __NV_E4M3);
1721
+ const __nv_fp8x2_storage_t rhi =
1722
+ __nv_cvt_double2_to_fp8x2(fhi, __NV_SATFINITE, __NV_E4M3);
1723
+ __x = __internal_pack_u16x2_to_u32(rlo, rhi);
1724
+ }
1725
+
1726
+ #if !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__)
1727
+ /* Widening converts */
1728
+
1729
+ /**
1730
+ * \ingroup CUDA_MATH_FP8X4_E4M3_STRUCT
1731
+ * Conversion operator to \p float4 vector data type.
1732
+ */
1733
+ explicit __CUDA_HOSTDEVICE_FP8__ operator float4() const {
1734
+ const __nv_fp8x2_storage_t slo = static_cast<__nv_fp8x2_storage_t>(__x);
1735
+ const __nv_fp8x2_storage_t shi =
1736
+ static_cast<__nv_fp8x2_storage_t>(__x >> 16U);
1737
+ float2 rlo = __internal_halfraw2_to_float2(
1738
+ __nv_cvt_fp8x2_to_halfraw2(slo, __NV_E4M3));
1739
+ float2 rhi = __internal_halfraw2_to_float2(
1740
+ __nv_cvt_fp8x2_to_halfraw2(shi, __NV_E4M3));
1741
+ float4 res = {rlo.x, rlo.y, rhi.x, rhi.y};
1742
+ return res;
1743
+ }
1744
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSION_OPERATORS__) */
1745
+ #endif /* !defined(__CUDA_NO_FP8_CONVERSIONS__) */
1746
+ };
1747
+
1748
+ #endif /* defined(__cplusplus) */
1749
+
1750
+ #endif /* end of include guard: __CUDA_FP8_HPP__ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_occupancy.h ADDED
@@ -0,0 +1,1958 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2017 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ /**
51
+ * CUDA Occupancy Calculator
52
+ *
53
+ * NAME
54
+ *
55
+ * cudaOccMaxActiveBlocksPerMultiprocessor,
56
+ * cudaOccMaxPotentialOccupancyBlockSize,
57
+ * cudaOccMaxPotentialOccupancyBlockSizeVariableSMem
58
+ * cudaOccAvailableDynamicSMemPerBlock
59
+ *
60
+ * DESCRIPTION
61
+ *
62
+ * The CUDA occupancy calculator provides a standalone, programmatical
63
+ * interface to compute the occupancy of a function on a device. It can also
64
+ * provide occupancy-oriented launch configuration suggestions.
65
+ *
66
+ * The function and device are defined by the user through
67
+ * cudaOccFuncAttributes, cudaOccDeviceProp, and cudaOccDeviceState
68
+ * structures. All APIs require all 3 of them.
69
+ *
70
+ * See the structure definition for more details about the device / function
71
+ * descriptors.
72
+ *
73
+ * See each API's prototype for API usage.
74
+ *
75
+ * COMPATIBILITY
76
+ *
77
+ * The occupancy calculator will be updated on each major CUDA toolkit
78
+ * release. It does not provide forward compatibility, i.e. new hardwares
79
+ * released after this implementation's release will not be supported.
80
+ *
81
+ * NOTE
82
+ *
83
+ * If there is access to CUDA runtime, and the sole intent is to calculate
84
+ * occupancy related values on one of the accessible CUDA devices, using CUDA
85
+ * runtime's occupancy calculation APIs is recommended.
86
+ *
87
+ */
88
+
89
+ #ifndef __cuda_occupancy_h__
90
+ #define __cuda_occupancy_h__
91
+
92
+ #include <stddef.h>
93
+ #include <limits.h>
94
+ #include <string.h>
95
+
96
+
97
+ // __OCC_INLINE will be undefined at the end of this header
98
+ //
99
+ #ifdef __CUDACC__
100
+ #define __OCC_INLINE inline __host__ __device__
101
+ #elif defined _MSC_VER
102
+ #define __OCC_INLINE __inline
103
+ #else // GNUCC assumed
104
+ #define __OCC_INLINE inline
105
+ #endif
106
+
107
+ enum cudaOccError_enum {
108
+ CUDA_OCC_SUCCESS = 0, // no error encountered
109
+ CUDA_OCC_ERROR_INVALID_INPUT = 1, // input parameter is invalid
110
+ CUDA_OCC_ERROR_UNKNOWN_DEVICE = 2, // requested device is not supported in
111
+ // current implementation or device is
112
+ // invalid
113
+ };
114
+ typedef enum cudaOccError_enum cudaOccError;
115
+
116
+ typedef struct cudaOccResult cudaOccResult;
117
+ typedef struct cudaOccDeviceProp cudaOccDeviceProp;
118
+ typedef struct cudaOccFuncAttributes cudaOccFuncAttributes;
119
+ typedef struct cudaOccDeviceState cudaOccDeviceState;
120
+
121
+ /**
122
+ * The CUDA occupancy calculator computes the occupancy of the function
123
+ * described by attributes with the given block size (blockSize), static device
124
+ * properties (properties), dynamic device states (states) and per-block dynamic
125
+ * shared memory allocation (dynamicSMemSize) in bytes, and output it through
126
+ * result along with other useful information. The occupancy is computed in
127
+ * terms of the maximum number of active blocks per multiprocessor. The user can
128
+ * then convert it to other metrics, such as number of active warps.
129
+ *
130
+ * RETURN VALUE
131
+ *
132
+ * The occupancy and related information is returned through result.
133
+ *
134
+ * If result->activeBlocksPerMultiprocessor is 0, then the given parameter
135
+ * combination cannot run on the device.
136
+ *
137
+ * ERRORS
138
+ *
139
+ * CUDA_OCC_ERROR_INVALID_INPUT input parameter is invalid.
140
+ * CUDA_OCC_ERROR_UNKNOWN_DEVICE requested device is not supported in
141
+ * current implementation or device is invalid
142
+ */
143
+ static __OCC_INLINE
144
+ cudaOccError cudaOccMaxActiveBlocksPerMultiprocessor(
145
+ cudaOccResult *result, // out
146
+ const cudaOccDeviceProp *properties, // in
147
+ const cudaOccFuncAttributes *attributes, // in
148
+ const cudaOccDeviceState *state, // in
149
+ int blockSize, // in
150
+ size_t dynamicSmemSize); // in
151
+
152
+ /**
153
+ * The CUDA launch configurator C API suggests a grid / block size pair (in
154
+ * minGridSize and blockSize) that achieves the best potential occupancy
155
+ * (i.e. maximum number of active warps with the smallest number of blocks) for
156
+ * the given function described by attributes, on a device described by
157
+ * properties with settings in state.
158
+ *
159
+ * If per-block dynamic shared memory allocation is not needed, the user should
160
+ * leave both blockSizeToDynamicSMemSize and dynamicSMemSize as 0.
161
+ *
162
+ * If per-block dynamic shared memory allocation is needed, then if the dynamic
163
+ * shared memory size is constant regardless of block size, the size should be
164
+ * passed through dynamicSMemSize, and blockSizeToDynamicSMemSize should be
165
+ * NULL.
166
+ *
167
+ * Otherwise, if the per-block dynamic shared memory size varies with different
168
+ * block sizes, the user needs to provide a pointer to an unary function through
169
+ * blockSizeToDynamicSMemSize that computes the dynamic shared memory needed by
170
+ * a block of the function for any given block size. dynamicSMemSize is
171
+ * ignored. An example signature is:
172
+ *
173
+ * // Take block size, returns dynamic shared memory needed
174
+ * size_t blockToSmem(int blockSize);
175
+ *
176
+ * RETURN VALUE
177
+ *
178
+ * The suggested block size and the minimum number of blocks needed to achieve
179
+ * the maximum occupancy are returned through blockSize and minGridSize.
180
+ *
181
+ * If *blockSize is 0, then the given combination cannot run on the device.
182
+ *
183
+ * ERRORS
184
+ *
185
+ * CUDA_OCC_ERROR_INVALID_INPUT input parameter is invalid.
186
+ * CUDA_OCC_ERROR_UNKNOWN_DEVICE requested device is not supported in
187
+ * current implementation or device is invalid
188
+ *
189
+ */
190
+ static __OCC_INLINE
191
+ cudaOccError cudaOccMaxPotentialOccupancyBlockSize(
192
+ int *minGridSize, // out
193
+ int *blockSize, // out
194
+ const cudaOccDeviceProp *properties, // in
195
+ const cudaOccFuncAttributes *attributes, // in
196
+ const cudaOccDeviceState *state, // in
197
+ size_t (*blockSizeToDynamicSMemSize)(int), // in
198
+ size_t dynamicSMemSize); // in
199
+
200
+ /**
201
+ * The CUDA launch configurator C++ API suggests a grid / block size pair (in
202
+ * minGridSize and blockSize) that achieves the best potential occupancy
203
+ * (i.e. the maximum number of active warps with the smallest number of blocks)
204
+ * for the given function described by attributes, on a device described by
205
+ * properties with settings in state.
206
+ *
207
+ * If per-block dynamic shared memory allocation is 0 or constant regardless of
208
+ * block size, the user can use cudaOccMaxPotentialOccupancyBlockSize to
209
+ * configure the launch. A constant dynamic shared memory allocation size in
210
+ * bytes can be passed through dynamicSMemSize.
211
+ *
212
+ * Otherwise, if the per-block dynamic shared memory size varies with different
213
+ * block sizes, the user needs to use
214
+ * cudaOccMaxPotentialOccupancyBlockSizeVariableSmem instead, and provide a
215
+ * functor / pointer to an unary function (blockSizeToDynamicSMemSize) that
216
+ * computes the dynamic shared memory needed by func for any given block
217
+ * size. An example signature is:
218
+ *
219
+ * // Take block size, returns per-block dynamic shared memory needed
220
+ * size_t blockToSmem(int blockSize);
221
+ *
222
+ * RETURN VALUE
223
+ *
224
+ * The suggested block size and the minimum number of blocks needed to achieve
225
+ * the maximum occupancy are returned through blockSize and minGridSize.
226
+ *
227
+ * If *blockSize is 0, then the given combination cannot run on the device.
228
+ *
229
+ * ERRORS
230
+ *
231
+ * CUDA_OCC_ERROR_INVALID_INPUT input parameter is invalid.
232
+ * CUDA_OCC_ERROR_UNKNOWN_DEVICE requested device is not supported in
233
+ * current implementation or device is invalid
234
+ *
235
+ */
236
+
237
+ #if defined(__cplusplus)
238
+ namespace {
239
+
240
+ __OCC_INLINE
241
+ cudaOccError cudaOccMaxPotentialOccupancyBlockSize(
242
+ int *minGridSize, // out
243
+ int *blockSize, // out
244
+ const cudaOccDeviceProp *properties, // in
245
+ const cudaOccFuncAttributes *attributes, // in
246
+ const cudaOccDeviceState *state, // in
247
+ size_t dynamicSMemSize = 0); // in
248
+
249
+ template <typename UnaryFunction>
250
+ __OCC_INLINE
251
+ cudaOccError cudaOccMaxPotentialOccupancyBlockSizeVariableSMem(
252
+ int *minGridSize, // out
253
+ int *blockSize, // out
254
+ const cudaOccDeviceProp *properties, // in
255
+ const cudaOccFuncAttributes *attributes, // in
256
+ const cudaOccDeviceState *state, // in
257
+ UnaryFunction blockSizeToDynamicSMemSize); // in
258
+
259
+ } // namespace anonymous
260
+ #endif // defined(__cplusplus)
261
+
262
+ /**
263
+ *
264
+ * The CUDA dynamic shared memory calculator computes the maximum size of
265
+ * per-block dynamic shared memory if we want to place numBlocks blocks
266
+ * on an SM.
267
+ *
268
+ * RETURN VALUE
269
+ *
270
+ * Returns in *dynamicSmemSize the maximum size of dynamic shared memory to allow
271
+ * numBlocks blocks per SM.
272
+ *
273
+ * ERRORS
274
+ *
275
+ * CUDA_OCC_ERROR_INVALID_INPUT input parameter is invalid.
276
+ * CUDA_OCC_ERROR_UNKNOWN_DEVICE requested device is not supported in
277
+ * current implementation or device is invalid
278
+ *
279
+ */
280
+ static __OCC_INLINE
281
+ cudaOccError cudaOccAvailableDynamicSMemPerBlock(
282
+ size_t *dynamicSmemSize,
283
+ const cudaOccDeviceProp *properties,
284
+ const cudaOccFuncAttributes *attributes,
285
+ const cudaOccDeviceState *state,
286
+ int numBlocks,
287
+ int blockSize);
288
+
289
+ /**
290
+ * Data structures
291
+ *
292
+ * These structures are subject to change for future architecture and CUDA
293
+ * releases. C users should initialize the structure as {0}.
294
+ *
295
+ */
296
+
297
+ /**
298
+ * Device descriptor
299
+ *
300
+ * This structure describes a device.
301
+ */
302
+ struct cudaOccDeviceProp {
303
+ int computeMajor; // Compute capability major version
304
+ int computeMinor; // Compute capability minor
305
+ // version. None supported minor version
306
+ // may cause error
307
+ int maxThreadsPerBlock; // Maximum number of threads per block
308
+ int maxThreadsPerMultiprocessor; // Maximum number of threads per SM
309
+ // i.e. (Max. number of warps) x (warp
310
+ // size)
311
+ int regsPerBlock; // Maximum number of registers per block
312
+ int regsPerMultiprocessor; // Maximum number of registers per SM
313
+ int warpSize; // Warp size
314
+ size_t sharedMemPerBlock; // Maximum shared memory size per block
315
+ size_t sharedMemPerMultiprocessor; // Maximum shared memory size per SM
316
+ int numSms; // Number of SMs available
317
+ size_t sharedMemPerBlockOptin; // Maximum optin shared memory size per block
318
+ size_t reservedSharedMemPerBlock; // Shared memory per block reserved by driver
319
+
320
+ #ifdef __cplusplus
321
+ // This structure can be converted from a cudaDeviceProp structure for users
322
+ // that use this header in their CUDA applications.
323
+ //
324
+ // If the application have access to the CUDA Runtime API, the application
325
+ // can obtain the device properties of a CUDA device through
326
+ // cudaGetDeviceProperties, and initialize a cudaOccDeviceProp with the
327
+ // cudaDeviceProp structure.
328
+ //
329
+ // Example:
330
+ /*
331
+ {
332
+ cudaDeviceProp prop;
333
+
334
+ cudaGetDeviceProperties(&prop, ...);
335
+
336
+ cudaOccDeviceProp occProp = prop;
337
+
338
+ ...
339
+
340
+ cudaOccMaxPotentialOccupancyBlockSize(..., &occProp, ...);
341
+ }
342
+ */
343
+ //
344
+ template<typename DeviceProp>
345
+ __OCC_INLINE
346
+ cudaOccDeviceProp(const DeviceProp &props)
347
+ : computeMajor (props.major),
348
+ computeMinor (props.minor),
349
+ maxThreadsPerBlock (props.maxThreadsPerBlock),
350
+ maxThreadsPerMultiprocessor (props.maxThreadsPerMultiProcessor),
351
+ regsPerBlock (props.regsPerBlock),
352
+ regsPerMultiprocessor (props.regsPerMultiprocessor),
353
+ warpSize (props.warpSize),
354
+ sharedMemPerBlock (props.sharedMemPerBlock),
355
+ sharedMemPerMultiprocessor (props.sharedMemPerMultiprocessor),
356
+ numSms (props.multiProcessorCount),
357
+ sharedMemPerBlockOptin (props.sharedMemPerBlockOptin),
358
+ reservedSharedMemPerBlock (props.reservedSharedMemPerBlock)
359
+ {}
360
+
361
+ __OCC_INLINE
362
+ cudaOccDeviceProp()
363
+ : computeMajor (0),
364
+ computeMinor (0),
365
+ maxThreadsPerBlock (0),
366
+ maxThreadsPerMultiprocessor (0),
367
+ regsPerBlock (0),
368
+ regsPerMultiprocessor (0),
369
+ warpSize (0),
370
+ sharedMemPerBlock (0),
371
+ sharedMemPerMultiprocessor (0),
372
+ numSms (0),
373
+ sharedMemPerBlockOptin (0),
374
+ reservedSharedMemPerBlock (0)
375
+ {}
376
+ #endif // __cplusplus
377
+ };
378
+
379
+ /**
380
+ * Partitioned global caching option
381
+ */
382
+ typedef enum cudaOccPartitionedGCConfig_enum {
383
+ PARTITIONED_GC_OFF, // Disable partitioned global caching
384
+ PARTITIONED_GC_ON, // Prefer partitioned global caching
385
+ PARTITIONED_GC_ON_STRICT // Force partitioned global caching
386
+ } cudaOccPartitionedGCConfig;
387
+
388
+ /**
389
+ * Per function opt in maximum dynamic shared memory limit
390
+ */
391
+ typedef enum cudaOccFuncShmemConfig_enum {
392
+ FUNC_SHMEM_LIMIT_DEFAULT, // Default shmem limit
393
+ FUNC_SHMEM_LIMIT_OPTIN, // Use the optin shmem limit
394
+ } cudaOccFuncShmemConfig;
395
+
396
+ /**
397
+ * Function descriptor
398
+ *
399
+ * This structure describes a CUDA function.
400
+ */
401
+ struct cudaOccFuncAttributes {
402
+ int maxThreadsPerBlock; // Maximum block size the function can work with. If
403
+ // unlimited, use INT_MAX or any value greater than
404
+ // or equal to maxThreadsPerBlock of the device
405
+ int numRegs; // Number of registers used. When the function is
406
+ // launched on device, the register count may change
407
+ // due to internal tools requirements.
408
+ size_t sharedSizeBytes; // Number of static shared memory used
409
+
410
+ cudaOccPartitionedGCConfig partitionedGCConfig;
411
+ // Partitioned global caching is required to enable
412
+ // caching on certain chips, such as sm_52
413
+ // devices. Partitioned global caching can be
414
+ // automatically disabled if the occupancy
415
+ // requirement of the launch cannot support caching.
416
+ //
417
+ // To override this behavior with caching on and
418
+ // calculate occupancy strictly according to the
419
+ // preference, set partitionedGCConfig to
420
+ // PARTITIONED_GC_ON_STRICT. This is especially
421
+ // useful for experimenting and finding launch
422
+ // configurations (MaxPotentialOccupancyBlockSize)
423
+ // that allow global caching to take effect.
424
+ //
425
+ // This flag only affects the occupancy calculation.
426
+
427
+ cudaOccFuncShmemConfig shmemLimitConfig;
428
+ // Certain chips like sm_70 allow a user to opt into
429
+ // a higher per block limit of dynamic shared memory
430
+ // This optin is performed on a per function basis
431
+ // using the cuFuncSetAttribute function
432
+
433
+ size_t maxDynamicSharedSizeBytes;
434
+ // User set limit on maximum dynamic shared memory
435
+ // usable by the kernel
436
+ // This limit is set using the cuFuncSetAttribute
437
+ // function.
438
+
439
+ int numBlockBarriers; // Number of block barriers used (default to 1)
440
+ #ifdef __cplusplus
441
+ // This structure can be converted from a cudaFuncAttributes structure for
442
+ // users that use this header in their CUDA applications.
443
+ //
444
+ // If the application have access to the CUDA Runtime API, the application
445
+ // can obtain the function attributes of a CUDA kernel function through
446
+ // cudaFuncGetAttributes, and initialize a cudaOccFuncAttributes with the
447
+ // cudaFuncAttributes structure.
448
+ //
449
+ // Example:
450
+ /*
451
+ __global__ void foo() {...}
452
+
453
+ ...
454
+
455
+ {
456
+ cudaFuncAttributes attr;
457
+
458
+ cudaFuncGetAttributes(&attr, foo);
459
+
460
+ cudaOccFuncAttributes occAttr = attr;
461
+
462
+ ...
463
+
464
+ cudaOccMaxPotentialOccupancyBlockSize(..., &occAttr, ...);
465
+ }
466
+ */
467
+ //
468
+ template<typename FuncAttributes>
469
+ __OCC_INLINE
470
+ cudaOccFuncAttributes(const FuncAttributes &attr)
471
+ : maxThreadsPerBlock (attr.maxThreadsPerBlock),
472
+ numRegs (attr.numRegs),
473
+ sharedSizeBytes (attr.sharedSizeBytes),
474
+ partitionedGCConfig (PARTITIONED_GC_OFF),
475
+ shmemLimitConfig (FUNC_SHMEM_LIMIT_OPTIN),
476
+ maxDynamicSharedSizeBytes (attr.maxDynamicSharedSizeBytes),
477
+ numBlockBarriers (1)
478
+ {}
479
+
480
+ __OCC_INLINE
481
+ cudaOccFuncAttributes()
482
+ : maxThreadsPerBlock (0),
483
+ numRegs (0),
484
+ sharedSizeBytes (0),
485
+ partitionedGCConfig (PARTITIONED_GC_OFF),
486
+ shmemLimitConfig (FUNC_SHMEM_LIMIT_DEFAULT),
487
+ maxDynamicSharedSizeBytes (0),
488
+ numBlockBarriers (0)
489
+ {}
490
+ #endif
491
+ };
492
+
493
+ typedef enum cudaOccCacheConfig_enum {
494
+ CACHE_PREFER_NONE = 0x00, // no preference for shared memory or L1 (default)
495
+ CACHE_PREFER_SHARED = 0x01, // prefer larger shared memory and smaller L1 cache
496
+ CACHE_PREFER_L1 = 0x02, // prefer larger L1 cache and smaller shared memory
497
+ CACHE_PREFER_EQUAL = 0x03 // prefer equal sized L1 cache and shared memory
498
+ } cudaOccCacheConfig;
499
+
500
+ typedef enum cudaOccCarveoutConfig_enum {
501
+ SHAREDMEM_CARVEOUT_DEFAULT = -1, // no preference for shared memory or L1 (default)
502
+ SHAREDMEM_CARVEOUT_MAX_SHARED = 100, // prefer maximum available shared memory, minimum L1 cache
503
+ SHAREDMEM_CARVEOUT_MAX_L1 = 0, // prefer maximum available L1 cache, minimum shared memory
504
+ SHAREDMEM_CARVEOUT_HALF = 50 // prefer half of maximum available shared memory, with the rest as L1 cache
505
+ } cudaOccCarveoutConfig;
506
+
507
+ /**
508
+ * Device state descriptor
509
+ *
510
+ * This structure describes device settings that affect occupancy calculation.
511
+ */
512
+ struct cudaOccDeviceState
513
+ {
514
+ // Cache / shared memory split preference. Deprecated on Volta
515
+ cudaOccCacheConfig cacheConfig;
516
+ // Shared memory / L1 split preference. Supported on only Volta
517
+ int carveoutConfig;
518
+
519
+ #ifdef __cplusplus
520
+ __OCC_INLINE
521
+ cudaOccDeviceState()
522
+ : cacheConfig (CACHE_PREFER_NONE),
523
+ carveoutConfig (SHAREDMEM_CARVEOUT_DEFAULT)
524
+ {}
525
+ #endif
526
+ };
527
+
528
+ typedef enum cudaOccLimitingFactor_enum {
529
+ // Occupancy limited due to:
530
+ OCC_LIMIT_WARPS = 0x01, // - warps available
531
+ OCC_LIMIT_REGISTERS = 0x02, // - registers available
532
+ OCC_LIMIT_SHARED_MEMORY = 0x04, // - shared memory available
533
+ OCC_LIMIT_BLOCKS = 0x08, // - blocks available
534
+ OCC_LIMIT_BARRIERS = 0x10 // - barrier available
535
+ } cudaOccLimitingFactor;
536
+
537
+ /**
538
+ * Occupancy output
539
+ *
540
+ * This structure contains occupancy calculator's output.
541
+ */
542
+ struct cudaOccResult {
543
+ int activeBlocksPerMultiprocessor; // Occupancy
544
+ unsigned int limitingFactors; // Factors that limited occupancy. A bit
545
+ // field that counts the limiting
546
+ // factors, see cudaOccLimitingFactor
547
+ int blockLimitRegs; // Occupancy due to register
548
+ // usage, INT_MAX if the kernel does not
549
+ // use any register.
550
+ int blockLimitSharedMem; // Occupancy due to shared memory
551
+ // usage, INT_MAX if the kernel does not
552
+ // use shared memory.
553
+ int blockLimitWarps; // Occupancy due to block size limit
554
+ int blockLimitBlocks; // Occupancy due to maximum number of blocks
555
+ // managable per SM
556
+ int blockLimitBarriers; // Occupancy due to block barrier usage
557
+ int allocatedRegistersPerBlock; // Actual number of registers allocated per
558
+ // block
559
+ size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
560
+ // per block
561
+ cudaOccPartitionedGCConfig partitionedGCConfig;
562
+ // Report if partitioned global caching
563
+ // is actually enabled.
564
+ };
565
+
566
+ /**
567
+ * Partitioned global caching support
568
+ *
569
+ * See cudaOccPartitionedGlobalCachingModeSupport
570
+ */
571
+ typedef enum cudaOccPartitionedGCSupport_enum {
572
+ PARTITIONED_GC_NOT_SUPPORTED, // Partitioned global caching is not supported
573
+ PARTITIONED_GC_SUPPORTED, // Partitioned global caching is supported
574
+ } cudaOccPartitionedGCSupport;
575
+
576
+ /**
577
+ * Implementation
578
+ */
579
+
580
+ /**
581
+ * Max compute capability supported
582
+ */
583
+ #define __CUDA_OCC_MAJOR__ 9
584
+ #define __CUDA_OCC_MINOR__ 0
585
+
586
+ //////////////////////////////////////////
587
+ // Mathematical Helper Functions //
588
+ //////////////////////////////////////////
589
+
590
+ static __OCC_INLINE int __occMin(int lhs, int rhs)
591
+ {
592
+ return rhs < lhs ? rhs : lhs;
593
+ }
594
+
595
+ static __OCC_INLINE int __occDivideRoundUp(int x, int y)
596
+ {
597
+ return (x + (y - 1)) / y;
598
+ }
599
+
600
+ static __OCC_INLINE int __occRoundUp(int x, int y)
601
+ {
602
+ return y * __occDivideRoundUp(x, y);
603
+ }
604
+
605
+ //////////////////////////////////////////
606
+ // Architectural Properties //
607
+ //////////////////////////////////////////
608
+
609
+ /**
610
+ * Granularity of shared memory allocation
611
+ */
612
+ static __OCC_INLINE cudaOccError cudaOccSMemAllocationGranularity(int *limit, const cudaOccDeviceProp *properties)
613
+ {
614
+ int value;
615
+
616
+ switch(properties->computeMajor) {
617
+ case 3:
618
+ case 5:
619
+ case 6:
620
+ case 7:
621
+ value = 256;
622
+ break;
623
+ case 8:
624
+ case 9:
625
+ value = 128;
626
+ break;
627
+ default:
628
+ return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
629
+ }
630
+
631
+ *limit = value;
632
+
633
+ return CUDA_OCC_SUCCESS;
634
+ }
635
+
636
+ /**
637
+ * Maximum number of registers per thread
638
+ */
639
+ static __OCC_INLINE cudaOccError cudaOccRegAllocationMaxPerThread(int *limit, const cudaOccDeviceProp *properties)
640
+ {
641
+ int value;
642
+
643
+ switch(properties->computeMajor) {
644
+ case 3:
645
+ case 5:
646
+ case 6:
647
+ value = 255;
648
+ break;
649
+ case 7:
650
+ case 8:
651
+ case 9:
652
+ value = 256;
653
+ break;
654
+ default:
655
+ return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
656
+ }
657
+
658
+ *limit = value;
659
+
660
+ return CUDA_OCC_SUCCESS;
661
+ }
662
+
663
+ /**
664
+ * Granularity of register allocation
665
+ */
666
+ static __OCC_INLINE cudaOccError cudaOccRegAllocationGranularity(int *limit, const cudaOccDeviceProp *properties)
667
+ {
668
+ int value;
669
+
670
+ switch(properties->computeMajor) {
671
+ case 3:
672
+ case 5:
673
+ case 6:
674
+ case 7:
675
+ case 8:
676
+ case 9:
677
+ value = 256;
678
+ break;
679
+ default:
680
+ return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
681
+ }
682
+
683
+ *limit = value;
684
+
685
+ return CUDA_OCC_SUCCESS;
686
+ }
687
+
688
+ /**
689
+ * Number of sub-partitions
690
+ */
691
+ static __OCC_INLINE cudaOccError cudaOccSubPartitionsPerMultiprocessor(int *limit, const cudaOccDeviceProp *properties)
692
+ {
693
+ int value;
694
+
695
+ switch(properties->computeMajor) {
696
+ case 3:
697
+ case 5:
698
+ case 7:
699
+ case 8:
700
+ case 9:
701
+ value = 4;
702
+ break;
703
+ case 6:
704
+ value = properties->computeMinor ? 4 : 2;
705
+ break;
706
+ default:
707
+ return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
708
+ }
709
+
710
+ *limit = value;
711
+
712
+ return CUDA_OCC_SUCCESS;
713
+ }
714
+
715
+
716
+ /**
717
+ * Maximum number of blocks that can run simultaneously on a multiprocessor
718
+ */
719
+ static __OCC_INLINE cudaOccError cudaOccMaxBlocksPerMultiprocessor(int* limit, const cudaOccDeviceProp *properties)
720
+ {
721
+ int value;
722
+
723
+ switch(properties->computeMajor) {
724
+ case 3:
725
+ value = 16;
726
+ break;
727
+ case 5:
728
+ case 6:
729
+ value = 32;
730
+ break;
731
+ case 7: {
732
+ int isTuring = properties->computeMinor == 5;
733
+ value = (isTuring) ? 16 : 32;
734
+ break;
735
+ }
736
+ case 8:
737
+ if (properties->computeMinor == 0) {
738
+ value = 32;
739
+ }
740
+ else if (properties->computeMinor == 9) {
741
+ value = 24;
742
+ }
743
+ else {
744
+ value = 16;
745
+ }
746
+ break;
747
+ case 9:
748
+ value = 32;
749
+ break;
750
+ default:
751
+ return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
752
+ }
753
+
754
+ *limit = value;
755
+
756
+ return CUDA_OCC_SUCCESS;
757
+ }
758
+
759
+ /**
760
+ * Align up shared memory based on compute major configurations
761
+ */
762
+ static __OCC_INLINE cudaOccError cudaOccAlignUpShmemSizeVoltaPlus(size_t *shMemSize, const cudaOccDeviceProp *properties)
763
+ {
764
+ // Volta and Turing have shared L1 cache / shared memory, and support cache
765
+ // configuration to trade one for the other. These values are needed to
766
+ // map carveout config ratio to the next available architecture size
767
+ size_t size = *shMemSize;
768
+
769
+ switch (properties->computeMajor) {
770
+ case 7: {
771
+ // Turing supports 32KB and 64KB shared mem.
772
+ int isTuring = properties->computeMinor == 5;
773
+ if (isTuring) {
774
+ if (size <= 32 * 1024) {
775
+ *shMemSize = 32 * 1024;
776
+ }
777
+ else if (size <= 64 * 1024) {
778
+ *shMemSize = 64 * 1024;
779
+ }
780
+ else {
781
+ return CUDA_OCC_ERROR_INVALID_INPUT;
782
+ }
783
+ }
784
+ // Volta supports 0KB, 8KB, 16KB, 32KB, 64KB, and 96KB shared mem.
785
+ else {
786
+ if (size == 0) {
787
+ *shMemSize = 0;
788
+ }
789
+ else if (size <= 8 * 1024) {
790
+ *shMemSize = 8 * 1024;
791
+ }
792
+ else if (size <= 16 * 1024) {
793
+ *shMemSize = 16 * 1024;
794
+ }
795
+ else if (size <= 32 * 1024) {
796
+ *shMemSize = 32 * 1024;
797
+ }
798
+ else if (size <= 64 * 1024) {
799
+ *shMemSize = 64 * 1024;
800
+ }
801
+ else if (size <= 96 * 1024) {
802
+ *shMemSize = 96 * 1024;
803
+ }
804
+ else {
805
+ return CUDA_OCC_ERROR_INVALID_INPUT;
806
+ }
807
+ }
808
+ break;
809
+ }
810
+ case 8:
811
+ if (properties->computeMinor == 0 || properties->computeMinor == 7) {
812
+ if (size == 0) {
813
+ *shMemSize = 0;
814
+ }
815
+ else if (size <= 8 * 1024) {
816
+ *shMemSize = 8 * 1024;
817
+ }
818
+ else if (size <= 16 * 1024) {
819
+ *shMemSize = 16 * 1024;
820
+ }
821
+ else if (size <= 32 * 1024) {
822
+ *shMemSize = 32 * 1024;
823
+ }
824
+ else if (size <= 64 * 1024) {
825
+ *shMemSize = 64 * 1024;
826
+ }
827
+ else if (size <= 100 * 1024) {
828
+ *shMemSize = 100 * 1024;
829
+ }
830
+ else if (size <= 132 * 1024) {
831
+ *shMemSize = 132 * 1024;
832
+ }
833
+ else if (size <= 164 * 1024) {
834
+ *shMemSize = 164 * 1024;
835
+ }
836
+ else {
837
+ return CUDA_OCC_ERROR_INVALID_INPUT;
838
+ }
839
+ }
840
+ else {
841
+ if (size == 0) {
842
+ *shMemSize = 0;
843
+ }
844
+ else if (size <= 8 * 1024) {
845
+ *shMemSize = 8 * 1024;
846
+ }
847
+ else if (size <= 16 * 1024) {
848
+ *shMemSize = 16 * 1024;
849
+ }
850
+ else if (size <= 32 * 1024) {
851
+ *shMemSize = 32 * 1024;
852
+ }
853
+ else if (size <= 64 * 1024) {
854
+ *shMemSize = 64 * 1024;
855
+ }
856
+ else if (size <= 100 * 1024) {
857
+ *shMemSize = 100 * 1024;
858
+ }
859
+ else {
860
+ return CUDA_OCC_ERROR_INVALID_INPUT;
861
+ }
862
+ }
863
+ break;
864
+ case 9: {
865
+ if (size == 0) {
866
+ *shMemSize = 0;
867
+ }
868
+ else if (size <= 8 * 1024) {
869
+ *shMemSize = 8 * 1024;
870
+ }
871
+ else if (size <= 16 * 1024) {
872
+ *shMemSize = 16 * 1024;
873
+ }
874
+ else if (size <= 32 * 1024) {
875
+ *shMemSize = 32 * 1024;
876
+ }
877
+ else if (size <= 64 * 1024) {
878
+ *shMemSize = 64 * 1024;
879
+ }
880
+ else if (size <= 100 * 1024) {
881
+ *shMemSize = 100 * 1024;
882
+ }
883
+ else if (size <= 132 * 1024) {
884
+ *shMemSize = 132 * 1024;
885
+ }
886
+ else if (size <= 164 * 1024) {
887
+ *shMemSize = 164 * 1024;
888
+ }
889
+ else if (size <= 196 * 1024) {
890
+ *shMemSize = 196 * 1024;
891
+ }
892
+ else if (size <= 228 * 1024) {
893
+ *shMemSize = 228 * 1024;
894
+ }
895
+ else {
896
+ return CUDA_OCC_ERROR_INVALID_INPUT;
897
+ }
898
+ break;
899
+ }
900
+ default:
901
+ return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
902
+ }
903
+
904
+ return CUDA_OCC_SUCCESS;
905
+ }
906
+
907
+ /**
908
+ * Shared memory based on the new carveoutConfig API introduced with Volta
909
+ */
910
+ static __OCC_INLINE cudaOccError cudaOccSMemPreferenceVoltaPlus(size_t *limit, const cudaOccDeviceProp *properties, const cudaOccDeviceState *state)
911
+ {
912
+ cudaOccError status = CUDA_OCC_SUCCESS;
913
+ size_t preferenceShmemSize;
914
+
915
+ // CUDA 9.0 introduces a new API to set shared memory - L1 configuration on supported
916
+ // devices. This preference will take precedence over the older cacheConfig setting.
917
+ // Map cacheConfig to its effective preference value.
918
+ int effectivePreference = state->carveoutConfig;
919
+ if ((effectivePreference < SHAREDMEM_CARVEOUT_DEFAULT) || (effectivePreference > SHAREDMEM_CARVEOUT_MAX_SHARED)) {
920
+ return CUDA_OCC_ERROR_INVALID_INPUT;
921
+ }
922
+
923
+ if (effectivePreference == SHAREDMEM_CARVEOUT_DEFAULT) {
924
+ switch (state->cacheConfig)
925
+ {
926
+ case CACHE_PREFER_L1:
927
+ effectivePreference = SHAREDMEM_CARVEOUT_MAX_L1;
928
+ break;
929
+ case CACHE_PREFER_SHARED:
930
+ effectivePreference = SHAREDMEM_CARVEOUT_MAX_SHARED;
931
+ break;
932
+ case CACHE_PREFER_EQUAL:
933
+ effectivePreference = SHAREDMEM_CARVEOUT_HALF;
934
+ break;
935
+ default:
936
+ effectivePreference = SHAREDMEM_CARVEOUT_DEFAULT;
937
+ break;
938
+ }
939
+ }
940
+
941
+ if (effectivePreference == SHAREDMEM_CARVEOUT_DEFAULT) {
942
+ preferenceShmemSize = properties->sharedMemPerMultiprocessor;
943
+ }
944
+ else {
945
+ preferenceShmemSize = (size_t) (effectivePreference * properties->sharedMemPerMultiprocessor) / 100;
946
+ }
947
+
948
+ status = cudaOccAlignUpShmemSizeVoltaPlus(&preferenceShmemSize, properties);
949
+ *limit = preferenceShmemSize;
950
+ return status;
951
+ }
952
+
953
+ /**
954
+ * Shared memory based on the cacheConfig
955
+ */
956
+ static __OCC_INLINE cudaOccError cudaOccSMemPreference(size_t *limit, const cudaOccDeviceProp *properties, const cudaOccDeviceState *state)
957
+ {
958
+ size_t bytes = 0;
959
+ size_t sharedMemPerMultiprocessorHigh = properties->sharedMemPerMultiprocessor;
960
+ cudaOccCacheConfig cacheConfig = state->cacheConfig;
961
+
962
+ // Kepler has shared L1 cache / shared memory, and support cache
963
+ // configuration to trade one for the other. These values are needed to
964
+ // calculate the correct shared memory size for user requested cache
965
+ // configuration.
966
+ //
967
+ size_t minCacheSize = 16384;
968
+ size_t maxCacheSize = 49152;
969
+ size_t cacheAndSharedTotal = sharedMemPerMultiprocessorHigh + minCacheSize;
970
+ size_t sharedMemPerMultiprocessorLow = cacheAndSharedTotal - maxCacheSize;
971
+
972
+ switch (properties->computeMajor) {
973
+ case 3:
974
+ // Kepler supports 16KB, 32KB, or 48KB partitions for L1. The rest
975
+ // is shared memory.
976
+ //
977
+ switch (cacheConfig) {
978
+ default :
979
+ case CACHE_PREFER_NONE:
980
+ case CACHE_PREFER_SHARED:
981
+ bytes = sharedMemPerMultiprocessorHigh;
982
+ break;
983
+ case CACHE_PREFER_L1:
984
+ bytes = sharedMemPerMultiprocessorLow;
985
+ break;
986
+ case CACHE_PREFER_EQUAL:
987
+ // Equal is the mid-point between high and low. It should be
988
+ // equivalent to low + 16KB.
989
+ //
990
+ bytes = (sharedMemPerMultiprocessorHigh + sharedMemPerMultiprocessorLow) / 2;
991
+ break;
992
+ }
993
+ break;
994
+ case 5:
995
+ case 6:
996
+ // Maxwell and Pascal have dedicated shared memory.
997
+ //
998
+ bytes = sharedMemPerMultiprocessorHigh;
999
+ break;
1000
+ default:
1001
+ return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
1002
+ }
1003
+
1004
+ *limit = bytes;
1005
+
1006
+ return CUDA_OCC_SUCCESS;
1007
+ }
1008
+
1009
+ /**
1010
+ * Shared memory based on config requested by User
1011
+ */
1012
+ static __OCC_INLINE cudaOccError cudaOccSMemPerMultiprocessor(size_t *limit, const cudaOccDeviceProp *properties, const cudaOccDeviceState *state)
1013
+ {
1014
+ // Volta introduces a new API that allows for shared memory carveout preference. Because it is a shared memory preference,
1015
+ // it is handled separately from the cache config preference.
1016
+ if (properties->computeMajor >= 7) {
1017
+ return cudaOccSMemPreferenceVoltaPlus(limit, properties, state);
1018
+ }
1019
+ return cudaOccSMemPreference(limit, properties, state);
1020
+ }
1021
+
1022
+ /**
1023
+ * Return the per block shared memory limit based on function config
1024
+ */
1025
+ static __OCC_INLINE cudaOccError cudaOccSMemPerBlock(size_t *limit, const cudaOccDeviceProp *properties, cudaOccFuncShmemConfig shmemLimitConfig, size_t smemPerCta)
1026
+ {
1027
+ switch (properties->computeMajor) {
1028
+ case 2:
1029
+ case 3:
1030
+ case 4:
1031
+ case 5:
1032
+ case 6:
1033
+ *limit = properties->sharedMemPerBlock;
1034
+ break;
1035
+ case 7:
1036
+ case 8:
1037
+ case 9:
1038
+ switch (shmemLimitConfig) {
1039
+ default:
1040
+ case FUNC_SHMEM_LIMIT_DEFAULT:
1041
+ *limit = properties->sharedMemPerBlock;
1042
+ break;
1043
+ case FUNC_SHMEM_LIMIT_OPTIN:
1044
+ if (smemPerCta > properties->sharedMemPerBlock) {
1045
+ *limit = properties->sharedMemPerBlockOptin;
1046
+ }
1047
+ else {
1048
+ *limit = properties->sharedMemPerBlock;
1049
+ }
1050
+ break;
1051
+ }
1052
+ break;
1053
+ default:
1054
+ return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
1055
+ }
1056
+
1057
+ // Starting Ampere, CUDA driver reserves additional shared memory per block
1058
+ if (properties->computeMajor >= 8) {
1059
+ *limit += properties->reservedSharedMemPerBlock;
1060
+ }
1061
+
1062
+ return CUDA_OCC_SUCCESS;
1063
+ }
1064
+
1065
+ /**
1066
+ * Partitioned global caching mode support
1067
+ */
1068
+ static __OCC_INLINE cudaOccError cudaOccPartitionedGlobalCachingModeSupport(cudaOccPartitionedGCSupport *limit, const cudaOccDeviceProp *properties)
1069
+ {
1070
+ *limit = PARTITIONED_GC_NOT_SUPPORTED;
1071
+
1072
+ if ((properties->computeMajor == 5 && (properties->computeMinor == 2 || properties->computeMinor == 3)) ||
1073
+ properties->computeMajor == 6) {
1074
+ *limit = PARTITIONED_GC_SUPPORTED;
1075
+ }
1076
+
1077
+ if (properties->computeMajor == 6 && properties->computeMinor == 0) {
1078
+ *limit = PARTITIONED_GC_NOT_SUPPORTED;
1079
+ }
1080
+
1081
+ return CUDA_OCC_SUCCESS;
1082
+ }
1083
+
1084
+ ///////////////////////////////////////////////
1085
+ // User Input Sanity //
1086
+ ///////////////////////////////////////////////
1087
+
1088
+ static __OCC_INLINE cudaOccError cudaOccDevicePropCheck(const cudaOccDeviceProp *properties)
1089
+ {
1090
+ // Verify device properties
1091
+ //
1092
+ // Each of these limits must be a positive number.
1093
+ //
1094
+ // Compute capacity is checked during the occupancy calculation
1095
+ //
1096
+ if (properties->maxThreadsPerBlock <= 0 ||
1097
+ properties->maxThreadsPerMultiprocessor <= 0 ||
1098
+ properties->regsPerBlock <= 0 ||
1099
+ properties->regsPerMultiprocessor <= 0 ||
1100
+ properties->warpSize <= 0 ||
1101
+ properties->sharedMemPerBlock <= 0 ||
1102
+ properties->sharedMemPerMultiprocessor <= 0 ||
1103
+ properties->numSms <= 0) {
1104
+ return CUDA_OCC_ERROR_INVALID_INPUT;
1105
+ }
1106
+
1107
+ return CUDA_OCC_SUCCESS;
1108
+ }
1109
+
1110
+ static __OCC_INLINE cudaOccError cudaOccFuncAttributesCheck(const cudaOccFuncAttributes *attributes)
1111
+ {
1112
+ // Verify function attributes
1113
+ //
1114
+ if (attributes->maxThreadsPerBlock <= 0 ||
1115
+ attributes->numRegs < 0) { // Compiler may choose not to use
1116
+ // any register (empty kernels,
1117
+ // etc.)
1118
+ return CUDA_OCC_ERROR_INVALID_INPUT;
1119
+ }
1120
+
1121
+ return CUDA_OCC_SUCCESS;
1122
+ }
1123
+
1124
+ static __OCC_INLINE cudaOccError cudaOccDeviceStateCheck(const cudaOccDeviceState *state)
1125
+ {
1126
+ (void)state; // silence unused-variable warning
1127
+ // Placeholder
1128
+ //
1129
+
1130
+ return CUDA_OCC_SUCCESS;
1131
+ }
1132
+
1133
+ static __OCC_INLINE cudaOccError cudaOccInputCheck(
1134
+ const cudaOccDeviceProp *properties,
1135
+ const cudaOccFuncAttributes *attributes,
1136
+ const cudaOccDeviceState *state)
1137
+ {
1138
+ cudaOccError status = CUDA_OCC_SUCCESS;
1139
+
1140
+ status = cudaOccDevicePropCheck(properties);
1141
+ if (status != CUDA_OCC_SUCCESS) {
1142
+ return status;
1143
+ }
1144
+
1145
+ status = cudaOccFuncAttributesCheck(attributes);
1146
+ if (status != CUDA_OCC_SUCCESS) {
1147
+ return status;
1148
+ }
1149
+
1150
+ status = cudaOccDeviceStateCheck(state);
1151
+ if (status != CUDA_OCC_SUCCESS) {
1152
+ return status;
1153
+ }
1154
+
1155
+ return status;
1156
+ }
1157
+
1158
+ ///////////////////////////////////////////////
1159
+ // Occupancy calculation Functions //
1160
+ ///////////////////////////////////////////////
1161
+
1162
+ static __OCC_INLINE cudaOccPartitionedGCConfig cudaOccPartitionedGCExpected(
1163
+ const cudaOccDeviceProp *properties,
1164
+ const cudaOccFuncAttributes *attributes)
1165
+ {
1166
+ cudaOccPartitionedGCSupport gcSupport;
1167
+ cudaOccPartitionedGCConfig gcConfig;
1168
+
1169
+ cudaOccPartitionedGlobalCachingModeSupport(&gcSupport, properties);
1170
+
1171
+ gcConfig = attributes->partitionedGCConfig;
1172
+
1173
+ if (gcSupport == PARTITIONED_GC_NOT_SUPPORTED) {
1174
+ gcConfig = PARTITIONED_GC_OFF;
1175
+ }
1176
+
1177
+ return gcConfig;
1178
+ }
1179
+
1180
+ // Warp limit
1181
+ //
1182
+ static __OCC_INLINE cudaOccError cudaOccMaxBlocksPerSMWarpsLimit(
1183
+ int *limit,
1184
+ cudaOccPartitionedGCConfig gcConfig,
1185
+ const cudaOccDeviceProp *properties,
1186
+ const cudaOccFuncAttributes *attributes,
1187
+ int blockSize)
1188
+ {
1189
+ cudaOccError status = CUDA_OCC_SUCCESS;
1190
+ int maxWarpsPerSm;
1191
+ int warpsAllocatedPerCTA;
1192
+ int maxBlocks;
1193
+ (void)attributes; // silence unused-variable warning
1194
+
1195
+ if (blockSize > properties->maxThreadsPerBlock) {
1196
+ maxBlocks = 0;
1197
+ }
1198
+ else {
1199
+ maxWarpsPerSm = properties->maxThreadsPerMultiprocessor / properties->warpSize;
1200
+ warpsAllocatedPerCTA = __occDivideRoundUp(blockSize, properties->warpSize);
1201
+ maxBlocks = 0;
1202
+
1203
+ if (gcConfig != PARTITIONED_GC_OFF) {
1204
+ int maxBlocksPerSmPartition;
1205
+ int maxWarpsPerSmPartition;
1206
+
1207
+ // If partitioned global caching is on, then a CTA can only use a SM
1208
+ // partition (a half SM), and thus a half of the warp slots
1209
+ // available per SM
1210
+ //
1211
+ maxWarpsPerSmPartition = maxWarpsPerSm / 2;
1212
+ maxBlocksPerSmPartition = maxWarpsPerSmPartition / warpsAllocatedPerCTA;
1213
+ maxBlocks = maxBlocksPerSmPartition * 2;
1214
+ }
1215
+ // On hardware that supports partitioned global caching, each half SM is
1216
+ // guaranteed to support at least 32 warps (maximum number of warps of a
1217
+ // CTA), so caching will not cause 0 occupancy due to insufficient warp
1218
+ // allocation slots.
1219
+ //
1220
+ else {
1221
+ maxBlocks = maxWarpsPerSm / warpsAllocatedPerCTA;
1222
+ }
1223
+ }
1224
+
1225
+ *limit = maxBlocks;
1226
+
1227
+ return status;
1228
+ }
1229
+
1230
+ // Shared memory limit
1231
+ //
1232
+ static __OCC_INLINE cudaOccError cudaOccMaxBlocksPerSMSmemLimit(
1233
+ int *limit,
1234
+ cudaOccResult *result,
1235
+ const cudaOccDeviceProp *properties,
1236
+ const cudaOccFuncAttributes *attributes,
1237
+ const cudaOccDeviceState *state,
1238
+ int blockSize,
1239
+ size_t dynamicSmemSize)
1240
+ {
1241
+ cudaOccError status = CUDA_OCC_SUCCESS;
1242
+ int allocationGranularity;
1243
+ size_t userSmemPreference = 0;
1244
+ size_t totalSmemUsagePerCTA;
1245
+ size_t maxSmemUsagePerCTA;
1246
+ size_t smemAllocatedPerCTA;
1247
+ size_t staticSmemSize;
1248
+ size_t sharedMemPerMultiprocessor;
1249
+ size_t smemLimitPerCTA;
1250
+ int maxBlocks;
1251
+ int dynamicSmemSizeExceeded = 0;
1252
+ int totalSmemSizeExceeded = 0;
1253
+ (void)blockSize; // silence unused-variable warning
1254
+
1255
+ status = cudaOccSMemAllocationGranularity(&allocationGranularity, properties);
1256
+ if (status != CUDA_OCC_SUCCESS) {
1257
+ return status;
1258
+ }
1259
+
1260
+ // Obtain the user preferred shared memory size. This setting is ignored if
1261
+ // user requests more shared memory than preferred.
1262
+ //
1263
+ status = cudaOccSMemPerMultiprocessor(&userSmemPreference, properties, state);
1264
+ if (status != CUDA_OCC_SUCCESS) {
1265
+ return status;
1266
+ }
1267
+
1268
+ staticSmemSize = attributes->sharedSizeBytes + properties->reservedSharedMemPerBlock;
1269
+ totalSmemUsagePerCTA = staticSmemSize + dynamicSmemSize;
1270
+ smemAllocatedPerCTA = __occRoundUp((int)totalSmemUsagePerCTA, (int)allocationGranularity);
1271
+
1272
+ maxSmemUsagePerCTA = staticSmemSize + attributes->maxDynamicSharedSizeBytes;
1273
+
1274
+ dynamicSmemSizeExceeded = 0;
1275
+ totalSmemSizeExceeded = 0;
1276
+
1277
+ // Obtain the user set maximum dynamic size if it exists
1278
+ // If so, the current launch dynamic shared memory must not
1279
+ // exceed the set limit
1280
+ if (attributes->shmemLimitConfig != FUNC_SHMEM_LIMIT_DEFAULT &&
1281
+ dynamicSmemSize > attributes->maxDynamicSharedSizeBytes) {
1282
+ dynamicSmemSizeExceeded = 1;
1283
+ }
1284
+
1285
+ status = cudaOccSMemPerBlock(&smemLimitPerCTA, properties, attributes->shmemLimitConfig, maxSmemUsagePerCTA);
1286
+ if (status != CUDA_OCC_SUCCESS) {
1287
+ return status;
1288
+ }
1289
+
1290
+ if (smemAllocatedPerCTA > smemLimitPerCTA) {
1291
+ totalSmemSizeExceeded = 1;
1292
+ }
1293
+
1294
+ if (dynamicSmemSizeExceeded || totalSmemSizeExceeded) {
1295
+ maxBlocks = 0;
1296
+ }
1297
+ else {
1298
+ // User requested shared memory limit is used as long as it is greater
1299
+ // than the total shared memory used per CTA, i.e. as long as at least
1300
+ // one CTA can be launched.
1301
+ if (userSmemPreference >= smemAllocatedPerCTA) {
1302
+ sharedMemPerMultiprocessor = userSmemPreference;
1303
+ }
1304
+ else {
1305
+ // On Volta+, user requested shared memory will limit occupancy
1306
+ // if it's less than shared memory per CTA. Otherwise, the
1307
+ // maximum shared memory limit is used.
1308
+ if (properties->computeMajor >= 7) {
1309
+ sharedMemPerMultiprocessor = smemAllocatedPerCTA;
1310
+ status = cudaOccAlignUpShmemSizeVoltaPlus(&sharedMemPerMultiprocessor, properties);
1311
+ if (status != CUDA_OCC_SUCCESS) {
1312
+ return status;
1313
+ }
1314
+ }
1315
+ else {
1316
+ sharedMemPerMultiprocessor = properties->sharedMemPerMultiprocessor;
1317
+ }
1318
+ }
1319
+
1320
+ if (smemAllocatedPerCTA > 0) {
1321
+ maxBlocks = (int)(sharedMemPerMultiprocessor / smemAllocatedPerCTA);
1322
+ }
1323
+ else {
1324
+ maxBlocks = INT_MAX;
1325
+ }
1326
+ }
1327
+
1328
+ result->allocatedSharedMemPerBlock = smemAllocatedPerCTA;
1329
+
1330
+ *limit = maxBlocks;
1331
+
1332
+ return status;
1333
+ }
1334
+
1335
+ static __OCC_INLINE
1336
+ cudaOccError cudaOccMaxBlocksPerSMRegsLimit(
1337
+ int *limit,
1338
+ cudaOccPartitionedGCConfig *gcConfig,
1339
+ cudaOccResult *result,
1340
+ const cudaOccDeviceProp *properties,
1341
+ const cudaOccFuncAttributes *attributes,
1342
+ int blockSize)
1343
+ {
1344
+ cudaOccError status = CUDA_OCC_SUCCESS;
1345
+ int allocationGranularity;
1346
+ int warpsAllocatedPerCTA;
1347
+ int regsAllocatedPerCTA;
1348
+ int regsAssumedPerCTA;
1349
+ int regsPerWarp;
1350
+ int regsAllocatedPerWarp;
1351
+ int numSubPartitions;
1352
+ int numRegsPerSubPartition;
1353
+ int numWarpsPerSubPartition;
1354
+ int numWarpsPerSM;
1355
+ int maxBlocks;
1356
+ int maxRegsPerThread;
1357
+
1358
+ status = cudaOccRegAllocationGranularity(
1359
+ &allocationGranularity,
1360
+ properties);
1361
+ if (status != CUDA_OCC_SUCCESS) {
1362
+ return status;
1363
+ }
1364
+
1365
+ status = cudaOccRegAllocationMaxPerThread(
1366
+ &maxRegsPerThread,
1367
+ properties);
1368
+ if (status != CUDA_OCC_SUCCESS) {
1369
+ return status;
1370
+ }
1371
+
1372
+ status = cudaOccSubPartitionsPerMultiprocessor(&numSubPartitions, properties);
1373
+ if (status != CUDA_OCC_SUCCESS) {
1374
+ return status;
1375
+ }
1376
+
1377
+ warpsAllocatedPerCTA = __occDivideRoundUp(blockSize, properties->warpSize);
1378
+
1379
+ // GPUs of compute capability 2.x and higher allocate registers to warps
1380
+ //
1381
+ // Number of regs per warp is regs per thread x warp size, rounded up to
1382
+ // register allocation granularity
1383
+ //
1384
+ regsPerWarp = attributes->numRegs * properties->warpSize;
1385
+ regsAllocatedPerWarp = __occRoundUp(regsPerWarp, allocationGranularity);
1386
+ regsAllocatedPerCTA = regsAllocatedPerWarp * warpsAllocatedPerCTA;
1387
+
1388
+ // Hardware verifies if a launch fits the per-CTA register limit. For
1389
+ // historical reasons, the verification logic assumes register
1390
+ // allocations are made to all partitions simultaneously. Therefore, to
1391
+ // simulate the hardware check, the warp allocation needs to be rounded
1392
+ // up to the number of partitions.
1393
+ //
1394
+ regsAssumedPerCTA = regsAllocatedPerWarp * __occRoundUp(warpsAllocatedPerCTA, numSubPartitions);
1395
+
1396
+ if (properties->regsPerBlock < regsAssumedPerCTA || // Hardware check
1397
+ properties->regsPerBlock < regsAllocatedPerCTA || // Software check
1398
+ attributes->numRegs > maxRegsPerThread) { // Per thread limit check
1399
+ maxBlocks = 0;
1400
+ }
1401
+ else {
1402
+ if (regsAllocatedPerWarp > 0) {
1403
+ // Registers are allocated in each sub-partition. The max number
1404
+ // of warps that can fit on an SM is equal to the max number of
1405
+ // warps per sub-partition x number of sub-partitions.
1406
+ //
1407
+ numRegsPerSubPartition = properties->regsPerMultiprocessor / numSubPartitions;
1408
+ numWarpsPerSubPartition = numRegsPerSubPartition / regsAllocatedPerWarp;
1409
+
1410
+ maxBlocks = 0;
1411
+
1412
+ if (*gcConfig != PARTITIONED_GC_OFF) {
1413
+ int numSubPartitionsPerSmPartition;
1414
+ int numWarpsPerSmPartition;
1415
+ int maxBlocksPerSmPartition;
1416
+
1417
+ // If partitioned global caching is on, then a CTA can only
1418
+ // use a half SM, and thus a half of the registers available
1419
+ // per SM
1420
+ //
1421
+ numSubPartitionsPerSmPartition = numSubPartitions / 2;
1422
+ numWarpsPerSmPartition = numWarpsPerSubPartition * numSubPartitionsPerSmPartition;
1423
+ maxBlocksPerSmPartition = numWarpsPerSmPartition / warpsAllocatedPerCTA;
1424
+ maxBlocks = maxBlocksPerSmPartition * 2;
1425
+ }
1426
+
1427
+ // Try again if partitioned global caching is not enabled, or if
1428
+ // the CTA cannot fit on the SM with caching on (maxBlocks == 0). In the latter
1429
+ // case, the device will automatically turn off caching, except
1430
+ // if the user forces enablement via PARTITIONED_GC_ON_STRICT to calculate
1431
+ // occupancy and launch configuration.
1432
+ //
1433
+ if (maxBlocks == 0 && *gcConfig != PARTITIONED_GC_ON_STRICT) {
1434
+ // In case *gcConfig was PARTITIONED_GC_ON flip it OFF since
1435
+ // this is what it will be if we spread CTA across partitions.
1436
+ //
1437
+ *gcConfig = PARTITIONED_GC_OFF;
1438
+ numWarpsPerSM = numWarpsPerSubPartition * numSubPartitions;
1439
+ maxBlocks = numWarpsPerSM / warpsAllocatedPerCTA;
1440
+ }
1441
+ }
1442
+ else {
1443
+ maxBlocks = INT_MAX;
1444
+ }
1445
+ }
1446
+
1447
+
1448
+ result->allocatedRegistersPerBlock = regsAllocatedPerCTA;
1449
+
1450
+ *limit = maxBlocks;
1451
+
1452
+ return status;
1453
+ }
1454
+
1455
+ // Barrier limit
1456
+ //
1457
+ static __OCC_INLINE cudaOccError cudaOccMaxBlocksPerSMBlockBarrierLimit(
1458
+ int *limit,
1459
+ int ctaLimitBlocks,
1460
+ const cudaOccFuncAttributes *attributes)
1461
+ {
1462
+ cudaOccError status = CUDA_OCC_SUCCESS;
1463
+ int numBarriersAvailable = ctaLimitBlocks * 2;
1464
+ int numBarriersUsed = attributes->numBlockBarriers;
1465
+ int maxBlocks = INT_MAX;
1466
+
1467
+ if (numBarriersUsed) {
1468
+ maxBlocks = numBarriersAvailable / numBarriersUsed;
1469
+ }
1470
+
1471
+ *limit = maxBlocks;
1472
+
1473
+ return status;
1474
+ }
1475
+
1476
+ ///////////////////////////////////
1477
+ // API Implementations //
1478
+ ///////////////////////////////////
1479
+
1480
+ static __OCC_INLINE
1481
+ cudaOccError cudaOccMaxActiveBlocksPerMultiprocessor(
1482
+ cudaOccResult *result,
1483
+ const cudaOccDeviceProp *properties,
1484
+ const cudaOccFuncAttributes *attributes,
1485
+ const cudaOccDeviceState *state,
1486
+ int blockSize,
1487
+ size_t dynamicSmemSize)
1488
+ {
1489
+ cudaOccError status = CUDA_OCC_SUCCESS;
1490
+ int ctaLimitWarps = 0;
1491
+ int ctaLimitBlocks = 0;
1492
+ int ctaLimitSMem = 0;
1493
+ int ctaLimitRegs = 0;
1494
+ int ctaLimitBars = 0;
1495
+ int ctaLimit = 0;
1496
+ unsigned int limitingFactors = 0;
1497
+
1498
+ cudaOccPartitionedGCConfig gcConfig = PARTITIONED_GC_OFF;
1499
+
1500
+ if (!result || !properties || !attributes || !state || blockSize <= 0) {
1501
+ return CUDA_OCC_ERROR_INVALID_INPUT;
1502
+ }
1503
+
1504
+ ///////////////////////////
1505
+ // Check user input
1506
+ ///////////////////////////
1507
+
1508
+ status = cudaOccInputCheck(properties, attributes, state);
1509
+ if (status != CUDA_OCC_SUCCESS) {
1510
+ return status;
1511
+ }
1512
+
1513
+ ///////////////////////////
1514
+ // Initialization
1515
+ ///////////////////////////
1516
+
1517
+ gcConfig = cudaOccPartitionedGCExpected(properties, attributes);
1518
+
1519
+ ///////////////////////////
1520
+ // Compute occupancy
1521
+ ///////////////////////////
1522
+
1523
+ // Limits due to registers/SM
1524
+ // Also compute if partitioned global caching has to be turned off
1525
+ //
1526
+ status = cudaOccMaxBlocksPerSMRegsLimit(&ctaLimitRegs, &gcConfig, result, properties, attributes, blockSize);
1527
+ if (status != CUDA_OCC_SUCCESS) {
1528
+ return status;
1529
+ }
1530
+
1531
+ // SMs on GP100 (6.0) have 2 subpartitions, while those on GP10x have 4.
1532
+ // As a result, an SM on GP100 may be able to run more CTAs than the one on GP10x.
1533
+ // For forward compatibility within Pascal family, if a function cannot run on GP10x (maxBlock == 0),
1534
+ // we do not let it run on any Pascal processor, even though it may be able to run on GP100.
1535
+ // Therefore, we check the occupancy on GP10x when it can run on GP100
1536
+ //
1537
+ if (properties->computeMajor == 6 && properties->computeMinor == 0 && ctaLimitRegs) {
1538
+ cudaOccDeviceProp propertiesGP10x;
1539
+ cudaOccPartitionedGCConfig gcConfigGP10x = gcConfig;
1540
+ int ctaLimitRegsGP10x = 0;
1541
+
1542
+ // Set up properties for GP10x
1543
+ memcpy(&propertiesGP10x, properties, sizeof(propertiesGP10x));
1544
+ propertiesGP10x.computeMinor = 1;
1545
+
1546
+ status = cudaOccMaxBlocksPerSMRegsLimit(&ctaLimitRegsGP10x, &gcConfigGP10x, result, &propertiesGP10x, attributes, blockSize);
1547
+ if (status != CUDA_OCC_SUCCESS) {
1548
+ return status;
1549
+ }
1550
+
1551
+ if (ctaLimitRegsGP10x == 0) {
1552
+ ctaLimitRegs = 0;
1553
+ }
1554
+ }
1555
+
1556
+ // Limits due to warps/SM
1557
+ //
1558
+ status = cudaOccMaxBlocksPerSMWarpsLimit(&ctaLimitWarps, gcConfig, properties, attributes, blockSize);
1559
+ if (status != CUDA_OCC_SUCCESS) {
1560
+ return status;
1561
+ }
1562
+
1563
+ // Limits due to blocks/SM
1564
+ //
1565
+ status = cudaOccMaxBlocksPerMultiprocessor(&ctaLimitBlocks, properties);
1566
+ if (status != CUDA_OCC_SUCCESS) {
1567
+ return status;
1568
+ }
1569
+
1570
+ // Limits due to shared memory/SM
1571
+ //
1572
+ status = cudaOccMaxBlocksPerSMSmemLimit(&ctaLimitSMem, result, properties, attributes, state, blockSize, dynamicSmemSize);
1573
+ if (status != CUDA_OCC_SUCCESS) {
1574
+ return status;
1575
+ }
1576
+
1577
+ ///////////////////////////
1578
+ // Overall occupancy
1579
+ ///////////////////////////
1580
+
1581
+ // Overall limit is min() of limits due to above reasons
1582
+ //
1583
+ ctaLimit = __occMin(ctaLimitRegs, __occMin(ctaLimitSMem, __occMin(ctaLimitWarps, ctaLimitBlocks)));
1584
+
1585
+ // Determine occupancy limiting factors
1586
+ //
1587
+ if (ctaLimit == ctaLimitWarps) {
1588
+ limitingFactors |= OCC_LIMIT_WARPS;
1589
+ }
1590
+ if (ctaLimit == ctaLimitRegs) {
1591
+ limitingFactors |= OCC_LIMIT_REGISTERS;
1592
+ }
1593
+ if (ctaLimit == ctaLimitSMem) {
1594
+ limitingFactors |= OCC_LIMIT_SHARED_MEMORY;
1595
+ }
1596
+ if (ctaLimit == ctaLimitBlocks) {
1597
+ limitingFactors |= OCC_LIMIT_BLOCKS;
1598
+ }
1599
+
1600
+ // For Hopper onwards compute the limits to occupancy based on block barrier count
1601
+ //
1602
+ if (properties->computeMajor >= 9 && attributes->numBlockBarriers > 0) {
1603
+ // Limits due to barrier/SM
1604
+ //
1605
+ status = cudaOccMaxBlocksPerSMBlockBarrierLimit(&ctaLimitBars, ctaLimitBlocks, attributes);
1606
+ if (status != CUDA_OCC_SUCCESS) {
1607
+ return status;
1608
+ }
1609
+
1610
+ // Recompute overall limit based on barrier/SM
1611
+ //
1612
+ ctaLimit = __occMin(ctaLimitBars, ctaLimit);
1613
+
1614
+ // Determine if this is occupancy limiting factor
1615
+ //
1616
+ if (ctaLimit == ctaLimitBars) {
1617
+ limitingFactors |= OCC_LIMIT_BARRIERS;
1618
+ }
1619
+ }
1620
+ else {
1621
+ ctaLimitBars = INT_MAX;
1622
+ }
1623
+
1624
+ // Fill in the return values
1625
+ //
1626
+ result->limitingFactors = limitingFactors;
1627
+
1628
+ result->blockLimitRegs = ctaLimitRegs;
1629
+ result->blockLimitSharedMem = ctaLimitSMem;
1630
+ result->blockLimitWarps = ctaLimitWarps;
1631
+ result->blockLimitBlocks = ctaLimitBlocks;
1632
+ result->blockLimitBarriers = ctaLimitBars;
1633
+ result->partitionedGCConfig = gcConfig;
1634
+
1635
+ // Final occupancy
1636
+ result->activeBlocksPerMultiprocessor = ctaLimit;
1637
+
1638
+ return CUDA_OCC_SUCCESS;
1639
+ }
1640
+
1641
+ static __OCC_INLINE
1642
+ cudaOccError cudaOccAvailableDynamicSMemPerBlock(
1643
+ size_t *bytesAvailable,
1644
+ const cudaOccDeviceProp *properties,
1645
+ const cudaOccFuncAttributes *attributes,
1646
+ const cudaOccDeviceState *state,
1647
+ int numBlocks,
1648
+ int blockSize)
1649
+ {
1650
+ int allocationGranularity;
1651
+ size_t smemLimitPerBlock;
1652
+ size_t smemAvailableForDynamic;
1653
+ size_t userSmemPreference = 0;
1654
+ size_t sharedMemPerMultiprocessor;
1655
+ cudaOccResult result;
1656
+ cudaOccError status = CUDA_OCC_SUCCESS;
1657
+
1658
+ if (numBlocks <= 0)
1659
+ return CUDA_OCC_ERROR_INVALID_INPUT;
1660
+
1661
+ // First compute occupancy of potential kernel launch.
1662
+ //
1663
+ status = cudaOccMaxActiveBlocksPerMultiprocessor(&result, properties, attributes, state, blockSize, 0);
1664
+ if (status != CUDA_OCC_SUCCESS) {
1665
+ return status;
1666
+ }
1667
+ // Check if occupancy is achievable given user requested number of blocks.
1668
+ //
1669
+ if (result.activeBlocksPerMultiprocessor < numBlocks) {
1670
+ return CUDA_OCC_ERROR_INVALID_INPUT;
1671
+ }
1672
+
1673
+ status = cudaOccSMemAllocationGranularity(&allocationGranularity, properties);
1674
+ if (status != CUDA_OCC_SUCCESS) {
1675
+ return status;
1676
+ }
1677
+
1678
+ // Return the per block shared memory limit based on function config.
1679
+ //
1680
+ status = cudaOccSMemPerBlock(&smemLimitPerBlock, properties, attributes->shmemLimitConfig, properties->sharedMemPerMultiprocessor);
1681
+ if (status != CUDA_OCC_SUCCESS) {
1682
+ return status;
1683
+ }
1684
+
1685
+ // If there is only a single block needed per SM, then the user preference can be ignored and the fully SW
1686
+ // limit is allowed to be used as shared memory otherwise if more than one block is needed, then the user
1687
+ // preference sets the total limit of available shared memory.
1688
+ //
1689
+ cudaOccSMemPerMultiprocessor(&userSmemPreference, properties, state);
1690
+ if (numBlocks == 1) {
1691
+ sharedMemPerMultiprocessor = smemLimitPerBlock;
1692
+ }
1693
+ else {
1694
+ if (!userSmemPreference) {
1695
+ userSmemPreference = 1 ;
1696
+ status = cudaOccAlignUpShmemSizeVoltaPlus(&userSmemPreference, properties);
1697
+ if (status != CUDA_OCC_SUCCESS) {
1698
+ return status;
1699
+ }
1700
+ }
1701
+ sharedMemPerMultiprocessor = userSmemPreference;
1702
+ }
1703
+
1704
+ // Compute total shared memory available per SM
1705
+ //
1706
+ smemAvailableForDynamic = sharedMemPerMultiprocessor / numBlocks;
1707
+ smemAvailableForDynamic = (smemAvailableForDynamic / allocationGranularity) * allocationGranularity;
1708
+
1709
+ // Cap shared memory
1710
+ //
1711
+ if (smemAvailableForDynamic > smemLimitPerBlock) {
1712
+ smemAvailableForDynamic = smemLimitPerBlock;
1713
+ }
1714
+
1715
+ // Now compute dynamic shared memory size
1716
+ smemAvailableForDynamic = smemAvailableForDynamic - attributes->sharedSizeBytes;
1717
+
1718
+ // Cap computed dynamic SM by user requested limit specified via cuFuncSetAttribute()
1719
+ //
1720
+ if (smemAvailableForDynamic > attributes->maxDynamicSharedSizeBytes)
1721
+ smemAvailableForDynamic = attributes->maxDynamicSharedSizeBytes;
1722
+
1723
+ *bytesAvailable = smemAvailableForDynamic;
1724
+ return CUDA_OCC_SUCCESS;
1725
+ }
1726
+
1727
+ static __OCC_INLINE
1728
+ cudaOccError cudaOccMaxPotentialOccupancyBlockSize(
1729
+ int *minGridSize,
1730
+ int *blockSize,
1731
+ const cudaOccDeviceProp *properties,
1732
+ const cudaOccFuncAttributes *attributes,
1733
+ const cudaOccDeviceState *state,
1734
+ size_t (*blockSizeToDynamicSMemSize)(int),
1735
+ size_t dynamicSMemSize)
1736
+ {
1737
+ cudaOccError status = CUDA_OCC_SUCCESS;
1738
+ cudaOccResult result;
1739
+
1740
+ // Limits
1741
+ int occupancyLimit;
1742
+ int granularity;
1743
+ int blockSizeLimit;
1744
+
1745
+ // Recorded maximum
1746
+ int maxBlockSize = 0;
1747
+ int numBlocks = 0;
1748
+ int maxOccupancy = 0;
1749
+
1750
+ // Temporary
1751
+ int blockSizeToTryAligned;
1752
+ int blockSizeToTry;
1753
+ int blockSizeLimitAligned;
1754
+ int occupancyInBlocks;
1755
+ int occupancyInThreads;
1756
+
1757
+ ///////////////////////////
1758
+ // Check user input
1759
+ ///////////////////////////
1760
+
1761
+ if (!minGridSize || !blockSize || !properties || !attributes || !state) {
1762
+ return CUDA_OCC_ERROR_INVALID_INPUT;
1763
+ }
1764
+
1765
+ status = cudaOccInputCheck(properties, attributes, state);
1766
+ if (status != CUDA_OCC_SUCCESS) {
1767
+ return status;
1768
+ }
1769
+
1770
+ /////////////////////////////////////////////////////////////////////////////////
1771
+ // Try each block size, and pick the block size with maximum occupancy
1772
+ /////////////////////////////////////////////////////////////////////////////////
1773
+
1774
+ occupancyLimit = properties->maxThreadsPerMultiprocessor;
1775
+ granularity = properties->warpSize;
1776
+
1777
+ blockSizeLimit = __occMin(properties->maxThreadsPerBlock, attributes->maxThreadsPerBlock);
1778
+ blockSizeLimitAligned = __occRoundUp(blockSizeLimit, granularity);
1779
+
1780
+ for (blockSizeToTryAligned = blockSizeLimitAligned; blockSizeToTryAligned > 0; blockSizeToTryAligned -= granularity) {
1781
+ blockSizeToTry = __occMin(blockSizeLimit, blockSizeToTryAligned);
1782
+
1783
+ // Ignore dynamicSMemSize if the user provides a mapping
1784
+ //
1785
+ if (blockSizeToDynamicSMemSize) {
1786
+ dynamicSMemSize = (*blockSizeToDynamicSMemSize)(blockSizeToTry);
1787
+ }
1788
+
1789
+ status = cudaOccMaxActiveBlocksPerMultiprocessor(
1790
+ &result,
1791
+ properties,
1792
+ attributes,
1793
+ state,
1794
+ blockSizeToTry,
1795
+ dynamicSMemSize);
1796
+
1797
+ if (status != CUDA_OCC_SUCCESS) {
1798
+ return status;
1799
+ }
1800
+
1801
+ occupancyInBlocks = result.activeBlocksPerMultiprocessor;
1802
+ occupancyInThreads = blockSizeToTry * occupancyInBlocks;
1803
+
1804
+ if (occupancyInThreads > maxOccupancy) {
1805
+ maxBlockSize = blockSizeToTry;
1806
+ numBlocks = occupancyInBlocks;
1807
+ maxOccupancy = occupancyInThreads;
1808
+ }
1809
+
1810
+ // Early out if we have reached the maximum
1811
+ //
1812
+ if (occupancyLimit == maxOccupancy) {
1813
+ break;
1814
+ }
1815
+ }
1816
+
1817
+ ///////////////////////////
1818
+ // Return best available
1819
+ ///////////////////////////
1820
+
1821
+ // Suggested min grid size to achieve a full machine launch
1822
+ //
1823
+ *minGridSize = numBlocks * properties->numSms;
1824
+ *blockSize = maxBlockSize;
1825
+
1826
+ return status;
1827
+ }
1828
+
1829
+
1830
+ #if defined(__cplusplus)
1831
+
1832
+ namespace {
1833
+
1834
+ __OCC_INLINE
1835
+ cudaOccError cudaOccMaxPotentialOccupancyBlockSize(
1836
+ int *minGridSize,
1837
+ int *blockSize,
1838
+ const cudaOccDeviceProp *properties,
1839
+ const cudaOccFuncAttributes *attributes,
1840
+ const cudaOccDeviceState *state,
1841
+ size_t dynamicSMemSize)
1842
+ {
1843
+ return cudaOccMaxPotentialOccupancyBlockSize(
1844
+ minGridSize,
1845
+ blockSize,
1846
+ properties,
1847
+ attributes,
1848
+ state,
1849
+ NULL,
1850
+ dynamicSMemSize);
1851
+ }
1852
+
1853
+ template <typename UnaryFunction>
1854
+ __OCC_INLINE
1855
+ cudaOccError cudaOccMaxPotentialOccupancyBlockSizeVariableSMem(
1856
+ int *minGridSize,
1857
+ int *blockSize,
1858
+ const cudaOccDeviceProp *properties,
1859
+ const cudaOccFuncAttributes *attributes,
1860
+ const cudaOccDeviceState *state,
1861
+ UnaryFunction blockSizeToDynamicSMemSize)
1862
+ {
1863
+ cudaOccError status = CUDA_OCC_SUCCESS;
1864
+ cudaOccResult result;
1865
+
1866
+ // Limits
1867
+ int occupancyLimit;
1868
+ int granularity;
1869
+ int blockSizeLimit;
1870
+
1871
+ // Recorded maximum
1872
+ int maxBlockSize = 0;
1873
+ int numBlocks = 0;
1874
+ int maxOccupancy = 0;
1875
+
1876
+ // Temporary
1877
+ int blockSizeToTryAligned;
1878
+ int blockSizeToTry;
1879
+ int blockSizeLimitAligned;
1880
+ int occupancyInBlocks;
1881
+ int occupancyInThreads;
1882
+ size_t dynamicSMemSize;
1883
+
1884
+ ///////////////////////////
1885
+ // Check user input
1886
+ ///////////////////////////
1887
+
1888
+ if (!minGridSize || !blockSize || !properties || !attributes || !state) {
1889
+ return CUDA_OCC_ERROR_INVALID_INPUT;
1890
+ }
1891
+
1892
+ status = cudaOccInputCheck(properties, attributes, state);
1893
+ if (status != CUDA_OCC_SUCCESS) {
1894
+ return status;
1895
+ }
1896
+
1897
+ /////////////////////////////////////////////////////////////////////////////////
1898
+ // Try each block size, and pick the block size with maximum occupancy
1899
+ /////////////////////////////////////////////////////////////////////////////////
1900
+
1901
+ occupancyLimit = properties->maxThreadsPerMultiprocessor;
1902
+ granularity = properties->warpSize;
1903
+ blockSizeLimit = __occMin(properties->maxThreadsPerBlock, attributes->maxThreadsPerBlock);
1904
+ blockSizeLimitAligned = __occRoundUp(blockSizeLimit, granularity);
1905
+
1906
+ for (blockSizeToTryAligned = blockSizeLimitAligned; blockSizeToTryAligned > 0; blockSizeToTryAligned -= granularity) {
1907
+ blockSizeToTry = __occMin(blockSizeLimit, blockSizeToTryAligned);
1908
+
1909
+ dynamicSMemSize = blockSizeToDynamicSMemSize(blockSizeToTry);
1910
+
1911
+ status = cudaOccMaxActiveBlocksPerMultiprocessor(
1912
+ &result,
1913
+ properties,
1914
+ attributes,
1915
+ state,
1916
+ blockSizeToTry,
1917
+ dynamicSMemSize);
1918
+
1919
+ if (status != CUDA_OCC_SUCCESS) {
1920
+ return status;
1921
+ }
1922
+
1923
+ occupancyInBlocks = result.activeBlocksPerMultiprocessor;
1924
+
1925
+ occupancyInThreads = blockSizeToTry * occupancyInBlocks;
1926
+
1927
+ if (occupancyInThreads > maxOccupancy) {
1928
+ maxBlockSize = blockSizeToTry;
1929
+ numBlocks = occupancyInBlocks;
1930
+ maxOccupancy = occupancyInThreads;
1931
+ }
1932
+
1933
+ // Early out if we have reached the maximum
1934
+ //
1935
+ if (occupancyLimit == maxOccupancy) {
1936
+ break;
1937
+ }
1938
+ }
1939
+
1940
+ ///////////////////////////
1941
+ // Return best available
1942
+ ///////////////////////////
1943
+
1944
+ // Suggested min grid size to achieve a full machine launch
1945
+ //
1946
+ *minGridSize = numBlocks * properties->numSms;
1947
+ *blockSize = maxBlockSize;
1948
+
1949
+ return status;
1950
+ }
1951
+
1952
+ } // namespace anonymous
1953
+
1954
+ #endif /*__cplusplus */
1955
+
1956
+ #undef __OCC_INLINE
1957
+
1958
+ #endif /*__cuda_occupancy_h__*/
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_pipeline.h ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #ifndef _CUDA_PIPELINE_H_
51
+ # define _CUDA_PIPELINE_H_
52
+
53
+ # include "cuda_pipeline_primitives.h"
54
+
55
+ # if !defined(_CUDA_PIPELINE_CPLUSPLUS_11_OR_LATER)
56
+ # error This file requires compiler support for the ISO C++ 2011 standard. This support must be enabled with the \
57
+ -std=c++11 compiler option.
58
+ # endif
59
+
60
+ # if defined(_CUDA_PIPELINE_ARCH_700_OR_LATER)
61
+ # include "cuda_awbarrier.h"
62
+ # endif
63
+
64
+ // Integration with libcu++'s cuda::barrier<cuda::thread_scope_block>.
65
+
66
+ # if defined(_CUDA_PIPELINE_ARCH_700_OR_LATER)
67
+ # if defined(_LIBCUDACXX_CUDA_ABI_VERSION)
68
+ # define _LIBCUDACXX_PIPELINE_ASSUMED_ABI_VERSION _LIBCUDACXX_CUDA_ABI_VERSION
69
+ # else
70
+ # define _LIBCUDACXX_PIPELINE_ASSUMED_ABI_VERSION 4
71
+ # endif
72
+
73
+ # define _LIBCUDACXX_PIPELINE_CONCAT(X, Y) X ## Y
74
+ # define _LIBCUDACXX_PIPELINE_CONCAT2(X, Y) _LIBCUDACXX_PIPELINE_CONCAT(X, Y)
75
+ # define _LIBCUDACXX_PIPELINE_INLINE_NAMESPACE _LIBCUDACXX_PIPELINE_CONCAT2(__, _LIBCUDACXX_PIPELINE_ASSUMED_ABI_VERSION)
76
+
77
+ namespace cuda { inline namespace _LIBCUDACXX_PIPELINE_INLINE_NAMESPACE {
78
+ struct __block_scope_barrier_base;
79
+ }}
80
+
81
+ # endif
82
+
83
+ _CUDA_PIPELINE_BEGIN_NAMESPACE
84
+
85
+ template<size_t N, typename T>
86
+ _CUDA_PIPELINE_QUALIFIER
87
+ auto segment(T* ptr) -> T(*)[N];
88
+
89
+ class pipeline {
90
+ public:
91
+ pipeline(const pipeline&) = delete;
92
+ pipeline(pipeline&&) = delete;
93
+ pipeline& operator=(const pipeline&) = delete;
94
+ pipeline& operator=(pipeline&&) = delete;
95
+
96
+ _CUDA_PIPELINE_QUALIFIER pipeline();
97
+ _CUDA_PIPELINE_QUALIFIER size_t commit();
98
+ _CUDA_PIPELINE_QUALIFIER void commit_and_wait();
99
+ _CUDA_PIPELINE_QUALIFIER void wait(size_t batch);
100
+ template<unsigned N>
101
+ _CUDA_PIPELINE_QUALIFIER void wait_prior();
102
+
103
+ # if defined(_CUDA_PIPELINE_ARCH_700_OR_LATER)
104
+ _CUDA_PIPELINE_QUALIFIER void arrive_on(awbarrier& barrier);
105
+ _CUDA_PIPELINE_QUALIFIER void arrive_on(cuda::__block_scope_barrier_base& barrier);
106
+ # endif
107
+
108
+ private:
109
+ size_t current_batch;
110
+ };
111
+
112
+ template<class T>
113
+ _CUDA_PIPELINE_QUALIFIER
114
+ void memcpy_async(T& dst, const T& src, pipeline& pipe);
115
+
116
+ template<class T, size_t DstN, size_t SrcN>
117
+ _CUDA_PIPELINE_QUALIFIER
118
+ void memcpy_async(T(*dst)[DstN], const T(*src)[SrcN], pipeline& pipe);
119
+
120
+ template<size_t N, typename T>
121
+ _CUDA_PIPELINE_QUALIFIER
122
+ auto segment(T* ptr) -> T(*)[N]
123
+ {
124
+ return (T(*)[N])ptr;
125
+ }
126
+
127
+ _CUDA_PIPELINE_QUALIFIER
128
+ pipeline::pipeline()
129
+ : current_batch(0)
130
+ {
131
+ }
132
+
133
+ _CUDA_PIPELINE_QUALIFIER
134
+ size_t pipeline::commit()
135
+ {
136
+ _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_commit();
137
+ return this->current_batch++;
138
+ }
139
+
140
+ _CUDA_PIPELINE_QUALIFIER
141
+ void pipeline::commit_and_wait()
142
+ {
143
+ (void)pipeline::commit();
144
+ pipeline::wait_prior<0>();
145
+ }
146
+
147
+ _CUDA_PIPELINE_QUALIFIER
148
+ void pipeline::wait(size_t batch)
149
+ {
150
+ const size_t prior = this->current_batch > batch ? this->current_batch - batch : 0;
151
+
152
+ switch (prior) {
153
+ case 0 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<0>(); break;
154
+ case 1 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<1>(); break;
155
+ case 2 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<2>(); break;
156
+ case 3 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<3>(); break;
157
+ case 4 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<4>(); break;
158
+ case 5 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<5>(); break;
159
+ case 6 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<6>(); break;
160
+ case 7 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<7>(); break;
161
+ default : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<8>(); break;
162
+ }
163
+ }
164
+
165
+ template<unsigned N>
166
+ _CUDA_PIPELINE_QUALIFIER
167
+ void pipeline::wait_prior()
168
+ {
169
+ _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<N>();
170
+ }
171
+
172
+ # if defined(_CUDA_PIPELINE_ARCH_700_OR_LATER)
173
+ _CUDA_PIPELINE_QUALIFIER
174
+ void pipeline::arrive_on(awbarrier& barrier)
175
+ {
176
+ _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_arrive_on(&barrier.barrier);
177
+ }
178
+
179
+ _CUDA_PIPELINE_QUALIFIER
180
+ void pipeline::arrive_on(cuda::__block_scope_barrier_base & barrier)
181
+ {
182
+ _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_arrive_on(reinterpret_cast<uint64_t *>(&barrier));
183
+ }
184
+ # endif
185
+
186
+ template<class T>
187
+ _CUDA_PIPELINE_QUALIFIER
188
+ void memcpy_async(T& dst, const T& src, pipeline& pipe)
189
+ {
190
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(&src) & (alignof(T) - 1)));
191
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(&dst) & (alignof(T) - 1)));
192
+
193
+ if (__is_trivially_copyable(T)) {
194
+ _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_copy_relaxed<sizeof(T), alignof(T)>(
195
+ reinterpret_cast<void*>(&dst), reinterpret_cast<const void*>(&src));
196
+ } else {
197
+ dst = src;
198
+ }
199
+ }
200
+
201
+ template<class T, size_t DstN, size_t SrcN>
202
+ _CUDA_PIPELINE_QUALIFIER
203
+ void memcpy_async(T(*dst)[DstN], const T(*src)[SrcN], pipeline& pipe)
204
+ {
205
+ constexpr size_t dst_size = sizeof(*dst);
206
+ constexpr size_t src_size = sizeof(*src);
207
+ static_assert(dst_size == 4 || dst_size == 8 || dst_size == 16, "Unsupported copy size.");
208
+ static_assert(src_size <= dst_size, "Source size must be less than or equal to destination size.");
209
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (dst_size - 1)));
210
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (dst_size - 1)));
211
+
212
+ if (__is_trivially_copyable(T)) {
213
+ _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_copy_strict<sizeof(*dst), sizeof(*src)>(
214
+ reinterpret_cast<void*>(*dst), reinterpret_cast<const void*>(*src));
215
+ } else {
216
+ for (size_t i = 0; i < DstN; ++i) {
217
+ (*dst)[i] = (i < SrcN) ? (*src)[i] : T();
218
+ }
219
+ }
220
+ }
221
+
222
+ _CUDA_PIPELINE_END_NAMESPACE
223
+
224
+ #endif /* !_CUDA_PIPELINE_H_ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_pipeline_helpers.h ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #ifndef _CUDA_PIPELINE_HELPERS_H_
51
+ # define _CUDA_PIPELINE_HELPERS_H_
52
+
53
+ # define _CUDA_PIPELINE_NAMESPACE nvcuda::experimental
54
+ # define _CUDA_PIPELINE_BEGIN_NAMESPACE namespace nvcuda { namespace experimental {
55
+ # define _CUDA_PIPELINE_END_NAMESPACE } }
56
+
57
+ # define _CUDA_PIPELINE_INTERNAL_NAMESPACE _CUDA_PIPELINE_NAMESPACE::__pipeline_internal
58
+ # define _CUDA_PIPELINE_BEGIN_INTERNAL_NAMESPACE _CUDA_PIPELINE_BEGIN_NAMESPACE namespace __pipeline_internal {
59
+ # define _CUDA_PIPELINE_END_INTERNAL_NAMESPACE } _CUDA_PIPELINE_END_NAMESPACE
60
+
61
+ # if !defined(_CUDA_PIPELINE_QUALIFIER)
62
+ # define _CUDA_PIPELINE_QUALIFIER inline __device__
63
+ # endif
64
+ # if !defined(_CUDA_PIPELINE_STATIC_QUALIFIER)
65
+ # define _CUDA_PIPELINE_STATIC_QUALIFIER static inline __device__
66
+ # endif
67
+
68
+ # if defined(_NVHPC_CUDA) || !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 700)
69
+ # define _CUDA_PIPELINE_ARCH_700_OR_LATER
70
+ # endif
71
+
72
+ # if (__CUDA_ARCH__ >= 800)
73
+ # define _CUDA_PIPELINE_HAS_ASYNC_COPY 1
74
+ # else
75
+ # define _CUDA_PIPELINE_HAS_ASYNC_COPY 0
76
+ # endif
77
+
78
+ # if !defined(_CUDA_PIPELINE_MAX_STAGES)
79
+ # define _CUDA_PIPELINE_MAX_STAGES 8
80
+ # endif
81
+
82
+ # if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1900)))
83
+ # define _CUDA_PIPELINE_CPLUSPLUS_11_OR_LATER
84
+ # endif
85
+
86
+ # if !defined(_CUDA_PIPELINE_DEBUG)
87
+ # if defined(__CUDACC_DEBUG__)
88
+ # define _CUDA_PIPELINE_DEBUG 1
89
+ # else
90
+ # define _CUDA_PIPELINE_DEBUG 0
91
+ # endif
92
+ # endif
93
+
94
+ # if defined(_CUDA_PIPELINE_DEBUG) && (_CUDA_PIPELINE_DEBUG == 1) && !defined(NDEBUG)
95
+ # if !defined(__CUDACC_RTC__)
96
+ # include <cassert>
97
+ # endif
98
+ # define _CUDA_PIPELINE_ASSERT(x) assert((x));
99
+ # define _CUDA_PIPELINE_ABORT() assert(0);
100
+ # else
101
+ # define _CUDA_PIPELINE_ASSERT(x)
102
+ # define _CUDA_PIPELINE_ABORT() __trap();
103
+ # endif
104
+
105
+ # if defined(_CUDA_PIPELINE_CPLUSPLUS_11_OR_LATER)
106
+ # define _CUDA_PIPELINE_STATIC_ASSERT(c, m) static_assert(c, m)
107
+ # else
108
+ # define _CUDA_PIPELINE_STATIC_ASSERT(c, m)
109
+ # endif
110
+
111
+ # if (defined(_MSC_VER) && !defined(_WIN64)) || defined(__arm__)
112
+ # define _CUDA_PIPELINE_ASM_PTR_CONSTRAINT "r"
113
+ # else
114
+ # define _CUDA_PIPELINE_ASM_PTR_CONSTRAINT "l"
115
+ # endif
116
+
117
+ # if defined(__CUDACC_RTC__)
118
+ typedef unsigned int uint32_t;
119
+ typedef unsigned long long uint64_t;
120
+ typedef uint64_t uintptr_t;
121
+ # else
122
+ # include <stdint.h>
123
+ # endif
124
+
125
+ _CUDA_PIPELINE_BEGIN_INTERNAL_NAMESPACE
126
+
127
+ _CUDA_PIPELINE_STATIC_ASSERT(sizeof(short) == 2, "Size mismatch for type 'short'");
128
+ _CUDA_PIPELINE_STATIC_ASSERT(sizeof(int) == 4, "Size mismatch for type 'int'");
129
+ _CUDA_PIPELINE_STATIC_ASSERT(sizeof(int2) == 8, "Size mismatch for type 'int2'");
130
+ _CUDA_PIPELINE_STATIC_ASSERT(sizeof(int4) == 16, "Size mismatch for type 'int4'");
131
+
132
+ extern "C" __device__ uint32_t __nvvm_get_smem_pointer(void *);
133
+
134
+ template<size_t CopySize, size_t SourceSize>
135
+ _CUDA_PIPELINE_QUALIFIER
136
+ void pipeline_memcpy_sync(void* __restrict__ dst, const void* __restrict__ src)
137
+ {
138
+ _CUDA_PIPELINE_STATIC_ASSERT(CopySize == 4 || CopySize == 8 || CopySize == 16, "Unsupported copy size.");
139
+ _CUDA_PIPELINE_STATIC_ASSERT(SourceSize <= CopySize, "Source size must be less than or equal to copy size");
140
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (CopySize - 1)));
141
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (CopySize - 1)));
142
+
143
+ char* const d = reinterpret_cast<char*>(dst);
144
+ const char* const s = reinterpret_cast<const char*>(src);
145
+
146
+ size_t copy_step_size;
147
+ if (SourceSize == 0) {
148
+ copy_step_size = CopySize;
149
+ } else if (SourceSize == 2 || SourceSize == 4 || SourceSize == 8 || SourceSize == 16) {
150
+ copy_step_size = SourceSize;
151
+ } else {
152
+ copy_step_size = 1;
153
+ }
154
+
155
+ for (size_t i = 0; i < CopySize; i += copy_step_size) {
156
+ const bool copy_source = SourceSize && (i < SourceSize);
157
+
158
+ switch (copy_step_size) {
159
+ case 1:
160
+ d[i] = copy_source ? s[i] : char();
161
+ break;
162
+ case 2:
163
+ *reinterpret_cast<short*>(d + i) = copy_source ? *reinterpret_cast<const short*>(s + i) : short();
164
+ break;
165
+ case 4:
166
+ *reinterpret_cast<int*>(d + i) = copy_source ? *reinterpret_cast<const int*>(s + i) : int();
167
+ break;
168
+ case 8:
169
+ *reinterpret_cast<int2*>(d + i) = copy_source ? *reinterpret_cast<const int2*>(s + i) : int2();
170
+ break;
171
+ case 16:
172
+ *reinterpret_cast<int4*>(d + i) = copy_source ? *reinterpret_cast<const int4*>(s + i) : int4();
173
+ break;
174
+ }
175
+ }
176
+ }
177
+
178
+ template<bool UseHwAsyncCopy>
179
+ struct ImplementationChooser;
180
+
181
+ template<>
182
+ struct ImplementationChooser<true> {
183
+ template<size_t CopySize, size_t SourceSize>
184
+ struct CpAsyncChooser {
185
+ _CUDA_PIPELINE_STATIC_QUALIFIER
186
+ void cp_async(void* __restrict__ dst, const void* __restrict__ src)
187
+ {
188
+ asm volatile ("cp.async.ca.shared.global [%0], [%1], %2, %3;"
189
+ :
190
+ : "r"(__nvvm_get_smem_pointer(dst)), _CUDA_PIPELINE_ASM_PTR_CONSTRAINT(src), "n"(CopySize),
191
+ "n"(SourceSize)
192
+ : "memory");
193
+ }
194
+ };
195
+
196
+ template<size_t SourceSize>
197
+ struct CpAsyncChooser<16, SourceSize> {
198
+ _CUDA_PIPELINE_STATIC_QUALIFIER
199
+ void cp_async(void* __restrict__ dst, const void* __restrict__ src)
200
+ {
201
+ asm volatile ("cp.async.cg.shared.global [%0], [%1], %2, %3;"
202
+ :
203
+ : "r"(__nvvm_get_smem_pointer(dst)), _CUDA_PIPELINE_ASM_PTR_CONSTRAINT(src), "n"(16), "n"(SourceSize)
204
+ : "memory");
205
+ }
206
+ };
207
+
208
+ template<size_t CopySize, size_t SourceSize>
209
+ _CUDA_PIPELINE_STATIC_QUALIFIER
210
+ void pipeline_memcpy_async(void* __restrict__ dst, const void* __restrict__ src)
211
+ {
212
+ _CUDA_PIPELINE_STATIC_ASSERT(CopySize == 4 || CopySize == 8 || CopySize == 16, "Unsupported copy size.");
213
+ _CUDA_PIPELINE_STATIC_ASSERT(SourceSize <= CopySize, "Source size must be less than or equal to copy size");
214
+ _CUDA_PIPELINE_ASSERT(__isShared(dst));
215
+ _CUDA_PIPELINE_ASSERT(__isGlobal(src));
216
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (CopySize - 1)));
217
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (CopySize - 1)));
218
+
219
+ CpAsyncChooser<CopySize, SourceSize>::cp_async(dst, src);
220
+ }
221
+
222
+ _CUDA_PIPELINE_STATIC_QUALIFIER
223
+ void pipeline_commit()
224
+ {
225
+ asm volatile ("cp.async.commit_group;");
226
+ }
227
+
228
+ template<unsigned N>
229
+ _CUDA_PIPELINE_STATIC_QUALIFIER
230
+ void pipeline_wait_prior()
231
+ {
232
+ asm volatile ("cp.async.wait_group %0;"
233
+ :
234
+ : "n"(N < _CUDA_PIPELINE_MAX_STAGES ? N : _CUDA_PIPELINE_MAX_STAGES));
235
+ }
236
+
237
+ _CUDA_PIPELINE_STATIC_QUALIFIER
238
+ void pipeline_arrive_on(uint64_t* barrier)
239
+ {
240
+ _CUDA_PIPELINE_ASSERT(__isShared(barrier));
241
+
242
+ asm volatile ("cp.async.mbarrier.arrive.shared.b64 [%0];"
243
+ :
244
+ : "r"(__nvvm_get_smem_pointer(barrier)));
245
+ }
246
+ };
247
+
248
+ template<>
249
+ struct ImplementationChooser<false> {
250
+ template<size_t CopySize, size_t SourceSize>
251
+ _CUDA_PIPELINE_STATIC_QUALIFIER
252
+ void pipeline_memcpy_async(void* __restrict__ dst, const void* __restrict__ src)
253
+ {
254
+ _CUDA_PIPELINE_STATIC_ASSERT(CopySize == 4 || CopySize == 8 || CopySize == 16, "Unsupported copy size.");
255
+ _CUDA_PIPELINE_STATIC_ASSERT(SourceSize <= CopySize, "Source size must be less than or equal to copy size");
256
+ _CUDA_PIPELINE_ASSERT(__isShared(dst));
257
+ _CUDA_PIPELINE_ASSERT(__isGlobal(src));
258
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (CopySize - 1)));
259
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (CopySize - 1)));
260
+
261
+ pipeline_memcpy_sync<CopySize, SourceSize>(dst, src);
262
+ }
263
+
264
+ _CUDA_PIPELINE_STATIC_QUALIFIER
265
+ void pipeline_commit()
266
+ {
267
+ }
268
+
269
+ template<unsigned N>
270
+ _CUDA_PIPELINE_STATIC_QUALIFIER
271
+ void pipeline_wait_prior()
272
+ {
273
+ }
274
+
275
+ _CUDA_PIPELINE_STATIC_QUALIFIER
276
+ void pipeline_arrive_on(uint64_t* barrier)
277
+ {
278
+ }
279
+ };
280
+
281
+ template<size_t CopySize, size_t SourceSize>
282
+ _CUDA_PIPELINE_QUALIFIER
283
+ void pipeline_memcpy_async(void* __restrict__ dst, const void* __restrict__ src)
284
+ {
285
+ _CUDA_PIPELINE_STATIC_ASSERT(CopySize == 4 || CopySize == 8 || CopySize == 16, "Unsupported copy size.");
286
+ _CUDA_PIPELINE_STATIC_ASSERT(SourceSize <= CopySize, "Source size must be less than or equal to copy size");
287
+ _CUDA_PIPELINE_ASSERT(__isShared(dst));
288
+ _CUDA_PIPELINE_ASSERT(__isGlobal(src));
289
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (CopySize - 1)));
290
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (CopySize - 1)));
291
+
292
+ ImplementationChooser<_CUDA_PIPELINE_HAS_ASYNC_COPY>::pipeline_memcpy_async<CopySize, SourceSize>(dst, src);
293
+ }
294
+
295
+ _CUDA_PIPELINE_QUALIFIER
296
+ void pipeline_commit()
297
+ {
298
+ ImplementationChooser<_CUDA_PIPELINE_HAS_ASYNC_COPY>::pipeline_commit();
299
+ }
300
+
301
+ template<unsigned N>
302
+ _CUDA_PIPELINE_QUALIFIER
303
+ void pipeline_wait_prior()
304
+ {
305
+ ImplementationChooser<_CUDA_PIPELINE_HAS_ASYNC_COPY>::pipeline_wait_prior<N>();
306
+ }
307
+
308
+ _CUDA_PIPELINE_QUALIFIER
309
+ void pipeline_arrive_on(uint64_t* barrier)
310
+ {
311
+ ImplementationChooser<_CUDA_PIPELINE_HAS_ASYNC_COPY>::pipeline_arrive_on(barrier);
312
+ }
313
+
314
+ template<size_t CopySize, size_t SourceSize>
315
+ _CUDA_PIPELINE_QUALIFIER
316
+ void pipeline_copy_strict(void* __restrict__ dst, const void* __restrict__ src)
317
+ {
318
+ _CUDA_PIPELINE_STATIC_ASSERT(CopySize == 4 || CopySize == 8 || CopySize == 16, "Unsupported copy size.");
319
+ _CUDA_PIPELINE_STATIC_ASSERT(SourceSize <= CopySize, "Source size must be less than or equal to copy size.");
320
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (CopySize - 1)));
321
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (CopySize - 1)));
322
+
323
+ if (__isGlobal(src) && __isShared(dst)) {
324
+ pipeline_memcpy_async<CopySize, SourceSize>(dst, src);
325
+ } else {
326
+ pipeline_memcpy_sync<CopySize, SourceSize>(dst, src);
327
+ }
328
+ }
329
+
330
+ template<size_t CopySize, size_t Align>
331
+ _CUDA_PIPELINE_QUALIFIER
332
+ void pipeline_copy_relaxed(void* __restrict__ dst, const void* __restrict__ src)
333
+ {
334
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (Align - 1)));
335
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (Align - 1)));
336
+
337
+ const char* s = reinterpret_cast<const char*>(src);
338
+ char* d = reinterpret_cast<char*>(dst);
339
+ size_t remaining = CopySize;
340
+
341
+ while (remaining) {
342
+ if ((Align >= 16) && (remaining >= 16)) {
343
+ pipeline_copy_strict<16, 16>(dst, src);
344
+ d += 16;
345
+ s += 16;
346
+ remaining -= 16;
347
+ } else if ((Align >= 8) && (remaining >= 8)) {
348
+ pipeline_copy_strict<8, 8>(dst, src);
349
+ d += 8;
350
+ s += 8;
351
+ remaining -= 8;
352
+ } else if ((Align >= 4) && (remaining >= 4)) {
353
+ pipeline_copy_strict<4, 4>(dst, src);
354
+ d += 4;
355
+ s += 4;
356
+ remaining -= 4;
357
+ } else if ((Align >= 2) && (remaining >= 2)) {
358
+ *reinterpret_cast<short*>(d) = *reinterpret_cast<const short*>(s);
359
+ d += 2;
360
+ s += 2;
361
+ remaining -= 2;
362
+ } else {
363
+ *d = *s;
364
+ d += 1;
365
+ s += 1;
366
+ remaining -= 1;
367
+ }
368
+ }
369
+ }
370
+
371
+ _CUDA_PIPELINE_END_INTERNAL_NAMESPACE
372
+
373
+ #endif /* !_CUDA_PIPELINE_HELPERS_H_ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_pipeline_primitives.h ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #ifndef _CUDA_PIPELINE_PRIMITIVES_H_
51
+ # define _CUDA_PIPELINE_PRIMITIVES_H_
52
+
53
+ # include "cuda_pipeline_helpers.h"
54
+
55
+ _CUDA_PIPELINE_STATIC_QUALIFIER
56
+ void __pipeline_memcpy_async(void* __restrict__ dst_shared, const void* __restrict__ src_global, size_t size_and_align,
57
+ size_t zfill = 0)
58
+ {
59
+ _CUDA_PIPELINE_ASSERT(size_and_align == 4 || size_and_align == 8 || size_and_align == 16);
60
+ _CUDA_PIPELINE_ASSERT(zfill <= size_and_align);
61
+ _CUDA_PIPELINE_ASSERT(__isShared(dst_shared));
62
+ _CUDA_PIPELINE_ASSERT(__isGlobal(src_global));
63
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst_shared) & (size_and_align - 1)));
64
+ _CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src_global) & (size_and_align - 1)));
65
+
66
+ switch (size_and_align) {
67
+ case 16:
68
+ switch (zfill) {
69
+ case 0: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 16>(dst_shared, src_global); return;
70
+ case 1: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 15>(dst_shared, src_global); return;
71
+ case 2: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 14>(dst_shared, src_global); return;
72
+ case 3: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 13>(dst_shared, src_global); return;
73
+ case 4: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 12>(dst_shared, src_global); return;
74
+ case 5: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 11>(dst_shared, src_global); return;
75
+ case 6: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 10>(dst_shared, src_global); return;
76
+ case 7: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 9>(dst_shared, src_global); return;
77
+ case 8: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 8>(dst_shared, src_global); return;
78
+ case 9: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 7>(dst_shared, src_global); return;
79
+ case 10: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 6>(dst_shared, src_global); return;
80
+ case 11: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 5>(dst_shared, src_global); return;
81
+ case 12: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 4>(dst_shared, src_global); return;
82
+ case 13: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 3>(dst_shared, src_global); return;
83
+ case 14: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 2>(dst_shared, src_global); return;
84
+ case 15: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 1>(dst_shared, src_global); return;
85
+ case 16: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 0>(dst_shared, src_global); return;
86
+ default: _CUDA_PIPELINE_ABORT(); return;
87
+ }
88
+ case 8:
89
+ switch (zfill) {
90
+ case 0: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 8>(dst_shared, src_global); return;
91
+ case 1: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 7>(dst_shared, src_global); return;
92
+ case 2: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 6>(dst_shared, src_global); return;
93
+ case 3: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 5>(dst_shared, src_global); return;
94
+ case 4: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 4>(dst_shared, src_global); return;
95
+ case 5: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 3>(dst_shared, src_global); return;
96
+ case 6: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 2>(dst_shared, src_global); return;
97
+ case 7: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 1>(dst_shared, src_global); return;
98
+ case 8: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 0>(dst_shared, src_global); return;
99
+ default: _CUDA_PIPELINE_ABORT(); return;
100
+ }
101
+ case 4:
102
+ switch (zfill) {
103
+ case 0: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 4, 4>(dst_shared, src_global); return;
104
+ case 1: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 4, 3>(dst_shared, src_global); return;
105
+ case 2: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 4, 2>(dst_shared, src_global); return;
106
+ case 3: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 4, 1>(dst_shared, src_global); return;
107
+ case 4: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 4, 0>(dst_shared, src_global); return;
108
+ default: _CUDA_PIPELINE_ABORT(); return;
109
+ }
110
+ default:
111
+ _CUDA_PIPELINE_ABORT();
112
+ return;
113
+ }
114
+ }
115
+
116
+ _CUDA_PIPELINE_STATIC_QUALIFIER
117
+ void __pipeline_commit()
118
+ {
119
+ _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_commit();
120
+ }
121
+
122
+ _CUDA_PIPELINE_STATIC_QUALIFIER
123
+ void __pipeline_wait_prior(size_t prior)
124
+ {
125
+ switch (prior) {
126
+ case 0 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<0>(); return;
127
+ case 1 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<1>(); return;
128
+ case 2 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<2>(); return;
129
+ case 3 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<3>(); return;
130
+ case 4 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<4>(); return;
131
+ case 5 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<5>(); return;
132
+ case 6 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<6>(); return;
133
+ case 7 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<7>(); return;
134
+ default : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<8>(); return;
135
+ }
136
+ }
137
+
138
+ # if defined(_CUDA_PIPELINE_ARCH_700_OR_LATER)
139
+ # include "cuda_awbarrier_primitives.h"
140
+
141
+ _CUDA_PIPELINE_STATIC_QUALIFIER
142
+ void __pipeline_arrive_on(__mbarrier_t* barrier)
143
+ {
144
+ _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_arrive_on(barrier);
145
+ }
146
+ # endif
147
+
148
+ #endif /* !_CUDA_PIPELINE_PRIMITIVES_H_ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_runtime.h ADDED
@@ -0,0 +1,2374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2023 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(__CUDA_RUNTIME_H__)
51
+ #define __CUDA_RUNTIME_H__
52
+
53
+ #if !defined(__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__)
54
+ #define __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
55
+ #define __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_CUDA_RUNTIME_H__
56
+ #endif
57
+
58
+ #define EXCLUDE_FROM_RTC
59
+ #if defined(__GNUC__)
60
+ #if defined(__clang__) || (!defined(__PGIC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
61
+ #pragma GCC diagnostic push
62
+ #endif
63
+ #if defined(__clang__) || (!defined(__PGIC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)))
64
+ #pragma GCC diagnostic ignored "-Wunused-function"
65
+ #endif
66
+ #elif defined(_MSC_VER)
67
+ #pragma warning(push)
68
+ #pragma warning(disable: 4820)
69
+ #endif
70
+ #ifdef __QNX__
71
+ #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
72
+ typedef unsigned size_t;
73
+ #endif
74
+ #endif
75
+ #undef EXCLUDE_FROM_RTC
76
+ /*******************************************************************************
77
+ * *
78
+ * *
79
+ * *
80
+ *******************************************************************************/
81
+
82
+ #include "crt/host_config.h"
83
+
84
+ /*******************************************************************************
85
+ * *
86
+ * *
87
+ * *
88
+ *******************************************************************************/
89
+
90
+ #include "builtin_types.h"
91
+ #include "library_types.h"
92
+ #if !defined(__CUDACC_RTC__)
93
+ #define EXCLUDE_FROM_RTC
94
+ #include "channel_descriptor.h"
95
+ #include "cuda_runtime_api.h"
96
+ #include "driver_functions.h"
97
+ #undef EXCLUDE_FROM_RTC
98
+ #endif /* !__CUDACC_RTC__ */
99
+ #include "crt/host_defines.h"
100
+ #ifdef __CUDACC_RTC__
101
+ #include "target"
102
+ #endif /* defined(__CUDACC_RTC__) */
103
+
104
+
105
+ #include "vector_functions.h"
106
+
107
+ #if defined(__CUDACC__)
108
+
109
+ #if defined(__CUDACC_RTC__)
110
+ #include "nvrtc_device_runtime.h"
111
+ #include "crt/device_functions.h"
112
+ #include "crt/common_functions.h"
113
+ #include "device_launch_parameters.h"
114
+
115
+ #else /* !__CUDACC_RTC__ */
116
+ #define EXCLUDE_FROM_RTC
117
+ #include "crt/common_functions.h"
118
+ #include "crt/device_functions.h"
119
+ #include "device_launch_parameters.h"
120
+
121
+ #if defined(__CUDACC_EXTENDED_LAMBDA__)
122
+ #include <functional>
123
+ #include <utility>
124
+ struct __device_builtin__ __nv_lambda_preheader_injection { };
125
+ #endif /* defined(__CUDACC_EXTENDED_LAMBDA__) */
126
+
127
+ #undef EXCLUDE_FROM_RTC
128
+ #endif /* __CUDACC_RTC__ */
129
+
130
+ #endif /* __CUDACC__ */
131
+
132
+ /** \cond impl_private */
133
+ #if defined(__DOXYGEN_ONLY__) || defined(CUDA_ENABLE_DEPRECATED)
134
+ #define __CUDA_DEPRECATED
135
+ #elif defined(_MSC_VER)
136
+ #define __CUDA_DEPRECATED __declspec(deprecated)
137
+ #elif defined(__GNUC__)
138
+ #define __CUDA_DEPRECATED __attribute__((deprecated))
139
+ #else
140
+ #define __CUDA_DEPRECATED
141
+ #endif
142
+ /** \endcond impl_private */
143
+
144
+ #define EXCLUDE_FROM_RTC
145
+ #if defined(__cplusplus) && !defined(__CUDACC_RTC__)
146
+
147
+ #if __cplusplus >= 201103L || (defined(_MSC_VER) && (_MSC_VER >= 1900))
148
+ #include <utility>
149
+ #endif
150
+
151
+ /*******************************************************************************
152
+ * *
153
+ * *
154
+ * *
155
+ *******************************************************************************/
156
+
157
+ /**
158
+ * \addtogroup CUDART_HIGHLEVEL
159
+ * @{
160
+ */
161
+
162
+ /**
163
+ *\brief Launches a device function
164
+ *
165
+ * The function invokes kernel \p func on \p gridDim (\p gridDim.x &times; \p gridDim.y
166
+ * &times; \p gridDim.z) grid of blocks. Each block contains \p blockDim (\p blockDim.x &times;
167
+ * \p blockDim.y &times; \p blockDim.z) threads.
168
+ *
169
+ * If the kernel has N parameters the \p args should point to array of N pointers.
170
+ * Each pointer, from <tt>args[0]</tt> to <tt>args[N - 1]</tt>, point to the region
171
+ * of memory from which the actual parameter will be copied.
172
+ *
173
+ * \p sharedMem sets the amount of dynamic shared memory that will be available to
174
+ * each thread block.
175
+ *
176
+ * \p stream specifies a stream the invocation is associated to.
177
+ *
178
+ * \param func - Device function symbol
179
+ * \param gridDim - Grid dimentions
180
+ * \param blockDim - Block dimentions
181
+ * \param args - Arguments
182
+ * \param sharedMem - Shared memory (defaults to 0)
183
+ * \param stream - Stream identifier (defaults to NULL)
184
+ *
185
+ * \return
186
+ * ::cudaSuccess,
187
+ * ::cudaErrorInvalidDeviceFunction,
188
+ * ::cudaErrorInvalidConfiguration,
189
+ * ::cudaErrorLaunchFailure,
190
+ * ::cudaErrorLaunchTimeout,
191
+ * ::cudaErrorLaunchOutOfResources,
192
+ * ::cudaErrorSharedObjectInitFailed,
193
+ * ::cudaErrorInvalidPtx,
194
+ * ::cudaErrorUnsupportedPtxVersion,
195
+ * ::cudaErrorNoKernelImageForDevice,
196
+ * ::cudaErrorJitCompilerNotFound,
197
+ * ::cudaErrorJitCompilationDisabled
198
+ * \notefnerr
199
+ * \note_async
200
+ * \note_null_stream
201
+ * \note_init_rt
202
+ * \note_callback
203
+ *
204
+ * \ref ::cudaLaunchKernel(const void *func, dim3 gridDim, dim3 blockDim, void **args, size_t sharedMem, cudaStream_t stream) "cudaLaunchKernel (C API)"
205
+ */
206
+ template<class T>
207
+ static __inline__ __host__ cudaError_t cudaLaunchKernel(
208
+ const T *func,
209
+ dim3 gridDim,
210
+ dim3 blockDim,
211
+ void **args,
212
+ size_t sharedMem = 0,
213
+ cudaStream_t stream = 0
214
+ )
215
+ {
216
+ return ::cudaLaunchKernel((const void *)func, gridDim, blockDim, args, sharedMem, stream);
217
+ }
218
+
219
+
220
+ #if __cplusplus >= 201103L || (defined(_MSC_VER) && (_MSC_VER >= 1900)) || defined(__DOXYGEN_ONLY__)
221
+ /**
222
+ * \brief Launches a CUDA function with launch-time configuration
223
+ *
224
+ * Invokes the kernel \p func on \p config->gridDim (\p config->gridDim.x
225
+ * &times; \p config->gridDim.y &times; \p config->gridDim.z) grid of blocks.
226
+ * Each block contains \p config->blockDim (\p config->blockDim.x &times;
227
+ * \p config->blockDim.y &times; \p config->blockDim.z) threads.
228
+ *
229
+ * \p config->dynamicSmemBytes sets the amount of dynamic shared memory that
230
+ * will be available to each thread block.
231
+ *
232
+ * \p config->stream specifies a stream the invocation is associated to.
233
+ *
234
+ * Configuration beyond grid and block dimensions, dynamic shared memory size,
235
+ * and stream can be provided with the following two fields of \p config:
236
+ *
237
+ * \p config->attrs is an array of \p config->numAttrs contiguous
238
+ * ::cudaLaunchAttribute elements. The value of this pointer is not considered
239
+ * if \p config->numAttrs is zero. However, in that case, it is recommended to
240
+ * set the pointer to NULL.
241
+ * \p config->numAttrs is the number of attributes populating the first
242
+ * \p config->numAttrs positions of the \p config->attrs array.
243
+ *
244
+ * The kernel arguments should be passed as arguments to this function via the
245
+ * \p args parameter pack.
246
+ *
247
+ * The C API version of this function, \p cudaLaunchKernelExC, is also available
248
+ * for pre-C++11 compilers and for use cases where the ability to pass kernel
249
+ * parameters via void* array is preferable.
250
+ *
251
+ * \param config - Launch configuration
252
+ * \param func - Kernel to launch
253
+ * \param args - Parameter pack of kernel parameters
254
+ *
255
+ * \return
256
+ * ::cudaSuccess,
257
+ * ::cudaErrorInvalidDeviceFunction,
258
+ * ::cudaErrorInvalidConfiguration,
259
+ * ::cudaErrorLaunchFailure,
260
+ * ::cudaErrorLaunchTimeout,
261
+ * ::cudaErrorLaunchOutOfResources,
262
+ * ::cudaErrorSharedObjectInitFailed,
263
+ * ::cudaErrorInvalidPtx,
264
+ * ::cudaErrorUnsupportedPtxVersion,
265
+ * ::cudaErrorNoKernelImageForDevice,
266
+ * ::cudaErrorJitCompilerNotFound,
267
+ * ::cudaErrorJitCompilationDisabled
268
+ * \note_null_stream
269
+ * \notefnerr
270
+ * \note_init_rt
271
+ * \note_callback
272
+ *
273
+ * \sa
274
+ * \ref ::cudaLaunchKernelExC(const cudaLaunchConfig_t *config, const void *func, void **args) "cudaLaunchKernelEx (C API)",
275
+ * ::cuLaunchKernelEx
276
+ */
277
+ template<typename... ExpTypes, typename... ActTypes>
278
+ static __inline__ __host__ cudaError_t cudaLaunchKernelEx(
279
+ const cudaLaunchConfig_t *config,
280
+ void (*kernel)(ExpTypes...),
281
+ ActTypes &&... args
282
+ )
283
+ {
284
+ return [&](ExpTypes... coercedArgs){
285
+ void *pArgs[] = { &coercedArgs... };
286
+ return ::cudaLaunchKernelExC(config, (const void *)kernel, pArgs);
287
+ }(std::forward<ActTypes>(args)...);
288
+ }
289
+ #endif
290
+
291
+ /**
292
+ *\brief Launches a device function
293
+ *
294
+ * The function invokes kernel \p func on \p gridDim (\p gridDim.x &times; \p gridDim.y
295
+ * &times; \p gridDim.z) grid of blocks. Each block contains \p blockDim (\p blockDim.x &times;
296
+ * \p blockDim.y &times; \p blockDim.z) threads.
297
+ *
298
+ * The device on which this kernel is invoked must have a non-zero value for
299
+ * the device attribute ::cudaDevAttrCooperativeLaunch.
300
+ *
301
+ * The total number of blocks launched cannot exceed the maximum number of blocks per
302
+ * multiprocessor as returned by ::cudaOccupancyMaxActiveBlocksPerMultiprocessor (or
303
+ * ::cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags) times the number of multiprocessors
304
+ * as specified by the device attribute ::cudaDevAttrMultiProcessorCount.
305
+ *
306
+ * The kernel cannot make use of CUDA dynamic parallelism.
307
+ *
308
+ * If the kernel has N parameters the \p args should point to array of N pointers.
309
+ * Each pointer, from <tt>args[0]</tt> to <tt>args[N - 1]</tt>, point to the region
310
+ * of memory from which the actual parameter will be copied.
311
+ *
312
+ * \p sharedMem sets the amount of dynamic shared memory that will be available to
313
+ * each thread block.
314
+ *
315
+ * \p stream specifies a stream the invocation is associated to.
316
+ *
317
+ * \param func - Device function symbol
318
+ * \param gridDim - Grid dimentions
319
+ * \param blockDim - Block dimentions
320
+ * \param args - Arguments
321
+ * \param sharedMem - Shared memory (defaults to 0)
322
+ * \param stream - Stream identifier (defaults to NULL)
323
+ *
324
+ * \return
325
+ * ::cudaSuccess,
326
+ * ::cudaErrorInvalidDeviceFunction,
327
+ * ::cudaErrorInvalidConfiguration,
328
+ * ::cudaErrorLaunchFailure,
329
+ * ::cudaErrorLaunchTimeout,
330
+ * ::cudaErrorLaunchOutOfResources,
331
+ * ::cudaErrorSharedObjectInitFailed
332
+ * \notefnerr
333
+ * \note_async
334
+ * \note_null_stream
335
+ * \note_init_rt
336
+ * \note_callback
337
+ *
338
+ * \ref ::cudaLaunchCooperativeKernel(const void *func, dim3 gridDim, dim3 blockDim, void **args, size_t sharedMem, cudaStream_t stream) "cudaLaunchCooperativeKernel (C API)"
339
+ */
340
+ template<class T>
341
+ static __inline__ __host__ cudaError_t cudaLaunchCooperativeKernel(
342
+ const T *func,
343
+ dim3 gridDim,
344
+ dim3 blockDim,
345
+ void **args,
346
+ size_t sharedMem = 0,
347
+ cudaStream_t stream = 0
348
+ )
349
+ {
350
+ return ::cudaLaunchCooperativeKernel((const void *)func, gridDim, blockDim, args, sharedMem, stream);
351
+ }
352
+
353
+ /**
354
+ * \brief \hl Creates an event object with the specified flags
355
+ *
356
+ * Creates an event object with the specified flags. Valid flags include:
357
+ * - ::cudaEventDefault: Default event creation flag.
358
+ * - ::cudaEventBlockingSync: Specifies that event should use blocking
359
+ * synchronization. A host thread that uses ::cudaEventSynchronize() to wait
360
+ * on an event created with this flag will block until the event actually
361
+ * completes.
362
+ * - ::cudaEventDisableTiming: Specifies that the created event does not need
363
+ * to record timing data. Events created with this flag specified and
364
+ * the ::cudaEventBlockingSync flag not specified will provide the best
365
+ * performance when used with ::cudaStreamWaitEvent() and ::cudaEventQuery().
366
+ *
367
+ * \param event - Newly created event
368
+ * \param flags - Flags for new event
369
+ *
370
+ * \return
371
+ * ::cudaSuccess,
372
+ * ::cudaErrorInvalidValue,
373
+ * ::cudaErrorLaunchFailure,
374
+ * ::cudaErrorMemoryAllocation
375
+ * \notefnerr
376
+ * \note_init_rt
377
+ * \note_callback
378
+ *
379
+ * \sa \ref ::cudaEventCreate(cudaEvent_t*) "cudaEventCreate (C API)",
380
+ * ::cudaEventCreateWithFlags, ::cudaEventRecord, ::cudaEventQuery,
381
+ * ::cudaEventSynchronize, ::cudaEventDestroy, ::cudaEventElapsedTime,
382
+ * ::cudaStreamWaitEvent
383
+ */
384
+ static __inline__ __host__ cudaError_t cudaEventCreate(
385
+ cudaEvent_t *event,
386
+ unsigned int flags
387
+ )
388
+ {
389
+ return ::cudaEventCreateWithFlags(event, flags);
390
+ }
391
+
392
+ /**
393
+ * \brief Creates an executable graph from a graph
394
+ *
395
+ * Instantiates \p graph as an executable graph. The graph is validated for any
396
+ * structural constraints or intra-node constraints which were not previously
397
+ * validated. If instantiation is successful, a handle to the instantiated graph
398
+ * is returned in \p pGraphExec.
399
+ *
400
+ * If there are any errors, diagnostic information may be returned in \p pErrorNode and
401
+ * \p pLogBuffer. This is the primary way to inspect instantiation errors. The output
402
+ * will be null terminated unless the diagnostics overflow
403
+ * the buffer. In this case, they will be truncated, and the last byte can be
404
+ * inspected to determine if truncation occurred.
405
+ *
406
+ * \param pGraphExec - Returns instantiated graph
407
+ * \param graph - Graph to instantiate
408
+ * \param pErrorNode - In case of an instantiation error, this may be modified to
409
+ * indicate a node contributing to the error
410
+ * \param pLogBuffer - A character buffer to store diagnostic messages
411
+ * \param bufferSize - Size of the log buffer in bytes
412
+ *
413
+ * \return
414
+ * ::cudaSuccess,
415
+ * ::cudaErrorInvalidValue
416
+ * \note_graph_thread_safety
417
+ * \notefnerr
418
+ * \note_init_rt
419
+ * \note_callback
420
+ *
421
+ * \sa
422
+ * ::cudaGraphInstantiateWithFlags,
423
+ * ::cudaGraphCreate,
424
+ * ::cudaGraphUpload,
425
+ * ::cudaGraphLaunch,
426
+ * ::cudaGraphExecDestroy
427
+ */
428
+ static __inline__ __host__ cudaError_t cudaGraphInstantiate(
429
+ cudaGraphExec_t *pGraphExec,
430
+ cudaGraph_t graph,
431
+ cudaGraphNode_t *pErrorNode,
432
+ char *pLogBuffer,
433
+ size_t bufferSize
434
+ )
435
+ {
436
+ (void)pErrorNode;
437
+ (void)pLogBuffer;
438
+ (void)bufferSize;
439
+ return ::cudaGraphInstantiate(pGraphExec, graph, 0);
440
+ }
441
+
442
+ /**
443
+ * \brief \hl Allocates page-locked memory on the host
444
+ *
445
+ * Allocates \p size bytes of host memory that is page-locked and accessible
446
+ * to the device. The driver tracks the virtual memory ranges allocated with
447
+ * this function and automatically accelerates calls to functions such as
448
+ * ::cudaMemcpy(). Since the memory can be accessed directly by the device, it
449
+ * can be read or written with much higher bandwidth than pageable memory
450
+ * obtained with functions such as ::malloc(). Allocating excessive amounts of
451
+ * pinned memory may degrade system performance, since it reduces the amount
452
+ * of memory available to the system for paging. As a result, this function is
453
+ * best used sparingly to allocate staging areas for data exchange between host
454
+ * and device.
455
+ *
456
+ * The \p flags parameter enables different options to be specified that affect
457
+ * the allocation, as follows.
458
+ * - ::cudaHostAllocDefault: This flag's value is defined to be 0.
459
+ * - ::cudaHostAllocPortable: The memory returned by this call will be
460
+ * considered as pinned memory by all CUDA contexts, not just the one that
461
+ * performed the allocation.
462
+ * - ::cudaHostAllocMapped: Maps the allocation into the CUDA address space.
463
+ * The device pointer to the memory may be obtained by calling
464
+ * ::cudaHostGetDevicePointer().
465
+ * - ::cudaHostAllocWriteCombined: Allocates the memory as write-combined (WC).
466
+ * WC memory can be transferred across the PCI Express bus more quickly on some
467
+ * system configurations, but cannot be read efficiently by most CPUs. WC
468
+ * memory is a good option for buffers that will be written by the CPU and read
469
+ * by the device via mapped pinned memory or host->device transfers.
470
+ *
471
+ * All of these flags are orthogonal to one another: a developer may allocate
472
+ * memory that is portable, mapped and/or write-combined with no restrictions.
473
+ *
474
+ * ::cudaSetDeviceFlags() must have been called with the ::cudaDeviceMapHost
475
+ * flag in order for the ::cudaHostAllocMapped flag to have any effect.
476
+ *
477
+ * The ::cudaHostAllocMapped flag may be specified on CUDA contexts for devices
478
+ * that do not support mapped pinned memory. The failure is deferred to
479
+ * ::cudaHostGetDevicePointer() because the memory may be mapped into other
480
+ * CUDA contexts via the ::cudaHostAllocPortable flag.
481
+ *
482
+ * Memory allocated by this function must be freed with ::cudaFreeHost().
483
+ *
484
+ * \param ptr - Device pointer to allocated memory
485
+ * \param size - Requested allocation size in bytes
486
+ * \param flags - Requested properties of allocated memory
487
+ *
488
+ * \return
489
+ * ::cudaSuccess,
490
+ * ::cudaErrorMemoryAllocation
491
+ * \notefnerr
492
+ * \note_init_rt
493
+ * \note_callback
494
+ *
495
+ * \sa ::cudaSetDeviceFlags,
496
+ * \ref ::cudaMallocHost(void**, size_t) "cudaMallocHost (C API)",
497
+ * ::cudaFreeHost, ::cudaHostAlloc
498
+ */
499
+ static __inline__ __host__ cudaError_t cudaMallocHost(
500
+ void **ptr,
501
+ size_t size,
502
+ unsigned int flags
503
+ )
504
+ {
505
+ return ::cudaHostAlloc(ptr, size, flags);
506
+ }
507
+
508
+ template<class T>
509
+ static __inline__ __host__ cudaError_t cudaHostAlloc(
510
+ T **ptr,
511
+ size_t size,
512
+ unsigned int flags
513
+ )
514
+ {
515
+ return ::cudaHostAlloc((void**)(void*)ptr, size, flags);
516
+ }
517
+
518
+ template<class T>
519
+ static __inline__ __host__ cudaError_t cudaHostGetDevicePointer(
520
+ T **pDevice,
521
+ void *pHost,
522
+ unsigned int flags
523
+ )
524
+ {
525
+ return ::cudaHostGetDevicePointer((void**)(void*)pDevice, pHost, flags);
526
+ }
527
+
528
+ /**
529
+ * \brief Allocates memory that will be automatically managed by the Unified Memory system
530
+ *
531
+ * Allocates \p size bytes of managed memory on the device and returns in
532
+ * \p *devPtr a pointer to the allocated memory. If the device doesn't support
533
+ * allocating managed memory, ::cudaErrorNotSupported is returned. Support
534
+ * for managed memory can be queried using the device attribute
535
+ * ::cudaDevAttrManagedMemory. The allocated memory is suitably
536
+ * aligned for any kind of variable. The memory is not cleared. If \p size
537
+ * is 0, ::cudaMallocManaged returns ::cudaErrorInvalidValue. The pointer
538
+ * is valid on the CPU and on all GPUs in the system that support managed memory.
539
+ * All accesses to this pointer must obey the Unified Memory programming model.
540
+ *
541
+ * \p flags specifies the default stream association for this allocation.
542
+ * \p flags must be one of ::cudaMemAttachGlobal or ::cudaMemAttachHost. The
543
+ * default value for \p flags is ::cudaMemAttachGlobal.
544
+ * If ::cudaMemAttachGlobal is specified, then this memory is accessible from
545
+ * any stream on any device. If ::cudaMemAttachHost is specified, then the
546
+ * allocation should not be accessed from devices that have a zero value for the
547
+ * device attribute ::cudaDevAttrConcurrentManagedAccess; an explicit call to
548
+ * ::cudaStreamAttachMemAsync will be required to enable access on such devices.
549
+ *
550
+ * If the association is later changed via ::cudaStreamAttachMemAsync to
551
+ * a single stream, the default association, as specifed during ::cudaMallocManaged,
552
+ * is restored when that stream is destroyed. For __managed__ variables, the
553
+ * default association is always ::cudaMemAttachGlobal. Note that destroying a
554
+ * stream is an asynchronous operation, and as a result, the change to default
555
+ * association won't happen until all work in the stream has completed.
556
+ *
557
+ * Memory allocated with ::cudaMallocManaged should be released with ::cudaFree.
558
+ *
559
+ * Device memory oversubscription is possible for GPUs that have a non-zero value for the
560
+ * device attribute ::cudaDevAttrConcurrentManagedAccess. Managed memory on
561
+ * such GPUs may be evicted from device memory to host memory at any time by the Unified
562
+ * Memory driver in order to make room for other allocations.
563
+ *
564
+ * In a multi-GPU system where all GPUs have a non-zero value for the device attribute
565
+ * ::cudaDevAttrConcurrentManagedAccess, managed memory may not be populated when this
566
+ * API returns and instead may be populated on access. In such systems, managed memory can
567
+ * migrate to any processor's memory at any time. The Unified Memory driver will employ heuristics to
568
+ * maintain data locality and prevent excessive page faults to the extent possible. The application
569
+ * can also guide the driver about memory usage patterns via ::cudaMemAdvise. The application
570
+ * can also explicitly migrate memory to a desired processor's memory via
571
+ * ::cudaMemPrefetchAsync.
572
+ *
573
+ * In a multi-GPU system where all of the GPUs have a zero value for the device attribute
574
+ * ::cudaDevAttrConcurrentManagedAccess and all the GPUs have peer-to-peer support
575
+ * with each other, the physical storage for managed memory is created on the GPU which is active
576
+ * at the time ::cudaMallocManaged is called. All other GPUs will reference the data at reduced
577
+ * bandwidth via peer mappings over the PCIe bus. The Unified Memory driver does not migrate
578
+ * memory among such GPUs.
579
+ *
580
+ * In a multi-GPU system where not all GPUs have peer-to-peer support with each other and
581
+ * where the value of the device attribute ::cudaDevAttrConcurrentManagedAccess
582
+ * is zero for at least one of those GPUs, the location chosen for physical storage of managed
583
+ * memory is system-dependent.
584
+ * - On Linux, the location chosen will be device memory as long as the current set of active
585
+ * contexts are on devices that either have peer-to-peer support with each other or have a
586
+ * non-zero value for the device attribute ::cudaDevAttrConcurrentManagedAccess.
587
+ * If there is an active context on a GPU that does not have a non-zero value for that device
588
+ * attribute and it does not have peer-to-peer support with the other devices that have active
589
+ * contexts on them, then the location for physical storage will be 'zero-copy' or host memory.
590
+ * Note that this means that managed memory that is located in device memory is migrated to
591
+ * host memory if a new context is created on a GPU that doesn't have a non-zero value for
592
+ * the device attribute and does not support peer-to-peer with at least one of the other devices
593
+ * that has an active context. This in turn implies that context creation may fail if there is
594
+ * insufficient host memory to migrate all managed allocations.
595
+ * - On Windows, the physical storage is always created in 'zero-copy' or host memory.
596
+ * All GPUs will reference the data at reduced bandwidth over the PCIe bus. In these
597
+ * circumstances, use of the environment variable CUDA_VISIBLE_DEVICES is recommended to
598
+ * restrict CUDA to only use those GPUs that have peer-to-peer support.
599
+ * Alternatively, users can also set CUDA_MANAGED_FORCE_DEVICE_ALLOC to a non-zero
600
+ * value to force the driver to always use device memory for physical storage.
601
+ * When this environment variable is set to a non-zero value, all devices used in
602
+ * that process that support managed memory have to be peer-to-peer compatible
603
+ * with each other. The error ::cudaErrorInvalidDevice will be returned if a device
604
+ * that supports managed memory is used and it is not peer-to-peer compatible with
605
+ * any of the other managed memory supporting devices that were previously used in
606
+ * that process, even if ::cudaDeviceReset has been called on those devices. These
607
+ * environment variables are described in the CUDA programming guide under the
608
+ * "CUDA environment variables" section.
609
+ * - On ARM, managed memory is not available on discrete gpu with Drive PX-2.
610
+ *
611
+ * \param devPtr - Pointer to allocated device memory
612
+ * \param size - Requested allocation size in bytes
613
+ * \param flags - Must be either ::cudaMemAttachGlobal or ::cudaMemAttachHost (defaults to ::cudaMemAttachGlobal)
614
+ *
615
+ * \return
616
+ * ::cudaSuccess,
617
+ * ::cudaErrorMemoryAllocation,
618
+ * ::cudaErrorNotSupported,
619
+ * ::cudaErrorInvalidValue
620
+ * \note_init_rt
621
+ * \note_callback
622
+ *
623
+ * \sa ::cudaMallocPitch, ::cudaFree, ::cudaMallocArray, ::cudaFreeArray,
624
+ * ::cudaMalloc3D, ::cudaMalloc3DArray,
625
+ * \ref ::cudaMallocHost(void**, size_t) "cudaMallocHost (C API)",
626
+ * ::cudaFreeHost, ::cudaHostAlloc, ::cudaDeviceGetAttribute, ::cudaStreamAttachMemAsync
627
+ */
628
+ template<class T>
629
+ static __inline__ __host__ cudaError_t cudaMallocManaged(
630
+ T **devPtr,
631
+ size_t size,
632
+ unsigned int flags = cudaMemAttachGlobal
633
+ )
634
+ {
635
+ return ::cudaMallocManaged((void**)(void*)devPtr, size, flags);
636
+ }
637
+
638
+ /**
639
+ * \brief Advise about the usage of a given memory range.
640
+ *
641
+ * This is an alternate spelling for cudaMemAdvise made available through operator overloading.
642
+ *
643
+ * \sa ::cudaMemAdvise,
644
+ * \ref ::cudaMemAdvise(const void* devPtr, size_t count, enum cudaMemoryAdvise advice, struct cudaMemLocation location) "cudaMemAdvise (C API)"
645
+ */
646
+ template<class T>
647
+ cudaError_t cudaMemAdvise(
648
+ T *devPtr,
649
+ size_t count,
650
+ enum cudaMemoryAdvise advice,
651
+ struct cudaMemLocation location
652
+ )
653
+ {
654
+ return ::cudaMemAdvise_v2((const void *)devPtr, count, advice, location);
655
+ }
656
+
657
+ template<class T>
658
+ static __inline__ __host__ cudaError_t cudaMemPrefetchAsync(
659
+ T *devPtr,
660
+ size_t count,
661
+ struct cudaMemLocation location,
662
+ unsigned int flags,
663
+ cudaStream_t stream = 0
664
+ )
665
+ {
666
+ return ::cudaMemPrefetchAsync_v2((const void *)devPtr, count, location, flags, stream);
667
+ }
668
+
669
+ /**
670
+ * \brief Attach memory to a stream asynchronously
671
+ *
672
+ * Enqueues an operation in \p stream to specify stream association of
673
+ * \p length bytes of memory starting from \p devPtr. This function is a
674
+ * stream-ordered operation, meaning that it is dependent on, and will
675
+ * only take effect when, previous work in stream has completed. Any
676
+ * previous association is automatically replaced.
677
+ *
678
+ * \p devPtr must point to an one of the following types of memories:
679
+ * - managed memory declared using the __managed__ keyword or allocated with
680
+ * ::cudaMallocManaged.
681
+ * - a valid host-accessible region of system-allocated pageable memory. This
682
+ * type of memory may only be specified if the device associated with the
683
+ * stream reports a non-zero value for the device attribute
684
+ * ::cudaDevAttrPageableMemoryAccess.
685
+ *
686
+ * For managed allocations, \p length must be either zero or the entire
687
+ * allocation's size. Both indicate that the entire allocation's stream
688
+ * association is being changed. Currently, it is not possible to change stream
689
+ * association for a portion of a managed allocation.
690
+ *
691
+ * For pageable allocations, \p length must be non-zero.
692
+ *
693
+ * The stream association is specified using \p flags which must be
694
+ * one of ::cudaMemAttachGlobal, ::cudaMemAttachHost or ::cudaMemAttachSingle.
695
+ * The default value for \p flags is ::cudaMemAttachSingle
696
+ * If the ::cudaMemAttachGlobal flag is specified, the memory can be accessed
697
+ * by any stream on any device.
698
+ * If the ::cudaMemAttachHost flag is specified, the program makes a guarantee
699
+ * that it won't access the memory on the device from any stream on a device that
700
+ * has a zero value for the device attribute ::cudaDevAttrConcurrentManagedAccess.
701
+ * If the ::cudaMemAttachSingle flag is specified and \p stream is associated with
702
+ * a device that has a zero value for the device attribute ::cudaDevAttrConcurrentManagedAccess,
703
+ * the program makes a guarantee that it will only access the memory on the device
704
+ * from \p stream. It is illegal to attach singly to the NULL stream, because the
705
+ * NULL stream is a virtual global stream and not a specific stream. An error will
706
+ * be returned in this case.
707
+ *
708
+ * When memory is associated with a single stream, the Unified Memory system will
709
+ * allow CPU access to this memory region so long as all operations in \p stream
710
+ * have completed, regardless of whether other streams are active. In effect,
711
+ * this constrains exclusive ownership of the managed memory region by
712
+ * an active GPU to per-stream activity instead of whole-GPU activity.
713
+ *
714
+ * Accessing memory on the device from streams that are not associated with
715
+ * it will produce undefined results. No error checking is performed by the
716
+ * Unified Memory system to ensure that kernels launched into other streams
717
+ * do not access this region.
718
+ *
719
+ * It is a program's responsibility to order calls to ::cudaStreamAttachMemAsync
720
+ * via events, synchronization or other means to ensure legal access to memory
721
+ * at all times. Data visibility and coherency will be changed appropriately
722
+ * for all kernels which follow a stream-association change.
723
+ *
724
+ * If \p stream is destroyed while data is associated with it, the association is
725
+ * removed and the association reverts to the default visibility of the allocation
726
+ * as specified at ::cudaMallocManaged. For __managed__ variables, the default
727
+ * association is always ::cudaMemAttachGlobal. Note that destroying a stream is an
728
+ * asynchronous operation, and as a result, the change to default association won't
729
+ * happen until all work in the stream has completed.
730
+ *
731
+ * \param stream - Stream in which to enqueue the attach operation
732
+ * \param devPtr - Pointer to memory (must be a pointer to managed memory or
733
+ * to a valid host-accessible region of system-allocated
734
+ * memory)
735
+ * \param length - Length of memory (defaults to zero)
736
+ * \param flags - Must be one of ::cudaMemAttachGlobal, ::cudaMemAttachHost or ::cudaMemAttachSingle (defaults to ::cudaMemAttachSingle)
737
+ *
738
+ * \return
739
+ * ::cudaSuccess,
740
+ * ::cudaErrorNotReady,
741
+ * ::cudaErrorInvalidValue,
742
+ * ::cudaErrorInvalidResourceHandle
743
+ * \notefnerr
744
+ * \note_init_rt
745
+ * \note_callback
746
+ *
747
+ * \sa ::cudaStreamCreate, ::cudaStreamCreateWithFlags, ::cudaStreamWaitEvent, ::cudaStreamSynchronize, ::cudaStreamAddCallback, ::cudaStreamDestroy, ::cudaMallocManaged
748
+ */
749
+ template<class T>
750
+ static __inline__ __host__ cudaError_t cudaStreamAttachMemAsync(
751
+ cudaStream_t stream,
752
+ T *devPtr,
753
+ size_t length = 0,
754
+ unsigned int flags = cudaMemAttachSingle
755
+ )
756
+ {
757
+ return ::cudaStreamAttachMemAsync(stream, (void*)devPtr, length, flags);
758
+ }
759
+
760
+ template<class T>
761
+ static __inline__ __host__ cudaError_t cudaMalloc(
762
+ T **devPtr,
763
+ size_t size
764
+ )
765
+ {
766
+ return ::cudaMalloc((void**)(void*)devPtr, size);
767
+ }
768
+
769
+ template<class T>
770
+ static __inline__ __host__ cudaError_t cudaMallocHost(
771
+ T **ptr,
772
+ size_t size,
773
+ unsigned int flags = 0
774
+ )
775
+ {
776
+ return cudaMallocHost((void**)(void*)ptr, size, flags);
777
+ }
778
+
779
+ template<class T>
780
+ static __inline__ __host__ cudaError_t cudaMallocPitch(
781
+ T **devPtr,
782
+ size_t *pitch,
783
+ size_t width,
784
+ size_t height
785
+ )
786
+ {
787
+ return ::cudaMallocPitch((void**)(void*)devPtr, pitch, width, height);
788
+ }
789
+
790
+ /**
791
+ * \brief Allocate from a pool
792
+ *
793
+ * This is an alternate spelling for cudaMallocFromPoolAsync
794
+ * made available through operator overloading.
795
+ *
796
+ * \sa ::cudaMallocFromPoolAsync,
797
+ * \ref ::cudaMallocAsync(void** ptr, size_t size, cudaStream_t hStream) "cudaMallocAsync (C API)"
798
+ */
799
+ static __inline__ __host__ cudaError_t cudaMallocAsync(
800
+ void **ptr,
801
+ size_t size,
802
+ cudaMemPool_t memPool,
803
+ cudaStream_t stream
804
+ )
805
+ {
806
+ return ::cudaMallocFromPoolAsync(ptr, size, memPool, stream);
807
+ }
808
+
809
+ template<class T>
810
+ static __inline__ __host__ cudaError_t cudaMallocAsync(
811
+ T **ptr,
812
+ size_t size,
813
+ cudaMemPool_t memPool,
814
+ cudaStream_t stream
815
+ )
816
+ {
817
+ return ::cudaMallocFromPoolAsync((void**)(void*)ptr, size, memPool, stream);
818
+ }
819
+
820
+ template<class T>
821
+ static __inline__ __host__ cudaError_t cudaMallocAsync(
822
+ T **ptr,
823
+ size_t size,
824
+ cudaStream_t stream
825
+ )
826
+ {
827
+ return ::cudaMallocAsync((void**)(void*)ptr, size, stream);
828
+ }
829
+
830
+ template<class T>
831
+ static __inline__ __host__ cudaError_t cudaMallocFromPoolAsync(
832
+ T **ptr,
833
+ size_t size,
834
+ cudaMemPool_t memPool,
835
+ cudaStream_t stream
836
+ )
837
+ {
838
+ return ::cudaMallocFromPoolAsync((void**)(void*)ptr, size, memPool, stream);
839
+ }
840
+
841
+ #if defined(__CUDACC__)
842
+
843
+ /**
844
+ * \brief \hl Copies data to the given symbol on the device
845
+ *
846
+ * Copies \p count bytes from the memory area pointed to by \p src
847
+ * to the memory area \p offset bytes from the start of symbol
848
+ * \p symbol. The memory areas may not overlap. \p symbol is a variable that
849
+ * resides in global or constant memory space. \p kind can be either
850
+ * ::cudaMemcpyHostToDevice or ::cudaMemcpyDeviceToDevice.
851
+ *
852
+ * \param symbol - Device symbol reference
853
+ * \param src - Source memory address
854
+ * \param count - Size in bytes to copy
855
+ * \param offset - Offset from start of symbol in bytes
856
+ * \param kind - Type of transfer
857
+ *
858
+ * \return
859
+ * ::cudaSuccess,
860
+ * ::cudaErrorInvalidValue,
861
+ * ::cudaErrorInvalidSymbol,
862
+ * ::cudaErrorInvalidMemcpyDirection,
863
+ * ::cudaErrorNoKernelImageForDevice
864
+ * \notefnerr
865
+ * \note_sync
866
+ * \note_string_api_deprecation
867
+ * \note_init_rt
868
+ * \note_callback
869
+ *
870
+ * \sa ::cudaMemcpy, ::cudaMemcpy2D,
871
+ * ::cudaMemcpy2DToArray, ::cudaMemcpy2DFromArray,
872
+ * ::cudaMemcpy2DArrayToArray,
873
+ * ::cudaMemcpyFromSymbol, ::cudaMemcpyAsync, ::cudaMemcpy2DAsync,
874
+ * ::cudaMemcpy2DToArrayAsync,
875
+ * ::cudaMemcpy2DFromArrayAsync,
876
+ * ::cudaMemcpyToSymbolAsync, ::cudaMemcpyFromSymbolAsync
877
+ */
878
+ template<class T>
879
+ static __inline__ __host__ cudaError_t cudaMemcpyToSymbol(
880
+ const T &symbol,
881
+ const void *src,
882
+ size_t count,
883
+ size_t offset = 0,
884
+ enum cudaMemcpyKind kind = cudaMemcpyHostToDevice
885
+ )
886
+ {
887
+ return ::cudaMemcpyToSymbol((const void*)&symbol, src, count, offset, kind);
888
+ }
889
+
890
+ /**
891
+ * \brief \hl Copies data to the given symbol on the device
892
+ *
893
+ * Copies \p count bytes from the memory area pointed to by \p src
894
+ * to the memory area \p offset bytes from the start of symbol
895
+ * \p symbol. The memory areas may not overlap. \p symbol is a variable that
896
+ * resides in global or constant memory space. \p kind can be either
897
+ * ::cudaMemcpyHostToDevice or ::cudaMemcpyDeviceToDevice.
898
+ *
899
+ * ::cudaMemcpyToSymbolAsync() is asynchronous with respect to the host, so
900
+ * the call may return before the copy is complete. The copy can optionally
901
+ * be associated to a stream by passing a non-zero \p stream argument. If
902
+ * \p kind is ::cudaMemcpyHostToDevice and \p stream is non-zero, the copy
903
+ * may overlap with operations in other streams.
904
+ *
905
+ * \param symbol - Device symbol reference
906
+ * \param src - Source memory address
907
+ * \param count - Size in bytes to copy
908
+ * \param offset - Offset from start of symbol in bytes
909
+ * \param kind - Type of transfer
910
+ * \param stream - Stream identifier
911
+ *
912
+ * \return
913
+ * ::cudaSuccess,
914
+ * ::cudaErrorInvalidValue,
915
+ * ::cudaErrorInvalidSymbol,
916
+ * ::cudaErrorInvalidMemcpyDirection,
917
+ * ::cudaErrorNoKernelImageForDevice
918
+ * \notefnerr
919
+ * \note_async
920
+ * \note_string_api_deprecation
921
+ * \note_init_rt
922
+ * \note_callback
923
+ *
924
+ * \sa ::cudaMemcpy, ::cudaMemcpy2D,
925
+ * ::cudaMemcpy2DToArray, ::cudaMemcpy2DFromArray,
926
+ * ::cudaMemcpy2DArrayToArray, ::cudaMemcpyToSymbol,
927
+ * ::cudaMemcpyFromSymbol, ::cudaMemcpyAsync, ::cudaMemcpy2DAsync,
928
+ * ::cudaMemcpy2DToArrayAsync,
929
+ * ::cudaMemcpy2DFromArrayAsync,
930
+ * ::cudaMemcpyFromSymbolAsync
931
+ */
932
+ template<class T>
933
+ static __inline__ __host__ cudaError_t cudaMemcpyToSymbolAsync(
934
+ const T &symbol,
935
+ const void *src,
936
+ size_t count,
937
+ size_t offset = 0,
938
+ enum cudaMemcpyKind kind = cudaMemcpyHostToDevice,
939
+ cudaStream_t stream = 0
940
+ )
941
+ {
942
+ return ::cudaMemcpyToSymbolAsync((const void*)&symbol, src, count, offset, kind, stream);
943
+ }
944
+
945
+ /**
946
+ * \brief \hl Copies data from the given symbol on the device
947
+ *
948
+ * Copies \p count bytes from the memory area \p offset bytes
949
+ * from the start of symbol \p symbol to the memory area pointed to by \p dst.
950
+ * The memory areas may not overlap. \p symbol is a variable that
951
+ * resides in global or constant memory space. \p kind can be either
952
+ * ::cudaMemcpyDeviceToHost or ::cudaMemcpyDeviceToDevice.
953
+ *
954
+ * \param dst - Destination memory address
955
+ * \param symbol - Device symbol reference
956
+ * \param count - Size in bytes to copy
957
+ * \param offset - Offset from start of symbol in bytes
958
+ * \param kind - Type of transfer
959
+ *
960
+ * \return
961
+ * ::cudaSuccess,
962
+ * ::cudaErrorInvalidValue,
963
+ * ::cudaErrorInvalidSymbol,
964
+ * ::cudaErrorInvalidMemcpyDirection,
965
+ * ::cudaErrorNoKernelImageForDevice
966
+ * \notefnerr
967
+ * \note_sync
968
+ * \note_string_api_deprecation
969
+ * \note_init_rt
970
+ * \note_callback
971
+ *
972
+ * \sa ::cudaMemcpy, ::cudaMemcpy2D,
973
+ * ::cudaMemcpy2DToArray, ::cudaMemcpy2DFromArray,
974
+ * ::cudaMemcpy2DArrayToArray, ::cudaMemcpyToSymbol,
975
+ * ::cudaMemcpyAsync, ::cudaMemcpy2DAsync,
976
+ * ::cudaMemcpy2DToArrayAsync,
977
+ * ::cudaMemcpy2DFromArrayAsync,
978
+ * ::cudaMemcpyToSymbolAsync, ::cudaMemcpyFromSymbolAsync
979
+ */
980
+ template<class T>
981
+ static __inline__ __host__ cudaError_t cudaMemcpyFromSymbol(
982
+ void *dst,
983
+ const T &symbol,
984
+ size_t count,
985
+ size_t offset = 0,
986
+ enum cudaMemcpyKind kind = cudaMemcpyDeviceToHost
987
+ )
988
+ {
989
+ return ::cudaMemcpyFromSymbol(dst, (const void*)&symbol, count, offset, kind);
990
+ }
991
+
992
+ /**
993
+ * \brief \hl Copies data from the given symbol on the device
994
+ *
995
+ * Copies \p count bytes from the memory area \p offset bytes
996
+ * from the start of symbol \p symbol to the memory area pointed to by \p dst.
997
+ * The memory areas may not overlap. \p symbol is a variable that resides in
998
+ * global or constant memory space. \p kind can be either
999
+ * ::cudaMemcpyDeviceToHost or ::cudaMemcpyDeviceToDevice.
1000
+ *
1001
+ * ::cudaMemcpyFromSymbolAsync() is asynchronous with respect to the host, so
1002
+ * the call may return before the copy is complete. The copy can optionally be
1003
+ * associated to a stream by passing a non-zero \p stream argument. If \p kind
1004
+ * is ::cudaMemcpyDeviceToHost and \p stream is non-zero, the copy may overlap
1005
+ * with operations in other streams.
1006
+ *
1007
+ * \param dst - Destination memory address
1008
+ * \param symbol - Device symbol reference
1009
+ * \param count - Size in bytes to copy
1010
+ * \param offset - Offset from start of symbol in bytes
1011
+ * \param kind - Type of transfer
1012
+ * \param stream - Stream identifier
1013
+ *
1014
+ * \return
1015
+ * ::cudaSuccess,
1016
+ * ::cudaErrorInvalidValue,
1017
+ * ::cudaErrorInvalidSymbol,
1018
+ * ::cudaErrorInvalidMemcpyDirection,
1019
+ * ::cudaErrorNoKernelImageForDevice
1020
+ * \notefnerr
1021
+ * \note_async
1022
+ * \note_string_api_deprecation
1023
+ * \note_init_rt
1024
+ * \note_callback
1025
+ *
1026
+ * \sa ::cudaMemcpy, ::cudaMemcpy2D,
1027
+ * ::cudaMemcpy2DToArray, ::cudaMemcpy2DFromArray,
1028
+ * ::cudaMemcpy2DArrayToArray, ::cudaMemcpyToSymbol,
1029
+ * ::cudaMemcpyFromSymbol, ::cudaMemcpyAsync, ::cudaMemcpy2DAsync,
1030
+ * ::cudaMemcpy2DToArrayAsync,
1031
+ * ::cudaMemcpy2DFromArrayAsync,
1032
+ * ::cudaMemcpyToSymbolAsync
1033
+ */
1034
+ template<class T>
1035
+ static __inline__ __host__ cudaError_t cudaMemcpyFromSymbolAsync(
1036
+ void *dst,
1037
+ const T &symbol,
1038
+ size_t count,
1039
+ size_t offset = 0,
1040
+ enum cudaMemcpyKind kind = cudaMemcpyDeviceToHost,
1041
+ cudaStream_t stream = 0
1042
+ )
1043
+ {
1044
+ return ::cudaMemcpyFromSymbolAsync(dst, (const void*)&symbol, count, offset, kind, stream);
1045
+ }
1046
+
1047
+ /**
1048
+ * \brief Creates a memcpy node to copy to a symbol on the device and adds it to a graph
1049
+ *
1050
+ * Creates a new memcpy node to copy to \p symbol and adds it to \p graph with
1051
+ * \p numDependencies dependencies specified via \p pDependencies.
1052
+ * It is possible for \p numDependencies to be 0, in which case the node will be placed
1053
+ * at the root of the graph. \p pDependencies may not have any duplicate entries.
1054
+ * A handle to the new node will be returned in \p pGraphNode.
1055
+ *
1056
+ * When the graph is launched, the node will copy \p count bytes from the memory area
1057
+ * pointed to by \p src to the memory area pointed to by \p offset bytes from the start
1058
+ * of symbol \p symbol. The memory areas may not overlap. \p symbol is a variable that
1059
+ * resides in global or constant memory space. \p kind can be either
1060
+ * ::cudaMemcpyHostToDevice, ::cudaMemcpyDeviceToDevice, or ::cudaMemcpyDefault.
1061
+ * Passing ::cudaMemcpyDefault is recommended, in which case the type of
1062
+ * transfer is inferred from the pointer values. However, ::cudaMemcpyDefault
1063
+ * is only allowed on systems that support unified virtual addressing.
1064
+ *
1065
+ * Memcpy nodes have some additional restrictions with regards to managed memory, if the
1066
+ * system contains at least one device which has a zero value for the device attribute
1067
+ * ::cudaDevAttrConcurrentManagedAccess.
1068
+ *
1069
+ * \param pGraphNode - Returns newly created node
1070
+ * \param graph - Graph to which to add the node
1071
+ * \param pDependencies - Dependencies of the node
1072
+ * \param numDependencies - Number of dependencies
1073
+ * \param symbol - Device symbol address
1074
+ * \param src - Source memory address
1075
+ * \param count - Size in bytes to copy
1076
+ * \param offset - Offset from start of symbol in bytes
1077
+ * \param kind - Type of transfer
1078
+ *
1079
+ * \return
1080
+ * ::cudaSuccess,
1081
+ * ::cudaErrorInvalidValue
1082
+ * \note_graph_thread_safety
1083
+ * \notefnerr
1084
+ * \note_init_rt
1085
+ * \note_callback
1086
+ *
1087
+ * \sa
1088
+ * ::cudaMemcpyToSymbol,
1089
+ * ::cudaGraphAddMemcpyNode,
1090
+ * ::cudaGraphAddMemcpyNodeFromSymbol,
1091
+ * ::cudaGraphMemcpyNodeGetParams,
1092
+ * ::cudaGraphMemcpyNodeSetParams,
1093
+ * ::cudaGraphMemcpyNodeSetParamsToSymbol,
1094
+ * ::cudaGraphMemcpyNodeSetParamsFromSymbol,
1095
+ * ::cudaGraphCreate,
1096
+ * ::cudaGraphDestroyNode,
1097
+ * ::cudaGraphAddChildGraphNode,
1098
+ * ::cudaGraphAddEmptyNode,
1099
+ * ::cudaGraphAddKernelNode,
1100
+ * ::cudaGraphAddHostNode,
1101
+ * ::cudaGraphAddMemsetNode
1102
+ */
1103
+ template<class T>
1104
+ static __inline__ __host__ cudaError_t cudaGraphAddMemcpyNodeToSymbol(
1105
+ cudaGraphNode_t *pGraphNode,
1106
+ cudaGraph_t graph,
1107
+ const cudaGraphNode_t *pDependencies,
1108
+ size_t numDependencies,
1109
+ const T &symbol,
1110
+ const void* src,
1111
+ size_t count,
1112
+ size_t offset,
1113
+ enum cudaMemcpyKind kind)
1114
+ {
1115
+ return ::cudaGraphAddMemcpyNodeToSymbol(pGraphNode, graph, pDependencies, numDependencies, (const void*)&symbol, src, count, offset, kind);
1116
+ }
1117
+
1118
+ /**
1119
+ * \brief Creates a memcpy node to copy from a symbol on the device and adds it to a graph
1120
+ *
1121
+ * Creates a new memcpy node to copy from \p symbol and adds it to \p graph with
1122
+ * \p numDependencies dependencies specified via \p pDependencies.
1123
+ * It is possible for \p numDependencies to be 0, in which case the node will be placed
1124
+ * at the root of the graph. \p pDependencies may not have any duplicate entries.
1125
+ * A handle to the new node will be returned in \p pGraphNode.
1126
+ *
1127
+ * When the graph is launched, the node will copy \p count bytes from the memory area
1128
+ * pointed to by \p offset bytes from the start of symbol \p symbol to the memory area
1129
+ * pointed to by \p dst. The memory areas may not overlap. \p symbol is a variable
1130
+ * that resides in global or constant memory space. \p kind can be either
1131
+ * ::cudaMemcpyDeviceToHost, ::cudaMemcpyDeviceToDevice, or ::cudaMemcpyDefault.
1132
+ * Passing ::cudaMemcpyDefault is recommended, in which case the type of transfer
1133
+ * is inferred from the pointer values. However, ::cudaMemcpyDefault is only
1134
+ * allowed on systems that support unified virtual addressing.
1135
+ *
1136
+ * Memcpy nodes have some additional restrictions with regards to managed memory, if the
1137
+ * system contains at least one device which has a zero value for the device attribute
1138
+ * ::cudaDevAttrConcurrentManagedAccess.
1139
+ *
1140
+ * \param pGraphNode - Returns newly created node
1141
+ * \param graph - Graph to which to add the node
1142
+ * \param pDependencies - Dependencies of the node
1143
+ * \param numDependencies - Number of dependencies
1144
+ * \param dst - Destination memory address
1145
+ * \param symbol - Device symbol address
1146
+ * \param count - Size in bytes to copy
1147
+ * \param offset - Offset from start of symbol in bytes
1148
+ * \param kind - Type of transfer
1149
+ *
1150
+ * \return
1151
+ * ::cudaSuccess,
1152
+ * ::cudaErrorInvalidValue
1153
+ * \note_graph_thread_safety
1154
+ * \notefnerr
1155
+ * \note_init_rt
1156
+ * \note_callback
1157
+ *
1158
+ * \sa
1159
+ * ::cudaMemcpyFromSymbol,
1160
+ * ::cudaGraphAddMemcpyNode,
1161
+ * ::cudaGraphAddMemcpyNodeToSymbol,
1162
+ * ::cudaGraphMemcpyNodeGetParams,
1163
+ * ::cudaGraphMemcpyNodeSetParams,
1164
+ * ::cudaGraphMemcpyNodeSetParamsFromSymbol,
1165
+ * ::cudaGraphMemcpyNodeSetParamsToSymbol,
1166
+ * ::cudaGraphCreate,
1167
+ * ::cudaGraphDestroyNode,
1168
+ * ::cudaGraphAddChildGraphNode,
1169
+ * ::cudaGraphAddEmptyNode,
1170
+ * ::cudaGraphAddKernelNode,
1171
+ * ::cudaGraphAddHostNode,
1172
+ * ::cudaGraphAddMemsetNode
1173
+ */
1174
+ template<class T>
1175
+ static __inline__ __host__ cudaError_t cudaGraphAddMemcpyNodeFromSymbol(
1176
+ cudaGraphNode_t* pGraphNode,
1177
+ cudaGraph_t graph,
1178
+ const cudaGraphNode_t* pDependencies,
1179
+ size_t numDependencies,
1180
+ void* dst,
1181
+ const T &symbol,
1182
+ size_t count,
1183
+ size_t offset,
1184
+ enum cudaMemcpyKind kind)
1185
+ {
1186
+ return ::cudaGraphAddMemcpyNodeFromSymbol(pGraphNode, graph, pDependencies, numDependencies, dst, (const void*)&symbol, count, offset, kind);
1187
+ }
1188
+
1189
+ /**
1190
+ * \brief Sets a memcpy node's parameters to copy to a symbol on the device
1191
+ *
1192
+ * Sets the parameters of memcpy node \p node to the copy described by the provided parameters.
1193
+ *
1194
+ * When the graph is launched, the node will copy \p count bytes from the memory area
1195
+ * pointed to by \p src to the memory area pointed to by \p offset bytes from the start
1196
+ * of symbol \p symbol. The memory areas may not overlap. \p symbol is a variable that
1197
+ * resides in global or constant memory space. \p kind can be either
1198
+ * ::cudaMemcpyHostToDevice, ::cudaMemcpyDeviceToDevice, or ::cudaMemcpyDefault.
1199
+ * Passing ::cudaMemcpyDefault is recommended, in which case the type of
1200
+ * transfer is inferred from the pointer values. However, ::cudaMemcpyDefault
1201
+ * is only allowed on systems that support unified virtual addressing.
1202
+ *
1203
+ * \param node - Node to set the parameters for
1204
+ * \param symbol - Device symbol address
1205
+ * \param src - Source memory address
1206
+ * \param count - Size in bytes to copy
1207
+ * \param offset - Offset from start of symbol in bytes
1208
+ * \param kind - Type of transfer
1209
+ *
1210
+ * \return
1211
+ * ::cudaSuccess,
1212
+ * ::cudaErrorInvalidValue
1213
+ * \note_graph_thread_safety
1214
+ * \notefnerr
1215
+ * \note_init_rt
1216
+ * \note_callback
1217
+ *
1218
+ * \sa
1219
+ * ::cudaMemcpyToSymbol,
1220
+ * ::cudaGraphMemcpyNodeSetParams,
1221
+ * ::cudaGraphMemcpyNodeSetParamsFromSymbol,
1222
+ * ::cudaGraphAddMemcpyNode,
1223
+ * ::cudaGraphMemcpyNodeGetParams
1224
+ */
1225
+ template<class T>
1226
+ static __inline__ __host__ cudaError_t cudaGraphMemcpyNodeSetParamsToSymbol(
1227
+ cudaGraphNode_t node,
1228
+ const T &symbol,
1229
+ const void* src,
1230
+ size_t count,
1231
+ size_t offset,
1232
+ enum cudaMemcpyKind kind)
1233
+ {
1234
+ return ::cudaGraphMemcpyNodeSetParamsToSymbol(node, (const void*)&symbol, src, count, offset, kind);
1235
+ }
1236
+
1237
+ /**
1238
+ * \brief Sets a memcpy node's parameters to copy from a symbol on the device
1239
+ *
1240
+ * Sets the parameters of memcpy node \p node to the copy described by the provided parameters.
1241
+ *
1242
+ * When the graph is launched, the node will copy \p count bytes from the memory area
1243
+ * pointed to by \p offset bytes from the start of symbol \p symbol to the memory area
1244
+ * pointed to by \p dst. The memory areas may not overlap. \p symbol is a variable
1245
+ * that resides in global or constant memory space. \p kind can be either
1246
+ * ::cudaMemcpyDeviceToHost, ::cudaMemcpyDeviceToDevice, or ::cudaMemcpyDefault.
1247
+ * Passing ::cudaMemcpyDefault is recommended, in which case the type of transfer
1248
+ * is inferred from the pointer values. However, ::cudaMemcpyDefault is only
1249
+ * allowed on systems that support unified virtual addressing.
1250
+ *
1251
+ * \param node - Node to set the parameters for
1252
+ * \param dst - Destination memory address
1253
+ * \param symbol - Device symbol address
1254
+ * \param count - Size in bytes to copy
1255
+ * \param offset - Offset from start of symbol in bytes
1256
+ * \param kind - Type of transfer
1257
+ *
1258
+ * \return
1259
+ * ::cudaSuccess,
1260
+ * ::cudaErrorInvalidValue
1261
+ * \note_graph_thread_safety
1262
+ * \notefnerr
1263
+ * \note_init_rt
1264
+ * \note_callback
1265
+ *
1266
+ * \sa
1267
+ * ::cudaMemcpyFromSymbol,
1268
+ * ::cudaGraphMemcpyNodeSetParams,
1269
+ * ::cudaGraphMemcpyNodeSetParamsToSymbol,
1270
+ * ::cudaGraphAddMemcpyNode,
1271
+ * ::cudaGraphMemcpyNodeGetParams
1272
+ */
1273
+ template<class T>
1274
+ static __inline__ __host__ cudaError_t cudaGraphMemcpyNodeSetParamsFromSymbol(
1275
+ cudaGraphNode_t node,
1276
+ void* dst,
1277
+ const T &symbol,
1278
+ size_t count,
1279
+ size_t offset,
1280
+ enum cudaMemcpyKind kind)
1281
+ {
1282
+ return ::cudaGraphMemcpyNodeSetParamsFromSymbol(node, dst, (const void*)&symbol, count, offset, kind);
1283
+ }
1284
+
1285
+ /**
1286
+ * \brief Sets the parameters for a memcpy node in the given graphExec to copy to a symbol on the device
1287
+ *
1288
+ * Updates the work represented by \p node in \p hGraphExec as though \p node had
1289
+ * contained the given params at instantiation. \p node must remain in the graph which was
1290
+ * used to instantiate \p hGraphExec. Changed edges to and from \p node are ignored.
1291
+ *
1292
+ * \p src and \p symbol must be allocated from the same contexts as the original source and
1293
+ * destination memory. The instantiation-time memory operands must be 1-dimensional.
1294
+ * Zero-length operations are not supported.
1295
+ *
1296
+ * The modifications only affect future launches of \p hGraphExec. Already enqueued
1297
+ * or running launches of \p hGraphExec are not affected by this call. \p node is also
1298
+ * not modified by this call.
1299
+ *
1300
+ * Returns ::cudaErrorInvalidValue if the memory operands' mappings changed or
1301
+ * the original memory operands are multidimensional.
1302
+ *
1303
+ * \param hGraphExec - The executable graph in which to set the specified node
1304
+ * \param node - Memcpy node from the graph which was used to instantiate graphExec
1305
+ * \param symbol - Device symbol address
1306
+ * \param src - Source memory address
1307
+ * \param count - Size in bytes to copy
1308
+ * \param offset - Offset from start of symbol in bytes
1309
+ * \param kind - Type of transfer
1310
+ *
1311
+ * \return
1312
+ * ::cudaSuccess,
1313
+ * ::cudaErrorInvalidValue
1314
+ * \note_graph_thread_safety
1315
+ * \notefnerr
1316
+ * \note_init_rt
1317
+ * \note_callback
1318
+ *
1319
+ * \sa
1320
+ * ::cudaGraphAddMemcpyNode,
1321
+ * ::cudaGraphAddMemcpyNodeToSymbol,
1322
+ * ::cudaGraphMemcpyNodeSetParams,
1323
+ * ::cudaGraphMemcpyNodeSetParamsToSymbol,
1324
+ * ::cudaGraphInstantiate,
1325
+ * ::cudaGraphExecMemcpyNodeSetParams,
1326
+ * ::cudaGraphExecMemcpyNodeSetParamsFromSymbol,
1327
+ * ::cudaGraphExecKernelNodeSetParams,
1328
+ * ::cudaGraphExecMemsetNodeSetParams,
1329
+ * ::cudaGraphExecHostNodeSetParams
1330
+ */
1331
+ template<class T>
1332
+ static __inline__ __host__ cudaError_t cudaGraphExecMemcpyNodeSetParamsToSymbol(
1333
+ cudaGraphExec_t hGraphExec,
1334
+ cudaGraphNode_t node,
1335
+ const T &symbol,
1336
+ const void* src,
1337
+ size_t count,
1338
+ size_t offset,
1339
+ enum cudaMemcpyKind kind)
1340
+ {
1341
+ return ::cudaGraphExecMemcpyNodeSetParamsToSymbol(hGraphExec, node, (const void*)&symbol, src, count, offset, kind);
1342
+ }
1343
+
1344
+ /**
1345
+ * \brief Sets the parameters for a memcpy node in the given graphExec to copy from a symbol on the device
1346
+ *
1347
+ * Updates the work represented by \p node in \p hGraphExec as though \p node had
1348
+ * contained the given params at instantiation. \p node must remain in the graph which was
1349
+ * used to instantiate \p hGraphExec. Changed edges to and from \p node are ignored.
1350
+ *
1351
+ * \p symbol and \p dst must be allocated from the same contexts as the original source and
1352
+ * destination memory. The instantiation-time memory operands must be 1-dimensional.
1353
+ * Zero-length operations are not supported.
1354
+ *
1355
+ * The modifications only affect future launches of \p hGraphExec. Already enqueued
1356
+ * or running launches of \p hGraphExec are not affected by this call. \p node is also
1357
+ * not modified by this call.
1358
+ *
1359
+ * Returns ::cudaErrorInvalidValue if the memory operands' mappings changed or
1360
+ * the original memory operands are multidimensional.
1361
+ *
1362
+ * \param hGraphExec - The executable graph in which to set the specified node
1363
+ * \param node - Memcpy node from the graph which was used to instantiate graphExec
1364
+ * \param dst - Destination memory address
1365
+ * \param symbol - Device symbol address
1366
+ * \param count - Size in bytes to copy
1367
+ * \param offset - Offset from start of symbol in bytes
1368
+ * \param kind - Type of transfer
1369
+ *
1370
+ * \return
1371
+ * ::cudaSuccess,
1372
+ * ::cudaErrorInvalidValue
1373
+ * \note_graph_thread_safety
1374
+ * \notefnerr
1375
+ * \note_init_rt
1376
+ * \note_callback
1377
+ *
1378
+ * \sa
1379
+ * ::cudaGraphAddMemcpyNode,
1380
+ * ::cudaGraphAddMemcpyNodeFromSymbol,
1381
+ * ::cudaGraphMemcpyNodeSetParams,
1382
+ * ::cudaGraphMemcpyNodeSetParamsFromSymbol,
1383
+ * ::cudaGraphInstantiate,
1384
+ * ::cudaGraphExecMemcpyNodeSetParams,
1385
+ * ::cudaGraphExecMemcpyNodeSetParamsToSymbol,
1386
+ * ::cudaGraphExecKernelNodeSetParams,
1387
+ * ::cudaGraphExecMemsetNodeSetParams,
1388
+ * ::cudaGraphExecHostNodeSetParams
1389
+ */
1390
+ template<class T>
1391
+ static __inline__ __host__ cudaError_t cudaGraphExecMemcpyNodeSetParamsFromSymbol(
1392
+ cudaGraphExec_t hGraphExec,
1393
+ cudaGraphNode_t node,
1394
+ void* dst,
1395
+ const T &symbol,
1396
+ size_t count,
1397
+ size_t offset,
1398
+ enum cudaMemcpyKind kind)
1399
+ {
1400
+ return ::cudaGraphExecMemcpyNodeSetParamsFromSymbol(hGraphExec, node, dst, (const void*)&symbol, count, offset, kind);
1401
+ }
1402
+
1403
+ // convenience function to avoid source breakage in c++ code
1404
+ static __inline__ __host__ cudaError_t CUDARTAPI cudaGraphExecUpdate(cudaGraphExec_t hGraphExec, cudaGraph_t hGraph, cudaGraphNode_t *hErrorNode_out, enum cudaGraphExecUpdateResult *updateResult_out)
1405
+ {
1406
+ cudaGraphExecUpdateResultInfo resultInfo;
1407
+ cudaError_t status = cudaGraphExecUpdate(hGraphExec, hGraph, &resultInfo);
1408
+ if (hErrorNode_out) {
1409
+ *hErrorNode_out = resultInfo.errorNode;
1410
+ }
1411
+ if (updateResult_out) {
1412
+ *updateResult_out = resultInfo.result;
1413
+ }
1414
+ return status;
1415
+ }
1416
+
1417
+ #if __cplusplus >= 201103L || (defined(_MSC_VER) && (_MSC_VER >= 1900))
1418
+
1419
+ /**
1420
+ * \brief Creates a user object by wrapping a C++ object
1421
+ *
1422
+ * TODO detail
1423
+ *
1424
+ * \param object_out - Location to return the user object handle
1425
+ * \param objectToWrap - This becomes the \ptr argument to ::cudaUserObjectCreate. A
1426
+ * lambda will be passed for the \p destroy argument, which calls
1427
+ * delete on this object pointer.
1428
+ * \param initialRefcount - The initial refcount to create the object with, typically 1. The
1429
+ * initial references are owned by the calling thread.
1430
+ * \param flags - Currently it is required to pass cudaUserObjectNoDestructorSync,
1431
+ * which is the only defined flag. This indicates that the destroy
1432
+ * callback cannot be waited on by any CUDA API. Users requiring
1433
+ * synchronization of the callback should signal its completion
1434
+ * manually.
1435
+ *
1436
+ * \return
1437
+ * ::cudaSuccess,
1438
+ * ::cudaErrorInvalidValue
1439
+ *
1440
+ * \sa
1441
+ * ::cudaUserObjectCreate
1442
+ */
1443
+ template<class T>
1444
+ static __inline__ __host__ cudaError_t cudaUserObjectCreate(
1445
+ cudaUserObject_t *object_out,
1446
+ T *objectToWrap,
1447
+ unsigned int initialRefcount,
1448
+ unsigned int flags)
1449
+ {
1450
+ return ::cudaUserObjectCreate(
1451
+ object_out,
1452
+ objectToWrap,
1453
+ [](void *vpObj) { delete reinterpret_cast<T *>(vpObj); },
1454
+ initialRefcount,
1455
+ flags);
1456
+ }
1457
+
1458
+ template<class T>
1459
+ static __inline__ __host__ cudaError_t cudaUserObjectCreate(
1460
+ cudaUserObject_t *object_out,
1461
+ T *objectToWrap,
1462
+ unsigned int initialRefcount,
1463
+ cudaUserObjectFlags flags)
1464
+ {
1465
+ return cudaUserObjectCreate(object_out, objectToWrap, initialRefcount, (unsigned int)flags);
1466
+ }
1467
+
1468
+ #endif
1469
+
1470
+ /**
1471
+ * \brief \hl Finds the address associated with a CUDA symbol
1472
+ *
1473
+ * Returns in \p *devPtr the address of symbol \p symbol on the device.
1474
+ * \p symbol can either be a variable that resides in global or constant memory space.
1475
+ * If \p symbol cannot be found, or if \p symbol is not declared
1476
+ * in the global or constant memory space, \p *devPtr is unchanged and the error
1477
+ * ::cudaErrorInvalidSymbol is returned.
1478
+ *
1479
+ * \param devPtr - Return device pointer associated with symbol
1480
+ * \param symbol - Device symbol reference
1481
+ *
1482
+ * \return
1483
+ * ::cudaSuccess,
1484
+ * ::cudaErrorInvalidSymbol,
1485
+ * ::cudaErrorNoKernelImageForDevice
1486
+ * \notefnerr
1487
+ * \note_init_rt
1488
+ * \note_callback
1489
+ *
1490
+ * \sa \ref ::cudaGetSymbolAddress(void**, const void*) "cudaGetSymbolAddress (C API)",
1491
+ * \ref ::cudaGetSymbolSize(size_t*, const T&) "cudaGetSymbolSize (C++ API)"
1492
+ */
1493
+ template<class T>
1494
+ static __inline__ __host__ cudaError_t cudaGetSymbolAddress(
1495
+ void **devPtr,
1496
+ const T &symbol
1497
+ )
1498
+ {
1499
+ return ::cudaGetSymbolAddress(devPtr, (const void*)&symbol);
1500
+ }
1501
+
1502
+ /**
1503
+ * \brief \hl Finds the size of the object associated with a CUDA symbol
1504
+ *
1505
+ * Returns in \p *size the size of symbol \p symbol. \p symbol must be a
1506
+ * variable that resides in global or constant memory space.
1507
+ * If \p symbol cannot be found, or if \p symbol is not declared
1508
+ * in global or constant memory space, \p *size is unchanged and the error
1509
+ * ::cudaErrorInvalidSymbol is returned.
1510
+ *
1511
+ * \param size - Size of object associated with symbol
1512
+ * \param symbol - Device symbol reference
1513
+ *
1514
+ * \return
1515
+ * ::cudaSuccess,
1516
+ * ::cudaErrorInvalidSymbol,
1517
+ * ::cudaErrorNoKernelImageForDevice
1518
+ * \notefnerr
1519
+ * \note_init_rt
1520
+ * \note_callback
1521
+ *
1522
+ * \sa \ref ::cudaGetSymbolAddress(void**, const T&) "cudaGetSymbolAddress (C++ API)",
1523
+ * \ref ::cudaGetSymbolSize(size_t*, const void*) "cudaGetSymbolSize (C API)"
1524
+ */
1525
+ template<class T>
1526
+ static __inline__ __host__ cudaError_t cudaGetSymbolSize(
1527
+ size_t *size,
1528
+ const T &symbol
1529
+ )
1530
+ {
1531
+ return ::cudaGetSymbolSize(size, (const void*)&symbol);
1532
+ }
1533
+
1534
+ /**
1535
+ * \brief \hl Sets the preferred cache configuration for a device function
1536
+ *
1537
+ * On devices where the L1 cache and shared memory use the same hardware
1538
+ * resources, this sets through \p cacheConfig the preferred cache configuration
1539
+ * for the function specified via \p func. This is only a preference. The
1540
+ * runtime will use the requested configuration if possible, but it is free to
1541
+ * choose a different configuration if required to execute \p func.
1542
+ *
1543
+ * \p func must be a pointer to a function that executes on the device.
1544
+ * The parameter specified by \p func must be declared as a \p __global__
1545
+ * function. If the specified function does not exist,
1546
+ * then ::cudaErrorInvalidDeviceFunction is returned.
1547
+ *
1548
+ * This setting does nothing on devices where the size of the L1 cache and
1549
+ * shared memory are fixed.
1550
+ *
1551
+ * Launching a kernel with a different preference than the most recent
1552
+ * preference setting may insert a device-side synchronization point.
1553
+ *
1554
+ * The supported cache configurations are:
1555
+ * - ::cudaFuncCachePreferNone: no preference for shared memory or L1 (default)
1556
+ * - ::cudaFuncCachePreferShared: prefer larger shared memory and smaller L1 cache
1557
+ * - ::cudaFuncCachePreferL1: prefer larger L1 cache and smaller shared memory
1558
+ *
1559
+ * \param func - device function pointer
1560
+ * \param cacheConfig - Requested cache configuration
1561
+ *
1562
+ * \return
1563
+ * ::cudaSuccess,
1564
+ * ::cudaErrorInvalidDeviceFunction
1565
+ * \notefnerr
1566
+ * \note_init_rt
1567
+ * \note_callback
1568
+ *
1569
+ * \ref ::cudaLaunchKernel(const T *func, dim3 gridDim, dim3 blockDim, void **args, size_t sharedMem, cudaStream_t stream) "cudaLaunchKernel (C++ API)",
1570
+ * \ref ::cudaFuncSetCacheConfig(const void*, enum cudaFuncCache) "cudaFuncSetCacheConfig (C API)",
1571
+ * \ref ::cudaFuncGetAttributes(struct cudaFuncAttributes*, T*) "cudaFuncGetAttributes (C++ API)",
1572
+ * ::cudaSetDoubleForDevice,
1573
+ * ::cudaSetDoubleForHost,
1574
+ * ::cudaThreadGetCacheConfig,
1575
+ * ::cudaThreadSetCacheConfig
1576
+ */
1577
+ template<class T>
1578
+ static __inline__ __host__ cudaError_t cudaFuncSetCacheConfig(
1579
+ T *func,
1580
+ enum cudaFuncCache cacheConfig
1581
+ )
1582
+ {
1583
+ return ::cudaFuncSetCacheConfig((const void*)func, cacheConfig);
1584
+ }
1585
+
1586
+ template<class T>
1587
+ static __inline__
1588
+ __CUDA_DEPRECATED
1589
+ __host__ cudaError_t cudaFuncSetSharedMemConfig(
1590
+ T *func,
1591
+ enum cudaSharedMemConfig config
1592
+ )
1593
+ {
1594
+ #if defined(__GNUC__)
1595
+ #pragma GCC diagnostic push
1596
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1597
+ #elif defined(_MSC_VER)
1598
+ #pragma warning(suppress: 4996)
1599
+ #endif
1600
+ return ::cudaFuncSetSharedMemConfig((const void*)func, config);
1601
+ #if defined(__GNUC__)
1602
+ #pragma GCC diagnostic pop
1603
+ #endif
1604
+ }
1605
+
1606
+ #endif // __CUDACC__
1607
+
1608
+ /**
1609
+ * \brief Returns occupancy for a device function
1610
+ *
1611
+ * Returns in \p *numBlocks the maximum number of active blocks per
1612
+ * streaming multiprocessor for the device function.
1613
+ *
1614
+ * \param numBlocks - Returned occupancy
1615
+ * \param func - Kernel function for which occupancy is calulated
1616
+ * \param blockSize - Block size the kernel is intended to be launched with
1617
+ * \param dynamicSMemSize - Per-block dynamic shared memory usage intended, in bytes
1618
+ *
1619
+ * \return
1620
+ * ::cudaSuccess,
1621
+ * ::cudaErrorInvalidDevice,
1622
+ * ::cudaErrorInvalidDeviceFunction,
1623
+ * ::cudaErrorInvalidValue,
1624
+ * ::cudaErrorUnknown,
1625
+ * \notefnerr
1626
+ * \note_init_rt
1627
+ * \note_callback
1628
+ *
1629
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
1630
+ * \sa ::cudaOccupancyMaxPotentialBlockSize
1631
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeWithFlags
1632
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMem
1633
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
1634
+ * \sa ::cudaOccupancyAvailableDynamicSMemPerBlock
1635
+ */
1636
+ template<class T>
1637
+ static __inline__ __host__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessor(
1638
+ int *numBlocks,
1639
+ T func,
1640
+ int blockSize,
1641
+ size_t dynamicSMemSize)
1642
+ {
1643
+ return ::cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(numBlocks, (const void*)func, blockSize, dynamicSMemSize, cudaOccupancyDefault);
1644
+ }
1645
+
1646
+ /**
1647
+ * \brief Returns occupancy for a device function with the specified flags
1648
+ *
1649
+ * Returns in \p *numBlocks the maximum number of active blocks per
1650
+ * streaming multiprocessor for the device function.
1651
+ *
1652
+ * The \p flags parameter controls how special cases are handled. Valid flags include:
1653
+ *
1654
+ * - ::cudaOccupancyDefault: keeps the default behavior as
1655
+ * ::cudaOccupancyMaxActiveBlocksPerMultiprocessor
1656
+ *
1657
+ * - ::cudaOccupancyDisableCachingOverride: suppresses the default behavior
1658
+ * on platform where global caching affects occupancy. On such platforms, if caching
1659
+ * is enabled, but per-block SM resource usage would result in zero occupancy, the
1660
+ * occupancy calculator will calculate the occupancy as if caching is disabled.
1661
+ * Setting this flag makes the occupancy calculator to return 0 in such cases.
1662
+ * More information can be found about this feature in the "Unified L1/Texture Cache"
1663
+ * section of the Maxwell tuning guide.
1664
+ *
1665
+ * \param numBlocks - Returned occupancy
1666
+ * \param func - Kernel function for which occupancy is calulated
1667
+ * \param blockSize - Block size the kernel is intended to be launched with
1668
+ * \param dynamicSMemSize - Per-block dynamic shared memory usage intended, in bytes
1669
+ * \param flags - Requested behavior for the occupancy calculator
1670
+ *
1671
+ * \return
1672
+ * ::cudaSuccess,
1673
+ * ::cudaErrorInvalidDevice,
1674
+ * ::cudaErrorInvalidDeviceFunction,
1675
+ * ::cudaErrorInvalidValue,
1676
+ * ::cudaErrorUnknown,
1677
+ * \notefnerr
1678
+ * \note_init_rt
1679
+ * \note_callback
1680
+ *
1681
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessor
1682
+ * \sa ::cudaOccupancyMaxPotentialBlockSize
1683
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeWithFlags
1684
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMem
1685
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
1686
+ * \sa ::cudaOccupancyAvailableDynamicSMemPerBlock
1687
+ */
1688
+ template<class T>
1689
+ static __inline__ __host__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
1690
+ int *numBlocks,
1691
+ T func,
1692
+ int blockSize,
1693
+ size_t dynamicSMemSize,
1694
+ unsigned int flags)
1695
+ {
1696
+ return ::cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(numBlocks, (const void*)func, blockSize, dynamicSMemSize, flags);
1697
+ }
1698
+
1699
+ /**
1700
+ * Helper functor for cudaOccupancyMaxPotentialBlockSize
1701
+ */
1702
+ class __cudaOccupancyB2DHelper {
1703
+ size_t n;
1704
+ public:
1705
+ inline __host__ CUDART_DEVICE __cudaOccupancyB2DHelper(size_t n_) : n(n_) {}
1706
+ inline __host__ CUDART_DEVICE size_t operator()(int)
1707
+ {
1708
+ return n;
1709
+ }
1710
+ };
1711
+
1712
+ /**
1713
+ * \brief Returns grid and block size that achieves maximum potential occupancy for a device function
1714
+ *
1715
+ * Returns in \p *minGridSize and \p *blocksize a suggested grid /
1716
+ * block size pair that achieves the best potential occupancy
1717
+ * (i.e. the maximum number of active warps with the smallest number
1718
+ * of blocks).
1719
+ *
1720
+ * The \p flags parameter controls how special cases are handled. Valid flags include:
1721
+ *
1722
+ * - ::cudaOccupancyDefault: keeps the default behavior as
1723
+ * ::cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
1724
+ *
1725
+ * - ::cudaOccupancyDisableCachingOverride: This flag suppresses the default behavior
1726
+ * on platform where global caching affects occupancy. On such platforms, if caching
1727
+ * is enabled, but per-block SM resource usage would result in zero occupancy, the
1728
+ * occupancy calculator will calculate the occupancy as if caching is disabled.
1729
+ * Setting this flag makes the occupancy calculator to return 0 in such cases.
1730
+ * More information can be found about this feature in the "Unified L1/Texture Cache"
1731
+ * section of the Maxwell tuning guide.
1732
+ *
1733
+ * \param minGridSize - Returned minimum grid size needed to achieve the best potential occupancy
1734
+ * \param blockSize - Returned block size
1735
+ * \param func - Device function symbol
1736
+ * \param blockSizeToDynamicSMemSize - A unary function / functor that takes block size, and returns the size, in bytes, of dynamic shared memory needed for a block
1737
+ * \param blockSizeLimit - The maximum block size \p func is designed to work with. 0 means no limit.
1738
+ * \param flags - Requested behavior for the occupancy calculator
1739
+ *
1740
+ * \return
1741
+ * ::cudaSuccess,
1742
+ * ::cudaErrorInvalidDevice,
1743
+ * ::cudaErrorInvalidDeviceFunction,
1744
+ * ::cudaErrorInvalidValue,
1745
+ * ::cudaErrorUnknown,
1746
+ * \notefnerr
1747
+ * \note_init_rt
1748
+ * \note_callback
1749
+ *
1750
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMem
1751
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessor
1752
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
1753
+ * \sa ::cudaOccupancyMaxPotentialBlockSize
1754
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeWithFlags
1755
+ * \sa ::cudaOccupancyAvailableDynamicSMemPerBlock
1756
+ */
1757
+
1758
+ template<typename UnaryFunction, class T>
1759
+ static __inline__ __host__ CUDART_DEVICE cudaError_t cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags(
1760
+ int *minGridSize,
1761
+ int *blockSize,
1762
+ T func,
1763
+ UnaryFunction blockSizeToDynamicSMemSize,
1764
+ int blockSizeLimit = 0,
1765
+ unsigned int flags = 0)
1766
+ {
1767
+ cudaError_t status;
1768
+
1769
+ // Device and function properties
1770
+ int device;
1771
+ struct cudaFuncAttributes attr;
1772
+
1773
+ // Limits
1774
+ int maxThreadsPerMultiProcessor;
1775
+ int warpSize;
1776
+ int devMaxThreadsPerBlock;
1777
+ int multiProcessorCount;
1778
+ int funcMaxThreadsPerBlock;
1779
+ int occupancyLimit;
1780
+ int granularity;
1781
+
1782
+ // Recorded maximum
1783
+ int maxBlockSize = 0;
1784
+ int numBlocks = 0;
1785
+ int maxOccupancy = 0;
1786
+
1787
+ // Temporary
1788
+ int blockSizeToTryAligned;
1789
+ int blockSizeToTry;
1790
+ int blockSizeLimitAligned;
1791
+ int occupancyInBlocks;
1792
+ int occupancyInThreads;
1793
+ size_t dynamicSMemSize;
1794
+
1795
+ ///////////////////////////
1796
+ // Check user input
1797
+ ///////////////////////////
1798
+
1799
+ if (!minGridSize || !blockSize || !func) {
1800
+ return cudaErrorInvalidValue;
1801
+ }
1802
+
1803
+ //////////////////////////////////////////////
1804
+ // Obtain device and function properties
1805
+ //////////////////////////////////////////////
1806
+
1807
+ status = ::cudaGetDevice(&device);
1808
+ if (status != cudaSuccess) {
1809
+ return status;
1810
+ }
1811
+
1812
+ status = cudaDeviceGetAttribute(
1813
+ &maxThreadsPerMultiProcessor,
1814
+ cudaDevAttrMaxThreadsPerMultiProcessor,
1815
+ device);
1816
+ if (status != cudaSuccess) {
1817
+ return status;
1818
+ }
1819
+
1820
+ status = cudaDeviceGetAttribute(
1821
+ &warpSize,
1822
+ cudaDevAttrWarpSize,
1823
+ device);
1824
+ if (status != cudaSuccess) {
1825
+ return status;
1826
+ }
1827
+
1828
+ status = cudaDeviceGetAttribute(
1829
+ &devMaxThreadsPerBlock,
1830
+ cudaDevAttrMaxThreadsPerBlock,
1831
+ device);
1832
+ if (status != cudaSuccess) {
1833
+ return status;
1834
+ }
1835
+
1836
+ status = cudaDeviceGetAttribute(
1837
+ &multiProcessorCount,
1838
+ cudaDevAttrMultiProcessorCount,
1839
+ device);
1840
+ if (status != cudaSuccess) {
1841
+ return status;
1842
+ }
1843
+
1844
+ status = cudaFuncGetAttributes(&attr, func);
1845
+ if (status != cudaSuccess) {
1846
+ return status;
1847
+ }
1848
+
1849
+ funcMaxThreadsPerBlock = attr.maxThreadsPerBlock;
1850
+
1851
+ /////////////////////////////////////////////////////////////////////////////////
1852
+ // Try each block size, and pick the block size with maximum occupancy
1853
+ /////////////////////////////////////////////////////////////////////////////////
1854
+
1855
+ occupancyLimit = maxThreadsPerMultiProcessor;
1856
+ granularity = warpSize;
1857
+
1858
+ if (blockSizeLimit == 0) {
1859
+ blockSizeLimit = devMaxThreadsPerBlock;
1860
+ }
1861
+
1862
+ if (devMaxThreadsPerBlock < blockSizeLimit) {
1863
+ blockSizeLimit = devMaxThreadsPerBlock;
1864
+ }
1865
+
1866
+ if (funcMaxThreadsPerBlock < blockSizeLimit) {
1867
+ blockSizeLimit = funcMaxThreadsPerBlock;
1868
+ }
1869
+
1870
+ blockSizeLimitAligned = ((blockSizeLimit + (granularity - 1)) / granularity) * granularity;
1871
+
1872
+ for (blockSizeToTryAligned = blockSizeLimitAligned; blockSizeToTryAligned > 0; blockSizeToTryAligned -= granularity) {
1873
+ // This is needed for the first iteration, because
1874
+ // blockSizeLimitAligned could be greater than blockSizeLimit
1875
+ //
1876
+ if (blockSizeLimit < blockSizeToTryAligned) {
1877
+ blockSizeToTry = blockSizeLimit;
1878
+ } else {
1879
+ blockSizeToTry = blockSizeToTryAligned;
1880
+ }
1881
+
1882
+ dynamicSMemSize = blockSizeToDynamicSMemSize(blockSizeToTry);
1883
+
1884
+ status = cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
1885
+ &occupancyInBlocks,
1886
+ func,
1887
+ blockSizeToTry,
1888
+ dynamicSMemSize,
1889
+ flags);
1890
+
1891
+ if (status != cudaSuccess) {
1892
+ return status;
1893
+ }
1894
+
1895
+ occupancyInThreads = blockSizeToTry * occupancyInBlocks;
1896
+
1897
+ if (occupancyInThreads > maxOccupancy) {
1898
+ maxBlockSize = blockSizeToTry;
1899
+ numBlocks = occupancyInBlocks;
1900
+ maxOccupancy = occupancyInThreads;
1901
+ }
1902
+
1903
+ // Early out if we have reached the maximum
1904
+ //
1905
+ if (occupancyLimit == maxOccupancy) {
1906
+ break;
1907
+ }
1908
+ }
1909
+
1910
+ ///////////////////////////
1911
+ // Return best available
1912
+ ///////////////////////////
1913
+
1914
+ // Suggested min grid size to achieve a full machine launch
1915
+ //
1916
+ *minGridSize = numBlocks * multiProcessorCount;
1917
+ *blockSize = maxBlockSize;
1918
+
1919
+ return status;
1920
+ }
1921
+
1922
+ /**
1923
+ * \brief Returns grid and block size that achieves maximum potential occupancy for a device function
1924
+ *
1925
+ * Returns in \p *minGridSize and \p *blocksize a suggested grid /
1926
+ * block size pair that achieves the best potential occupancy
1927
+ * (i.e. the maximum number of active warps with the smallest number
1928
+ * of blocks).
1929
+ *
1930
+ * \param minGridSize - Returned minimum grid size needed to achieve the best potential occupancy
1931
+ * \param blockSize - Returned block size
1932
+ * \param func - Device function symbol
1933
+ * \param blockSizeToDynamicSMemSize - A unary function / functor that takes block size, and returns the size, in bytes, of dynamic shared memory needed for a block
1934
+ * \param blockSizeLimit - The maximum block size \p func is designed to work with. 0 means no limit.
1935
+ *
1936
+ * \return
1937
+ * ::cudaSuccess,
1938
+ * ::cudaErrorInvalidDevice,
1939
+ * ::cudaErrorInvalidDeviceFunction,
1940
+ * ::cudaErrorInvalidValue,
1941
+ * ::cudaErrorUnknown,
1942
+ * \notefnerr
1943
+ * \note_init_rt
1944
+ * \note_callback
1945
+ *
1946
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
1947
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessor
1948
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
1949
+ * \sa ::cudaOccupancyMaxPotentialBlockSize
1950
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeWithFlags
1951
+ * \sa ::cudaOccupancyAvailableDynamicSMemPerBlock
1952
+ */
1953
+
1954
+ template<typename UnaryFunction, class T>
1955
+ static __inline__ __host__ CUDART_DEVICE cudaError_t cudaOccupancyMaxPotentialBlockSizeVariableSMem(
1956
+ int *minGridSize,
1957
+ int *blockSize,
1958
+ T func,
1959
+ UnaryFunction blockSizeToDynamicSMemSize,
1960
+ int blockSizeLimit = 0)
1961
+ {
1962
+ return cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags(minGridSize, blockSize, func, blockSizeToDynamicSMemSize, blockSizeLimit, cudaOccupancyDefault);
1963
+ }
1964
+
1965
+ /**
1966
+ * \brief Returns grid and block size that achieves maximum potential occupancy for a device function
1967
+ *
1968
+ * Returns in \p *minGridSize and \p *blocksize a suggested grid /
1969
+ * block size pair that achieves the best potential occupancy
1970
+ * (i.e. the maximum number of active warps with the smallest number
1971
+ * of blocks).
1972
+ *
1973
+ * Use \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMem if the
1974
+ * amount of per-block dynamic shared memory changes with different
1975
+ * block sizes.
1976
+ *
1977
+ * \param minGridSize - Returned minimum grid size needed to achieve the best potential occupancy
1978
+ * \param blockSize - Returned block size
1979
+ * \param func - Device function symbol
1980
+ * \param dynamicSMemSize - Per-block dynamic shared memory usage intended, in bytes
1981
+ * \param blockSizeLimit - The maximum block size \p func is designed to work with. 0 means no limit.
1982
+ *
1983
+ * \return
1984
+ * ::cudaSuccess,
1985
+ * ::cudaErrorInvalidDevice,
1986
+ * ::cudaErrorInvalidDeviceFunction,
1987
+ * ::cudaErrorInvalidValue,
1988
+ * ::cudaErrorUnknown,
1989
+ * \notefnerr
1990
+ * \note_init_rt
1991
+ * \note_callback
1992
+ *
1993
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeWithFlags
1994
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessor
1995
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
1996
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMem
1997
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
1998
+ * \sa ::cudaOccupancyAvailableDynamicSMemPerBlock
1999
+ */
2000
+ template<class T>
2001
+ static __inline__ __host__ CUDART_DEVICE cudaError_t cudaOccupancyMaxPotentialBlockSize(
2002
+ int *minGridSize,
2003
+ int *blockSize,
2004
+ T func,
2005
+ size_t dynamicSMemSize = 0,
2006
+ int blockSizeLimit = 0)
2007
+ {
2008
+ return cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags(minGridSize, blockSize, func, __cudaOccupancyB2DHelper(dynamicSMemSize), blockSizeLimit, cudaOccupancyDefault);
2009
+ }
2010
+
2011
+ /**
2012
+ * \brief Returns dynamic shared memory available per block when launching \p numBlocks blocks on SM.
2013
+ *
2014
+ * Returns in \p *dynamicSmemSize the maximum size of dynamic shared memory to allow \p numBlocks blocks per SM.
2015
+ *
2016
+ * \param dynamicSmemSize - Returned maximum dynamic shared memory
2017
+ * \param func - Kernel function for which occupancy is calculated
2018
+ * \param numBlocks - Number of blocks to fit on SM
2019
+ * \param blockSize - Size of the block
2020
+ *
2021
+ * \return
2022
+ * ::cudaSuccess,
2023
+ * ::cudaErrorInvalidDevice,
2024
+ * ::cudaErrorInvalidDeviceFunction,
2025
+ * ::cudaErrorInvalidValue,
2026
+ * ::cudaErrorUnknown,
2027
+ * \notefnerr
2028
+ * \note_init_rt
2029
+ * \note_callback
2030
+ *
2031
+ * \sa ::cudaOccupancyMaxPotentialBlockSize
2032
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeWithFlags
2033
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessor
2034
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
2035
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMem
2036
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
2037
+ */
2038
+ template<class T>
2039
+ static __inline__ __host__ cudaError_t cudaOccupancyAvailableDynamicSMemPerBlock(
2040
+ size_t *dynamicSmemSize,
2041
+ T func,
2042
+ int numBlocks,
2043
+ int blockSize)
2044
+ {
2045
+ return ::cudaOccupancyAvailableDynamicSMemPerBlock(dynamicSmemSize, (const void*)func, numBlocks, blockSize);
2046
+ }
2047
+
2048
+ /**
2049
+ * \brief Returns grid and block size that achived maximum potential occupancy for a device function with the specified flags
2050
+ *
2051
+ * Returns in \p *minGridSize and \p *blocksize a suggested grid /
2052
+ * block size pair that achieves the best potential occupancy
2053
+ * (i.e. the maximum number of active warps with the smallest number
2054
+ * of blocks).
2055
+ *
2056
+ * The \p flags parameter controls how special cases are handle. Valid flags include:
2057
+ *
2058
+ * - ::cudaOccupancyDefault: keeps the default behavior as
2059
+ * ::cudaOccupancyMaxPotentialBlockSize
2060
+ *
2061
+ * - ::cudaOccupancyDisableCachingOverride: This flag suppresses the default behavior
2062
+ * on platform where global caching affects occupancy. On such platforms, if caching
2063
+ * is enabled, but per-block SM resource usage would result in zero occupancy, the
2064
+ * occupancy calculator will calculate the occupancy as if caching is disabled.
2065
+ * Setting this flag makes the occupancy calculator to return 0 in such cases.
2066
+ * More information can be found about this feature in the "Unified L1/Texture Cache"
2067
+ * section of the Maxwell tuning guide.
2068
+ *
2069
+ * Use \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMem if the
2070
+ * amount of per-block dynamic shared memory changes with different
2071
+ * block sizes.
2072
+ *
2073
+ * \param minGridSize - Returned minimum grid size needed to achieve the best potential occupancy
2074
+ * \param blockSize - Returned block size
2075
+ * \param func - Device function symbol
2076
+ * \param dynamicSMemSize - Per-block dynamic shared memory usage intended, in bytes
2077
+ * \param blockSizeLimit - The maximum block size \p func is designed to work with. 0 means no limit.
2078
+ * \param flags - Requested behavior for the occupancy calculator
2079
+ *
2080
+ * \return
2081
+ * ::cudaSuccess,
2082
+ * ::cudaErrorInvalidDevice,
2083
+ * ::cudaErrorInvalidDeviceFunction,
2084
+ * ::cudaErrorInvalidValue,
2085
+ * ::cudaErrorUnknown,
2086
+ * \notefnerr
2087
+ * \note_init_rt
2088
+ * \note_callback
2089
+ *
2090
+ * \sa ::cudaOccupancyMaxPotentialBlockSize
2091
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessor
2092
+ * \sa ::cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
2093
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMem
2094
+ * \sa ::cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
2095
+ * \sa ::cudaOccupancyAvailableDynamicSMemPerBlock
2096
+ */
2097
+ template<class T>
2098
+ static __inline__ __host__ CUDART_DEVICE cudaError_t cudaOccupancyMaxPotentialBlockSizeWithFlags(
2099
+ int *minGridSize,
2100
+ int *blockSize,
2101
+ T func,
2102
+ size_t dynamicSMemSize = 0,
2103
+ int blockSizeLimit = 0,
2104
+ unsigned int flags = 0)
2105
+ {
2106
+ return cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags(minGridSize, blockSize, func, __cudaOccupancyB2DHelper(dynamicSMemSize), blockSizeLimit, flags);
2107
+ }
2108
+
2109
+ /**
2110
+ * \brief Given the kernel function (\p func) and launch configuration
2111
+ * (\p config), return the maximum cluster size in \p *clusterSize.
2112
+ *
2113
+ * The cluster dimensions in \p config are ignored. If func has a required
2114
+ * cluster size set (see ::cudaFuncGetAttributes),\p *clusterSize will reflect
2115
+ * the required cluster size.
2116
+ *
2117
+ * By default this function will always return a value that's portable on
2118
+ * future hardware. A higher value may be returned if the kernel function
2119
+ * allows non-portable cluster sizes.
2120
+ *
2121
+ * This function will respect the compile time launch bounds.
2122
+ *
2123
+ * \param clusterSize - Returned maximum cluster size that can be launched
2124
+ * for the given kernel function and launch configuration
2125
+ * \param func - Kernel function for which maximum cluster
2126
+ * size is calculated
2127
+ * \param config - Launch configuration for the given kernel function
2128
+ *
2129
+ * \return
2130
+ * ::cudaSuccess,
2131
+ * ::cudaErrorInvalidDeviceFunction,
2132
+ * ::cudaErrorInvalidValue,
2133
+ * ::cudaErrorUnknown,
2134
+ * \notefnerr
2135
+ * \note_init_rt
2136
+ * \note_callback
2137
+ *
2138
+ * \sa
2139
+ * ::cudaFuncGetAttributes
2140
+ */
2141
+ template<class T>
2142
+ static __inline__ __host__ cudaError_t cudaOccupancyMaxPotentialClusterSize(
2143
+ int *clusterSize,
2144
+ T *func,
2145
+ const cudaLaunchConfig_t *config)
2146
+ {
2147
+ return ::cudaOccupancyMaxPotentialClusterSize(clusterSize, (const void*)func, config);
2148
+ }
2149
+
2150
+ /**
2151
+ * \brief Given the kernel function (\p func) and launch configuration
2152
+ * (\p config), return the maximum number of clusters that could co-exist
2153
+ * on the target device in \p *numClusters.
2154
+ *
2155
+ * If the function has required cluster size already set (see
2156
+ * ::cudaFuncGetAttributes), the cluster size from config must either be
2157
+ * unspecified or match the required size.
2158
+ * Without required sizes, the cluster size must be specified in config,
2159
+ * else the function will return an error.
2160
+ *
2161
+ * Note that various attributes of the kernel function may affect occupancy
2162
+ * calculation. Runtime environment may affect how the hardware schedules
2163
+ * the clusters, so the calculated occupancy is not guaranteed to be achievable.
2164
+ *
2165
+ * \param numClusters - Returned maximum number of clusters that
2166
+ * could co-exist on the target device
2167
+ * \param func - Kernel function for which maximum number
2168
+ * of clusters are calculated
2169
+ * \param config - Launch configuration for the given kernel function
2170
+ *
2171
+ * \return
2172
+ * ::cudaSuccess,
2173
+ * ::cudaErrorInvalidDeviceFunction,
2174
+ * ::cudaErrorInvalidValue,
2175
+ * ::cudaErrorInvalidClusterSize,
2176
+ * ::cudaErrorUnknown,
2177
+ * \notefnerr
2178
+ * \note_init_rt
2179
+ * \note_callback
2180
+ *
2181
+ * \sa
2182
+ * ::cudaFuncGetAttributes
2183
+ */
2184
+ template<class T>
2185
+ static __inline__ __host__ cudaError_t cudaOccupancyMaxActiveClusters(
2186
+ int *numClusters,
2187
+ T *func,
2188
+ const cudaLaunchConfig_t *config)
2189
+ {
2190
+ return ::cudaOccupancyMaxActiveClusters(numClusters, (const void*)func, config);
2191
+ }
2192
+
2193
+ #if defined __CUDACC__
2194
+
2195
+ /**
2196
+ * \brief \hl Find out attributes for a given function
2197
+ *
2198
+ * This function obtains the attributes of a function specified via \p entry.
2199
+ * The parameter \p entry must be a pointer to a function that executes
2200
+ * on the device. The parameter specified by \p entry must be declared as a \p __global__
2201
+ * function. The fetched attributes are placed in \p attr. If the specified
2202
+ * function does not exist, then ::cudaErrorInvalidDeviceFunction is returned.
2203
+ *
2204
+ * Note that some function attributes such as
2205
+ * \ref ::cudaFuncAttributes::maxThreadsPerBlock "maxThreadsPerBlock"
2206
+ * may vary based on the device that is currently being used.
2207
+ *
2208
+ * \param attr - Return pointer to function's attributes
2209
+ * \param entry - Function to get attributes of
2210
+ *
2211
+ * \return
2212
+ * ::cudaSuccess,
2213
+ * ::cudaErrorInvalidDeviceFunction
2214
+ * \notefnerr
2215
+ * \note_init_rt
2216
+ * \note_callback
2217
+ *
2218
+ * \ref ::cudaLaunchKernel(const T *func, dim3 gridDim, dim3 blockDim, void **args, size_t sharedMem, cudaStream_t stream) "cudaLaunchKernel (C++ API)",
2219
+ * \ref ::cudaFuncSetCacheConfig(T*, enum cudaFuncCache) "cudaFuncSetCacheConfig (C++ API)",
2220
+ * \ref ::cudaFuncGetAttributes(struct cudaFuncAttributes*, const void*) "cudaFuncGetAttributes (C API)",
2221
+ * ::cudaSetDoubleForDevice,
2222
+ * ::cudaSetDoubleForHost
2223
+ */
2224
+ template<class T>
2225
+ static __inline__ __host__ cudaError_t cudaFuncGetAttributes(
2226
+ struct cudaFuncAttributes *attr,
2227
+ T *entry
2228
+ )
2229
+ {
2230
+ return ::cudaFuncGetAttributes(attr, (const void*)entry);
2231
+ }
2232
+
2233
+ /**
2234
+ * \brief \hl Set attributes for a given function
2235
+ *
2236
+ * This function sets the attributes of a function specified via \p entry.
2237
+ * The parameter \p entry must be a pointer to a function that executes
2238
+ * on the device. The parameter specified by \p entry must be declared as a \p __global__
2239
+ * function. The enumeration defined by \p attr is set to the value defined by \p value.
2240
+ * If the specified function does not exist, then ::cudaErrorInvalidDeviceFunction is returned.
2241
+ * If the specified attribute cannot be written, or if the value is incorrect,
2242
+ * then ::cudaErrorInvalidValue is returned.
2243
+ *
2244
+ * Valid values for \p attr are:
2245
+ * - ::cudaFuncAttributeMaxDynamicSharedMemorySize - The requested maximum size in bytes of dynamically-allocated shared memory. The sum of this value and the function attribute ::sharedSizeBytes
2246
+ * cannot exceed the device attribute ::cudaDevAttrMaxSharedMemoryPerBlockOptin. The maximal size of requestable dynamic shared memory may differ by GPU architecture.
2247
+ * - ::cudaFuncAttributePreferredSharedMemoryCarveout - On devices where the L1 cache and shared memory use the same hardware resources,
2248
+ * this sets the shared memory carveout preference, in percent of the total shared memory. See ::cudaDevAttrMaxSharedMemoryPerMultiprocessor.
2249
+ * This is only a hint, and the driver can choose a different ratio if required to execute the function.
2250
+ * - ::cudaFuncAttributeRequiredClusterWidth: The required cluster width in
2251
+ * blocks. The width, height, and depth values must either all be 0 or all be
2252
+ * positive. The validity of the cluster dimensions is checked at launch time.
2253
+ * If the value is set during compile time, it cannot be set at runtime.
2254
+ * Setting it at runtime will return cudaErrorNotPermitted.
2255
+ * - ::cudaFuncAttributeRequiredClusterHeight: The required cluster height in
2256
+ * blocks. The width, height, and depth values must either all be 0 or all be
2257
+ * positive. The validity of the cluster dimensions is checked at launch time.
2258
+ * If the value is set during compile time, it cannot be set at runtime.
2259
+ * Setting it at runtime will return cudaErrorNotPermitted.
2260
+ * - ::cudaFuncAttributeRequiredClusterDepth: The required cluster depth in
2261
+ * blocks. The width, height, and depth values must either all be 0 or all be
2262
+ * positive. The validity of the cluster dimensions is checked at launch time.
2263
+ * If the value is set during compile time, it cannot be set at runtime.
2264
+ * Setting it at runtime will return cudaErrorNotPermitted.
2265
+ * - ::cudaFuncAttributeClusterSchedulingPolicyPreference: The block
2266
+ * scheduling policy of a function. The value type is cudaClusterSchedulingPolicy.
2267
+ *
2268
+ * \param entry - Function to get attributes of
2269
+ * \param attr - Attribute to set
2270
+ * \param value - Value to set
2271
+ *
2272
+ * \return
2273
+ * ::cudaSuccess,
2274
+ * ::cudaErrorInvalidDeviceFunction,
2275
+ * ::cudaErrorInvalidValue
2276
+ * \notefnerr
2277
+ * \note_init_rt
2278
+ * \note_callback
2279
+ *
2280
+ * \ref ::cudaLaunchKernel(const T *func, dim3 gridDim, dim3 blockDim, void **args, size_t sharedMem, cudaStream_t stream) "cudaLaunchKernel (C++ API)",
2281
+ * \ref ::cudaFuncSetCacheConfig(T*, enum cudaFuncCache) "cudaFuncSetCacheConfig (C++ API)",
2282
+ * \ref ::cudaFuncGetAttributes(struct cudaFuncAttributes*, const void*) "cudaFuncGetAttributes (C API)",
2283
+ * ::cudaSetDoubleForDevice,
2284
+ * ::cudaSetDoubleForHost
2285
+ */
2286
+ template<class T>
2287
+ static __inline__ __host__ cudaError_t cudaFuncSetAttribute(
2288
+ T *entry,
2289
+ enum cudaFuncAttribute attr,
2290
+ int value
2291
+ )
2292
+ {
2293
+ return ::cudaFuncSetAttribute((const void*)entry, attr, value);
2294
+ }
2295
+
2296
+ /**
2297
+ * \brief Returns the function name for a device entry function pointer.
2298
+ *
2299
+ * Returns in \p **name the function name associated with the symbol \p func .
2300
+ * The function name is returned as a null-terminated string. This API may
2301
+ * return a mangled name if the function is not declared as having C linkage.
2302
+ * If \p **name is NULL, ::cudaErrorInvalidValue is returned. If \p func is
2303
+ * not a device entry function, ::cudaErrorInvalidDeviceFunction is returned.
2304
+ *
2305
+ * \param name - The returned name of the function
2306
+ * \param func - The function pointer to retrieve name for
2307
+ *
2308
+ * \return
2309
+ * ::cudaSuccess,
2310
+ * ::cudaErrorInvalidValue,
2311
+ * ::cudaErrorInvalidDeviceFunction
2312
+ * \notefnerr
2313
+ * \note_init_rt
2314
+ * \note_callback
2315
+ *
2316
+ * \ref ::cudaFuncGetName(const char **name, const void *func) "cudaFuncGetName (C API)"
2317
+ */
2318
+ template<class T>
2319
+ static __inline__ __host__ cudaError_t CUDARTAPI cudaFuncGetName(
2320
+ const char **name,
2321
+ const T *func
2322
+ )
2323
+ {
2324
+ return ::cudaFuncGetName(name, (const void *)func);
2325
+ }
2326
+
2327
+ /**
2328
+ * \brief Get pointer to device kernel that matches entry function \p entryFuncAddr
2329
+ *
2330
+ * Returns in \p kernelPtr the device kernel corresponding to the entry function \p entryFuncAddr.
2331
+ *
2332
+ * \param kernelPtr - Returns the device kernel
2333
+ * \param entryFuncAddr - Address of device entry function to search kernel for
2334
+ *
2335
+ * \return
2336
+ * ::cudaSuccess
2337
+ *
2338
+ * \sa
2339
+ * \ref ::cudaGetKernel(cudaKernel_t *kernelPtr, const void *entryFuncAddr) "cudaGetKernel (C API)"
2340
+ */
2341
+ template<class T>
2342
+ static __inline__ __host__ cudaError_t cudaGetKernel(
2343
+ cudaKernel_t *kernelPtr,
2344
+ const T *entryFuncAddr
2345
+ )
2346
+ {
2347
+ return ::cudaGetKernel(kernelPtr, (const void *)entryFuncAddr);
2348
+ }
2349
+
2350
+ #endif /* __CUDACC__ */
2351
+
2352
+ /** @} */ /* END CUDART_HIGHLEVEL */
2353
+
2354
+ #endif /* __cplusplus && !__CUDACC_RTC__ */
2355
+
2356
+ #if !defined(__CUDACC_RTC__)
2357
+ #if defined(__GNUC__)
2358
+ #if defined(__clang__) || (!defined(__PGIC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
2359
+ #pragma GCC diagnostic pop
2360
+ #endif
2361
+ #elif defined(_MSC_VER)
2362
+ #pragma warning(pop)
2363
+ #endif
2364
+ #endif
2365
+
2366
+ #undef EXCLUDE_FROM_RTC
2367
+ #undef __CUDA_DEPRECATED
2368
+
2369
+ #if defined(__UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_CUDA_RUNTIME_H__)
2370
+ #undef __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
2371
+ #undef __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_CUDA_RUNTIME_H__
2372
+ #endif
2373
+
2374
+ #endif /* !__CUDA_RUNTIME_H__ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cuda_texture_types.h ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(__CUDA_TEXTURE_TYPES_H__)
51
+ #define __CUDA_TEXTURE_TYPES_H__
52
+
53
+ #if defined(__cplusplus) && defined(__CUDACC__)
54
+
55
+ /*******************************************************************************
56
+ * *
57
+ * *
58
+ * *
59
+ *******************************************************************************/
60
+
61
+ #if !defined(__CUDACC_RTC__)
62
+ #define EXCLUDE_FROM_RTC
63
+ #include "channel_descriptor.h"
64
+ #undef EXCLUDE_FROM_RTC
65
+ #endif /* !__CUDACC_RTC__ */
66
+ #include "cuda_runtime_api.h"
67
+
68
+ /*******************************************************************************
69
+ * *
70
+ * *
71
+ * *
72
+ *******************************************************************************/
73
+
74
+ #endif /* __cplusplus && __CUDACC__ */
75
+
76
+ #endif /* !__CUDA_TEXTURE_TYPES_H__ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cupti_checkpoint.h ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ #include <cuda.h>
4
+ #include <cupti_result.h>
5
+
6
+ #include <stddef.h>
7
+ #include <stdint.h>
8
+
9
+ namespace NV { namespace Cupti { namespace Checkpoint {
10
+
11
+ #ifdef __cplusplus
12
+ extern "C"
13
+ {
14
+ #endif
15
+
16
+ /**
17
+ * \defgroup CUPTI_CHECKPOINT_API CUPTI Checkpoint API
18
+ * Functions, types, and enums that implement the CUPTI Checkpoint API.
19
+ * @{
20
+ */
21
+
22
+ /**
23
+ * \brief Specifies optimization options for a checkpoint, may be OR'd together to specify multiple options.
24
+ */
25
+ typedef enum
26
+ {
27
+ CUPTI_CHECKPOINT_OPT_NONE = 0, //!< Default behavior
28
+ CUPTI_CHECKPOINT_OPT_TRANSFER = 1, //!< Determine which mem blocks have changed, and only restore those. This optimization is cached, which means cuptiCheckpointRestore must always be called at the same point in the application when this option is enabled, or the result may be incorrect.
29
+ } CUpti_CheckpointOptimizations;
30
+
31
+ /**
32
+ * \brief Configuration and handle for a CUPTI Checkpoint
33
+ *
34
+ * A CUptiCheckpoint object should be initialized with desired options prior to passing into any
35
+ * CUPTI Checkpoint API function. The first call into a Checkpoint API function will initialize internal
36
+ * state based on these options. Subsequent changes to these options will not have any effect.
37
+ *
38
+ * Checkpoint data is saved in device, host, and filesystem space. There are options to reserve memory
39
+ * at each level (device, host, filesystem) which are intended to allow a guarantee that a certain amount
40
+ * of memory will remain free for use after the checkpoint is saved.
41
+ * Note, however, that falling back to slower levels of memory (host, and then filesystem) to save the checkpoint
42
+ * will result in performance degradation.
43
+ * Currently, the filesystem limitation is not implemented. Note that falling back to filesystem storage may
44
+ * significantly impact the performance for saving and restoring a checkpoint.
45
+ */
46
+ typedef struct
47
+ {
48
+ size_t structSize; //!< [in] Must be set to CUpti_Checkpoint_STRUCT_SIZE
49
+
50
+ CUcontext ctx; //!< [in] Set to context to save from, or will use current context if NULL
51
+
52
+ size_t reserveDeviceMB; //!< [in] Restrict checkpoint from using last N MB of device memory (-1 = use no device memory)
53
+ size_t reserveHostMB; //!< [in] Restrict checkpoint from using last N MB of host memory (-1 = use no host memory)
54
+ uint8_t allowOverwrite; //!< [in] Boolean, Allow checkpoint to save over existing checkpoint
55
+ uint8_t optimizations; //!< [in] Mask of CUpti_CheckpointOptimizations flags for this checkpoint
56
+
57
+ void * pPriv; //!< [in] Assign to NULL
58
+ } CUpti_Checkpoint;
59
+
60
+ #define CUpti_Checkpoint_STRUCT_SIZE \
61
+ (offsetof(CUpti_Checkpoint, pPriv) + \
62
+ sizeof(((CUpti_Checkpoint*)(nullptr))->pPriv))
63
+
64
+ #if defined(__GNUC__) && defined(CUPTI_LIB)
65
+ #pragma GCC visibility push(default)
66
+ #endif
67
+
68
+ /**
69
+ * \brief Initialize and save a checkpoint of the device state associated with the handle context
70
+ *
71
+ * Uses the handle options to configure and save a checkpoint of the device state associated with the specified context.
72
+ *
73
+ * \param handle A pointer to a CUpti_Checkpoint object
74
+ *
75
+ * \retval CUPTI_SUCCESS if a checkpoint was successfully initialized and saved
76
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if \p handle does not appear to refer to a valid CUpti_Checkpoint
77
+ * \retval CUPTI_ERROR_INVALID_CONTEXT
78
+ * \retval CUPTI_ERROR_INVALID_DEVICE if device associated with context is not compatible with checkpoint API
79
+ * \retval CUPTI_ERROR_INVALID_OPERATION if Save is requested over an existing checkpoint, but \p allowOverwrite was not originally specified
80
+ * \retval CUPTI_ERROR_OUT_OF_MEMORY if as configured, not enough backing storage space to save the checkpoint
81
+ */
82
+ CUptiResult cuptiCheckpointSave(CUpti_Checkpoint * const handle);
83
+
84
+ /**
85
+ * \brief Restore a checkpoint to the device associated with its context
86
+ *
87
+ * Restores device, pinned, and allocated memory to the state when the checkpoint was saved
88
+ *
89
+ * \param handle A pointer to a previously saved CUpti_Checkpoint object
90
+ *
91
+ * \retval CUTPI_SUCCESS if the checkpoint was successfully restored
92
+ * \retval CUPTI_ERROR_NOT_INITIALIZED if the checkpoint was not previously initialized
93
+ * \retval CUPTI_ERROR_INVALID_CONTEXT
94
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if the handle appears invalid
95
+ * \retval CUPTI_ERROR_UNKNOWN if the restore or optimization operation fails
96
+ */
97
+ CUptiResult cuptiCheckpointRestore(CUpti_Checkpoint * const handle);
98
+
99
+ /**
100
+ * \brief Free the backing data for a checkpoint
101
+ *
102
+ * Frees all associated device, host memory and filesystem storage used for this context.
103
+ * After freeing a handle, it may be re-used as if it was new - options may be re-configured and will
104
+ * take effect on the next call to \p cuptiCheckpointSave.
105
+ *
106
+ * \param handle A pointer to a previously saved CUpti_Checkpoint object
107
+ *
108
+ * \retval CUPTI_SUCCESS if the handle was successfully freed
109
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if the handle was already freed or appears invalid
110
+ * \retval CUPTI_ERROR_INVALID_CONTEXT if the context is no longer valid
111
+ */
112
+ CUptiResult cuptiCheckpointFree(CUpti_Checkpoint * const handle);
113
+
114
+ #if defined(__GNUC__) && defined(CUPTI_LIB)
115
+ #pragma GCC visibility pop
116
+ #endif
117
+
118
+ /**
119
+ * @}
120
+ */
121
+
122
+ #ifdef __cplusplus
123
+ }
124
+ #endif
125
+
126
+ // Exit namespace NV::Cupti::Checkpoint
127
+ }}}
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cupti_nvtx_cbid.h ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2013-2017 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if defined(__GNUC__) && defined(CUPTI_LIB)
51
+ #pragma GCC visibility push(default)
52
+ #endif
53
+
54
+ typedef enum {
55
+ CUPTI_CBID_NVTX_INVALID = 0,
56
+ CUPTI_CBID_NVTX_nvtxMarkA = 1,
57
+ CUPTI_CBID_NVTX_nvtxMarkW = 2,
58
+ CUPTI_CBID_NVTX_nvtxMarkEx = 3,
59
+ CUPTI_CBID_NVTX_nvtxRangeStartA = 4,
60
+ CUPTI_CBID_NVTX_nvtxRangeStartW = 5,
61
+ CUPTI_CBID_NVTX_nvtxRangeStartEx = 6,
62
+ CUPTI_CBID_NVTX_nvtxRangeEnd = 7,
63
+ CUPTI_CBID_NVTX_nvtxRangePushA = 8,
64
+ CUPTI_CBID_NVTX_nvtxRangePushW = 9,
65
+ CUPTI_CBID_NVTX_nvtxRangePushEx = 10,
66
+ CUPTI_CBID_NVTX_nvtxRangePop = 11,
67
+ CUPTI_CBID_NVTX_nvtxNameCategoryA = 12,
68
+ CUPTI_CBID_NVTX_nvtxNameCategoryW = 13,
69
+ CUPTI_CBID_NVTX_nvtxNameOsThreadA = 14,
70
+ CUPTI_CBID_NVTX_nvtxNameOsThreadW = 15,
71
+ CUPTI_CBID_NVTX_nvtxNameCuDeviceA = 16,
72
+ CUPTI_CBID_NVTX_nvtxNameCuDeviceW = 17,
73
+ CUPTI_CBID_NVTX_nvtxNameCuContextA = 18,
74
+ CUPTI_CBID_NVTX_nvtxNameCuContextW = 19,
75
+ CUPTI_CBID_NVTX_nvtxNameCuStreamA = 20,
76
+ CUPTI_CBID_NVTX_nvtxNameCuStreamW = 21,
77
+ CUPTI_CBID_NVTX_nvtxNameCuEventA = 22,
78
+ CUPTI_CBID_NVTX_nvtxNameCuEventW = 23,
79
+ CUPTI_CBID_NVTX_nvtxNameCudaDeviceA = 24,
80
+ CUPTI_CBID_NVTX_nvtxNameCudaDeviceW = 25,
81
+ CUPTI_CBID_NVTX_nvtxNameCudaStreamA = 26,
82
+ CUPTI_CBID_NVTX_nvtxNameCudaStreamW = 27,
83
+ CUPTI_CBID_NVTX_nvtxNameCudaEventA = 28,
84
+ CUPTI_CBID_NVTX_nvtxNameCudaEventW = 29,
85
+ CUPTI_CBID_NVTX_nvtxDomainMarkEx = 30,
86
+ CUPTI_CBID_NVTX_nvtxDomainRangeStartEx = 31,
87
+ CUPTI_CBID_NVTX_nvtxDomainRangeEnd = 32,
88
+ CUPTI_CBID_NVTX_nvtxDomainRangePushEx = 33,
89
+ CUPTI_CBID_NVTX_nvtxDomainRangePop = 34,
90
+ CUPTI_CBID_NVTX_nvtxDomainResourceCreate = 35,
91
+ CUPTI_CBID_NVTX_nvtxDomainResourceDestroy = 36,
92
+ CUPTI_CBID_NVTX_nvtxDomainNameCategoryA = 37,
93
+ CUPTI_CBID_NVTX_nvtxDomainNameCategoryW = 38,
94
+ CUPTI_CBID_NVTX_nvtxDomainRegisterStringA = 39,
95
+ CUPTI_CBID_NVTX_nvtxDomainRegisterStringW = 40,
96
+ CUPTI_CBID_NVTX_nvtxDomainCreateA = 41,
97
+ CUPTI_CBID_NVTX_nvtxDomainCreateW = 42,
98
+ CUPTI_CBID_NVTX_nvtxDomainDestroy = 43,
99
+ CUPTI_CBID_NVTX_nvtxDomainSyncUserCreate = 44,
100
+ CUPTI_CBID_NVTX_nvtxDomainSyncUserDestroy = 45,
101
+ CUPTI_CBID_NVTX_nvtxDomainSyncUserAcquireStart = 46,
102
+ CUPTI_CBID_NVTX_nvtxDomainSyncUserAcquireFailed = 47,
103
+ CUPTI_CBID_NVTX_nvtxDomainSyncUserAcquireSuccess = 48,
104
+ CUPTI_CBID_NVTX_nvtxDomainSyncUserReleasing = 49,
105
+ CUPTI_CBID_NVTX_SIZE,
106
+ CUPTI_CBID_NVTX_FORCE_INT = 0x7fffffff
107
+ } CUpti_nvtx_api_trace_cbid;
108
+
109
+ #if defined(__GNUC__) && defined(CUPTI_LIB)
110
+ #pragma GCC visibility pop
111
+ #endif
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cupti_pcsampling.h ADDED
@@ -0,0 +1,936 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2020-2022 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(_CUPTI_PCSAMPLING_H_)
51
+ #define _CUPTI_PCSAMPLING_H_
52
+
53
+ #include <cuda.h>
54
+ #include <stdint.h>
55
+ #include <stddef.h>
56
+ #include "cupti_result.h"
57
+ #include "cupti_common.h"
58
+
59
+
60
+ #if defined(__cplusplus)
61
+ extern "C" {
62
+ #endif
63
+
64
+ #if defined(__GNUC__) && defined(CUPTI_LIB)
65
+ #pragma GCC visibility push(default)
66
+ #endif
67
+
68
+ /**
69
+ * \defgroup CUPTI_PCSAMPLING_API CUPTI PC Sampling API
70
+ * Functions, types, and enums that implement the CUPTI PC Sampling API.
71
+ * @{
72
+ */
73
+
74
+ #ifndef CUPTI_PCSAMPLING_STRUCT_SIZE
75
+ #define CUPTI_PCSAMPLING_STRUCT_SIZE(type_, lastfield_) (offsetof(type_, lastfield_) + sizeof(((type_*)0)->lastfield_))
76
+ #endif
77
+
78
+ #ifndef CUPTI_STALL_REASON_STRING_SIZE
79
+ #define CUPTI_STALL_REASON_STRING_SIZE 128
80
+ #endif
81
+
82
+ /**
83
+ * \brief PC Sampling collection mode
84
+ */
85
+ typedef enum
86
+ {
87
+ /**
88
+ * INVALID Value
89
+ */
90
+ CUPTI_PC_SAMPLING_COLLECTION_MODE_INVALID = 0,
91
+ /**
92
+ * Continuous mode. Kernels are not serialized in this mode.
93
+ */
94
+ CUPTI_PC_SAMPLING_COLLECTION_MODE_CONTINUOUS = 1,
95
+ /**
96
+ * Serialized mode. Kernels are serialized in this mode.
97
+ */
98
+ CUPTI_PC_SAMPLING_COLLECTION_MODE_KERNEL_SERIALIZED = 2,
99
+ } CUpti_PCSamplingCollectionMode;
100
+
101
+ /**
102
+ * \brief PC Sampling stall reasons
103
+ */
104
+ typedef struct PACKED_ALIGNMENT
105
+ {
106
+ /**
107
+ * [r] Collected stall reason index
108
+ */
109
+ uint32_t pcSamplingStallReasonIndex;
110
+ /**
111
+ * [r] Number of times the PC was sampled with the stallReason.
112
+ */
113
+ uint32_t samples;
114
+ } CUpti_PCSamplingStallReason;
115
+
116
+ /**
117
+ * \brief PC Sampling data
118
+ */
119
+ typedef struct PACKED_ALIGNMENT
120
+ {
121
+ /**
122
+ * [w] Size of the data structure.
123
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
124
+ * available in the structure. Used to preserve backward compatibility.
125
+ */
126
+ size_t size;
127
+ /**
128
+ * [r] Unique cubin id
129
+ */
130
+ uint64_t cubinCrc;
131
+ /**
132
+ * [r] PC offset
133
+ */
134
+ uint64_t pcOffset;
135
+ /**
136
+ * The function's unique symbol index in the module.
137
+ */
138
+ uint32_t functionIndex;
139
+ /**
140
+ * Padding
141
+ */
142
+ uint32_t pad;
143
+ /**
144
+ * [r] The function name. This name string might be shared across all the records
145
+ * including records from activity APIs representing the same function, and so it should not be
146
+ * modified or freed until post processing of all the records is done. Once done, it is user’s responsibility to
147
+ * free the memory using free() function.
148
+ */
149
+ char* functionName;
150
+ /**
151
+ * [r] Collected stall reason count
152
+ */
153
+ size_t stallReasonCount;
154
+ /**
155
+ * [r] Stall reason id
156
+ * Total samples
157
+ */
158
+ CUpti_PCSamplingStallReason *stallReason;
159
+ /**
160
+ * The correlation ID of the kernel to which this result is associated. Only valid for serialized mode of pc sampling collection.
161
+ * For continous mode of collection the correlationId will be set to 0.
162
+ */
163
+ uint32_t correlationId;
164
+ } CUpti_PCSamplingPCData;
165
+
166
+ /**
167
+ * \brief PC Sampling output data format
168
+ */
169
+ typedef enum
170
+ {
171
+ CUPTI_PC_SAMPLING_OUTPUT_DATA_FORMAT_INVALID = 0,
172
+ /**
173
+ * HW buffer data will be parsed during collection of data
174
+ */
175
+ CUPTI_PC_SAMPLING_OUTPUT_DATA_FORMAT_PARSED = 1,
176
+ } CUpti_PCSamplingOutputDataFormat;
177
+
178
+ /**
179
+ * \brief Collected PC Sampling data
180
+ *
181
+ */
182
+ typedef struct PACKED_ALIGNMENT
183
+ {
184
+ /**
185
+ * [w] Size of the data structure.
186
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
187
+ * available in the structure. Used to preserve backward compatibility.
188
+ */
189
+ size_t size;
190
+ /**
191
+ * [w] Number of PCs to be collected
192
+ */
193
+ size_t collectNumPcs;
194
+ /**
195
+ * [r] Number of samples collected across all PCs.
196
+ * It includes samples for user modules, samples for non-user kernels and dropped samples.
197
+ * It includes counts for all non selected stall reasons.
198
+ * CUPTI does not provide PC records for non-user kernels.
199
+ * CUPTI does not provide PC records for instructions for which all selected stall reason metrics counts are zero.
200
+ */
201
+ uint64_t totalSamples;
202
+ /**
203
+ * [r] Number of samples that were dropped by hardware due to backpressure/overflow.
204
+ */
205
+ uint64_t droppedSamples;
206
+ /**
207
+ * [r] Number of PCs collected
208
+ */
209
+ size_t totalNumPcs;
210
+ /**
211
+ * [r] Number of PCs available for collection
212
+ */
213
+ size_t remainingNumPcs;
214
+ /**
215
+ * [r] Unique identifier for each range.
216
+ * Data collected across multiple ranges in multiple buffers can be identified using range id.
217
+ */
218
+ uint64_t rangeId;
219
+ /**
220
+ * [r] Profiled PC data
221
+ * This data struct should have enough memory to collect number of PCs mentioned in \brief collectNumPcs
222
+ */
223
+ CUpti_PCSamplingPCData *pPcData;
224
+ /**
225
+ * [r] Number of samples collected across all non user kernels PCs.
226
+ * It includes samples for non-user kernels.
227
+ * It includes counts for all non selected stall reasons as well.
228
+ * CUPTI does not provide PC records for non-user kernels.
229
+ */
230
+ uint64_t nonUsrKernelsTotalSamples;
231
+
232
+ /**
233
+ * [r] Status of the hardware buffer.
234
+ * CUPTI returns the error code CUPTI_ERROR_OUT_OF_MEMORY when hardware buffer is full.
235
+ * When hardware buffer is full, user will get pc data as 0. To mitigate this issue, one or more of the below options can be tried:
236
+ * 1. Increase the hardware buffer size using the attribute CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_HARDWARE_BUFFER_SIZE
237
+ * 2. Decrease the thread sleep span using the attribute CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_WORKER_THREAD_PERIODIC_SLEEP_SPAN
238
+ * 3. Decrease the sampling frequency using the attribute CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_SAMPLING_PERIOD
239
+ */
240
+ uint8_t hardwareBufferFull;
241
+ } CUpti_PCSamplingData;
242
+
243
+ /**
244
+ * \brief PC Sampling configuration attributes
245
+ *
246
+ * PC Sampling configuration attribute types. These attributes can be read
247
+ * using \ref cuptiPCSamplingGetConfigurationAttribute and can be written
248
+ * using \ref cuptiPCSamplingSetConfigurationAttribute. Attributes marked
249
+ * [r] can only be read using \ref cuptiPCSamplingGetConfigurationAttribute
250
+ * [w] can only be written using \ref cuptiPCSamplingSetConfigurationAttribute
251
+ * [rw] can be read using \ref cuptiPCSamplingGetConfigurationAttribute and
252
+ * written using \ref cuptiPCSamplingSetConfigurationAttribute
253
+ */
254
+ typedef enum
255
+ {
256
+ CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_INVALID = 0,
257
+ /**
258
+ * [rw] Sampling period for PC Sampling.
259
+ * DEFAULT - CUPTI defined value based on number of SMs
260
+ * Valid values for the sampling
261
+ * periods are between 5 to 31 both inclusive. This will set the
262
+ * sampling period to (2^samplingPeriod) cycles.
263
+ * For e.g. for sampling period = 5 to 31, cycles = 32, 64, 128,..., 2^31
264
+ * Value is a uint32_t
265
+ */
266
+ CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_SAMPLING_PERIOD = 1,
267
+ /**
268
+ * [w] Number of stall reasons to collect.
269
+ * DEFAULT - All stall reasons will be collected
270
+ * Value is a size_t
271
+ * [w] Stall reasons to collect
272
+ * DEFAULT - All stall reasons will be collected
273
+ * Input value should be a pointer pointing to array of stall reason indexes
274
+ * containing all the stall reason indexes to collect.
275
+ */
276
+ CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_STALL_REASON = 2,
277
+ /**
278
+ * [rw] Size of SW buffer for raw PC counter data downloaded from HW buffer
279
+ * DEFAULT - 1 MB, which can accommodate approximately 5500 PCs
280
+ * with all stall reasons
281
+ * Approximately it takes 16 Bytes (and some fixed size memory)
282
+ * to accommodate one PC with one stall reason
283
+ * For e.g. 1 PC with 1 stall reason = 32 Bytes
284
+ * 1 PC with 2 stall reason = 48 Bytes
285
+ * 1 PC with 4 stall reason = 96 Bytes
286
+ * Value is a size_t
287
+ */
288
+ CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_SCRATCH_BUFFER_SIZE = 3,
289
+ /**
290
+ * [rw] Size of HW buffer in bytes
291
+ * DEFAULT - 512 MB
292
+ * If sampling period is too less, HW buffer can overflow
293
+ * and drop PC data
294
+ * Value is a size_t
295
+ */
296
+ CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_HARDWARE_BUFFER_SIZE = 4,
297
+ /**
298
+ * [rw] PC Sampling collection mode
299
+ * DEFAULT - CUPTI_PC_SAMPLING_COLLECTION_MODE_CONTINUOUS
300
+ * Input value should be of type \ref CUpti_PCSamplingCollectionMode.
301
+ */
302
+ CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_COLLECTION_MODE = 5,
303
+ /**
304
+ * [rw] Control over PC Sampling data collection range
305
+ * Default - 0
306
+ * 1 - Allows user to start and stop PC Sampling using APIs -
307
+ * \ref cuptiPCSamplingStart() - Start PC Sampling
308
+ * \ref cuptiPCSamplingStop() - Stop PC Sampling
309
+ * Value is a uint32_t
310
+ */
311
+ CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_ENABLE_START_STOP_CONTROL = 6,
312
+ /**
313
+ * [w] Value for output data format
314
+ * Default - CUPTI_PC_SAMPLING_OUTPUT_DATA_FORMAT_PARSED
315
+ * Input value should be of type \ref CUpti_PCSamplingOutputDataFormat.
316
+ */
317
+ CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_OUTPUT_DATA_FORMAT = 7,
318
+ /**
319
+ * [w] Data buffer to hold collected PC Sampling data PARSED_DATA
320
+ * Default - none.
321
+ * Buffer type is void * which can point to PARSED_DATA
322
+ * Refer \ref CUpti_PCSamplingData for buffer format for PARSED_DATA
323
+ */
324
+ CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_SAMPLING_DATA_BUFFER = 8,
325
+ /**
326
+ * [rw] Control sleep time of the worker threads created by CUPTI for various PC sampling operations.
327
+ * CUPTI creates multiple worker threads to offload certain operations to these threads. This includes decoding of HW data to
328
+ * the CUPTI PC sampling data and correlating PC data to SASS instructions. CUPTI wakes up these threads periodically.
329
+ * Default - 100 milliseconds.
330
+ * Value is a uint32_t
331
+ */
332
+ CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_WORKER_THREAD_PERIODIC_SLEEP_SPAN = 9,
333
+ CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_FORCE_INT = 0x7fffffff,
334
+ } CUpti_PCSamplingConfigurationAttributeType;
335
+
336
+ /**
337
+ * \brief PC sampling configuration information structure
338
+ *
339
+ * This structure provides \ref CUpti_PCSamplingConfigurationAttributeType which can be configured
340
+ * or queried for PC sampling configuration
341
+ */
342
+ typedef struct
343
+ {
344
+ /**
345
+ * Refer \ref CUpti_PCSamplingConfigurationAttributeType for all supported attribute types
346
+ */
347
+ CUpti_PCSamplingConfigurationAttributeType attributeType;
348
+ /*
349
+ * Configure or query status for \p attributeType
350
+ * CUPTI_SUCCESS for valid \p attributeType and \p attributeData
351
+ * CUPTI_ERROR_INVALID_OPERATION if \p attributeData is not valid
352
+ * CUPTI_ERROR_INVALID_PARAMETER if \p attributeType is not valid
353
+ */
354
+ CUptiResult attributeStatus;
355
+ union
356
+ {
357
+ /**
358
+ * Invalid Value
359
+ */
360
+ struct
361
+ {
362
+ uint64_t data[3];
363
+ } invalidData;
364
+ /**
365
+ * Refer \ref CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_SAMPLING_PERIOD
366
+ */
367
+ struct
368
+ {
369
+ uint32_t samplingPeriod;
370
+ } samplingPeriodData;
371
+ /**
372
+ * Refer \ref CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_STALL_REASON
373
+ */
374
+ struct
375
+ {
376
+ size_t stallReasonCount;
377
+ uint32_t *pStallReasonIndex;
378
+ } stallReasonData;
379
+ /**
380
+ * Refer \ref CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_SCRATCH_BUFFER_SIZE
381
+ */
382
+ struct
383
+ {
384
+ size_t scratchBufferSize;
385
+ } scratchBufferSizeData;
386
+ /**
387
+ * Refer \ref CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_HARDWARE_BUFFER_SIZE
388
+ */
389
+ struct
390
+ {
391
+ size_t hardwareBufferSize;
392
+ } hardwareBufferSizeData;
393
+ /**
394
+ * Refer \ref CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_COLLECTION_MODE
395
+ */
396
+ struct
397
+ {
398
+ CUpti_PCSamplingCollectionMode collectionMode;
399
+ } collectionModeData;
400
+ /**
401
+ * Refer \ref CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_ENABLE_START_STOP_CONTROL
402
+ */
403
+ struct
404
+ {
405
+ uint32_t enableStartStopControl;
406
+ } enableStartStopControlData;
407
+ /**
408
+ * Refer \ref CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_OUTPUT_DATA_FORMAT
409
+ */
410
+ struct
411
+ {
412
+ CUpti_PCSamplingOutputDataFormat outputDataFormat;
413
+ } outputDataFormatData;
414
+ /**
415
+ * Refer \ref CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_SAMPLING_DATA_BUFFER
416
+ */
417
+ struct
418
+ {
419
+ void *samplingDataBuffer;
420
+ } samplingDataBufferData;
421
+ /**
422
+ * Refer \ref CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_WORKER_THREAD_PERIODIC_SLEEP_SPAN
423
+ */
424
+ struct
425
+ {
426
+ uint32_t workerThreadPeriodicSleepSpan;
427
+ } workerThreadPeriodicSleepSpanData;
428
+
429
+ } attributeData;
430
+ } CUpti_PCSamplingConfigurationInfo;
431
+
432
+ /**
433
+ * \brief PC sampling configuration structure
434
+ *
435
+ * This structure configures PC sampling using \ref cuptiPCSamplingSetConfigurationAttribute
436
+ * and queries PC sampling default configuration using \ref cuptiPCSamplingGetConfigurationAttribute
437
+ */
438
+ typedef struct
439
+ {
440
+ /**
441
+ * [w] Size of the data structure i.e. CUpti_PCSamplingConfigurationInfoParamsSize
442
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
443
+ * available in the structure. Used to preserve backward compatibility.
444
+ */
445
+ size_t size;
446
+ /**
447
+ * [w] Assign to NULL
448
+ */
449
+ void* pPriv;
450
+ /**
451
+ * [w] CUcontext
452
+ */
453
+ CUcontext ctx;
454
+ /**
455
+ * [w] Number of attributes to configure using \ref cuptiPCSamplingSetConfigurationAttribute or query
456
+ * using \ref cuptiPCSamplingGetConfigurationAttribute
457
+ */
458
+ size_t numAttributes;
459
+ /**
460
+ * Refer \ref CUpti_PCSamplingConfigurationInfo
461
+ */
462
+ CUpti_PCSamplingConfigurationInfo *pPCSamplingConfigurationInfo;
463
+ } CUpti_PCSamplingConfigurationInfoParams;
464
+ #define CUpti_PCSamplingConfigurationInfoParamsSize CUPTI_PCSAMPLING_STRUCT_SIZE(CUpti_PCSamplingConfigurationInfoParams,pPCSamplingConfigurationInfo)
465
+
466
+ /**
467
+ * \brief Write PC Sampling configuration attribute.
468
+ *
469
+ * \param pParams A pointer to \ref CUpti_PCSamplingConfigurationInfoParams
470
+ * containing PC sampling configuration.
471
+ *
472
+ * \retval CUPTI_SUCCESS
473
+ * \retval CUPTI_ERROR_INVALID_OPERATION if this API is called with
474
+ * some invalid \p attrib.
475
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if attribute \p value is not valid
476
+ * or any \p pParams is not valid
477
+ * \retval CUPTI_ERROR_NOT_SUPPORTED indicates that the system/device
478
+ * does not support the API
479
+ */
480
+ CUptiResult CUPTIAPI cuptiPCSamplingSetConfigurationAttribute(CUpti_PCSamplingConfigurationInfoParams *pParams);
481
+
482
+ /**
483
+ * \brief Read PC Sampling configuration attribute.
484
+ *
485
+ * \param pParams A pointer to \ref CUpti_PCSamplingConfigurationInfoParams
486
+ * containing PC sampling configuration.
487
+ *
488
+ * \retval CUPTI_SUCCESS
489
+ * \retval CUPTI_ERROR_INVALID_OPERATION if this API is called with
490
+ * some invalid attribute.
491
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if \p attrib is not valid
492
+ * or any \p pParams is not valid
493
+ * \retval CUPTI_ERROR_PARAMETER_SIZE_NOT_SUFFICIENT indicates that
494
+ * the \p value buffer is too small to hold the attribute value
495
+ * \retval CUPTI_ERROR_NOT_SUPPORTED indicates that the system/device
496
+ * does not support the API
497
+ */
498
+ CUptiResult CUPTIAPI cuptiPCSamplingGetConfigurationAttribute(CUpti_PCSamplingConfigurationInfoParams *pParams);
499
+
500
+ /**
501
+ * \brief Params for cuptiPCSamplingEnable
502
+ */
503
+ typedef struct
504
+ {
505
+ /**
506
+ * [w] Size of the data structure i.e. CUpti_PCSamplingGetDataParamsSize
507
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
508
+ * available in the structure. Used to preserve backward compatibility.
509
+ */
510
+ size_t size;
511
+ /**
512
+ * [w] Assign to NULL
513
+ */
514
+ void* pPriv;
515
+ /**
516
+ * [w] CUcontext
517
+ */
518
+ CUcontext ctx;
519
+ /**
520
+ * \param pcSamplingData Data buffer to hold collected PC Sampling data PARSED_DATA
521
+ * Buffer type is void * which can point to PARSED_DATA
522
+ * Refer \ref CUpti_PCSamplingData for buffer format for PARSED_DATA
523
+ */
524
+ void *pcSamplingData;
525
+ } CUpti_PCSamplingGetDataParams;
526
+ #define CUpti_PCSamplingGetDataParamsSize CUPTI_PCSAMPLING_STRUCT_SIZE(CUpti_PCSamplingGetDataParams, pcSamplingData)
527
+ /**
528
+ * \brief Flush GPU PC sampling data periodically.
529
+ *
530
+ * Flushing of GPU PC Sampling data is required at following point to maintain uniqueness of PCs:
531
+ * For \brief CUPTI_PC_SAMPLING_COLLECTION_MODE_CONTINUOUS, after every module load-unload-load
532
+ * For \brief CUPTI_PC_SAMPLING_COLLECTION_MODE_KERNEL_SERIALIZED, after every kernel ends
533
+ * If configuration option \brief CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_ENABLE_START_STOP_CONTROL
534
+ * is enabled, then after every range end i.e. \brief cuptiPCSamplingStop()
535
+ *
536
+ * If application is profiled in \brief CUPTI_PC_SAMPLING_COLLECTION_MODE_CONTINUOUS, with disabled
537
+ * \brief CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_ENABLE_START_STOP_CONTROL, and there is no module unload,
538
+ * user can collect data in two ways:
539
+ * Use \brief cuptiPCSamplingGetData() API periodically
540
+ * Use \brief cuptiPCSamplingDisable() on application exit and read GPU PC sampling data from sampling
541
+ * data buffer passed during configuration.
542
+ * Note: In case, \brief cuptiPCSamplingGetData() API is not called periodically, then sampling data buffer
543
+ * passed during configuration should be large enough to hold all PCs data.
544
+ * \brief cuptiPCSamplingGetData() API never does device synchronization.
545
+ * It is possible that when the API is called there is some unconsumed data from the HW buffer. In this case
546
+ * CUPTI provides only the data available with it at that moment.
547
+ *
548
+ * \param pParams A pointer to \ref CUpti_PCSamplingGetDataParams
549
+ *
550
+ * \retval CUPTI_SUCCESS
551
+ * \retval CUPTI_ERROR_INVALID_OPERATION if this API is called without
552
+ * enabling PC sampling.
553
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if any \p pParams is not valid
554
+ * \retval CUPTI_ERROR_NOT_SUPPORTED indicates that the system/device
555
+ * \retval CUPTI_ERROR_OUT_OF_MEMORY indicates that the HW buffer is full
556
+ * does not support the API
557
+ */
558
+ CUptiResult CUPTIAPI cuptiPCSamplingGetData(CUpti_PCSamplingGetDataParams *pParams);
559
+
560
+ /**
561
+ * \brief Params for cuptiPCSamplingEnable
562
+ */
563
+ typedef struct
564
+ {
565
+ /**
566
+ * [w] Size of the data structure i.e. CUpti_PCSamplingEnableParamsSize
567
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
568
+ * available in the structure. Used to preserve backward compatibility.
569
+ */
570
+ size_t size;
571
+ /**
572
+ * [w] Assign to NULL
573
+ */
574
+ void* pPriv;
575
+ /**
576
+ * [w] CUcontext
577
+ */
578
+ CUcontext ctx;
579
+ } CUpti_PCSamplingEnableParams;
580
+ #define CUpti_PCSamplingEnableParamsSize CUPTI_PCSAMPLING_STRUCT_SIZE(CUpti_PCSamplingEnableParams, ctx)
581
+
582
+ /**
583
+ * \brief Enable PC sampling.
584
+ *
585
+ * \param pParams A pointer to \ref CUpti_PCSamplingEnableParams
586
+ *
587
+ * \retval CUPTI_SUCCESS
588
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if any \p pParams is not valid
589
+ * \retval CUPTI_ERROR_NOT_SUPPORTED indicates that the system/device
590
+ * does not support the API
591
+ */
592
+ CUptiResult CUPTIAPI cuptiPCSamplingEnable(CUpti_PCSamplingEnableParams *pParams);
593
+
594
+ /**
595
+ * \brief Params for cuptiPCSamplingDisable
596
+ */
597
+ typedef struct
598
+ {
599
+ /**
600
+ * [w] Size of the data structure i.e. CUpti_PCSamplingDisableParamsSize
601
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
602
+ * available in the structure. Used to preserve backward compatibility.
603
+ */
604
+ size_t size;
605
+ /**
606
+ * [w] Assign to NULL
607
+ */
608
+ void* pPriv;
609
+ /**
610
+ * [w] CUcontext
611
+ */
612
+ CUcontext ctx;
613
+ } CUpti_PCSamplingDisableParams;
614
+ #define CUpti_PCSamplingDisableParamsSize CUPTI_PCSAMPLING_STRUCT_SIZE(CUpti_PCSamplingDisableParams, ctx)
615
+
616
+ /**
617
+ * \brief Disable PC sampling.
618
+ *
619
+ * For application which doesn't destroy the CUDA context explicitly,
620
+ * this API does the PC Sampling tear-down, joins threads and copies PC records in the buffer provided
621
+ * during the PC sampling configuration. PC records which can't be accommodated in the buffer are discarded.
622
+ *
623
+ * \param pParams A pointer to \ref CUpti_PCSamplingDisableParams
624
+ *
625
+ * \retval CUPTI_SUCCESS
626
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if any \p pParams is not valid
627
+ * \retval CUPTI_ERROR_NOT_SUPPORTED indicates that the system/device
628
+ * does not support the API
629
+ */
630
+ CUptiResult CUPTIAPI cuptiPCSamplingDisable(CUpti_PCSamplingDisableParams *pParams);
631
+
632
+ /**
633
+ * \brief Params for cuptiPCSamplingStart
634
+ */
635
+ typedef struct
636
+ {
637
+ /**
638
+ * [w] Size of the data structure i.e. CUpti_PCSamplingStartParamsSize
639
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
640
+ * available in the structure. Used to preserve backward compatibility.
641
+ */
642
+ size_t size;
643
+ /**
644
+ * [w] Assign to NULL
645
+ */
646
+ void* pPriv;
647
+ /**
648
+ * [w] CUcontext
649
+ */
650
+ CUcontext ctx;
651
+ } CUpti_PCSamplingStartParams;
652
+ #define CUpti_PCSamplingStartParamsSize CUPTI_PCSAMPLING_STRUCT_SIZE(CUpti_PCSamplingStartParams, ctx)
653
+
654
+ /**
655
+ * \brief Start PC sampling.
656
+ *
657
+ * User can collect PC Sampling data for user-defined range specified by Start/Stop APIs.
658
+ * This API can be used to mark starting of range. Set configuration option
659
+ * \brief CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_ENABLE_START_STOP_CONTROL to use this API.
660
+ *
661
+ * \param pParams A pointer to \ref CUpti_PCSamplingStartParams
662
+ *
663
+ * \retval CUPTI_SUCCESS
664
+ * \retval CUPTI_ERROR_INVALID_OPERATION if this API is called with
665
+ * incorrect PC Sampling configuration.
666
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if any \p pParams is not valid
667
+ * \retval CUPTI_ERROR_NOT_SUPPORTED indicates that the system/device
668
+ * does not support the API
669
+ */
670
+ CUptiResult CUPTIAPI cuptiPCSamplingStart(CUpti_PCSamplingStartParams *pParams);
671
+
672
+ /**
673
+ * \brief Params for cuptiPCSamplingStop
674
+ */
675
+ typedef struct
676
+ {
677
+ /**
678
+ * [w] Size of the data structure i.e. CUpti_PCSamplingStopParamsSize
679
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
680
+ * available in the structure. Used to preserve backward compatibility.
681
+ */
682
+ size_t size;
683
+ /**
684
+ * [w] Assign to NULL
685
+ */
686
+ void* pPriv;
687
+ /**
688
+ * [w] CUcontext
689
+ */
690
+ CUcontext ctx;
691
+ } CUpti_PCSamplingStopParams;
692
+ #define CUpti_PCSamplingStopParamsSize CUPTI_PCSAMPLING_STRUCT_SIZE(CUpti_PCSamplingStopParams, ctx)
693
+
694
+ /**
695
+ * \brief Stop PC sampling.
696
+ *
697
+ * User can collect PC Sampling data for user-defined range specified by Start/Stop APIs.
698
+ * This API can be used to mark end of range. Set configuration option
699
+ * \brief CUPTI_PC_SAMPLING_CONFIGURATION_ATTR_TYPE_ENABLE_START_STOP_CONTROL to use this API.
700
+ *
701
+ * \param pParams A pointer to \ref CUpti_PCSamplingStopParams
702
+ *
703
+ * \retval CUPTI_SUCCESS
704
+ * \retval CUPTI_ERROR_INVALID_OPERATION if this API is called with
705
+ * incorrect PC Sampling configuration.
706
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if any \p pParams is not valid
707
+ * \retval CUPTI_ERROR_NOT_SUPPORTED indicates that the system/device
708
+ * does not support the API
709
+ */
710
+ CUptiResult CUPTIAPI cuptiPCSamplingStop(CUpti_PCSamplingStopParams *pParams);
711
+
712
+ /**
713
+ * \brief Params for cuptiPCSamplingGetNumStallReasons
714
+ */
715
+ typedef struct
716
+ {
717
+ /**
718
+ * [w] Size of the data structure i.e. CUpti_PCSamplingGetNumStallReasonsParamsSize
719
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
720
+ * available in the structure. Used to preserve backward compatibility.
721
+ */
722
+ size_t size;
723
+ /**
724
+ * [w] Assign to NULL
725
+ */
726
+ void* pPriv;
727
+ /**
728
+ * [w] CUcontext
729
+ */
730
+ CUcontext ctx;
731
+ /**
732
+ * [r] Number of stall reasons
733
+ */
734
+ size_t *numStallReasons;
735
+ } CUpti_PCSamplingGetNumStallReasonsParams;
736
+ #define CUpti_PCSamplingGetNumStallReasonsParamsSize CUPTI_PCSAMPLING_STRUCT_SIZE(CUpti_PCSamplingGetNumStallReasonsParams, numStallReasons)
737
+
738
+ /**
739
+ * \brief Get PC sampling stall reason count.
740
+ *
741
+ * \param pParams A pointer to \ref CUpti_PCSamplingGetNumStallReasonsParams
742
+ *
743
+ * \retval CUPTI_SUCCESS
744
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if any \p pParams is not valid
745
+ * \retval CUPTI_ERROR_NOT_SUPPORTED indicates that the system/device
746
+ * does not support the API
747
+ */
748
+ CUptiResult CUPTIAPI cuptiPCSamplingGetNumStallReasons(CUpti_PCSamplingGetNumStallReasonsParams *pParams);
749
+
750
+ /**
751
+ * \brief Params for cuptiPCSamplingGetStallReasons
752
+ */
753
+ typedef struct
754
+ {
755
+ /**
756
+ * [w] Size of the data structure i.e. CUpti_PCSamplingGetStallReasonsParamsSize
757
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
758
+ * available in the structure. Used to preserve backward compatibility.
759
+ */
760
+ size_t size;
761
+ /**
762
+ * [w] Assign to NULL
763
+ */
764
+ void* pPriv;
765
+ /**
766
+ * [w] CUcontext
767
+ */
768
+ CUcontext ctx;
769
+ /**
770
+ * [w] Number of stall reasons
771
+ */
772
+ size_t numStallReasons;
773
+ /**
774
+ * [r] Stall reason index
775
+ */
776
+ uint32_t *stallReasonIndex;
777
+ /**
778
+ * [r] Stall reasons name
779
+ */
780
+ char **stallReasons;
781
+ } CUpti_PCSamplingGetStallReasonsParams;
782
+ #define CUpti_PCSamplingGetStallReasonsParamsSize CUPTI_PCSAMPLING_STRUCT_SIZE(CUpti_PCSamplingGetStallReasonsParams, stallReasons)
783
+
784
+ /**
785
+ * \brief Get PC sampling stall reasons.
786
+ *
787
+ * \param pParams A pointer to \ref CUpti_PCSamplingGetStallReasonsParams
788
+ *
789
+ * \retval CUPTI_SUCCESS
790
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if any \p pParams is not valid
791
+ * \retval CUPTI_ERROR_NOT_SUPPORTED indicates that the system/device
792
+ * does not support the API
793
+ */
794
+ CUptiResult CUPTIAPI cuptiPCSamplingGetStallReasons(CUpti_PCSamplingGetStallReasonsParams *pParams);
795
+
796
+
797
+ /**
798
+ * \brief Params for cuptiGetSassToSourceCorrelation
799
+ */
800
+ typedef struct CUpti_GetSassToSourceCorrelationParams {
801
+ /**
802
+ * [w] Size of the data structure i.e. CUpti_GetSassToSourceCorrelationParamsSize
803
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
804
+ * available in the structure. Used to preserve backward compatibility.
805
+ */
806
+ size_t size;
807
+ /**
808
+ * [w] Pointer to cubin binary where function belongs.
809
+ */
810
+ const void* cubin;
811
+ /**
812
+ * [w] Function name to which PC belongs.
813
+ */
814
+ const char *functionName;
815
+ /**
816
+ * [w] Size of cubin binary.
817
+ */
818
+ size_t cubinSize;
819
+ /**
820
+ * [r] Line number in the source code.
821
+ */
822
+ uint32_t lineNumber;
823
+ /**
824
+ * [w] PC offset
825
+ */
826
+ uint64_t pcOffset;
827
+ /**
828
+ * [r] Path for the source file.
829
+ */
830
+ char *fileName;
831
+ /**
832
+ * [r] Path for the directory of source file.
833
+ */
834
+ char *dirName;
835
+ } CUpti_GetSassToSourceCorrelationParams;
836
+
837
+ #define CUpti_GetSassToSourceCorrelationParamsSize CUPTI_PCSAMPLING_STRUCT_SIZE(CUpti_GetSassToSourceCorrelationParams, dirName)
838
+
839
+ /**
840
+ * \brief SASS to Source correlation.
841
+ *
842
+ * \param pParams A pointer to \ref CUpti_GetSassToSourceCorrelationParams
843
+ *
844
+ * It is expected from user to free allocated memory for fileName and dirName after use.
845
+ *
846
+ * \retval CUPTI_SUCCESS
847
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if either of the parameters cubin or functionName
848
+ * is NULL or cubinSize is zero or size field is not set correctly.
849
+ * \retval CUPTI_ERROR_INVALID_MODULE provided cubin is invalid.
850
+ * \retval CUPTI_ERROR_UNKNOWN an internal error occurred.
851
+ * This error code is also used for cases when the function is not present in the module.
852
+ * A better error code will be returned in the future release.
853
+ */
854
+ CUptiResult CUPTIAPI cuptiGetSassToSourceCorrelation(CUpti_GetSassToSourceCorrelationParams *pParams);
855
+
856
+ /**
857
+ * \brief Params for cuptiGetCubinCrc
858
+ */
859
+ typedef struct {
860
+ /**
861
+ * [w] Size of configuration structure.
862
+ * CUPTI client should set the size of the structure. It will be used in CUPTI to check what fields are
863
+ * available in the structure. Used to preserve backward compatibility.
864
+ */
865
+ size_t size;
866
+ /**
867
+ * [w] Size of cubin binary.
868
+ */
869
+ size_t cubinSize;
870
+ /**
871
+ * [w] Pointer to cubin binary
872
+ */
873
+ const void* cubin;
874
+ /**
875
+ * [r] Computed CRC will be stored in it.
876
+ */
877
+ uint64_t cubinCrc;
878
+ } CUpti_GetCubinCrcParams;
879
+ #define CUpti_GetCubinCrcParamsSize CUPTI_PCSAMPLING_STRUCT_SIZE(CUpti_GetCubinCrcParams, cubinCrc)
880
+
881
+ /**
882
+ * \brief Get the CRC of cubin.
883
+ *
884
+ * This function returns the CRC of provided cubin binary.
885
+ *
886
+ * \param pParams A pointer to \ref CUpti_GetCubinCrcParams
887
+ *
888
+ * \retval CUPTI_SUCCESS
889
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if parameter cubin is NULL or
890
+ * provided cubinSize is zero or size field is not set.
891
+ */
892
+ CUptiResult CUPTIAPI cuptiGetCubinCrc(CUpti_GetCubinCrcParams *pParams);
893
+
894
+ /**
895
+ * \brief Function type for callback used by CUPTI to request crc of
896
+ * loaded module.
897
+ *
898
+ * This callback function ask for crc of provided module in function.
899
+ * The provided crc will be stored in PC sampling records i.e. in the field 'cubinCrc' of the PC sampling
900
+ * struct CUpti_PCSamplingPCData. The CRC is uses during the offline source correlation to uniquely identify the module.
901
+ *
902
+ * \param cubin The pointer to cubin binary
903
+ * \param cubinSize The size of cubin binary.
904
+ * \param cubinCrc Returns the computed crc of cubin.
905
+ */
906
+ typedef void (CUPTIAPI *CUpti_ComputeCrcCallbackFunc)(
907
+ const void* cubin,
908
+ size_t cubinSize,
909
+ uint64_t *cubinCrc);
910
+
911
+ /**
912
+ * \brief Register callback function with CUPTI to use
913
+ * your own algorithm to compute cubin crc.
914
+ *
915
+ * This function registers a callback function and it gets called
916
+ * from CUPTI when a CUDA module is loaded.
917
+ *
918
+ * \param funcComputeCubinCrc callback is invoked when a CUDA module
919
+ * is loaded.
920
+ *
921
+ * \retval CUPTI_SUCCESS
922
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if \p funcComputeCubinCrc is NULL.
923
+ */
924
+ CUptiResult CUPTIAPI cuptiRegisterComputeCrcCallback(CUpti_ComputeCrcCallbackFunc funcComputeCubinCrc);
925
+
926
+ /** @} */ /* END CUPTI_PCSAMPLING_API */
927
+
928
+ #if defined(__GNUC__) && defined(CUPTI_LIB)
929
+ #pragma GCC visibility pop
930
+ #endif
931
+
932
+ #if defined(__cplusplus)
933
+ }
934
+ #endif
935
+
936
+ #endif /*_CUPTI_PCSAMPLING_H_*/
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cupti_result.h ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2010-2021 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(_CUPTI_RESULT_H_)
51
+ #define _CUPTI_RESULT_H_
52
+
53
+ #ifndef CUPTIAPI
54
+ #ifdef _WIN32
55
+ #define CUPTIAPI __stdcall
56
+ #else
57
+ #define CUPTIAPI
58
+ #endif
59
+ #endif
60
+
61
+ #if defined(__cplusplus)
62
+ extern "C" {
63
+ #endif
64
+
65
+ #if defined(__GNUC__) && defined(CUPTI_LIB)
66
+ #pragma GCC visibility push(default)
67
+ #endif
68
+
69
+ /**
70
+ * \defgroup CUPTI_RESULT_API CUPTI Result Codes
71
+ * Error and result codes returned by CUPTI functions.
72
+ * @{
73
+ */
74
+
75
+ /**
76
+ * \brief CUPTI result codes.
77
+ *
78
+ * Error and result codes returned by CUPTI functions.
79
+ */
80
+ typedef enum {
81
+ /**
82
+ * No error.
83
+ */
84
+ CUPTI_SUCCESS = 0,
85
+ /**
86
+ * One or more of the parameters is invalid.
87
+ */
88
+ CUPTI_ERROR_INVALID_PARAMETER = 1,
89
+ /**
90
+ * The device does not correspond to a valid CUDA device.
91
+ */
92
+ CUPTI_ERROR_INVALID_DEVICE = 2,
93
+ /**
94
+ * The context is NULL or not valid.
95
+ */
96
+ CUPTI_ERROR_INVALID_CONTEXT = 3,
97
+ /**
98
+ * The event domain id is invalid.
99
+ */
100
+ CUPTI_ERROR_INVALID_EVENT_DOMAIN_ID = 4,
101
+ /**
102
+ * The event id is invalid.
103
+ */
104
+ CUPTI_ERROR_INVALID_EVENT_ID = 5,
105
+ /**
106
+ * The event name is invalid.
107
+ */
108
+ CUPTI_ERROR_INVALID_EVENT_NAME = 6,
109
+ /**
110
+ * The current operation cannot be performed due to dependency on
111
+ * other factors.
112
+ */
113
+ CUPTI_ERROR_INVALID_OPERATION = 7,
114
+ /**
115
+ * Unable to allocate enough memory to perform the requested
116
+ * operation.
117
+ */
118
+ CUPTI_ERROR_OUT_OF_MEMORY = 8,
119
+ /**
120
+ * An error occurred on the performance monitoring hardware.
121
+ */
122
+ CUPTI_ERROR_HARDWARE = 9,
123
+ /**
124
+ * The output buffer size is not sufficient to return all
125
+ * requested data.
126
+ */
127
+ CUPTI_ERROR_PARAMETER_SIZE_NOT_SUFFICIENT = 10,
128
+ /**
129
+ * API is not implemented.
130
+ */
131
+ CUPTI_ERROR_API_NOT_IMPLEMENTED = 11,
132
+ /**
133
+ * The maximum limit is reached.
134
+ */
135
+ CUPTI_ERROR_MAX_LIMIT_REACHED = 12,
136
+ /**
137
+ * The object is not yet ready to perform the requested operation.
138
+ */
139
+ CUPTI_ERROR_NOT_READY = 13,
140
+ /**
141
+ * The current operation is not compatible with the current state
142
+ * of the object
143
+ */
144
+ CUPTI_ERROR_NOT_COMPATIBLE = 14,
145
+ /**
146
+ * CUPTI is unable to initialize its connection to the CUDA
147
+ * driver.
148
+ */
149
+ CUPTI_ERROR_NOT_INITIALIZED = 15,
150
+ /**
151
+ * The metric id is invalid.
152
+ */
153
+ CUPTI_ERROR_INVALID_METRIC_ID = 16,
154
+ /**
155
+ * The metric name is invalid.
156
+ */
157
+ CUPTI_ERROR_INVALID_METRIC_NAME = 17,
158
+ /**
159
+ * The queue is empty.
160
+ */
161
+ CUPTI_ERROR_QUEUE_EMPTY = 18,
162
+ /**
163
+ * Invalid handle (internal?).
164
+ */
165
+ CUPTI_ERROR_INVALID_HANDLE = 19,
166
+ /**
167
+ * Invalid stream.
168
+ */
169
+ CUPTI_ERROR_INVALID_STREAM = 20,
170
+ /**
171
+ * Invalid kind.
172
+ */
173
+ CUPTI_ERROR_INVALID_KIND = 21,
174
+ /**
175
+ * Invalid event value.
176
+ */
177
+ CUPTI_ERROR_INVALID_EVENT_VALUE = 22,
178
+ /**
179
+ * CUPTI is disabled due to conflicts with other enabled profilers
180
+ */
181
+ CUPTI_ERROR_DISABLED = 23,
182
+ /**
183
+ * Invalid module.
184
+ */
185
+ CUPTI_ERROR_INVALID_MODULE = 24,
186
+ /**
187
+ * Invalid metric value.
188
+ */
189
+ CUPTI_ERROR_INVALID_METRIC_VALUE = 25,
190
+ /**
191
+ * The performance monitoring hardware is in use by other client.
192
+ */
193
+ CUPTI_ERROR_HARDWARE_BUSY = 26,
194
+ /**
195
+ * The attempted operation is not supported on the current
196
+ * system or device.
197
+ */
198
+ CUPTI_ERROR_NOT_SUPPORTED = 27,
199
+ /**
200
+ * Unified memory profiling is not supported on the system.
201
+ * Potential reason could be unsupported OS or architecture.
202
+ */
203
+ CUPTI_ERROR_UM_PROFILING_NOT_SUPPORTED = 28,
204
+ /**
205
+ * Unified memory profiling is not supported on the device
206
+ */
207
+ CUPTI_ERROR_UM_PROFILING_NOT_SUPPORTED_ON_DEVICE = 29,
208
+ /**
209
+ * Unified memory profiling is not supported on a multi-GPU
210
+ * configuration without P2P support between any pair of devices
211
+ */
212
+ CUPTI_ERROR_UM_PROFILING_NOT_SUPPORTED_ON_NON_P2P_DEVICES = 30,
213
+ /**
214
+ * Unified memory profiling is not supported under the
215
+ * Multi-Process Service (MPS) environment. CUDA 7.5 removes this
216
+ * restriction.
217
+ */
218
+ CUPTI_ERROR_UM_PROFILING_NOT_SUPPORTED_WITH_MPS = 31,
219
+ /**
220
+ * In CUDA 9.0, devices with compute capability 7.0 don't
221
+ * support CDP tracing
222
+ */
223
+ CUPTI_ERROR_CDP_TRACING_NOT_SUPPORTED = 32,
224
+ /**
225
+ * Profiling on virtualized GPU is not supported.
226
+ */
227
+ CUPTI_ERROR_VIRTUALIZED_DEVICE_NOT_SUPPORTED = 33,
228
+ /**
229
+ * Profiling results might be incorrect for CUDA applications
230
+ * compiled with nvcc version older than 9.0 for devices with
231
+ * compute capability 6.0 and 6.1.
232
+ * Profiling session will continue and CUPTI will notify it using this error code.
233
+ * User is advised to recompile the application code with nvcc version 9.0 or later.
234
+ * Ignore this warning if code is already compiled with the recommended nvcc version.
235
+ */
236
+ CUPTI_ERROR_CUDA_COMPILER_NOT_COMPATIBLE = 34,
237
+ /**
238
+ * User doesn't have sufficient privileges which are required to
239
+ * start the profiling session.
240
+ * One possible reason for this may be that the NVIDIA driver or your system
241
+ * administrator may have restricted access to the NVIDIA GPU performance counters.
242
+ * To learn how to resolve this issue and find more information, please visit
243
+ * https://developer.nvidia.com/CUPTI_ERROR_INSUFFICIENT_PRIVILEGES
244
+ */
245
+ CUPTI_ERROR_INSUFFICIENT_PRIVILEGES = 35,
246
+ /**
247
+ * Legacy CUPTI Profiling API i.e. event API from the header cupti_events.h and
248
+ * metric API from the header cupti_metrics.h are not compatible with the
249
+ * Profiling API in the header cupti_profiler_target.h and Perfworks metrics API
250
+ * in the headers nvperf_host.h and nvperf_target.h.
251
+ */
252
+ CUPTI_ERROR_OLD_PROFILER_API_INITIALIZED = 36,
253
+ /**
254
+ * Missing definition of the OpenACC API routine in the linked OpenACC library.
255
+ *
256
+ * One possible reason is that OpenACC library is linked statically in the
257
+ * user application, which might not have the definition of all the OpenACC
258
+ * API routines needed for the OpenACC profiling, as compiler might ignore
259
+ * definitions for the functions not used in the application. This issue
260
+ * can be mitigated by linking the OpenACC library dynamically.
261
+ */
262
+ CUPTI_ERROR_OPENACC_UNDEFINED_ROUTINE = 37,
263
+ /**
264
+ * Legacy CUPTI Profiling API i.e. event API from the header cupti_events.h and
265
+ * metric API from the header cupti_metrics.h are not supported on devices with
266
+ * compute capability 7.5 and higher (i.e. Turing and later GPU architectures).
267
+ * These API will be deprecated in a future CUDA release. These are replaced by
268
+ * Profiling API in the header cupti_profiler_target.h and Perfworks metrics API
269
+ * in the headers nvperf_host.h and nvperf_target.h.
270
+ */
271
+ CUPTI_ERROR_LEGACY_PROFILER_NOT_SUPPORTED = 38,
272
+ /**
273
+ * CUPTI doesn't allow multiple callback subscribers. Only a single subscriber
274
+ * can be registered at a time.
275
+ * Same error code is used when application is launched using NVIDIA tools
276
+ * like nvprof, Visual Profiler, Nsight Systems, Nsight Compute, cuda-gdb and
277
+ * cuda-memcheck.
278
+ */
279
+ CUPTI_ERROR_MULTIPLE_SUBSCRIBERS_NOT_SUPPORTED = 39,
280
+ /**
281
+ * Profiling on virtualized GPU is not allowed by hypervisor.
282
+ */
283
+ CUPTI_ERROR_VIRTUALIZED_DEVICE_INSUFFICIENT_PRIVILEGES = 40,
284
+ /**
285
+ * Profiling and tracing are not allowed when confidential computing mode
286
+ * is enabled.
287
+ */
288
+ CUPTI_ERROR_CONFIDENTIAL_COMPUTING_NOT_SUPPORTED = 41,
289
+ /**
290
+ * CUPTI does not support NVIDIA Crypto Mining Processors (CMP).
291
+ * For more information, please visit https://developer.nvidia.com/ERR_NVCMPGPU
292
+ */
293
+ CUPTI_ERROR_CMP_DEVICE_NOT_SUPPORTED = 42,
294
+ /**
295
+ * An unknown internal error has occurred.
296
+ */
297
+ CUPTI_ERROR_UNKNOWN = 999,
298
+ CUPTI_ERROR_FORCE_INT = 0x7fffffff
299
+ } CUptiResult;
300
+
301
+ /**
302
+ * \brief Get the descriptive string for a CUptiResult.
303
+ *
304
+ * Return the descriptive string for a CUptiResult in \p *str.
305
+ * \note \b Thread-safety: this function is thread safe.
306
+ *
307
+ * \param result The result to get the string for
308
+ * \param str Returns the string
309
+ *
310
+ * \retval CUPTI_SUCCESS on success
311
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if \p str is NULL or \p
312
+ * result is not a valid CUptiResult
313
+ */
314
+ CUptiResult CUPTIAPI cuptiGetResultString(CUptiResult result, const char **str);
315
+
316
+ /**
317
+ * @brief Get the descriptive message corresponding to error codes returned
318
+ * by CUPTI.
319
+ *
320
+ * Return the descriptive error message for a CUptiResult in \p *str.
321
+ * \note \b Thread-safety: this function is thread safe.
322
+ *
323
+ * \param result The result to get the descriptive error message for
324
+ * \param str Returns the error message string
325
+ *
326
+ * \retval CUPTI_SUCCESS on success
327
+ * \retval CUPTI_ERROR_INVALID_PARAMETER if \p str is NULL or \p
328
+ * result is not a valid CUptiResult
329
+ *
330
+ */
331
+
332
+ CUptiResult CUPTIAPI cuptiGetErrorMessage(CUptiResult result, const char **str);
333
+
334
+ /** @} */ /* END CUPTI_RESULT_API */
335
+
336
+ #if defined(__GNUC__) && defined(CUPTI_LIB)
337
+ #pragma GCC visibility pop
338
+ #endif
339
+
340
+ #if defined(__cplusplus)
341
+ }
342
+ #endif
343
+
344
+ #endif /*_CUPTI_RESULT_H_*/
345
+
346
+
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/cupti_target.h ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(_CUPTI_TARGET_H_)
2
+ #define _CUPTI_TARGET_H_
3
+
4
+ /*
5
+ CUPTI profiler target API's
6
+ This file contains the CUPTI profiling API's.
7
+ */
8
+ #include <cupti_result.h>
9
+ #include <stddef.h>
10
+ #include <stdint.h>
11
+
12
+ #ifdef __cplusplus
13
+ extern "C" {
14
+ #endif
15
+
16
+ #if defined(__GNUC__) && defined(CUPTI_LIB)
17
+ #pragma GCC visibility push(default)
18
+ #endif
19
+
20
+ #ifndef CUPTI_PROFILER_STRUCT_SIZE
21
+ #define CUPTI_PROFILER_STRUCT_SIZE(type_, lastfield_) (offsetof(type_, lastfield_) + sizeof(((type_*)0)->lastfield_))
22
+ #endif
23
+
24
+ typedef struct CUpti_Device_GetChipName_Params
25
+ {
26
+ size_t structSize; //!< [in]
27
+ void* pPriv; //!< [in] assign to NULL
28
+
29
+ size_t deviceIndex; //!< [in]
30
+ const char* pChipName; //!< [out]
31
+ } CUpti_Device_GetChipName_Params;
32
+
33
+ #define CUpti_Device_GetChipName_Params_STRUCT_SIZE CUPTI_PROFILER_STRUCT_SIZE(CUpti_Device_GetChipName_Params, pChipName)
34
+ CUptiResult CUPTIAPI cuptiDeviceGetChipName(CUpti_Device_GetChipName_Params *pParams);
35
+
36
+ #if defined(__GNUC__) && defined(CUPTI_LIB)
37
+ #pragma GCC visibility pop
38
+ #endif
39
+
40
+ #ifdef __cplusplus
41
+ } /* extern "C" */
42
+ #endif
43
+ #endif
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/device_double_functions.h ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2018 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__)
51
+ #if defined(_MSC_VER)
52
+ #pragma message("device_double_functions.h is an internal header file and must not be used directly. This file will be removed in a future CUDA release. Please use cuda_runtime_api.h or cuda_runtime.h instead.")
53
+ #else
54
+ #warning "device_double_functions.h is an internal header file and must not be used directly. This file will be removed in a future CUDA release. Please use cuda_runtime_api.h or cuda_runtime.h instead."
55
+ #endif
56
+ #define __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
57
+ #define __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_DEVICE_DOUBLE_FUNCTIONS_H_WRAPPER__
58
+ #endif
59
+
60
+ #include "crt/device_double_functions.h"
61
+
62
+ #if defined(__UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_DEVICE_DOUBLE_FUNCTIONS_H_WRAPPER__)
63
+ #undef __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
64
+ #undef __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_DEVICE_DOUBLE_FUNCTIONS_H_WRAPPER__
65
+ #endif
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/device_launch_parameters.h ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2012 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(__DEVICE_LAUNCH_PARAMETERS_H__)
51
+ #define __DEVICE_LAUNCH_PARAMETERS_H__
52
+
53
+ #include "vector_types.h"
54
+
55
+ #if !defined(__STORAGE__)
56
+
57
+ #if defined(__CUDACC_RTC__)
58
+ #define __STORAGE__ \
59
+ extern const __device__
60
+ #else /* !__CUDACC_RTC__ */
61
+ #define __STORAGE__ \
62
+ extern const
63
+ #endif /* __CUDACC_RTC__ */
64
+
65
+ #endif /* __STORAGE__ */
66
+
67
+ #if defined(__cplusplus)
68
+ extern "C" {
69
+ #endif /* __cplusplus */
70
+
71
+ uint3 __device_builtin__ __STORAGE__ threadIdx;
72
+ uint3 __device_builtin__ __STORAGE__ blockIdx;
73
+ dim3 __device_builtin__ __STORAGE__ blockDim;
74
+ dim3 __device_builtin__ __STORAGE__ gridDim;
75
+ int __device_builtin__ __STORAGE__ warpSize;
76
+
77
+ #undef __STORAGE__
78
+
79
+ #if defined(__cplusplus)
80
+ }
81
+ #endif /* __cplusplus */
82
+
83
+ #if !defined(__cudaGet_threadIdx)
84
+
85
+ #define __cudaGet_threadIdx() \
86
+ threadIdx
87
+
88
+ #endif /* __cudaGet_threadIdx */
89
+
90
+ #if !defined(__cudaGet_blockIdx)
91
+
92
+ #define __cudaGet_blockIdx() \
93
+ blockIdx
94
+
95
+ #endif /* __cudaGet_blockIdx */
96
+
97
+ #if !defined(__cudaGet_blockDim)
98
+
99
+ #define __cudaGet_blockDim() \
100
+ blockDim
101
+
102
+ #endif /* __cudaGet_blockDim */
103
+
104
+ #if !defined(__cudaGet_gridDim)
105
+
106
+ #define __cudaGet_gridDim() \
107
+ gridDim
108
+
109
+ #endif /* __cudaGet_gridDim */
110
+
111
+ #if !defined(__cudaGet_warpSize)
112
+
113
+ #define __cudaGet_warpSize() \
114
+ warpSize
115
+
116
+ #endif /* __cudaGet_warpSize */
117
+
118
+ #endif /* !__DEVICE_LAUNCH_PARAMETERS_H__ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/device_types.h ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2018 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(__DEVICE_TYPES_H__)
51
+ #define __DEVICE_TYPES_H__
52
+
53
+ #if !defined(__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__)
54
+ #define __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
55
+ #define __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_DEVICE_TYPES_H__
56
+ #endif
57
+
58
+ #ifndef __DOXYGEN_ONLY__
59
+ #include "crt/host_defines.h"
60
+ #endif
61
+
62
+ /*******************************************************************************
63
+ * *
64
+ * *
65
+ * *
66
+ *******************************************************************************/
67
+
68
+ enum __device_builtin__ cudaRoundMode
69
+ {
70
+ cudaRoundNearest,
71
+ cudaRoundZero,
72
+ cudaRoundPosInf,
73
+ cudaRoundMinInf
74
+ };
75
+
76
+ #if defined(__UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_DEVICE_TYPES_H__)
77
+ #undef __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
78
+ #undef __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_DEVICE_TYPES_H__
79
+ #endif
80
+
81
+ #endif /* !__DEVICE_TYPES_H__ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/driver_functions.h ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 1993-2018 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO LICENSEE:
5
+ *
6
+ * This source code and/or documentation ("Licensed Deliverables") are
7
+ * subject to NVIDIA intellectual property rights under U.S. and
8
+ * international Copyright laws.
9
+ *
10
+ * These Licensed Deliverables contained herein is PROPRIETARY and
11
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
+ * conditions of a form of NVIDIA software license agreement by and
13
+ * between NVIDIA and Licensee ("License Agreement") or electronically
14
+ * accepted by Licensee. Notwithstanding any terms or conditions to
15
+ * the contrary in the License Agreement, reproduction or disclosure
16
+ * of the Licensed Deliverables to any third party without the express
17
+ * written consent of NVIDIA is prohibited.
18
+ *
19
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
+ * OF THESE LICENSED DELIVERABLES.
33
+ *
34
+ * U.S. Government End Users. These Licensed Deliverables are a
35
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
+ * 1995), consisting of "commercial computer software" and "commercial
37
+ * computer software documentation" as such terms are used in 48
38
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
+ * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
+ * U.S. Government End Users acquire the Licensed Deliverables with
42
+ * only those rights set forth herein.
43
+ *
44
+ * Any use of the Licensed Deliverables in individual and commercial
45
+ * software must include, in the user documentation and internal
46
+ * comments to the code, the above Disclaimer and U.S. Government End
47
+ * Users Notice.
48
+ */
49
+
50
+ #if !defined(__DRIVER_FUNCTIONS_H__)
51
+ #define __DRIVER_FUNCTIONS_H__
52
+
53
+ #include "builtin_types.h"
54
+ #include "crt/host_defines.h"
55
+ #include "driver_types.h"
56
+
57
+ /**
58
+ * \addtogroup CUDART_MEMORY
59
+ *
60
+ * @{
61
+ */
62
+
63
+ /**
64
+ * \brief Returns a cudaPitchedPtr based on input parameters
65
+ *
66
+ * Returns a ::cudaPitchedPtr based on the specified input parameters \p d,
67
+ * \p p, \p xsz, and \p ysz.
68
+ *
69
+ * \param d - Pointer to allocated memory
70
+ * \param p - Pitch of allocated memory in bytes
71
+ * \param xsz - Logical width of allocation in elements
72
+ * \param ysz - Logical height of allocation in elements
73
+ *
74
+ * \return
75
+ * ::cudaPitchedPtr specified by \p d, \p p, \p xsz, and \p ysz
76
+ *
77
+ * \sa make_cudaExtent, make_cudaPos
78
+ */
79
+ static __inline__ __host__ struct cudaPitchedPtr make_cudaPitchedPtr(void *d, size_t p, size_t xsz, size_t ysz)
80
+ {
81
+ struct cudaPitchedPtr s;
82
+
83
+ s.ptr = d;
84
+ s.pitch = p;
85
+ s.xsize = xsz;
86
+ s.ysize = ysz;
87
+
88
+ return s;
89
+ }
90
+
91
+ /**
92
+ * \brief Returns a cudaPos based on input parameters
93
+ *
94
+ * Returns a ::cudaPos based on the specified input parameters \p x,
95
+ * \p y, and \p z.
96
+ *
97
+ * \param x - X position
98
+ * \param y - Y position
99
+ * \param z - Z position
100
+ *
101
+ * \return
102
+ * ::cudaPos specified by \p x, \p y, and \p z
103
+ *
104
+ * \sa make_cudaExtent, make_cudaPitchedPtr
105
+ */
106
+ static __inline__ __host__ struct cudaPos make_cudaPos(size_t x, size_t y, size_t z)
107
+ {
108
+ struct cudaPos p;
109
+
110
+ p.x = x;
111
+ p.y = y;
112
+ p.z = z;
113
+
114
+ return p;
115
+ }
116
+
117
+ /**
118
+ * \brief Returns a cudaExtent based on input parameters
119
+ *
120
+ * Returns a ::cudaExtent based on the specified input parameters \p w,
121
+ * \p h, and \p d.
122
+ *
123
+ * \param w - Width in elements when referring to array memory, in bytes when referring to linear memory
124
+ * \param h - Height in elements
125
+ * \param d - Depth in elements
126
+ *
127
+ * \return
128
+ * ::cudaExtent specified by \p w, \p h, and \p d
129
+ *
130
+ * \sa make_cudaPitchedPtr, make_cudaPos
131
+ */
132
+ static __inline__ __host__ struct cudaExtent make_cudaExtent(size_t w, size_t h, size_t d)
133
+ {
134
+ struct cudaExtent e;
135
+
136
+ e.width = w;
137
+ e.height = h;
138
+ e.depth = d;
139
+
140
+ return e;
141
+ }
142
+
143
+ /** @} */ /* END CUDART_MEMORY */
144
+
145
+ #endif /* !__DRIVER_FUNCTIONS_H__ */
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/driver_types.h ADDED
The diff for this file is too large to render. See raw diff
 
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/generated_cudaVDPAU_meta.h ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is generated. Any changes you make will be lost during the next clean build.
2
+
3
+ // Dependent includes
4
+ #include <vdpau/vdpau.h>
5
+
6
+ // CUDA public interface, for type definitions and cu* function prototypes
7
+ #include "cudaVDPAU.h"
8
+
9
+
10
+ // *************************************************************************
11
+ // Definitions of structs to hold parameters for each function
12
+ // *************************************************************************
13
+
14
+ typedef struct cuVDPAUGetDevice_params_st {
15
+ CUdevice *pDevice;
16
+ VdpDevice vdpDevice;
17
+ VdpGetProcAddress *vdpGetProcAddress;
18
+ } cuVDPAUGetDevice_params;
19
+
20
+ typedef struct cuVDPAUCtxCreate_v2_params_st {
21
+ CUcontext *pCtx;
22
+ unsigned int flags;
23
+ CUdevice device;
24
+ VdpDevice vdpDevice;
25
+ VdpGetProcAddress *vdpGetProcAddress;
26
+ } cuVDPAUCtxCreate_v2_params;
27
+
28
+ typedef struct cuGraphicsVDPAURegisterVideoSurface_params_st {
29
+ CUgraphicsResource *pCudaResource;
30
+ VdpVideoSurface vdpSurface;
31
+ unsigned int flags;
32
+ } cuGraphicsVDPAURegisterVideoSurface_params;
33
+
34
+ typedef struct cuGraphicsVDPAURegisterOutputSurface_params_st {
35
+ CUgraphicsResource *pCudaResource;
36
+ VdpOutputSurface vdpSurface;
37
+ unsigned int flags;
38
+ } cuGraphicsVDPAURegisterOutputSurface_params;
39
+
40
+ typedef struct cuVDPAUCtxCreate_params_st {
41
+ CUcontext *pCtx;
42
+ unsigned int flags;
43
+ CUdevice device;
44
+ VdpDevice vdpDevice;
45
+ VdpGetProcAddress *vdpGetProcAddress;
46
+ } cuVDPAUCtxCreate_params;
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/generated_cuda_gl_interop_meta.h ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is generated. Any changes you make will be lost during the next clean build.
2
+
3
+ // CUDA public interface, for type definitions and api function prototypes
4
+ #include "cuda_gl_interop.h"
5
+
6
+ // *************************************************************************
7
+ // Definitions of structs to hold parameters for each function
8
+ // *************************************************************************
9
+
10
+ // Currently used parameter trace structures
11
+ typedef struct cudaGLGetDevices_v4010_params_st {
12
+ unsigned int *pCudaDeviceCount;
13
+ int *pCudaDevices;
14
+ unsigned int cudaDeviceCount;
15
+ enum cudaGLDeviceList deviceList;
16
+ } cudaGLGetDevices_v4010_params;
17
+
18
+ typedef struct cudaGraphicsGLRegisterImage_v3020_params_st {
19
+ struct cudaGraphicsResource **resource;
20
+ GLuint image;
21
+ GLenum target;
22
+ unsigned int flags;
23
+ } cudaGraphicsGLRegisterImage_v3020_params;
24
+
25
+ typedef struct cudaGraphicsGLRegisterBuffer_v3020_params_st {
26
+ struct cudaGraphicsResource **resource;
27
+ GLuint buffer;
28
+ unsigned int flags;
29
+ } cudaGraphicsGLRegisterBuffer_v3020_params;
30
+
31
+ typedef struct cudaGLSetGLDevice_v3020_params_st {
32
+ int device;
33
+ } cudaGLSetGLDevice_v3020_params;
34
+
35
+ typedef struct cudaGLRegisterBufferObject_v3020_params_st {
36
+ GLuint bufObj;
37
+ } cudaGLRegisterBufferObject_v3020_params;
38
+
39
+ typedef struct cudaGLMapBufferObject_v3020_params_st {
40
+ void **devPtr;
41
+ GLuint bufObj;
42
+ } cudaGLMapBufferObject_v3020_params;
43
+
44
+ typedef struct cudaGLUnmapBufferObject_v3020_params_st {
45
+ GLuint bufObj;
46
+ } cudaGLUnmapBufferObject_v3020_params;
47
+
48
+ typedef struct cudaGLUnregisterBufferObject_v3020_params_st {
49
+ GLuint bufObj;
50
+ } cudaGLUnregisterBufferObject_v3020_params;
51
+
52
+ typedef struct cudaGLSetBufferObjectMapFlags_v3020_params_st {
53
+ GLuint bufObj;
54
+ unsigned int flags;
55
+ } cudaGLSetBufferObjectMapFlags_v3020_params;
56
+
57
+ typedef struct cudaGLMapBufferObjectAsync_v3020_params_st {
58
+ void **devPtr;
59
+ GLuint bufObj;
60
+ cudaStream_t stream;
61
+ } cudaGLMapBufferObjectAsync_v3020_params;
62
+
63
+ typedef struct cudaGLUnmapBufferObjectAsync_v3020_params_st {
64
+ GLuint bufObj;
65
+ cudaStream_t stream;
66
+ } cudaGLUnmapBufferObjectAsync_v3020_params;
67
+
68
+ // Parameter trace structures for removed functions
69
+
70
+
71
+ // End of parameter trace structures
.venv/lib/python3.11/site-packages/triton/backends/nvidia/include/generated_cuda_meta.h ADDED
@@ -0,0 +1,3563 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is generated. Any changes you make will be lost during the next clean build.
2
+
3
+ // No dependent includes
4
+
5
+ // CUDA public interface, for type definitions and cu* function prototypes
6
+ #include "cuda.h"
7
+
8
+
9
+ // *************************************************************************
10
+ // Definitions of structs to hold parameters for each function
11
+ // *************************************************************************
12
+
13
+ typedef struct cuGetErrorString_params_st {
14
+ CUresult error;
15
+ const char **pStr;
16
+ } cuGetErrorString_params;
17
+
18
+ typedef struct cuGetErrorName_params_st {
19
+ CUresult error;
20
+ const char **pStr;
21
+ } cuGetErrorName_params;
22
+
23
+ typedef struct cuInit_params_st {
24
+ unsigned int Flags;
25
+ } cuInit_params;
26
+
27
+ typedef struct cuDriverGetVersion_params_st {
28
+ int *driverVersion;
29
+ } cuDriverGetVersion_params;
30
+
31
+ typedef struct cuDeviceGet_params_st {
32
+ CUdevice *device;
33
+ int ordinal;
34
+ } cuDeviceGet_params;
35
+
36
+ typedef struct cuDeviceGetCount_params_st {
37
+ int *count;
38
+ } cuDeviceGetCount_params;
39
+
40
+ typedef struct cuDeviceGetName_params_st {
41
+ char *name;
42
+ int len;
43
+ CUdevice dev;
44
+ } cuDeviceGetName_params;
45
+
46
+ typedef struct cuDeviceGetUuid_params_st {
47
+ CUuuid *uuid;
48
+ CUdevice dev;
49
+ } cuDeviceGetUuid_params;
50
+
51
+ typedef struct cuDeviceGetUuid_v2_params_st {
52
+ CUuuid *uuid;
53
+ CUdevice dev;
54
+ } cuDeviceGetUuid_v2_params;
55
+
56
+ typedef struct cuDeviceGetLuid_params_st {
57
+ char *luid;
58
+ unsigned int *deviceNodeMask;
59
+ CUdevice dev;
60
+ } cuDeviceGetLuid_params;
61
+
62
+ typedef struct cuDeviceTotalMem_v2_params_st {
63
+ size_t *bytes;
64
+ CUdevice dev;
65
+ } cuDeviceTotalMem_v2_params;
66
+
67
+ typedef struct cuDeviceGetTexture1DLinearMaxWidth_params_st {
68
+ size_t *maxWidthInElements;
69
+ CUarray_format format;
70
+ unsigned numChannels;
71
+ CUdevice dev;
72
+ } cuDeviceGetTexture1DLinearMaxWidth_params;
73
+
74
+ typedef struct cuDeviceGetAttribute_params_st {
75
+ int *pi;
76
+ CUdevice_attribute attrib;
77
+ CUdevice dev;
78
+ } cuDeviceGetAttribute_params;
79
+
80
+ typedef struct cuDeviceGetNvSciSyncAttributes_params_st {
81
+ void *nvSciSyncAttrList;
82
+ CUdevice dev;
83
+ int flags;
84
+ } cuDeviceGetNvSciSyncAttributes_params;
85
+
86
+ typedef struct cuDeviceSetMemPool_params_st {
87
+ CUdevice dev;
88
+ CUmemoryPool pool;
89
+ } cuDeviceSetMemPool_params;
90
+
91
+ typedef struct cuDeviceGetMemPool_params_st {
92
+ CUmemoryPool *pool;
93
+ CUdevice dev;
94
+ } cuDeviceGetMemPool_params;
95
+
96
+ typedef struct cuDeviceGetDefaultMemPool_params_st {
97
+ CUmemoryPool *pool_out;
98
+ CUdevice dev;
99
+ } cuDeviceGetDefaultMemPool_params;
100
+
101
+ typedef struct cuDeviceGetExecAffinitySupport_params_st {
102
+ int *pi;
103
+ CUexecAffinityType type;
104
+ CUdevice dev;
105
+ } cuDeviceGetExecAffinitySupport_params;
106
+
107
+ typedef struct cuFlushGPUDirectRDMAWrites_params_st {
108
+ CUflushGPUDirectRDMAWritesTarget target;
109
+ CUflushGPUDirectRDMAWritesScope scope;
110
+ } cuFlushGPUDirectRDMAWrites_params;
111
+
112
+ typedef struct cuDeviceGetProperties_params_st {
113
+ CUdevprop *prop;
114
+ CUdevice dev;
115
+ } cuDeviceGetProperties_params;
116
+
117
+ typedef struct cuDeviceComputeCapability_params_st {
118
+ int *major;
119
+ int *minor;
120
+ CUdevice dev;
121
+ } cuDeviceComputeCapability_params;
122
+
123
+ typedef struct cuDevicePrimaryCtxRetain_params_st {
124
+ CUcontext *pctx;
125
+ CUdevice dev;
126
+ } cuDevicePrimaryCtxRetain_params;
127
+
128
+ typedef struct cuDevicePrimaryCtxRelease_v2_params_st {
129
+ CUdevice dev;
130
+ } cuDevicePrimaryCtxRelease_v2_params;
131
+
132
+ typedef struct cuDevicePrimaryCtxSetFlags_v2_params_st {
133
+ CUdevice dev;
134
+ unsigned int flags;
135
+ } cuDevicePrimaryCtxSetFlags_v2_params;
136
+
137
+ typedef struct cuDevicePrimaryCtxGetState_params_st {
138
+ CUdevice dev;
139
+ unsigned int *flags;
140
+ int *active;
141
+ } cuDevicePrimaryCtxGetState_params;
142
+
143
+ typedef struct cuDevicePrimaryCtxReset_v2_params_st {
144
+ CUdevice dev;
145
+ } cuDevicePrimaryCtxReset_v2_params;
146
+
147
+ typedef struct cuCtxCreate_v2_params_st {
148
+ CUcontext *pctx;
149
+ unsigned int flags;
150
+ CUdevice dev;
151
+ } cuCtxCreate_v2_params;
152
+
153
+ typedef struct cuCtxCreate_v3_params_st {
154
+ CUcontext *pctx;
155
+ CUexecAffinityParam *paramsArray;
156
+ int numParams;
157
+ unsigned int flags;
158
+ CUdevice dev;
159
+ } cuCtxCreate_v3_params;
160
+
161
+ typedef struct cuCtxDestroy_v2_params_st {
162
+ CUcontext ctx;
163
+ } cuCtxDestroy_v2_params;
164
+
165
+ typedef struct cuCtxPushCurrent_v2_params_st {
166
+ CUcontext ctx;
167
+ } cuCtxPushCurrent_v2_params;
168
+
169
+ typedef struct cuCtxPopCurrent_v2_params_st {
170
+ CUcontext *pctx;
171
+ } cuCtxPopCurrent_v2_params;
172
+
173
+ typedef struct cuCtxSetCurrent_params_st {
174
+ CUcontext ctx;
175
+ } cuCtxSetCurrent_params;
176
+
177
+ typedef struct cuCtxGetCurrent_params_st {
178
+ CUcontext *pctx;
179
+ } cuCtxGetCurrent_params;
180
+
181
+ typedef struct cuCtxGetDevice_params_st {
182
+ CUdevice *device;
183
+ } cuCtxGetDevice_params;
184
+
185
+ typedef struct cuCtxGetFlags_params_st {
186
+ unsigned int *flags;
187
+ } cuCtxGetFlags_params;
188
+
189
+ typedef struct cuCtxSetFlags_params_st {
190
+ unsigned int flags;
191
+ } cuCtxSetFlags_params;
192
+
193
+ typedef struct cuCtxGetId_params_st {
194
+ CUcontext ctx;
195
+ unsigned long long *ctxId;
196
+ } cuCtxGetId_params;
197
+
198
+ typedef struct cuCtxSetLimit_params_st {
199
+ CUlimit limit;
200
+ size_t value;
201
+ } cuCtxSetLimit_params;
202
+
203
+ typedef struct cuCtxGetLimit_params_st {
204
+ size_t *pvalue;
205
+ CUlimit limit;
206
+ } cuCtxGetLimit_params;
207
+
208
+ typedef struct cuCtxGetCacheConfig_params_st {
209
+ CUfunc_cache *pconfig;
210
+ } cuCtxGetCacheConfig_params;
211
+
212
+ typedef struct cuCtxSetCacheConfig_params_st {
213
+ CUfunc_cache config;
214
+ } cuCtxSetCacheConfig_params;
215
+
216
+ typedef struct cuCtxGetApiVersion_params_st {
217
+ CUcontext ctx;
218
+ unsigned int *version;
219
+ } cuCtxGetApiVersion_params;
220
+
221
+ typedef struct cuCtxGetStreamPriorityRange_params_st {
222
+ int *leastPriority;
223
+ int *greatestPriority;
224
+ } cuCtxGetStreamPriorityRange_params;
225
+
226
+ typedef struct cuCtxGetExecAffinity_params_st {
227
+ CUexecAffinityParam *pExecAffinity;
228
+ CUexecAffinityType type;
229
+ } cuCtxGetExecAffinity_params;
230
+
231
+ typedef struct cuCtxAttach_params_st {
232
+ CUcontext *pctx;
233
+ unsigned int flags;
234
+ } cuCtxAttach_params;
235
+
236
+ typedef struct cuCtxDetach_params_st {
237
+ CUcontext ctx;
238
+ } cuCtxDetach_params;
239
+
240
+ typedef struct cuCtxGetSharedMemConfig_params_st {
241
+ CUsharedconfig *pConfig;
242
+ } cuCtxGetSharedMemConfig_params;
243
+
244
+ typedef struct cuCtxSetSharedMemConfig_params_st {
245
+ CUsharedconfig config;
246
+ } cuCtxSetSharedMemConfig_params;
247
+
248
+ typedef struct cuModuleLoad_params_st {
249
+ CUmodule *module;
250
+ const char *fname;
251
+ } cuModuleLoad_params;
252
+
253
+ typedef struct cuModuleLoadData_params_st {
254
+ CUmodule *module;
255
+ const void *image;
256
+ } cuModuleLoadData_params;
257
+
258
+ typedef struct cuModuleLoadDataEx_params_st {
259
+ CUmodule *module;
260
+ const void *image;
261
+ unsigned int numOptions;
262
+ CUjit_option *options;
263
+ void **optionValues;
264
+ } cuModuleLoadDataEx_params;
265
+
266
+ typedef struct cuModuleLoadFatBinary_params_st {
267
+ CUmodule *module;
268
+ const void *fatCubin;
269
+ } cuModuleLoadFatBinary_params;
270
+
271
+ typedef struct cuModuleUnload_params_st {
272
+ CUmodule hmod;
273
+ } cuModuleUnload_params;
274
+
275
+ typedef struct cuModuleGetLoadingMode_params_st {
276
+ CUmoduleLoadingMode *mode;
277
+ } cuModuleGetLoadingMode_params;
278
+
279
+ typedef struct cuModuleGetFunction_params_st {
280
+ CUfunction *hfunc;
281
+ CUmodule hmod;
282
+ const char *name;
283
+ } cuModuleGetFunction_params;
284
+
285
+ typedef struct cuModuleGetFunctionCount_params_st {
286
+ unsigned int *count;
287
+ CUmodule mod;
288
+ } cuModuleGetFunctionCount_params;
289
+
290
+ typedef struct cuModuleEnumerateFunctions_params_st {
291
+ CUfunction *functions;
292
+ unsigned int numFunctions;
293
+ CUmodule mod;
294
+ } cuModuleEnumerateFunctions_params;
295
+
296
+ typedef struct cuModuleGetGlobal_v2_params_st {
297
+ CUdeviceptr *dptr;
298
+ size_t *bytes;
299
+ CUmodule hmod;
300
+ const char *name;
301
+ } cuModuleGetGlobal_v2_params;
302
+
303
+ typedef struct cuLinkCreate_v2_params_st {
304
+ unsigned int numOptions;
305
+ CUjit_option *options;
306
+ void **optionValues;
307
+ CUlinkState *stateOut;
308
+ } cuLinkCreate_v2_params;
309
+
310
+ typedef struct cuLinkAddData_v2_params_st {
311
+ CUlinkState state;
312
+ CUjitInputType type;
313
+ void *data;
314
+ size_t size;
315
+ const char *name;
316
+ unsigned int numOptions;
317
+ CUjit_option *options;
318
+ void **optionValues;
319
+ } cuLinkAddData_v2_params;
320
+
321
+ typedef struct cuLinkAddFile_v2_params_st {
322
+ CUlinkState state;
323
+ CUjitInputType type;
324
+ const char *path;
325
+ unsigned int numOptions;
326
+ CUjit_option *options;
327
+ void **optionValues;
328
+ } cuLinkAddFile_v2_params;
329
+
330
+ typedef struct cuLinkComplete_params_st {
331
+ CUlinkState state;
332
+ void **cubinOut;
333
+ size_t *sizeOut;
334
+ } cuLinkComplete_params;
335
+
336
+ typedef struct cuLinkDestroy_params_st {
337
+ CUlinkState state;
338
+ } cuLinkDestroy_params;
339
+
340
+ typedef struct cuModuleGetTexRef_params_st {
341
+ CUtexref *pTexRef;
342
+ CUmodule hmod;
343
+ const char *name;
344
+ } cuModuleGetTexRef_params;
345
+
346
+ typedef struct cuModuleGetSurfRef_params_st {
347
+ CUsurfref *pSurfRef;
348
+ CUmodule hmod;
349
+ const char *name;
350
+ } cuModuleGetSurfRef_params;
351
+
352
+ typedef struct cuLibraryLoadData_params_st {
353
+ CUlibrary *library;
354
+ const void *code;
355
+ CUjit_option *jitOptions;
356
+ void **jitOptionsValues;
357
+ unsigned int numJitOptions;
358
+ CUlibraryOption *libraryOptions;
359
+ void **libraryOptionValues;
360
+ unsigned int numLibraryOptions;
361
+ } cuLibraryLoadData_params;
362
+
363
+ typedef struct cuLibraryLoadFromFile_params_st {
364
+ CUlibrary *library;
365
+ const char *fileName;
366
+ CUjit_option *jitOptions;
367
+ void **jitOptionsValues;
368
+ unsigned int numJitOptions;
369
+ CUlibraryOption *libraryOptions;
370
+ void **libraryOptionValues;
371
+ unsigned int numLibraryOptions;
372
+ } cuLibraryLoadFromFile_params;
373
+
374
+ typedef struct cuLibraryUnload_params_st {
375
+ CUlibrary library;
376
+ } cuLibraryUnload_params;
377
+
378
+ typedef struct cuLibraryGetKernel_params_st {
379
+ CUkernel *pKernel;
380
+ CUlibrary library;
381
+ const char *name;
382
+ } cuLibraryGetKernel_params;
383
+
384
+ typedef struct cuLibraryGetKernelCount_params_st {
385
+ unsigned int *count;
386
+ CUlibrary lib;
387
+ } cuLibraryGetKernelCount_params;
388
+
389
+ typedef struct cuLibraryEnumerateKernels_params_st {
390
+ CUkernel *kernels;
391
+ unsigned int numKernels;
392
+ CUlibrary lib;
393
+ } cuLibraryEnumerateKernels_params;
394
+
395
+ typedef struct cuLibraryGetModule_params_st {
396
+ CUmodule *pMod;
397
+ CUlibrary library;
398
+ } cuLibraryGetModule_params;
399
+
400
+ typedef struct cuKernelGetFunction_params_st {
401
+ CUfunction *pFunc;
402
+ CUkernel kernel;
403
+ } cuKernelGetFunction_params;
404
+
405
+ typedef struct cuLibraryGetGlobal_params_st {
406
+ CUdeviceptr *dptr;
407
+ size_t *bytes;
408
+ CUlibrary library;
409
+ const char *name;
410
+ } cuLibraryGetGlobal_params;
411
+
412
+ typedef struct cuLibraryGetManaged_params_st {
413
+ CUdeviceptr *dptr;
414
+ size_t *bytes;
415
+ CUlibrary library;
416
+ const char *name;
417
+ } cuLibraryGetManaged_params;
418
+
419
+ typedef struct cuLibraryGetUnifiedFunction_params_st {
420
+ void **fptr;
421
+ CUlibrary library;
422
+ const char *symbol;
423
+ } cuLibraryGetUnifiedFunction_params;
424
+
425
+ typedef struct cuKernelGetAttribute_params_st {
426
+ int *pi;
427
+ CUfunction_attribute attrib;
428
+ CUkernel kernel;
429
+ CUdevice dev;
430
+ } cuKernelGetAttribute_params;
431
+
432
+ typedef struct cuKernelSetAttribute_params_st {
433
+ CUfunction_attribute attrib;
434
+ int val;
435
+ CUkernel kernel;
436
+ CUdevice dev;
437
+ } cuKernelSetAttribute_params;
438
+
439
+ typedef struct cuKernelSetCacheConfig_params_st {
440
+ CUkernel kernel;
441
+ CUfunc_cache config;
442
+ CUdevice dev;
443
+ } cuKernelSetCacheConfig_params;
444
+
445
+ typedef struct cuKernelGetName_params_st {
446
+ const char **name;
447
+ CUkernel hfunc;
448
+ } cuKernelGetName_params;
449
+
450
+ typedef struct cuKernelGetParamInfo_params_st {
451
+ CUkernel kernel;
452
+ size_t paramIndex;
453
+ size_t *paramOffset;
454
+ size_t *paramSize;
455
+ } cuKernelGetParamInfo_params;
456
+
457
+ typedef struct cuMemGetInfo_v2_params_st {
458
+ size_t *free;
459
+ size_t *total;
460
+ } cuMemGetInfo_v2_params;
461
+
462
+ typedef struct cuMemAlloc_v2_params_st {
463
+ CUdeviceptr *dptr;
464
+ size_t bytesize;
465
+ } cuMemAlloc_v2_params;
466
+
467
+ typedef struct cuMemAllocPitch_v2_params_st {
468
+ CUdeviceptr *dptr;
469
+ size_t *pPitch;
470
+ size_t WidthInBytes;
471
+ size_t Height;
472
+ unsigned int ElementSizeBytes;
473
+ } cuMemAllocPitch_v2_params;
474
+
475
+ typedef struct cuMemFree_v2_params_st {
476
+ CUdeviceptr dptr;
477
+ } cuMemFree_v2_params;
478
+
479
+ typedef struct cuMemGetAddressRange_v2_params_st {
480
+ CUdeviceptr *pbase;
481
+ size_t *psize;
482
+ CUdeviceptr dptr;
483
+ } cuMemGetAddressRange_v2_params;
484
+
485
+ typedef struct cuMemAllocHost_v2_params_st {
486
+ void **pp;
487
+ size_t bytesize;
488
+ } cuMemAllocHost_v2_params;
489
+
490
+ typedef struct cuMemFreeHost_params_st {
491
+ void *p;
492
+ } cuMemFreeHost_params;
493
+
494
+ typedef struct cuMemHostAlloc_params_st {
495
+ void **pp;
496
+ size_t bytesize;
497
+ unsigned int Flags;
498
+ } cuMemHostAlloc_params;
499
+
500
+ typedef struct cuMemHostGetDevicePointer_v2_params_st {
501
+ CUdeviceptr *pdptr;
502
+ void *p;
503
+ unsigned int Flags;
504
+ } cuMemHostGetDevicePointer_v2_params;
505
+
506
+ typedef struct cuMemHostGetFlags_params_st {
507
+ unsigned int *pFlags;
508
+ void *p;
509
+ } cuMemHostGetFlags_params;
510
+
511
+ typedef struct cuMemAllocManaged_params_st {
512
+ CUdeviceptr *dptr;
513
+ size_t bytesize;
514
+ unsigned int flags;
515
+ } cuMemAllocManaged_params;
516
+
517
+ typedef struct cuDeviceGetByPCIBusId_params_st {
518
+ CUdevice *dev;
519
+ const char *pciBusId;
520
+ } cuDeviceGetByPCIBusId_params;
521
+
522
+ typedef struct cuDeviceGetPCIBusId_params_st {
523
+ char *pciBusId;
524
+ int len;
525
+ CUdevice dev;
526
+ } cuDeviceGetPCIBusId_params;
527
+
528
+ typedef struct cuIpcGetEventHandle_params_st {
529
+ CUipcEventHandle *pHandle;
530
+ CUevent event;
531
+ } cuIpcGetEventHandle_params;
532
+
533
+ typedef struct cuIpcOpenEventHandle_params_st {
534
+ CUevent *phEvent;
535
+ CUipcEventHandle handle;
536
+ } cuIpcOpenEventHandle_params;
537
+
538
+ typedef struct cuIpcGetMemHandle_params_st {
539
+ CUipcMemHandle *pHandle;
540
+ CUdeviceptr dptr;
541
+ } cuIpcGetMemHandle_params;
542
+
543
+ typedef struct cuIpcOpenMemHandle_v2_params_st {
544
+ CUdeviceptr *pdptr;
545
+ CUipcMemHandle handle;
546
+ unsigned int Flags;
547
+ } cuIpcOpenMemHandle_v2_params;
548
+
549
+ typedef struct cuIpcCloseMemHandle_params_st {
550
+ CUdeviceptr dptr;
551
+ } cuIpcCloseMemHandle_params;
552
+
553
+ typedef struct cuMemHostRegister_v2_params_st {
554
+ void *p;
555
+ size_t bytesize;
556
+ unsigned int Flags;
557
+ } cuMemHostRegister_v2_params;
558
+
559
+ typedef struct cuMemHostUnregister_params_st {
560
+ void *p;
561
+ } cuMemHostUnregister_params;
562
+
563
+ typedef struct cuMemcpy_ptds_params_st {
564
+ CUdeviceptr dst;
565
+ CUdeviceptr src;
566
+ size_t ByteCount;
567
+ } cuMemcpy_ptds_params;
568
+
569
+ typedef struct cuMemcpyPeer_ptds_params_st {
570
+ CUdeviceptr dstDevice;
571
+ CUcontext dstContext;
572
+ CUdeviceptr srcDevice;
573
+ CUcontext srcContext;
574
+ size_t ByteCount;
575
+ } cuMemcpyPeer_ptds_params;
576
+
577
+ typedef struct cuMemcpyHtoD_v2_ptds_params_st {
578
+ CUdeviceptr dstDevice;
579
+ const void *srcHost;
580
+ size_t ByteCount;
581
+ } cuMemcpyHtoD_v2_ptds_params;
582
+
583
+ typedef struct cuMemcpyDtoH_v2_ptds_params_st {
584
+ void *dstHost;
585
+ CUdeviceptr srcDevice;
586
+ size_t ByteCount;
587
+ } cuMemcpyDtoH_v2_ptds_params;
588
+
589
+ typedef struct cuMemcpyDtoD_v2_ptds_params_st {
590
+ CUdeviceptr dstDevice;
591
+ CUdeviceptr srcDevice;
592
+ size_t ByteCount;
593
+ } cuMemcpyDtoD_v2_ptds_params;
594
+
595
+ typedef struct cuMemcpyDtoA_v2_ptds_params_st {
596
+ CUarray dstArray;
597
+ size_t dstOffset;
598
+ CUdeviceptr srcDevice;
599
+ size_t ByteCount;
600
+ } cuMemcpyDtoA_v2_ptds_params;
601
+
602
+ typedef struct cuMemcpyAtoD_v2_ptds_params_st {
603
+ CUdeviceptr dstDevice;
604
+ CUarray srcArray;
605
+ size_t srcOffset;
606
+ size_t ByteCount;
607
+ } cuMemcpyAtoD_v2_ptds_params;
608
+
609
+ typedef struct cuMemcpyHtoA_v2_ptds_params_st {
610
+ CUarray dstArray;
611
+ size_t dstOffset;
612
+ const void *srcHost;
613
+ size_t ByteCount;
614
+ } cuMemcpyHtoA_v2_ptds_params;
615
+
616
+ typedef struct cuMemcpyAtoH_v2_ptds_params_st {
617
+ void *dstHost;
618
+ CUarray srcArray;
619
+ size_t srcOffset;
620
+ size_t ByteCount;
621
+ } cuMemcpyAtoH_v2_ptds_params;
622
+
623
+ typedef struct cuMemcpyAtoA_v2_ptds_params_st {
624
+ CUarray dstArray;
625
+ size_t dstOffset;
626
+ CUarray srcArray;
627
+ size_t srcOffset;
628
+ size_t ByteCount;
629
+ } cuMemcpyAtoA_v2_ptds_params;
630
+
631
+ typedef struct cuMemcpy2D_v2_ptds_params_st {
632
+ const CUDA_MEMCPY2D *pCopy;
633
+ } cuMemcpy2D_v2_ptds_params;
634
+
635
+ typedef struct cuMemcpy2DUnaligned_v2_ptds_params_st {
636
+ const CUDA_MEMCPY2D *pCopy;
637
+ } cuMemcpy2DUnaligned_v2_ptds_params;
638
+
639
+ typedef struct cuMemcpy3D_v2_ptds_params_st {
640
+ const CUDA_MEMCPY3D *pCopy;
641
+ } cuMemcpy3D_v2_ptds_params;
642
+
643
+ typedef struct cuMemcpy3DPeer_ptds_params_st {
644
+ const CUDA_MEMCPY3D_PEER *pCopy;
645
+ } cuMemcpy3DPeer_ptds_params;
646
+
647
+ typedef struct cuMemcpyAsync_ptsz_params_st {
648
+ CUdeviceptr dst;
649
+ CUdeviceptr src;
650
+ size_t ByteCount;
651
+ CUstream hStream;
652
+ } cuMemcpyAsync_ptsz_params;
653
+
654
+ typedef struct cuMemcpyPeerAsync_ptsz_params_st {
655
+ CUdeviceptr dstDevice;
656
+ CUcontext dstContext;
657
+ CUdeviceptr srcDevice;
658
+ CUcontext srcContext;
659
+ size_t ByteCount;
660
+ CUstream hStream;
661
+ } cuMemcpyPeerAsync_ptsz_params;
662
+
663
+ typedef struct cuMemcpyHtoDAsync_v2_ptsz_params_st {
664
+ CUdeviceptr dstDevice;
665
+ const void *srcHost;
666
+ size_t ByteCount;
667
+ CUstream hStream;
668
+ } cuMemcpyHtoDAsync_v2_ptsz_params;
669
+
670
+ typedef struct cuMemcpyDtoHAsync_v2_ptsz_params_st {
671
+ void *dstHost;
672
+ CUdeviceptr srcDevice;
673
+ size_t ByteCount;
674
+ CUstream hStream;
675
+ } cuMemcpyDtoHAsync_v2_ptsz_params;
676
+
677
+ typedef struct cuMemcpyDtoDAsync_v2_ptsz_params_st {
678
+ CUdeviceptr dstDevice;
679
+ CUdeviceptr srcDevice;
680
+ size_t ByteCount;
681
+ CUstream hStream;
682
+ } cuMemcpyDtoDAsync_v2_ptsz_params;
683
+
684
+ typedef struct cuMemcpyHtoAAsync_v2_ptsz_params_st {
685
+ CUarray dstArray;
686
+ size_t dstOffset;
687
+ const void *srcHost;
688
+ size_t ByteCount;
689
+ CUstream hStream;
690
+ } cuMemcpyHtoAAsync_v2_ptsz_params;
691
+
692
+ typedef struct cuMemcpyAtoHAsync_v2_ptsz_params_st {
693
+ void *dstHost;
694
+ CUarray srcArray;
695
+ size_t srcOffset;
696
+ size_t ByteCount;
697
+ CUstream hStream;
698
+ } cuMemcpyAtoHAsync_v2_ptsz_params;
699
+
700
+ typedef struct cuMemcpy2DAsync_v2_ptsz_params_st {
701
+ const CUDA_MEMCPY2D *pCopy;
702
+ CUstream hStream;
703
+ } cuMemcpy2DAsync_v2_ptsz_params;
704
+
705
+ typedef struct cuMemcpy3DAsync_v2_ptsz_params_st {
706
+ const CUDA_MEMCPY3D *pCopy;
707
+ CUstream hStream;
708
+ } cuMemcpy3DAsync_v2_ptsz_params;
709
+
710
+ typedef struct cuMemcpy3DPeerAsync_ptsz_params_st {
711
+ const CUDA_MEMCPY3D_PEER *pCopy;
712
+ CUstream hStream;
713
+ } cuMemcpy3DPeerAsync_ptsz_params;
714
+
715
+ typedef struct cuMemsetD8_v2_ptds_params_st {
716
+ CUdeviceptr dstDevice;
717
+ unsigned char uc;
718
+ size_t N;
719
+ } cuMemsetD8_v2_ptds_params;
720
+
721
+ typedef struct cuMemsetD16_v2_ptds_params_st {
722
+ CUdeviceptr dstDevice;
723
+ unsigned short us;
724
+ size_t N;
725
+ } cuMemsetD16_v2_ptds_params;
726
+
727
+ typedef struct cuMemsetD32_v2_ptds_params_st {
728
+ CUdeviceptr dstDevice;
729
+ unsigned int ui;
730
+ size_t N;
731
+ } cuMemsetD32_v2_ptds_params;
732
+
733
+ typedef struct cuMemsetD2D8_v2_ptds_params_st {
734
+ CUdeviceptr dstDevice;
735
+ size_t dstPitch;
736
+ unsigned char uc;
737
+ size_t Width;
738
+ size_t Height;
739
+ } cuMemsetD2D8_v2_ptds_params;
740
+
741
+ typedef struct cuMemsetD2D16_v2_ptds_params_st {
742
+ CUdeviceptr dstDevice;
743
+ size_t dstPitch;
744
+ unsigned short us;
745
+ size_t Width;
746
+ size_t Height;
747
+ } cuMemsetD2D16_v2_ptds_params;
748
+
749
+ typedef struct cuMemsetD2D32_v2_ptds_params_st {
750
+ CUdeviceptr dstDevice;
751
+ size_t dstPitch;
752
+ unsigned int ui;
753
+ size_t Width;
754
+ size_t Height;
755
+ } cuMemsetD2D32_v2_ptds_params;
756
+
757
+ typedef struct cuMemsetD8Async_ptsz_params_st {
758
+ CUdeviceptr dstDevice;
759
+ unsigned char uc;
760
+ size_t N;
761
+ CUstream hStream;
762
+ } cuMemsetD8Async_ptsz_params;
763
+
764
+ typedef struct cuMemsetD16Async_ptsz_params_st {
765
+ CUdeviceptr dstDevice;
766
+ unsigned short us;
767
+ size_t N;
768
+ CUstream hStream;
769
+ } cuMemsetD16Async_ptsz_params;
770
+
771
+ typedef struct cuMemsetD32Async_ptsz_params_st {
772
+ CUdeviceptr dstDevice;
773
+ unsigned int ui;
774
+ size_t N;
775
+ CUstream hStream;
776
+ } cuMemsetD32Async_ptsz_params;
777
+
778
+ typedef struct cuMemsetD2D8Async_ptsz_params_st {
779
+ CUdeviceptr dstDevice;
780
+ size_t dstPitch;
781
+ unsigned char uc;
782
+ size_t Width;
783
+ size_t Height;
784
+ CUstream hStream;
785
+ } cuMemsetD2D8Async_ptsz_params;
786
+
787
+ typedef struct cuMemsetD2D16Async_ptsz_params_st {
788
+ CUdeviceptr dstDevice;
789
+ size_t dstPitch;
790
+ unsigned short us;
791
+ size_t Width;
792
+ size_t Height;
793
+ CUstream hStream;
794
+ } cuMemsetD2D16Async_ptsz_params;
795
+
796
+ typedef struct cuMemsetD2D32Async_ptsz_params_st {
797
+ CUdeviceptr dstDevice;
798
+ size_t dstPitch;
799
+ unsigned int ui;
800
+ size_t Width;
801
+ size_t Height;
802
+ CUstream hStream;
803
+ } cuMemsetD2D32Async_ptsz_params;
804
+
805
+ typedef struct cuArrayCreate_v2_params_st {
806
+ CUarray *pHandle;
807
+ const CUDA_ARRAY_DESCRIPTOR *pAllocateArray;
808
+ } cuArrayCreate_v2_params;
809
+
810
+ typedef struct cuArrayGetDescriptor_v2_params_st {
811
+ CUDA_ARRAY_DESCRIPTOR *pArrayDescriptor;
812
+ CUarray hArray;
813
+ } cuArrayGetDescriptor_v2_params;
814
+
815
+ typedef struct cuArrayGetSparseProperties_params_st {
816
+ CUDA_ARRAY_SPARSE_PROPERTIES *sparseProperties;
817
+ CUarray array;
818
+ } cuArrayGetSparseProperties_params;
819
+
820
+ typedef struct cuMipmappedArrayGetSparseProperties_params_st {
821
+ CUDA_ARRAY_SPARSE_PROPERTIES *sparseProperties;
822
+ CUmipmappedArray mipmap;
823
+ } cuMipmappedArrayGetSparseProperties_params;
824
+
825
+ typedef struct cuArrayGetMemoryRequirements_params_st {
826
+ CUDA_ARRAY_MEMORY_REQUIREMENTS *memoryRequirements;
827
+ CUarray array;
828
+ CUdevice device;
829
+ } cuArrayGetMemoryRequirements_params;
830
+
831
+ typedef struct cuMipmappedArrayGetMemoryRequirements_params_st {
832
+ CUDA_ARRAY_MEMORY_REQUIREMENTS *memoryRequirements;
833
+ CUmipmappedArray mipmap;
834
+ CUdevice device;
835
+ } cuMipmappedArrayGetMemoryRequirements_params;
836
+
837
+ typedef struct cuArrayGetPlane_params_st {
838
+ CUarray *pPlaneArray;
839
+ CUarray hArray;
840
+ unsigned int planeIdx;
841
+ } cuArrayGetPlane_params;
842
+
843
+ typedef struct cuArrayDestroy_params_st {
844
+ CUarray hArray;
845
+ } cuArrayDestroy_params;
846
+
847
+ typedef struct cuArray3DCreate_v2_params_st {
848
+ CUarray *pHandle;
849
+ const CUDA_ARRAY3D_DESCRIPTOR *pAllocateArray;
850
+ } cuArray3DCreate_v2_params;
851
+
852
+ typedef struct cuArray3DGetDescriptor_v2_params_st {
853
+ CUDA_ARRAY3D_DESCRIPTOR *pArrayDescriptor;
854
+ CUarray hArray;
855
+ } cuArray3DGetDescriptor_v2_params;
856
+
857
+ typedef struct cuMipmappedArrayCreate_params_st {
858
+ CUmipmappedArray *pHandle;
859
+ const CUDA_ARRAY3D_DESCRIPTOR *pMipmappedArrayDesc;
860
+ unsigned int numMipmapLevels;
861
+ } cuMipmappedArrayCreate_params;
862
+
863
+ typedef struct cuMipmappedArrayGetLevel_params_st {
864
+ CUarray *pLevelArray;
865
+ CUmipmappedArray hMipmappedArray;
866
+ unsigned int level;
867
+ } cuMipmappedArrayGetLevel_params;
868
+
869
+ typedef struct cuMipmappedArrayDestroy_params_st {
870
+ CUmipmappedArray hMipmappedArray;
871
+ } cuMipmappedArrayDestroy_params;
872
+
873
+ typedef struct cuMemGetHandleForAddressRange_params_st {
874
+ void *handle;
875
+ CUdeviceptr dptr;
876
+ size_t size;
877
+ CUmemRangeHandleType handleType;
878
+ unsigned long long flags;
879
+ } cuMemGetHandleForAddressRange_params;
880
+
881
+ typedef struct cuMemAddressReserve_params_st {
882
+ CUdeviceptr *ptr;
883
+ size_t size;
884
+ size_t alignment;
885
+ CUdeviceptr addr;
886
+ unsigned long long flags;
887
+ } cuMemAddressReserve_params;
888
+
889
+ typedef struct cuMemAddressFree_params_st {
890
+ CUdeviceptr ptr;
891
+ size_t size;
892
+ } cuMemAddressFree_params;
893
+
894
+ typedef struct cuMemCreate_params_st {
895
+ CUmemGenericAllocationHandle *handle;
896
+ size_t size;
897
+ const CUmemAllocationProp *prop;
898
+ unsigned long long flags;
899
+ } cuMemCreate_params;
900
+
901
+ typedef struct cuMemRelease_params_st {
902
+ CUmemGenericAllocationHandle handle;
903
+ } cuMemRelease_params;
904
+
905
+ typedef struct cuMemMap_params_st {
906
+ CUdeviceptr ptr;
907
+ size_t size;
908
+ size_t offset;
909
+ CUmemGenericAllocationHandle handle;
910
+ unsigned long long flags;
911
+ } cuMemMap_params;
912
+
913
+ typedef struct cuMemMapArrayAsync_ptsz_params_st {
914
+ CUarrayMapInfo *mapInfoList;
915
+ unsigned int count;
916
+ CUstream hStream;
917
+ } cuMemMapArrayAsync_ptsz_params;
918
+
919
+ typedef struct cuMemUnmap_params_st {
920
+ CUdeviceptr ptr;
921
+ size_t size;
922
+ } cuMemUnmap_params;
923
+
924
+ typedef struct cuMemSetAccess_params_st {
925
+ CUdeviceptr ptr;
926
+ size_t size;
927
+ const CUmemAccessDesc *desc;
928
+ size_t count;
929
+ } cuMemSetAccess_params;
930
+
931
+ typedef struct cuMemGetAccess_params_st {
932
+ unsigned long long *flags;
933
+ const CUmemLocation *location;
934
+ CUdeviceptr ptr;
935
+ } cuMemGetAccess_params;
936
+
937
+ typedef struct cuMemExportToShareableHandle_params_st {
938
+ void *shareableHandle;
939
+ CUmemGenericAllocationHandle handle;
940
+ CUmemAllocationHandleType handleType;
941
+ unsigned long long flags;
942
+ } cuMemExportToShareableHandle_params;
943
+
944
+ typedef struct cuMemImportFromShareableHandle_params_st {
945
+ CUmemGenericAllocationHandle *handle;
946
+ void *osHandle;
947
+ CUmemAllocationHandleType shHandleType;
948
+ } cuMemImportFromShareableHandle_params;
949
+
950
+ typedef struct cuMemGetAllocationGranularity_params_st {
951
+ size_t *granularity;
952
+ const CUmemAllocationProp *prop;
953
+ CUmemAllocationGranularity_flags option;
954
+ } cuMemGetAllocationGranularity_params;
955
+
956
+ typedef struct cuMemGetAllocationPropertiesFromHandle_params_st {
957
+ CUmemAllocationProp *prop;
958
+ CUmemGenericAllocationHandle handle;
959
+ } cuMemGetAllocationPropertiesFromHandle_params;
960
+
961
+ typedef struct cuMemRetainAllocationHandle_params_st {
962
+ CUmemGenericAllocationHandle *handle;
963
+ void *addr;
964
+ } cuMemRetainAllocationHandle_params;
965
+
966
+ typedef struct cuMemFreeAsync_ptsz_params_st {
967
+ CUdeviceptr dptr;
968
+ CUstream hStream;
969
+ } cuMemFreeAsync_ptsz_params;
970
+
971
+ typedef struct cuMemAllocAsync_ptsz_params_st {
972
+ CUdeviceptr *dptr;
973
+ size_t bytesize;
974
+ CUstream hStream;
975
+ } cuMemAllocAsync_ptsz_params;
976
+
977
+ typedef struct cuMemPoolTrimTo_params_st {
978
+ CUmemoryPool pool;
979
+ size_t minBytesToKeep;
980
+ } cuMemPoolTrimTo_params;
981
+
982
+ typedef struct cuMemPoolSetAttribute_params_st {
983
+ CUmemoryPool pool;
984
+ CUmemPool_attribute attr;
985
+ void *value;
986
+ } cuMemPoolSetAttribute_params;
987
+
988
+ typedef struct cuMemPoolGetAttribute_params_st {
989
+ CUmemoryPool pool;
990
+ CUmemPool_attribute attr;
991
+ void *value;
992
+ } cuMemPoolGetAttribute_params;
993
+
994
+ typedef struct cuMemPoolSetAccess_params_st {
995
+ CUmemoryPool pool;
996
+ const CUmemAccessDesc *map;
997
+ size_t count;
998
+ } cuMemPoolSetAccess_params;
999
+
1000
+ typedef struct cuMemPoolGetAccess_params_st {
1001
+ CUmemAccess_flags *flags;
1002
+ CUmemoryPool memPool;
1003
+ CUmemLocation *location;
1004
+ } cuMemPoolGetAccess_params;
1005
+
1006
+ typedef struct cuMemPoolCreate_params_st {
1007
+ CUmemoryPool *pool;
1008
+ const CUmemPoolProps *poolProps;
1009
+ } cuMemPoolCreate_params;
1010
+
1011
+ typedef struct cuMemPoolDestroy_params_st {
1012
+ CUmemoryPool pool;
1013
+ } cuMemPoolDestroy_params;
1014
+
1015
+ typedef struct cuMemAllocFromPoolAsync_ptsz_params_st {
1016
+ CUdeviceptr *dptr;
1017
+ size_t bytesize;
1018
+ CUmemoryPool pool;
1019
+ CUstream hStream;
1020
+ } cuMemAllocFromPoolAsync_ptsz_params;
1021
+
1022
+ typedef struct cuMemPoolExportToShareableHandle_params_st {
1023
+ void *handle_out;
1024
+ CUmemoryPool pool;
1025
+ CUmemAllocationHandleType handleType;
1026
+ unsigned long long flags;
1027
+ } cuMemPoolExportToShareableHandle_params;
1028
+
1029
+ typedef struct cuMemPoolImportFromShareableHandle_params_st {
1030
+ CUmemoryPool *pool_out;
1031
+ void *handle;
1032
+ CUmemAllocationHandleType handleType;
1033
+ unsigned long long flags;
1034
+ } cuMemPoolImportFromShareableHandle_params;
1035
+
1036
+ typedef struct cuMemPoolExportPointer_params_st {
1037
+ CUmemPoolPtrExportData *shareData_out;
1038
+ CUdeviceptr ptr;
1039
+ } cuMemPoolExportPointer_params;
1040
+
1041
+ typedef struct cuMemPoolImportPointer_params_st {
1042
+ CUdeviceptr *ptr_out;
1043
+ CUmemoryPool pool;
1044
+ CUmemPoolPtrExportData *shareData;
1045
+ } cuMemPoolImportPointer_params;
1046
+
1047
+ typedef struct cuMulticastCreate_params_st {
1048
+ CUmemGenericAllocationHandle *mcHandle;
1049
+ const CUmulticastObjectProp *prop;
1050
+ } cuMulticastCreate_params;
1051
+
1052
+ typedef struct cuMulticastAddDevice_params_st {
1053
+ CUmemGenericAllocationHandle mcHandle;
1054
+ CUdevice dev;
1055
+ } cuMulticastAddDevice_params;
1056
+
1057
+ typedef struct cuMulticastBindMem_params_st {
1058
+ CUmemGenericAllocationHandle mcHandle;
1059
+ size_t mcOffset;
1060
+ CUmemGenericAllocationHandle memHandle;
1061
+ size_t memOffset;
1062
+ size_t size;
1063
+ unsigned long long flags;
1064
+ } cuMulticastBindMem_params;
1065
+
1066
+ typedef struct cuMulticastBindAddr_params_st {
1067
+ CUmemGenericAllocationHandle mcHandle;
1068
+ size_t mcOffset;
1069
+ CUdeviceptr memptr;
1070
+ size_t size;
1071
+ unsigned long long flags;
1072
+ } cuMulticastBindAddr_params;
1073
+
1074
+ typedef struct cuMulticastUnbind_params_st {
1075
+ CUmemGenericAllocationHandle mcHandle;
1076
+ CUdevice dev;
1077
+ size_t mcOffset;
1078
+ size_t size;
1079
+ } cuMulticastUnbind_params;
1080
+
1081
+ typedef struct cuMulticastGetGranularity_params_st {
1082
+ size_t *granularity;
1083
+ const CUmulticastObjectProp *prop;
1084
+ CUmulticastGranularity_flags option;
1085
+ } cuMulticastGetGranularity_params;
1086
+
1087
+ typedef struct cuPointerGetAttribute_params_st {
1088
+ void *data;
1089
+ CUpointer_attribute attribute;
1090
+ CUdeviceptr ptr;
1091
+ } cuPointerGetAttribute_params;
1092
+
1093
+ typedef struct cuMemPrefetchAsync_ptsz_params_st {
1094
+ CUdeviceptr devPtr;
1095
+ size_t count;
1096
+ CUdevice dstDevice;
1097
+ CUstream hStream;
1098
+ } cuMemPrefetchAsync_ptsz_params;
1099
+
1100
+ typedef struct cuMemPrefetchAsync_v2_ptsz_params_st {
1101
+ CUdeviceptr devPtr;
1102
+ size_t count;
1103
+ CUmemLocation location;
1104
+ unsigned int flags;
1105
+ CUstream hStream;
1106
+ } cuMemPrefetchAsync_v2_ptsz_params;
1107
+
1108
+ typedef struct cuMemAdvise_params_st {
1109
+ CUdeviceptr devPtr;
1110
+ size_t count;
1111
+ CUmem_advise advice;
1112
+ CUdevice device;
1113
+ } cuMemAdvise_params;
1114
+
1115
+ typedef struct cuMemAdvise_v2_params_st {
1116
+ CUdeviceptr devPtr;
1117
+ size_t count;
1118
+ CUmem_advise advice;
1119
+ CUmemLocation location;
1120
+ } cuMemAdvise_v2_params;
1121
+
1122
+ typedef struct cuMemRangeGetAttribute_params_st {
1123
+ void *data;
1124
+ size_t dataSize;
1125
+ CUmem_range_attribute attribute;
1126
+ CUdeviceptr devPtr;
1127
+ size_t count;
1128
+ } cuMemRangeGetAttribute_params;
1129
+
1130
+ typedef struct cuMemRangeGetAttributes_params_st {
1131
+ void **data;
1132
+ size_t *dataSizes;
1133
+ CUmem_range_attribute *attributes;
1134
+ size_t numAttributes;
1135
+ CUdeviceptr devPtr;
1136
+ size_t count;
1137
+ } cuMemRangeGetAttributes_params;
1138
+
1139
+ typedef struct cuPointerSetAttribute_params_st {
1140
+ const void *value;
1141
+ CUpointer_attribute attribute;
1142
+ CUdeviceptr ptr;
1143
+ } cuPointerSetAttribute_params;
1144
+
1145
+ typedef struct cuPointerGetAttributes_params_st {
1146
+ unsigned int numAttributes;
1147
+ CUpointer_attribute *attributes;
1148
+ void **data;
1149
+ CUdeviceptr ptr;
1150
+ } cuPointerGetAttributes_params;
1151
+
1152
+ typedef struct cuStreamCreate_params_st {
1153
+ CUstream *phStream;
1154
+ unsigned int Flags;
1155
+ } cuStreamCreate_params;
1156
+
1157
+ typedef struct cuStreamCreateWithPriority_params_st {
1158
+ CUstream *phStream;
1159
+ unsigned int flags;
1160
+ int priority;
1161
+ } cuStreamCreateWithPriority_params;
1162
+
1163
+ typedef struct cuStreamGetPriority_ptsz_params_st {
1164
+ CUstream hStream;
1165
+ int *priority;
1166
+ } cuStreamGetPriority_ptsz_params;
1167
+
1168
+ typedef struct cuStreamGetFlags_ptsz_params_st {
1169
+ CUstream hStream;
1170
+ unsigned int *flags;
1171
+ } cuStreamGetFlags_ptsz_params;
1172
+
1173
+ typedef struct cuStreamGetId_ptsz_params_st {
1174
+ CUstream hStream;
1175
+ unsigned long long *streamId;
1176
+ } cuStreamGetId_ptsz_params;
1177
+
1178
+ typedef struct cuStreamGetCtx_ptsz_params_st {
1179
+ CUstream hStream;
1180
+ CUcontext *pctx;
1181
+ } cuStreamGetCtx_ptsz_params;
1182
+
1183
+ typedef struct cuStreamWaitEvent_ptsz_params_st {
1184
+ CUstream hStream;
1185
+ CUevent hEvent;
1186
+ unsigned int Flags;
1187
+ } cuStreamWaitEvent_ptsz_params;
1188
+
1189
+ typedef struct cuStreamAddCallback_ptsz_params_st {
1190
+ CUstream hStream;
1191
+ CUstreamCallback callback;
1192
+ void *userData;
1193
+ unsigned int flags;
1194
+ } cuStreamAddCallback_ptsz_params;
1195
+
1196
+ typedef struct cuStreamBeginCapture_v2_ptsz_params_st {
1197
+ CUstream hStream;
1198
+ CUstreamCaptureMode mode;
1199
+ } cuStreamBeginCapture_v2_ptsz_params;
1200
+
1201
+ typedef struct cuStreamBeginCaptureToGraph_ptsz_params_st {
1202
+ CUstream hStream;
1203
+ CUgraph hGraph;
1204
+ const CUgraphNode *dependencies;
1205
+ const CUgraphEdgeData *dependencyData;
1206
+ size_t numDependencies;
1207
+ CUstreamCaptureMode mode;
1208
+ } cuStreamBeginCaptureToGraph_ptsz_params;
1209
+
1210
+ typedef struct cuThreadExchangeStreamCaptureMode_params_st {
1211
+ CUstreamCaptureMode *mode;
1212
+ } cuThreadExchangeStreamCaptureMode_params;
1213
+
1214
+ typedef struct cuStreamEndCapture_ptsz_params_st {
1215
+ CUstream hStream;
1216
+ CUgraph *phGraph;
1217
+ } cuStreamEndCapture_ptsz_params;
1218
+
1219
+ typedef struct cuStreamIsCapturing_ptsz_params_st {
1220
+ CUstream hStream;
1221
+ CUstreamCaptureStatus *captureStatus;
1222
+ } cuStreamIsCapturing_ptsz_params;
1223
+
1224
+ typedef struct cuStreamGetCaptureInfo_v2_ptsz_params_st {
1225
+ CUstream hStream;
1226
+ CUstreamCaptureStatus *captureStatus_out;
1227
+ cuuint64_t *id_out;
1228
+ CUgraph *graph_out;
1229
+ const CUgraphNode **dependencies_out;
1230
+ size_t *numDependencies_out;
1231
+ } cuStreamGetCaptureInfo_v2_ptsz_params;
1232
+
1233
+ typedef struct cuStreamGetCaptureInfo_v3_ptsz_params_st {
1234
+ CUstream hStream;
1235
+ CUstreamCaptureStatus *captureStatus_out;
1236
+ cuuint64_t *id_out;
1237
+ CUgraph *graph_out;
1238
+ const CUgraphNode **dependencies_out;
1239
+ const CUgraphEdgeData **edgeData_out;
1240
+ size_t *numDependencies_out;
1241
+ } cuStreamGetCaptureInfo_v3_ptsz_params;
1242
+
1243
+ typedef struct cuStreamUpdateCaptureDependencies_ptsz_params_st {
1244
+ CUstream hStream;
1245
+ CUgraphNode *dependencies;
1246
+ size_t numDependencies;
1247
+ unsigned int flags;
1248
+ } cuStreamUpdateCaptureDependencies_ptsz_params;
1249
+
1250
+ typedef struct cuStreamUpdateCaptureDependencies_v2_ptsz_params_st {
1251
+ CUstream hStream;
1252
+ CUgraphNode *dependencies;
1253
+ const CUgraphEdgeData *dependencyData;
1254
+ size_t numDependencies;
1255
+ unsigned int flags;
1256
+ } cuStreamUpdateCaptureDependencies_v2_ptsz_params;
1257
+
1258
+ typedef struct cuStreamAttachMemAsync_ptsz_params_st {
1259
+ CUstream hStream;
1260
+ CUdeviceptr dptr;
1261
+ size_t length;
1262
+ unsigned int flags;
1263
+ } cuStreamAttachMemAsync_ptsz_params;
1264
+
1265
+ typedef struct cuStreamQuery_ptsz_params_st {
1266
+ CUstream hStream;
1267
+ } cuStreamQuery_ptsz_params;
1268
+
1269
+ typedef struct cuStreamSynchronize_ptsz_params_st {
1270
+ CUstream hStream;
1271
+ } cuStreamSynchronize_ptsz_params;
1272
+
1273
+ typedef struct cuStreamDestroy_v2_params_st {
1274
+ CUstream hStream;
1275
+ } cuStreamDestroy_v2_params;
1276
+
1277
+ typedef struct cuStreamCopyAttributes_ptsz_params_st {
1278
+ CUstream dst;
1279
+ CUstream src;
1280
+ } cuStreamCopyAttributes_ptsz_params;
1281
+
1282
+ typedef struct cuStreamGetAttribute_ptsz_params_st {
1283
+ CUstream hStream;
1284
+ CUstreamAttrID attr;
1285
+ CUstreamAttrValue *value_out;
1286
+ } cuStreamGetAttribute_ptsz_params;
1287
+
1288
+ typedef struct cuStreamSetAttribute_ptsz_params_st {
1289
+ CUstream hStream;
1290
+ CUstreamAttrID attr;
1291
+ const CUstreamAttrValue *value;
1292
+ } cuStreamSetAttribute_ptsz_params;
1293
+
1294
+ typedef struct cuEventCreate_params_st {
1295
+ CUevent *phEvent;
1296
+ unsigned int Flags;
1297
+ } cuEventCreate_params;
1298
+
1299
+ typedef struct cuEventRecord_ptsz_params_st {
1300
+ CUevent hEvent;
1301
+ CUstream hStream;
1302
+ } cuEventRecord_ptsz_params;
1303
+
1304
+ typedef struct cuEventRecordWithFlags_ptsz_params_st {
1305
+ CUevent hEvent;
1306
+ CUstream hStream;
1307
+ unsigned int flags;
1308
+ } cuEventRecordWithFlags_ptsz_params;
1309
+
1310
+ typedef struct cuEventQuery_params_st {
1311
+ CUevent hEvent;
1312
+ } cuEventQuery_params;
1313
+
1314
+ typedef struct cuEventSynchronize_params_st {
1315
+ CUevent hEvent;
1316
+ } cuEventSynchronize_params;
1317
+
1318
+ typedef struct cuEventDestroy_v2_params_st {
1319
+ CUevent hEvent;
1320
+ } cuEventDestroy_v2_params;
1321
+
1322
+ typedef struct cuEventElapsedTime_params_st {
1323
+ float *pMilliseconds;
1324
+ CUevent hStart;
1325
+ CUevent hEnd;
1326
+ } cuEventElapsedTime_params;
1327
+
1328
+ typedef struct cuImportExternalMemory_params_st {
1329
+ CUexternalMemory *extMem_out;
1330
+ const CUDA_EXTERNAL_MEMORY_HANDLE_DESC *memHandleDesc;
1331
+ } cuImportExternalMemory_params;
1332
+
1333
+ typedef struct cuExternalMemoryGetMappedBuffer_params_st {
1334
+ CUdeviceptr *devPtr;
1335
+ CUexternalMemory extMem;
1336
+ const CUDA_EXTERNAL_MEMORY_BUFFER_DESC *bufferDesc;
1337
+ } cuExternalMemoryGetMappedBuffer_params;
1338
+
1339
+ typedef struct cuExternalMemoryGetMappedMipmappedArray_params_st {
1340
+ CUmipmappedArray *mipmap;
1341
+ CUexternalMemory extMem;
1342
+ const CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC *mipmapDesc;
1343
+ } cuExternalMemoryGetMappedMipmappedArray_params;
1344
+
1345
+ typedef struct cuDestroyExternalMemory_params_st {
1346
+ CUexternalMemory extMem;
1347
+ } cuDestroyExternalMemory_params;
1348
+
1349
+ typedef struct cuImportExternalSemaphore_params_st {
1350
+ CUexternalSemaphore *extSem_out;
1351
+ const CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC *semHandleDesc;
1352
+ } cuImportExternalSemaphore_params;
1353
+
1354
+ typedef struct cuSignalExternalSemaphoresAsync_ptsz_params_st {
1355
+ const CUexternalSemaphore *extSemArray;
1356
+ const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS *paramsArray;
1357
+ unsigned int numExtSems;
1358
+ CUstream stream;
1359
+ } cuSignalExternalSemaphoresAsync_ptsz_params;
1360
+
1361
+ typedef struct cuWaitExternalSemaphoresAsync_ptsz_params_st {
1362
+ const CUexternalSemaphore *extSemArray;
1363
+ const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS *paramsArray;
1364
+ unsigned int numExtSems;
1365
+ CUstream stream;
1366
+ } cuWaitExternalSemaphoresAsync_ptsz_params;
1367
+
1368
+ typedef struct cuDestroyExternalSemaphore_params_st {
1369
+ CUexternalSemaphore extSem;
1370
+ } cuDestroyExternalSemaphore_params;
1371
+
1372
+ typedef struct cuStreamWaitValue32_v2_ptsz_params_st {
1373
+ CUstream stream;
1374
+ CUdeviceptr addr;
1375
+ cuuint32_t value;
1376
+ unsigned int flags;
1377
+ } cuStreamWaitValue32_v2_ptsz_params;
1378
+
1379
+ typedef struct cuStreamWaitValue64_v2_ptsz_params_st {
1380
+ CUstream stream;
1381
+ CUdeviceptr addr;
1382
+ cuuint64_t value;
1383
+ unsigned int flags;
1384
+ } cuStreamWaitValue64_v2_ptsz_params;
1385
+
1386
+ typedef struct cuStreamWriteValue32_v2_ptsz_params_st {
1387
+ CUstream stream;
1388
+ CUdeviceptr addr;
1389
+ cuuint32_t value;
1390
+ unsigned int flags;
1391
+ } cuStreamWriteValue32_v2_ptsz_params;
1392
+
1393
+ typedef struct cuStreamWriteValue64_v2_ptsz_params_st {
1394
+ CUstream stream;
1395
+ CUdeviceptr addr;
1396
+ cuuint64_t value;
1397
+ unsigned int flags;
1398
+ } cuStreamWriteValue64_v2_ptsz_params;
1399
+
1400
+ typedef struct cuStreamBatchMemOp_v2_ptsz_params_st {
1401
+ CUstream stream;
1402
+ unsigned int count;
1403
+ CUstreamBatchMemOpParams *paramArray;
1404
+ unsigned int flags;
1405
+ } cuStreamBatchMemOp_v2_ptsz_params;
1406
+
1407
+ typedef struct cuFuncGetAttribute_params_st {
1408
+ int *pi;
1409
+ CUfunction_attribute attrib;
1410
+ CUfunction hfunc;
1411
+ } cuFuncGetAttribute_params;
1412
+
1413
+ typedef struct cuFuncSetAttribute_params_st {
1414
+ CUfunction hfunc;
1415
+ CUfunction_attribute attrib;
1416
+ int value;
1417
+ } cuFuncSetAttribute_params;
1418
+
1419
+ typedef struct cuFuncSetCacheConfig_params_st {
1420
+ CUfunction hfunc;
1421
+ CUfunc_cache config;
1422
+ } cuFuncSetCacheConfig_params;
1423
+
1424
+ typedef struct cuFuncGetModule_params_st {
1425
+ CUmodule *hmod;
1426
+ CUfunction hfunc;
1427
+ } cuFuncGetModule_params;
1428
+
1429
+ typedef struct cuFuncGetName_params_st {
1430
+ const char **name;
1431
+ CUfunction hfunc;
1432
+ } cuFuncGetName_params;
1433
+
1434
+ typedef struct cuFuncGetParamInfo_params_st {
1435
+ CUfunction func;
1436
+ size_t paramIndex;
1437
+ size_t *paramOffset;
1438
+ size_t *paramSize;
1439
+ } cuFuncGetParamInfo_params;
1440
+
1441
+ typedef struct cuFuncIsLoaded_params_st {
1442
+ CUfunctionLoadingState *state;
1443
+ CUfunction function;
1444
+ } cuFuncIsLoaded_params;
1445
+
1446
+ typedef struct cuFuncLoad_params_st {
1447
+ CUfunction function;
1448
+ } cuFuncLoad_params;
1449
+
1450
+ typedef struct cuLaunchKernel_ptsz_params_st {
1451
+ CUfunction f;
1452
+ unsigned int gridDimX;
1453
+ unsigned int gridDimY;
1454
+ unsigned int gridDimZ;
1455
+ unsigned int blockDimX;
1456
+ unsigned int blockDimY;
1457
+ unsigned int blockDimZ;
1458
+ unsigned int sharedMemBytes;
1459
+ CUstream hStream;
1460
+ void **kernelParams;
1461
+ void **extra;
1462
+ } cuLaunchKernel_ptsz_params;
1463
+
1464
+ typedef struct cuLaunchKernelEx_ptsz_params_st {
1465
+ const CUlaunchConfig *config;
1466
+ CUfunction f;
1467
+ void **kernelParams;
1468
+ void **extra;
1469
+ } cuLaunchKernelEx_ptsz_params;
1470
+
1471
+ typedef struct cuLaunchCooperativeKernel_ptsz_params_st {
1472
+ CUfunction f;
1473
+ unsigned int gridDimX;
1474
+ unsigned int gridDimY;
1475
+ unsigned int gridDimZ;
1476
+ unsigned int blockDimX;
1477
+ unsigned int blockDimY;
1478
+ unsigned int blockDimZ;
1479
+ unsigned int sharedMemBytes;
1480
+ CUstream hStream;
1481
+ void **kernelParams;
1482
+ } cuLaunchCooperativeKernel_ptsz_params;
1483
+
1484
+ typedef struct cuLaunchCooperativeKernelMultiDevice_params_st {
1485
+ CUDA_LAUNCH_PARAMS *launchParamsList;
1486
+ unsigned int numDevices;
1487
+ unsigned int flags;
1488
+ } cuLaunchCooperativeKernelMultiDevice_params;
1489
+
1490
+ typedef struct cuLaunchHostFunc_ptsz_params_st {
1491
+ CUstream hStream;
1492
+ CUhostFn fn;
1493
+ void *userData;
1494
+ } cuLaunchHostFunc_ptsz_params;
1495
+
1496
+ typedef struct cuFuncSetBlockShape_params_st {
1497
+ CUfunction hfunc;
1498
+ int x;
1499
+ int y;
1500
+ int z;
1501
+ } cuFuncSetBlockShape_params;
1502
+
1503
+ typedef struct cuFuncSetSharedSize_params_st {
1504
+ CUfunction hfunc;
1505
+ unsigned int bytes;
1506
+ } cuFuncSetSharedSize_params;
1507
+
1508
+ typedef struct cuParamSetSize_params_st {
1509
+ CUfunction hfunc;
1510
+ unsigned int numbytes;
1511
+ } cuParamSetSize_params;
1512
+
1513
+ typedef struct cuParamSeti_params_st {
1514
+ CUfunction hfunc;
1515
+ int offset;
1516
+ unsigned int value;
1517
+ } cuParamSeti_params;
1518
+
1519
+ typedef struct cuParamSetf_params_st {
1520
+ CUfunction hfunc;
1521
+ int offset;
1522
+ float value;
1523
+ } cuParamSetf_params;
1524
+
1525
+ typedef struct cuParamSetv_params_st {
1526
+ CUfunction hfunc;
1527
+ int offset;
1528
+ void *ptr;
1529
+ unsigned int numbytes;
1530
+ } cuParamSetv_params;
1531
+
1532
+ typedef struct cuLaunch_params_st {
1533
+ CUfunction f;
1534
+ } cuLaunch_params;
1535
+
1536
+ typedef struct cuLaunchGrid_params_st {
1537
+ CUfunction f;
1538
+ int grid_width;
1539
+ int grid_height;
1540
+ } cuLaunchGrid_params;
1541
+
1542
+ typedef struct cuLaunchGridAsync_params_st {
1543
+ CUfunction f;
1544
+ int grid_width;
1545
+ int grid_height;
1546
+ CUstream hStream;
1547
+ } cuLaunchGridAsync_params;
1548
+
1549
+ typedef struct cuParamSetTexRef_params_st {
1550
+ CUfunction hfunc;
1551
+ int texunit;
1552
+ CUtexref hTexRef;
1553
+ } cuParamSetTexRef_params;
1554
+
1555
+ typedef struct cuFuncSetSharedMemConfig_params_st {
1556
+ CUfunction hfunc;
1557
+ CUsharedconfig config;
1558
+ } cuFuncSetSharedMemConfig_params;
1559
+
1560
+ typedef struct cuGraphCreate_params_st {
1561
+ CUgraph *phGraph;
1562
+ unsigned int flags;
1563
+ } cuGraphCreate_params;
1564
+
1565
+ typedef struct cuGraphAddKernelNode_v2_params_st {
1566
+ CUgraphNode *phGraphNode;
1567
+ CUgraph hGraph;
1568
+ const CUgraphNode *dependencies;
1569
+ size_t numDependencies;
1570
+ const CUDA_KERNEL_NODE_PARAMS *nodeParams;
1571
+ } cuGraphAddKernelNode_v2_params;
1572
+
1573
+ typedef struct cuGraphKernelNodeGetParams_v2_params_st {
1574
+ CUgraphNode hNode;
1575
+ CUDA_KERNEL_NODE_PARAMS *nodeParams;
1576
+ } cuGraphKernelNodeGetParams_v2_params;
1577
+
1578
+ typedef struct cuGraphKernelNodeSetParams_v2_params_st {
1579
+ CUgraphNode hNode;
1580
+ const CUDA_KERNEL_NODE_PARAMS *nodeParams;
1581
+ } cuGraphKernelNodeSetParams_v2_params;
1582
+
1583
+ typedef struct cuGraphAddMemcpyNode_params_st {
1584
+ CUgraphNode *phGraphNode;
1585
+ CUgraph hGraph;
1586
+ const CUgraphNode *dependencies;
1587
+ size_t numDependencies;
1588
+ const CUDA_MEMCPY3D *copyParams;
1589
+ CUcontext ctx;
1590
+ } cuGraphAddMemcpyNode_params;
1591
+
1592
+ typedef struct cuGraphMemcpyNodeGetParams_params_st {
1593
+ CUgraphNode hNode;
1594
+ CUDA_MEMCPY3D *nodeParams;
1595
+ } cuGraphMemcpyNodeGetParams_params;
1596
+
1597
+ typedef struct cuGraphMemcpyNodeSetParams_params_st {
1598
+ CUgraphNode hNode;
1599
+ const CUDA_MEMCPY3D *nodeParams;
1600
+ } cuGraphMemcpyNodeSetParams_params;
1601
+
1602
+ typedef struct cuGraphAddMemsetNode_params_st {
1603
+ CUgraphNode *phGraphNode;
1604
+ CUgraph hGraph;
1605
+ const CUgraphNode *dependencies;
1606
+ size_t numDependencies;
1607
+ const CUDA_MEMSET_NODE_PARAMS *memsetParams;
1608
+ CUcontext ctx;
1609
+ } cuGraphAddMemsetNode_params;
1610
+
1611
+ typedef struct cuGraphMemsetNodeGetParams_params_st {
1612
+ CUgraphNode hNode;
1613
+ CUDA_MEMSET_NODE_PARAMS *nodeParams;
1614
+ } cuGraphMemsetNodeGetParams_params;
1615
+
1616
+ typedef struct cuGraphMemsetNodeSetParams_params_st {
1617
+ CUgraphNode hNode;
1618
+ const CUDA_MEMSET_NODE_PARAMS *nodeParams;
1619
+ } cuGraphMemsetNodeSetParams_params;
1620
+
1621
+ typedef struct cuGraphAddHostNode_params_st {
1622
+ CUgraphNode *phGraphNode;
1623
+ CUgraph hGraph;
1624
+ const CUgraphNode *dependencies;
1625
+ size_t numDependencies;
1626
+ const CUDA_HOST_NODE_PARAMS *nodeParams;
1627
+ } cuGraphAddHostNode_params;
1628
+
1629
+ typedef struct cuGraphHostNodeGetParams_params_st {
1630
+ CUgraphNode hNode;
1631
+ CUDA_HOST_NODE_PARAMS *nodeParams;
1632
+ } cuGraphHostNodeGetParams_params;
1633
+
1634
+ typedef struct cuGraphHostNodeSetParams_params_st {
1635
+ CUgraphNode hNode;
1636
+ const CUDA_HOST_NODE_PARAMS *nodeParams;
1637
+ } cuGraphHostNodeSetParams_params;
1638
+
1639
+ typedef struct cuGraphAddChildGraphNode_params_st {
1640
+ CUgraphNode *phGraphNode;
1641
+ CUgraph hGraph;
1642
+ const CUgraphNode *dependencies;
1643
+ size_t numDependencies;
1644
+ CUgraph childGraph;
1645
+ } cuGraphAddChildGraphNode_params;
1646
+
1647
+ typedef struct cuGraphChildGraphNodeGetGraph_params_st {
1648
+ CUgraphNode hNode;
1649
+ CUgraph *phGraph;
1650
+ } cuGraphChildGraphNodeGetGraph_params;
1651
+
1652
+ typedef struct cuGraphAddEmptyNode_params_st {
1653
+ CUgraphNode *phGraphNode;
1654
+ CUgraph hGraph;
1655
+ const CUgraphNode *dependencies;
1656
+ size_t numDependencies;
1657
+ } cuGraphAddEmptyNode_params;
1658
+
1659
+ typedef struct cuGraphAddEventRecordNode_params_st {
1660
+ CUgraphNode *phGraphNode;
1661
+ CUgraph hGraph;
1662
+ const CUgraphNode *dependencies;
1663
+ size_t numDependencies;
1664
+ CUevent event;
1665
+ } cuGraphAddEventRecordNode_params;
1666
+
1667
+ typedef struct cuGraphEventRecordNodeGetEvent_params_st {
1668
+ CUgraphNode hNode;
1669
+ CUevent *event_out;
1670
+ } cuGraphEventRecordNodeGetEvent_params;
1671
+
1672
+ typedef struct cuGraphEventRecordNodeSetEvent_params_st {
1673
+ CUgraphNode hNode;
1674
+ CUevent event;
1675
+ } cuGraphEventRecordNodeSetEvent_params;
1676
+
1677
+ typedef struct cuGraphAddEventWaitNode_params_st {
1678
+ CUgraphNode *phGraphNode;
1679
+ CUgraph hGraph;
1680
+ const CUgraphNode *dependencies;
1681
+ size_t numDependencies;
1682
+ CUevent event;
1683
+ } cuGraphAddEventWaitNode_params;
1684
+
1685
+ typedef struct cuGraphEventWaitNodeGetEvent_params_st {
1686
+ CUgraphNode hNode;
1687
+ CUevent *event_out;
1688
+ } cuGraphEventWaitNodeGetEvent_params;
1689
+
1690
+ typedef struct cuGraphEventWaitNodeSetEvent_params_st {
1691
+ CUgraphNode hNode;
1692
+ CUevent event;
1693
+ } cuGraphEventWaitNodeSetEvent_params;
1694
+
1695
+ typedef struct cuGraphAddExternalSemaphoresSignalNode_params_st {
1696
+ CUgraphNode *phGraphNode;
1697
+ CUgraph hGraph;
1698
+ const CUgraphNode *dependencies;
1699
+ size_t numDependencies;
1700
+ const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS *nodeParams;
1701
+ } cuGraphAddExternalSemaphoresSignalNode_params;
1702
+
1703
+ typedef struct cuGraphExternalSemaphoresSignalNodeGetParams_params_st {
1704
+ CUgraphNode hNode;
1705
+ CUDA_EXT_SEM_SIGNAL_NODE_PARAMS *params_out;
1706
+ } cuGraphExternalSemaphoresSignalNodeGetParams_params;
1707
+
1708
+ typedef struct cuGraphExternalSemaphoresSignalNodeSetParams_params_st {
1709
+ CUgraphNode hNode;
1710
+ const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS *nodeParams;
1711
+ } cuGraphExternalSemaphoresSignalNodeSetParams_params;
1712
+
1713
+ typedef struct cuGraphAddExternalSemaphoresWaitNode_params_st {
1714
+ CUgraphNode *phGraphNode;
1715
+ CUgraph hGraph;
1716
+ const CUgraphNode *dependencies;
1717
+ size_t numDependencies;
1718
+ const CUDA_EXT_SEM_WAIT_NODE_PARAMS *nodeParams;
1719
+ } cuGraphAddExternalSemaphoresWaitNode_params;
1720
+
1721
+ typedef struct cuGraphExternalSemaphoresWaitNodeGetParams_params_st {
1722
+ CUgraphNode hNode;
1723
+ CUDA_EXT_SEM_WAIT_NODE_PARAMS *params_out;
1724
+ } cuGraphExternalSemaphoresWaitNodeGetParams_params;
1725
+
1726
+ typedef struct cuGraphExternalSemaphoresWaitNodeSetParams_params_st {
1727
+ CUgraphNode hNode;
1728
+ const CUDA_EXT_SEM_WAIT_NODE_PARAMS *nodeParams;
1729
+ } cuGraphExternalSemaphoresWaitNodeSetParams_params;
1730
+
1731
+ typedef struct cuGraphAddBatchMemOpNode_params_st {
1732
+ CUgraphNode *phGraphNode;
1733
+ CUgraph hGraph;
1734
+ const CUgraphNode *dependencies;
1735
+ size_t numDependencies;
1736
+ const CUDA_BATCH_MEM_OP_NODE_PARAMS *nodeParams;
1737
+ } cuGraphAddBatchMemOpNode_params;
1738
+
1739
+ typedef struct cuGraphBatchMemOpNodeGetParams_params_st {
1740
+ CUgraphNode hNode;
1741
+ CUDA_BATCH_MEM_OP_NODE_PARAMS *nodeParams_out;
1742
+ } cuGraphBatchMemOpNodeGetParams_params;
1743
+
1744
+ typedef struct cuGraphBatchMemOpNodeSetParams_params_st {
1745
+ CUgraphNode hNode;
1746
+ const CUDA_BATCH_MEM_OP_NODE_PARAMS *nodeParams;
1747
+ } cuGraphBatchMemOpNodeSetParams_params;
1748
+
1749
+ typedef struct cuGraphExecBatchMemOpNodeSetParams_params_st {
1750
+ CUgraphExec hGraphExec;
1751
+ CUgraphNode hNode;
1752
+ const CUDA_BATCH_MEM_OP_NODE_PARAMS *nodeParams;
1753
+ } cuGraphExecBatchMemOpNodeSetParams_params;
1754
+
1755
+ typedef struct cuGraphAddMemAllocNode_params_st {
1756
+ CUgraphNode *phGraphNode;
1757
+ CUgraph hGraph;
1758
+ const CUgraphNode *dependencies;
1759
+ size_t numDependencies;
1760
+ CUDA_MEM_ALLOC_NODE_PARAMS *nodeParams;
1761
+ } cuGraphAddMemAllocNode_params;
1762
+
1763
+ typedef struct cuGraphMemAllocNodeGetParams_params_st {
1764
+ CUgraphNode hNode;
1765
+ CUDA_MEM_ALLOC_NODE_PARAMS *params_out;
1766
+ } cuGraphMemAllocNodeGetParams_params;
1767
+
1768
+ typedef struct cuGraphAddMemFreeNode_params_st {
1769
+ CUgraphNode *phGraphNode;
1770
+ CUgraph hGraph;
1771
+ const CUgraphNode *dependencies;
1772
+ size_t numDependencies;
1773
+ CUdeviceptr dptr;
1774
+ } cuGraphAddMemFreeNode_params;
1775
+
1776
+ typedef struct cuGraphMemFreeNodeGetParams_params_st {
1777
+ CUgraphNode hNode;
1778
+ CUdeviceptr *dptr_out;
1779
+ } cuGraphMemFreeNodeGetParams_params;
1780
+
1781
+ typedef struct cuDeviceGraphMemTrim_params_st {
1782
+ CUdevice device;
1783
+ } cuDeviceGraphMemTrim_params;
1784
+
1785
+ typedef struct cuDeviceGetGraphMemAttribute_params_st {
1786
+ CUdevice device;
1787
+ CUgraphMem_attribute attr;
1788
+ void *value;
1789
+ } cuDeviceGetGraphMemAttribute_params;
1790
+
1791
+ typedef struct cuDeviceSetGraphMemAttribute_params_st {
1792
+ CUdevice device;
1793
+ CUgraphMem_attribute attr;
1794
+ void *value;
1795
+ } cuDeviceSetGraphMemAttribute_params;
1796
+
1797
+ typedef struct cuGraphClone_params_st {
1798
+ CUgraph *phGraphClone;
1799
+ CUgraph originalGraph;
1800
+ } cuGraphClone_params;
1801
+
1802
+ typedef struct cuGraphNodeFindInClone_params_st {
1803
+ CUgraphNode *phNode;
1804
+ CUgraphNode hOriginalNode;
1805
+ CUgraph hClonedGraph;
1806
+ } cuGraphNodeFindInClone_params;
1807
+
1808
+ typedef struct cuGraphNodeGetType_params_st {
1809
+ CUgraphNode hNode;
1810
+ CUgraphNodeType *type;
1811
+ } cuGraphNodeGetType_params;
1812
+
1813
+ typedef struct cuGraphGetNodes_params_st {
1814
+ CUgraph hGraph;
1815
+ CUgraphNode *nodes;
1816
+ size_t *numNodes;
1817
+ } cuGraphGetNodes_params;
1818
+
1819
+ typedef struct cuGraphGetRootNodes_params_st {
1820
+ CUgraph hGraph;
1821
+ CUgraphNode *rootNodes;
1822
+ size_t *numRootNodes;
1823
+ } cuGraphGetRootNodes_params;
1824
+
1825
+ typedef struct cuGraphGetEdges_params_st {
1826
+ CUgraph hGraph;
1827
+ CUgraphNode *from;
1828
+ CUgraphNode *to;
1829
+ size_t *numEdges;
1830
+ } cuGraphGetEdges_params;
1831
+
1832
+ typedef struct cuGraphGetEdges_v2_params_st {
1833
+ CUgraph hGraph;
1834
+ CUgraphNode *from;
1835
+ CUgraphNode *to;
1836
+ CUgraphEdgeData *edgeData;
1837
+ size_t *numEdges;
1838
+ } cuGraphGetEdges_v2_params;
1839
+
1840
+ typedef struct cuGraphNodeGetDependencies_params_st {
1841
+ CUgraphNode hNode;
1842
+ CUgraphNode *dependencies;
1843
+ size_t *numDependencies;
1844
+ } cuGraphNodeGetDependencies_params;
1845
+
1846
+ typedef struct cuGraphNodeGetDependencies_v2_params_st {
1847
+ CUgraphNode hNode;
1848
+ CUgraphNode *dependencies;
1849
+ CUgraphEdgeData *edgeData;
1850
+ size_t *numDependencies;
1851
+ } cuGraphNodeGetDependencies_v2_params;
1852
+
1853
+ typedef struct cuGraphNodeGetDependentNodes_params_st {
1854
+ CUgraphNode hNode;
1855
+ CUgraphNode *dependentNodes;
1856
+ size_t *numDependentNodes;
1857
+ } cuGraphNodeGetDependentNodes_params;
1858
+
1859
+ typedef struct cuGraphNodeGetDependentNodes_v2_params_st {
1860
+ CUgraphNode hNode;
1861
+ CUgraphNode *dependentNodes;
1862
+ CUgraphEdgeData *edgeData;
1863
+ size_t *numDependentNodes;
1864
+ } cuGraphNodeGetDependentNodes_v2_params;
1865
+
1866
+ typedef struct cuGraphAddDependencies_params_st {
1867
+ CUgraph hGraph;
1868
+ const CUgraphNode *from;
1869
+ const CUgraphNode *to;
1870
+ size_t numDependencies;
1871
+ } cuGraphAddDependencies_params;
1872
+
1873
+ typedef struct cuGraphAddDependencies_v2_params_st {
1874
+ CUgraph hGraph;
1875
+ const CUgraphNode *from;
1876
+ const CUgraphNode *to;
1877
+ const CUgraphEdgeData *edgeData;
1878
+ size_t numDependencies;
1879
+ } cuGraphAddDependencies_v2_params;
1880
+
1881
+ typedef struct cuGraphRemoveDependencies_params_st {
1882
+ CUgraph hGraph;
1883
+ const CUgraphNode *from;
1884
+ const CUgraphNode *to;
1885
+ size_t numDependencies;
1886
+ } cuGraphRemoveDependencies_params;
1887
+
1888
+ typedef struct cuGraphRemoveDependencies_v2_params_st {
1889
+ CUgraph hGraph;
1890
+ const CUgraphNode *from;
1891
+ const CUgraphNode *to;
1892
+ const CUgraphEdgeData *edgeData;
1893
+ size_t numDependencies;
1894
+ } cuGraphRemoveDependencies_v2_params;
1895
+
1896
+ typedef struct cuGraphDestroyNode_params_st {
1897
+ CUgraphNode hNode;
1898
+ } cuGraphDestroyNode_params;
1899
+
1900
+ typedef struct cuGraphInstantiateWithFlags_params_st {
1901
+ CUgraphExec *phGraphExec;
1902
+ CUgraph hGraph;
1903
+ unsigned long long flags;
1904
+ } cuGraphInstantiateWithFlags_params;
1905
+
1906
+ typedef struct cuGraphInstantiateWithParams_ptsz_params_st {
1907
+ CUgraphExec *phGraphExec;
1908
+ CUgraph hGraph;
1909
+ CUDA_GRAPH_INSTANTIATE_PARAMS *instantiateParams;
1910
+ } cuGraphInstantiateWithParams_ptsz_params;
1911
+
1912
+ typedef struct cuGraphExecGetFlags_params_st {
1913
+ CUgraphExec hGraphExec;
1914
+ cuuint64_t *flags;
1915
+ } cuGraphExecGetFlags_params;
1916
+
1917
+ typedef struct cuGraphExecKernelNodeSetParams_v2_params_st {
1918
+ CUgraphExec hGraphExec;
1919
+ CUgraphNode hNode;
1920
+ const CUDA_KERNEL_NODE_PARAMS *nodeParams;
1921
+ } cuGraphExecKernelNodeSetParams_v2_params;
1922
+
1923
+ typedef struct cuGraphExecMemcpyNodeSetParams_params_st {
1924
+ CUgraphExec hGraphExec;
1925
+ CUgraphNode hNode;
1926
+ const CUDA_MEMCPY3D *copyParams;
1927
+ CUcontext ctx;
1928
+ } cuGraphExecMemcpyNodeSetParams_params;
1929
+
1930
+ typedef struct cuGraphExecMemsetNodeSetParams_params_st {
1931
+ CUgraphExec hGraphExec;
1932
+ CUgraphNode hNode;
1933
+ const CUDA_MEMSET_NODE_PARAMS *memsetParams;
1934
+ CUcontext ctx;
1935
+ } cuGraphExecMemsetNodeSetParams_params;
1936
+
1937
+ typedef struct cuGraphExecHostNodeSetParams_params_st {
1938
+ CUgraphExec hGraphExec;
1939
+ CUgraphNode hNode;
1940
+ const CUDA_HOST_NODE_PARAMS *nodeParams;
1941
+ } cuGraphExecHostNodeSetParams_params;
1942
+
1943
+ typedef struct cuGraphExecChildGraphNodeSetParams_params_st {
1944
+ CUgraphExec hGraphExec;
1945
+ CUgraphNode hNode;
1946
+ CUgraph childGraph;
1947
+ } cuGraphExecChildGraphNodeSetParams_params;
1948
+
1949
+ typedef struct cuGraphExecEventRecordNodeSetEvent_params_st {
1950
+ CUgraphExec hGraphExec;
1951
+ CUgraphNode hNode;
1952
+ CUevent event;
1953
+ } cuGraphExecEventRecordNodeSetEvent_params;
1954
+
1955
+ typedef struct cuGraphExecEventWaitNodeSetEvent_params_st {
1956
+ CUgraphExec hGraphExec;
1957
+ CUgraphNode hNode;
1958
+ CUevent event;
1959
+ } cuGraphExecEventWaitNodeSetEvent_params;
1960
+
1961
+ typedef struct cuGraphExecExternalSemaphoresSignalNodeSetParams_params_st {
1962
+ CUgraphExec hGraphExec;
1963
+ CUgraphNode hNode;
1964
+ const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS *nodeParams;
1965
+ } cuGraphExecExternalSemaphoresSignalNodeSetParams_params;
1966
+
1967
+ typedef struct cuGraphExecExternalSemaphoresWaitNodeSetParams_params_st {
1968
+ CUgraphExec hGraphExec;
1969
+ CUgraphNode hNode;
1970
+ const CUDA_EXT_SEM_WAIT_NODE_PARAMS *nodeParams;
1971
+ } cuGraphExecExternalSemaphoresWaitNodeSetParams_params;
1972
+
1973
+ typedef struct cuGraphNodeSetEnabled_params_st {
1974
+ CUgraphExec hGraphExec;
1975
+ CUgraphNode hNode;
1976
+ unsigned int isEnabled;
1977
+ } cuGraphNodeSetEnabled_params;
1978
+
1979
+ typedef struct cuGraphNodeGetEnabled_params_st {
1980
+ CUgraphExec hGraphExec;
1981
+ CUgraphNode hNode;
1982
+ unsigned int *isEnabled;
1983
+ } cuGraphNodeGetEnabled_params;
1984
+
1985
+ typedef struct cuGraphUpload_ptsz_params_st {
1986
+ CUgraphExec hGraphExec;
1987
+ CUstream hStream;
1988
+ } cuGraphUpload_ptsz_params;
1989
+
1990
+ typedef struct cuGraphLaunch_ptsz_params_st {
1991
+ CUgraphExec hGraphExec;
1992
+ CUstream hStream;
1993
+ } cuGraphLaunch_ptsz_params;
1994
+
1995
+ typedef struct cuGraphExecDestroy_params_st {
1996
+ CUgraphExec hGraphExec;
1997
+ } cuGraphExecDestroy_params;
1998
+
1999
+ typedef struct cuGraphDestroy_params_st {
2000
+ CUgraph hGraph;
2001
+ } cuGraphDestroy_params;
2002
+
2003
+ typedef struct cuGraphExecUpdate_v2_params_st {
2004
+ CUgraphExec hGraphExec;
2005
+ CUgraph hGraph;
2006
+ CUgraphExecUpdateResultInfo *resultInfo;
2007
+ } cuGraphExecUpdate_v2_params;
2008
+
2009
+ typedef struct cuGraphKernelNodeCopyAttributes_params_st {
2010
+ CUgraphNode dst;
2011
+ CUgraphNode src;
2012
+ } cuGraphKernelNodeCopyAttributes_params;
2013
+
2014
+ typedef struct cuGraphKernelNodeGetAttribute_params_st {
2015
+ CUgraphNode hNode;
2016
+ CUkernelNodeAttrID attr;
2017
+ CUkernelNodeAttrValue *value_out;
2018
+ } cuGraphKernelNodeGetAttribute_params;
2019
+
2020
+ typedef struct cuGraphKernelNodeSetAttribute_params_st {
2021
+ CUgraphNode hNode;
2022
+ CUkernelNodeAttrID attr;
2023
+ const CUkernelNodeAttrValue *value;
2024
+ } cuGraphKernelNodeSetAttribute_params;
2025
+
2026
+ typedef struct cuGraphDebugDotPrint_params_st {
2027
+ CUgraph hGraph;
2028
+ const char *path;
2029
+ unsigned int flags;
2030
+ } cuGraphDebugDotPrint_params;
2031
+
2032
+ typedef struct cuUserObjectCreate_params_st {
2033
+ CUuserObject *object_out;
2034
+ void *ptr;
2035
+ CUhostFn destroy;
2036
+ unsigned int initialRefcount;
2037
+ unsigned int flags;
2038
+ } cuUserObjectCreate_params;
2039
+
2040
+ typedef struct cuUserObjectRetain_params_st {
2041
+ CUuserObject object;
2042
+ unsigned int count;
2043
+ } cuUserObjectRetain_params;
2044
+
2045
+ typedef struct cuUserObjectRelease_params_st {
2046
+ CUuserObject object;
2047
+ unsigned int count;
2048
+ } cuUserObjectRelease_params;
2049
+
2050
+ typedef struct cuGraphRetainUserObject_params_st {
2051
+ CUgraph graph;
2052
+ CUuserObject object;
2053
+ unsigned int count;
2054
+ unsigned int flags;
2055
+ } cuGraphRetainUserObject_params;
2056
+
2057
+ typedef struct cuGraphReleaseUserObject_params_st {
2058
+ CUgraph graph;
2059
+ CUuserObject object;
2060
+ unsigned int count;
2061
+ } cuGraphReleaseUserObject_params;
2062
+
2063
+ typedef struct cuGraphAddNode_params_st {
2064
+ CUgraphNode *phGraphNode;
2065
+ CUgraph hGraph;
2066
+ const CUgraphNode *dependencies;
2067
+ size_t numDependencies;
2068
+ CUgraphNodeParams *nodeParams;
2069
+ } cuGraphAddNode_params;
2070
+
2071
+ typedef struct cuGraphAddNode_v2_params_st {
2072
+ CUgraphNode *phGraphNode;
2073
+ CUgraph hGraph;
2074
+ const CUgraphNode *dependencies;
2075
+ const CUgraphEdgeData *dependencyData;
2076
+ size_t numDependencies;
2077
+ CUgraphNodeParams *nodeParams;
2078
+ } cuGraphAddNode_v2_params;
2079
+
2080
+ typedef struct cuGraphNodeSetParams_params_st {
2081
+ CUgraphNode hNode;
2082
+ CUgraphNodeParams *nodeParams;
2083
+ } cuGraphNodeSetParams_params;
2084
+
2085
+ typedef struct cuGraphExecNodeSetParams_params_st {
2086
+ CUgraphExec hGraphExec;
2087
+ CUgraphNode hNode;
2088
+ CUgraphNodeParams *nodeParams;
2089
+ } cuGraphExecNodeSetParams_params;
2090
+
2091
+ typedef struct cuGraphConditionalHandleCreate_params_st {
2092
+ CUgraphConditionalHandle *pHandle_out;
2093
+ CUgraph hGraph;
2094
+ CUcontext ctx;
2095
+ unsigned int defaultLaunchValue;
2096
+ unsigned int flags;
2097
+ } cuGraphConditionalHandleCreate_params;
2098
+
2099
+ typedef struct cuOccupancyMaxActiveBlocksPerMultiprocessor_params_st {
2100
+ int *numBlocks;
2101
+ CUfunction func;
2102
+ int blockSize;
2103
+ size_t dynamicSMemSize;
2104
+ } cuOccupancyMaxActiveBlocksPerMultiprocessor_params;
2105
+
2106
+ typedef struct cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_params_st {
2107
+ int *numBlocks;
2108
+ CUfunction func;
2109
+ int blockSize;
2110
+ size_t dynamicSMemSize;
2111
+ unsigned int flags;
2112
+ } cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_params;
2113
+
2114
+ typedef struct cuOccupancyMaxPotentialBlockSize_params_st {
2115
+ int *minGridSize;
2116
+ int *blockSize;
2117
+ CUfunction func;
2118
+ CUoccupancyB2DSize blockSizeToDynamicSMemSize;
2119
+ size_t dynamicSMemSize;
2120
+ int blockSizeLimit;
2121
+ } cuOccupancyMaxPotentialBlockSize_params;
2122
+
2123
+ typedef struct cuOccupancyMaxPotentialBlockSizeWithFlags_params_st {
2124
+ int *minGridSize;
2125
+ int *blockSize;
2126
+ CUfunction func;
2127
+ CUoccupancyB2DSize blockSizeToDynamicSMemSize;
2128
+ size_t dynamicSMemSize;
2129
+ int blockSizeLimit;
2130
+ unsigned int flags;
2131
+ } cuOccupancyMaxPotentialBlockSizeWithFlags_params;
2132
+
2133
+ typedef struct cuOccupancyAvailableDynamicSMemPerBlock_params_st {
2134
+ size_t *dynamicSmemSize;
2135
+ CUfunction func;
2136
+ int numBlocks;
2137
+ int blockSize;
2138
+ } cuOccupancyAvailableDynamicSMemPerBlock_params;
2139
+
2140
+ typedef struct cuOccupancyMaxPotentialClusterSize_params_st {
2141
+ int *clusterSize;
2142
+ CUfunction func;
2143
+ const CUlaunchConfig *config;
2144
+ } cuOccupancyMaxPotentialClusterSize_params;
2145
+
2146
+ typedef struct cuOccupancyMaxActiveClusters_params_st {
2147
+ int *numClusters;
2148
+ CUfunction func;
2149
+ const CUlaunchConfig *config;
2150
+ } cuOccupancyMaxActiveClusters_params;
2151
+
2152
+ typedef struct cuTexRefSetArray_params_st {
2153
+ CUtexref hTexRef;
2154
+ CUarray hArray;
2155
+ unsigned int Flags;
2156
+ } cuTexRefSetArray_params;
2157
+
2158
+ typedef struct cuTexRefSetMipmappedArray_params_st {
2159
+ CUtexref hTexRef;
2160
+ CUmipmappedArray hMipmappedArray;
2161
+ unsigned int Flags;
2162
+ } cuTexRefSetMipmappedArray_params;
2163
+
2164
+ typedef struct cuTexRefSetAddress_v2_params_st {
2165
+ size_t *ByteOffset;
2166
+ CUtexref hTexRef;
2167
+ CUdeviceptr dptr;
2168
+ size_t bytes;
2169
+ } cuTexRefSetAddress_v2_params;
2170
+
2171
+ typedef struct cuTexRefSetAddress2D_v3_params_st {
2172
+ CUtexref hTexRef;
2173
+ const CUDA_ARRAY_DESCRIPTOR *desc;
2174
+ CUdeviceptr dptr;
2175
+ size_t Pitch;
2176
+ } cuTexRefSetAddress2D_v3_params;
2177
+
2178
+ typedef struct cuTexRefSetFormat_params_st {
2179
+ CUtexref hTexRef;
2180
+ CUarray_format fmt;
2181
+ int NumPackedComponents;
2182
+ } cuTexRefSetFormat_params;
2183
+
2184
+ typedef struct cuTexRefSetAddressMode_params_st {
2185
+ CUtexref hTexRef;
2186
+ int dim;
2187
+ CUaddress_mode am;
2188
+ } cuTexRefSetAddressMode_params;
2189
+
2190
+ typedef struct cuTexRefSetFilterMode_params_st {
2191
+ CUtexref hTexRef;
2192
+ CUfilter_mode fm;
2193
+ } cuTexRefSetFilterMode_params;
2194
+
2195
+ typedef struct cuTexRefSetMipmapFilterMode_params_st {
2196
+ CUtexref hTexRef;
2197
+ CUfilter_mode fm;
2198
+ } cuTexRefSetMipmapFilterMode_params;
2199
+
2200
+ typedef struct cuTexRefSetMipmapLevelBias_params_st {
2201
+ CUtexref hTexRef;
2202
+ float bias;
2203
+ } cuTexRefSetMipmapLevelBias_params;
2204
+
2205
+ typedef struct cuTexRefSetMipmapLevelClamp_params_st {
2206
+ CUtexref hTexRef;
2207
+ float minMipmapLevelClamp;
2208
+ float maxMipmapLevelClamp;
2209
+ } cuTexRefSetMipmapLevelClamp_params;
2210
+
2211
+ typedef struct cuTexRefSetMaxAnisotropy_params_st {
2212
+ CUtexref hTexRef;
2213
+ unsigned int maxAniso;
2214
+ } cuTexRefSetMaxAnisotropy_params;
2215
+
2216
+ typedef struct cuTexRefSetBorderColor_params_st {
2217
+ CUtexref hTexRef;
2218
+ float *pBorderColor;
2219
+ } cuTexRefSetBorderColor_params;
2220
+
2221
+ typedef struct cuTexRefSetFlags_params_st {
2222
+ CUtexref hTexRef;
2223
+ unsigned int Flags;
2224
+ } cuTexRefSetFlags_params;
2225
+
2226
+ typedef struct cuTexRefGetAddress_v2_params_st {
2227
+ CUdeviceptr *pdptr;
2228
+ CUtexref hTexRef;
2229
+ } cuTexRefGetAddress_v2_params;
2230
+
2231
+ typedef struct cuTexRefGetArray_params_st {
2232
+ CUarray *phArray;
2233
+ CUtexref hTexRef;
2234
+ } cuTexRefGetArray_params;
2235
+
2236
+ typedef struct cuTexRefGetMipmappedArray_params_st {
2237
+ CUmipmappedArray *phMipmappedArray;
2238
+ CUtexref hTexRef;
2239
+ } cuTexRefGetMipmappedArray_params;
2240
+
2241
+ typedef struct cuTexRefGetAddressMode_params_st {
2242
+ CUaddress_mode *pam;
2243
+ CUtexref hTexRef;
2244
+ int dim;
2245
+ } cuTexRefGetAddressMode_params;
2246
+
2247
+ typedef struct cuTexRefGetFilterMode_params_st {
2248
+ CUfilter_mode *pfm;
2249
+ CUtexref hTexRef;
2250
+ } cuTexRefGetFilterMode_params;
2251
+
2252
+ typedef struct cuTexRefGetFormat_params_st {
2253
+ CUarray_format *pFormat;
2254
+ int *pNumChannels;
2255
+ CUtexref hTexRef;
2256
+ } cuTexRefGetFormat_params;
2257
+
2258
+ typedef struct cuTexRefGetMipmapFilterMode_params_st {
2259
+ CUfilter_mode *pfm;
2260
+ CUtexref hTexRef;
2261
+ } cuTexRefGetMipmapFilterMode_params;
2262
+
2263
+ typedef struct cuTexRefGetMipmapLevelBias_params_st {
2264
+ float *pbias;
2265
+ CUtexref hTexRef;
2266
+ } cuTexRefGetMipmapLevelBias_params;
2267
+
2268
+ typedef struct cuTexRefGetMipmapLevelClamp_params_st {
2269
+ float *pminMipmapLevelClamp;
2270
+ float *pmaxMipmapLevelClamp;
2271
+ CUtexref hTexRef;
2272
+ } cuTexRefGetMipmapLevelClamp_params;
2273
+
2274
+ typedef struct cuTexRefGetMaxAnisotropy_params_st {
2275
+ int *pmaxAniso;
2276
+ CUtexref hTexRef;
2277
+ } cuTexRefGetMaxAnisotropy_params;
2278
+
2279
+ typedef struct cuTexRefGetBorderColor_params_st {
2280
+ float *pBorderColor;
2281
+ CUtexref hTexRef;
2282
+ } cuTexRefGetBorderColor_params;
2283
+
2284
+ typedef struct cuTexRefGetFlags_params_st {
2285
+ unsigned int *pFlags;
2286
+ CUtexref hTexRef;
2287
+ } cuTexRefGetFlags_params;
2288
+
2289
+ typedef struct cuTexRefCreate_params_st {
2290
+ CUtexref *pTexRef;
2291
+ } cuTexRefCreate_params;
2292
+
2293
+ typedef struct cuTexRefDestroy_params_st {
2294
+ CUtexref hTexRef;
2295
+ } cuTexRefDestroy_params;
2296
+
2297
+ typedef struct cuSurfRefSetArray_params_st {
2298
+ CUsurfref hSurfRef;
2299
+ CUarray hArray;
2300
+ unsigned int Flags;
2301
+ } cuSurfRefSetArray_params;
2302
+
2303
+ typedef struct cuSurfRefGetArray_params_st {
2304
+ CUarray *phArray;
2305
+ CUsurfref hSurfRef;
2306
+ } cuSurfRefGetArray_params;
2307
+
2308
+ typedef struct cuTexObjectCreate_params_st {
2309
+ CUtexObject *pTexObject;
2310
+ const CUDA_RESOURCE_DESC *pResDesc;
2311
+ const CUDA_TEXTURE_DESC *pTexDesc;
2312
+ const CUDA_RESOURCE_VIEW_DESC *pResViewDesc;
2313
+ } cuTexObjectCreate_params;
2314
+
2315
+ typedef struct cuTexObjectDestroy_params_st {
2316
+ CUtexObject texObject;
2317
+ } cuTexObjectDestroy_params;
2318
+
2319
+ typedef struct cuTexObjectGetResourceDesc_params_st {
2320
+ CUDA_RESOURCE_DESC *pResDesc;
2321
+ CUtexObject texObject;
2322
+ } cuTexObjectGetResourceDesc_params;
2323
+
2324
+ typedef struct cuTexObjectGetTextureDesc_params_st {
2325
+ CUDA_TEXTURE_DESC *pTexDesc;
2326
+ CUtexObject texObject;
2327
+ } cuTexObjectGetTextureDesc_params;
2328
+
2329
+ typedef struct cuTexObjectGetResourceViewDesc_params_st {
2330
+ CUDA_RESOURCE_VIEW_DESC *pResViewDesc;
2331
+ CUtexObject texObject;
2332
+ } cuTexObjectGetResourceViewDesc_params;
2333
+
2334
+ typedef struct cuSurfObjectCreate_params_st {
2335
+ CUsurfObject *pSurfObject;
2336
+ const CUDA_RESOURCE_DESC *pResDesc;
2337
+ } cuSurfObjectCreate_params;
2338
+
2339
+ typedef struct cuSurfObjectDestroy_params_st {
2340
+ CUsurfObject surfObject;
2341
+ } cuSurfObjectDestroy_params;
2342
+
2343
+ typedef struct cuSurfObjectGetResourceDesc_params_st {
2344
+ CUDA_RESOURCE_DESC *pResDesc;
2345
+ CUsurfObject surfObject;
2346
+ } cuSurfObjectGetResourceDesc_params;
2347
+
2348
+ typedef struct cuTensorMapEncodeTiled_params_st {
2349
+ CUtensorMap *tensorMap;
2350
+ CUtensorMapDataType tensorDataType;
2351
+ cuuint32_t tensorRank;
2352
+ void *globalAddress;
2353
+ const cuuint64_t *globalDim;
2354
+ const cuuint64_t *globalStrides;
2355
+ const cuuint32_t *boxDim;
2356
+ const cuuint32_t *elementStrides;
2357
+ CUtensorMapInterleave interleave;
2358
+ CUtensorMapSwizzle swizzle;
2359
+ CUtensorMapL2promotion l2Promotion;
2360
+ CUtensorMapFloatOOBfill oobFill;
2361
+ } cuTensorMapEncodeTiled_params;
2362
+
2363
+ typedef struct cuTensorMapEncodeIm2col_params_st {
2364
+ CUtensorMap *tensorMap;
2365
+ CUtensorMapDataType tensorDataType;
2366
+ cuuint32_t tensorRank;
2367
+ void *globalAddress;
2368
+ const cuuint64_t *globalDim;
2369
+ const cuuint64_t *globalStrides;
2370
+ const int *pixelBoxLowerCorner;
2371
+ const int *pixelBoxUpperCorner;
2372
+ cuuint32_t channelsPerPixel;
2373
+ cuuint32_t pixelsPerColumn;
2374
+ const cuuint32_t *elementStrides;
2375
+ CUtensorMapInterleave interleave;
2376
+ CUtensorMapSwizzle swizzle;
2377
+ CUtensorMapL2promotion l2Promotion;
2378
+ CUtensorMapFloatOOBfill oobFill;
2379
+ } cuTensorMapEncodeIm2col_params;
2380
+
2381
+ typedef struct cuTensorMapReplaceAddress_params_st {
2382
+ CUtensorMap *tensorMap;
2383
+ void *globalAddress;
2384
+ } cuTensorMapReplaceAddress_params;
2385
+
2386
+ typedef struct cuDeviceCanAccessPeer_params_st {
2387
+ int *canAccessPeer;
2388
+ CUdevice dev;
2389
+ CUdevice peerDev;
2390
+ } cuDeviceCanAccessPeer_params;
2391
+
2392
+ typedef struct cuCtxEnablePeerAccess_params_st {
2393
+ CUcontext peerContext;
2394
+ unsigned int Flags;
2395
+ } cuCtxEnablePeerAccess_params;
2396
+
2397
+ typedef struct cuCtxDisablePeerAccess_params_st {
2398
+ CUcontext peerContext;
2399
+ } cuCtxDisablePeerAccess_params;
2400
+
2401
+ typedef struct cuDeviceGetP2PAttribute_params_st {
2402
+ int *value;
2403
+ CUdevice_P2PAttribute attrib;
2404
+ CUdevice srcDevice;
2405
+ CUdevice dstDevice;
2406
+ } cuDeviceGetP2PAttribute_params;
2407
+
2408
+ typedef struct cuGraphicsUnregisterResource_params_st {
2409
+ CUgraphicsResource resource;
2410
+ } cuGraphicsUnregisterResource_params;
2411
+
2412
+ typedef struct cuGraphicsSubResourceGetMappedArray_params_st {
2413
+ CUarray *pArray;
2414
+ CUgraphicsResource resource;
2415
+ unsigned int arrayIndex;
2416
+ unsigned int mipLevel;
2417
+ } cuGraphicsSubResourceGetMappedArray_params;
2418
+
2419
+ typedef struct cuGraphicsResourceGetMappedMipmappedArray_params_st {
2420
+ CUmipmappedArray *pMipmappedArray;
2421
+ CUgraphicsResource resource;
2422
+ } cuGraphicsResourceGetMappedMipmappedArray_params;
2423
+
2424
+ typedef struct cuGraphicsResourceGetMappedPointer_v2_params_st {
2425
+ CUdeviceptr *pDevPtr;
2426
+ size_t *pSize;
2427
+ CUgraphicsResource resource;
2428
+ } cuGraphicsResourceGetMappedPointer_v2_params;
2429
+
2430
+ typedef struct cuGraphicsResourceSetMapFlags_v2_params_st {
2431
+ CUgraphicsResource resource;
2432
+ unsigned int flags;
2433
+ } cuGraphicsResourceSetMapFlags_v2_params;
2434
+
2435
+ typedef struct cuGraphicsMapResources_ptsz_params_st {
2436
+ unsigned int count;
2437
+ CUgraphicsResource *resources;
2438
+ CUstream hStream;
2439
+ } cuGraphicsMapResources_ptsz_params;
2440
+
2441
+ typedef struct cuGraphicsUnmapResources_ptsz_params_st {
2442
+ unsigned int count;
2443
+ CUgraphicsResource *resources;
2444
+ CUstream hStream;
2445
+ } cuGraphicsUnmapResources_ptsz_params;
2446
+
2447
+ typedef struct cuGetProcAddress_v2_params_st {
2448
+ const char *symbol;
2449
+ void **pfn;
2450
+ int cudaVersion;
2451
+ cuuint64_t flags;
2452
+ CUdriverProcAddressQueryResult *symbolStatus;
2453
+ } cuGetProcAddress_v2_params;
2454
+
2455
+ typedef struct cuCoredumpGetAttribute_params_st {
2456
+ CUcoredumpSettings attrib;
2457
+ void *value;
2458
+ size_t *size;
2459
+ } cuCoredumpGetAttribute_params;
2460
+
2461
+ typedef struct cuCoredumpGetAttributeGlobal_params_st {
2462
+ CUcoredumpSettings attrib;
2463
+ void *value;
2464
+ size_t *size;
2465
+ } cuCoredumpGetAttributeGlobal_params;
2466
+
2467
+ typedef struct cuCoredumpSetAttribute_params_st {
2468
+ CUcoredumpSettings attrib;
2469
+ void *value;
2470
+ size_t *size;
2471
+ } cuCoredumpSetAttribute_params;
2472
+
2473
+ typedef struct cuCoredumpSetAttributeGlobal_params_st {
2474
+ CUcoredumpSettings attrib;
2475
+ void *value;
2476
+ size_t *size;
2477
+ } cuCoredumpSetAttributeGlobal_params;
2478
+
2479
+ typedef struct cuGetExportTable_params_st {
2480
+ const void **ppExportTable;
2481
+ const CUuuid *pExportTableId;
2482
+ } cuGetExportTable_params;
2483
+
2484
+ typedef struct cuGreenCtxCreate_params_st {
2485
+ CUgreenCtx *phCtx;
2486
+ CUdevResourceDesc desc;
2487
+ CUdevice dev;
2488
+ unsigned int flags;
2489
+ } cuGreenCtxCreate_params;
2490
+
2491
+ typedef struct cuGreenCtxDestroy_params_st {
2492
+ CUgreenCtx hCtx;
2493
+ } cuGreenCtxDestroy_params;
2494
+
2495
+ typedef struct cuCtxFromGreenCtx_params_st {
2496
+ CUcontext *pContext;
2497
+ CUgreenCtx hCtx;
2498
+ } cuCtxFromGreenCtx_params;
2499
+
2500
+ typedef struct cuDeviceGetDevResource_params_st {
2501
+ CUdevice device;
2502
+ CUdevResource *resource;
2503
+ CUdevResourceType type;
2504
+ } cuDeviceGetDevResource_params;
2505
+
2506
+ typedef struct cuCtxGetDevResource_params_st {
2507
+ CUcontext hCtx;
2508
+ CUdevResource *resource;
2509
+ CUdevResourceType type;
2510
+ } cuCtxGetDevResource_params;
2511
+
2512
+ typedef struct cuGreenCtxGetDevResource_params_st {
2513
+ CUgreenCtx hCtx;
2514
+ CUdevResource *resource;
2515
+ CUdevResourceType type;
2516
+ } cuGreenCtxGetDevResource_params;
2517
+
2518
+ typedef struct cuDevSmResourceSplitByCount_params_st {
2519
+ CUdevResource *result;
2520
+ unsigned int *nbGroups;
2521
+ const CUdevResource *input;
2522
+ CUdevResource *remaining;
2523
+ unsigned int useFlags;
2524
+ unsigned int minCount;
2525
+ } cuDevSmResourceSplitByCount_params;
2526
+
2527
+ typedef struct cuDevResourceGenerateDesc_params_st {
2528
+ CUdevResourceDesc *phDesc;
2529
+ CUdevResource *resources;
2530
+ unsigned int nbResources;
2531
+ } cuDevResourceGenerateDesc_params;
2532
+
2533
+ typedef struct cuGreenCtxRecordEvent_params_st {
2534
+ CUgreenCtx hCtx;
2535
+ CUevent hEvent;
2536
+ } cuGreenCtxRecordEvent_params;
2537
+
2538
+ typedef struct cuGreenCtxWaitEvent_params_st {
2539
+ CUgreenCtx hCtx;
2540
+ CUevent hEvent;
2541
+ } cuGreenCtxWaitEvent_params;
2542
+
2543
+ typedef struct cuStreamGetGreenCtx_params_st {
2544
+ CUstream hStream;
2545
+ CUgreenCtx *phCtx;
2546
+ } cuStreamGetGreenCtx_params;
2547
+
2548
+ typedef struct cuMemHostRegister_params_st {
2549
+ void *p;
2550
+ size_t bytesize;
2551
+ unsigned int Flags;
2552
+ } cuMemHostRegister_params;
2553
+
2554
+ typedef struct cuGraphicsResourceSetMapFlags_params_st {
2555
+ CUgraphicsResource resource;
2556
+ unsigned int flags;
2557
+ } cuGraphicsResourceSetMapFlags_params;
2558
+
2559
+ typedef struct cuLinkCreate_params_st {
2560
+ unsigned int numOptions;
2561
+ CUjit_option *options;
2562
+ void **optionValues;
2563
+ CUlinkState *stateOut;
2564
+ } cuLinkCreate_params;
2565
+
2566
+ typedef struct cuLinkAddData_params_st {
2567
+ CUlinkState state;
2568
+ CUjitInputType type;
2569
+ void *data;
2570
+ size_t size;
2571
+ const char *name;
2572
+ unsigned int numOptions;
2573
+ CUjit_option *options;
2574
+ void **optionValues;
2575
+ } cuLinkAddData_params;
2576
+
2577
+ typedef struct cuLinkAddFile_params_st {
2578
+ CUlinkState state;
2579
+ CUjitInputType type;
2580
+ const char *path;
2581
+ unsigned int numOptions;
2582
+ CUjit_option *options;
2583
+ void **optionValues;
2584
+ } cuLinkAddFile_params;
2585
+
2586
+ typedef struct cuTexRefSetAddress2D_v2_params_st {
2587
+ CUtexref hTexRef;
2588
+ const CUDA_ARRAY_DESCRIPTOR *desc;
2589
+ CUdeviceptr dptr;
2590
+ size_t Pitch;
2591
+ } cuTexRefSetAddress2D_v2_params;
2592
+
2593
+ typedef struct cuDeviceTotalMem_params_st {
2594
+ unsigned int *bytes;
2595
+ CUdevice dev;
2596
+ } cuDeviceTotalMem_params;
2597
+
2598
+ typedef struct cuCtxCreate_params_st {
2599
+ CUcontext *pctx;
2600
+ unsigned int flags;
2601
+ CUdevice dev;
2602
+ } cuCtxCreate_params;
2603
+
2604
+ typedef struct cuModuleGetGlobal_params_st {
2605
+ CUdeviceptr_v1 *dptr;
2606
+ unsigned int *bytes;
2607
+ CUmodule hmod;
2608
+ const char *name;
2609
+ } cuModuleGetGlobal_params;
2610
+
2611
+ typedef struct cuMemGetInfo_params_st {
2612
+ unsigned int *free;
2613
+ unsigned int *total;
2614
+ } cuMemGetInfo_params;
2615
+
2616
+ typedef struct cuMemAlloc_params_st {
2617
+ CUdeviceptr_v1 *dptr;
2618
+ unsigned int bytesize;
2619
+ } cuMemAlloc_params;
2620
+
2621
+ typedef struct cuMemAllocPitch_params_st {
2622
+ CUdeviceptr_v1 *dptr;
2623
+ unsigned int *pPitch;
2624
+ unsigned int WidthInBytes;
2625
+ unsigned int Height;
2626
+ unsigned int ElementSizeBytes;
2627
+ } cuMemAllocPitch_params;
2628
+
2629
+ typedef struct cuMemFree_params_st {
2630
+ CUdeviceptr_v1 dptr;
2631
+ } cuMemFree_params;
2632
+
2633
+ typedef struct cuMemGetAddressRange_params_st {
2634
+ CUdeviceptr_v1 *pbase;
2635
+ unsigned int *psize;
2636
+ CUdeviceptr_v1 dptr;
2637
+ } cuMemGetAddressRange_params;
2638
+
2639
+ typedef struct cuMemAllocHost_params_st {
2640
+ void **pp;
2641
+ unsigned int bytesize;
2642
+ } cuMemAllocHost_params;
2643
+
2644
+ typedef struct cuMemHostGetDevicePointer_params_st {
2645
+ CUdeviceptr_v1 *pdptr;
2646
+ void *p;
2647
+ unsigned int Flags;
2648
+ } cuMemHostGetDevicePointer_params;
2649
+
2650
+ typedef struct cuMemcpyHtoD_params_st {
2651
+ CUdeviceptr_v1 dstDevice;
2652
+ const void *srcHost;
2653
+ unsigned int ByteCount;
2654
+ } cuMemcpyHtoD_params;
2655
+
2656
+ typedef struct cuMemcpyDtoH_params_st {
2657
+ void *dstHost;
2658
+ CUdeviceptr_v1 srcDevice;
2659
+ unsigned int ByteCount;
2660
+ } cuMemcpyDtoH_params;
2661
+
2662
+ typedef struct cuMemcpyDtoD_params_st {
2663
+ CUdeviceptr_v1 dstDevice;
2664
+ CUdeviceptr_v1 srcDevice;
2665
+ unsigned int ByteCount;
2666
+ } cuMemcpyDtoD_params;
2667
+
2668
+ typedef struct cuMemcpyDtoA_params_st {
2669
+ CUarray dstArray;
2670
+ unsigned int dstOffset;
2671
+ CUdeviceptr_v1 srcDevice;
2672
+ unsigned int ByteCount;
2673
+ } cuMemcpyDtoA_params;
2674
+
2675
+ typedef struct cuMemcpyAtoD_params_st {
2676
+ CUdeviceptr_v1 dstDevice;
2677
+ CUarray srcArray;
2678
+ unsigned int srcOffset;
2679
+ unsigned int ByteCount;
2680
+ } cuMemcpyAtoD_params;
2681
+
2682
+ typedef struct cuMemcpyHtoA_params_st {
2683
+ CUarray dstArray;
2684
+ unsigned int dstOffset;
2685
+ const void *srcHost;
2686
+ unsigned int ByteCount;
2687
+ } cuMemcpyHtoA_params;
2688
+
2689
+ typedef struct cuMemcpyAtoH_params_st {
2690
+ void *dstHost;
2691
+ CUarray srcArray;
2692
+ unsigned int srcOffset;
2693
+ unsigned int ByteCount;
2694
+ } cuMemcpyAtoH_params;
2695
+
2696
+ typedef struct cuMemcpyAtoA_params_st {
2697
+ CUarray dstArray;
2698
+ unsigned int dstOffset;
2699
+ CUarray srcArray;
2700
+ unsigned int srcOffset;
2701
+ unsigned int ByteCount;
2702
+ } cuMemcpyAtoA_params;
2703
+
2704
+ typedef struct cuMemcpyHtoAAsync_params_st {
2705
+ CUarray dstArray;
2706
+ unsigned int dstOffset;
2707
+ const void *srcHost;
2708
+ unsigned int ByteCount;
2709
+ CUstream hStream;
2710
+ } cuMemcpyHtoAAsync_params;
2711
+
2712
+ typedef struct cuMemcpyAtoHAsync_params_st {
2713
+ void *dstHost;
2714
+ CUarray srcArray;
2715
+ unsigned int srcOffset;
2716
+ unsigned int ByteCount;
2717
+ CUstream hStream;
2718
+ } cuMemcpyAtoHAsync_params;
2719
+
2720
+ typedef struct cuMemcpy2D_params_st {
2721
+ const CUDA_MEMCPY2D_v1 *pCopy;
2722
+ } cuMemcpy2D_params;
2723
+
2724
+ typedef struct cuMemcpy2DUnaligned_params_st {
2725
+ const CUDA_MEMCPY2D_v1 *pCopy;
2726
+ } cuMemcpy2DUnaligned_params;
2727
+
2728
+ typedef struct cuMemcpy3D_params_st {
2729
+ const CUDA_MEMCPY3D_v1 *pCopy;
2730
+ } cuMemcpy3D_params;
2731
+
2732
+ typedef struct cuMemcpyHtoDAsync_params_st {
2733
+ CUdeviceptr_v1 dstDevice;
2734
+ const void *srcHost;
2735
+ unsigned int ByteCount;
2736
+ CUstream hStream;
2737
+ } cuMemcpyHtoDAsync_params;
2738
+
2739
+ typedef struct cuMemcpyDtoHAsync_params_st {
2740
+ void *dstHost;
2741
+ CUdeviceptr_v1 srcDevice;
2742
+ unsigned int ByteCount;
2743
+ CUstream hStream;
2744
+ } cuMemcpyDtoHAsync_params;
2745
+
2746
+ typedef struct cuMemcpyDtoDAsync_params_st {
2747
+ CUdeviceptr_v1 dstDevice;
2748
+ CUdeviceptr_v1 srcDevice;
2749
+ unsigned int ByteCount;
2750
+ CUstream hStream;
2751
+ } cuMemcpyDtoDAsync_params;
2752
+
2753
+ typedef struct cuMemcpy2DAsync_params_st {
2754
+ const CUDA_MEMCPY2D_v1 *pCopy;
2755
+ CUstream hStream;
2756
+ } cuMemcpy2DAsync_params;
2757
+
2758
+ typedef struct cuMemcpy3DAsync_params_st {
2759
+ const CUDA_MEMCPY3D_v1 *pCopy;
2760
+ CUstream hStream;
2761
+ } cuMemcpy3DAsync_params;
2762
+
2763
+ typedef struct cuMemsetD8_params_st {
2764
+ CUdeviceptr_v1 dstDevice;
2765
+ unsigned char uc;
2766
+ unsigned int N;
2767
+ } cuMemsetD8_params;
2768
+
2769
+ typedef struct cuMemsetD16_params_st {
2770
+ CUdeviceptr_v1 dstDevice;
2771
+ unsigned short us;
2772
+ unsigned int N;
2773
+ } cuMemsetD16_params;
2774
+
2775
+ typedef struct cuMemsetD32_params_st {
2776
+ CUdeviceptr_v1 dstDevice;
2777
+ unsigned int ui;
2778
+ unsigned int N;
2779
+ } cuMemsetD32_params;
2780
+
2781
+ typedef struct cuMemsetD2D8_params_st {
2782
+ CUdeviceptr_v1 dstDevice;
2783
+ unsigned int dstPitch;
2784
+ unsigned char uc;
2785
+ unsigned int Width;
2786
+ unsigned int Height;
2787
+ } cuMemsetD2D8_params;
2788
+
2789
+ typedef struct cuMemsetD2D16_params_st {
2790
+ CUdeviceptr_v1 dstDevice;
2791
+ unsigned int dstPitch;
2792
+ unsigned short us;
2793
+ unsigned int Width;
2794
+ unsigned int Height;
2795
+ } cuMemsetD2D16_params;
2796
+
2797
+ typedef struct cuMemsetD2D32_params_st {
2798
+ CUdeviceptr_v1 dstDevice;
2799
+ unsigned int dstPitch;
2800
+ unsigned int ui;
2801
+ unsigned int Width;
2802
+ unsigned int Height;
2803
+ } cuMemsetD2D32_params;
2804
+
2805
+ typedef struct cuArrayCreate_params_st {
2806
+ CUarray *pHandle;
2807
+ const CUDA_ARRAY_DESCRIPTOR_v1 *pAllocateArray;
2808
+ } cuArrayCreate_params;
2809
+
2810
+ typedef struct cuArrayGetDescriptor_params_st {
2811
+ CUDA_ARRAY_DESCRIPTOR_v1 *pArrayDescriptor;
2812
+ CUarray hArray;
2813
+ } cuArrayGetDescriptor_params;
2814
+
2815
+ typedef struct cuArray3DCreate_params_st {
2816
+ CUarray *pHandle;
2817
+ const CUDA_ARRAY3D_DESCRIPTOR_v1 *pAllocateArray;
2818
+ } cuArray3DCreate_params;
2819
+
2820
+ typedef struct cuArray3DGetDescriptor_params_st {
2821
+ CUDA_ARRAY3D_DESCRIPTOR_v1 *pArrayDescriptor;
2822
+ CUarray hArray;
2823
+ } cuArray3DGetDescriptor_params;
2824
+
2825
+ typedef struct cuTexRefSetAddress_params_st {
2826
+ unsigned int *ByteOffset;
2827
+ CUtexref hTexRef;
2828
+ CUdeviceptr_v1 dptr;
2829
+ unsigned int bytes;
2830
+ } cuTexRefSetAddress_params;
2831
+
2832
+ typedef struct cuTexRefSetAddress2D_params_st {
2833
+ CUtexref hTexRef;
2834
+ const CUDA_ARRAY_DESCRIPTOR_v1 *desc;
2835
+ CUdeviceptr_v1 dptr;
2836
+ unsigned int Pitch;
2837
+ } cuTexRefSetAddress2D_params;
2838
+
2839
+ typedef struct cuTexRefGetAddress_params_st {
2840
+ CUdeviceptr_v1 *pdptr;
2841
+ CUtexref hTexRef;
2842
+ } cuTexRefGetAddress_params;
2843
+
2844
+ typedef struct cuGraphicsResourceGetMappedPointer_params_st {
2845
+ CUdeviceptr_v1 *pDevPtr;
2846
+ unsigned int *pSize;
2847
+ CUgraphicsResource resource;
2848
+ } cuGraphicsResourceGetMappedPointer_params;
2849
+
2850
+ typedef struct cuCtxDestroy_params_st {
2851
+ CUcontext ctx;
2852
+ } cuCtxDestroy_params;
2853
+
2854
+ typedef struct cuCtxPopCurrent_params_st {
2855
+ CUcontext *pctx;
2856
+ } cuCtxPopCurrent_params;
2857
+
2858
+ typedef struct cuCtxPushCurrent_params_st {
2859
+ CUcontext ctx;
2860
+ } cuCtxPushCurrent_params;
2861
+
2862
+ typedef struct cuStreamDestroy_params_st {
2863
+ CUstream hStream;
2864
+ } cuStreamDestroy_params;
2865
+
2866
+ typedef struct cuEventDestroy_params_st {
2867
+ CUevent hEvent;
2868
+ } cuEventDestroy_params;
2869
+
2870
+ typedef struct cuDevicePrimaryCtxRelease_params_st {
2871
+ CUdevice dev;
2872
+ } cuDevicePrimaryCtxRelease_params;
2873
+
2874
+ typedef struct cuDevicePrimaryCtxReset_params_st {
2875
+ CUdevice dev;
2876
+ } cuDevicePrimaryCtxReset_params;
2877
+
2878
+ typedef struct cuDevicePrimaryCtxSetFlags_params_st {
2879
+ CUdevice dev;
2880
+ unsigned int flags;
2881
+ } cuDevicePrimaryCtxSetFlags_params;
2882
+
2883
+ typedef struct cuMemcpyHtoD_v2_params_st {
2884
+ CUdeviceptr dstDevice;
2885
+ const void *srcHost;
2886
+ size_t ByteCount;
2887
+ } cuMemcpyHtoD_v2_params;
2888
+
2889
+ typedef struct cuMemcpyDtoH_v2_params_st {
2890
+ void *dstHost;
2891
+ CUdeviceptr srcDevice;
2892
+ size_t ByteCount;
2893
+ } cuMemcpyDtoH_v2_params;
2894
+
2895
+ typedef struct cuMemcpyDtoD_v2_params_st {
2896
+ CUdeviceptr dstDevice;
2897
+ CUdeviceptr srcDevice;
2898
+ size_t ByteCount;
2899
+ } cuMemcpyDtoD_v2_params;
2900
+
2901
+ typedef struct cuMemcpyDtoA_v2_params_st {
2902
+ CUarray dstArray;
2903
+ size_t dstOffset;
2904
+ CUdeviceptr srcDevice;
2905
+ size_t ByteCount;
2906
+ } cuMemcpyDtoA_v2_params;
2907
+
2908
+ typedef struct cuMemcpyAtoD_v2_params_st {
2909
+ CUdeviceptr dstDevice;
2910
+ CUarray srcArray;
2911
+ size_t srcOffset;
2912
+ size_t ByteCount;
2913
+ } cuMemcpyAtoD_v2_params;
2914
+
2915
+ typedef struct cuMemcpyHtoA_v2_params_st {
2916
+ CUarray dstArray;
2917
+ size_t dstOffset;
2918
+ const void *srcHost;
2919
+ size_t ByteCount;
2920
+ } cuMemcpyHtoA_v2_params;
2921
+
2922
+ typedef struct cuMemcpyAtoH_v2_params_st {
2923
+ void *dstHost;
2924
+ CUarray srcArray;
2925
+ size_t srcOffset;
2926
+ size_t ByteCount;
2927
+ } cuMemcpyAtoH_v2_params;
2928
+
2929
+ typedef struct cuMemcpyAtoA_v2_params_st {
2930
+ CUarray dstArray;
2931
+ size_t dstOffset;
2932
+ CUarray srcArray;
2933
+ size_t srcOffset;
2934
+ size_t ByteCount;
2935
+ } cuMemcpyAtoA_v2_params;
2936
+
2937
+ typedef struct cuMemcpyHtoAAsync_v2_params_st {
2938
+ CUarray dstArray;
2939
+ size_t dstOffset;
2940
+ const void *srcHost;
2941
+ size_t ByteCount;
2942
+ CUstream hStream;
2943
+ } cuMemcpyHtoAAsync_v2_params;
2944
+
2945
+ typedef struct cuMemcpyAtoHAsync_v2_params_st {
2946
+ void *dstHost;
2947
+ CUarray srcArray;
2948
+ size_t srcOffset;
2949
+ size_t ByteCount;
2950
+ CUstream hStream;
2951
+ } cuMemcpyAtoHAsync_v2_params;
2952
+
2953
+ typedef struct cuMemcpy2D_v2_params_st {
2954
+ const CUDA_MEMCPY2D *pCopy;
2955
+ } cuMemcpy2D_v2_params;
2956
+
2957
+ typedef struct cuMemcpy2DUnaligned_v2_params_st {
2958
+ const CUDA_MEMCPY2D *pCopy;
2959
+ } cuMemcpy2DUnaligned_v2_params;
2960
+
2961
+ typedef struct cuMemcpy3D_v2_params_st {
2962
+ const CUDA_MEMCPY3D *pCopy;
2963
+ } cuMemcpy3D_v2_params;
2964
+
2965
+ typedef struct cuMemcpyHtoDAsync_v2_params_st {
2966
+ CUdeviceptr dstDevice;
2967
+ const void *srcHost;
2968
+ size_t ByteCount;
2969
+ CUstream hStream;
2970
+ } cuMemcpyHtoDAsync_v2_params;
2971
+
2972
+ typedef struct cuMemcpyDtoHAsync_v2_params_st {
2973
+ void *dstHost;
2974
+ CUdeviceptr srcDevice;
2975
+ size_t ByteCount;
2976
+ CUstream hStream;
2977
+ } cuMemcpyDtoHAsync_v2_params;
2978
+
2979
+ typedef struct cuMemcpyDtoDAsync_v2_params_st {
2980
+ CUdeviceptr dstDevice;
2981
+ CUdeviceptr srcDevice;
2982
+ size_t ByteCount;
2983
+ CUstream hStream;
2984
+ } cuMemcpyDtoDAsync_v2_params;
2985
+
2986
+ typedef struct cuMemcpy2DAsync_v2_params_st {
2987
+ const CUDA_MEMCPY2D *pCopy;
2988
+ CUstream hStream;
2989
+ } cuMemcpy2DAsync_v2_params;
2990
+
2991
+ typedef struct cuMemcpy3DAsync_v2_params_st {
2992
+ const CUDA_MEMCPY3D *pCopy;
2993
+ CUstream hStream;
2994
+ } cuMemcpy3DAsync_v2_params;
2995
+
2996
+ typedef struct cuMemsetD8_v2_params_st {
2997
+ CUdeviceptr dstDevice;
2998
+ unsigned char uc;
2999
+ size_t N;
3000
+ } cuMemsetD8_v2_params;
3001
+
3002
+ typedef struct cuMemsetD16_v2_params_st {
3003
+ CUdeviceptr dstDevice;
3004
+ unsigned short us;
3005
+ size_t N;
3006
+ } cuMemsetD16_v2_params;
3007
+
3008
+ typedef struct cuMemsetD32_v2_params_st {
3009
+ CUdeviceptr dstDevice;
3010
+ unsigned int ui;
3011
+ size_t N;
3012
+ } cuMemsetD32_v2_params;
3013
+
3014
+ typedef struct cuMemsetD2D8_v2_params_st {
3015
+ CUdeviceptr dstDevice;
3016
+ size_t dstPitch;
3017
+ unsigned char uc;
3018
+ size_t Width;
3019
+ size_t Height;
3020
+ } cuMemsetD2D8_v2_params;
3021
+
3022
+ typedef struct cuMemsetD2D16_v2_params_st {
3023
+ CUdeviceptr dstDevice;
3024
+ size_t dstPitch;
3025
+ unsigned short us;
3026
+ size_t Width;
3027
+ size_t Height;
3028
+ } cuMemsetD2D16_v2_params;
3029
+
3030
+ typedef struct cuMemsetD2D32_v2_params_st {
3031
+ CUdeviceptr dstDevice;
3032
+ size_t dstPitch;
3033
+ unsigned int ui;
3034
+ size_t Width;
3035
+ size_t Height;
3036
+ } cuMemsetD2D32_v2_params;
3037
+
3038
+ typedef struct cuMemcpy_params_st {
3039
+ CUdeviceptr dst;
3040
+ CUdeviceptr src;
3041
+ size_t ByteCount;
3042
+ } cuMemcpy_params;
3043
+
3044
+ typedef struct cuMemcpyAsync_params_st {
3045
+ CUdeviceptr dst;
3046
+ CUdeviceptr src;
3047
+ size_t ByteCount;
3048
+ CUstream hStream;
3049
+ } cuMemcpyAsync_params;
3050
+
3051
+ typedef struct cuMemcpyPeer_params_st {
3052
+ CUdeviceptr dstDevice;
3053
+ CUcontext dstContext;
3054
+ CUdeviceptr srcDevice;
3055
+ CUcontext srcContext;
3056
+ size_t ByteCount;
3057
+ } cuMemcpyPeer_params;
3058
+
3059
+ typedef struct cuMemcpyPeerAsync_params_st {
3060
+ CUdeviceptr dstDevice;
3061
+ CUcontext dstContext;
3062
+ CUdeviceptr srcDevice;
3063
+ CUcontext srcContext;
3064
+ size_t ByteCount;
3065
+ CUstream hStream;
3066
+ } cuMemcpyPeerAsync_params;
3067
+
3068
+ typedef struct cuMemcpy3DPeer_params_st {
3069
+ const CUDA_MEMCPY3D_PEER *pCopy;
3070
+ } cuMemcpy3DPeer_params;
3071
+
3072
+ typedef struct cuMemcpy3DPeerAsync_params_st {
3073
+ const CUDA_MEMCPY3D_PEER *pCopy;
3074
+ CUstream hStream;
3075
+ } cuMemcpy3DPeerAsync_params;
3076
+
3077
+ typedef struct cuMemsetD8Async_params_st {
3078
+ CUdeviceptr dstDevice;
3079
+ unsigned char uc;
3080
+ size_t N;
3081
+ CUstream hStream;
3082
+ } cuMemsetD8Async_params;
3083
+
3084
+ typedef struct cuMemsetD16Async_params_st {
3085
+ CUdeviceptr dstDevice;
3086
+ unsigned short us;
3087
+ size_t N;
3088
+ CUstream hStream;
3089
+ } cuMemsetD16Async_params;
3090
+
3091
+ typedef struct cuMemsetD32Async_params_st {
3092
+ CUdeviceptr dstDevice;
3093
+ unsigned int ui;
3094
+ size_t N;
3095
+ CUstream hStream;
3096
+ } cuMemsetD32Async_params;
3097
+
3098
+ typedef struct cuMemsetD2D8Async_params_st {
3099
+ CUdeviceptr dstDevice;
3100
+ size_t dstPitch;
3101
+ unsigned char uc;
3102
+ size_t Width;
3103
+ size_t Height;
3104
+ CUstream hStream;
3105
+ } cuMemsetD2D8Async_params;
3106
+
3107
+ typedef struct cuMemsetD2D16Async_params_st {
3108
+ CUdeviceptr dstDevice;
3109
+ size_t dstPitch;
3110
+ unsigned short us;
3111
+ size_t Width;
3112
+ size_t Height;
3113
+ CUstream hStream;
3114
+ } cuMemsetD2D16Async_params;
3115
+
3116
+ typedef struct cuMemsetD2D32Async_params_st {
3117
+ CUdeviceptr dstDevice;
3118
+ size_t dstPitch;
3119
+ unsigned int ui;
3120
+ size_t Width;
3121
+ size_t Height;
3122
+ CUstream hStream;
3123
+ } cuMemsetD2D32Async_params;
3124
+
3125
+ typedef struct cuStreamGetPriority_params_st {
3126
+ CUstream hStream;
3127
+ int *priority;
3128
+ } cuStreamGetPriority_params;
3129
+
3130
+ typedef struct cuStreamGetId_params_st {
3131
+ CUstream hStream;
3132
+ unsigned long long *streamId;
3133
+ } cuStreamGetId_params;
3134
+
3135
+ typedef struct cuStreamGetFlags_params_st {
3136
+ CUstream hStream;
3137
+ unsigned int *flags;
3138
+ } cuStreamGetFlags_params;
3139
+
3140
+ typedef struct cuStreamGetCtx_params_st {
3141
+ CUstream hStream;
3142
+ CUcontext *pctx;
3143
+ } cuStreamGetCtx_params;
3144
+
3145
+ typedef struct cuStreamWaitEvent_params_st {
3146
+ CUstream hStream;
3147
+ CUevent hEvent;
3148
+ unsigned int Flags;
3149
+ } cuStreamWaitEvent_params;
3150
+
3151
+ typedef struct cuStreamAddCallback_params_st {
3152
+ CUstream hStream;
3153
+ CUstreamCallback callback;
3154
+ void *userData;
3155
+ unsigned int flags;
3156
+ } cuStreamAddCallback_params;
3157
+
3158
+ typedef struct cuStreamAttachMemAsync_params_st {
3159
+ CUstream hStream;
3160
+ CUdeviceptr dptr;
3161
+ size_t length;
3162
+ unsigned int flags;
3163
+ } cuStreamAttachMemAsync_params;
3164
+
3165
+ typedef struct cuStreamQuery_params_st {
3166
+ CUstream hStream;
3167
+ } cuStreamQuery_params;
3168
+
3169
+ typedef struct cuStreamSynchronize_params_st {
3170
+ CUstream hStream;
3171
+ } cuStreamSynchronize_params;
3172
+
3173
+ typedef struct cuEventRecord_params_st {
3174
+ CUevent hEvent;
3175
+ CUstream hStream;
3176
+ } cuEventRecord_params;
3177
+
3178
+ typedef struct cuEventRecordWithFlags_params_st {
3179
+ CUevent hEvent;
3180
+ CUstream hStream;
3181
+ unsigned int flags;
3182
+ } cuEventRecordWithFlags_params;
3183
+
3184
+ typedef struct cuLaunchKernel_params_st {
3185
+ CUfunction f;
3186
+ unsigned int gridDimX;
3187
+ unsigned int gridDimY;
3188
+ unsigned int gridDimZ;
3189
+ unsigned int blockDimX;
3190
+ unsigned int blockDimY;
3191
+ unsigned int blockDimZ;
3192
+ unsigned int sharedMemBytes;
3193
+ CUstream hStream;
3194
+ void **kernelParams;
3195
+ void **extra;
3196
+ } cuLaunchKernel_params;
3197
+
3198
+ typedef struct cuLaunchKernelEx_params_st {
3199
+ const CUlaunchConfig *config;
3200
+ CUfunction f;
3201
+ void **kernelParams;
3202
+ void **extra;
3203
+ } cuLaunchKernelEx_params;
3204
+
3205
+ typedef struct cuLaunchHostFunc_params_st {
3206
+ CUstream hStream;
3207
+ CUhostFn fn;
3208
+ void *userData;
3209
+ } cuLaunchHostFunc_params;
3210
+
3211
+ typedef struct cuGraphicsMapResources_params_st {
3212
+ unsigned int count;
3213
+ CUgraphicsResource *resources;
3214
+ CUstream hStream;
3215
+ } cuGraphicsMapResources_params;
3216
+
3217
+ typedef struct cuGraphicsUnmapResources_params_st {
3218
+ unsigned int count;
3219
+ CUgraphicsResource *resources;
3220
+ CUstream hStream;
3221
+ } cuGraphicsUnmapResources_params;
3222
+
3223
+ typedef struct cuStreamWriteValue32_params_st {
3224
+ CUstream stream;
3225
+ CUdeviceptr addr;
3226
+ cuuint32_t value;
3227
+ unsigned int flags;
3228
+ } cuStreamWriteValue32_params;
3229
+
3230
+ typedef struct cuStreamWaitValue32_params_st {
3231
+ CUstream stream;
3232
+ CUdeviceptr addr;
3233
+ cuuint32_t value;
3234
+ unsigned int flags;
3235
+ } cuStreamWaitValue32_params;
3236
+
3237
+ typedef struct cuStreamWriteValue64_params_st {
3238
+ CUstream stream;
3239
+ CUdeviceptr addr;
3240
+ cuuint64_t value;
3241
+ unsigned int flags;
3242
+ } cuStreamWriteValue64_params;
3243
+
3244
+ typedef struct cuStreamWaitValue64_params_st {
3245
+ CUstream stream;
3246
+ CUdeviceptr addr;
3247
+ cuuint64_t value;
3248
+ unsigned int flags;
3249
+ } cuStreamWaitValue64_params;
3250
+
3251
+ typedef struct cuStreamBatchMemOp_params_st {
3252
+ CUstream stream;
3253
+ unsigned int count;
3254
+ CUstreamBatchMemOpParams *paramArray;
3255
+ unsigned int flags;
3256
+ } cuStreamBatchMemOp_params;
3257
+
3258
+ typedef struct cuStreamWriteValue32_ptsz_params_st {
3259
+ CUstream stream;
3260
+ CUdeviceptr addr;
3261
+ cuuint32_t value;
3262
+ unsigned int flags;
3263
+ } cuStreamWriteValue32_ptsz_params;
3264
+
3265
+ typedef struct cuStreamWaitValue32_ptsz_params_st {
3266
+ CUstream stream;
3267
+ CUdeviceptr addr;
3268
+ cuuint32_t value;
3269
+ unsigned int flags;
3270
+ } cuStreamWaitValue32_ptsz_params;
3271
+
3272
+ typedef struct cuStreamWriteValue64_ptsz_params_st {
3273
+ CUstream stream;
3274
+ CUdeviceptr addr;
3275
+ cuuint64_t value;
3276
+ unsigned int flags;
3277
+ } cuStreamWriteValue64_ptsz_params;
3278
+
3279
+ typedef struct cuStreamWaitValue64_ptsz_params_st {
3280
+ CUstream stream;
3281
+ CUdeviceptr addr;
3282
+ cuuint64_t value;
3283
+ unsigned int flags;
3284
+ } cuStreamWaitValue64_ptsz_params;
3285
+
3286
+ typedef struct cuStreamBatchMemOp_ptsz_params_st {
3287
+ CUstream stream;
3288
+ unsigned int count;
3289
+ CUstreamBatchMemOpParams *paramArray;
3290
+ unsigned int flags;
3291
+ } cuStreamBatchMemOp_ptsz_params;
3292
+
3293
+ typedef struct cuStreamWriteValue32_v2_params_st {
3294
+ CUstream stream;
3295
+ CUdeviceptr addr;
3296
+ cuuint32_t value;
3297
+ unsigned int flags;
3298
+ } cuStreamWriteValue32_v2_params;
3299
+
3300
+ typedef struct cuStreamWaitValue32_v2_params_st {
3301
+ CUstream stream;
3302
+ CUdeviceptr addr;
3303
+ cuuint32_t value;
3304
+ unsigned int flags;
3305
+ } cuStreamWaitValue32_v2_params;
3306
+
3307
+ typedef struct cuStreamWriteValue64_v2_params_st {
3308
+ CUstream stream;
3309
+ CUdeviceptr addr;
3310
+ cuuint64_t value;
3311
+ unsigned int flags;
3312
+ } cuStreamWriteValue64_v2_params;
3313
+
3314
+ typedef struct cuStreamWaitValue64_v2_params_st {
3315
+ CUstream stream;
3316
+ CUdeviceptr addr;
3317
+ cuuint64_t value;
3318
+ unsigned int flags;
3319
+ } cuStreamWaitValue64_v2_params;
3320
+
3321
+ typedef struct cuStreamBatchMemOp_v2_params_st {
3322
+ CUstream stream;
3323
+ unsigned int count;
3324
+ CUstreamBatchMemOpParams *paramArray;
3325
+ unsigned int flags;
3326
+ } cuStreamBatchMemOp_v2_params;
3327
+
3328
+ typedef struct cuMemPrefetchAsync_params_st {
3329
+ CUdeviceptr devPtr;
3330
+ size_t count;
3331
+ CUdevice dstDevice;
3332
+ CUstream hStream;
3333
+ } cuMemPrefetchAsync_params;
3334
+
3335
+ typedef struct cuMemPrefetchAsync_v2_params_st {
3336
+ CUdeviceptr devPtr;
3337
+ size_t count;
3338
+ CUmemLocation location;
3339
+ unsigned int flags;
3340
+ CUstream hStream;
3341
+ } cuMemPrefetchAsync_v2_params;
3342
+
3343
+ typedef struct cuLaunchCooperativeKernel_params_st {
3344
+ CUfunction f;
3345
+ unsigned int gridDimX;
3346
+ unsigned int gridDimY;
3347
+ unsigned int gridDimZ;
3348
+ unsigned int blockDimX;
3349
+ unsigned int blockDimY;
3350
+ unsigned int blockDimZ;
3351
+ unsigned int sharedMemBytes;
3352
+ CUstream hStream;
3353
+ void **kernelParams;
3354
+ } cuLaunchCooperativeKernel_params;
3355
+
3356
+ typedef struct cuSignalExternalSemaphoresAsync_params_st {
3357
+ const CUexternalSemaphore *extSemArray;
3358
+ const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS *paramsArray;
3359
+ unsigned int numExtSems;
3360
+ CUstream stream;
3361
+ } cuSignalExternalSemaphoresAsync_params;
3362
+
3363
+ typedef struct cuWaitExternalSemaphoresAsync_params_st {
3364
+ const CUexternalSemaphore *extSemArray;
3365
+ const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS *paramsArray;
3366
+ unsigned int numExtSems;
3367
+ CUstream stream;
3368
+ } cuWaitExternalSemaphoresAsync_params;
3369
+
3370
+ typedef struct cuStreamBeginCapture_params_st {
3371
+ CUstream hStream;
3372
+ } cuStreamBeginCapture_params;
3373
+
3374
+ typedef struct cuStreamBeginCapture_ptsz_params_st {
3375
+ CUstream hStream;
3376
+ } cuStreamBeginCapture_ptsz_params;
3377
+
3378
+ typedef struct cuStreamBeginCapture_v2_params_st {
3379
+ CUstream hStream;
3380
+ CUstreamCaptureMode mode;
3381
+ } cuStreamBeginCapture_v2_params;
3382
+
3383
+ typedef struct cuStreamBeginCaptureToGraph_params_st {
3384
+ CUstream hStream;
3385
+ CUgraph hGraph;
3386
+ const CUgraphNode *dependencies;
3387
+ const CUgraphEdgeData *dependencyData;
3388
+ size_t numDependencies;
3389
+ CUstreamCaptureMode mode;
3390
+ } cuStreamBeginCaptureToGraph_params;
3391
+
3392
+ typedef struct cuStreamEndCapture_params_st {
3393
+ CUstream hStream;
3394
+ CUgraph *phGraph;
3395
+ } cuStreamEndCapture_params;
3396
+
3397
+ typedef struct cuStreamIsCapturing_params_st {
3398
+ CUstream hStream;
3399
+ CUstreamCaptureStatus *captureStatus;
3400
+ } cuStreamIsCapturing_params;
3401
+
3402
+ typedef struct cuStreamGetCaptureInfo_params_st {
3403
+ CUstream hStream;
3404
+ CUstreamCaptureStatus *captureStatus_out;
3405
+ cuuint64_t *id_out;
3406
+ } cuStreamGetCaptureInfo_params;
3407
+
3408
+ typedef struct cuStreamGetCaptureInfo_ptsz_params_st {
3409
+ CUstream hStream;
3410
+ CUstreamCaptureStatus *captureStatus_out;
3411
+ cuuint64_t *id_out;
3412
+ } cuStreamGetCaptureInfo_ptsz_params;
3413
+
3414
+ typedef struct cuStreamGetCaptureInfo_v2_params_st {
3415
+ CUstream hStream;
3416
+ CUstreamCaptureStatus *captureStatus_out;
3417
+ cuuint64_t *id_out;
3418
+ CUgraph *graph_out;
3419
+ const CUgraphNode **dependencies_out;
3420
+ size_t *numDependencies_out;
3421
+ } cuStreamGetCaptureInfo_v2_params;
3422
+
3423
+ typedef struct cuStreamGetCaptureInfo_v3_params_st {
3424
+ CUstream hStream;
3425
+ CUstreamCaptureStatus *captureStatus_out;
3426
+ cuuint64_t *id_out;
3427
+ CUgraph *graph_out;
3428
+ const CUgraphNode **dependencies_out;
3429
+ const CUgraphEdgeData **edgeData_out;
3430
+ size_t *numDependencies_out;
3431
+ } cuStreamGetCaptureInfo_v3_params;
3432
+
3433
+ typedef struct cuGraphAddKernelNode_params_st {
3434
+ CUgraphNode *phGraphNode;
3435
+ CUgraph hGraph;
3436
+ const CUgraphNode *dependencies;
3437
+ size_t numDependencies;
3438
+ const CUDA_KERNEL_NODE_PARAMS_v1 *nodeParams;
3439
+ } cuGraphAddKernelNode_params;
3440
+
3441
+ typedef struct cuGraphKernelNodeGetParams_params_st {
3442
+ CUgraphNode hNode;
3443
+ CUDA_KERNEL_NODE_PARAMS_v1 *nodeParams;
3444
+ } cuGraphKernelNodeGetParams_params;
3445
+
3446
+ typedef struct cuGraphKernelNodeSetParams_params_st {
3447
+ CUgraphNode hNode;
3448
+ const CUDA_KERNEL_NODE_PARAMS_v1 *nodeParams;
3449
+ } cuGraphKernelNodeSetParams_params;
3450
+
3451
+ typedef struct cuGraphExecKernelNodeSetParams_params_st {
3452
+ CUgraphExec hGraphExec;
3453
+ CUgraphNode hNode;
3454
+ const CUDA_KERNEL_NODE_PARAMS_v1 *nodeParams;
3455
+ } cuGraphExecKernelNodeSetParams_params;
3456
+
3457
+ typedef struct cuGraphInstantiateWithParams_params_st {
3458
+ CUgraphExec *phGraphExec;
3459
+ CUgraph hGraph;
3460
+ CUDA_GRAPH_INSTANTIATE_PARAMS *instantiateParams;
3461
+ } cuGraphInstantiateWithParams_params;
3462
+
3463
+ typedef struct cuGraphExecUpdate_params_st {
3464
+ CUgraphExec hGraphExec;
3465
+ CUgraph hGraph;
3466
+ CUgraphNode *hErrorNode_out;
3467
+ CUgraphExecUpdateResult *updateResult_out;
3468
+ } cuGraphExecUpdate_params;
3469
+
3470
+ typedef struct cuGraphUpload_params_st {
3471
+ CUgraphExec hGraph;
3472
+ CUstream hStream;
3473
+ } cuGraphUpload_params;
3474
+
3475
+ typedef struct cuGraphLaunch_params_st {
3476
+ CUgraphExec hGraph;
3477
+ CUstream hStream;
3478
+ } cuGraphLaunch_params;
3479
+
3480
+ typedef struct cuStreamCopyAttributes_params_st {
3481
+ CUstream dstStream;
3482
+ CUstream srcStream;
3483
+ } cuStreamCopyAttributes_params;
3484
+
3485
+ typedef struct cuStreamGetAttribute_params_st {
3486
+ CUstream hStream;
3487
+ CUstreamAttrID attr;
3488
+ CUstreamAttrValue *value;
3489
+ } cuStreamGetAttribute_params;
3490
+
3491
+ typedef struct cuStreamSetAttribute_params_st {
3492
+ CUstream hStream;
3493
+ CUstreamAttrID attr;
3494
+ const CUstreamAttrValue *param;
3495
+ } cuStreamSetAttribute_params;
3496
+
3497
+ typedef struct cuIpcOpenMemHandle_params_st {
3498
+ CUdeviceptr *pdptr;
3499
+ CUipcMemHandle handle;
3500
+ unsigned int Flags;
3501
+ } cuIpcOpenMemHandle_params;
3502
+
3503
+ typedef struct cuGraphInstantiate_params_st {
3504
+ CUgraphExec *phGraphExec;
3505
+ CUgraph hGraph;
3506
+ CUgraphNode *phErrorNode;
3507
+ char *logBuffer;
3508
+ size_t bufferSize;
3509
+ } cuGraphInstantiate_params;
3510
+
3511
+ typedef struct cuGraphInstantiate_v2_params_st {
3512
+ CUgraphExec *phGraphExec;
3513
+ CUgraph hGraph;
3514
+ CUgraphNode *phErrorNode;
3515
+ char *logBuffer;
3516
+ size_t bufferSize;
3517
+ } cuGraphInstantiate_v2_params;
3518
+
3519
+ typedef struct cuMemMapArrayAsync_params_st {
3520
+ CUarrayMapInfo *mapInfoList;
3521
+ unsigned int count;
3522
+ CUstream hStream;
3523
+ } cuMemMapArrayAsync_params;
3524
+
3525
+ typedef struct cuMemFreeAsync_params_st {
3526
+ CUdeviceptr dptr;
3527
+ CUstream hStream;
3528
+ } cuMemFreeAsync_params;
3529
+
3530
+ typedef struct cuMemAllocAsync_params_st {
3531
+ CUdeviceptr *dptr;
3532
+ size_t bytesize;
3533
+ CUstream hStream;
3534
+ } cuMemAllocAsync_params;
3535
+
3536
+ typedef struct cuMemAllocFromPoolAsync_params_st {
3537
+ CUdeviceptr *dptr;
3538
+ size_t bytesize;
3539
+ CUmemoryPool pool;
3540
+ CUstream hStream;
3541
+ } cuMemAllocFromPoolAsync_params;
3542
+
3543
+ typedef struct cuStreamUpdateCaptureDependencies_params_st {
3544
+ CUstream hStream;
3545
+ CUgraphNode *dependencies;
3546
+ size_t numDependencies;
3547
+ unsigned int flags;
3548
+ } cuStreamUpdateCaptureDependencies_params;
3549
+
3550
+ typedef struct cuStreamUpdateCaptureDependencies_v2_params_st {
3551
+ CUstream hStream;
3552
+ CUgraphNode *dependencies;
3553
+ const CUgraphEdgeData *dependencyData;
3554
+ size_t numDependencies;
3555
+ unsigned int flags;
3556
+ } cuStreamUpdateCaptureDependencies_v2_params;
3557
+
3558
+ typedef struct cuGetProcAddress_params_st {
3559
+ const char *symbol;
3560
+ void **pfn;
3561
+ int cudaVersion;
3562
+ cuuint64_t flags;
3563
+ } cuGetProcAddress_params;