MPI错误后如何在TotalView中停止? [英] How do you stop in TotalView after an MPI Error?

查看:129
本文介绍了MPI错误后如何在TotalView中停止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TotalView并收到MPI_Error.但是,Totalview不会在此错误上停止,我无法找到它发生的位置.我相信这也适用于GDB.

I am using TotalView and am getting an MPI_Error. However, Totalview does not stop on this error and I can't find where it is occurring. I believe this also applies to GDB.

推荐答案

定义MPI_ErrHandler.它会代替默认的MPI处理程序被调用,您可以在此处设置一个断点.欢迎提供有关如何使它打印与MPI错误相同的信息的建议,或者提供更多更好的信息.

Define an MPI_ErrHandler. It gets called in place of the default MPI handler and you can set a breakpoint there. Suggestions welcome on how to get it to print the same thing as the MPI error, or better yet, more information.

MPIErrorHander.hpp:

MPIErrorHander.hpp:

#define MPIERRORHANDLER_HPP

#ifdef mpi

#include <stdexcept>
#include <string>
#include <mpi.h>

namespace MPIErrorHandler {
  //subclass so we can specifically catch MPI errors 
  class Exception : public std::exception {
  public:
    Exception(std::string const& what) : std::exception(), m_what(what) { }
    virtual ~Exception() throw() { }
    virtual const char* what() const throw() {
      return m_what.c_str( );
    }

  protected:
    std::string m_what;
  };

  void convertToException( MPI_Comm *comm, int *err, ... );
}

#endif // mpi

#endif // MPIERRORHANDLER_HPP

MPIErrorHandler.cpp:

MPIErrorHandler.cpp:

#ifdef mpi

#include "MPIErrorHandler.hpp"

void MPIErrorHandler::convertToException( MPI_Comm *comm, int *err, ... ) {
  throw Exception(std::string("MPI Error.")); 
}

#endif //mpi

main.cpp:

#include "MPIErrorHandler.hpp"

{
    MPI_Errhandler mpiErrorHandler;

  MPI_Init( &argc, &argv );

  //Set this up so we always get an exception that will stop TV

  MPI_Errhandler_create( MPIErrorHandler::convertToException, 
              &mpiErrorHandler );
  MPI_Errhandler_set( MPI_COMM_WORLD, mpiErrorHandler );

    // Your program here.

    MPI_Finalize( ); 
}

这篇关于MPI错误后如何在TotalView中停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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