PlayaErrorPolling.cpp

00001 // @HEADER
00002 // @HEADER
00003 
00004 #include "PlayaErrorPolling.hpp"
00005 #include "PlayaMPIComm.hpp"
00006 
00007 namespace Playa
00008 {
00009   void ErrorPolling::reportFailure(const MPIComm& comm)
00010   {
00011     if (isActive())
00012       {
00013         int myBad = 1;
00014         int anyBad = 0;
00015         comm.allReduce((void*) &myBad, (void*) &anyBad, 1, MPIDataType::intType(),
00016                        MPIOp::sumOp());
00017       }
00018   }
00019 
00020   bool ErrorPolling::pollForFailures(const MPIComm& comm)
00021   {
00022     /* bypass if inactive */
00023     if (!isActive()) return true;
00024 
00025     int myBad = 0;
00026     int anyBad = 0;
00027     try
00028       {
00029         comm.allReduce((void*) &myBad, (void*) &anyBad, 1, MPIDataType::intType(),
00030                        MPIOp::sumOp());
00031       }
00032     catch(const std::exception&)
00033       {
00034         return true;
00035       }
00036     return anyBad > 0;
00037   }
00038 }
00039 
00040 
00041 
00042   
00043 
00044 
00045 
00046 
00047 

doxygen