Как вы останавливаетесь в TotalView после ошибки MPI? - PullRequest
0 голосов
/ 21 мая 2010

Я использую TotalView и получаю MPI_Error.Тем не менее, Totalview не останавливается на этой ошибке, и я не могу найти, где это происходит.Я считаю, что это также относится к GDB.

1 Ответ

0 голосов
/ 21 мая 2010

Определить 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( ); 
}
...