HIP is the AMD GPU programming model corresponding to the NVIDIA's CUDA. I have a code snippet from HIP source code that I can't fully understand. As a reminder, the understanding of the following code snippnet doesn't require any background knowledge of HIP, but more of a question in C++ template/function pointer.
typedef int hipLaunchParm;
template <typename... Args, typename F = void (*)(hipLaunchParm, Args...)>
inline void hipLaunchKernel(F&& kernel, const dim3& numBlocks, const dim3& dimBlocks,
std::uint32_t groupMemBytes, hipStream_t stream, Args... args)
{
hipLaunchKernelGGL(kernel, numBlocks, dimBlocks, groupMemBytes, stream,
hipLaunchParm{}, std::move(args)...);
}
I'm confused about the following:
- If F is a function pointer, why does it need to be double referenced in the argument?
- How is the first template argument
typename... Args
useful? - hipLaunchParm is just an alias for integer, but what is the meaning of {} when it is called in the argument?