23 #ifndef HIP_INCLUDE_HIP_HIP_EXT_H
24 #define HIP_INCLUDE_HIP_HIP_EXT_H
25 #include "hip/hip_runtime.h"
26 #if defined(__cplusplus)
28 #include <type_traits>
35 class accelerator_view;
65 #endif // #ifdef __HCC__
98 uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ,
99 uint32_t localWorkSizeX, uint32_t localWorkSizeY,
100 uint32_t localWorkSizeZ,
size_t sharedMemBytes,
101 hipStream_t hStream,
void** kernelParams,
void** extra,
107 hipError_t hipHccModuleLaunchKernel(
hipFunction_t f, uint32_t globalWorkSizeX,
108 uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ,
109 uint32_t localWorkSizeX, uint32_t localWorkSizeY,
110 uint32_t localWorkSizeZ,
size_t sharedMemBytes,
111 hipStream_t hStream,
void** kernelParams,
void** extra,
116 #if defined(__HIP_ROCclr__) && defined(__cplusplus)
118 extern "C" hipError_t hipExtLaunchKernel(
const void* function_address,
dim3 numBlocks,
119 dim3 dimBlocks,
void** args,
size_t sharedMemBytes,
123 template <
typename... Args,
typename F = void (*)(Args...)>
124 inline void hipExtLaunchKernelGGL(F kernel,
const dim3& numBlocks,
const dim3& dimBlocks,
128 constexpr
size_t count =
sizeof...(Args);
129 auto tup_ = std::tuple<Args...>{args...};
130 auto tup = validateArgsCountType(kernel, tup_);
132 pArgs<0>(tup, _Args);
134 auto k =
reinterpret_cast<void*
>(kernel);
135 hipExtLaunchKernel(k, numBlocks, dimBlocks, _Args, sharedMemBytes, stream, startEvent,
136 stopEvent, (
int)flags);
138 #elif defined(__HIP_PLATFORM_HCC__) && GENERIC_GRID_LAUNCH == 1 && defined(__HCC__)
143 __attribute__((visibility(
"hidden")))
144 void hipExtLaunchKernelGGLImpl(
145 std::uintptr_t function_address,
146 const
dim3& numBlocks,
147 const
dim3& dimBlocks,
148 std::uint32_t sharedMemBytes,
155 const auto& kd = hip_impl::get_program_state()
156 .kernel_descriptor(function_address, target_agent(stream));
159 numBlocks.y * dimBlocks.y,
160 numBlocks.z * dimBlocks.z,
161 dimBlocks.x, dimBlocks.y, dimBlocks.z,
162 sharedMemBytes, stream,
nullptr, kernarg,
163 startEvent, stopEvent, flags);
167 template <
typename... Args,
typename F = void (*)(Args...)>
169 void hipExtLaunchKernelGGL(F kernel,
const dim3& numBlocks,
170 const dim3& dimBlocks, std::uint32_t sharedMemBytes,
174 hip_impl::hip_init();
176 hip_impl::make_kernarg(kernel, std::tuple<Args...>{std::move(args)...});
177 std::size_t kernarg_size = kernarg.size();
180 HIP_LAUNCH_PARAM_BUFFER_POINTER,
182 HIP_LAUNCH_PARAM_BUFFER_SIZE,
184 HIP_LAUNCH_PARAM_END};
186 hip_impl::hipExtLaunchKernelGGLImpl(
reinterpret_cast<std::uintptr_t
>(kernel),
187 numBlocks, dimBlocks, sharedMemBytes,
188 stream, startEvent, stopEvent, flags,
191 #endif // !__HIP_ROCclr__ && defined(__cplusplus)
197 #endif // #iidef HIP_INCLUDE_HIP_HIP_EXT_H