【问题标题】:Uncrustify command for CUDA kernelCUDA 内核的 Uncrustify 命令
【发布时间】:2015-07-10 08:30:10
【问题描述】:

我想将uncrustify(通过 Atom 编辑器中的美化和配置文件)应用于 CUDA 代码。但是,我不知道如何告诉 uncrustify 识别具有以下结构的 CUDA 内核调用:

kernelName <<<N,M>>> (arg0,arg1,...);

但是,uncrustify 与 &lt;&lt;&lt; &gt;&gt;&gt; 存在问题,应用它会产生以下令人不快的结果

kernelName << < N, M >> >
    (arg0,arg1,...);

我想让它看起来更像一个函数调用,并避免将&lt;&lt;&lt; 格式化为&lt;&lt; &lt;。理想情况下,结果应该是这样的

kernelName <<< N, M >>> (arg0,arg1,
      ...); // line break if argument list is too long

我可以在config.cfg 中添加哪些参数来实现上述结果?

非常感谢。

【问题讨论】:

    标签: cuda code-formatting uncrustify


    【解决方案1】:

    查看 uncrustify 的整个文档,我发现了 2 个可能影响您的 CUDA 内核样式的参数:

    sp_compare                                { Ignore, Add, Remove, Force     }
     Add or remove space around compare operator '<', '>', '==', etc
    

    还有:

    align_left_shift                          { False, True }
      Align lines that start with '<<' with previous '<<'. Default=true
    

    您可以尝试使用这些参数以更接近解决方案,尽管我会尝试类似的方法:

    sp_compare     =   Remove
    align_left_shift   = False
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-28
      • 2011-03-23
      • 1970-01-01
      • 2015-05-17
      • 2021-02-07
      • 1970-01-01
      • 2013-03-17
      • 2011-10-22
      相关资源
      最近更新 更多