在编译错误时使nvcc输出跟踪 [英] Make nvcc output traces on compile error

查看:225
本文介绍了在编译错误时使nvcc输出跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用nvcc编译一些代码时遇到了一些问题。它严重依赖于模板等,所以错误消息很难阅读。例如目前我收到一封邮件

I have some trouble compiling some code with nvcc. It heavily relies on templates and the like so error messages are hard to read. For example currently I'm getting a message


/usr/include/boost/utility/detail/result_of_iterate.hpp:135:338:
错误:无效使用qualified-name
'std :: allocator_traits< _Alloc> :: propagate_on_container_swap'

/usr/include/boost/utility/detail/result_of_iterate.hpp:135:338: error: invalid use of qualified-name ‘std::allocator_traits<_Alloc>::propagate_on_container_swap’

这不是真的有帮助。没有关于它来自哪里或模板参数是什么的信息。用例如gcc显示一些非常好的输出与候选人和模板参数等。

which is not really helpful. No information on where it came from or what the template arguments were. Compiling with e.g. gcc shows some really nice output with candidates and template arguments etc.

是否可能得到那些与nvcc吗?还是至少对于主机代码?这是不可能用gcc编译,因为cuda函数被使用,不能被消除。

Is it anyhow possible to get those with nvcc too? Or at least for the host code? It is impossible to compile with gcc only as cuda functions are used which can't be eliminated.

这个问题不是关于那个特定的错误,从nvcc获取更多的细节ANY错误。

This question is NOT about that particular error, but on how to get more details from nvcc on ANY error. This one should only serve as an example

精简的工作示例(使用nvcc -std = c ++ 11编译):

Condensed working example (compile with nvcc -std=c++11):

#include <memory>
#include <boost/utility/result_of.hpp>

struct foo{
    int operator()(int x){ return x + 42; }
};
typename boost::result_of < foo(int) >::type
bar(int x){ return foo()(x); }

int main(int argc, char**argv){
  return bar(argc);
}

或更少的代码:

template<typename T>
struct TriggerError{

private:
    template<typename _Tp>
    static float helper(_Tp*);
    static int   helper(...);
    typedef decltype(helper((T*)0)) privateWrong;

public:
  typedef privateWrong SomethingWentWrong;
};

#include <boost/utility/result_of.hpp>

struct foo{
    int operator()(int x){ return x + 42; }
};

typename boost::result_of < foo(int) >::type
bar(int x){ return foo()(x); }

int main(int argc, char**argv){
  return bar(argc);
}

似乎cudafe ++用TriggerError :: SomethingWentWrong出于某种原因。因此,这似乎是一个CUDA错误。

It seems, that cudafe++ replaces the "type" token with "TriggerError::SomethingWentWrong" for some reason. So this seems to be a CUDA bug.

nvcc --version:Cuda编译工具,版本7.0,V7.0.27

nvcc --version: Cuda compilation tools, release 7.0, V7.0.27

gcc --version:gcc(Ubuntu 4.8.4-2ubuntu1〜14.04)4.8.4

gcc --version: gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4

推荐答案

主要问题:没有标志或任何使nvcc输出更多的模板信息比已经有。显示的错误是语法错误,而不是模板实例化错误,但它是由CUDA 7.0中的错误导致的。

On the main question: There is no flag or anything that makes nvcc output more template information than there already is. The error shown is a syntax error rather than a template instantiation error but it is caused by a bug in CUDA 7.0.

有关错误的信息以供参考:

此错误仅在CUDA 7.0中发生。它不是在CUDA 6.5和固定在CUDA 7.5RC及以上。它只影响C ++ 11编译模式(试图编译上述代码在C ++ 98中应该失败)该错误也只发生在boost 1.5x(可能是1.50最新的1.52),其中decltype用法boost :: result_of引入。更小的示例:编译错误与nvcc和c + +11,需要最小失败示例

Information on the bug for reference:
The bug occurs only in CUDA 7.0. It was not there in CUDA 6.5 and is fixed in CUDA 7.5RC and up. It only affects C++11 compilation mode (trying to compile the above code in C++98 is supposed to fail) The bug also occurs only with boost 1.5x (possibly 1.50 latest 1.52) where the decltype usage for boost::result_of was introduced. A more minimal example: Compilation error with nvcc and c++11, need minimal failing example

有3种可能的解决方法:

There are 3 possible work-arounds:


  1. 使用 std :: result_of (c ++ 11)

  2. 包括 boost / utility / result_of.hpp> 作为第一个include

  3. 使用boost TR1协议并定义 BOOST_RESULT_OF_USE_TR1

  1. Use std::result_of (c++11)
  2. Include <boost/utility/result_of.hpp> as the very first include
  3. Use the boost TR1 protocol and define BOOST_RESULT_OF_USE_TR1

这篇关于在编译错误时使nvcc输出跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆