triton-windows 3.3.1.post19__cp312-cp312-win_amd64.whl → 3.4.0.post20__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of triton-windows might be problematic. Click here for more details.
- triton/_C/libtriton.pyd +0 -0
- triton/__init__.py +4 -1
- triton/_filecheck.py +87 -0
- triton/_internal_testing.py +26 -15
- triton/_utils.py +110 -21
- triton/backends/__init__.py +20 -23
- triton/backends/amd/__init__.py +0 -0
- triton/backends/amd/compiler.py +112 -78
- triton/backends/amd/driver.c +5 -2
- triton/backends/amd/driver.py +149 -47
- triton/backends/compiler.py +7 -21
- triton/backends/nvidia/bin/ptxas.exe +0 -0
- triton/backends/nvidia/compiler.py +92 -93
- triton/backends/nvidia/driver.c +90 -98
- triton/backends/nvidia/driver.py +303 -128
- triton/compiler/code_generator.py +212 -111
- triton/compiler/compiler.py +110 -25
- triton/experimental/__init__.py +0 -0
- triton/experimental/gluon/__init__.py +4 -0
- triton/experimental/gluon/_compiler.py +0 -0
- triton/experimental/gluon/_runtime.py +99 -0
- triton/experimental/gluon/language/__init__.py +18 -0
- triton/experimental/gluon/language/_core.py +312 -0
- triton/experimental/gluon/language/_layouts.py +230 -0
- triton/experimental/gluon/language/_math.py +12 -0
- triton/experimental/gluon/language/_semantic.py +287 -0
- triton/experimental/gluon/language/_standard.py +47 -0
- triton/experimental/gluon/language/nvidia/__init__.py +4 -0
- triton/experimental/gluon/language/nvidia/blackwell/__init__.py +202 -0
- triton/experimental/gluon/language/nvidia/blackwell/tma.py +32 -0
- triton/experimental/gluon/language/nvidia/hopper/__init__.py +11 -0
- triton/experimental/gluon/language/nvidia/hopper/mbarrier.py +51 -0
- triton/experimental/gluon/language/nvidia/hopper/tma.py +96 -0
- triton/experimental/gluon/nvidia/__init__.py +4 -0
- triton/experimental/gluon/nvidia/blackwell.py +3 -0
- triton/experimental/gluon/nvidia/hopper.py +40 -0
- triton/knobs.py +481 -0
- triton/language/__init__.py +39 -14
- triton/language/core.py +794 -537
- triton/language/extra/cuda/__init__.py +10 -7
- triton/language/extra/cuda/gdc.py +42 -0
- triton/language/extra/cuda/libdevice.py +394 -394
- triton/language/extra/cuda/utils.py +21 -21
- triton/language/extra/hip/libdevice.py +113 -104
- triton/language/math.py +65 -66
- triton/language/random.py +12 -2
- triton/language/semantic.py +1706 -1770
- triton/language/standard.py +116 -51
- triton/runtime/autotuner.py +117 -59
- triton/runtime/build.py +76 -12
- triton/runtime/cache.py +18 -47
- triton/runtime/driver.py +32 -29
- triton/runtime/interpreter.py +72 -35
- triton/runtime/jit.py +146 -110
- triton/testing.py +16 -12
- triton/tools/disasm.py +3 -4
- triton/tools/tensor_descriptor.py +36 -0
- triton/windows_utils.py +14 -6
- {triton_windows-3.3.1.post19.dist-info → triton_windows-3.4.0.post20.dist-info}/METADATA +7 -2
- triton_windows-3.4.0.post20.dist-info/RECORD +186 -0
- triton_windows-3.4.0.post20.dist-info/entry_points.txt +3 -0
- triton_windows-3.4.0.post20.dist-info/licenses/LICENSE +23 -0
- triton_windows-3.4.0.post20.dist-info/top_level.txt +1 -0
- triton/backends/amd/include/hip/amd_detail/amd_channel_descriptor.h +0 -358
- triton/backends/amd/include/hip/amd_detail/amd_device_functions.h +0 -1010
- triton/backends/amd/include/hip/amd_detail/amd_hip_atomic.h +0 -1638
- triton/backends/amd/include/hip/amd_detail/amd_hip_bf16.h +0 -1814
- triton/backends/amd/include/hip/amd_detail/amd_hip_bfloat16.h +0 -293
- triton/backends/amd/include/hip/amd_detail/amd_hip_common.h +0 -32
- triton/backends/amd/include/hip/amd_detail/amd_hip_complex.h +0 -174
- triton/backends/amd/include/hip/amd_detail/amd_hip_cooperative_groups.h +0 -835
- triton/backends/amd/include/hip/amd_detail/amd_hip_fp16.h +0 -1809
- triton/backends/amd/include/hip/amd_detail/amd_hip_fp8.h +0 -1391
- triton/backends/amd/include/hip/amd_detail/amd_hip_gl_interop.h +0 -108
- triton/backends/amd/include/hip/amd_detail/amd_hip_math_constants.h +0 -124
- triton/backends/amd/include/hip/amd_detail/amd_hip_runtime.h +0 -405
- triton/backends/amd/include/hip/amd_detail/amd_hip_runtime_pt_api.h +0 -196
- triton/backends/amd/include/hip/amd_detail/amd_hip_unsafe_atomics.h +0 -565
- triton/backends/amd/include/hip/amd_detail/amd_hip_vector_types.h +0 -2226
- triton/backends/amd/include/hip/amd_detail/amd_math_functions.h +0 -104
- triton/backends/amd/include/hip/amd_detail/amd_surface_functions.h +0 -244
- triton/backends/amd/include/hip/amd_detail/amd_warp_functions.h +0 -538
- triton/backends/amd/include/hip/amd_detail/amd_warp_sync_functions.h +0 -288
- triton/backends/amd/include/hip/amd_detail/concepts.hpp +0 -30
- triton/backends/amd/include/hip/amd_detail/device_library_decls.h +0 -133
- triton/backends/amd/include/hip/amd_detail/functional_grid_launch.hpp +0 -218
- triton/backends/amd/include/hip/amd_detail/grid_launch.h +0 -67
- triton/backends/amd/include/hip/amd_detail/grid_launch.hpp +0 -50
- triton/backends/amd/include/hip/amd_detail/grid_launch_GGL.hpp +0 -26
- triton/backends/amd/include/hip/amd_detail/helpers.hpp +0 -137
- triton/backends/amd/include/hip/amd_detail/hip_api_trace.hpp +0 -1446
- triton/backends/amd/include/hip/amd_detail/hip_assert.h +0 -101
- triton/backends/amd/include/hip/amd_detail/hip_cooperative_groups_helper.h +0 -242
- triton/backends/amd/include/hip/amd_detail/hip_fp16_gcc.h +0 -254
- triton/backends/amd/include/hip/amd_detail/hip_fp16_math_fwd.h +0 -96
- triton/backends/amd/include/hip/amd_detail/hip_ldg.h +0 -100
- triton/backends/amd/include/hip/amd_detail/hip_prof_str.h +0 -10570
- triton/backends/amd/include/hip/amd_detail/hip_runtime_prof.h +0 -78
- triton/backends/amd/include/hip/amd_detail/host_defines.h +0 -184
- triton/backends/amd/include/hip/amd_detail/hsa_helpers.hpp +0 -102
- triton/backends/amd/include/hip/amd_detail/macro_based_grid_launch.hpp +0 -798
- triton/backends/amd/include/hip/amd_detail/math_fwd.h +0 -698
- triton/backends/amd/include/hip/amd_detail/ockl_image.h +0 -177
- triton/backends/amd/include/hip/amd_detail/program_state.hpp +0 -107
- triton/backends/amd/include/hip/amd_detail/texture_fetch_functions.h +0 -491
- triton/backends/amd/include/hip/amd_detail/texture_indirect_functions.h +0 -478
- triton/backends/amd/include/hip/channel_descriptor.h +0 -39
- triton/backends/amd/include/hip/device_functions.h +0 -38
- triton/backends/amd/include/hip/driver_types.h +0 -468
- triton/backends/amd/include/hip/hip_bf16.h +0 -36
- triton/backends/amd/include/hip/hip_bfloat16.h +0 -44
- triton/backends/amd/include/hip/hip_common.h +0 -100
- triton/backends/amd/include/hip/hip_complex.h +0 -38
- triton/backends/amd/include/hip/hip_cooperative_groups.h +0 -46
- triton/backends/amd/include/hip/hip_deprecated.h +0 -95
- triton/backends/amd/include/hip/hip_ext.h +0 -161
- triton/backends/amd/include/hip/hip_fp16.h +0 -36
- triton/backends/amd/include/hip/hip_fp8.h +0 -33
- triton/backends/amd/include/hip/hip_gl_interop.h +0 -32
- triton/backends/amd/include/hip/hip_hcc.h +0 -24
- triton/backends/amd/include/hip/hip_math_constants.h +0 -36
- triton/backends/amd/include/hip/hip_profile.h +0 -27
- triton/backends/amd/include/hip/hip_runtime.h +0 -75
- triton/backends/amd/include/hip/hip_runtime_api.h +0 -9261
- triton/backends/amd/include/hip/hip_texture_types.h +0 -29
- triton/backends/amd/include/hip/hip_vector_types.h +0 -41
- triton/backends/amd/include/hip/hip_version.h +0 -17
- triton/backends/amd/include/hip/hiprtc.h +0 -421
- triton/backends/amd/include/hip/library_types.h +0 -78
- triton/backends/amd/include/hip/math_functions.h +0 -42
- triton/backends/amd/include/hip/surface_types.h +0 -63
- triton/backends/amd/include/hip/texture_types.h +0 -194
- triton/backends/amd/include/hsa/Brig.h +0 -1131
- triton/backends/amd/include/hsa/amd_hsa_common.h +0 -91
- triton/backends/amd/include/hsa/amd_hsa_elf.h +0 -462
- triton/backends/amd/include/hsa/amd_hsa_kernel_code.h +0 -269
- triton/backends/amd/include/hsa/amd_hsa_queue.h +0 -109
- triton/backends/amd/include/hsa/amd_hsa_signal.h +0 -80
- triton/backends/amd/include/hsa/hsa.h +0 -5738
- triton/backends/amd/include/hsa/hsa_amd_tool.h +0 -91
- triton/backends/amd/include/hsa/hsa_api_trace.h +0 -579
- triton/backends/amd/include/hsa/hsa_api_trace_version.h +0 -68
- triton/backends/amd/include/hsa/hsa_ext_amd.h +0 -3146
- triton/backends/amd/include/hsa/hsa_ext_finalize.h +0 -531
- triton/backends/amd/include/hsa/hsa_ext_image.h +0 -1454
- triton/backends/amd/include/hsa/hsa_ven_amd_aqlprofile.h +0 -488
- triton/backends/amd/include/hsa/hsa_ven_amd_loader.h +0 -667
- triton/backends/amd/include/hsa/hsa_ven_amd_pc_sampling.h +0 -416
- triton/backends/amd/include/roctracer/ext/prof_protocol.h +0 -107
- triton/backends/amd/include/roctracer/hip_ostream_ops.h +0 -4515
- triton/backends/amd/include/roctracer/hsa_ostream_ops.h +0 -1727
- triton/backends/amd/include/roctracer/hsa_prof_str.h +0 -3059
- triton/backends/amd/include/roctracer/roctracer.h +0 -779
- triton/backends/amd/include/roctracer/roctracer_ext.h +0 -81
- triton/backends/amd/include/roctracer/roctracer_hcc.h +0 -24
- triton/backends/amd/include/roctracer/roctracer_hip.h +0 -37
- triton/backends/amd/include/roctracer/roctracer_hsa.h +0 -112
- triton/backends/amd/include/roctracer/roctracer_plugin.h +0 -137
- triton/backends/amd/include/roctracer/roctracer_roctx.h +0 -67
- triton/backends/amd/include/roctracer/roctx.h +0 -229
- triton/language/_utils.py +0 -21
- triton/language/extra/cuda/_experimental_tma.py +0 -106
- triton/tools/experimental_descriptor.py +0 -32
- triton_windows-3.3.1.post19.dist-info/RECORD +0 -260
- triton_windows-3.3.1.post19.dist-info/top_level.txt +0 -14
- {triton_windows-3.3.1.post19.dist-info → triton_windows-3.4.0.post20.dist-info}/WHEEL +0 -0
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 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
|
-
// Warp sync builtins (with explicit mask argument) introduced in ROCm 6.2 as a
|
|
26
|
-
// preview to allow end-users to adapt to the new interface involving 64-bit
|
|
27
|
-
// masks. These are disabled by default, and can be enabled by setting the macro
|
|
28
|
-
// below. The builtins will be enabled unconditionally in ROCm 6.3.
|
|
29
|
-
//
|
|
30
|
-
// This arrangement also applies to the __activemask() builtin defined in
|
|
31
|
-
// amd_warp_functions.h.
|
|
32
|
-
#ifdef HIP_ENABLE_WARP_SYNC_BUILTINS
|
|
33
|
-
|
|
34
|
-
#if !defined(__HIPCC_RTC__)
|
|
35
|
-
#include "amd_warp_functions.h"
|
|
36
|
-
#include "hip_assert.h"
|
|
37
|
-
#endif
|
|
38
|
-
|
|
39
|
-
template <typename T>
|
|
40
|
-
__device__ inline
|
|
41
|
-
T __hip_readfirstlane(T val) {
|
|
42
|
-
// In theory, behaviour is undefined when reading from a union member other
|
|
43
|
-
// than the member that was last assigned to, but it works in practice because
|
|
44
|
-
// we rely on the compiler to do the reasonable thing.
|
|
45
|
-
union {
|
|
46
|
-
unsigned long long l;
|
|
47
|
-
T d;
|
|
48
|
-
} u;
|
|
49
|
-
u.d = val;
|
|
50
|
-
// NOTE: The builtin returns int, so we first cast it to unsigned int and only
|
|
51
|
-
// then extend it to 64 bits.
|
|
52
|
-
unsigned long long lower = (unsigned)__builtin_amdgcn_readfirstlane(u.l);
|
|
53
|
-
unsigned long long upper =
|
|
54
|
-
(unsigned)__builtin_amdgcn_readfirstlane(u.l >> 32);
|
|
55
|
-
u.l = (upper << 32) | lower;
|
|
56
|
-
return u.d;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// When compiling for wave32 mode, ignore the upper half of the 64-bit mask.
|
|
60
|
-
#define __hip_adjust_mask_for_wave32(MASK) \
|
|
61
|
-
do { \
|
|
62
|
-
if (warpSize == 32) MASK &= 0xFFFFFFFF; \
|
|
63
|
-
} while (0)
|
|
64
|
-
|
|
65
|
-
// We use a macro to expand each builtin into a waterfall that implements the
|
|
66
|
-
// mask semantics:
|
|
67
|
-
//
|
|
68
|
-
// 1. The mask argument may be divergent.
|
|
69
|
-
// 2. Each active thread must have its own bit set in its own mask value.
|
|
70
|
-
// 3. For a given mask value, all threads that are mentioned in the mask must
|
|
71
|
-
// execute the same static instance of the builtin with the same mask.
|
|
72
|
-
// 4. The union of all mask values supplied at a static instance must be equal
|
|
73
|
-
// to the activemask at the program point.
|
|
74
|
-
//
|
|
75
|
-
// Thus, the mask argument partitions the set of currently active threads in the
|
|
76
|
-
// wave into disjoint subsets that cover all active threads.
|
|
77
|
-
//
|
|
78
|
-
// Implementation notes:
|
|
79
|
-
// ---------------------
|
|
80
|
-
//
|
|
81
|
-
// We implement this as a waterfall loop that executes the builtin for each
|
|
82
|
-
// subset separately. The return value is a divergent value across the active
|
|
83
|
-
// threads. The value for inactive threads is defined by each builtin
|
|
84
|
-
// separately.
|
|
85
|
-
//
|
|
86
|
-
// As long as every mask value is non-zero, we don't need to check if a lane
|
|
87
|
-
// specifies itself in the mask; that is done by the later assertion where all
|
|
88
|
-
// chosen lanes must be in the chosen mask.
|
|
89
|
-
|
|
90
|
-
#define __hip_check_mask(MASK) \
|
|
91
|
-
do { \
|
|
92
|
-
__hip_assert(MASK && "mask must be non-zero"); \
|
|
93
|
-
bool done = false; \
|
|
94
|
-
while (__any(!done)) { \
|
|
95
|
-
if (!done) { \
|
|
96
|
-
auto chosen_mask = __hip_readfirstlane(MASK); \
|
|
97
|
-
if (MASK == chosen_mask) { \
|
|
98
|
-
__hip_assert(MASK == __ballot(true) && \
|
|
99
|
-
"all threads specified in the mask" \
|
|
100
|
-
" must execute the same operation with the same mask"); \
|
|
101
|
-
done = true; \
|
|
102
|
-
} \
|
|
103
|
-
} \
|
|
104
|
-
} \
|
|
105
|
-
} while(0)
|
|
106
|
-
|
|
107
|
-
#define __hip_do_sync(RETVAL, FUNC, MASK, ...) \
|
|
108
|
-
do { \
|
|
109
|
-
__hip_assert(MASK && "mask must be non-zero"); \
|
|
110
|
-
bool done = false; \
|
|
111
|
-
while (__any(!done)) { \
|
|
112
|
-
if (!done) { \
|
|
113
|
-
auto chosen_mask = __hip_readfirstlane(MASK); \
|
|
114
|
-
if (MASK == chosen_mask) { \
|
|
115
|
-
__hip_assert(MASK == __ballot(true) && \
|
|
116
|
-
"all threads specified in the mask" \
|
|
117
|
-
" must execute the same operation with the same mask"); \
|
|
118
|
-
RETVAL = FUNC(__VA_ARGS__); \
|
|
119
|
-
done = true; \
|
|
120
|
-
} \
|
|
121
|
-
} \
|
|
122
|
-
} \
|
|
123
|
-
} while(0)
|
|
124
|
-
|
|
125
|
-
// __all_sync, __any_sync, __ballot_sync
|
|
126
|
-
|
|
127
|
-
template <typename MaskT>
|
|
128
|
-
__device__ inline
|
|
129
|
-
unsigned long long __ballot_sync(MaskT mask, int predicate) {
|
|
130
|
-
static_assert(
|
|
131
|
-
__hip_internal::is_integral<MaskT>::value && sizeof(MaskT) == 8,
|
|
132
|
-
"The mask must be a 64-bit integer. "
|
|
133
|
-
"Implicitly promoting a smaller integer is almost always an error.");
|
|
134
|
-
__hip_adjust_mask_for_wave32(mask);
|
|
135
|
-
__hip_check_mask(mask);
|
|
136
|
-
return __ballot(predicate) & mask;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
template <typename MaskT>
|
|
140
|
-
__device__ inline
|
|
141
|
-
int __all_sync(MaskT mask, int predicate) {
|
|
142
|
-
static_assert(
|
|
143
|
-
__hip_internal::is_integral<MaskT>::value && sizeof(MaskT) == 8,
|
|
144
|
-
"The mask must be a 64-bit integer. "
|
|
145
|
-
"Implicitly promoting a smaller integer is almost always an error.");
|
|
146
|
-
__hip_adjust_mask_for_wave32(mask);
|
|
147
|
-
return __ballot_sync(mask, predicate) == mask;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
template <typename MaskT>
|
|
151
|
-
__device__ inline
|
|
152
|
-
int __any_sync(MaskT mask, int predicate) {
|
|
153
|
-
static_assert(
|
|
154
|
-
__hip_internal::is_integral<MaskT>::value && sizeof(MaskT) == 8,
|
|
155
|
-
"The mask must be a 64-bit integer. "
|
|
156
|
-
"Implicitly promoting a smaller integer is almost always an error.");
|
|
157
|
-
__hip_adjust_mask_for_wave32(mask);
|
|
158
|
-
return __ballot_sync(mask, predicate) != 0;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// __match_any, __match_all and sync variants
|
|
162
|
-
|
|
163
|
-
template <typename T>
|
|
164
|
-
__device__ inline
|
|
165
|
-
unsigned long long __match_any(T value) {
|
|
166
|
-
static_assert(
|
|
167
|
-
(__hip_internal::is_integral<T>::value || __hip_internal::is_floating_point<T>::value) &&
|
|
168
|
-
(sizeof(T) == 4 || sizeof(T) == 8),
|
|
169
|
-
"T can be int, unsigned int, long, unsigned long, long long, unsigned "
|
|
170
|
-
"long long, float or double.");
|
|
171
|
-
bool done = false;
|
|
172
|
-
unsigned long long retval = 0;
|
|
173
|
-
|
|
174
|
-
while (__any(!done)) {
|
|
175
|
-
if (!done) {
|
|
176
|
-
T chosen = __hip_readfirstlane(value);
|
|
177
|
-
if (chosen == value) {
|
|
178
|
-
retval = __activemask();
|
|
179
|
-
done = true;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return retval;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
template <typename MaskT, typename T>
|
|
188
|
-
__device__ inline
|
|
189
|
-
unsigned long long __match_any_sync(MaskT mask, T value) {
|
|
190
|
-
static_assert(
|
|
191
|
-
__hip_internal::is_integral<MaskT>::value && sizeof(MaskT) == 8,
|
|
192
|
-
"The mask must be a 64-bit integer. "
|
|
193
|
-
"Implicitly promoting a smaller integer is almost always an error.");
|
|
194
|
-
__hip_adjust_mask_for_wave32(mask);
|
|
195
|
-
__hip_check_mask(mask);
|
|
196
|
-
return __match_any(value) & mask;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
template <typename T>
|
|
200
|
-
__device__ inline
|
|
201
|
-
unsigned long long __match_all(T value, int* pred) {
|
|
202
|
-
static_assert(
|
|
203
|
-
(__hip_internal::is_integral<T>::value || __hip_internal::is_floating_point<T>::value) &&
|
|
204
|
-
(sizeof(T) == 4 || sizeof(T) == 8),
|
|
205
|
-
"T can be int, unsigned int, long, unsigned long, long long, unsigned "
|
|
206
|
-
"long long, float or double.");
|
|
207
|
-
T first = __hip_readfirstlane(value);
|
|
208
|
-
if (__all(first == value)) {
|
|
209
|
-
*pred = true;
|
|
210
|
-
return __activemask();
|
|
211
|
-
} else {
|
|
212
|
-
*pred = false;
|
|
213
|
-
return 0;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
template <typename MaskT, typename T>
|
|
218
|
-
__device__ inline
|
|
219
|
-
unsigned long long __match_all_sync(MaskT mask, T value, int* pred) {
|
|
220
|
-
static_assert(
|
|
221
|
-
__hip_internal::is_integral<MaskT>::value && sizeof(MaskT) == 8,
|
|
222
|
-
"The mask must be a 64-bit integer. "
|
|
223
|
-
"Implicitly promoting a smaller integer is almost always an error.");
|
|
224
|
-
MaskT retval = 0;
|
|
225
|
-
__hip_adjust_mask_for_wave32(mask);
|
|
226
|
-
__hip_do_sync(retval, __match_all, mask, value, pred);
|
|
227
|
-
return retval;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// various variants of shfl
|
|
231
|
-
|
|
232
|
-
template <typename MaskT, typename T>
|
|
233
|
-
__device__ inline
|
|
234
|
-
T __shfl_sync(MaskT mask, T var, int srcLane,
|
|
235
|
-
int width = __AMDGCN_WAVEFRONT_SIZE) {
|
|
236
|
-
static_assert(
|
|
237
|
-
__hip_internal::is_integral<MaskT>::value && sizeof(MaskT) == 8,
|
|
238
|
-
"The mask must be a 64-bit integer. "
|
|
239
|
-
"Implicitly promoting a smaller integer is almost always an error.");
|
|
240
|
-
__hip_adjust_mask_for_wave32(mask);
|
|
241
|
-
__hip_check_mask(mask);
|
|
242
|
-
return __shfl(var, srcLane, width);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
template <typename MaskT, typename T>
|
|
246
|
-
__device__ inline
|
|
247
|
-
T __shfl_up_sync(MaskT mask, T var, unsigned int delta,
|
|
248
|
-
int width = __AMDGCN_WAVEFRONT_SIZE) {
|
|
249
|
-
static_assert(
|
|
250
|
-
__hip_internal::is_integral<MaskT>::value && sizeof(MaskT) == 8,
|
|
251
|
-
"The mask must be a 64-bit integer. "
|
|
252
|
-
"Implicitly promoting a smaller integer is almost always an error.");
|
|
253
|
-
__hip_adjust_mask_for_wave32(mask);
|
|
254
|
-
__hip_check_mask(mask);
|
|
255
|
-
return __shfl_up(var, delta, width);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
template <typename MaskT, typename T>
|
|
259
|
-
__device__ inline
|
|
260
|
-
T __shfl_down_sync(MaskT mask, T var, unsigned int delta,
|
|
261
|
-
int width = __AMDGCN_WAVEFRONT_SIZE) {
|
|
262
|
-
static_assert(
|
|
263
|
-
__hip_internal::is_integral<MaskT>::value && sizeof(MaskT) == 8,
|
|
264
|
-
"The mask must be a 64-bit integer. "
|
|
265
|
-
"Implicitly promoting a smaller integer is almost always an error.");
|
|
266
|
-
__hip_adjust_mask_for_wave32(mask);
|
|
267
|
-
__hip_check_mask(mask);
|
|
268
|
-
return __shfl_down(var, delta, width);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
template <typename MaskT, typename T>
|
|
272
|
-
__device__ inline
|
|
273
|
-
T __shfl_xor_sync(MaskT mask, T var, int laneMask,
|
|
274
|
-
int width = __AMDGCN_WAVEFRONT_SIZE) {
|
|
275
|
-
static_assert(
|
|
276
|
-
__hip_internal::is_integral<MaskT>::value && sizeof(MaskT) == 8,
|
|
277
|
-
"The mask must be a 64-bit integer. "
|
|
278
|
-
"Implicitly promoting a smaller integer is almost always an error.");
|
|
279
|
-
__hip_adjust_mask_for_wave32(mask);
|
|
280
|
-
__hip_check_mask(mask);
|
|
281
|
-
return __shfl_xor(var, laneMask, width);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
#undef __hip_do_sync
|
|
285
|
-
#undef __hip_check_mask
|
|
286
|
-
#undef __hip_adjust_mask_for_wave32
|
|
287
|
-
|
|
288
|
-
#endif // HIP_ENABLE_WARP_SYNC_BUILTINS
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
|
@@ -1,133 +0,0 @@
|
|
|
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
|
-
/**
|
|
24
|
-
* @file amd_detail/device_library_decls.h
|
|
25
|
-
* @brief Contains declarations for types and functions in device library.
|
|
26
|
-
* Uses int64_t and uint64_t instead of long, long long, unsigned
|
|
27
|
-
* long and unsigned long long types for device library API
|
|
28
|
-
* declarations.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_DEVICE_LIBRARY_DECLS_H
|
|
32
|
-
#define HIP_INCLUDE_HIP_AMD_DETAIL_DEVICE_LIBRARY_DECLS_H
|
|
33
|
-
|
|
34
|
-
#if !defined(__HIPCC_RTC__)
|
|
35
|
-
#include "hip/amd_detail/host_defines.h"
|
|
36
|
-
#endif
|
|
37
|
-
|
|
38
|
-
typedef unsigned char uchar;
|
|
39
|
-
typedef unsigned short ushort;
|
|
40
|
-
typedef unsigned int uint;
|
|
41
|
-
typedef unsigned long ulong;
|
|
42
|
-
typedef unsigned long long ullong;
|
|
43
|
-
|
|
44
|
-
extern "C" __device__ __attribute__((const)) bool __ockl_wfany_i32(int);
|
|
45
|
-
extern "C" __device__ __attribute__((const)) bool __ockl_wfall_i32(int);
|
|
46
|
-
extern "C" __device__ uint __ockl_activelane_u32(void);
|
|
47
|
-
|
|
48
|
-
extern "C" __device__ __attribute__((const)) uint __ockl_mul24_u32(uint, uint);
|
|
49
|
-
extern "C" __device__ __attribute__((const)) int __ockl_mul24_i32(int, int);
|
|
50
|
-
extern "C" __device__ __attribute__((const)) uint __ockl_mul_hi_u32(uint, uint);
|
|
51
|
-
extern "C" __device__ __attribute__((const)) int __ockl_mul_hi_i32(int, int);
|
|
52
|
-
extern "C" __device__ __attribute__((const)) uint __ockl_sadd_u32(uint, uint, uint);
|
|
53
|
-
|
|
54
|
-
extern "C" __device__ __attribute__((const)) uchar __ockl_clz_u8(uchar);
|
|
55
|
-
extern "C" __device__ __attribute__((const)) ushort __ockl_clz_u16(ushort);
|
|
56
|
-
extern "C" __device__ __attribute__((const)) uint __ockl_clz_u32(uint);
|
|
57
|
-
extern "C" __device__ __attribute__((const)) uint64_t __ockl_clz_u64(uint64_t);
|
|
58
|
-
|
|
59
|
-
extern "C" __device__ __attribute__((const)) float __ocml_floor_f32(float);
|
|
60
|
-
extern "C" __device__ __attribute__((const)) float __ocml_rint_f32(float);
|
|
61
|
-
extern "C" __device__ __attribute__((const)) float __ocml_ceil_f32(float);
|
|
62
|
-
extern "C" __device__ __attribute__((const)) float __ocml_trunc_f32(float);
|
|
63
|
-
|
|
64
|
-
extern "C" __device__ __attribute__((const)) float __ocml_fmin_f32(float, float);
|
|
65
|
-
extern "C" __device__ __attribute__((const)) float __ocml_fmax_f32(float, float);
|
|
66
|
-
|
|
67
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtn_f32_f64(double);
|
|
68
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtp_f32_f64(double);
|
|
69
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtz_f32_f64(double);
|
|
70
|
-
|
|
71
|
-
extern "C" __device__ __attribute__((const)) _Float16 __ocml_cvtrtn_f16_f32(float);
|
|
72
|
-
extern "C" __device__ __attribute__((const)) _Float16 __ocml_cvtrtp_f16_f32(float);
|
|
73
|
-
extern "C" __device__ __attribute__((const)) _Float16 __ocml_cvtrtz_f16_f32(float);
|
|
74
|
-
|
|
75
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtn_f32_s32(int);
|
|
76
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtp_f32_s32(int);
|
|
77
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtz_f32_s32(int);
|
|
78
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtn_f32_u32(uint32_t);
|
|
79
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtp_f32_u32(uint32_t);
|
|
80
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtz_f32_u32(uint32_t);
|
|
81
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtn_f32_s64(int64_t);
|
|
82
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtp_f32_s64(int64_t);
|
|
83
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtz_f32_s64(int64_t);
|
|
84
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtn_f32_u64(uint64_t);
|
|
85
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtp_f32_u64(uint64_t);
|
|
86
|
-
extern "C" __device__ __attribute__((const)) float __ocml_cvtrtz_f32_u64(uint64_t);
|
|
87
|
-
extern "C" __device__ __attribute__((const)) double __ocml_cvtrtn_f64_s64(int64_t);
|
|
88
|
-
extern "C" __device__ __attribute__((const)) double __ocml_cvtrtp_f64_s64(int64_t);
|
|
89
|
-
extern "C" __device__ __attribute__((const)) double __ocml_cvtrtz_f64_s64(int64_t);
|
|
90
|
-
extern "C" __device__ __attribute__((const)) double __ocml_cvtrtn_f64_u64(uint64_t);
|
|
91
|
-
extern "C" __device__ __attribute__((const)) double __ocml_cvtrtp_f64_u64(uint64_t);
|
|
92
|
-
extern "C" __device__ __attribute__((const)) double __ocml_cvtrtz_f64_u64(uint64_t);
|
|
93
|
-
|
|
94
|
-
extern "C" __device__ __attribute__((convergent)) void __ockl_gws_init(uint nwm1, uint rid);
|
|
95
|
-
extern "C" __device__ __attribute__((convergent)) void __ockl_gws_barrier(uint nwm1, uint rid);
|
|
96
|
-
|
|
97
|
-
extern "C" __device__ __attribute__((const)) uint32_t __ockl_lane_u32();
|
|
98
|
-
extern "C" __device__ __attribute__((const)) int __ockl_grid_is_valid(void);
|
|
99
|
-
extern "C" __device__ __attribute__((convergent)) void __ockl_grid_sync(void);
|
|
100
|
-
extern "C" __device__ __attribute__((const)) uint __ockl_multi_grid_num_grids(void);
|
|
101
|
-
extern "C" __device__ __attribute__((const)) uint __ockl_multi_grid_grid_rank(void);
|
|
102
|
-
extern "C" __device__ __attribute__((const)) uint __ockl_multi_grid_size(void);
|
|
103
|
-
extern "C" __device__ __attribute__((const)) uint __ockl_multi_grid_thread_rank(void);
|
|
104
|
-
extern "C" __device__ __attribute__((const)) int __ockl_multi_grid_is_valid(void);
|
|
105
|
-
extern "C" __device__ __attribute__((convergent)) void __ockl_multi_grid_sync(void);
|
|
106
|
-
|
|
107
|
-
extern "C" __device__ void __ockl_atomic_add_noret_f32(float*, float);
|
|
108
|
-
|
|
109
|
-
extern "C" __device__ __attribute__((convergent)) int __ockl_wgred_add_i32(int a);
|
|
110
|
-
extern "C" __device__ __attribute__((convergent)) int __ockl_wgred_and_i32(int a);
|
|
111
|
-
extern "C" __device__ __attribute__((convergent)) int __ockl_wgred_or_i32(int a);
|
|
112
|
-
|
|
113
|
-
extern "C" __device__ uint64_t __ockl_fprintf_stderr_begin();
|
|
114
|
-
extern "C" __device__ uint64_t __ockl_fprintf_append_args(uint64_t msg_desc, uint32_t num_args,
|
|
115
|
-
uint64_t value0, uint64_t value1,
|
|
116
|
-
uint64_t value2, uint64_t value3,
|
|
117
|
-
uint64_t value4, uint64_t value5,
|
|
118
|
-
uint64_t value6, uint32_t is_last);
|
|
119
|
-
extern "C" __device__ uint64_t __ockl_fprintf_append_string_n(uint64_t msg_desc, const char* data,
|
|
120
|
-
uint64_t length, uint32_t is_last);
|
|
121
|
-
|
|
122
|
-
// Introduce local address space
|
|
123
|
-
#define __local __attribute__((address_space(3)))
|
|
124
|
-
|
|
125
|
-
#ifdef __HIP_DEVICE_COMPILE__
|
|
126
|
-
__device__ inline static __local void* __to_local(unsigned x) { return (__local void*)x; }
|
|
127
|
-
#endif //__HIP_DEVICE_COMPILE__
|
|
128
|
-
|
|
129
|
-
// Using hip.amdgcn.bc - sync threads
|
|
130
|
-
#define __CLK_LOCAL_MEM_FENCE 0x01
|
|
131
|
-
typedef unsigned __cl_mem_fence_flags;
|
|
132
|
-
|
|
133
|
-
#endif
|
|
@@ -1,218 +0,0 @@
|
|
|
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
|
-
#include "program_state.hpp"
|
|
28
|
-
#include "hip_runtime_api.h"
|
|
29
|
-
|
|
30
|
-
#include <cstdint>
|
|
31
|
-
#include <cstring>
|
|
32
|
-
#include <stdexcept>
|
|
33
|
-
#include <tuple>
|
|
34
|
-
#include <type_traits>
|
|
35
|
-
#include <utility>
|
|
36
|
-
|
|
37
|
-
hipError_t ihipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList, int numDevices,
|
|
38
|
-
unsigned int flags, hip_impl::program_state& ps);
|
|
39
|
-
|
|
40
|
-
hipError_t hipLaunchCooperativeKernel(const void* f, dim3 gridDim,
|
|
41
|
-
dim3 blockDim, void** args,
|
|
42
|
-
size_t sharedMem, hipStream_t stream,
|
|
43
|
-
hip_impl::program_state& ps);
|
|
44
|
-
|
|
45
|
-
hipError_t hipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsList,
|
|
46
|
-
int numDevices,
|
|
47
|
-
unsigned int flags,
|
|
48
|
-
hip_impl::program_state& ps);
|
|
49
|
-
|
|
50
|
-
#pragma GCC visibility push(hidden)
|
|
51
|
-
|
|
52
|
-
namespace hip_impl {
|
|
53
|
-
template <typename T, typename std::enable_if<std::is_integral<T>{}>::type* = nullptr>
|
|
54
|
-
inline T round_up_to_next_multiple_nonnegative(T x, T y) {
|
|
55
|
-
T tmp = x + y - 1;
|
|
56
|
-
return tmp - tmp % y;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
template <
|
|
60
|
-
std::size_t n,
|
|
61
|
-
typename... Ts,
|
|
62
|
-
typename std::enable_if<n == sizeof...(Ts)>::type* = nullptr>
|
|
63
|
-
inline hip_impl::kernarg make_kernarg(
|
|
64
|
-
const std::tuple<Ts...>&,
|
|
65
|
-
const kernargs_size_align&,
|
|
66
|
-
hip_impl::kernarg kernarg) {
|
|
67
|
-
return kernarg;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
template <
|
|
71
|
-
std::size_t n,
|
|
72
|
-
typename... Ts,
|
|
73
|
-
typename std::enable_if<n != sizeof...(Ts)>::type* = nullptr>
|
|
74
|
-
inline hip_impl::kernarg make_kernarg(
|
|
75
|
-
const std::tuple<Ts...>& formals,
|
|
76
|
-
const kernargs_size_align& size_align,
|
|
77
|
-
hip_impl::kernarg kernarg) {
|
|
78
|
-
using T = typename std::tuple_element<n, std::tuple<Ts...>>::type;
|
|
79
|
-
|
|
80
|
-
static_assert(
|
|
81
|
-
!std::is_reference<T>{},
|
|
82
|
-
"A __global__ function cannot have a reference as one of its "
|
|
83
|
-
"arguments.");
|
|
84
|
-
#if defined(HIP_STRICT)
|
|
85
|
-
static_assert(
|
|
86
|
-
std::is_trivially_copyable<T>{},
|
|
87
|
-
"Only TriviallyCopyable types can be arguments to a __global__ "
|
|
88
|
-
"function");
|
|
89
|
-
#endif
|
|
90
|
-
|
|
91
|
-
kernarg.resize(round_up_to_next_multiple_nonnegative(
|
|
92
|
-
kernarg.size(), size_align.alignment(n)) + size_align.size(n));
|
|
93
|
-
|
|
94
|
-
std::memcpy(
|
|
95
|
-
kernarg.data() + kernarg.size() - size_align.size(n),
|
|
96
|
-
&std::get<n>(formals),
|
|
97
|
-
size_align.size(n));
|
|
98
|
-
return make_kernarg<n + 1>(formals, size_align, std::move(kernarg));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
template <typename... Formals, typename... Actuals>
|
|
102
|
-
inline hip_impl::kernarg make_kernarg(
|
|
103
|
-
void (*kernel)(Formals...), std::tuple<Actuals...> actuals) {
|
|
104
|
-
static_assert(sizeof...(Formals) == sizeof...(Actuals),
|
|
105
|
-
"The count of formal arguments must match the count of actuals.");
|
|
106
|
-
|
|
107
|
-
if (sizeof...(Formals) == 0) return {};
|
|
108
|
-
|
|
109
|
-
std::tuple<Formals...> to_formals{std::move(actuals)};
|
|
110
|
-
hip_impl::kernarg kernarg;
|
|
111
|
-
kernarg.reserve(sizeof(to_formals));
|
|
112
|
-
|
|
113
|
-
auto& ps = hip_impl::get_program_state();
|
|
114
|
-
return make_kernarg<0>(to_formals,
|
|
115
|
-
ps.get_kernargs_size_align(
|
|
116
|
-
reinterpret_cast<std::uintptr_t>(kernel)),
|
|
117
|
-
std::move(kernarg));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
HIP_INTERNAL_EXPORTED_API hsa_agent_t target_agent(hipStream_t stream);
|
|
122
|
-
|
|
123
|
-
inline
|
|
124
|
-
__attribute__((visibility("hidden")))
|
|
125
|
-
void hipLaunchKernelGGLImpl(
|
|
126
|
-
std::uintptr_t function_address,
|
|
127
|
-
const dim3& numBlocks,
|
|
128
|
-
const dim3& dimBlocks,
|
|
129
|
-
std::uint32_t sharedMemBytes,
|
|
130
|
-
hipStream_t stream,
|
|
131
|
-
void** kernarg) {
|
|
132
|
-
|
|
133
|
-
const auto& kd = hip_impl::get_program_state().kernel_descriptor(function_address,
|
|
134
|
-
target_agent(stream));
|
|
135
|
-
|
|
136
|
-
hipModuleLaunchKernel(kd, numBlocks.x, numBlocks.y, numBlocks.z,
|
|
137
|
-
dimBlocks.x, dimBlocks.y, dimBlocks.z, sharedMemBytes,
|
|
138
|
-
stream, nullptr, kernarg);
|
|
139
|
-
}
|
|
140
|
-
} // Namespace hip_impl.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
template <class T>
|
|
144
|
-
inline
|
|
145
|
-
hipError_t hipOccupancyMaxPotentialBlockSize(int* gridSize, int* blockSize,
|
|
146
|
-
T kernel, size_t dynSharedMemPerBlk = 0, int blockSizeLimit = 0) {
|
|
147
|
-
|
|
148
|
-
using namespace hip_impl;
|
|
149
|
-
|
|
150
|
-
hip_impl::hip_init();
|
|
151
|
-
auto f = get_program_state().kernel_descriptor(reinterpret_cast<std::uintptr_t>(kernel),
|
|
152
|
-
target_agent(0));
|
|
153
|
-
|
|
154
|
-
return hipModuleOccupancyMaxPotentialBlockSize(gridSize, blockSize, f,
|
|
155
|
-
dynSharedMemPerBlk, blockSizeLimit);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
template <class T>
|
|
159
|
-
inline
|
|
160
|
-
hipError_t hipOccupancyMaxPotentialBlockSizeWithFlags(int* gridSize, int* blockSize,
|
|
161
|
-
T kernel, size_t dynSharedMemPerBlk = 0, int blockSizeLimit = 0, unsigned int flags = 0 ) {
|
|
162
|
-
|
|
163
|
-
using namespace hip_impl;
|
|
164
|
-
|
|
165
|
-
hip_impl::hip_init();
|
|
166
|
-
if(flags != hipOccupancyDefault) return hipErrorNotSupported;
|
|
167
|
-
auto f = get_program_state().kernel_descriptor(reinterpret_cast<std::uintptr_t>(kernel),
|
|
168
|
-
target_agent(0));
|
|
169
|
-
|
|
170
|
-
return hipModuleOccupancyMaxPotentialBlockSize(gridSize, blockSize, f,
|
|
171
|
-
dynSharedMemPerBlk, blockSizeLimit);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
template <typename... Args, typename F = void (*)(Args...)>
|
|
175
|
-
inline
|
|
176
|
-
void hipLaunchKernelGGL(F kernel, const dim3& numBlocks, const dim3& dimBlocks,
|
|
177
|
-
std::uint32_t sharedMemBytes, hipStream_t stream,
|
|
178
|
-
Args... args) {
|
|
179
|
-
hip_impl::hip_init();
|
|
180
|
-
auto kernarg = hip_impl::make_kernarg(kernel, std::tuple<Args...>{std::move(args)...});
|
|
181
|
-
std::size_t kernarg_size = kernarg.size();
|
|
182
|
-
|
|
183
|
-
void* config[]{
|
|
184
|
-
HIP_LAUNCH_PARAM_BUFFER_POINTER,
|
|
185
|
-
kernarg.data(),
|
|
186
|
-
HIP_LAUNCH_PARAM_BUFFER_SIZE,
|
|
187
|
-
&kernarg_size,
|
|
188
|
-
HIP_LAUNCH_PARAM_END};
|
|
189
|
-
|
|
190
|
-
hip_impl::hipLaunchKernelGGLImpl(reinterpret_cast<std::uintptr_t>(kernel),
|
|
191
|
-
numBlocks, dimBlocks, sharedMemBytes,
|
|
192
|
-
stream, &config[0]);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
template <typename F>
|
|
196
|
-
inline
|
|
197
|
-
__attribute__((visibility("hidden")))
|
|
198
|
-
hipError_t hipLaunchCooperativeKernel(F f, dim3 gridDim, dim3 blockDim,
|
|
199
|
-
void** args, size_t sharedMem,
|
|
200
|
-
hipStream_t stream) {
|
|
201
|
-
hip_impl::hip_init();
|
|
202
|
-
auto& ps = hip_impl::get_program_state();
|
|
203
|
-
return hipLaunchCooperativeKernel(reinterpret_cast<void*>(f), gridDim,
|
|
204
|
-
blockDim, args, sharedMem, stream, ps);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
inline
|
|
208
|
-
__attribute__((visibility("hidden")))
|
|
209
|
-
hipError_t hipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsList,
|
|
210
|
-
int numDevices,
|
|
211
|
-
unsigned int flags) {
|
|
212
|
-
|
|
213
|
-
hip_impl::hip_init();
|
|
214
|
-
auto& ps = hip_impl::get_program_state();
|
|
215
|
-
return hipLaunchCooperativeKernelMultiDevice(launchParamsList, numDevices, flags, ps);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
#pragma GCC visibility pop
|