【问题标题】:C++: confusing variadic template causing "candidate function not viable" errorC++:混淆可变参数模板导致“候选函数不可行”错误
【发布时间】:2019-08-19 17:23:21
【问题描述】:

我试图将 CUDA 项目移植到广泛使用 C++ 模板的 ROCm 平台。在此过程中,我收到以下编译错误

/root/warp-ctc/include/detail/gpu_ctc.h:381:5: error: no matching function for call to 'hipLaunchKernelGGL'
    hipLaunchKernelGGL((prepare_stable_SM_kernel<ProbT, VT>), dim3(grid_size), dim3(NT), 0, stream_, ctc_helper::identity<ProbT>(), probs_,
    ^~~~~~~~~~~~~~~~~~
.....
.....
/opt/rocm/hip/include/hip/hcc_detail/functional_grid_launch.hpp:138:13: note: candidate function [with Args = <ctc_helper::identity<float, float>, float *,
      float *, int, int>, F = void (*)(ctc_helper::identity<float, float>, float *, float *, int, int)] not viable: no overload of 'prepare_stable_SM_kernel'
      matching 'void (*)(ctc_helper::identity<float, float>, float *, float *, int, int)' for 1st argument
inline void hipLaunchKernelGGL(F kernel, const dim3& numBlocks, const dim3& dimBlocks,

following piece of C++ code

hipLaunchKernelGGL((prepare_stable_SM_kernel<ProbT, VT>),
                   dim3(grid_size),
                   dim3(NT),
                   0,
                   stream_,
                   ctc_helper::identity<ProbT>(),
                   probs_,
                   denoms_,
                   out_dim_,
                   num_elements);

hipLaunchKernelGGLdefined as

template <typename... Args, typename F = void (*)(Args...)>
inline void hipLaunchKernelGGL(F kernel,
                               const dim3& numBlocks,
                               const dim3& dimBlocks,
                               std::uint32_t sharedMemBytes,
                               hipStream_t stream,
                               Args... args) {

// ...
// ...
}

prepare_stable_SM_kerneldefined as

template <typename ProbT, int VT = 1, typename Op>
__global__ void prepare_stable_SM_kernel(Op f, ProbT* probs,
                                         const ProbT* const col_max,
                                         int alphabet_size,
                                         int count) {
// ...
}

请任何人提供一些提示来帮助我解决此问题。

【问题讨论】:

  • 什么是(prepare_stable_SM_kernel&lt;ProbT, VT&gt;)?你能把它变成minimal reproducible example吗?
  • @NathanOliver:事实是,我是 C++11 的初学者,我无法完全理解代码。我已经用prepare_stable_SM_kernel 的定义更新了问题

标签: c++ variadic-templates amd-rocm


【解决方案1】:

通过在prepare_stable_SM_kernel 函数中添加第三个参数ctc_helper::identity&lt;ProbT&gt; 已修复此错误

参考https://github.com/harish2704/warp-ctc/commit/c7ec45febc9c0077ffa35932b3d11a05daf8bf7c#diff-1e372cfc8edab301b6c284e9db8dbf68

【讨论】:

    猜你喜欢
    • 2013-03-20
    • 2021-04-19
    • 2021-12-08
    • 2016-01-12
    • 1970-01-01
    • 2016-04-20
    • 1970-01-01
    • 2021-06-22
    • 2013-02-09
    相关资源
    最近更新 更多