LAMA
/home/brandes/workspace/LAMA/src/lama/mpi/MPIUtils.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_MPIUTILS_HPP_
00034 #define LAMA_MPIUTILS_HPP_
00035 
00036 #include <lama/mpi/MPIException.hpp>
00037 
00038 #include <sstream>
00039 #include <mpi.h>
00040 
00041 #ifdef LAMACHECKASSERTS
00042 
00043 #define LAMA_MPICALL(logger,exp,msg)                                                 \
00044     {                                                                               \
00045         LAMA_LOG_TRACE(logger, "MPI call " << msg);                                      \
00046         int status = exp;                                                           \
00047         LAMA_LOG_TRACE(logger, "MPI call " << msg  << ", status = " << status);          \
00048         if (status != MPI_SUCCESS)                                                  \
00049         {                                                                           \
00050             std::ostringstream errorStr;                                            \
00051             errorStr<<"MPI error in line "<<__LINE__;                               \
00052             errorStr<<" of file "<<__FILE__<<": ";                                  \
00053             errorStr<<msg<<"\n";                                                    \
00054             lama::Exception::addCallStack( errorStr );                              \
00055             fprintf(stderr, "%s\n", errorStr.str().c_str() );                       \
00056             throw MPIException(errorStr.str(),status);                              \
00057         }                                                                           \
00058     }
00059 #else
00060 #define LAMA_MPICALL(logger,exp,msg) exp
00061 #endif //LAMACHECKASSERTS
00062 
00063 #endif // LAMA_MPIUTILS_HPP_