0

TotalView を使用していますが、MPI_Error が発生します。ただし、Totalview はこのエラーで停止せず、どこで発生しているのかわかりません。これはGDBにも当てはまると思います。

4

1 に答える 1

0

MPI_ErrHandler を定義します。デフォルトの MPI ハンドラーの代わりに呼び出され、そこにブレークポイントを設定できます。MPI エラーと同じものを出力する方法、またはより良い情報を出力する方法についての提案を歓迎します。

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:

#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( ); 
}
于 2010-05-21T19:54:28.063 に答える